===================================================================
@@ -0,0 +1,15 @@
+Broadcom BCM4760 and BCM4761 watchdog timer device tree bindings
+----------------------------------------------------------------
+
+Required properties:
+
+- compatible : should be "brcm,bcm4760-pm-wdt" or
+ "brcm,bcm4761-pm-wdt"
+- reg : Specifies base physical address and size of the registers.
+
+Example:
+
+watchdog {
+ compatible = "brcm,bcm4760-pm-wdt";
+ reg = <0xbd000 0x1000>;
+};
===================================================================
@@ -24,6 +24,11 @@
clock-frequency = <32000>;
};
+ watchdog {
+ compatible = "brcm,bcm4760-pm-wdt";
+ reg = <0xbd000 0x1000>;
+ };
+
vic0: interrupt-controller@80000 {
compatible = "brcm,bcm4760-pl192", "arm,pl192-vic", "arm,primecell";
reg = <0x80000 0x1000>;
===================================================================
@@ -24,6 +24,11 @@
clock-frequency = <32000>;
};
+ watchdog {
+ compatible = "brcm,bcm4761-pm-wdt";
+ reg = <0xbd000 0x1000>;
+ };
+
vic0: interrupt-controller@80000 {
compatible = "brcm,bcm4761-pl192", "arm,pl192-vic", "arm,primecell";
reg = <0x80000 0x1000>;
===================================================================
@@ -15,7 +15,9 @@
*/
#include <linux/init.h>
+#include <linux/delay.h>
#include <linux/of_irq.h>
+#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/bcm476x_timer.h>
#include <linux/clk/bcm476x.h>
@@ -28,6 +30,17 @@
#define BCM476X_PERIPH_VIRT IOMEM(0xd0080000)
#define BCM476X_PERIPH_SIZE SZ_512K
+#define BCM476X_WDT_LOAD 0x000
+#define BCM476X_WDT_CTRL 0x008
+#define BCM476X_WDT_INTCLR 0x00c
+#define BCM476X_WDT_LOCK 0xc00
+
+#define BCM476X_WDT_PASSWORD 0x1acce551
+#define BCM476X_WDT_INTEN BIT(0)
+#define BCM476X_WDT_RESEN BIT(1)
+
+static void __iomem *wdt_regs;
+
static struct map_desc io_map __initdata = {
.virtual = (unsigned long) BCM476X_PERIPH_VIRT,
.pfn = __phys_to_pfn(BCM476X_PERIPH_PHYS),
@@ -40,10 +53,75 @@ static void __init bcm476x_map_io(void)
iotable_init(&io_map, 1);
}
+static const struct of_device_id bcm476x_pm_wdt_match[] __initconst = {
+ { .compatible = "brcm,bcm4760-pm-wdt" },
+ { .compatible = "brcm,bcm4761-pm-wdt" },
+ {}
+};
+
+/*
+ * The machine restart method can be called from an atomic context so we won't
+ * be able to ioremap the regs then.
+ */
+static void bcm476x_setup_restart(void)
+{
+ struct device_node *node;
+
+ node = of_find_matching_node(NULL, bcm476x_pm_wdt_match);
+ if (!node) {
+ pr_info("No bcm476x watchdog node\n");
+ return;
+ }
+
+ wdt_regs = of_iomap(node, 0);
+ if (!wdt_regs) {
+ pr_err("Can't remap watchdog registers\n");
+ return;
+ }
+
+ /* unlock watchdog registers */
+ writel(BCM476X_WDT_PASSWORD, wdt_regs + BCM476X_WDT_LOCK);
+ /* disable watchdog */
+ writel(0, wdt_regs + BCM476X_WDT_CTRL);
+ /* lock watchdog registers */
+ writel(1, wdt_regs + BCM476X_WDT_LOCK);
+}
+
+static void bcm476x_restart(char mode, const char *cmd)
+{
+ if (!wdt_regs) {
+ pr_err("No restart hook installed. ");
+ return;
+ }
+
+ /* unlock watchdog registers */
+ writel(BCM476X_WDT_PASSWORD, wdt_regs + BCM476X_WDT_LOCK);
+
+ /* disable watchdog */
+ writel(0, wdt_regs + BCM476X_WDT_CTRL);
+ udelay(20);
+
+ /* clear the irq status */
+ writel(1, wdt_regs + BCM476X_WDT_INTCLR);
+ udelay(20);
+
+ /* expire after 5 cycles (~156us) */
+ writel(5, wdt_regs + BCM476X_WDT_LOAD);
+ /* enable watchdog */
+ writel(BCM476X_WDT_INTEN | BCM476X_WDT_RESEN,
+ wdt_regs + BCM476X_WDT_CTRL);
+
+ /* lock watchdog registers */
+ writel(1, wdt_regs + BCM476X_WDT_LOCK);
+ /* wait the bite */
+ udelay(400);
+}
+
static void __init bcm476x_init(void)
{
int err;
+ bcm476x_setup_restart();
bcm476x_init_clocks();
err = of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
@@ -75,5 +153,6 @@ DT_MACHINE_START(BCM476X, "Broadcom BCM4
.handle_irq = vic_handle_irq,
.init_machine = bcm476x_init,
.timer = &bcm476x_timer,
+ .restart = bcm476x_restart,
.dt_compat = bcm476x_compat
MACHINE_END