Commit 7db6a7fa authored by Eric Miao's avatar Eric Miao

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: default avatarNick Bane <nickbane1@gmail.com>
Signed-off-by: default avatarEric Miao <eric.y.miao@gmail.com>
parent 83fd6c68
...@@ -103,7 +103,20 @@ ...@@ -103,7 +103,20 @@
#define gpio_to_bank(gpio) ((gpio) >> 5) #define gpio_to_bank(gpio) ((gpio) >> 5)
#define gpio_to_irq(gpio) IRQ_GPIO(gpio) #define gpio_to_irq(gpio) IRQ_GPIO(gpio)
#define irq_to_gpio(irq) IRQ_TO_GPIO(irq)
static inline int irq_to_gpio(unsigned int irq)
{
int gpio;
if (irq == IRQ_GPIO0 || irq == IRQ_GPIO1)
return irq - IRQ_GPIO0;
gpio = irq - PXA_GPIO_IRQ_BASE;
if (gpio >= 2 && gpio < NR_BUILTIN_GPIO)
return gpio;
return -1;
}
#ifdef CONFIG_CPU_PXA26x #ifdef CONFIG_CPU_PXA26x
/* GPIO86/87/88/89 on PXA26x have their direction bits in GPDR2 inverted, /* GPIO86/87/88/89 on PXA26x have their direction bits in GPDR2 inverted,
......
...@@ -93,9 +93,6 @@ ...@@ -93,9 +93,6 @@
#define GPIO_2_x_TO_IRQ(x) (PXA_GPIO_IRQ_BASE + (x)) #define GPIO_2_x_TO_IRQ(x) (PXA_GPIO_IRQ_BASE + (x))
#define IRQ_GPIO(x) (((x) < 2) ? (IRQ_GPIO0 + (x)) : GPIO_2_x_TO_IRQ(x)) #define IRQ_GPIO(x) (((x) < 2) ? (IRQ_GPIO0 + (x)) : GPIO_2_x_TO_IRQ(x))
#define IRQ_TO_GPIO_2_x(i) ((i) - PXA_GPIO_IRQ_BASE)
#define IRQ_TO_GPIO(i) (((i) < IRQ_GPIO(2)) ? ((i) - IRQ_GPIO0) : IRQ_TO_GPIO_2_x(i))
/* /*
* The following interrupts are for board specific purposes. Since * The following interrupts are for board specific purposes. Since
* the kernel can only run on one machine at a time, we can re-use * the kernel can only run on one machine at a time, we can re-use
......
...@@ -285,7 +285,7 @@ static inline void pxa25x_init_pm(void) {} ...@@ -285,7 +285,7 @@ static inline void pxa25x_init_pm(void) {}
static int pxa25x_set_wake(struct irq_data *d, unsigned int on) static int pxa25x_set_wake(struct irq_data *d, unsigned int on)
{ {
int gpio = IRQ_TO_GPIO(d->irq); int gpio = irq_to_gpio(d->irq);
uint32_t mask = 0; uint32_t mask = 0;
if (gpio >= 0 && gpio < 85) if (gpio >= 0 && gpio < 85)
......
...@@ -345,7 +345,7 @@ static inline void pxa27x_init_pm(void) {} ...@@ -345,7 +345,7 @@ static inline void pxa27x_init_pm(void) {}
*/ */
static int pxa27x_set_wake(struct irq_data *d, unsigned int on) static int pxa27x_set_wake(struct irq_data *d, unsigned int on)
{ {
int gpio = IRQ_TO_GPIO(d->irq); int gpio = irq_to_gpio(d->irq);
uint32_t mask; uint32_t mask;
if (gpio >= 0 && gpio < 128) if (gpio >= 0 && gpio < 128)
......
...@@ -69,15 +69,15 @@ static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt) ...@@ -69,15 +69,15 @@ static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
for (i = 0; i < ARRAY_SIZE(irqs); i++) { for (i = 0; i < ARRAY_SIZE(irqs); i++) {
if (irqs[i].sock != skt->nr) if (irqs[i].sock != skt->nr)
continue; continue;
if (gpio_request(IRQ_TO_GPIO(irqs[i].irq), irqs[i].str) < 0) { if (gpio_request(irq_to_gpio(irqs[i].irq), irqs[i].str) < 0) {
pr_err("%s: sock %d unable to request gpio %d\n", pr_err("%s: sock %d unable to request gpio %d\n",
__func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq)); __func__, skt->nr, irq_to_gpio(irqs[i].irq));
ret = -EBUSY; ret = -EBUSY;
goto error; goto error;
} }
if (gpio_direction_input(IRQ_TO_GPIO(irqs[i].irq)) < 0) { if (gpio_direction_input(irq_to_gpio(irqs[i].irq)) < 0) {
pr_err("%s: sock %d unable to set input gpio %d\n", pr_err("%s: sock %d unable to set input gpio %d\n",
__func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq)); __func__, skt->nr, irq_to_gpio(irqs[i].irq));
ret = -EINVAL; ret = -EINVAL;
goto error; goto error;
} }
...@@ -86,7 +86,7 @@ static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt) ...@@ -86,7 +86,7 @@ static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
error: error:
for (; i >= 0; i--) { for (; i >= 0; i--) {
gpio_free(IRQ_TO_GPIO(irqs[i].irq)); gpio_free(irq_to_gpio(irqs[i].irq));
} }
return (ret); return (ret);
} }
...@@ -97,7 +97,7 @@ static void trizeps_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) ...@@ -97,7 +97,7 @@ static void trizeps_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
/* free allocated gpio's */ /* free allocated gpio's */
gpio_free(GPIO_PRDY); gpio_free(GPIO_PRDY);
for (i = 0; i < ARRAY_SIZE(irqs); i++) for (i = 0; i < ARRAY_SIZE(irqs); i++)
gpio_free(IRQ_TO_GPIO(irqs[i].irq)); gpio_free(irq_to_gpio(irqs[i].irq));
} }
static unsigned long trizeps_pcmcia_status[2]; static unsigned long trizeps_pcmcia_status[2];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment