From: Ahmad Fatoum <a.fatoum@pengutronix.de> To: barebox@lists.infradead.org Cc: Ahmad Fatoum <a.fatoum@pengutronix.de> Subject: [PATCH 07/11] sandbox: power: implement reset source support Date: Mon, 12 Oct 2020 00:11:56 +0200 [thread overview] Message-ID: <20201011221200.9023-7-a.fatoum@pengutronix.de> (raw) In-Reply-To: <20201011221200.9023-1-a.fatoum@pengutronix.de> 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> --- arch/sandbox/board/power.c | 21 +++++++++++++++++++++ arch/sandbox/dts/sandbox.dts | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c index ffd8692845ef..3cc944795895 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 d32999292eb3..93824cba9da5 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>; }; }; -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-10-11 22:12 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-11 22:11 [PATCH 01/11] sandbox: dts: retire skeleton.dtsi Ahmad Fatoum 2020-10-11 22:11 ` [PATCH 02/11] of: implement of_property_read_u64_array Ahmad Fatoum 2020-10-11 22:11 ` [PATCH 03/11] sandbox: hostfile: unify --image and direct device tree probe Ahmad Fatoum 2020-10-11 22:11 ` [PATCH 04/11] sandbox: hostfile: support anonymous hostfiles in device tree Ahmad Fatoum 2020-10-11 22:11 ` [PATCH 05/11] sandbox: dts: define default environment node Ahmad Fatoum 2020-10-11 22:11 ` [PATCH 06/11] sandbox: poweroff: migrate to driver probed from device tree Ahmad Fatoum 2020-10-11 22:11 ` Ahmad Fatoum [this message] 2020-10-11 22:11 ` [PATCH 08/11] sandbox: dts: implement reboot mode Ahmad Fatoum 2020-10-11 22:11 ` [PATCH 09/11] sandbox: add watchdog driver Ahmad Fatoum 2020-10-11 22:11 ` [PATCH 10/11] sandbox: dts: include state node by default Ahmad Fatoum 2020-10-11 22:12 ` [PATCH 11/11] sandbox: defconfig: enable new generic features Ahmad Fatoum
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201011221200.9023-7-a.fatoum@pengutronix.de \ --to=a.fatoum@pengutronix.de \ --cc=barebox@lists.infradead.org \ --subject='Re: [PATCH 07/11] sandbox: power: implement reset source support' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox