diff mbox series

[v2,1/1] xilinx: zynqmp: Enable reset_cpu() in SPL

Message ID 20240604135915.405660-2-lukas.funke-oss@weidmueller.com
State Superseded
Delegated to: Michal Simek
Headers show
Series Enable reset_cpu() in SPL for ZynqMP | expand

Commit Message

Lukas Funke June 4, 2024, 1:59 p.m. UTC
From: Lukas Funke <lukas.funke@weidmueller.com>

This commit enables SPL to reset the CPU via PMU-firmware. The usual
reset mechanism requires bl31 to be loaded which may not be the case in
SPL.

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
---

Changes in v2:
- Drop 2/2 since reworking ZYNQMP_FIRMWARE dependency is out-of-scope

 board/xilinx/zynqmp/zynqmp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Michal Simek June 6, 2024, 2:51 p.m. UTC | #1
On 6/4/24 15:59, lukas.funke-oss@weidmueller.com wrote:
> From: Lukas Funke <lukas.funke@weidmueller.com>
> 
> This commit enables SPL to reset the CPU via PMU-firmware. The usual
> reset mechanism requires bl31 to be loaded which may not be the case in
> SPL.
> 
> Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
> ---
> 
> Changes in v2:
> - Drop 2/2 since reworking ZYNQMP_FIRMWARE dependency is out-of-scope
> 
>   board/xilinx/zynqmp/zynqmp.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index f370fb7347a..a129b1dbbbc 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -40,6 +40,7 @@
>   #include <linux/bitops.h>
>   #include <linux/delay.h>
>   #include <linux/sizes.h>
> +#include <dt-bindings/reset/xlnx-zynqmp-resets.h>
>   #include "../common/board.h"
>   
>   #include "pm_cfg_obj.h"
> @@ -285,6 +286,14 @@ int dram_init(void)
>   #if !CONFIG_IS_ENABLED(SYSRESET)
>   void reset_cpu(void)
>   {
> +	if (!IS_ENABLED(CONFIG_ZYNQMP_FIRMWARE)) {
> +		log_warning("reset failed: ZYNQMP_FIRMWARE disabled");
> +		return;
> +	}
> +
> +	xilinx_pm_request(PM_RESET_ASSERT,
> +			  ZYNQMP_PM_RESET_START + ZYNQMP_RESET_SOFT,

Isn't it easier to use ZYNQMP_PM_RESET_SOFT directly?
Also you can remove that include above to dt binding.

The rest looks good. If you want to make nicer I would put there a comment that 
in case of !CONFIG_ZYNQMP_FIRMWARE xilinx_pm_request is not present compiler 
removes it because of return inside if. If defined in SPL case xilinx_pm_request 
will send command over IPI.

Thanks,
Michal
diff mbox series

Patch

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index f370fb7347a..a129b1dbbbc 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -40,6 +40,7 @@ 
 #include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/sizes.h>
+#include <dt-bindings/reset/xlnx-zynqmp-resets.h>
 #include "../common/board.h"
 
 #include "pm_cfg_obj.h"
@@ -285,6 +286,14 @@  int dram_init(void)
 #if !CONFIG_IS_ENABLED(SYSRESET)
 void reset_cpu(void)
 {
+	if (!IS_ENABLED(CONFIG_ZYNQMP_FIRMWARE)) {
+		log_warning("reset failed: ZYNQMP_FIRMWARE disabled");
+		return;
+	}
+
+	xilinx_pm_request(PM_RESET_ASSERT,
+			  ZYNQMP_PM_RESET_START + ZYNQMP_RESET_SOFT,
+			  PM_RESET_ACTION_ASSERT, 0, 0, NULL);
 }
 #endif