]>
Commit | Line | Data |
---|---|---|
75f10b46 DES |
1 | /* |
2 | * This program is free software; you can redistribute it and/or modify | |
3 | * it under the terms of the GNU General Public License version 2 as | |
4 | * published by the Free Software Foundation. | |
5 | */ | |
6 | #include <linux/kernel.h> | |
7 | #include <linux/module.h> | |
8 | #include <linux/delay.h> | |
9 | #include <linux/gpio.h> | |
10 | #include <asm/io.h> | |
11 | #include <asm/proc-fns.h> | |
12 | ||
13 | #include <asm/arch/pxa-regs.h> | |
4d1fe075 | 14 | #include <asm/arch/pxa2xx-regs.h> |
ab277121 | 15 | #include <asm/arch/reset.h> |
75f10b46 DES |
16 | |
17 | static void do_hw_reset(void); | |
18 | ||
19 | static int reset_gpio = -1; | |
20 | ||
21 | int init_gpio_reset(int gpio) | |
22 | { | |
23 | int rc; | |
24 | ||
25 | rc = gpio_request(gpio, "reset generator"); | |
26 | if (rc) { | |
27 | printk(KERN_ERR "Can't request reset_gpio\n"); | |
28 | goto out; | |
29 | } | |
30 | ||
31 | rc = gpio_direction_input(gpio); | |
32 | if (rc) { | |
33 | printk(KERN_ERR "Can't configure reset_gpio for input\n"); | |
34 | gpio_free(gpio); | |
35 | goto out; | |
36 | } | |
37 | ||
38 | out: | |
39 | if (!rc) | |
40 | reset_gpio = gpio; | |
41 | ||
42 | return rc; | |
43 | } | |
44 | ||
45 | /* | |
46 | * Trigger GPIO reset. | |
47 | * This covers various types of logic connecting gpio pin | |
48 | * to RESET pins (nRESET or GPIO_RESET): | |
49 | */ | |
50 | static void do_gpio_reset(void) | |
51 | { | |
52 | BUG_ON(reset_gpio == -1); | |
53 | ||
54 | /* drive it low */ | |
55 | gpio_direction_output(reset_gpio, 0); | |
56 | mdelay(2); | |
57 | /* rising edge or drive high */ | |
58 | gpio_set_value(reset_gpio, 1); | |
59 | mdelay(2); | |
60 | /* falling edge */ | |
61 | gpio_set_value(reset_gpio, 0); | |
62 | ||
63 | /* give it some time */ | |
64 | mdelay(10); | |
65 | ||
66 | WARN_ON(1); | |
67 | /* fallback */ | |
68 | do_hw_reset(); | |
69 | } | |
70 | ||
71 | static void do_hw_reset(void) | |
72 | { | |
73 | /* Initialize the watchdog and let it fire */ | |
74 | OWER = OWER_WME; | |
75 | OSSR = OSSR_M3; | |
76 | OSMR3 = OSCR + 368640; /* ... in 100 ms */ | |
77 | } | |
78 | ||
79 | void arch_reset(char mode) | |
80 | { | |
81 | if (cpu_is_pxa2xx()) | |
82 | RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR; | |
83 | ||
84 | switch (mode) { | |
85 | case 's': | |
86 | /* Jump into ROM at address 0 */ | |
87 | cpu_reset(0); | |
88 | break; | |
89 | case 'h': | |
90 | do_hw_reset(); | |
91 | break; | |
92 | case 'g': | |
93 | do_gpio_reset(); | |
94 | break; | |
95 | } | |
96 | } | |
97 |