drivers: soc: xilinx: Add support for ZynqMP power domain driver
Subsystems (2)
v4 cover drivers: soc: xilinx: Add support for ZynqMP power domain driver
The zynqmp power domain driver communicates the usage requirements for logical power domains / devices to the platform FW. FW is responsible for choosing appropriate power states, taking Linux' usage information into account.
v4:
- Added reviewed tag for dt bindings
- Remove local device list for each domain and use list maintained in core genpd structure
- Remove hardcoded pd-id to node ID mapping. Instead use argument passed in peripheral node as node ID. Firmware would validate node ID when APIs requested from genpd ops.
v3:
- Changed binding to have FW node as a power controller as suggested by Rob
- Updated FW driver to register it as mfd child devices from firmware probe
- Move bindings location as suggested
v2:
- Rebased on top of latest firmware driver patch series
- Updated driver name from zynqmp-genpd to zynqmp-power-controller
- Updated device tree bindings to move power controller node under firmware node
Jolly Shah (1):
drivers: soc: xilinx: Add ZynqMP power domain driver
Rajan Vaja (2):
dt-bindings: power: Add ZynqMP power domain bindings
firmware: xilinx: Add APIs to control node status/power
.../bindings/power/xlnx,zynqmp-genpd.txt | 34 +++ drivers/firmware/xilinx/Kconfig | 1 + drivers/firmware/xilinx/zynqmp.c | 73 +++++ drivers/soc/xilinx/Kconfig | 9 + drivers/soc/xilinx/Makefile | 1 + drivers/soc/xilinx/zynqmp_pm_domains.c | 321 +++++++++++++++++++++ include/dt-bindings/power/xlnx-zynqmp-power.h | 39 +++ include/linux/firmware/xlnx-zynqmp.h | 26 ++ 8 files changed, 504 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/xlnx,zynqmp-genpd.txt create mode 100644 drivers/soc/xilinx/zynqmp_pm_domains.c create mode 100644 include/dt-bindings/power/xlnx-zynqmp-power.h
Signature · 1 line
2.7.4
PATCH v4 1/3 dt-bindings: power: Add ZynqMP power domain bindings
From: Rajan Vaja <[email protected]>
Add documentation to describe ZynqMP power domain bindings.
--- .../bindings/power/xlnx,zynqmp-genpd.txt | 34 +++++++++++++++++++ include/dt-bindings/power/xlnx-zynqmp-power.h | 39 ++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/xlnx,zynqmp-genpd.txt create mode 100644 include/dt-bindings/power/xlnx-zynqmp-power.h
Documentation/devicetree/bindings/power/xlnx,zynqmp-genpd.txt new file +34 -0
@@ -0,0 +1,34 @@ +----------------------------------------------------------- +Device Tree Bindings for the Xilinx Zynq MPSoC PM domains +----------------------------------------------------------- +The binding for zynqmp-power-controller follow the common +generic PM domain binding[1]. + +[1] Documentation/devicetree/bindings/power/power_domain.txt + +== Zynq MPSoC Generic PM Domain Node == + +Required property: + - Below property should be in zynqmp-firmware node. + - #power-domain-cells: Number of cells in a PM domain specifier. Must be 1. + +Power domain ID indexes are mentioned in +include/dt-bindings/power/xlnx-zynqmp-power.h. + +------- +Example +------- + +firmware { + zynqmp_firmware: zynqmp-firmware { + ... + #power-domain-cells = <1>; + ... + }; +}; + +sata { + ... + power-domains = <&zynqmp_firmware 28>; + ... +};
include/dt-bindings/power/xlnx-zynqmp-power.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2018 Xilinx, Inc. +*/ + +#ifndef _DT_BINDINGS_ZYNQMP_POWER_H +#define _DT_BINDINGS_ZYNQMP_POWER_H + +#define PD_USB_0 22 +#define PD_USB_1 23 +#define PD_TTC_0 24 +#define PD_TTC_1 25 +#define PD_TTC_2 26 +#define PD_TTC_3 27 +#define PD_SATA 28 +#define PD_ETH_0 29 +#define PD_ETH_1 30 +#define PD_ETH_2 31 +#define PD_ETH_3 32 +#define PD_UART_0 33 +#define PD_UART_1 34 +#define PD_SPI_0 35 +#define PD_SPI_1 36 +#define PD_I2C_0 37 +#define PD_I2C_1 38 +#define PD_SD_0 39 +#define PD_SD_1 40 +#define PD_DP 41 +#define PD_GDMA 42 +#define PD_ADMA 43 +#define PD_NAND 44 +#define PD_QSPI 45 +#define PD_GPIO 46 +#define PD_CAN_0 47 +#define PD_CAN_1 48 +#define PD_GPU 58 +#define PD_PCIE 59 + +#endif
Signature · 1 line
2.7.4
PATCH v4 2/3 firmware: xilinx: Add APIs to control node status/power
In reply to Jolly ShahFrom: Rajan Vaja <[email protected]>
Add Xilinx ZynqMP firmware APIs to control node status and power. These APIs allows turning on/off power domain and setting capabilities of devices present in power domain.
--- drivers/firmware/xilinx/zynqmp.c | 58 ++++++++++++++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 26 ++++++++++++++++ 2 files changed, 84 insertions(+)
drivers/firmware/xilinx/zynqmp.c +58 -0
@@ -534,6 +534,61 @@ static int zynqmp_pm_set_suspend_mode(u32 mode)return zynqmp_pm_invoke_fn (PM_SET_SUSPEND_MODE , mode,0 ,0 ,0 ,NULL ); } +/** +* zynqmp_pm_request_node() - Request a node with specific capabilities +* @node: Node ID of the slave +* @capabilities: Requested capabilities of the slave +* @qos: Quality of service (not supported) +* @ack: Flag to specify whether acknowledge is requested +* +* This function is used by master to request particular node from firmware. +* Every master must request node before using it. +* +* Return: Returns status, either success or error+reason +*/ +static int zynqmp_pm_request_node (const u32 node,const u32 capabilities, +const u32 qos, +const enum zynqmp_pm_request_ack ack) +{ +return zynqmp_pm_invoke_fn (PM_REQUEST_NODE , node, capabilities, + qos, ack,NULL ); +} + +/** +* zynqmp_pm_release_node() - Release a node +* @node: Node ID of the slave +* +* This function is used by master to inform firmware that master +* has released node. Once released, master must not use that node +* without re-request. +* +* Return: Returns status, either success or error+reason +*/ +static int zynqmp_pm_release_node (const u32 node) +{ +return zynqmp_pm_invoke_fn (PM_RELEASE_NODE , node,0 ,0 ,0 ,NULL ); +} + +/** +* zynqmp_pm_set_requirement() - PM call to set requirement for PM slaves +* @node: Node ID of the slave +* @capabilities: Requested capabilities of the slave +* @qos: Quality of service (not supported) +* @ack: Flag to specify whether acknowledge is requested +* +* This API function is to be used for slaves a PU already has requested +* to change its capabilities. +* +* Return: Returns status, either success or error+reason +*/ +static int zynqmp_pm_set_requirement (const u32 node,const u32 capabilities, +const u32 qos, +const enum zynqmp_pm_request_ack ack) +{ +return zynqmp_pm_invoke_fn (PM_SET_REQUIREMENT , node, capabilities, + qos, ack,NULL ); +} +static const struct zynqmp_eemi_ops eemi_ops = { .get_api_version = zynqmp_pm_get_api_version, .query_data = zynqmp_pm_query_data,
@@ -551,6 +606,9 @@ static const struct zynqmp_eemi_ops eemi_ops = { .reset_get_status = zynqmp_pm_reset_get_status, .init_finalize = zynqmp_pm_init_finalize, .set_suspend_mode = zynqmp_pm_set_suspend_mode, + .request_node = zynqmp_pm_request_node, + .release_node = zynqmp_pm_release_node, + .set_requirement = zynqmp_pm_set_requirement, };/**
include/linux/firmware/xlnx-zynqmp.h +26 -0
@@ -40,8 +40,19 @@/* Payload size (consists of callback API ID + arguments) */ #define CB_PAYLOAD_SIZE (CB_ARG_CNT + 1) +#define ZYNQMP_PM_MAX_QOS 100U + +/* Node capabilities */ +#define ZYNQMP_PM_CAPABILITY_ACCESS 0x1U +#define ZYNQMP_PM_CAPABILITY_CONTEXT 0x2U +#define ZYNQMP_PM_CAPABILITY_WAKEUP 0x4U +#define ZYNQMP_PM_CAPABILITY_POWER 0x8U +enum pm_api_id {PM_GET_API_VERSION =1 , +PM_REQUEST_NODE =13 , +PM_RELEASE_NODE , +PM_SET_REQUIREMENT ,PM_RESET_ASSERT =17 ,PM_RESET_GET_STATUS ,PM_PM_INIT_FINALIZE =21 ,
@@ -223,6 +234,12 @@ enum zynqmp_pm_suspend_reason { SUSPEND_SYSTEM_SHUTDOWN, }; +enum zynqmp_pm_request_ack { +ZYNQMP_PM_REQUEST_ACK_NO =1 , +ZYNQMP_PM_REQUEST_ACK_BLOCKING , +ZYNQMP_PM_REQUEST_ACK_NON_BLOCKING , +}; +/** * struct zynqmp_pm_query_data - PM query data * @qid: query ID
@@ -255,6 +272,15 @@ struct zynqmp_eemi_ops {int (*reset_get_status)(const enum zynqmp_pm_reset reset,u32 *status);int (*init_finalize)(void );int (*set_suspend_mode)(u32 mode); +int (*request_node)(const u32 node, +const u32 capabilities, +const u32 qos, +const enum zynqmp_pm_request_ack ack); +int (*release_node)(const u32 node); +int (*set_requirement)(const u32 node, +const u32 capabilities, +const u32 qos, +const enum zynqmp_pm_request_ack ack); }; int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,
Signature · 1 line
2.7.4
PATCH v4 3/3 drivers: soc: xilinx: Add ZynqMP power domain driver
In reply to Jolly ShahThe zynqmp-genpd driver communicates the usage requirements for logical power domains / devices to the platform FW. FW is responsible for choosing appropriate power states, taking Linux' usage information into account.
--- drivers/firmware/xilinx/Kconfig | 1 + drivers/firmware/xilinx/zynqmp.c | 15 ++ drivers/soc/xilinx/Kconfig | 9 + drivers/soc/xilinx/Makefile | 1 + drivers/soc/xilinx/zynqmp_pm_domains.c | 321 +++++++++++++++++++++++++++++++++ 5 files changed, 347 insertions(+) create mode 100644 drivers/soc/xilinx/zynqmp_pm_domains.c
drivers/firmware/xilinx/Kconfig +1 -0
@@ -6,6 +6,7 @@ menu "Zynq MPSoC Firmware Drivers" config ZYNQMP_FIRMWARE bool "Enable Xilinx Zynq MPSoC firmware interface" + select MFD_CORE help Firmware interface driver is used by different drivers to communicate with the firmware for
drivers/firmware/xilinx/zynqmp.c +15 -0
@@ -14,6 +14,7 @@#include <linux/compiler.h> #include <linux/device.h> #include <linux/init.h> +#include <linux/mfd/core.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_platform.h>
@@ -23,6 +24,12 @@#include <linux/firmware/xlnx-zynqmp.h> #include "zynqmp-debug.h" +static const struct mfd_cell firmware_devs[] = { + { + .name ="zynqmp_power_controller" , + }, +}; +/** * zynqmp_pm_ret_code() - Convert PMU-FW error codes to Linux error codes * @ret_status: PMUFW return code
@@ -665,11 +672,19 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)zynqmp_pm_api_debugfs_init (); + ret =mfd_add_devices (&pdev->dev,PLATFORM_DEVID_NONE , firmware_devs, +ARRAY_SIZE (firmware_devs),NULL ,0 ,NULL ); +if (ret) { +dev_err (&pdev->dev,"failed to add MFD devices %d\n" , ret); +return ret; + } +return of_platform_populate (dev->of_node,NULL ,NULL , dev); }static int zynqmp_firmware_remove (struct platform_device *pdev) { +mfd_remove_devices (&pdev->dev);zynqmp_pm_api_debugfs_exit ();return 0 ;
drivers/soc/xilinx/Kconfig +9 -0
@@ -28,4 +28,13 @@ config ZYNQMP_POWER power management callbacks from firmware. If in doubt, say N. +config ZYNQMP_PM_DOMAINS + bool "Enable Zynq MPSoC generic PM domains" + default y + depends on PM && ARCH_ZYNQMP && ZYNQMP_FIRMWARE + select PM_GENERIC_DOMAINS + help + Say yes to enable device power management through PM domains + If in doubt, say N. + endmenu
drivers/soc/xilinx/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_XILINX_VCU) += xlnx_vcu.o obj-$(CONFIG_ZYNQMP_POWER) += zynqmp_power.o +obj-$(CONFIG_ZYNQMP_PM_DOMAINS) += zynqmp_pm_domains.o
drivers/soc/xilinx/zynqmp_pm_domains.c new file +321 -0
321 lines not on this page · raw message
Signature · 1 line
2.7.4
Michal Simek
AppliedQuoted 28 lines · Jolly Shah
The zynqmp power domain driver communicates the usage requirements for logical power domains / devices to the platform FW. FW is responsible for choosing appropriate power states, taking Linux' usage information into account.
v4:
- Added reviewed tag for dt bindings
- Remove local device list for each domain and use list maintained in core genpd structure
- Remove hardcoded pd-id to node ID mapping. Instead use argument passed in peripheral node as node ID. Firmware would validate node ID when APIs requested from genpd ops.v3:
- Changed binding to have FW node as a power controller as suggested by Rob
- Updated FW driver to register it as mfd child devices from firmware probe
- Move bindings location as suggestedv2:
- Rebased on top of latest firmware driver patch series
- Updated driver name from zynqmp-genpd to zynqmp-power-controller
- Updated device tree bindings to move power controller node under firmware nodeJolly Shah (1):
drivers: soc: xilinx: Add ZynqMP power domain driverRajan Vaja (2):
dt-bindings: power: Add ZynqMP power domain bindings
firmware: xilinx: Add APIs to control node status/power
Quoted 13 lines
.../bindings/power/xlnx,zynqmp-genpd.txt | 34 +++ drivers/firmware/xilinx/Kconfig | 1 + drivers/firmware/xilinx/zynqmp.c | 73 +++++ drivers/soc/xilinx/Kconfig | 9 + drivers/soc/xilinx/Makefile | 1 + drivers/soc/xilinx/zynqmp_pm_domains.c | 321 +++++++++++++++++++++ include/dt-bindings/power/xlnx-zynqmp-power.h | 39 +++ include/linux/firmware/xlnx-zynqmp.h | 26 ++ 8 files changed, 504 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/xlnx,zynqmp-genpd.txt create mode 100644 drivers/soc/xilinx/zynqmp_pm_domains.c create mode 100644 include/dt-bindings/power/xlnx-zynqmp-power.h
Applied.
Thanks,
Michal