aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-picoxcell/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-picoxcell/common.c')
-rw-r--r--arch/arm/mach-picoxcell/common.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/arch/arm/mach-picoxcell/common.c b/arch/arm/mach-picoxcell/common.c
index ad871bd7b1a..a2e8ae8b582 100644
--- a/arch/arm/mach-picoxcell/common.c
+++ b/arch/arm/mach-picoxcell/common.c
@@ -7,6 +7,7 @@
7 * 7 *
8 * All enquiries to support@picochip.com 8 * All enquiries to support@picochip.com
9 */ 9 */
10#include <linux/delay.h>
10#include <linux/irq.h> 11#include <linux/irq.h>
11#include <linux/irqdomain.h> 12#include <linux/irqdomain.h>
12#include <linux/of.h> 13#include <linux/of.h>
@@ -16,15 +17,49 @@
16 17
17#include <asm/mach/arch.h> 18#include <asm/mach/arch.h>
18#include <asm/hardware/vic.h> 19#include <asm/hardware/vic.h>
20#include <asm/mach/map.h>
19 21
20#include <mach/map.h> 22#include <mach/map.h>
21#include <mach/picoxcell_soc.h> 23#include <mach/picoxcell_soc.h>
22 24
23#include "common.h" 25#include "common.h"
24 26
27#define WDT_CTRL_REG_EN_MASK (1 << 0)
28#define WDT_CTRL_REG_OFFS (0x00)
29#define WDT_TIMEOUT_REG_OFFS (0x04)
30static void __iomem *wdt_regs;
31
32/*
33 * The machine restart method can be called from an atomic context so we won't
34 * be able to ioremap the regs then.
35 */
36static void picoxcell_setup_restart(void)
37{
38 struct device_node *np = of_find_compatible_node(NULL, NULL,
39 "snps,dw-apb-wdg");
40 if (WARN(!np, "unable to setup watchdog restart"))
41 return;
42
43 wdt_regs = of_iomap(np, 0);
44 WARN(!wdt_regs, "failed to remap watchdog regs");
45}
46
47static struct map_desc io_map __initdata = {
48 .virtual = PHYS_TO_IO(PICOXCELL_PERIPH_BASE),
49 .pfn = __phys_to_pfn(PICOXCELL_PERIPH_BASE),
50 .length = PICOXCELL_PERIPH_LENGTH,
51 .type = MT_DEVICE,
52};
53
54static void __init picoxcell_map_io(void)
55{
56 iotable_init(&io_map, 1);
57}
58
25static void __init picoxcell_init_machine(void) 59static void __init picoxcell_init_machine(void)
26{ 60{
27 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 61 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
62 picoxcell_setup_restart();
28} 63}
29 64
30static const char *picoxcell_dt_match[] = { 65static const char *picoxcell_dt_match[] = {
@@ -43,12 +78,27 @@ static void __init picoxcell_init_irq(void)
43 of_irq_init(vic_of_match); 78 of_irq_init(vic_of_match);
44} 79}
45 80
81static void picoxcell_wdt_restart(char mode, const char *cmd)
82{
83 /*
84 * Configure the watchdog to reset with the shortest possible timeout
85 * and give it chance to do the reset.
86 */
87 if (wdt_regs) {
88 writel_relaxed(WDT_CTRL_REG_EN_MASK, wdt_regs + WDT_CTRL_REG_OFFS);
89 writel_relaxed(0, wdt_regs + WDT_TIMEOUT_REG_OFFS);
90 /* No sleeping, possibly atomic. */
91 mdelay(500);
92 }
93}
94
46DT_MACHINE_START(PICOXCELL, "Picochip picoXcell") 95DT_MACHINE_START(PICOXCELL, "Picochip picoXcell")
47 .map_io = picoxcell_map_io, 96 .map_io = picoxcell_map_io,
48 .nr_irqs = ARCH_NR_IRQS, 97 .nr_irqs = NR_IRQS_LEGACY,
49 .init_irq = picoxcell_init_irq, 98 .init_irq = picoxcell_init_irq,
50 .handle_irq = vic_handle_irq, 99 .handle_irq = vic_handle_irq,
51 .timer = &picoxcell_timer, 100 .timer = &picoxcell_timer,
52 .init_machine = picoxcell_init_machine, 101 .init_machine = picoxcell_init_machine,
53 .dt_compat = picoxcell_dt_match, 102 .dt_compat = picoxcell_dt_match,
103 .restart = picoxcell_wdt_restart,
54MACHINE_END 104MACHINE_END