arm: rockchip: rk3399: rock-pi-4: power domain driver to boot from MMCSD
Subsystems (3)
cover arm: rockchip: rk3399: rock-pi-4: power domain driver to boot from MMCSD
Hello.
I've been trying to compile myself all the stack to boot a Radxa Rock Pi 4B.
I've found and worked around a few issues and I'm starting to select, clean up and send the patches I used.
Since I'm new to the project I may have overseen something obvious. If so sorry. For the rest I hope something can be useful to others.
Likewise I've found a couple of suspicions lines in clk_rk3399.c, but since I haven't found cases where they give problems, I should not send changes, or should I?
This series is the minimum I needed to be able to boot linux-libre from a SD card, which wasn't possible for me just from master. It still displays some errors, but I leave them for later because it boots.
The series is basically about trying not to overlap ATF, enabling a couple of clocks that MMCSD uses, and adding a power domain driver for rockchip, since I guess the DTS must have been updated from linux and the board may have worked before but the new DTS maybe broke boot from SD.
I'm not sure why power domain drivers in U-Boot leave the clocks they need enabled, but I tried to disable them once powered up and it didn't boot.
If people wants to test with other rockchip SOCs that'd be welcome, but I'm not sure whether they need the new driver. For now I only configured it for Rock Pi 4.
Thanks beforehand for any feedback. Specially if I should run any tests.
Signature · 1 line
Xavier Drudis Ferran
Re: [PATCH 1/3] Reserve some RAM at 0 for bl31_0x00000000.bin for Radxa Rock Pi 4.
When trying to boot from MMC in a Rock Pi 4 where I shorted SPI clk to GND to have bootrom load tpl+spl from MMC, SPL hanged after the message "Trying to boot from MMC1".
With this patch it continued booting, printed two notices from ATF with BL31 version and date, and loaded U-Boot proper.
I'm not sure if there's something special with the ATF I built, or what would be a reasonable standard for the size of BL31@0 but in my u-boot.its I find
atf_1 {
description = "ARM Trusted Firmware";
data = /incbin/("bl31_0x00000000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0x00000000>;
entry = <0x00001000>;
};and bl31_0x00000000.bin size is 82008 bytes.
0x15000 is 86016 which gives some room for variation and seems good aligned enough. I don't want to make u-boot too big.
Most other boards which define CONFIG_ROCKCHIP_SPL_RESERVE_IRAM put it at 0x4000 but in my tests this wasn't enough.
--- configs/rock-pi-4-rk3399_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/rock-pi-4-rk3399_defconfig +1 -0
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1 CONFIG_ENV_OFFSET=0x3F8000 CONFIG_DEFAULT_DEVICE_TREE="rk3399-rock-pi-4b" CONFIG_ROCKCHIP_RK3399=y +CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x15000 CONFIG_TARGET_EVB_RK3399=y CONFIG_DEBUG_UART_BASE=0xFF1A0000 CONFIG_DEBUG_UART_CLOCK=24000000
Signature · 1 line
2.20.1
Re: [PATCH 2/3] Add a couple of missing clocks for MMCSD.
In reply to Xavier Drudis FerranThis helped boot a Radxa Rock Pi 4B from SD card. With U-boot master at commit 4fe629d2e8bb ("Merge
https://source.denx.de/u-boot/custodians/u-boot-riscv") from
2022-05-27T08:50:42-0400 and the SPI clock shorted to GND to make the
bootrom boot from SD card, SPL stopped at the "Trying to boot from MMC1" message.
--- drivers/clk/rockchip/clk_rk3399.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/clk/rockchip/clk_rk3399.c +12 -0
@@ -1184,6 +1184,12 @@ static int rk3399_clk_enable(struct clk *clk)case SCLK_PCIEPHY_REF :rk_clrreg (&priv->cru->clksel_con[18 ],BIT (10 ));break ; +case SCLK_SDMMC : +rk_clrreg (&priv->cru->clksel_con[6 ],BIT (1 )); +break ; +case HCLK_SDMMC : +rk_clrreg (&priv->cru->clksel_con[33 ],BIT (8 )); +break ;default :debug ("%s: unsupported clk %ld\n" , __func__, clk->id);return -ENOENT ;
@@ -1278,6 +1284,12 @@ static int rk3399_clk_disable(struct clk *clk)case SCLK_PCIEPHY_REF :rk_clrreg (&priv->cru->clksel_con[18 ],BIT (10 ));break ; +case SCLK_SDMMC : +rk_setreg (&priv->cru->clksel_con[6 ],BIT (1 )); +break ; +case HCLK_SDMMC : +rk_setreg (&priv->cru->clksel_con[33 ],BIT (8 )); +break ;default :debug ("%s: unsupported clk %ld\n" , __func__, clk->id);return -ENOENT ;
Signature · 1 line
2.20.1
Re: [PATCH 3/3] arm: rockchip: rk3399: Power domain driver for rockchip.
In reply to Xavier Drudis FerranEnable clocks and power up domains when a get on a domain is made.
This (together with initialising a couple of new clocks) helped boot a Radxa Rock Pi 4B from SD card. It's adapted from Linux 5.15.25 and includes parameters for a dozen Rockchip SOCs, but it's only tested on RK3399.
Some of the parameters are for SOCs not even in U-Boot yet. To save a little space it avoids most data for SOCs not configured in the build. It even mentions CONFIG_ROCKCHIP_RK3066 and CONFIG_ROCKCHIP_RK3366 despite those constants not being in Kconfig yet.
--- configs/rock-pi-4-rk3399_defconfig | 2 + drivers/power/domain/Kconfig | 11 + drivers/power/domain/Makefile | 1 + drivers/power/domain/power-domain-uclass.c | 4 +- drivers/power/domain/rockchip-power-domain.c | 1006 ++++++++++++++++++ include/dt-bindings/power/rk3036-power.h | 13 + include/dt-bindings/power/rk3128-power.h | 14 + include/dt-bindings/power/rk3366-power.h | 24 + include/dt-bindings/power/rk3368-power.h | 29 + include/dt-bindings/power/rk3568-power.h | 32 + include/power-domain-uclass.h | 32 + 11 files changed, 1166 insertions(+), 2 deletions(-) create mode 100644 drivers/power/domain/rockchip-power-domain.c create mode 100644 include/dt-bindings/power/rk3036-power.h create mode 100644 include/dt-bindings/power/rk3128-power.h create mode 100644 include/dt-bindings/power/rk3366-power.h create mode 100644 include/dt-bindings/power/rk3368-power.h create mode 100644 include/dt-bindings/power/rk3568-power.h
configs/rock-pi-4-rk3399_defconfig +2 -0
@@ -46,6 +46,8 @@ CONFIG_NVME_PCI=y CONFIG_PCI=y CONFIG_PHY_ROCKCHIP_INNO_USB2=y CONFIG_PHY_ROCKCHIP_TYPEC=y +CONFIG_POWER_DOMAIN=y +CONFIG_ROCKCHIP_POWER_DOMAIN=y CONFIG_PMIC_RK8XX=y CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_RK8XX=y
drivers/power/domain/Kconfig +11 -0
@@ -68,6 +68,17 @@ config MESON_EE_POWER_DOMAIN Enable support for manipulating Amlogic Meson Everything-Else power domains. +config ROCKCHIP_POWER_DOMAIN + bool "Enable the Rockchip Power domain driver" + depends on POWER_DOMAIN && ARCH_ROCKCHIP + help + Power domain driver for Rockchip SOCs. It's only tested on + RK3399 but includes parameters copied from linux-5.15.25 for + PX30, RK3036, RK3128, RK3188, RK3228, RK3288, RK3328, + RK3368 and RK3568. It also includes parameters for RK3066 + and RK3366 waiting for mainline U-Boot support. + Try at your own risk. + config SANDBOX_POWER_DOMAIN bool "Enable the sandbox power domain test driver" depends on POWER_DOMAIN && SANDBOX
drivers/power/domain/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o obj-$(CONFIG_MESON_EE_POWER_DOMAIN) += meson-ee-pwrc.o +obj-$(CONFIG_ROCKCHIP_POWER_DOMAIN) += rockchip-power-domain.o obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain-test.o obj-$(CONFIG_TEGRA186_POWER_DOMAIN) += tegra186-power-domain.o
drivers/power/domain/power-domain-uclass.c +2 -2
@@ -18,8 +18,8 @@ static inline struct power_domain_ops *power_domain_dev_ops(struct udevice *dev)return (struct power_domain_ops *)dev->driver->ops; } -static int power_domain_of_xlate_default (struct power_domain *power_domain, -struct ofnode_phandle_args *args) +int power_domain_of_xlate_default (struct power_domain *power_domain, +struct ofnode_phandle_args *args) {debug ("%s(power_domain=%p)\n" , __func__, power_domain);
drivers/power/domain/rockchip-power-domain.c new file +1006 -0
1,006 lines not on this page · raw message
include/dt-bindings/power/rk3036-power.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_BINDINGS_POWER_RK3036_POWER_H__ +#define __DT_BINDINGS_POWER_RK3036_POWER_H__ + +#define RK3036_PD_MSCH 0 +#define RK3036_PD_CORE 1 +#define RK3036_PD_PERI 2 +#define RK3036_PD_VIO 3 +#define RK3036_PD_VPU 4 +#define RK3036_PD_GPU 5 +#define RK3036_PD_SYS 6 + +#endif
include/dt-bindings/power/rk3128-power.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_BINDINGS_POWER_RK3128_POWER_H__ +#define __DT_BINDINGS_POWER_RK3128_POWER_H__ + +/* VD_CORE */ +#define RK3128_PD_CORE 0 + +/* VD_LOGIC */ +#define RK3128_PD_VIO 1 +#define RK3128_PD_VIDEO 2 +#define RK3128_PD_GPU 3 +#define RK3128_PD_MSCH 4 + +#endif
include/dt-bindings/power/rk3366-power.h new file +24 -0
@@ -0,0 +1,24 @@ +#ifndef __DT_BINDINGS_POWER_RK3366_POWER_H__ +#define __DT_BINDINGS_POWER_RK3366_POWER_H__ + +/* VD_CORE */ +#define RK3366_PD_A53_0 0 +#define RK3366_PD_A53_1 1 +#define RK3366_PD_A53_2 2 +#define RK3366_PD_A53_3 3 + +/* VD_LOGIC */ +#define RK3366_PD_BUS 4 +#define RK3366_PD_PERI 5 +#define RK3366_PD_VIO 6 +#define RK3366_PD_VIDEO 7 +#define RK3366_PD_RKVDEC 8 +#define RK3366_PD_WIFIBT 9 +#define RK3366_PD_VPU 10 +#define RK3366_PD_GPU 11 +#define RK3366_PD_ALIVE 12 + +/* VD_PMU */ +#define RK3366_PD_PMU 13 + +#endif
include/dt-bindings/power/rk3368-power.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_BINDINGS_POWER_RK3368_POWER_H__ +#define __DT_BINDINGS_POWER_RK3368_POWER_H__ + +/* VD_CORE */ +#define RK3368_PD_A53_L0 0 +#define RK3368_PD_A53_L1 1 +#define RK3368_PD_A53_L2 2 +#define RK3368_PD_A53_L3 3 +#define RK3368_PD_SCU_L 4 +#define RK3368_PD_A53_B0 5 +#define RK3368_PD_A53_B1 6 +#define RK3368_PD_A53_B2 7 +#define RK3368_PD_A53_B3 8 +#define RK3368_PD_SCU_B 9 + +/* VD_LOGIC */ +#define RK3368_PD_BUS 10 +#define RK3368_PD_PERI 11 +#define RK3368_PD_VIO 12 +#define RK3368_PD_ALIVE 13 +#define RK3368_PD_VIDEO 14 +#define RK3368_PD_GPU_0 15 +#define RK3368_PD_GPU_1 16 + +/* VD_PMU */ +#define RK3368_PD_PMU 17 + +#endif
include/dt-bindings/power/rk3568-power.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_BINDINGS_POWER_RK3568_POWER_H__ +#define __DT_BINDINGS_POWER_RK3568_POWER_H__ + +/* VD_CORE */ +#define RK3568_PD_CPU_0 0 +#define RK3568_PD_CPU_1 1 +#define RK3568_PD_CPU_2 2 +#define RK3568_PD_CPU_3 3 +#define RK3568_PD_CORE_ALIVE 4 + +/* VD_PMU */ +#define RK3568_PD_PMU 5 + +/* VD_NPU */ +#define RK3568_PD_NPU 6 + +/* VD_GPU */ +#define RK3568_PD_GPU 7 + +/* VD_LOGIC */ +#define RK3568_PD_VI 8 +#define RK3568_PD_VO 9 +#define RK3568_PD_RGA 10 +#define RK3568_PD_VPU 11 +#define RK3568_PD_CENTER 12 +#define RK3568_PD_RKVDEC 13 +#define RK3568_PD_RKVENC 14 +#define RK3568_PD_PIPE 15 +#define RK3568_PD_LOGIC_ALIVE 16 + +#endif
include/power-domain-uclass.h +32 -0
@@ -78,4 +78,36 @@ struct power_domain_ops { int (*off)(struct power_domain *power_domain); }; +/** +* power_domain_of_xlate_default - Minimally translate a client's +* device-tree (OF) power domain specifier. +* +* This is the default implementation for the of_xlate member of +* struct power_domain_ops, which assumes #power-domain-cells = <1>, +* and that the DT cell contains a simple integer power domain ID. +* It simply assigns the power domain id member from it or complains +* if no arguments present. +* +* The power domain core calls this operation as the first step in +* implementing a client's power_domain_get() call and each power +* domain driver can either assign this function as the operation, +* assign its own function which calls this one or do it their own way. +* +* @power_domain: The power domain struct to hold the +* translation result. +* @args: The power domain specifier values from device +* tree. +* @return 0 if OK, or a negative error code. +*/ +#if CONFIG_IS_ENABLED (OF_REAL ) &&CONFIG_IS_ENABLED (POWER_DOMAIN ) +int power_domain_of_xlate_default (struct power_domain *power_domain, +struct ofnode_phandle_args *args); +#else +int power_domain_of_xlate_default (struct power_domain *power_domain, +struct ofnode_phandle_args *args) +{ +return 0 ; +} +#endif +#endif
Signature · 1 line
2.20.1