merge of '178eac00dc5aa8338d42e8e203633bec7817bbf6'
[vuplus_openembedded] / packages / linux / linux-rp-2.6.24 / tosa / 0056-Support-resetting-by-asserting-GPIO-pin.patch
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
5
6 This adds support for resetting via assertion of GPIO pin.
7 This e.g. is used on Sharp Zaurus SL-6000.
8
9 Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
10 ---
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(-)
15
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
20 @@ -19,6 +19,7 @@
21  #include <asm/hardware.h>
22  #include <asm/io.h>
23  #include <asm/arch/pxa-regs.h>
24 +#include <asm/arch/system.h>
25  
26  #include "generic.h"
27  
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);
31         }
32 +
33 +       if (reset_gpio < gpio_nr)
34 +               init_reset_gpio();
35 +}
36 +
37 +int reset_gpio = -1;
38 +static int __init reset_gpio_setup(char *str)
39 +{
40 +       if (get_option(&str, &reset_gpio) != 1) {
41 +               printk(KERN_ERR "reset_gpio: bad value secified");
42 +               return 0;
43 +       }
44 +
45 +       return 1;
46 +}
47 +
48 +__setup("reset_gpio=", reset_gpio_setup);
49 +
50 +int init_reset_gpio(void)
51 +{
52 +       int rc = 0;
53 +       if (reset_gpio == -1)
54 +               goto out;
55 +
56 +       rc = gpio_request(reset_gpio, "reset generator");
57 +       if (rc) {
58 +               printk(KERN_ERR "Can't request reset_gpio\n");
59 +               goto out;
60 +       }
61 +
62 +       rc = gpio_direction_input(reset_gpio);
63 +       if (rc) {
64 +               printk(KERN_ERR "Can't configure reset_gpio for input\n");
65 +               gpio_free(reset_gpio);
66 +               goto out;
67 +       }
68 +
69 +out:
70 +       if (rc)
71 +               reset_gpio = -1;
72 +
73 +       return rc;
74  }
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)
80  
81         pxa_cpu_pm_fns->save(sleep_save);
82  
83 -       /* Clear sleep reset status */
84 -       RCSR = RCSR_SMR;
85 +       /* Clear reset status */
86 +       RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
87  
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
94 @@ -11,6 +11,7 @@
95   */
96  
97  #include <asm/proc-fns.h>
98 +#include <asm/gpio.h>
99  #include "hardware.h"
100  #include "pxa-regs.h"
101  
102 @@ -19,12 +20,21 @@ static inline void arch_idle(void)
103         cpu_do_idle();
104  }
105  
106 +extern int reset_gpio;
107 +
108 +int init_reset_gpio(void);
109  
110  static inline void arch_reset(char mode)
111  {
112 +       RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
113 +
114         if (mode == 's') {
115                 /* Jump into ROM at address 0 */
116                 cpu_reset(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);
121         } else {
122                 /* Initialize the watchdog and let it fire */
123                 OWER = OWER_WME;
124 -- 
125 1.5.3.8
126