2 * Copyright (c) 2011 Picochip Ltd., Jamie Iles
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * All enquiries to support@picochip.com
10 #include <linux/delay.h>
11 #include <linux/irq.h>
12 #include <linux/irqdomain.h>
14 #include <linux/of_address.h>
15 #include <linux/of_irq.h>
16 #include <linux/of_platform.h>
17 #include <linux/dw_apb_timer.h>
19 #include <asm/mach/arch.h>
20 #include <asm/hardware/vic.h>
21 #include <asm/mach/map.h>
24 #include <mach/picoxcell_soc.h>
28 #define WDT_CTRL_REG_EN_MASK (1 << 0)
29 #define WDT_CTRL_REG_OFFS (0x00)
30 #define WDT_TIMEOUT_REG_OFFS (0x04)
31 static void __iomem
*wdt_regs
;
34 * The machine restart method can be called from an atomic context so we won't
35 * be able to ioremap the regs then.
37 static void picoxcell_setup_restart(void)
39 struct device_node
*np
= of_find_compatible_node(NULL
, NULL
,
41 if (WARN(!np
, "unable to setup watchdog restart"))
44 wdt_regs
= of_iomap(np
, 0);
45 WARN(!wdt_regs
, "failed to remap watchdog regs");
48 static struct map_desc io_map __initdata
= {
49 .virtual = PHYS_TO_IO(PICOXCELL_PERIPH_BASE
),
50 .pfn
= __phys_to_pfn(PICOXCELL_PERIPH_BASE
),
51 .length
= PICOXCELL_PERIPH_LENGTH
,
55 static void __init
picoxcell_map_io(void)
57 iotable_init(&io_map
, 1);
60 static void __init
picoxcell_init_machine(void)
62 of_platform_populate(NULL
, of_default_bus_match_table
, NULL
, NULL
);
63 picoxcell_setup_restart();
66 static const char *picoxcell_dt_match
[] = {
72 static const struct of_device_id vic_of_match
[] __initconst
= {
73 { .compatible
= "arm,pl192-vic", .data
= vic_of_init
, },
77 static void __init
picoxcell_init_irq(void)
79 of_irq_init(vic_of_match
);
82 static void picoxcell_wdt_restart(char mode
, const char *cmd
)
85 * Configure the watchdog to reset with the shortest possible timeout
86 * and give it chance to do the reset.
89 writel_relaxed(WDT_CTRL_REG_EN_MASK
, wdt_regs
+ WDT_CTRL_REG_OFFS
);
90 writel_relaxed(0, wdt_regs
+ WDT_TIMEOUT_REG_OFFS
);
91 /* No sleeping, possibly atomic. */
96 DT_MACHINE_START(PICOXCELL
, "Picochip picoXcell")
97 .map_io
= picoxcell_map_io
,
98 .nr_irqs
= NR_IRQS_LEGACY
,
99 .init_irq
= picoxcell_init_irq
,
100 .handle_irq
= vic_handle_irq
,
101 .timer
= &dw_apb_timer
,
102 .init_machine
= picoxcell_init_machine
,
103 .dt_compat
= picoxcell_dt_match
,
104 .restart
= picoxcell_wdt_restart
,