diff options
Diffstat (limited to 'arch/arm/mach-pxa/irq.c')
-rw-r--r-- | arch/arm/mach-pxa/irq.c | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c index f815678a9d63..4619d5fe606c 100644 --- a/arch/arm/mach-pxa/irq.c +++ b/arch/arm/mach-pxa/irq.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/ptrace.h> | ||
19 | 18 | ||
20 | #include <asm/hardware.h> | 19 | #include <asm/hardware.h> |
21 | #include <asm/irq.h> | 20 | #include <asm/irq.h> |
@@ -39,11 +38,33 @@ static void pxa_unmask_low_irq(unsigned int irq) | |||
39 | ICMR |= (1 << (irq + PXA_IRQ_SKIP)); | 38 | ICMR |= (1 << (irq + PXA_IRQ_SKIP)); |
40 | } | 39 | } |
41 | 40 | ||
41 | static int pxa_set_wake(unsigned int irq, unsigned int on) | ||
42 | { | ||
43 | u32 mask; | ||
44 | |||
45 | switch (irq) { | ||
46 | case IRQ_RTCAlrm: | ||
47 | mask = PWER_RTC; | ||
48 | break; | ||
49 | #ifdef CONFIG_PXA27x | ||
50 | /* REVISIT can handle USBH1, USBH2, USB, MSL, USIM, ... */ | ||
51 | #endif | ||
52 | default: | ||
53 | return -EINVAL; | ||
54 | } | ||
55 | if (on) | ||
56 | PWER |= mask; | ||
57 | else | ||
58 | PWER &= ~mask; | ||
59 | return 0; | ||
60 | } | ||
61 | |||
42 | static struct irq_chip pxa_internal_chip_low = { | 62 | static struct irq_chip pxa_internal_chip_low = { |
43 | .name = "SC", | 63 | .name = "SC", |
44 | .ack = pxa_mask_low_irq, | 64 | .ack = pxa_mask_low_irq, |
45 | .mask = pxa_mask_low_irq, | 65 | .mask = pxa_mask_low_irq, |
46 | .unmask = pxa_unmask_low_irq, | 66 | .unmask = pxa_unmask_low_irq, |
67 | .set_wake = pxa_set_wake, | ||
47 | }; | 68 | }; |
48 | 69 | ||
49 | #if PXA_INTERNAL_IRQS > 32 | 70 | #if PXA_INTERNAL_IRQS > 32 |
@@ -71,6 +92,26 @@ static struct irq_chip pxa_internal_chip_high = { | |||
71 | 92 | ||
72 | #endif | 93 | #endif |
73 | 94 | ||
95 | /* Note that if an input/irq line ever gets changed to an output during | ||
96 | * suspend, the relevant PWER, PRER, and PFER bits should be cleared. | ||
97 | */ | ||
98 | #ifdef CONFIG_PXA27x | ||
99 | |||
100 | /* PXA27x: Various gpios can issue wakeup events. This logic only | ||
101 | * handles the simple cases, not the WEMUX2 and WEMUX3 options | ||
102 | */ | ||
103 | #define PXA27x_GPIO_NOWAKE_MASK \ | ||
104 | ((1 << 8) | (1 << 7) | (1 << 6) | (1 << 5) | (1 << 2)) | ||
105 | #define WAKEMASK(gpio) \ | ||
106 | (((gpio) <= 15) \ | ||
107 | ? ((1 << (gpio)) & ~PXA27x_GPIO_NOWAKE_MASK) \ | ||
108 | : ((gpio == 35) ? (1 << 24) : 0)) | ||
109 | #else | ||
110 | |||
111 | /* pxa 210, 250, 255, 26x: gpios 0..15 can issue wakeups */ | ||
112 | #define WAKEMASK(gpio) (((gpio) <= 15) ? (1 << (gpio)) : 0) | ||
113 | #endif | ||
114 | |||
74 | /* | 115 | /* |
75 | * PXA GPIO edge detection for IRQs: | 116 | * PXA GPIO edge detection for IRQs: |
76 | * IRQs are generated on Falling-Edge, Rising-Edge, or both. | 117 | * IRQs are generated on Falling-Edge, Rising-Edge, or both. |
@@ -84,9 +125,11 @@ static long GPIO_IRQ_mask[4]; | |||
84 | static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) | 125 | static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) |
85 | { | 126 | { |
86 | int gpio, idx; | 127 | int gpio, idx; |
128 | u32 mask; | ||
87 | 129 | ||
88 | gpio = IRQ_TO_GPIO(irq); | 130 | gpio = IRQ_TO_GPIO(irq); |
89 | idx = gpio >> 5; | 131 | idx = gpio >> 5; |
132 | mask = WAKEMASK(gpio); | ||
90 | 133 | ||
91 | if (type == IRQT_PROBE) { | 134 | if (type == IRQT_PROBE) { |
92 | /* Don't mess with enabled GPIOs using preconfigured edges or | 135 | /* Don't mess with enabled GPIOs using preconfigured edges or |
@@ -106,14 +149,20 @@ static int pxa_gpio_irq_type(unsigned int irq, unsigned int type) | |||
106 | if (type & __IRQT_RISEDGE) { | 149 | if (type & __IRQT_RISEDGE) { |
107 | /* printk("rising "); */ | 150 | /* printk("rising "); */ |
108 | __set_bit (gpio, GPIO_IRQ_rising_edge); | 151 | __set_bit (gpio, GPIO_IRQ_rising_edge); |
109 | } else | 152 | PRER |= mask; |
153 | } else { | ||
110 | __clear_bit (gpio, GPIO_IRQ_rising_edge); | 154 | __clear_bit (gpio, GPIO_IRQ_rising_edge); |
155 | PRER &= ~mask; | ||
156 | } | ||
111 | 157 | ||
112 | if (type & __IRQT_FALEDGE) { | 158 | if (type & __IRQT_FALEDGE) { |
113 | /* printk("falling "); */ | 159 | /* printk("falling "); */ |
114 | __set_bit (gpio, GPIO_IRQ_falling_edge); | 160 | __set_bit (gpio, GPIO_IRQ_falling_edge); |
115 | } else | 161 | PFER |= mask; |
162 | } else { | ||
116 | __clear_bit (gpio, GPIO_IRQ_falling_edge); | 163 | __clear_bit (gpio, GPIO_IRQ_falling_edge); |
164 | PFER &= ~mask; | ||
165 | } | ||
117 | 166 | ||
118 | /* printk("edges\n"); */ | 167 | /* printk("edges\n"); */ |
119 | 168 | ||
@@ -131,12 +180,29 @@ static void pxa_ack_low_gpio(unsigned int irq) | |||
131 | GEDR0 = (1 << (irq - IRQ_GPIO0)); | 180 | GEDR0 = (1 << (irq - IRQ_GPIO0)); |
132 | } | 181 | } |
133 | 182 | ||
183 | static int pxa_set_gpio_wake(unsigned int irq, unsigned int on) | ||
184 | { | ||
185 | int gpio = IRQ_TO_GPIO(irq); | ||
186 | u32 mask = WAKEMASK(gpio); | ||
187 | |||
188 | if (!mask) | ||
189 | return -EINVAL; | ||
190 | |||
191 | if (on) | ||
192 | PWER |= mask; | ||
193 | else | ||
194 | PWER &= ~mask; | ||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | |||
134 | static struct irq_chip pxa_low_gpio_chip = { | 199 | static struct irq_chip pxa_low_gpio_chip = { |
135 | .name = "GPIO-l", | 200 | .name = "GPIO-l", |
136 | .ack = pxa_ack_low_gpio, | 201 | .ack = pxa_ack_low_gpio, |
137 | .mask = pxa_mask_low_irq, | 202 | .mask = pxa_mask_low_irq, |
138 | .unmask = pxa_unmask_low_irq, | 203 | .unmask = pxa_unmask_low_irq, |
139 | .set_type = pxa_gpio_irq_type, | 204 | .set_type = pxa_gpio_irq_type, |
205 | .set_wake = pxa_set_gpio_wake, | ||
140 | }; | 206 | }; |
141 | 207 | ||
142 | /* | 208 | /* |
@@ -245,6 +311,7 @@ static struct irq_chip pxa_muxed_gpio_chip = { | |||
245 | .mask = pxa_mask_muxed_gpio, | 311 | .mask = pxa_mask_muxed_gpio, |
246 | .unmask = pxa_unmask_muxed_gpio, | 312 | .unmask = pxa_unmask_muxed_gpio, |
247 | .set_type = pxa_gpio_irq_type, | 313 | .set_type = pxa_gpio_irq_type, |
314 | .set_wake = pxa_set_gpio_wake, | ||
248 | }; | 315 | }; |
249 | 316 | ||
250 | 317 | ||