diff options
-rw-r--r-- | arch/arm/plat-s3c24xx/cpu.c | 27 | ||||
-rw-r--r-- | include/asm-arm/arch-s3c2410/system-reset.h | 64 | ||||
-rw-r--r-- | include/asm-arm/arch-s3c2410/system.h | 46 |
3 files changed, 92 insertions, 45 deletions
diff --git a/arch/arm/plat-s3c24xx/cpu.c b/arch/arm/plat-s3c24xx/cpu.c index f513ab083b8f..f5699cadb0c3 100644 --- a/arch/arm/plat-s3c24xx/cpu.c +++ b/arch/arm/plat-s3c24xx/cpu.c | |||
@@ -28,15 +28,19 @@ | |||
28 | #include <linux/ioport.h> | 28 | #include <linux/ioport.h> |
29 | #include <linux/serial_core.h> | 29 | #include <linux/serial_core.h> |
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/delay.h> | ||
31 | 32 | ||
32 | #include <asm/hardware.h> | 33 | #include <asm/hardware.h> |
33 | #include <asm/irq.h> | 34 | #include <asm/irq.h> |
34 | #include <asm/io.h> | 35 | #include <asm/io.h> |
35 | #include <asm/delay.h> | 36 | #include <asm/delay.h> |
37 | #include <asm/cacheflush.h> | ||
36 | 38 | ||
37 | #include <asm/mach/arch.h> | 39 | #include <asm/mach/arch.h> |
38 | #include <asm/mach/map.h> | 40 | #include <asm/mach/map.h> |
39 | 41 | ||
42 | #include <asm/arch/system-reset.h> | ||
43 | |||
40 | #include <asm/arch/regs-gpio.h> | 44 | #include <asm/arch/regs-gpio.h> |
41 | #include <asm/plat-s3c/regs-serial.h> | 45 | #include <asm/plat-s3c/regs-serial.h> |
42 | 46 | ||
@@ -203,6 +207,27 @@ static unsigned long s3c24xx_read_idcode_v4(void) | |||
203 | #endif | 207 | #endif |
204 | } | 208 | } |
205 | 209 | ||
210 | /* Hook for arm_pm_restart to ensure we execute the reset code | ||
211 | * with the caches enabled. It seems at least the S3C2440 has a problem | ||
212 | * resetting if there is bus activity interrupted by the reset. | ||
213 | */ | ||
214 | static void s3c24xx_pm_restart(char mode) | ||
215 | { | ||
216 | if (mode != 's') { | ||
217 | unsigned long flags; | ||
218 | |||
219 | local_irq_save(flags); | ||
220 | __cpuc_flush_kern_all(); | ||
221 | __cpuc_flush_user_all(); | ||
222 | |||
223 | arch_reset(mode); | ||
224 | local_irq_restore(flags); | ||
225 | } | ||
226 | |||
227 | /* fallback, or unhandled */ | ||
228 | arm_machine_restart(mode); | ||
229 | } | ||
230 | |||
206 | void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) | 231 | void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) |
207 | { | 232 | { |
208 | unsigned long idcode = 0x0; | 233 | unsigned long idcode = 0x0; |
@@ -230,6 +255,8 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) | |||
230 | panic("Unsupported S3C24XX CPU"); | 255 | panic("Unsupported S3C24XX CPU"); |
231 | } | 256 | } |
232 | 257 | ||
258 | arm_pm_restart = s3c24xx_pm_restart; | ||
259 | |||
233 | (cpu->map_io)(mach_desc, size); | 260 | (cpu->map_io)(mach_desc, size); |
234 | } | 261 | } |
235 | 262 | ||
diff --git a/include/asm-arm/arch-s3c2410/system-reset.h b/include/asm-arm/arch-s3c2410/system-reset.h new file mode 100644 index 000000000000..1615bce0c026 --- /dev/null +++ b/include/asm-arm/arch-s3c2410/system-reset.h | |||
@@ -0,0 +1,64 @@ | |||
1 | /* linux/include/asm-arm/arch-s3c2410/system-reset.h | ||
2 | * | ||
3 | * Copyright (c) 2008 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * S3C2410 - System define for arch_reset() function | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <asm/hardware.h> | ||
14 | #include <asm/io.h> | ||
15 | |||
16 | #include <asm/plat-s3c/regs-watchdog.h> | ||
17 | #include <asm/arch/regs-clock.h> | ||
18 | |||
19 | #include <linux/clk.h> | ||
20 | #include <linux/err.h> | ||
21 | |||
22 | extern void (*s3c24xx_reset_hook)(void); | ||
23 | |||
24 | static void | ||
25 | arch_reset(char mode) | ||
26 | { | ||
27 | struct clk *wdtclk; | ||
28 | |||
29 | if (mode == 's') { | ||
30 | cpu_reset(0); | ||
31 | } | ||
32 | |||
33 | if (s3c24xx_reset_hook) | ||
34 | s3c24xx_reset_hook(); | ||
35 | |||
36 | printk("arch_reset: attempting watchdog reset\n"); | ||
37 | |||
38 | __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ | ||
39 | |||
40 | wdtclk = clk_get(NULL, "watchdog"); | ||
41 | if (!IS_ERR(wdtclk)) { | ||
42 | clk_enable(wdtclk); | ||
43 | } else | ||
44 | printk(KERN_WARNING "%s: warning: cannot get watchdog clock\n", __func__); | ||
45 | |||
46 | /* put initial values into count and data */ | ||
47 | __raw_writel(0x80, S3C2410_WTCNT); | ||
48 | __raw_writel(0x80, S3C2410_WTDAT); | ||
49 | |||
50 | /* set the watchdog to go and reset... */ | ||
51 | __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN | | ||
52 | S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON); | ||
53 | |||
54 | /* wait for reset to assert... */ | ||
55 | mdelay(500); | ||
56 | |||
57 | printk(KERN_ERR "Watchdog reset failed to assert reset\n"); | ||
58 | |||
59 | /* delay to allow the serial port to show the message */ | ||
60 | mdelay(50); | ||
61 | |||
62 | /* we'll take a jump through zero as a poor second */ | ||
63 | cpu_reset(0); | ||
64 | } | ||
diff --git a/include/asm-arm/arch-s3c2410/system.h b/include/asm-arm/arch-s3c2410/system.h index 14de4e596f87..ad258085e53b 100644 --- a/include/asm-arm/arch-s3c2410/system.h +++ b/include/asm-arm/arch-s3c2410/system.h | |||
@@ -17,12 +17,8 @@ | |||
17 | #include <asm/arch/idle.h> | 17 | #include <asm/arch/idle.h> |
18 | #include <asm/arch/reset.h> | 18 | #include <asm/arch/reset.h> |
19 | 19 | ||
20 | #include <asm/plat-s3c/regs-watchdog.h> | ||
21 | #include <asm/arch/regs-clock.h> | 20 | #include <asm/arch/regs-clock.h> |
22 | 21 | ||
23 | #include <linux/clk.h> | ||
24 | #include <linux/err.h> | ||
25 | |||
26 | void (*s3c24xx_idle)(void); | 22 | void (*s3c24xx_idle)(void); |
27 | void (*s3c24xx_reset_hook)(void); | 23 | void (*s3c24xx_reset_hook)(void); |
28 | 24 | ||
@@ -59,44 +55,4 @@ static void arch_idle(void) | |||
59 | s3c24xx_default_idle(); | 55 | s3c24xx_default_idle(); |
60 | } | 56 | } |
61 | 57 | ||
62 | static void | 58 | #include <asm/arch/system-reset.h> |
63 | arch_reset(char mode) | ||
64 | { | ||
65 | struct clk *wdtclk; | ||
66 | |||
67 | if (mode == 's') { | ||
68 | cpu_reset(0); | ||
69 | } | ||
70 | |||
71 | if (s3c24xx_reset_hook) | ||
72 | s3c24xx_reset_hook(); | ||
73 | |||
74 | printk("arch_reset: attempting watchdog reset\n"); | ||
75 | |||
76 | __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ | ||
77 | |||
78 | wdtclk = clk_get(NULL, "watchdog"); | ||
79 | if (!IS_ERR(wdtclk)) { | ||
80 | clk_enable(wdtclk); | ||
81 | } else | ||
82 | printk(KERN_WARNING "%s: warning: cannot get watchdog clock\n", __func__); | ||
83 | |||
84 | /* put initial values into count and data */ | ||
85 | __raw_writel(0x80, S3C2410_WTCNT); | ||
86 | __raw_writel(0x80, S3C2410_WTDAT); | ||
87 | |||
88 | /* set the watchdog to go and reset... */ | ||
89 | __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN | | ||
90 | S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON); | ||
91 | |||
92 | /* wait for reset to assert... */ | ||
93 | mdelay(500); | ||
94 | |||
95 | printk(KERN_ERR "Watchdog reset failed to assert reset\n"); | ||
96 | |||
97 | /* delay to allow the serial port to show the message */ | ||
98 | mdelay(50); | ||
99 | |||
100 | /* we'll take a jump through zero as a poor second */ | ||
101 | cpu_reset(0); | ||
102 | } | ||