soc: rockchip: add driver for rockchip io domains
v2 cover soc: rockchip: add driver for rockchip io domains
Hi all,
The IO domains in Rockchip SoCs need to be configured to match the corresponding bank voltage. In Linux this is achieved by means of a platform driver that reads the voltage value of the supplies and configures the bits in the general register file (GRF) accordingly.
This series ports this driver to barebox to provide support for the Rockchip RK356x SoCs. Please note that I could only test the changes on RK3568 boards, so I left out the parts for the other SoCs supported by the Linux driver. Also, it should be noted that the Linux driver uses notifiers to react to voltage changes. This is not supported by this barebox driver.
The driver has been tested on a Radxa ROCK3 Model A and a Rockchip RK3568 EVB1. I do not have a BananaPi R2Pro and would therefore like to ask someone with such a board a test.
The removal of the IO domain configuration in the low-level code allows to refactor the low-level initialization to a common method rk3568_start. This is introduced and used in patches 6 and 7.
Looking forward to your comments!
Best regards,
Michael
Changes since v1:
- add defconfig
- extend removal of IO domain configuration code
- refactor initialization to rk3568_start()
Michael Riesch (7):
soc: rockchip: add driver for rockchip io domains
arm: rockchip_v8_defconfig: enable io domain driver
arm: rockchip: radxa-rock3: remove io domain configuration
arm: rockchip: rk3568-evb: remove io domain configuration
arm: rockchip: rk3568-bpi-r2pro: remove io domain configuration
arm: rockchip: rk3568: refactor common rk3568_start method
arm: rockchip: rk3568-bpi-r2pro: use common method rk3568_start
arch/arm/boards/pine64-quartz64/lowlevel.c | 30 +-- arch/arm/boards/radxa-rock3/lowlevel.c | 33 --- .../rockchip-rk3568-bpi-r2pro/lowlevel.c | 42 +--- .../arm/boards/rockchip-rk3568-evb/lowlevel.c | 39 +-- arch/arm/configs/rockchip_v8_defconfig | 4 + .../arm/mach-rockchip/include/mach/rockchip.h | 1 + arch/arm/mach-rockchip/rk3568.c | 24 ++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/rockchip/Kconfig | 17 ++ drivers/soc/rockchip/Makefile | 6 + drivers/soc/rockchip/io-domain.c | 223 ++++++++++++++++++ 12 files changed, 280 insertions(+), 141 deletions(-) create mode 100644 drivers/soc/rockchip/Kconfig create mode 100644 drivers/soc/rockchip/Makefile create mode 100644 drivers/soc/rockchip/io-domain.c
Signature · 1 line
2.30.2
PATCH v2 1/7 soc: rockchip: add driver for rockchip io domains
The IO domains in Rockchip SoCs need to be configured to match the corresponding bank voltage. In Linux this is achieved by means of a platform driver that reads the voltage value of the supplies and configures the bits in the general register file (GRF) accordingly. Port this driver to barebox to provide support for the Rockchip RK356x SoCs.
--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/rockchip/Kconfig | 17 +++ drivers/soc/rockchip/Makefile | 6 + drivers/soc/rockchip/io-domain.c | 223 +++++++++++++++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 drivers/soc/rockchip/Kconfig create mode 100644 drivers/soc/rockchip/Makefile create mode 100644 drivers/soc/rockchip/io-domain.c
drivers/soc/Kconfig +1 -0
@@ -2,5 +2,6 @@ menu "SoC drivers" source "drivers/soc/imx/Kconfig" source "drivers/soc/kvx/Kconfig" +source "drivers/soc/rockchip/Kconfig" endmenu
drivers/soc/Makefile +1 -0
@@ -2,5 +2,6 @@ obj-$(CONFIG_ARCH_IMX) += imx/ obj-$(CONFIG_KVX) += kvx/ +obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ obj-$(CONFIG_CPU_SIFIVE) += sifive/ obj-$(CONFIG_SOC_STARFIVE) += starfive/
drivers/soc/rockchip/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only + +if ARCH_ROCKCHIP || COMPILE_TEST + +menu "Rockchip SoC drivers" + +config ROCKCHIP_IODOMAIN + tristate "Rockchip IO domain support" + depends on OFDEVICE + help + Say y here to enable support io domains on Rockchip SoCs. It is + necessary for the io domain setting of the SoC to match the + voltage supplied by the regulators. + +endmenu + +endif
drivers/soc/rockchip/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Rockchip Soc drivers +# + +obj-$(CONFIG_ROCKCHIP_IODOMAIN) += io-domain.o
drivers/soc/rockchip/io-domain.c new file +223 -0
223 lines not on this page · raw message
Signature · 1 line
2.30.2
Quoted 8 lines · Michael Riesch
The IO domains in Rockchip SoCs need to be configured to match the corresponding bank voltage. In Linux this is achieved by means of a platform driver that reads the voltage value of the supplies and configures the bits in the general register file (GRF) accordingly. Port this driver to barebox to provide support for the Rockchip RK356x SoCs.
Signed-off-by Michael Riesch <[email protected]>
Quoted 10 lines
--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/rockchip/Kconfig | 17 +++ drivers/soc/rockchip/Makefile | 6 + drivers/soc/rockchip/io-domain.c | 223 +++++++++++++++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 drivers/soc/rockchip/Kconfig create mode 100644 drivers/soc/rockchip/Makefile create mode 100644 drivers/soc/rockchip/io-domain.c
There's nothing in this driver that makes sure it is probed before the users of the io domains. What happens when the users are probed before the io domain driver?
Normally I would expect that the consumers have some phandle to their io domain, but there's nothing like it in the device trees.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Sascha,
Quoted 20 lines · Sascha Hauer
Quoted 8 lines · Michael Riesch
The IO domains in Rockchip SoCs need to be configured to match the corresponding bank voltage. In Linux this is achieved by means of a platform driver that reads the voltage value of the supplies and configures the bits in the general register file (GRF) accordingly. Port this driver to barebox to provide support for the Rockchip RK356x SoCs.
Signed-off-by Michael Riesch <[email protected]>Quoted 10 lines
--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/rockchip/Kconfig | 17 +++ drivers/soc/rockchip/Makefile | 6 + drivers/soc/rockchip/io-domain.c | 223 +++++++++++++++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 drivers/soc/rockchip/Kconfig create mode 100644 drivers/soc/rockchip/Makefile create mode 100644 drivers/soc/rockchip/io-domain.c
Quoted 3 lines
There's nothing in this driver that makes sure it is probed before the users of the io domains. What happens when the users are probed before the io domain driver?
Correct. Unfortunately, the situation is quite the same in the kernel. Only recently there was a discussion as to how to resolve this issue [0]. While the RFC in [0] was received well there is no mainline solution to this problem. I would suggest that the mainline kernel solution is adopted once there is one.
In the mean time we could
- accept that it just works for some reason (TM)
- leave the magic bits in the low-level initialization to be on the safe side
- simply wait
- ???
Quoted 2 lines
Normally I would expect that the consumers have some phandle to their io domain, but there's nothing like it in the device trees.
The RFC in [0] suggests that the pinctrl is a consumer of the io domains, which would be in alignment with your expectations.
Best regards,
Michael
Quoted 33 lines · Michael Riesch
Hi Sascha,
Quoted 20 lines · Sascha Hauer
Quoted 8 lines · Michael Riesch
The IO domains in Rockchip SoCs need to be configured to match the corresponding bank voltage. In Linux this is achieved by means of a platform driver that reads the voltage value of the supplies and configures the bits in the general register file (GRF) accordingly. Port this driver to barebox to provide support for the Rockchip RK356x SoCs.
Signed-off-by Michael Riesch <[email protected]>Quoted 10 lines
--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/rockchip/Kconfig | 17 +++ drivers/soc/rockchip/Makefile | 6 + drivers/soc/rockchip/io-domain.c | 223 +++++++++++++++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 drivers/soc/rockchip/Kconfig create mode 100644 drivers/soc/rockchip/Makefile create mode 100644 drivers/soc/rockchip/io-domain.cQuoted 3 lines
There's nothing in this driver that makes sure it is probed before the users of the io domains. What happens when the users are probed before the io domain driver?
Correct. Unfortunately, the situation is quite the same in the kernel. Only recently there was a discussion as to how to resolve this issue [0]. While the RFC in [0] was received well there is no mainline solution to this problem. I would suggest that the mainline kernel solution is adopted once there is one.
Quoted 4 lines
In the mean time we could
- accept that it just works for some reason (TM)
- leave the magic bits in the low-level initialization to be on the safe side
Decided for this solution for now.
I added the following as a reminder that there's still something to do.
Sascha
---------------------------8<---------------------------
Quoted 1 line
From
502c4e819b80a6ccaefbce4af4c55b830b7e2c73Mon Sep 17 00:00:00 2001
From: Sascha Hauer <[email protected]>
Date: Thu, 22 Sep 2022 09:56:57 +0200
Subject: [PATCH] ARM: Rockchip: Add FIXME comment to io domain setup
We have a io-domain driver for rockchip boards which correctly configures the io domain voltages, but currently there is no way to make sure the io-domain driver is probed before its consumers.
To be on the safe side keep the io domain setup in the lowlevel code for now, but add a comment that it should be removed once this issue is resolved.
To solve this issue we need a phandle from the consumers to the io domain node. We could add this in barebox locally, but decided to wait until the upstream dts files have them.
--- arch/arm/boards/radxa-rock3/lowlevel.c | 4 ++++ arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c | 4 ++++ arch/arm/boards/rockchip-rk3568-evb/lowlevel.c | 4 ++++ 3 files changed, 12 insertions(+)
arch/arm/boards/radxa-rock3/lowlevel.c +4 -0
@@ -17,6 +17,10 @@ static noinline void rk3568_start(void)/* * Enable vccio4 1.8V and vccio6 1.8V * Needed for GMAC to work. +* FIXME: This is done by the io-domain driver as well, but there +* currently is no mechanism to make sure the driver gets probed +* before its consumers. Remove this setup once this issue is +* resolved. */ writel (RK_SETBITS (0x50 ),0xfdc20140 );
arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c +4 -0
@@ -18,6 +18,10 @@ static noinline void rk3568_start(void)/* * set iodomain vccio6 to 1.8V needed for GMAC1 to work. * vccio4 (gmac0/switch) needs to stay at 3v3 (default) +* FIXME: This is done by the io-domain driver as well, but there +* currently is no mechanism to make sure the driver gets probed +* before its consumers. Remove this setup once this issue is +* resolved. */ //set bit 6 in PMU_GRF_IO_VSEL0 for vccio6 1v8 writel (RK_SETBITS (BIT (6 )),PMU_GRF_IO_VSEL0 );
arch/arm/boards/rockchip-rk3568-evb/lowlevel.c +4 -0
@@ -18,6 +18,10 @@ static noinline void rk3568_start(void)/* * Enable vccio4 1.8V and vccio6 1.8V * Needed for GMAC to work. +* FIXME: This is done by the io-domain driver as well, but there +* currently is no mechanism to make sure the driver gets probed +* before its consumers. Remove this setup once this issue is +* resolved. */ writel (RK_SETBITS (0x50 ),0xfdc20140 );
Signature · 7 lines
2.30.2 -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi,
Quoted 39 lines · Sascha Hauer
Quoted 33 lines · Michael Riesch
Hi Sascha,
Quoted 20 lines · Sascha Hauer
Quoted 8 lines · Michael Riesch
The IO domains in Rockchip SoCs need to be configured to match the corresponding bank voltage. In Linux this is achieved by means of a platform driver that reads the voltage value of the supplies and configures the bits in the general register file (GRF) accordingly. Port this driver to barebox to provide support for the Rockchip RK356x SoCs.
Signed-off-by Michael Riesch <[email protected]>Quoted 10 lines
--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/rockchip/Kconfig | 17 +++ drivers/soc/rockchip/Makefile | 6 + drivers/soc/rockchip/io-domain.c | 223 +++++++++++++++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 drivers/soc/rockchip/Kconfig create mode 100644 drivers/soc/rockchip/Makefile create mode 100644 drivers/soc/rockchip/io-domain.cQuoted 3 lines
There's nothing in this driver that makes sure it is probed before the users of the io domains. What happens when the users are probed before the io domain driver?
Correct. Unfortunately, the situation is quite the same in the kernel. Only recently there was a discussion as to how to resolve this issue [0]. While the RFC in [0] was received well there is no mainline solution to this problem. I would suggest that the mainline kernel solution is adopted once there is one.
Quoted 4 lines
In the mean time we could
- accept that it just works for some reason (TM)
- leave the magic bits in the low-level initialization to be on the safe side
Quoted 4 lines
Decided for this solution for now.
I added the following as a reminder that there's still something to do.
Why not do an of_device_ensure_probed for the I/O domain driver in rk3568_init()?
Quoted 74 lines
Sascha
---------------------------8<---------------------------
From
502c4e819b80a6ccaefbce4af4c55b830b7e2c73Mon Sep 17 00:00:00 2001
From: Sascha Hauer <[email protected]>
Date: Thu, 22 Sep 2022 09:56:57 +0200
Subject: [PATCH] ARM: Rockchip: Add FIXME comment to io domain setupWe have a io-domain driver for rockchip boards which correctly configures the io domain voltages, but currently there is no way to make sure the io-domain driver is probed before its consumers.
To be on the safe side keep the io domain setup in the lowlevel code for now, but add a comment that it should be removed once this issue is resolved.
To solve this issue we need a phandle from the consumers to the io domain node. We could add this in barebox locally, but decided to wait until the upstream dts files have them.
Signed-off-by Sascha Hauer <[email protected]>--- arch/arm/boards/radxa-rock3/lowlevel.c | 4 ++++ arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c | 4 ++++ arch/arm/boards/rockchip-rk3568-evb/lowlevel.c | 4 ++++ 3 files changed, 12 insertions(+)arch/arm/boards/radxa-rock3/lowlevel.c +4
-0@@ -17,6 +17,10 @@ static noinline void rk3568_start(void)/* * Enable vccio4 1.8V and vccio6 1.8V * Needed for GMAC to work. +* FIXME: This is done by the io-domain driver as well, but there +* currently is no mechanism to make sure the driver gets probed +* before its consumers. Remove this setup once this issue is +* resolved. */ writel (RK_SETBITS (0x50 ),0xfdc20140 );arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c +4
-0@@ -18,6 +18,10 @@ static noinline void rk3568_start(void)/* * set iodomain vccio6 to 1.8V needed for GMAC1 to work. * vccio4 (gmac0/switch) needs to stay at 3v3 (default) +* FIXME: This is done by the io-domain driver as well, but there +* currently is no mechanism to make sure the driver gets probed +* before its consumers. Remove this setup once this issue is +* resolved. */ //set bit 6 in PMU_GRF_IO_VSEL0 for vccio6 1v8 writel (RK_SETBITS (BIT (6 )),PMU_GRF_IO_VSEL0 );arch/arm/boards/rockchip-rk3568-evb/lowlevel.c +4
-0@@ -18,6 +18,10 @@ static noinline void rk3568_start(void)/* * Enable vccio4 1.8V and vccio6 1.8V * Needed for GMAC to work. +* FIXME: This is done by the io-domain driver as well, but there +* currently is no mechanism to make sure the driver gets probed +* before its consumers. Remove this setup once this issue is +* resolved. */ writel (RK_SETBITS (0x50 ),0xfdc20140 );
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 42 lines · Ahmad Fatoum
Hi,
Quoted 39 lines · Sascha Hauer
Quoted 37 lines · Michael Riesch
Hi Sascha,
Quoted 20 lines · Sascha Hauer
Quoted 8 lines · Michael Riesch
The IO domains in Rockchip SoCs need to be configured to match the corresponding bank voltage. In Linux this is achieved by means of a platform driver that reads the voltage value of the supplies and configures the bits in the general register file (GRF) accordingly. Port this driver to barebox to provide support for the Rockchip RK356x SoCs.
Signed-off-by Michael Riesch <[email protected]>Quoted 10 lines
--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/rockchip/Kconfig | 17 +++ drivers/soc/rockchip/Makefile | 6 + drivers/soc/rockchip/io-domain.c | 223 +++++++++++++++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 drivers/soc/rockchip/Kconfig create mode 100644 drivers/soc/rockchip/Makefile create mode 100644 drivers/soc/rockchip/io-domain.cQuoted 3 lines
There's nothing in this driver that makes sure it is probed before the users of the io domains. What happens when the users are probed before the io domain driver?
Correct. Unfortunately, the situation is quite the same in the kernel. Only recently there was a discussion as to how to resolve this issue [0]. While the RFC in [0] was received well there is no mainline solution to this problem. I would suggest that the mainline kernel solution is adopted once there is one.
In the mean time we could
- accept that it just works for some reason (TM)
- leave the magic bits in the low-level initialization to be on the safe side
Quoted 7 lines
Quoted 4 lines
Decided for this solution for now.
I added the following as a reminder that there's still something to do.
Why not do an
of_device_ensure_probedfor the I/O domain driver inrk3568_init()?
We can't do a of_device_ensure_probed() properly from plain initcalls. For example rk3568_init() is called at postcore level, at that time the io-domain driver is not yet registered.
We would have to find an initcall level where the io-domain driver and all its dependencies (i2c bus driver, PMIC driver) is registered, but none of its consumers are probed. While we could probably find the right initcall level this defeats the purpose of deep probe.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v2 2/7 arm: rockchip_v8_defconfig: enable io domain driver
In reply to Michael RieschThe IO domain driver is required on RK356x boards to configure the IO domains correctly. Enable this driver in the defconfig. Since the corresponding voltages are usually supplied by the RK80x companion PMIC, enable the RK808 driver as well.
--- arch/arm/configs/rockchip_v8_defconfig | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/configs/rockchip_v8_defconfig +4 -0
@@ -139,3 +139,7 @@ CONFIG_FS_FAT_LFN=y CONFIG_FS_BPKFS=y CONFIG_FS_UIMAGEFS=y CONFIG_LZO_DECOMPRESS=y +CONFIG_I2C_RK3X=y +CONFIG_MFD_RK808=y +CONFIG_REGULATOR_RK808=y +CONFIG_ROCKCHIP_IODOMAIN=y
Signature · 1 line
2.30.2
PATCH v2 3/7 arm: rockchip: radxa-rock3: remove io domain configuration
In reply to Michael RieschLet the recently added Rockchip IO domain driver configure the IO domains instead of setting the bits in rk3568_start().
--- arch/arm/boards/radxa-rock3/lowlevel.c | 6 ------ 1 file changed, 6 deletions(-)
arch/arm/boards/radxa-rock3/lowlevel.c +0 -6
@@ -23,12 +23,6 @@ static noinline void rk3568_start(void *fdt)setup_c (); -/* -* Enable vccio4 1.8V and vccio6 1.8V -* Needed for GMAC to work. -*/ -writel (RK_SETBITS (0x50 ),0xfdc20140 ); -if (current_el () ==3 ) {rk3568_lowlevel_init ();rk3568_atf_load_bl31 (fdt);
Signature · 1 line
2.30.2
PATCH v2 4/7 arm: rockchip: rk3568-evb: remove io domain configuration
In reply to Michael RieschLet the recently added Rockchip IO domain driver configure the IO domains instead of setting the bits in rk3568_start().
--- arch/arm/boards/rockchip-rk3568-evb/lowlevel.c | 6 ------ 1 file changed, 6 deletions(-)
arch/arm/boards/rockchip-rk3568-evb/lowlevel.c +0 -6
@@ -15,12 +15,6 @@ static noinline void rk3568_start(void) {void *fdt; -/* -* Enable vccio4 1.8V and vccio6 1.8V -* Needed for GMAC to work. -*/ -writel (RK_SETBITS (0x50 ),0xfdc20140 ); - fdt = __dtb_rk3568_evb1_v10_start;if (current_el () ==3 ) {
Signature · 1 line
2.30.2
PATCH v2 5/7 arm: rockchip: rk3568-bpi-r2pro: remove io domain configuration
In reply to Michael RieschLet the recently added Rockchip IO domain driver configure the IO domains instead of setting the bits in rk3568_start().
--- arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c | 9 --------- 1 file changed, 9 deletions(-)
arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c +0 -9
@@ -15,15 +15,6 @@ static noinline void rk3568_start(void) {void *fdt; -/* -* set iodomain vccio6 to 1.8V needed for GMAC1 to work. -* vccio4 (gmac0/switch) needs to stay at 3v3 (default) -*/ -//set bit 6 in PMU_GRF_IO_VSEL0 for vccio6 1v8 -writel (RK_SETBITS (BIT (6 )),PMU_GRF_IO_VSEL0 ); -//clear bit 6 for 3v3 as it was set to 1v8 -writel (RK_CLRBITS (BIT (6 )),PMU_GRF_IO_VSEL1 ); - fdt = __dtb_rk3568_bpi_r2_pro_start;if (current_el () ==3 ) {
Signature · 1 line
2.30.2
PATCH v2 6/7 arm: rockchip: rk3568: refactor common rk3568_start method
In reply to Michael RieschAfter 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.
--- 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(-)
arch/arm/boards/pine64-quartz64/lowlevel.c +1 -29
@@ -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); }
arch/arm/boards/radxa-rock3/lowlevel.c +0 -27
@@ -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);
arch/arm/boards/rockchip-rk3568-evb/lowlevel.c +1 -32
@@ -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); }
arch/arm/mach-rockchip/include/mach/rockchip.h +1 -0
@@ -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 */
arch/arm/mach-rockchip/rk3568.c +24 -0
@@ -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); +}
Signature · 1 line
2.30.2
Re: [PATCH v2 6/7] arm: rockchip: rk3568: refactor common rk3568_start method
Quoted 48 lines · Michael Riesch
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_startto remove this code duplication.Signed-off-by Michael Riesch <[email protected]>--- 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(-)arch/arm/boards/pine64-quartz64/lowlevel.c +0
-23@@ -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 */ - }
arch/arm/boards/pine64-quartz64/lowlevel.c line 11
Quoted 10 lines
arch/arm/boards/pine64-quartz64/lowlevel.c +1
-6- -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); }
Here __dtb_rk3566_quartz64_a_start is accessed before setup_c() has been called. That is not allowed, see the patch I just sent.
BTW this patch breaks compilation, which is only fixed in 7/7:
/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c:14:22: error: conflicting types for 'rk3568_start'
14 | static noinline void rk3568_start(void)
| ^~~~~~~~~~~~
In file included from /ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c:10:
/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/mach-rockchip/include/mach/rockchip.h:37:6: note: previous declaration of 'rk3568_start' was here
37 | void rk3568_start(void *fdt);
| ^~~~~~~~~~~~Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 6/7] arm: rockchip: rk3568: refactor common rk3568_start method
Hi Sascha,
Quoted 54 lines · Sascha Hauer
Quoted 53 lines · Michael Riesch
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_startto remove this code duplication.Signed-off-by Michael Riesch <[email protected]>--- 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(-)arch/arm/boards/pine64-quartz64/lowlevel.c +0
-28@@ -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); -} -
Quoted 8 lines
arch/arm/boards/pine64-quartz64/lowlevel.c line 11
Quoted 5 lines
arch/arm/boards/pine64-quartz64/lowlevel.c +1
-1ENTRY_FUNCTION(start_quartz64a, r0, r1, r2) { -start_quartz64 (__dtb_rk3566_quartz64_a_start); +rk3568_start (__dtb_rk3566_quartz64_a_start); }Here
__dtb_rk3566_quartz64_a_startis accessed beforesetup_c()has been called. That is not allowed, see the patch I just sent.
Does the refactoring make sense to you in general? Can I change it to
ENTRY_FUNCTION(start_my_fancy_board, r0, r1, r2)
{
setup_c();
rk3568_start(__dtb_my_fancy_board_start);
}?
Quoted 9 lines
BTW this patch breaks compilation, which is only fixed in 7/7:
/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c:14:22: error: conflicting types for '
rk3568_start'
14 | static noinline voidrk3568_start(void)| ^~~~~~~~~~~~ In file included from /ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c:10: /ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/mach-rockchip/include/mach/rockchip.h:37:6: note: previous declaration of 'rk3568_start' was here 37 | void rk3568_start(void *fdt); | ^~~~~~~~~~~~
Oops. The goal was to separate the changes that affect the BananaPi, but in this case 6 + 7 need to be squashed. I guess Frank needs to object to the combined patch if it breaks something on his side.
Best regards,
Michael
Re: [PATCH v2 6/7] arm: rockchip: rk3568: refactor common rk3568_start method
Quoted 66 lines · Michael Riesch
Hi Sascha,
Quoted 54 lines · Sascha Hauer
Quoted 53 lines · Michael Riesch
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_startto remove this code duplication.Signed-off-by Michael Riesch <[email protected]>--- 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(-)arch/arm/boards/pine64-quartz64/lowlevel.c +0
-28@@ -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); -} -Quoted 8 lines
arch/arm/boards/pine64-quartz64/lowlevel.c line 11
Quoted 5 lines
arch/arm/boards/pine64-quartz64/lowlevel.c +1
-1ENTRY_FUNCTION(start_quartz64a, r0, r1, r2) { -start_quartz64 (__dtb_rk3566_quartz64_a_start); +rk3568_start (__dtb_rk3566_quartz64_a_start); }Here
__dtb_rk3566_quartz64_a_startis accessed beforesetup_c()has been called. That is not allowed, see the patch I just sent.
Quoted 7 lines
Does the refactoring make sense to you in general? Can I change it to
ENTRY_FUNCTION(start_my_fancy_board, r0, r1, r2){ setup_c(); rk3568_start(__dtb_my_fancy_board_start); }
Well it's not only setup_c() but also the relocate_to_adr_full() or relocate_to_current_adr() part that has to be called before setup_c().
At that point there is not much left to factor out to a common function.
Unless you want to turn this into preprocessor macros (and I don't recommand doing that) my suggestion is that we just live with this bit of code duplication.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 6/7] arm: rockchip: rk3568: refactor common rk3568_start method
Hi Sascha,
Quoted 69 lines · Sascha Hauer
Quoted 68 lines · Michael Riesch
Hi Sascha,
Quoted 54 lines · Sascha Hauer
Quoted 53 lines · Michael Riesch
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_startto remove this code duplication.Signed-off-by Michael Riesch <[email protected]>--- 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(-)arch/arm/boards/pine64-quartz64/lowlevel.c +0
-28@@ -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); -} -Quoted 8 lines
arch/arm/boards/pine64-quartz64/lowlevel.c line 11
Quoted 5 lines
arch/arm/boards/pine64-quartz64/lowlevel.c +1
-1ENTRY_FUNCTION(start_quartz64a, r0, r1, r2) { -start_quartz64 (__dtb_rk3566_quartz64_a_start); +rk3568_start (__dtb_rk3566_quartz64_a_start); }Here
__dtb_rk3566_quartz64_a_startis accessed beforesetup_c()has been called. That is not allowed, see the patch I just sent.Does the refactoring make sense to you in general? Can I change it to
Quoted 8 lines
Quoted 5 lines
ENTRY_FUNCTION(start_my_fancy_board, r0, r1, r2){ setup_c(); rk3568_start(__dtb_my_fancy_board_start); }Well it's not only
setup_c()but also therelocate_to_adr_full()orrelocate_to_current_adr()part that has to be called beforesetup_c().
Ah OK! Thanks for the clarification.
Quoted 5 lines
At that point there is not much left to factor out to a common function.
Unless you want to turn this into preprocessor macros (and I don't recommand doing that) my suggestion is that we just live with this bit of code duplication.
OK, patches 6+7 can be dropped, then.
Best regards,
Michael
PATCH v2 7/7 arm: rockchip: rk3568-bpi-r2pro: use common method rk3568_start
In reply to Michael RieschAfter the removal of the IO domain configuration code, the common low-level initialization method rk3568_start can be used to remove code duplication.
--- .../rockchip-rk3568-bpi-r2pro/lowlevel.c | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-)
arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c +1 -32
@@ -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_bpi_r2_pro_start[]; -static noinline void rk3568_start(void) -{ -void *fdt; - - fdt = __dtb_rk3568_bpi_r2_pro_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_bpi_r2pro, 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_bpi_r2_pro_start); }
Signature · 1 line
2.30.2