aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Miao <eric.y.miao@gmail.com>2011-04-12 06:39:39 -0400
committerEric Miao <eric.y.miao@gmail.com>2011-04-12 21:30:40 -0400
commit7db6a7fa09884b34d2a5d4e6e4ed58664a5f0cf8 (patch)
treefba3439bafcfaa4640a9f943be6746580203134e
parent83fd6c685bd8e83be1e29e2841bab94dd831e186 (diff)
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>
-rw-r--r--arch/arm/mach-pxa/include/mach/gpio.h15
-rw-r--r--arch/arm/mach-pxa/include/mach/irqs.h3
-rw-r--r--arch/arm/mach-pxa/pxa25x.c2
-rw-r--r--arch/arm/mach-pxa/pxa27x.c2
-rw-r--r--drivers/pcmcia/pxa2xx_trizeps4.c12
5 files changed, 22 insertions, 12 deletions
diff --git a/arch/arm/mach-pxa/include/mach/gpio.h b/arch/arm/mach-pxa/include/mach/gpio.h
index 48ef925ffb3b..c4639502efca 100644
--- a/arch/arm/mach-pxa/include/mach/gpio.h
+++ b/arch/arm/mach-pxa/include/mach/gpio.h
@@ -103,7 +103,20 @@
103 103
104#define gpio_to_bank(gpio) ((gpio) >> 5) 104#define gpio_to_bank(gpio) ((gpio) >> 5)
105#define gpio_to_irq(gpio) IRQ_GPIO(gpio) 105#define gpio_to_irq(gpio) IRQ_GPIO(gpio)
106#define irq_to_gpio(irq) IRQ_TO_GPIO(irq) 106
107static 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#ifdef CONFIG_CPU_PXA26x 121#ifdef CONFIG_CPU_PXA26x
109/* GPIO86/87/88/89 on PXA26x have their direction bits in GPDR2 inverted, 122/* GPIO86/87/88/89 on PXA26x have their direction bits in GPDR2 inverted,
diff --git a/arch/arm/mach-pxa/include/mach/irqs.h b/arch/arm/mach-pxa/include/mach/irqs.h
index a4285fc00878..038402404e39 100644
--- a/arch/arm/mach-pxa/include/mach/irqs.h
+++ b/arch/arm/mach-pxa/include/mach/irqs.h
@@ -93,9 +93,6 @@
93#define GPIO_2_x_TO_IRQ(x) (PXA_GPIO_IRQ_BASE + (x)) 93#define GPIO_2_x_TO_IRQ(x) (PXA_GPIO_IRQ_BASE + (x))
94#define IRQ_GPIO(x) (((x) < 2) ? (IRQ_GPIO0 + (x)) : GPIO_2_x_TO_IRQ(x)) 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 * The following interrupts are for board specific purposes. Since 97 * The following interrupts are for board specific purposes. Since
101 * the kernel can only run on one machine at a time, we can re-use 98 * the kernel can only run on one machine at a time, we can re-use
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index 6bde5956358d..a4af8c52d7ee 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -285,7 +285,7 @@ static inline void pxa25x_init_pm(void) {}
285 285
286static int pxa25x_set_wake(struct irq_data *d, unsigned int on) 286static 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 uint32_t mask = 0; 289 uint32_t mask = 0;
290 290
291 if (gpio >= 0 && gpio < 85) 291 if (gpio >= 0 && gpio < 85)
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index 1cb5d0f9723f..909756eaf4b7 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -345,7 +345,7 @@ static inline void pxa27x_init_pm(void) {}
345 */ 345 */
346static int pxa27x_set_wake(struct irq_data *d, unsigned int on) 346static 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 uint32_t mask; 349 uint32_t mask;
350 350
351 if (gpio >= 0 && gpio < 128) 351 if (gpio >= 0 && gpio < 128)
diff --git a/drivers/pcmcia/pxa2xx_trizeps4.c b/drivers/pcmcia/pxa2xx_trizeps4.c
index 5bb4e1a94d25..b829e655457b 100644
--- a/drivers/pcmcia/pxa2xx_trizeps4.c
+++ b/drivers/pcmcia/pxa2xx_trizeps4.c
@@ -69,15 +69,15 @@ static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
69 for (i = 0; i < ARRAY_SIZE(irqs); i++) { 69 for (i = 0; i < ARRAY_SIZE(irqs); i++) {
70 if (irqs[i].sock != skt->nr) 70 if (irqs[i].sock != skt->nr)
71 continue; 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 pr_err("%s: sock %d unable to request gpio %d\n", 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 ret = -EBUSY; 75 ret = -EBUSY;
76 goto error; 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 pr_err("%s: sock %d unable to set input gpio %d\n", 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 ret = -EINVAL; 81 ret = -EINVAL;
82 goto error; 82 goto error;
83 } 83 }
@@ -86,7 +86,7 @@ static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
86 86
87error: 87error:
88 for (; i >= 0; i--) { 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 return (ret); 91 return (ret);
92} 92}
@@ -97,7 +97,7 @@ static void trizeps_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
97 /* free allocated gpio's */ 97 /* free allocated gpio's */
98 gpio_free(GPIO_PRDY); 98 gpio_free(GPIO_PRDY);
99 for (i = 0; i < ARRAY_SIZE(irqs); i++) 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
103static unsigned long trizeps_pcmcia_status[2]; 103static unsigned long trizeps_pcmcia_status[2];