Commit 7db6a7fa09884b34d2a5d4e6e4ed58664a5f0cf8

Authored by Eric Miao
1 parent 83fd6c685b

ARM: pxa: convert incorrect IRQ_TO_IRQ() to irq_to_gpio()

This fixes the failure to register the IRQ_RTCAlrm alarm as a wakeup
event.  It is misinterpreted as a gpio irq not a PWER bitmask. Fixed
this by converting the incorrect IRQ_TO_IRQ() to a correct version of
irq_to_gpio().

Reported-by: Nick Bane <nickbane1@gmail.com>
Signed-off-by: Eric Miao <eric.y.miao@gmail.com>

Showing 5 changed files with 22 additions and 12 deletions Side-by-side Diff

arch/arm/mach-pxa/include/mach/gpio.h
... ... @@ -103,7 +103,20 @@
103 103  
104 104 #define gpio_to_bank(gpio) ((gpio) >> 5)
105 105 #define gpio_to_irq(gpio) IRQ_GPIO(gpio)
106   -#define irq_to_gpio(irq) IRQ_TO_GPIO(irq)
  106 +
  107 +static inline int irq_to_gpio(unsigned int irq)
  108 +{
  109 + int gpio;
  110 +
  111 + if (irq == IRQ_GPIO0 || irq == IRQ_GPIO1)
  112 + return irq - IRQ_GPIO0;
  113 +
  114 + gpio = irq - PXA_GPIO_IRQ_BASE;
  115 + if (gpio >= 2 && gpio < NR_BUILTIN_GPIO)
  116 + return gpio;
  117 +
  118 + return -1;
  119 +}
107 120  
108 121 #ifdef CONFIG_CPU_PXA26x
109 122 /* GPIO86/87/88/89 on PXA26x have their direction bits in GPDR2 inverted,
arch/arm/mach-pxa/include/mach/irqs.h
... ... @@ -93,9 +93,6 @@
93 93 #define GPIO_2_x_TO_IRQ(x) (PXA_GPIO_IRQ_BASE + (x))
94 94 #define IRQ_GPIO(x) (((x) < 2) ? (IRQ_GPIO0 + (x)) : GPIO_2_x_TO_IRQ(x))
95 95  
96   -#define IRQ_TO_GPIO_2_x(i) ((i) - PXA_GPIO_IRQ_BASE)
97   -#define IRQ_TO_GPIO(i) (((i) < IRQ_GPIO(2)) ? ((i) - IRQ_GPIO0) : IRQ_TO_GPIO_2_x(i))
98   -
99 96 /*
100 97 * The following interrupts are for board specific purposes. Since
101 98 * the kernel can only run on one machine at a time, we can re-use
arch/arm/mach-pxa/pxa25x.c
... ... @@ -285,7 +285,7 @@
285 285  
286 286 static int pxa25x_set_wake(struct irq_data *d, unsigned int on)
287 287 {
288   - int gpio = IRQ_TO_GPIO(d->irq);
  288 + int gpio = irq_to_gpio(d->irq);
289 289 uint32_t mask = 0;
290 290  
291 291 if (gpio >= 0 && gpio < 85)
arch/arm/mach-pxa/pxa27x.c
... ... @@ -345,7 +345,7 @@
345 345 */
346 346 static int pxa27x_set_wake(struct irq_data *d, unsigned int on)
347 347 {
348   - int gpio = IRQ_TO_GPIO(d->irq);
  348 + int gpio = irq_to_gpio(d->irq);
349 349 uint32_t mask;
350 350  
351 351 if (gpio >= 0 && gpio < 128)
drivers/pcmcia/pxa2xx_trizeps4.c
... ... @@ -69,15 +69,15 @@
69 69 for (i = 0; i < ARRAY_SIZE(irqs); i++) {
70 70 if (irqs[i].sock != skt->nr)
71 71 continue;
72   - if (gpio_request(IRQ_TO_GPIO(irqs[i].irq), irqs[i].str) < 0) {
  72 + if (gpio_request(irq_to_gpio(irqs[i].irq), irqs[i].str) < 0) {
73 73 pr_err("%s: sock %d unable to request gpio %d\n",
74   - __func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq));
  74 + __func__, skt->nr, irq_to_gpio(irqs[i].irq));
75 75 ret = -EBUSY;
76 76 goto error;
77 77 }
78   - if (gpio_direction_input(IRQ_TO_GPIO(irqs[i].irq)) < 0) {
  78 + if (gpio_direction_input(irq_to_gpio(irqs[i].irq)) < 0) {
79 79 pr_err("%s: sock %d unable to set input gpio %d\n",
80   - __func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq));
  80 + __func__, skt->nr, irq_to_gpio(irqs[i].irq));
81 81 ret = -EINVAL;
82 82 goto error;
83 83 }
... ... @@ -86,7 +86,7 @@
86 86  
87 87 error:
88 88 for (; i >= 0; i--) {
89   - gpio_free(IRQ_TO_GPIO(irqs[i].irq));
  89 + gpio_free(irq_to_gpio(irqs[i].irq));
90 90 }
91 91 return (ret);
92 92 }
... ... @@ -97,7 +97,7 @@
97 97 /* free allocated gpio's */
98 98 gpio_free(GPIO_PRDY);
99 99 for (i = 0; i < ARRAY_SIZE(irqs); i++)
100   - gpio_free(IRQ_TO_GPIO(irqs[i].irq));
  100 + gpio_free(irq_to_gpio(irqs[i].irq));
101 101 }
102 102  
103 103 static unsigned long trizeps_pcmcia_status[2];