drivers: soc: xilinx: Add support for ZynqMP PM driver
Subsystems (2)
v2 cover drivers: soc: xilinx: Add support for ZynqMP PM driver
Add ZynqMP PM driver. PM driver provides power management support for ZynqMP.
This patch series is based on top of Xilinx firmware patch set:
https://patchwork.kernel.org/cover/10555405/
v2:
- Rebased on top of latest firmware driver patch series
- Updated driver to use shared interrupt instead of mailbox
Rajan Vaja (3):
dt-bindings: soc: Add ZynqMP PM bindings
firmware: xilinx: Implement ZynqMP power management APIs
drivers: soc: xilinx: Add ZynqMP PM driver
.../firmware/xilinx/xlnx,zynqmp-firmware.txt | 16 ++ drivers/firmware/xilinx/zynqmp.c | 29 +++ drivers/soc/xilinx/Kconfig | 11 + drivers/soc/xilinx/Makefile | 1 + drivers/soc/xilinx/zynqmp_power.c | 230 +++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 20 ++ 6 files changed, 307 insertions(+) create mode 100644 drivers/soc/xilinx/zynqmp_power.c
Signature · 1 line
2.7.4
PATCH v2 1/3 dt-bindings: soc: Add ZynqMP PM bindings
From: Rajan Vaja <[email protected]>
Add documentation to describe Xilinx ZynqMP power management bindings.
--- .../bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +16 -0
@@ -64,6 +64,17 @@ Output clocks are registered based on clock information received from firmware. Output clocks indexes are mentioned in include/dt-bindings/clock/xlnx,zynqmp-clk.h. +-------------------------------------------------------------------- +Device Tree Bindings for the Xilinx Zynq MPSoC Power Management +-------------------------------------------------------------------- +The zynqmp-power node describes the power management configurations. +It will control remote suspend/shutdown interfaces. + +Required properties: + - compatible: Must contain: "xlnx,zynqmp-power" + - interrupt-parent: Interrupt controller the interrupt is routed through + - interrupts: Interrupt specifier + ------- Example -------
@@ -78,5 +89,10 @@ firmware { clocks = <&pss_ref_clk>, <&video_clk>, <&pss_alt_ref_clk>, <&aux_ref_clk>, <>_crx_ref_clk>; clock-names = "pss_ref_clk", "video_clk", "pss_alt_ref_clk","aux_ref_clk", "gt_crx_ref_clk"; }; + zynqmp_power: zynqmp-power { + compatible = "xlnx,zynqmp-power"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + }; }; };
Signature · 1 line
2.7.4
PATCH v2 2/3 firmware: xilinx: Implement ZynqMP power management APIs
In reply to Jolly ShahFrom: Rajan Vaja <[email protected]>
Add Xilinx ZynqMP firmware APIs to set suspend mode and inform firmware that master has initialized its own power management.
--- drivers/firmware/xilinx/zynqmp.c | 29 +++++++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+)
drivers/firmware/xilinx/zynqmp.c +29 -0
@@ -447,6 +447,33 @@ static int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id)return ret; } +/** +* zynqmp_pm_init_finalize() - PM call to inform firmware that the caller +* master has initialized its own power management +* +* This API function is to be used for notify the power management controller +* about the completed power management initialization. +* +* Return: Returns status, either success or error+reason +*/ +static int zynqmp_pm_init_finalize (void ) +{ +return zynqmp_pm_invoke_fn (PM_PM_INIT_FINALIZE ,0 ,0 ,0 ,0 ,NULL ); +} + +/** +* zynqmp_pm_set_suspend_mode() - Set system suspend mode +* @mode: Mode to set for system suspend +* +* This API function is used to set mode of system suspend. +* +* Return: Returns status, either success or error+reason +*/ +static int zynqmp_pm_set_suspend_mode (u32 mode) +{ +return zynqmp_pm_invoke_fn (PM_SET_SUSPEND_MODE , mode,0 ,0 ,0 ,NULL ); +} +static const struct zynqmp_eemi_ops eemi_ops = { .get_api_version = zynqmp_pm_get_api_version, .ioctl = zynqmp_pm_ioctl,
@@ -460,6 +487,8 @@ static const struct zynqmp_eemi_ops eemi_ops = { .clock_getrate = zynqmp_pm_clock_getrate, .clock_setparent = zynqmp_pm_clock_setparent, .clock_getparent = zynqmp_pm_clock_getparent, + .init_finalize = zynqmp_pm_init_finalize, + .set_suspend_mode = zynqmp_pm_set_suspend_mode, };/**
include/linux/firmware/xlnx-zynqmp.h +20 -0
@@ -28,12 +28,21 @@/* SMC SIP service Call Function Identifier Prefix */ #define PM_SIP_SVC 0xC2000000#define PM_GET_TRUSTZONE_VERSION 0xa03 +#define PM_SET_SUSPEND_MODE 0xa02 +#define GET_CALLBACK_DATA 0xa01/* Number of 32bits values in payload */ #define PAYLOAD_ARG_CNT 4U +/* Number of arguments for a callback */ +#define CB_ARG_CNT 4 + +/* Payload size (consists of callback API ID + arguments) */ +#define CB_PAYLOAD_SIZE (CB_ARG_CNT + 1) +enum pm_api_id {PM_GET_API_VERSION =1 , +PM_PM_INIT_FINALIZE =21 ,PM_IOCTL =34 ,PM_QUERY_DATA ,PM_CLOCK_ENABLE ,
@@ -75,6 +84,12 @@ enum pm_query_id { PM_QID_CLOCK_GET_NUM_CLOCKS = 12, }; +enum zynqmp_pm_suspend_reason { +ZYNQMP_PM_SUSPEND_REASON_POWER_UNIT_REQUEST =201 , +ZYNQMP_PM_SUSPEND_REASON_ALERT , +ZYNQMP_PM_SUSPEND_REASON_SYSTEM_SHUTDOWN , +}; +/** * struct zynqmp_pm_query_data - PM query data * @qid: query ID
@@ -102,8 +117,13 @@ struct zynqmp_eemi_ops {int (*clock_getrate)(u32 clock_id,u64 *rate);int (*clock_setparent)(u32 clock_id,u32 parent_id);int (*clock_getparent)(u32 clock_id,u32 *parent_id); +int (*init_finalize)(void ); +int (*set_suspend_mode)(u32 mode); }; +int zynqmp_pm_invoke_fn (u32 pm_api_id,u32 arg0,u32 arg1, +u32 arg2,u32 arg3,u32 *ret_payload); +#if IS_REACHABLE (CONFIG_ARCH_ZYNQMP )const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops (void );#else
Signature · 1 line
2.7.4
PATCH v2 3/3 drivers: soc: xilinx: Add ZynqMP PM driver
In reply to Jolly ShahFrom: Rajan Vaja <[email protected]>
Add ZynqMP PM driver. PM driver provides power management support for ZynqMP.
--- drivers/soc/xilinx/Kconfig | 11 ++ drivers/soc/xilinx/Makefile | 1 + drivers/soc/xilinx/zynqmp_power.c | 230 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 242 insertions(+) create mode 100644 drivers/soc/xilinx/zynqmp_power.c
drivers/soc/xilinx/Kconfig +11 -0
@@ -17,4 +17,15 @@ config XILINX_VCU To compile this driver as a module, choose M here: the module will be called xlnx_vcu. +config ZYNQMP_POWER + bool "Enable Xilinx Zynq MPSoC Power Management driver" + depends on PM && ARCH_ZYNQMP + default y + help + Say yes to enable power management support for ZyqnMP SoC. + This driver uses firmware driver as an interface for power + management request to firmware. It registers isr to handle + power management callbacks from firmware. + If in doubt, say N. + endmenu
drivers/soc/xilinx/Makefile +1 -0
@@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_XILINX_VCU) += xlnx_vcu.o +obj-$(CONFIG_ZYNQMP_POWER) += zynqmp_power.o
drivers/soc/xilinx/zynqmp_power.c new file +230 -0
230 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v2 1/3] dt-bindings: soc: Add ZynqMP PM bindings
In reply to Jolly ShahQuoted 18 lines · Jolly Shah
From: Rajan Vaja <[email protected]>
Add documentation to describe Xilinx ZynqMP power management bindings.
Signed-off-by Rajan Vaja <[email protected]>Signed-off-by Jolly Shah <[email protected]>--- .../bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +0
-0@@ -64,6 +64,17 @@ Output clocks are registered based on clock information received from firmware. Output clocks indexes are mentioned in include/dt-bindings/clock/xlnx,zynqmp-clk.h.
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt Output clocks are registered based on clock information received · line 75
Quoted 10 lines
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +9
-0+-------------------------------------------------------------------- +Device Tree Bindings for the Xilinx Zynq MPSoC Power Management +-------------------------------------------------------------------- +The zynqmp-power node describes the power management configurations. +It will control remote suspend/shutdown interfaces. + +Required properties: + - compatible: Must contain: "xlnx,zynqmp-power" + - interrupt-parent: Interrupt controller the interrupt is routed through
interrupt-parent is implied and could be in a parent node, so remove.
With that,
Quoted 19 lines
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +7
-0+ - interrupts: Interrupt specifier + ------- Example -------@@ -78,5 +89,10 @@ firmware { clocks = <&pss_ref_clk>, <&video_clk>, <&pss_alt_ref_clk>, <&aux_ref_clk>, <>_crx_ref_clk>; clock-names = "pss_ref_clk", "video_clk", "pss_alt_ref_clk","aux_ref_clk", "gt_crx_ref_clk"; }; + zynqmp_power: zynqmp-power { + compatible = "xlnx,zynqmp-power"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + }; }; };Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH v2 1/3] dt-bindings: soc: Add ZynqMP PM bindings
Quoted 10 lines · Rob Herring
Quoted 9 lines · Jolly Shah
From: Rajan Vaja <[email protected]>
Add documentation to describe Xilinx ZynqMP power management bindings.
Signed-off-by Rajan Vaja <[email protected]>Signed-off-by Jolly Shah <[email protected]>--- .../bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt | 16 ++++++++++++++++
Also, this should be located in bindings/power/reset/
Quoted 45 lines
Quoted 9 lines
1 file changed, 16 insertions(+)Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +0
-0@@ -64,6 +64,17 @@ Output clocks are registered based on clock information received from firmware. Output clocks indexes are mentioned in include/dt-bindings/clock/xlnx,zynqmp-clk.h.Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt Output clocks are registered based on clock information received · line 75
Quoted 10 lines
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +9
-0+-------------------------------------------------------------------- +Device Tree Bindings for the Xilinx Zynq MPSoC Power Management +-------------------------------------------------------------------- +The zynqmp-power node describes the power management configurations. +It will control remote suspend/shutdown interfaces. + +Required properties: + - compatible: Must contain: "xlnx,zynqmp-power" + - interrupt-parent: Interrupt controller the interrupt is routed throughinterrupt-parent is implied and could be in a parent node, so remove.
With that,
Reviewed-by Rob Herring <[email protected]>Quoted 19 lines
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +7
-0+ - interrupts: Interrupt specifier + ------- Example -------@@ -78,5 +89,10 @@ firmware { clocks = <&pss_ref_clk>, <&video_clk>, <&pss_alt_ref_clk>, <&aux_ref_clk>, <>_crx_ref_clk>; clock-names = "pss_ref_clk", "video_clk", "pss_alt_ref_clk","aux_ref_clk", "gt_crx_ref_clk"; }; + zynqmp_power: zynqmp-power { + compatible = "xlnx,zynqmp-power"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + }; }; };Signature · 1 line
2.7.4
RE: [PATCH v2 1/3] dt-bindings: soc: Add ZynqMP PM bindings
Hi Rob,
Quoted 20 lines
-----Original Message-----
From: Rob Herring [mailto:robh at kernel.org]
Sent: Monday, August 20, 2018 12:49 PM
To: Jolly Shah <[email protected]>
Cc: matthias.bgg at gmail.com; andy.gross at linaro.org; shawnguo at kernel.org; geert+renesas at glider.be; bjorn.andersson at linaro.org; sean.wang at mediatek.com; m.szyprowski at samsung.com; Michal Simek <[email protected]>; mark.rutland at arm.com; Rajan Vaja <[email protected]>; devicetree at vger.kernel.org; linux-arm- kernel at lists.infradead.org; linux-kernel at vger.kernel.org; Rajan Vaja <[email protected]>; Jolly Shah <[email protected]>
Subject: Re: [PATCH v2 1/3] dt-bindings: soc: Add ZynqMP PM bindingsQuoted 6 lines · Rob Herring
Quoted 5 lines · Jolly Shah
From: Rajan Vaja <[email protected]>
Add documentation to describe Xilinx ZynqMP power management bindings.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Rajan Vaja <[email protected]>Signed-off-by Jolly Shah <[email protected]>--- .../bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt | 16++++++++++++++++
Also, this should be located in bindings/power/reset/
Base firmware node has clock subnode too. Do you still suggest to move bindings to "bindings/power/reset/" or keep it under "bindings/firmware" ?
Thanks,
Jolly Shah
Quoted 56 lines
Quoted 35 lines
Quoted 22 lines
1 file changed, 16 insertions(+)diff --git a/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firm ware.txt b/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firm ware.txt
index d215d15..cb9a6b7 100644
---
a/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firm ware.txt
+++ b/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp- +++ firmware.txt(quoted diff) +0
-0@@ -64,6 +64,17 @@ Output clocks are registered based on clockinformation received from firmware. Output clocks indexes are mentioned in
include/dt-bindings/clock/xlnx,zynqmp-clk.h.+------------------------------------------------------------------- +- Device Tree Bindings for the Xilinx Zynq MPSoC Power Management +------------------------------------------------------------------- +- The zynqmp-power node describes the power managementDocumentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt Output clocks are registered based on clock information received · line 75
Quoted 6 lines
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +6
-0+configurations. +It will control remote suspend/shutdown interfaces. + +Required properties: + - compatible: Must contain: "xlnx,zynqmp-power" + - interrupt-parent: Interrupt controller the interrupt is routed throughinterrupt-parent is implied and could be in a parent node, so remove.
With that,
Reviewed-by Rob Herring <[email protected]>Quoted 7 lines
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt firmware { · line 89
Quoted 7 lines
+ - interrupts: Interrupt specifier
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +1
-0+ ------- Example -------@@ -78,5 +89,10 @@ firmware { clocks = <&pss_ref_clk>, <&video_clk>,<
&pss_alt_ref_clk>, <&aux_ref_clk>, <>_crx_ref_clk>;Quoted 1 line
Review firmware { · line 90
Quoted 1 line
(quoted diff) +0
-0clock-names = "pss_ref_clk", "video_clk","pss_alt_ref_clk","aux_ref_clk", "
gt_crx_ref_clk";Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.txt +5
-1}; + zynqmp_power: zynqmp-power { + compatible = "xlnx,zynqmp-power"; + interrupt-parent = <&gic>; + interrupts = <0 35 4>; + }; }; }; --2.7.4