Commit ae0d33a7291a164a11ae034bcf4f71226b2bef48
1 parent
884ad05d34
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
rockchip: rk3399-puma: add code to allow forcing a power-on reset
The reset circuitry in the RK3399 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 rk3399-puma (i.e. RK3399-Q7) board-support and the documentation for the new property (sysreset-gpio) within the /config-node. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 2 changed files with 50 additions and 0 deletions Side-by-side Diff
board/theobroma-systems/puma_rk3399/puma-rk3399.c
... | ... | @@ -11,7 +11,10 @@ |
11 | 11 | #include <usb.h> |
12 | 12 | #include <dm/pinctrl.h> |
13 | 13 | #include <dm/uclass-internal.h> |
14 | +#include <asm/gpio.h> | |
14 | 15 | #include <asm/setup.h> |
16 | +#include <asm/arch/clock.h> | |
17 | +#include <asm/arch/cru_rk3399.h> | |
15 | 18 | #include <asm/arch/periph.h> |
16 | 19 | #include <power/regulator.h> |
17 | 20 | #include <u-boot/sha256.h> |
18 | 21 | |
... | ... | @@ -33,9 +36,50 @@ |
33 | 36 | return 0; |
34 | 37 | } |
35 | 38 | |
39 | +static void rk3399_force_power_on_reset(void) | |
40 | +{ | |
41 | + ofnode node; | |
42 | + struct gpio_desc sysreset_gpio; | |
43 | + | |
44 | + debug("%s: trying to force a power-on reset\n", __func__); | |
45 | + | |
46 | + node = ofnode_path("/config"); | |
47 | + if (!ofnode_valid(node)) { | |
48 | + debug("%s: no /config node?\n", __func__); | |
49 | + return; | |
50 | + } | |
51 | + | |
52 | + if (gpio_request_by_name_nodev(node, "sysreset-gpio", 0, | |
53 | + &sysreset_gpio, GPIOD_IS_OUT)) { | |
54 | + debug("%s: could not find a /config/sysreset-gpio\n", __func__); | |
55 | + return; | |
56 | + } | |
57 | + | |
58 | + dm_gpio_set_value(&sysreset_gpio, 1); | |
59 | +} | |
60 | + | |
36 | 61 | void spl_board_init(void) |
37 | 62 | { |
38 | 63 | int ret; |
64 | + struct rk3399_cru *cru = rockchip_get_cru(); | |
65 | + | |
66 | + /* | |
67 | + * The RK3399 resets only 'almost all logic' (see also in the TRM | |
68 | + * "3.9.4 Global software reset"), when issuing a software reset. | |
69 | + * This may cause issues during boot-up for some configurations of | |
70 | + * the application software stack. | |
71 | + * | |
72 | + * To work around this, we test whether the last reset reason was | |
73 | + * a power-on reset and (if not) issue an overtemp-reset to reset | |
74 | + * the entire module. | |
75 | + * | |
76 | + * While this was previously fixed by modifying the various places | |
77 | + * that could generate a software reset (e.g. U-Boot's sysreset | |
78 | + * driver, the ATF or Linux), we now have it here to ensure that | |
79 | + * we no longer have to track this through the various components. | |
80 | + */ | |
81 | + if (cru->glb_rst_st != 0) | |
82 | + rk3399_force_power_on_reset(); | |
39 | 83 | |
40 | 84 | /* |
41 | 85 | * Turning the eMMC and SPI back on (if disabled via the Qseven |
doc/device-tree-bindings/config.txt
... | ... | @@ -46,4 +46,10 @@ |
46 | 46 | If present (and SPL is controlled by the device-tree), this allows |
47 | 47 | to override the CONFIG_SYS_SPI_U_BOOT_OFFS setting using a value |
48 | 48 | from the device-tree. |
49 | + | |
50 | +sysreset-gpio | |
51 | + If present (and supported by the specific board), indicates a | |
52 | + GPIO that can be set to trigger a system reset. It is assumed | |
53 | + that such a system reset will effect a complete platform reset, | |
54 | + being roughly equivalent to a power-on reset. |