From 7d61a541e5ce8caf10dd8b7d847e12276368952a Mon Sep 17 00:00:00 2001 From: Christoph Muellner Date: Mon, 21 Oct 2019 19:20:09 +0200 Subject: rockchip: rk3368-lion: add code to allow forcing a power-on reset Similar to the RK3399, the RK3368 only resets almost all logic when a software reset is performed. To make our software maintenance easier in the future, we want to have the option (controlled by a DTS property) to force all reset causes other than a power-on reset to trigger a power-on reset via a GPIO trigger. This adds the necessary support to the rk3368-lion (i.e. RK3368-uQ7) board-support. Signed-off-by: Christoph Muellner --- arch/arm/dts/rk3368-lion-u-boot.dtsi | 5 ++++ board/theobroma-systems/lion_rk3368/lion_rk3368.c | 28 ++++++++++++++++++++++- configs/lion-rk3368_defconfig | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/rk3368-lion-u-boot.dtsi b/arch/arm/dts/rk3368-lion-u-boot.dtsi index fb4a4fb59c..077005c1e5 100644 --- a/arch/arm/dts/rk3368-lion-u-boot.dtsi +++ b/arch/arm/dts/rk3368-lion-u-boot.dtsi @@ -7,6 +7,8 @@ config { u-boot,spl-payload-offset = <0x40000>; /* @ 256KB */ u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ + #gpio-cells = <0x2>; + sysreset-gpio = <&gpio0 RK_PA3 GPIO_ACTIVE_HIGH>; }; chosen { @@ -91,4 +93,7 @@ status = "okay"; }; +&gpio0 { + u-boot,dm-pre-reloc; +}; diff --git a/board/theobroma-systems/lion_rk3368/lion_rk3368.c b/board/theobroma-systems/lion_rk3368/lion_rk3368.c index 31e09c87b1..2c5ce7154d 100644 --- a/board/theobroma-systems/lion_rk3368/lion_rk3368.c +++ b/board/theobroma-systems/lion_rk3368/lion_rk3368.c @@ -9,7 +9,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -34,11 +36,35 @@ int board_init(void) return 0; } +static void rk3368_force_power_on_reset(void) +{ + ofnode node; + struct gpio_desc sysreset_gpio; + + debug("%s: trying to force a power-on reset\n", __func__); + + node = ofnode_path("/config"); + if (!ofnode_valid(node)) { + debug("%s: no /config node?\n", __func__); + return; + } + + if (gpio_request_by_name_nodev(node, "sysreset-gpio", 0, + &sysreset_gpio, GPIOD_IS_OUT)) { + debug("%s: could not find a /config/sysreset-gpio\n", __func__); + return; + } + + dm_gpio_set_value(&sysreset_gpio, 1); +} + void spl_board_init(void) { int ret; + struct rk3368_cru *cru = rockchip_get_cru(); - debug("%s: calling regulators_enable_boot_on\n", __func__); + if (cru->glb_rst_st != 0) + rk3368_force_power_on_reset(); ret = regulators_enable_boot_on(false); if (ret) diff --git a/configs/lion-rk3368_defconfig b/configs/lion-rk3368_defconfig index 7b0da59fbf..6a0476251c 100644 --- a/configs/lion-rk3368_defconfig +++ b/configs/lion-rk3368_defconfig @@ -1,6 +1,7 @@ CONFIG_ARM=y CONFIG_ARCH_ROCKCHIP=y CONFIG_SYS_TEXT_BASE=0x00200000 +CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x2000 -- cgit v1.2.3