Commit eef4bec7 authored by Kevin Hilman's avatar Kevin Hilman

gpio/omap: consolidate IRQ status handling, remove #ifdefs

Cleanup IRQ status handling by passing IRQ status register offsets
via platform data.

Cleans up clearing of GPIO IRQ status and GPIO ISR handler.
Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent fa87931a
...@@ -38,6 +38,7 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = { ...@@ -38,6 +38,7 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
.direction = OMAP_MPUIO_IO_CNTL, .direction = OMAP_MPUIO_IO_CNTL,
.datain = OMAP_MPUIO_INPUT_LATCH, .datain = OMAP_MPUIO_INPUT_LATCH,
.dataout = OMAP_MPUIO_OUTPUT, .dataout = OMAP_MPUIO_OUTPUT,
.irqstatus = OMAP_MPUIO_GPIO_INT,
}; };
static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
...@@ -75,6 +76,7 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = { ...@@ -75,6 +76,7 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
.direction = OMAP1510_GPIO_DIR_CONTROL, .direction = OMAP1510_GPIO_DIR_CONTROL,
.datain = OMAP1510_GPIO_DATA_INPUT, .datain = OMAP1510_GPIO_DATA_INPUT,
.dataout = OMAP1510_GPIO_DATA_OUTPUT, .dataout = OMAP1510_GPIO_DATA_OUTPUT,
.irqstatus = OMAP1510_GPIO_INT_STATUS,
}; };
static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
......
...@@ -41,6 +41,7 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = { ...@@ -41,6 +41,7 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
.direction = OMAP_MPUIO_IO_CNTL, .direction = OMAP_MPUIO_IO_CNTL,
.datain = OMAP_MPUIO_INPUT_LATCH, .datain = OMAP_MPUIO_INPUT_LATCH,
.dataout = OMAP_MPUIO_OUTPUT, .dataout = OMAP_MPUIO_OUTPUT,
.irqstatus = OMAP_MPUIO_GPIO_INT,
}; };
static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
...@@ -80,6 +81,7 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = { ...@@ -80,6 +81,7 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
.clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT, .clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT,
.datain = OMAP1610_GPIO_DATAIN, .datain = OMAP1610_GPIO_DATAIN,
.dataout = OMAP1610_GPIO_DATAOUT, .dataout = OMAP1610_GPIO_DATAOUT,
.irqstatus = OMAP1610_GPIO_IRQSTATUS1,
}; };
static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
......
...@@ -43,6 +43,7 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = { ...@@ -43,6 +43,7 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
.direction = OMAP_MPUIO_IO_CNTL / 2, .direction = OMAP_MPUIO_IO_CNTL / 2,
.datain = OMAP_MPUIO_INPUT_LATCH / 2, .datain = OMAP_MPUIO_INPUT_LATCH / 2,
.dataout = OMAP_MPUIO_OUTPUT / 2, .dataout = OMAP_MPUIO_OUTPUT / 2,
.irqstatus = OMAP_MPUIO_GPIO_INT / 2,
}; };
static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
...@@ -80,6 +81,7 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = { ...@@ -80,6 +81,7 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
.direction = OMAP7XX_GPIO_DIR_CONTROL, .direction = OMAP7XX_GPIO_DIR_CONTROL,
.datain = OMAP7XX_GPIO_DATA_INPUT, .datain = OMAP7XX_GPIO_DATA_INPUT,
.dataout = OMAP7XX_GPIO_DATA_OUTPUT, .dataout = OMAP7XX_GPIO_DATA_OUTPUT,
.irqstatus = OMAP7XX_GPIO_INT_STATUS,
}; };
static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
......
...@@ -76,6 +76,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) ...@@ -76,6 +76,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
pdata->regs->dataout = OMAP24XX_GPIO_DATAOUT; pdata->regs->dataout = OMAP24XX_GPIO_DATAOUT;
pdata->regs->set_dataout = OMAP24XX_GPIO_SETDATAOUT; pdata->regs->set_dataout = OMAP24XX_GPIO_SETDATAOUT;
pdata->regs->clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT; pdata->regs->clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT;
pdata->regs->irqstatus = OMAP24XX_GPIO_IRQSTATUS1;
pdata->regs->irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2;
break; break;
case 2: case 2:
pdata->bank_type = METHOD_GPIO_44XX; pdata->bank_type = METHOD_GPIO_44XX;
...@@ -84,6 +86,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) ...@@ -84,6 +86,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
pdata->regs->dataout = OMAP4_GPIO_DATAOUT; pdata->regs->dataout = OMAP4_GPIO_DATAOUT;
pdata->regs->set_dataout = OMAP4_GPIO_SETDATAOUT; pdata->regs->set_dataout = OMAP4_GPIO_SETDATAOUT;
pdata->regs->clr_dataout = OMAP4_GPIO_CLEARDATAOUT; pdata->regs->clr_dataout = OMAP4_GPIO_CLEARDATAOUT;
pdata->regs->irqstatus = OMAP4_GPIO_IRQSTATUS0;
pdata->regs->irqstatus2 = OMAP4_GPIO_IRQSTATUS1;
break; break;
default: default:
WARN(1, "Invalid gpio bank_type\n"); WARN(1, "Invalid gpio bank_type\n");
......
...@@ -180,6 +180,8 @@ struct omap_gpio_reg_offs { ...@@ -180,6 +180,8 @@ struct omap_gpio_reg_offs {
u16 dataout; u16 dataout;
u16 set_dataout; u16 set_dataout;
u16 clr_dataout; u16 clr_dataout;
u16 irqstatus;
u16 irqstatus2;
}; };
struct omap_gpio_platform_data { struct omap_gpio_platform_data {
......
...@@ -481,46 +481,14 @@ static void _clear_gpio_irqbank(struct gpio_bank *bank, int gpio_mask) ...@@ -481,46 +481,14 @@ static void _clear_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
{ {
void __iomem *reg = bank->base; void __iomem *reg = bank->base;
switch (bank->method) { reg += bank->regs->irqstatus;
#ifdef CONFIG_ARCH_OMAP15XX
case METHOD_GPIO_1510:
reg += OMAP1510_GPIO_INT_STATUS;
break;
#endif
#ifdef CONFIG_ARCH_OMAP16XX
case METHOD_GPIO_1610:
reg += OMAP1610_GPIO_IRQSTATUS1;
break;
#endif
#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
case METHOD_GPIO_7XX:
reg += OMAP7XX_GPIO_INT_STATUS;
break;
#endif
#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
case METHOD_GPIO_24XX:
reg += OMAP24XX_GPIO_IRQSTATUS1;
break;
#endif
#if defined(CONFIG_ARCH_OMAP4)
case METHOD_GPIO_44XX:
reg += OMAP4_GPIO_IRQSTATUS0;
break;
#endif
default:
WARN_ON(1);
return;
}
__raw_writel(gpio_mask, reg); __raw_writel(gpio_mask, reg);
/* Workaround for clearing DSP GPIO interrupts to allow retention */ /* Workaround for clearing DSP GPIO interrupts to allow retention */
if (cpu_is_omap24xx() || cpu_is_omap34xx()) if (bank->regs->irqstatus2) {
reg = bank->base + OMAP24XX_GPIO_IRQSTATUS2; reg = bank->base + bank->regs->irqstatus2;
else if (cpu_is_omap44xx())
reg = bank->base + OMAP4_GPIO_IRQSTATUS1;
if (cpu_is_omap24xx() || cpu_is_omap34xx() || cpu_is_omap44xx())
__raw_writel(gpio_mask, reg); __raw_writel(gpio_mask, reg);
}
/* Flush posted write for the irq status to avoid spurious interrupts */ /* Flush posted write for the irq status to avoid spurious interrupts */
__raw_readl(reg); __raw_readl(reg);
...@@ -841,31 +809,7 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) ...@@ -841,31 +809,7 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
chained_irq_enter(chip, desc); chained_irq_enter(chip, desc);
bank = irq_get_handler_data(irq); bank = irq_get_handler_data(irq);
#ifdef CONFIG_ARCH_OMAP1 isr_reg = bank->base + bank->regs->irqstatus;
if (bank->method == METHOD_MPUIO)
isr_reg = bank->base +
OMAP_MPUIO_GPIO_INT / bank->stride;
#endif
#ifdef CONFIG_ARCH_OMAP15XX
if (bank->method == METHOD_GPIO_1510)
isr_reg = bank->base + OMAP1510_GPIO_INT_STATUS;
#endif
#if defined(CONFIG_ARCH_OMAP16XX)
if (bank->method == METHOD_GPIO_1610)
isr_reg = bank->base + OMAP1610_GPIO_IRQSTATUS1;
#endif
#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
if (bank->method == METHOD_GPIO_7XX)
isr_reg = bank->base + OMAP7XX_GPIO_INT_STATUS;
#endif
#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
if (bank->method == METHOD_GPIO_24XX)
isr_reg = bank->base + OMAP24XX_GPIO_IRQSTATUS1;
#endif
#if defined(CONFIG_ARCH_OMAP4)
if (bank->method == METHOD_GPIO_44XX)
isr_reg = bank->base + OMAP4_GPIO_IRQSTATUS0;
#endif
if (WARN_ON(!isr_reg)) if (WARN_ON(!isr_reg))
goto exit; goto exit;
......
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