diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-10-12 08:26:15 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-10-13 08:45:15 +0200 |
commit | 0589fdfe78fa3b306c9c37b65040543454209813 (patch) | |
tree | 36cb7af6579445df7d80d2dda36b46c0b5ba86ed /arch/sandbox | |
parent | d2748c1ae720ee594fa56d8185b59fbfb222b23b (diff) | |
download | barebox-0589fdfe78fa3b306c9c37b65040543454209813.tar.gz barebox-0589fdfe78fa3b306c9c37b65040543454209813.tar.xz |
sandbox: power: implement reset source support
We can differentiate between POR and RST by explicitly storing RST as
reset reason when we invoke the reset handler. Do so.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox')
-rw-r--r-- | arch/sandbox/board/power.c | 21 | ||||
-rw-r--r-- | arch/sandbox/dts/sandbox.dts | 5 |
2 files changed, 25 insertions, 1 deletions
diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c index ffd8692845..3cc9447958 100644 --- a/arch/sandbox/board/power.c +++ b/arch/sandbox/board/power.c @@ -4,9 +4,12 @@ #include <restart.h> #include <mach/linux.h> #include <reset_source.h> +#include <mfd/syscon.h> struct sandbox_power { struct restart_handler rst_hang, rst_reexec; + struct regmap *src; + u32 src_offset; }; static void sandbox_poweroff(struct poweroff_handler *poweroff) @@ -21,12 +24,16 @@ static void sandbox_rst_hang(struct restart_handler *rst) static void sandbox_rst_reexec(struct restart_handler *rst) { + struct sandbox_power *power = container_of(rst, struct sandbox_power, rst_reexec); + regmap_update_bits(power->src, power->src_offset, 0xff, RESET_RST); linux_reexec(); } static int sandbox_power_probe(struct device_d *dev) { struct sandbox_power *power = xzalloc(sizeof(*power)); + unsigned int rst; + int ret; poweroff_handler_register_fn(sandbox_poweroff); @@ -45,6 +52,20 @@ static int sandbox_power_probe(struct device_d *dev) if (IS_ENABLED(CONFIG_SANDBOX_REEXEC)) restart_handler_register(&power->rst_reexec); + power->src = syscon_regmap_lookup_by_phandle(dev->device_node, "barebox,reset-source"); + if (IS_ERR(power->src)) + return 0; + + ret = of_property_read_u32_index(dev->device_node, "barebox,reset-source", 1, + &power->src_offset); + if (ret) + return 0; + + ret = regmap_read(power->src, power->src_offset, &rst); + if (ret == 0 && rst == 0) + rst = RESET_POR; + + reset_source_set_prinst(rst, RESET_SOURCE_DEFAULT_PRIORITY, 0); return 0; } diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index d32999292e..93824cba9d 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -23,7 +23,7 @@ }; stickypage: stickypage { - compatible = "barebox,hostfile"; + compatible = "barebox,hostfile", "syscon"; reg = <0 0 0 4096>; partitions { @@ -31,6 +31,8 @@ #address-cells = <1>; #size-cells = <1>; + /* 0x00+4 reserved for syscon use */ + part_env: env@400 { reg = <0x400 0x800>; label = "env"; @@ -40,5 +42,6 @@ power { compatible = "barebox,sandbox-power"; + barebox,reset-source = <&stickypage 0>; }; }; |