mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Riesch <michael.riesch@wolfvision.net>
To: barebox@lists.infradead.org
Cc: Frank Wunderlich <frank-w@public-files.de>,
	Michael Riesch <michael.riesch@wolfvision.net>
Subject: [PATCH v2 6/7] arm: rockchip: rk3568: refactor common rk3568_start method
Date: Mon, 19 Sep 2022 13:39:47 +0200	[thread overview]
Message-ID: <20220919113948.991245-7-michael.riesch@wolfvision.net> (raw)
In-Reply-To: <20220919113948.991245-1-michael.riesch@wolfvision.net>

After the removal of the IO domain configuration code, the low-level
initialization is the same for all RK356x boards. Add a common
method rk3568_start to remove this code duplication.

Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
---
 arch/arm/boards/pine64-quartz64/lowlevel.c    | 30 +----------------
 arch/arm/boards/radxa-rock3/lowlevel.c        | 27 ---------------
 .../arm/boards/rockchip-rk3568-evb/lowlevel.c | 33 +------------------
 .../arm/mach-rockchip/include/mach/rockchip.h |  1 +
 arch/arm/mach-rockchip/rk3568.c               | 24 ++++++++++++++
 5 files changed, 27 insertions(+), 88 deletions(-)

diff --git a/arch/arm/boards/pine64-quartz64/lowlevel.c b/arch/arm/boards/pine64-quartz64/lowlevel.c
index b295885522..e1beb3e624 100644
--- a/arch/arm/boards/pine64-quartz64/lowlevel.c
+++ b/arch/arm/boards/pine64-quartz64/lowlevel.c
@@ -1,39 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <common.h>
-#include <linux/sizes.h>
-#include <asm/barebox-arm-head.h>
 #include <asm/barebox-arm.h>
-#include <mach/hardware.h>
-#include <mach/atf.h>
-#include <debug_ll.h>
 #include <mach/rockchip.h>
 
 extern char __dtb_rk3566_quartz64_a_start[];
 
-static noinline void start_quartz64(void *fdt)
-{
-	/*
-	 * Image execution starts at 0x0, but this is used for ATF and
-	 * OP-TEE later, so move away from here.
-	 */
-	if (current_el() == 3)
-		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
-	else
-		relocate_to_current_adr();
-
-	setup_c();
-
-	if (current_el() == 3) {
-		rk3568_lowlevel_init();
-		rk3568_atf_load_bl31(fdt);
-		/* not reached */
-	}
-
-	barebox_arm_entry(RK3568_DRAM_BOTTOM, 0x80000000 - RK3568_DRAM_BOTTOM,
-			  fdt);
-}
-
 ENTRY_FUNCTION(start_quartz64a, r0, r1, r2)
 {
-	start_quartz64(__dtb_rk3566_quartz64_a_start);
+	rk3568_start(__dtb_rk3566_quartz64_a_start);
 }
diff --git a/arch/arm/boards/radxa-rock3/lowlevel.c b/arch/arm/boards/radxa-rock3/lowlevel.c
index 5c2499362b..9875a3966b 100644
--- a/arch/arm/boards/radxa-rock3/lowlevel.c
+++ b/arch/arm/boards/radxa-rock3/lowlevel.c
@@ -1,37 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <common.h>
-#include <linux/sizes.h>
-#include <asm/barebox-arm-head.h>
 #include <asm/barebox-arm.h>
-#include <mach/hardware.h>
-#include <mach/atf.h>
-#include <debug_ll.h>
 #include <mach/rockchip.h>
 
 extern char __dtb_rk3568_rock_3a_start[];
 
-static noinline void rk3568_start(void *fdt)
-{
-	/*
-	 * Image execution starts at 0x0, but this is used for ATF and
-	 * OP-TEE later, so move away from here.
-	 */
-	if (current_el() == 3)
-		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
-	else
-		relocate_to_current_adr();
-
-	setup_c();
-
-	if (current_el() == 3) {
-		rk3568_lowlevel_init();
-		rk3568_atf_load_bl31(fdt);
-		/* not reached */
-	}
-
-	barebox_arm_entry(RK3568_DRAM_BOTTOM, 0x80000000 - RK3568_DRAM_BOTTOM, fdt);
-}
-
 ENTRY_FUNCTION(start_rock3a, r0, r1, r2)
 {
 	rk3568_start(__dtb_rk3568_rock_3a_start);
diff --git a/arch/arm/boards/rockchip-rk3568-evb/lowlevel.c b/arch/arm/boards/rockchip-rk3568-evb/lowlevel.c
index 9c1c7be8a6..4954e9a3cc 100644
--- a/arch/arm/boards/rockchip-rk3568-evb/lowlevel.c
+++ b/arch/arm/boards/rockchip-rk3568-evb/lowlevel.c
@@ -1,43 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
 #include <common.h>
-#include <linux/sizes.h>
-#include <asm/barebox-arm-head.h>
 #include <asm/barebox-arm.h>
-#include <mach/hardware.h>
-#include <mach/atf.h>
-#include <debug_ll.h>
 #include <mach/rockchip.h>
 
 extern char __dtb_rk3568_evb1_v10_start[];
 
-static noinline void rk3568_start(void)
-{
-	void *fdt;
-
-	fdt = __dtb_rk3568_evb1_v10_start;
-
-	if (current_el() == 3) {
-		rk3568_lowlevel_init();
-		rk3568_atf_load_bl31(fdt);
-		/* not reached */
-	}
-
-	barebox_arm_entry(RK3568_DRAM_BOTTOM, 0x80000000 - RK3568_DRAM_BOTTOM, fdt);
-}
-
 ENTRY_FUNCTION(start_rk3568_evb, r0, r1, r2)
 {
-	/*
-	 * Image execution starts at 0x0, but this is used for ATF and
-	 * OP-TEE later, so move away from here.
-	 */
-	if (current_el() == 3)
-		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
-	else
-		relocate_to_current_adr();
-
-	setup_c();
-
-	rk3568_start();
+	rk3568_start(__dtb_rk3568_evb1_v10_start);
 }
diff --git a/arch/arm/mach-rockchip/include/mach/rockchip.h b/arch/arm/mach-rockchip/include/mach/rockchip.h
index ff8b1109f8..7b681c6ce3 100644
--- a/arch/arm/mach-rockchip/include/mach/rockchip.h
+++ b/arch/arm/mach-rockchip/include/mach/rockchip.h
@@ -34,5 +34,6 @@ static inline int rk3568_init(void)
 #endif
 
 void rk3568_lowlevel_init(void);
+void rk3568_start(void *fdt);
 
 #endif /* __MACH_ROCKCHIP_H */
diff --git a/arch/arm/mach-rockchip/rk3568.c b/arch/arm/mach-rockchip/rk3568.c
index 19dfa9b871..26bc4a06eb 100644
--- a/arch/arm/mach-rockchip/rk3568.c
+++ b/arch/arm/mach-rockchip/rk3568.c
@@ -2,8 +2,10 @@
 #include <common.h>
 #include <io.h>
 #include <bootsource.h>
+#include <mach/atf.h>
 #include <mach/rk3568-regs.h>
 #include <mach/rockchip.h>
+#include <asm/barebox-arm.h>
 
 #define GRF_BASE		0xfdc60000
 #define GRF_GPIO1B_DS_2		0x218
@@ -169,3 +171,25 @@ int rk3568_init(void)
 
 	return 0;
 }
+
+void rk3568_start(void *fdt)
+{
+	/*
+	 * Image execution starts at 0x0, but this is used for ATF and
+	 * OP-TEE later, so move away from here.
+	 */
+	if (current_el() == 3)
+		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
+	else
+		relocate_to_current_adr();
+
+	setup_c();
+
+	if (current_el() == 3) {
+		rk3568_lowlevel_init();
+		rk3568_atf_load_bl31(fdt);
+		/* not reached */
+	}
+
+	barebox_arm_entry(RK3568_DRAM_BOTTOM, 0x80000000 - RK3568_DRAM_BOTTOM, fdt);
+}
-- 
2.30.2




  parent reply	other threads:[~2022-09-19 11:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 11:39 [PATCH v2 0/7] soc: rockchip: add driver for rockchip io domains Michael Riesch
2022-09-19 11:39 ` [PATCH v2 1/7] " Michael Riesch
2022-09-21  9:46   ` Sascha Hauer
2022-09-21 11:49     ` Michael Riesch
2022-09-22  8:03       ` Sascha Hauer
2022-09-22  8:13         ` Ahmad Fatoum
2022-09-22  8:23           ` Sascha Hauer
2022-09-19 11:39 ` [PATCH v2 2/7] arm: rockchip_v8_defconfig: enable io domain driver Michael Riesch
2022-09-19 11:39 ` [PATCH v2 3/7] arm: rockchip: radxa-rock3: remove io domain configuration Michael Riesch
2022-09-19 11:39 ` [PATCH v2 4/7] arm: rockchip: rk3568-evb: " Michael Riesch
2022-09-19 11:39 ` [PATCH v2 5/7] arm: rockchip: rk3568-bpi-r2pro: " Michael Riesch
2022-09-19 11:39 ` Michael Riesch [this message]
2022-09-21  9:17   ` [PATCH v2 6/7] arm: rockchip: rk3568: refactor common rk3568_start method Sascha Hauer
2022-09-21 11:57     ` Michael Riesch
2022-09-21 12:21       ` Sascha Hauer
2022-09-21 12:34         ` Michael Riesch
2022-09-19 11:39 ` [PATCH v2 7/7] arm: rockchip: rk3568-bpi-r2pro: use common method rk3568_start Michael Riesch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220919113948.991245-7-michael.riesch@wolfvision.net \
    --to=michael.riesch@wolfvision.net \
    --cc=barebox@lists.infradead.org \
    --cc=frank-w@public-files.de \
    --subject='Re: [PATCH v2 6/7] arm: rockchip: rk3568: refactor common rk3568_start method' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox