* [PATCH] ARM: bcm2835: implement machine restart hook @ 2012-09-28 4:08 Stephen Warren [not found] ` <1348805280-7647-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Stephen Warren @ 2012-09-28 4:08 UTC (permalink / raw) To: Stephen Warren Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Implement the machine restart hook using the SoC's watchdog timer module. To support this, define a DT binding for the watchdog module, and add it to the device tree. The downstream rpi-split branch contains a full watchdog timer driver implementation, which also implements the restart hook. However, the restart function is largely separate from the watchdog driver, so for simplicity, the restart hook is implemented here directly in the main machine source file. Overall structure (separate setup/restart) functions derived from the picoxcell ARM support. Watchdog register IO sequence taken from code by Simon Arlott. Note that the watchdog module is not documented in BCM2835-ARM-Peripherals.pdf. Signed-off-by: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> --- .../bindings/watchdog/brcm,bcm2835-pm-wdog.txt | 13 ++++++ arch/arm/boot/dts/bcm2835.dtsi | 5 +++ arch/arm/mach-bcm2835/bcm2835.c | 46 ++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt b/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt new file mode 100644 index 0000000..03138e6 --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt @@ -0,0 +1,13 @@ +BCM2835 Watchdog timer + +Required properties: + +- compatible : should be "brcm,bcm2835-pm-wdog" +- reg : Specifies base physical address and size of the registers. + +Example: + +intc: interrupt-controller { + compatible = "brcm,bcm2835-pm-wdog"; + reg = <0x7e100000 0x28>; +}; diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi index 0b61939..7e0d515 100644 --- a/arch/arm/boot/dts/bcm2835.dtsi +++ b/arch/arm/boot/dts/bcm2835.dtsi @@ -29,6 +29,11 @@ #interrupt-cells = <2>; }; + watchdog { + compatible = "brcm,bcm2835-pm-wdog"; + reg = <0x7e100000 0x28>; + }; + uart@20201000 { compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell"; reg = <0x7e201000 0x1000>; diff --git a/arch/arm/mach-bcm2835/bcm2835.c b/arch/arm/mach-bcm2835/bcm2835.c index f6fea49..35859c6 100644 --- a/arch/arm/mach-bcm2835/bcm2835.c +++ b/arch/arm/mach-bcm2835/bcm2835.c @@ -12,8 +12,10 @@ * GNU General Public License for more details. */ +#include <linux/delay.h> #include <linux/init.h> #include <linux/irqchip/bcm2835.h> +#include <linux/of_address.h> #include <linux/of_platform.h> #include <linux/bcm2835_timer.h> #include <linux/clk/bcm2835.h> @@ -23,6 +25,48 @@ #include <mach/bcm2835_soc.h> +#define PM_RSTC 0x1c +#define PM_WDOG 0x24 + +#define PM_PASSWORD 0x5a000000 +#define PM_RSTC_WRCFG_MASK 0x00000030 +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020 + +static void __iomem *wdt_regs; + +/* + * The machine restart method can be called from an atomic context so we won't + * be able to ioremap the regs then. + */ +static void bcm2835_setup_restart(void) +{ + struct device_node *np = of_find_compatible_node(NULL, NULL, + "brcm,bcm2835-pm-wdog"); + if (WARN(!np, "unable to setup watchdog restart")) + return; + + wdt_regs = of_iomap(np, 0); + WARN(!wdt_regs, "failed to remap watchdog regs"); +} + +static void bcm2835_restart(char mode, const char *cmd) +{ + u32 val; + + if (!wdt_regs) + return; + + /* use a timeout of 10 ticks (~150us) */ + writel_relaxed(10 | PM_PASSWORD, wdt_regs + PM_WDOG); + val = readl_relaxed(wdt_regs + PM_RSTC); + val &= ~PM_RSTC_WRCFG_MASK; + val |= PM_PASSWORD | PM_RSTC_WRCFG_FULL_RESET; + writel_relaxed(val, wdt_regs + PM_RSTC); + + /* No sleeping, possibly atomic. */ + mdelay(1); +} + static struct map_desc io_map __initdata = { .virtual = BCM2835_PERIPH_VIRT, .pfn = __phys_to_pfn(BCM2835_PERIPH_PHYS), @@ -39,6 +83,7 @@ void __init bcm2835_init(void) { int ret; + bcm2835_setup_restart(); bcm2835_init_clocks(); ret = of_platform_populate(NULL, of_default_bus_match_table, NULL, @@ -60,5 +105,6 @@ DT_MACHINE_START(BCM2835, "BCM2835") .handle_irq = bcm2835_handle_irq, .init_machine = bcm2835_init, .timer = &bcm2835_timer, + .restart = bcm2835_restart, .dt_compat = bcm2835_compat MACHINE_END -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <1348805280-7647-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>]
* Re: [PATCH] ARM: bcm2835: implement machine restart hook [not found] ` <1348805280-7647-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> @ 2012-09-28 10:15 ` Thomas Petazzoni 2012-09-28 14:56 ` Stephen Warren 2012-09-28 10:31 ` Jean-Christophe PLAGNIOL-VILLARD 2012-10-26 2:51 ` Stephen Warren 2 siblings, 1 reply; 6+ messages in thread From: Thomas Petazzoni @ 2012-09-28 10:15 UTC (permalink / raw) To: Stephen Warren Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Stephen, On Thu, 27 Sep 2012 22:08:00 -0600, Stephen Warren wrote: > +intc: interrupt-controller { Isn't this a bizarre name for a watchdog device? > + compatible = "brcm,bcm2835-pm-wdog"; > + reg = <0x7e100000 0x28>; > +}; Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: bcm2835: implement machine restart hook 2012-09-28 10:15 ` Thomas Petazzoni @ 2012-09-28 14:56 ` Stephen Warren 0 siblings, 0 replies; 6+ messages in thread From: Stephen Warren @ 2012-09-28 14:56 UTC (permalink / raw) To: Thomas Petazzoni Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On 09/28/2012 04:15 AM, Thomas Petazzoni wrote: > Stephen, > > On Thu, 27 Sep 2012 22:08:00 -0600, Stephen Warren wrote: > >> +intc: interrupt-controller { > > Isn't this a bizarre name for a watchdog device? Yes, certainly! It looks like I only made this cut/paste mistake in the binding document, which is why the code actually worked... >> + compatible = "brcm,bcm2835-pm-wdog"; >> + reg = <0x7e100000 0x28>; >> +}; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: bcm2835: implement machine restart hook [not found] ` <1348805280-7647-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> 2012-09-28 10:15 ` Thomas Petazzoni @ 2012-09-28 10:31 ` Jean-Christophe PLAGNIOL-VILLARD [not found] ` <20120928103140.GZ17667-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org> 2012-10-26 2:51 ` Stephen Warren 2 siblings, 1 reply; 6+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-28 10:31 UTC (permalink / raw) To: Stephen Warren Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On 22:08 Thu 27 Sep , Stephen Warren wrote: > Implement the machine restart hook using the SoC's watchdog timer module. > To support this, define a DT binding for the watchdog module, and add it > to the device tree. > > The downstream rpi-split branch contains a full watchdog timer driver > implementation, which also implements the restart hook. However, the > restart function is largely separate from the watchdog driver, so for > simplicity, the restart hook is implemented here directly in the main > machine source file. > > Overall structure (separate setup/restart) functions derived from the > picoxcell ARM support. > > Watchdog register IO sequence taken from code by Simon Arlott. Note that > the watchdog module is not documented in BCM2835-ARM-Peripherals.pdf. > > Signed-off-by: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> > --- > .../bindings/watchdog/brcm,bcm2835-pm-wdog.txt | 13 ++++++ > arch/arm/boot/dts/bcm2835.dtsi | 5 +++ > arch/arm/mach-bcm2835/bcm2835.c | 46 ++++++++++++++++++++ > 3 files changed, 64 insertions(+) > create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt > > diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt b/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt > new file mode 100644 > index 0000000..03138e6 > --- /dev/null > +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt > @@ -0,0 +1,13 @@ > +BCM2835 Watchdog timer > + > +Required properties: > + > +- compatible : should be "brcm,bcm2835-pm-wdog" > +- reg : Specifies base physical address and size of the registers. > + > +Example: > + > +intc: interrupt-controller { > + compatible = "brcm,bcm2835-pm-wdog"; it's seems everyone use -wdt Best Regards, J. ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <20120928103140.GZ17667-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org>]
* Re: [PATCH] ARM: bcm2835: implement machine restart hook [not found] ` <20120928103140.GZ17667-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org> @ 2012-09-28 14:57 ` Stephen Warren 0 siblings, 0 replies; 6+ messages in thread From: Stephen Warren @ 2012-09-28 14:57 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On 09/28/2012 04:31 AM, Jean-Christophe PLAGNIOL-VILLARD wrote: > On 22:08 Thu 27 Sep , Stephen Warren wrote: >> Implement the machine restart hook using the SoC's watchdog timer module. >> To support this, define a DT binding for the watchdog module, and add it >> to the device tree. >> >> The downstream rpi-split branch contains a full watchdog timer driver >> implementation, which also implements the restart hook. However, the >> restart function is largely separate from the watchdog driver, so for >> simplicity, the restart hook is implemented here directly in the main >> machine source file. >> +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm2835-pm-wdog.txt >> +Example: >> + >> +intc: interrupt-controller { >> + compatible = "brcm,bcm2835-pm-wdog"; > > it's seems everyone use -wdt That is true. "-wdog" is what was in the downstream patch, but I guess it makes sense to fix it up to be consistent with everything already in the kernel. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ARM: bcm2835: implement machine restart hook [not found] ` <1348805280-7647-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> 2012-09-28 10:15 ` Thomas Petazzoni 2012-09-28 10:31 ` Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-26 2:51 ` Stephen Warren 2 siblings, 0 replies; 6+ messages in thread From: Stephen Warren @ 2012-10-26 2:51 UTC (permalink / raw) To: Stephen Warren Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r On 09/27/2012 10:08 PM, Stephen Warren wrote: > Implement the machine restart hook using the SoC's watchdog timer module. > To support this, define a DT binding for the watchdog module, and add it > to the device tree. > > The downstream rpi-split branch contains a full watchdog timer driver > implementation, which also implements the restart hook. However, the > restart function is largely separate from the watchdog driver, so for > simplicity, the restart hook is implemented here directly in the main > machine source file. > > Overall structure (separate setup/restart) functions derived from the > picoxcell ARM support. > > Watchdog register IO sequence taken from code by Simon Arlott. Note that > the watchdog module is not documented in BCM2835-ARM-Peripherals.pdf. Applied to rpi's for-3.8/soc branch. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-10-26 2:51 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-09-28 4:08 [PATCH] ARM: bcm2835: implement machine restart hook Stephen Warren [not found] ` <1348805280-7647-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> 2012-09-28 10:15 ` Thomas Petazzoni 2012-09-28 14:56 ` Stephen Warren 2012-09-28 10:31 ` Jean-Christophe PLAGNIOL-VILLARD [not found] ` <20120928103140.GZ17667-RQcB7r2h9QmfDR2tN2SG5Ni2O/JbrIOy@public.gmane.org> 2012-09-28 14:57 ` Stephen Warren 2012-10-26 2:51 ` Stephen Warren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).