* [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c
@ 2021-08-27 20:57 Adam Ford
2021-08-27 20:57 ` [PATCH 2/2] arm: rmobile: Remove duplicate code from beacon-rzg2m and hihope-rzg2 Adam Ford
2021-08-29 16:22 ` [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c Marek Vasut
0 siblings, 2 replies; 5+ messages in thread
From: Adam Ford @ 2021-08-27 20:57 UTC (permalink / raw)
To: u-boot; +Cc: marek.vasut+renesas, biju.das.jz, Adam Ford
Various RZ/G2[MNH] boards have copies of cpu_reset which
creates duplicate code, so move this to a common file shared
among all users of the RZG2 and declare it weak so it can be
overwritten if necessary.
Signed-off-by: Adam Ford <aford173@gmail.com>
diff --git a/arch/arm/mach-rmobile/Makefile b/arch/arm/mach-rmobile/Makefile
index 195bbeb5c8..2bd173ec3a 100644
--- a/arch/arm/mach-rmobile/Makefile
+++ b/arch/arm/mach-rmobile/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_SH73A0) += lowlevel_init.o cpu_info-sh73a0.o pfc-sh73a0.o
obj-$(CONFIG_R8A7740) += lowlevel_init.o cpu_info-r8a7740.o pfc-r8a7740.o
obj-$(CONFIG_RCAR_GEN2) += lowlevel_init_ca15.o cpu_info-rcar.o
obj-$(CONFIG_RCAR_GEN3) += lowlevel_init_gen3.o cpu_info-rcar.o memmap-gen3.o
-obj-$(CONFIG_RZ_G2) += cpu_info-rzg.o
+obj-$(CONFIG_RZ_G2) += cpu_info-rzg.o rzg2-reset.o
ifneq ($(CONFIG_R8A779A0),)
obj-$(CONFIG_ARMV8_PSCI) += psci-r8a779a0.o
diff --git a/arch/arm/mach-rmobile/rzg2-reset.c b/arch/arm/mach-rmobile/rzg2-reset.c
new file mode 100644
index 0000000000..8c3608f34a
--- /dev/null
+++ b/arch/arm/mach-rmobile/rzg2-reset.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Renesas Electronics Corporation
+ */
+
+#include <asm/io.h>
+
+#define RST_BASE 0xE6160000
+#define RST_CA57RESCNT (RST_BASE + 0x40)
+#define RST_CA53RESCNT (RST_BASE + 0x44)
+#define RST_CA57_CODE 0xA5A5000F
+#define RST_CA53_CODE 0x5A5A000F
+
+__weak void reset_cpu(void)
+{
+ unsigned long midr, cputype;
+
+ asm volatile("mrs %0, midr_el1" : "=r" (midr));
+ cputype = (midr >> 4) & 0xfff;
+
+ if (cputype == 0xd03)
+ writel(RST_CA53_CODE, RST_CA53RESCNT);
+ else
+ writel(RST_CA57_CODE, RST_CA57RESCNT);
+}
+
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] arm: rmobile: Remove duplicate code from beacon-rzg2m and hihope-rzg2
2021-08-27 20:57 [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c Adam Ford
@ 2021-08-27 20:57 ` Adam Ford
2021-08-29 16:22 ` [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c Marek Vasut
1 sibling, 0 replies; 5+ messages in thread
From: Adam Ford @ 2021-08-27 20:57 UTC (permalink / raw)
To: u-boot; +Cc: marek.vasut+renesas, biju.das.jz, Adam Ford
With reset_cpu() now existing in common code, there is no need to
have this exist in each board.
Signed-off-by: Adam Ford <aford173@gmail.com>
diff --git a/board/beacon/beacon-rzg2m/beacon-rzg2m.c b/board/beacon/beacon-rzg2m/beacon-rzg2m.c
index c12ff77fb2..f5146594b5 100644
--- a/board/beacon/beacon-rzg2m/beacon-rzg2m.c
+++ b/board/beacon/beacon-rzg2m/beacon-rzg2m.c
@@ -27,12 +27,3 @@ int board_init(void)
return 0;
}
-
-#define RST_BASE 0xE6160000
-#define RST_CA57RESCNT (RST_BASE + 0x40)
-#define RST_CODE 0xA5A5000F
-
-void reset_cpu(void)
-{
- writel(RST_CODE, RST_CA57RESCNT);
-}
diff --git a/board/hoperun/hihope-rzg2/hihope-rzg2.c b/board/hoperun/hihope-rzg2/hihope-rzg2.c
index c1db387b27..59e124c829 100644
--- a/board/hoperun/hihope-rzg2/hihope-rzg2.c
+++ b/board/hoperun/hihope-rzg2/hihope-rzg2.c
@@ -16,12 +16,6 @@
#include <linux/delay.h>
#include <linux/libfdt.h>
-#define RST_BASE 0xE6160000
-#define RST_CA57RESCNT (RST_BASE + 0x40)
-#define RST_CA53RESCNT (RST_BASE + 0x44)
-#define RST_CA57_CODE 0xA5A5000F
-#define RST_CA53_CODE 0x5A5A000F
-
DECLARE_GLOBAL_DATA_PTR;
#define HSUSB_MSTP704 BIT(4) /* HSUSB */
@@ -65,19 +59,6 @@ int board_init(void)
return 0;
}
-void reset_cpu(void)
-{
- unsigned long midr, cputype;
-
- asm volatile("mrs %0, midr_el1" : "=r" (midr));
- cputype = (midr >> 4) & 0xfff;
-
- if (cputype == 0xd03)
- writel(RST_CA53_CODE, RST_CA53RESCNT);
- else
- writel(RST_CA57_CODE, RST_CA57RESCNT);
-}
-
#if defined(CONFIG_MULTI_DTB_FIT)
/* If the firmware passed a device tree, use it for board identification. */
extern u64 rcar_atf_boot_args[];
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c
2021-08-27 20:57 [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c Adam Ford
2021-08-27 20:57 ` [PATCH 2/2] arm: rmobile: Remove duplicate code from beacon-rzg2m and hihope-rzg2 Adam Ford
@ 2021-08-29 16:22 ` Marek Vasut
2021-08-30 17:52 ` Adam Ford
1 sibling, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2021-08-29 16:22 UTC (permalink / raw)
To: Adam Ford, u-boot; +Cc: biju.das.jz
On 8/27/21 10:57 PM, Adam Ford wrote:
> Various RZ/G2[MNH] boards have copies of cpu_reset which
> creates duplicate code, so move this to a common file shared
> among all users of the RZG2 and declare it weak so it can be
> overwritten if necessary.
RCar3 has the same reset code too, so this could be unified further.
However, I wonder, can't you simply call the PSCI reset ? There is a
PSCI reset driver in drivers/reset/ too I think.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c
2021-08-29 16:22 ` [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c Marek Vasut
@ 2021-08-30 17:52 ` Adam Ford
2021-08-30 17:58 ` Marek Vasut
0 siblings, 1 reply; 5+ messages in thread
From: Adam Ford @ 2021-08-30 17:52 UTC (permalink / raw)
To: Marek Vasut; +Cc: U-Boot Mailing List, Biju Das
On Sun, Aug 29, 2021 at 12:53 PM Marek Vasut <marex@denx.de> wrote:
>
> On 8/27/21 10:57 PM, Adam Ford wrote:
> > Various RZ/G2[MNH] boards have copies of cpu_reset which
> > creates duplicate code, so move this to a common file shared
> > among all users of the RZG2 and declare it weak so it can be
> > overwritten if necessary.
>
> RCar3 has the same reset code too, so this could be unified further.
> However, I wonder, can't you simply call the PSCI reset ? There is a
> PSCI reset driver in drivers/reset/ too I think.
Thanks for the suggestion. I removed the custom cpu_reset code from
the board file, and enabled sysreset and the psci, and that appeared
to still reset when needed.
I'll send a different patch shortly.
adam
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c
2021-08-30 17:52 ` Adam Ford
@ 2021-08-30 17:58 ` Marek Vasut
0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2021-08-30 17:58 UTC (permalink / raw)
To: Adam Ford; +Cc: U-Boot Mailing List, Biju Das
On 8/30/21 7:52 PM, Adam Ford wrote:
> On Sun, Aug 29, 2021 at 12:53 PM Marek Vasut <marex@denx.de> wrote:
>>
>> On 8/27/21 10:57 PM, Adam Ford wrote:
>>> Various RZ/G2[MNH] boards have copies of cpu_reset which
>>> creates duplicate code, so move this to a common file shared
>>> among all users of the RZG2 and declare it weak so it can be
>>> overwritten if necessary.
>>
>> RCar3 has the same reset code too, so this could be unified further.
>> However, I wonder, can't you simply call the PSCI reset ? There is a
>> PSCI reset driver in drivers/reset/ too I think.
>
> Thanks for the suggestion. I removed the custom cpu_reset code from
> the board file, and enabled sysreset and the psci, and that appeared
> to still reset when needed.
>
> I'll send a different patch shortly.
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-30 17:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-27 20:57 [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c Adam Ford
2021-08-27 20:57 ` [PATCH 2/2] arm: rmobile: Remove duplicate code from beacon-rzg2m and hihope-rzg2 Adam Ford
2021-08-29 16:22 ` [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c Marek Vasut
2021-08-30 17:52 ` Adam Ford
2021-08-30 17:58 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox