[U-Boot] [PATCH v2 00/10] rockchip: puma-rk3399: support 'same-as-spl' for boot-order and always power-up eMMC/SPI

For the RK3399-Q7, we have a few additional features in the SPL boot path that we'd like to see supported in the mainline: - The override signal BIOS_DISABLE keeps the on-module SPI and eMMC powered-down (actually: in reset) to force booting from external sources. Before proceeding with the SPL boot, we thus need to power the devices up (actually: release the reset) in software. This is done using the regulator framework and a fixed regulator. - Depending on the boot-sources and system configuration, we may want to insert the device the SPL stage was booted from at the start of the boot order, for these we introduce the special device select 'same-as-spl' for the boot-order.
This series contains the following changes: * moves board-specific functionality for the RK3399 SPL stage from the shared SPL board support file to individual ones for the EVB and Puma. * enables the power-regulator framework of Puma * adds fixed regulator support for powering up the eMMC and SPI flashes * adds support for the 'same-as-spl' specifier for the boot order (incl. updating the documentation for this
Changes in v2: - dropped reordering of #includes (as this violated the coding style) - fixes style-warnings (for a printf and useless return statements) newly raised by patman - ran 'whitespace-cleanup' on 'rk3399-puma.dtsi'
Philipp Tomsich (10): rockchip: rk3399: make spl_board_init board-specific rockchip: bootrom: add definitions to retrieve BROM boot-source rockchip: spl: add documentation for spl_node_to_boot_device() rockchip: spl: support a 'same-as-spl'-specifier in the spl-boot-order rockchip: spl: rk3399: implement chip-specific board_spl_was_booted_from() rockchip: dts: rk3399-puma: add 'same-as-spl' to the front of the boot-order rockchip: puma-rk3399: update board_init() rockchip: rk3399-puma: add boot-on regulator to override BIOS_DISABLE power: spl: add SPL_DM_REGULATOR_FIXED in Kconfig rockchip: defconfig: puma-rk3399: update for DM_REGULATOR support in SPL
arch/arm/dts/rk3399-puma.dtsi | 33 +++++++++++-- arch/arm/include/asm/arch-rockchip/bootrom.h | 18 ++++++++ arch/arm/mach-rockchip/rk3399-board-spl.c | 51 ++++++++++----------- arch/arm/mach-rockchip/spl-boot-order.c | 48 ++++++++++++++++++- board/rockchip/evb_rk3399/evb-rk3399.c | 30 +++++++++++- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 56 ++++++++--------------- configs/puma-rk3399_defconfig | 7 ++- doc/device-tree-bindings/chosen.txt | 12 ++++- drivers/power/regulator/Kconfig | 7 +++ 9 files changed, 190 insertions(+), 72 deletions(-)

The later-stage spl_board_init (as opposed to board_init_f) should set up board-specific details: these differ between the EVB-RK3399 and the RK3399-Q7 (Puma).
This moves spl_board_init back into the individual boards and removes the unneeded functionality from Puma.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
---
Changes in v2: - dropped reordering of #includes (as this violated the coding style) - fixes style-warnings (for a printf and useless return statements) newly raised by patman
arch/arm/mach-rockchip/rk3399-board-spl.c | 27 -------------------- board/rockchip/evb_rk3399/evb-rk3399.c | 30 ++++++++++++++++++++++- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 12 +++++---- 3 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/arch/arm/mach-rockchip/rk3399-board-spl.c b/arch/arm/mach-rockchip/rk3399-board-spl.c index 1c39d9b..8e38ef1 100644 --- a/arch/arm/mach-rockchip/rk3399-board-spl.c +++ b/arch/arm/mach-rockchip/rk3399-board-spl.c @@ -149,33 +149,6 @@ void board_init_f(ulong dummy) } }
-void spl_board_init(void) -{ - struct udevice *pinctrl; - int ret; - - ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl); - if (ret) { - debug("%s: Cannot find pinctrl device\n", __func__); - goto err; - } - - /* Enable debug UART */ - ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_UART_DBG); - if (ret) { - debug("%s: Failed to set up console UART\n", __func__); - goto err; - } - - preloader_console_init(); - return; -err: - printf("spl_board_init: Error %d\n", ret); - - /* No way to report error here */ - hang(); -} - #ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match(const char *name) { diff --git a/board/rockchip/evb_rk3399/evb-rk3399.c b/board/rockchip/evb_rk3399/evb-rk3399.c index d50c59d..502dec3 100644 --- a/board/rockchip/evb_rk3399/evb-rk3399.c +++ b/board/rockchip/evb_rk3399/evb-rk3399.c @@ -3,13 +3,14 @@ * * SPDX-License-Identifier: GPL-2.0+ */ + #include <common.h> #include <dm.h> -#include <ram.h> #include <dm/pinctrl.h> #include <dm/uclass-internal.h> #include <asm/arch/periph.h> #include <power/regulator.h> +#include <spl.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -67,3 +68,30 @@ int board_init(void) out: return 0; } + +void spl_board_init(void) +{ + struct udevice *pinctrl; + int ret; + + ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl); + if (ret) { + debug("%s: Cannot find pinctrl device\n", __func__); + goto err; + } + + /* Enable debug UART */ + ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_UART_DBG); + if (ret) { + debug("%s: Failed to set up console UART\n", __func__); + goto err; + } + + preloader_console_init(); + return; +err: + printf("%s: Error %d\n", __func__, ret); + + /* No way to report error here */ + hang(); +} diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index 45d56cd..e55a5c6 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -3,15 +3,16 @@ * * SPDX-License-Identifier: GPL-2.0+ */ + #include <common.h> #include <dm.h> #include <misc.h> -#include <ram.h> #include <dm/pinctrl.h> #include <dm/uclass-internal.h> #include <asm/setup.h> #include <asm/arch/periph.h> #include <power/regulator.h> +#include <spl.h> #include <u-boot/sha256.h>
DECLARE_GLOBAL_DATA_PTR; @@ -59,6 +60,11 @@ out: return 0; }
+void spl_board_init(void) +{ + preloader_console_init(); +} + static void setup_macaddr(void) { #if CONFIG_IS_ENABLED(CMD_NET) @@ -91,8 +97,6 @@ static void setup_macaddr(void) mac_addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ eth_env_set_enetaddr("ethaddr", mac_addr); #endif - - return; }
static void setup_serial(void) @@ -147,8 +151,6 @@ static void setup_serial(void) env_set("cpuid#", cpuid_str); env_set("serial#", serialno_str); #endif - - return; }
int misc_init_r(void)

The later-stage spl_board_init (as opposed to board_init_f) should set up board-specific details: these differ between the EVB-RK3399 and the RK3399-Q7 (Puma).
This moves spl_board_init back into the individual boards and removes the unneeded functionality from Puma.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
Changes in v2:
- dropped reordering of #includes (as this violated the coding style)
- fixes style-warnings (for a printf and useless return statements) newly raised by patman
arch/arm/mach-rockchip/rk3399-board-spl.c | 27 -------------------- board/rockchip/evb_rk3399/evb-rk3399.c | 30 ++++++++++++++++++++++- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 12 +++++---- 3 files changed, 36 insertions(+), 33 deletions(-)
Applied to u-boot-rockchip, thanks!

The Rockchip BROM allows reading where it booted from from SRAM. This adds the necessary definitions (as received from Kever) for the location of this information in the RK3399's SRAM and naming for the constants used.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
arch/arm/include/asm/arch-rockchip/bootrom.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/arch/arm/include/asm/arch-rockchip/bootrom.h b/arch/arm/include/asm/arch-rockchip/bootrom.h index 92eb878..169cc5e 100644 --- a/arch/arm/include/asm/arch-rockchip/bootrom.h +++ b/arch/arm/include/asm/arch-rockchip/bootrom.h @@ -24,4 +24,22 @@ void back_to_bootrom(void); */ void _back_to_bootrom_s(void);
+/** + * Boot-device identifiers as used by the BROM + */ +enum { + BROM_BOOTSOURCE_NAND = 1, + BROM_BOOTSOURCE_EMMC = 2, + BROM_BOOTSOURCE_SPINOR = 3, + BROM_BOOTSOURCE_SPINAND = 4, + BROM_BOOTSOURCE_SD = 5, + BROM_BOOTSOURCE_USB = 10, + BROM_LAST_BOOTSOURCE = BROM_BOOTSOURCE_USB +}; + +/** + * Locations of the boot-device identifier in SRAM + */ +#define RK3399_BROM_BOOTSOURCE_ID_ADDR 0xff8c0010 + #endif

The Rockchip BROM allows reading where it booted from from SRAM. This adds the necessary definitions (as received from Kever) for the location of this information in the RK3399's SRAM and naming for the constants used.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
arch/arm/include/asm/arch-rockchip/bootrom.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Applied to u-boot-rockchip, thanks!

In the expectation that the spl-boot-order code will eventually gain use outside of mach-rockchip: let's add documentation on the spl_node_to_boot_device() function, which is likely to become a publicly exported function.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
arch/arm/mach-rockchip/spl-boot-order.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c index 4f78c72..0bb9a73 100644 --- a/arch/arm/mach-rockchip/spl-boot-order.c +++ b/arch/arm/mach-rockchip/spl-boot-order.c @@ -10,6 +10,25 @@ #include <spl.h>
#if CONFIG_IS_ENABLED(OF_CONTROL) +/** + * spl_node_to_boot_device() - maps from a DT-node to a SPL boot device + * @node: of_offset of the node + * + * The SPL framework uses BOOT_DEVICE_... constants to identify its boot + * sources. These may take on a device-specific meaning, depending on + * what nodes are enabled in a DTS (e.g. BOOT_DEVICE_MMC1 may refer to + * different controllers/block-devices, depending on which SD/MMC controllers + * are enabled in any given DTS). This function maps from a DT-node back + * onto a BOOT_DEVICE_... constant, considering the currently active devices. + * + * Returns + * -ENOENT, if no device matching the node could be found + * -ENOSYS, if the device matching the node can not be mapped onto a + * SPL boot device (e.g. the third MMC device) + * -1, for unspecified failures + * a positive integer (from the BOOT_DEVICE_... family) on succes. + */ + static int spl_node_to_boot_device(int node) { struct udevice *parent;

In the expectation that the spl-boot-order code will eventually gain use outside of mach-rockchip: let's add documentation on the spl_node_to_boot_device() function, which is likely to become a publicly exported function.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
arch/arm/mach-rockchip/spl-boot-order.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Applied to u-boot-rockchip, thanks!

It is often desirable to configure the spl-boot-order (i.e. the order that SPL probes devices to find the FIT image containing a full U-Boot) such that it contains 'the same device the SPL stage was booted from' early on. To support this, we introduce the 'same-as-spl' specifier for the spl-boot-order property.
This commit adds: - documentation for the new board_spl_was_booted_from() function that individual SoCs/boards should provide, if they can determine where the SPL was booted from - implements the new board_spl_was_booted_from() stub function - adds support for handling the 'same-as-spl' specifier and calling into the per-SoC/per-board support code.
This also updates the documentation for the 'u-boot,spl-boot-order' property.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
arch/arm/mach-rockchip/spl-boot-order.c | 29 ++++++++++++++++++++++++++++- doc/device-tree-bindings/chosen.txt | 12 +++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c index 0bb9a73..843998d 100644 --- a/arch/arm/mach-rockchip/spl-boot-order.c +++ b/arch/arm/mach-rockchip/spl-boot-order.c @@ -76,6 +76,24 @@ static int spl_node_to_boot_device(int node) return -1; }
+/** + * board_spl_was_booted_from() - retrieves the of-path the SPL was loaded from + * + * To support a 'same-as-spl' specification in the search-order for the next + * stage, we need a SoC- or board-specific way to handshake with what 'came + * before us' (either a BROM or TPL stage) and map the info retrieved onto + * a OF path. + * + * Returns + * NULL, on failure or if the device could not be identified + * a of_path (a string), on success + */ +__weak const char *board_spl_was_booted_from(void) +{ + debug("%s: no support for 'same-as-spl' for this board\n", __func__); + return NULL; +} + void board_boot_order(u32 *spl_boot_list) { const void *blob = gd->fdt_blob; @@ -97,8 +115,17 @@ void board_boot_order(u32 *spl_boot_list) (conf = fdt_stringlist_get(blob, chosen_node, "u-boot,spl-boot-order", elem, NULL)); elem++) { + const char *alias; + + /* Handle the case of 'same device the SPL was loaded from' */ + if (strncmp(conf, "same-as-spl", 11) == 0) { + conf = board_spl_was_booted_from(); + if (!conf) + continue; + } + /* First check if the list element is an alias */ - const char *alias = fdt_get_alias(blob, conf); + alias = fdt_get_alias(blob, conf); if (alias) conf = alias;
diff --git a/doc/device-tree-bindings/chosen.txt b/doc/device-tree-bindings/chosen.txt index 5625d21..c96b8f7 100644 --- a/doc/device-tree-bindings/chosen.txt +++ b/doc/device-tree-bindings/chosen.txt @@ -56,10 +56,20 @@ Each list element of the property should specify a device to be probed in the order they are listed: references (i.e. implicit paths), a full path or an alias is expected for each entry.
+A special specifier "same-as-spl" can be used at any position in the +boot-order to direct U-Boot to insert the device the SPL was booted +from there. Whether this is indeed inserted or silently ignored (if +it is not supported on any given SoC/board or if the boot-device is +not available to continue booting from) is implementation-defined. +Note that if "same-as-spl" expands to an actual node for a given +board, the corresponding node may appear multiple times in the +boot-order (as there currently exists no mechanism to suppress +duplicates from the list). + Example ------- / { chosen { - u-boot,spl-boot-order = &sdmmc, "/sdhci@fe330000"; + u-boot,spl-boot-order = "same-as-spl", &sdmmc, "/sdhci@fe330000"; }; };

It is often desirable to configure the spl-boot-order (i.e. the order that SPL probes devices to find the FIT image containing a full U-Boot) such that it contains 'the same device the SPL stage was booted from' early on. To support this, we introduce the 'same-as-spl' specifier for the spl-boot-order property.
This commit adds:
- documentation for the new board_spl_was_booted_from() function that individual SoCs/boards should provide, if they can determine where the SPL was booted from
- implements the new board_spl_was_booted_from() stub function
- adds support for handling the 'same-as-spl' specifier and calling into the per-SoC/per-board support code.
This also updates the documentation for the 'u-boot,spl-boot-order' property.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
arch/arm/mach-rockchip/spl-boot-order.c | 29 ++++++++++++++++++++++++++++- doc/device-tree-bindings/chosen.txt | 12 +++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-)
Applied to u-boot-rockchip, thanks!

To support the new "same-as-spl" specifier in the boot-order on the RK3399, this implements the chip-specific mapping from the information obtainable from the BROM to a OF path name.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
arch/arm/mach-rockchip/rk3399-board-spl.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/arch/arm/mach-rockchip/rk3399-board-spl.c b/arch/arm/mach-rockchip/rk3399-board-spl.c index 8e38ef1..9c20f56 100644 --- a/arch/arm/mach-rockchip/rk3399-board-spl.c +++ b/arch/arm/mach-rockchip/rk3399-board-spl.c @@ -26,6 +26,30 @@ void board_return_to_bootrom(void) back_to_bootrom(); }
+static const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { + [BROM_BOOTSOURCE_EMMC] = "/sdhci@fe330000", + [BROM_BOOTSOURCE_SPINOR] = "/spi@ff1d0000", + [BROM_BOOTSOURCE_SD] = "/dwmmc@fe320000", +}; + +const char *board_spl_was_booted_from(void) +{ + u32 bootdevice_brom_id = readl(RK3399_BROM_BOOTSOURCE_ID_ADDR); + const char *bootdevice_ofpath = NULL; + + if (bootdevice_brom_id < ARRAY_SIZE(boot_devices)) + bootdevice_ofpath = boot_devices[bootdevice_brom_id]; + + if (bootdevice_ofpath) + debug("%s: brom_bootdevice_id %x maps to '%s'\n", + __func__, bootdevice_brom_id, bootdevice_ofpath); + else + debug("%s: failed to resolve brom_bootdevice_id %x\n", + __func__, bootdevice_brom_id); + + return bootdevice_ofpath; +} + u32 spl_boot_device(void) { u32 boot_device = BOOT_DEVICE_MMC1;

To support the new "same-as-spl" specifier in the boot-order on the RK3399, this implements the chip-specific mapping from the information obtainable from the BROM to a OF path name.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
arch/arm/mach-rockchip/rk3399-board-spl.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
Applied to u-boot-rockchip, thanks!

In the general case, we want to continue booting the full U-Boot (contained in a discoverable FIT image) from the same device the SPL stage was loaded from. This prepends the 'same-as-spl' specifier to our configurable boot-order to make this the default behaviour.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
arch/arm/dts/rk3399-puma.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi index a04878e..f95c68e 100644 --- a/arch/arm/dts/rk3399-puma.dtsi +++ b/arch/arm/dts/rk3399-puma.dtsi @@ -20,7 +20,8 @@
chosen { stdout-path = "serial0:115200n8"; - u-boot,spl-boot-order = &spiflash, &sdhci, &sdmmc; + u-boot,spl-boot-order = \ + "same-as-spl", &spiflash, &sdhci, &sdmmc; };
aliases {

In the general case, we want to continue booting the full U-Boot (contained in a discoverable FIT image) from the same device the SPL stage was loaded from. This prepends the 'same-as-spl' specifier to our configurable boot-order to make this the default behaviour.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
arch/arm/dts/rk3399-puma.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to u-boot-rockchip, thanks!

The original initialisation code for board_init() was largely lifted from the code on the EVB. However, the RK3399-Q7 can do with a much more concise init sequence.
This cleans up the board_init() by updating it to the essentials for the RK3399-Q7 and getting rid of the accumulated cruft.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
board/theobroma-systems/puma_rk3399/puma-rk3399.c | 36 +++-------------------- 1 file changed, 4 insertions(+), 32 deletions(-)
diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index e55a5c6..3cab7b1 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -19,44 +19,16 @@ DECLARE_GLOBAL_DATA_PTR;
int board_init(void) { - struct udevice *pinctrl, *regulator; int ret;
/* - * The PWM does not have decicated interrupt number in dts and can - * not get periph_id by pinctrl framework, so let's init them here. - * The PWM2 and PWM3 are for pwm regulators. + * We need to call into regulators_enable_boot_on() again, as the call + * during SPL may have not included all regulators. */ - ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl); - if (ret) { - debug("%s: Cannot find pinctrl device\n", __func__); - goto out; - } - - ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM2); - if (ret) { - debug("%s PWM2 pinctrl init fail!\n", __func__); - goto out; - } - - /* rk3399 need to init vdd_center to get the correct output voltage */ - ret = regulator_get_by_platname("vdd_center", ®ulator); + ret = regulators_enable_boot_on(false); if (ret) - debug("%s: Cannot get vdd_center regulator\n", __func__); - - ret = regulator_get_by_platname("vcc5v0_host", ®ulator); - if (ret) { - debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret); - goto out; - } - - ret = regulator_set_enable(regulator, true); - if (ret) { - debug("%s vcc5v0-host-en set fail!\n", __func__); - goto out; - } + debug("%s: Cannot enable boot on regulator\n", __func__);
-out: return 0; }

The original initialisation code for board_init() was largely lifted from the code on the EVB. However, the RK3399-Q7 can do with a much more concise init sequence.
This cleans up the board_init() by updating it to the essentials for the RK3399-Q7 and getting rid of the accumulated cruft.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
board/theobroma-systems/puma_rk3399/puma-rk3399.c | 36 +++-------------------- 1 file changed, 4 insertions(+), 32 deletions(-)
Applied to u-boot-rockchip, thanks!

The (Qseven) BIOS_DISABLE signal on the RK3399-Q7 (Puma) keeps the eMMC and SPI in reset initially and we need to write a GPIO to turn them on before continuing the boot-up.
This adds the DTS entries for the additional regulator and makes pinctrl and gpio3 available during SPL. It also adds a hook to the spl_board_init() to ensure that the regulator gets probed and enabled.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
---
Changes in v2: - ran 'whitespace-cleanup' on 'rk3399-puma.dtsi'
arch/arm/dts/rk3399-puma.dtsi | 30 ++++++++++++++++++++--- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 10 ++++++++ 2 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/arch/arm/dts/rk3399-puma.dtsi b/arch/arm/dts/rk3399-puma.dtsi index f95c68e..65ab380 100644 --- a/arch/arm/dts/rk3399-puma.dtsi +++ b/arch/arm/dts/rk3399-puma.dtsi @@ -101,6 +101,24 @@ regulator-max-microvolt = <3300000>; };
+ /* + * The Qseven BIOS_DISABLE signal on the RK3399-Q7 keeps the on-module + * eMMC and SPI flash powered-down initially (in fact it keeps the + * reset signal asserted). Even though it is an enable signal, we + * model this as a regulator. + */ + bios_enable: bios_enable { + compatible = "regulator-fixed"; + u-boot,dm-pre-reloc; + regulator-name = "bios_enable"; + enable-active-low; + gpio = <&gpio3 29 GPIO_ACTIVE_HIGH>; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + vccadc_ref: vccadc-ref { compatible = "regulator-fixed"; regulator-name = "vcc1v8_sys"; @@ -459,7 +477,7 @@ };
&pcie_phy { - status = "okay"; + status = "okay"; };
&pmu_io_domains { @@ -486,7 +504,7 @@ };
&sdmmc { - u-boot,dm-pre-reloc; + u-boot,dm-pre-reloc; clock-frequency = <150000000>; clock-freq-min-max = <100000 150000000>; supports-sd; @@ -533,10 +551,15 @@ status = "okay"; };
+&gpio3 { + u-boot,dm-pre-reloc; +}; + &pinctrl { /* Pins that are not explicitely used by any devices */ pinctrl-names = "default"; pinctrl-0 = <&puma_pin_hog>; + hog { puma_pin_hog: puma_pin_hog { rockchip,pins = @@ -576,7 +599,7 @@ i2c8 { i2c8_xfer_a: i2c8-xfer { rockchip,pins = <1 21 RK_FUNC_1 &pcfg_pull_up>, - <1 20 RK_FUNC_1 &pcfg_pull_up>; + <1 20 RK_FUNC_1 &pcfg_pull_up>; }; }; }; @@ -652,4 +675,3 @@ &spi5 { status = "okay"; }; - diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c index 3cab7b1..2b4988e 100644 --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c @@ -34,6 +34,16 @@ int board_init(void)
void spl_board_init(void) { + int ret; + + /* + * Turning the eMMC and SPI back on (if disabled via the Qseven + * BIOS_ENABLE) signal is done through a always-on regulator). + */ + ret = regulators_enable_boot_on(false); + if (ret) + debug("%s: Cannot enable boot on regulator\n", __func__); + preloader_console_init(); }

The (Qseven) BIOS_DISABLE signal on the RK3399-Q7 (Puma) keeps the eMMC and SPI in reset initially and we need to write a GPIO to turn them on before continuing the boot-up.
This adds the DTS entries for the additional regulator and makes pinctrl and gpio3 available during SPL. It also adds a hook to the spl_board_init() to ensure that the regulator gets probed and enabled.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2:
- ran 'whitespace-cleanup' on 'rk3399-puma.dtsi'
arch/arm/dts/rk3399-puma.dtsi | 30 ++++++++++++++++++++--- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 10 ++++++++ 2 files changed, 36 insertions(+), 4 deletions(-)
Applied to u-boot-rockchip, thanks!

The Makefile already tests for SPL_DM_REGULATOR_FIXED, but Kconfig does not provide it. This adds SPL_DM_REGULATOR_FIXED to Kconfig.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
drivers/power/regulator/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 2cfade1..8892fa1 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -77,6 +77,13 @@ config DM_REGULATOR_FIXED features for fixed value regulators. The driver implements get/set api for enable and get only for voltage value.
+config SPL_DM_REGULATOR_FIXED + bool "Enable Driver Model for REGULATOR Fixed value in SPL" + depends on DM_REGULATOR_FIXED + ---help--- + This config enables implementation of driver-model regulator uclass + features for fixed value regulators in SPL. + config DM_REGULATOR_GPIO bool "Enable Driver Model for GPIO REGULATOR" depends on DM_REGULATOR

The Makefile already tests for SPL_DM_REGULATOR_FIXED, but Kconfig does not provide it. This adds SPL_DM_REGULATOR_FIXED to Kconfig.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
drivers/power/regulator/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)
Applied to u-boot-rockchip, thanks!

The RK3399-Q7 requires DM regulator support in SPL, so we can use the regulator framework to reenable the eMMC and SPI, if these had been turned of by the BIOS_DISABLE signal.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
configs/puma-rk3399_defconfig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig index 2ab2516..62a8d7c 100644 --- a/configs/puma-rk3399_defconfig +++ b/configs/puma-rk3399_defconfig @@ -1,5 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_ROCKCHIP=y +CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x4000 @@ -20,6 +21,8 @@ CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x4000 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 +CONFIG_SPL_I2C_SUPPORT=y +CONFIG_SPL_POWER_SUPPORT=y CONFIG_CMD_BOOTZ=y # CONFIG_CMD_IMLS is not set CONFIG_CMD_GPT=y @@ -63,8 +66,10 @@ CONFIG_SPL_PINCTRL=y CONFIG_PINCTRL_ROCKCHIP_RK3399=y CONFIG_DM_PMIC=y CONFIG_PMIC_RK8XX=y -CONFIG_REGULATOR_PWM=y +CONFIG_SPL_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y +CONFIG_SPL_DM_REGULATOR_FIXED=y +CONFIG_DM_REGULATOR_GPIO=y CONFIG_REGULATOR_RK8XX=y CONFIG_PWM_ROCKCHIP=y CONFIG_RAM=y

The RK3399-Q7 requires DM regulator support in SPL, so we can use the regulator framework to reenable the eMMC and SPI, if these had been turned of by the BIOS_DISABLE signal.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
configs/puma-rk3399_defconfig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Applied to u-boot-rockchip, thanks!
participants (1)
-
Philipp Tomsich