1 From e039614a0ce6df645f8fa4cbe32e4b21fe46a288 Mon Sep 17 00:00:00 2001
2 From: Dmitry Baryshkov <dbaryshkov@gmail.com>
3 Date: Sun, 20 Jan 2008 02:44:03 +0300
4 Subject: [PATCH 56/64] Support resetting by asserting GPIO pin
6 This adds support for resetting via assertion of GPIO pin.
7 This e.g. is used on Sharp Zaurus SL-6000.
9 Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
11 arch/arm/mach-pxa/gpio.c | 43 +++++++++++++++++++++++++++++++++++++
12 arch/arm/mach-pxa/pm.c | 4 +-
13 include/asm-arm/arch-pxa/system.h | 10 ++++++++
14 3 files changed, 55 insertions(+), 2 deletions(-)
16 diff --git a/arch/arm/mach-pxa/gpio.c b/arch/arm/mach-pxa/gpio.c
17 index 8638dd7..589da3b 100644
18 --- a/arch/arm/mach-pxa/gpio.c
19 +++ b/arch/arm/mach-pxa/gpio.c
21 #include <asm/hardware.h>
23 #include <asm/arch/pxa-regs.h>
24 +#include <asm/arch/system.h>
28 @@ -194,4 +195,46 @@ void __init pxa_init_gpio(int gpio_nr)
29 pxa_gpio_chip[i/32].chip.ngpio = gpio_nr - i;
30 gpiochip_add(&pxa_gpio_chip[i/32].chip);
33 + if (reset_gpio < gpio_nr)
38 +static int __init reset_gpio_setup(char *str)
40 + if (get_option(&str, &reset_gpio) != 1) {
41 + printk(KERN_ERR "reset_gpio: bad value secified");
48 +__setup("reset_gpio=", reset_gpio_setup);
50 +int init_reset_gpio(void)
53 + if (reset_gpio == -1)
56 + rc = gpio_request(reset_gpio, "reset generator");
58 + printk(KERN_ERR "Can't request reset_gpio\n");
62 + rc = gpio_direction_input(reset_gpio);
64 + printk(KERN_ERR "Can't configure reset_gpio for input\n");
65 + gpio_free(reset_gpio);
75 diff --git a/arch/arm/mach-pxa/pm.c b/arch/arm/mach-pxa/pm.c
76 index a941c71..64f37e5 100644
77 --- a/arch/arm/mach-pxa/pm.c
78 +++ b/arch/arm/mach-pxa/pm.c
79 @@ -40,8 +40,8 @@ int pxa_pm_enter(suspend_state_t state)
81 pxa_cpu_pm_fns->save(sleep_save);
83 - /* Clear sleep reset status */
85 + /* Clear reset status */
86 + RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
88 /* before sleeping, calculate and save a checksum */
89 for (i = 0; i < pxa_cpu_pm_fns->save_size - 1; i++)
90 diff --git a/include/asm-arm/arch-pxa/system.h b/include/asm-arm/arch-pxa/system.h
91 index 1d56a3e..c075018 100644
92 --- a/include/asm-arm/arch-pxa/system.h
93 +++ b/include/asm-arm/arch-pxa/system.h
97 #include <asm/proc-fns.h>
98 +#include <asm/gpio.h>
100 #include "pxa-regs.h"
102 @@ -19,12 +20,21 @@ static inline void arch_idle(void)
106 +extern int reset_gpio;
108 +int init_reset_gpio(void);
110 static inline void arch_reset(char mode)
112 + RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
115 /* Jump into ROM at address 0 */
117 + } else if (mode == 'g' && reset_gpio != -1) {
118 + /* Use GPIO reset */
119 + gpio_direction_output(reset_gpio, 0);
120 + gpio_set_value(reset_gpio, 1);
122 /* Initialize the watchdog and let it fire */