diff options
author | Kevin Hilman <khilman@ti.com> | 2011-04-21 12:53:06 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@ti.com> | 2011-06-16 14:13:51 -0400 |
commit | 28f3b5a073b6dbafbb78cae65b22ea90547d7a87 (patch) | |
tree | 7e4f1ce8067c39d50c84081a26dec08143edff8c | |
parent | eef4bec7bf2fa9953f6b8f371d5914d014f45d40 (diff) |
gpio/omap: conslidate enable/disable of GPIO IRQs, remove ifdefs
Cleanup GPIO IRQ enable/disable handling by removing SoC-specific
Also split enable/disable IRQ into separate functions for better
readability and also facilitate potentially moving to generic irq_chip
in the future.
Signed-off-by: Kevin Hilman <khilman@ti.com>
-rw-r--r-- | arch/arm/mach-omap1/gpio15xx.c | 4 | ||||
-rw-r--r-- | arch/arm/mach-omap1/gpio16xx.c | 5 | ||||
-rw-r--r-- | arch/arm/mach-omap1/gpio7xx.c | 4 | ||||
-rw-r--r-- | arch/arm/mach-omap2/gpio.c | 6 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/gpio.h | 5 | ||||
-rw-r--r-- | drivers/gpio/gpio-omap.c | 129 |
6 files changed, 54 insertions, 99 deletions
diff --git a/arch/arm/mach-omap1/gpio15xx.c b/arch/arm/mach-omap1/gpio15xx.c index 487a08749655..91756245e860 100644 --- a/arch/arm/mach-omap1/gpio15xx.c +++ b/arch/arm/mach-omap1/gpio15xx.c | |||
@@ -39,6 +39,8 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = { | |||
39 | .datain = OMAP_MPUIO_INPUT_LATCH, | 39 | .datain = OMAP_MPUIO_INPUT_LATCH, |
40 | .dataout = OMAP_MPUIO_OUTPUT, | 40 | .dataout = OMAP_MPUIO_OUTPUT, |
41 | .irqstatus = OMAP_MPUIO_GPIO_INT, | 41 | .irqstatus = OMAP_MPUIO_GPIO_INT, |
42 | .irqenable = OMAP_MPUIO_GPIO_MASKIT, | ||
43 | .irqenable_inv = true, | ||
42 | }; | 44 | }; |
43 | 45 | ||
44 | static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { | 46 | static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { |
@@ -77,6 +79,8 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = { | |||
77 | .datain = OMAP1510_GPIO_DATA_INPUT, | 79 | .datain = OMAP1510_GPIO_DATA_INPUT, |
78 | .dataout = OMAP1510_GPIO_DATA_OUTPUT, | 80 | .dataout = OMAP1510_GPIO_DATA_OUTPUT, |
79 | .irqstatus = OMAP1510_GPIO_INT_STATUS, | 81 | .irqstatus = OMAP1510_GPIO_INT_STATUS, |
82 | .irqenable = OMAP1510_GPIO_INT_MASK, | ||
83 | .irqenable_inv = true, | ||
80 | }; | 84 | }; |
81 | 85 | ||
82 | static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { | 86 | static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { |
diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c index 3e52b7f3d9cb..a6d4a71ea4af 100644 --- a/arch/arm/mach-omap1/gpio16xx.c +++ b/arch/arm/mach-omap1/gpio16xx.c | |||
@@ -42,6 +42,8 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = { | |||
42 | .datain = OMAP_MPUIO_INPUT_LATCH, | 42 | .datain = OMAP_MPUIO_INPUT_LATCH, |
43 | .dataout = OMAP_MPUIO_OUTPUT, | 43 | .dataout = OMAP_MPUIO_OUTPUT, |
44 | .irqstatus = OMAP_MPUIO_GPIO_INT, | 44 | .irqstatus = OMAP_MPUIO_GPIO_INT, |
45 | .irqenable = OMAP_MPUIO_GPIO_MASKIT, | ||
46 | .irqenable_inv = true, | ||
45 | }; | 47 | }; |
46 | 48 | ||
47 | static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { | 49 | static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { |
@@ -82,6 +84,9 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = { | |||
82 | .datain = OMAP1610_GPIO_DATAIN, | 84 | .datain = OMAP1610_GPIO_DATAIN, |
83 | .dataout = OMAP1610_GPIO_DATAOUT, | 85 | .dataout = OMAP1610_GPIO_DATAOUT, |
84 | .irqstatus = OMAP1610_GPIO_IRQSTATUS1, | 86 | .irqstatus = OMAP1610_GPIO_IRQSTATUS1, |
87 | .irqenable = OMAP1610_GPIO_IRQENABLE1, | ||
88 | .set_irqenable = OMAP1610_GPIO_SET_IRQENABLE1, | ||
89 | .clr_irqenable = OMAP1610_GPIO_CLEAR_IRQENABLE1, | ||
85 | }; | 90 | }; |
86 | 91 | ||
87 | static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { | 92 | static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { |
diff --git a/arch/arm/mach-omap1/gpio7xx.c b/arch/arm/mach-omap1/gpio7xx.c index 35e8b31688d0..12bcd9f2864a 100644 --- a/arch/arm/mach-omap1/gpio7xx.c +++ b/arch/arm/mach-omap1/gpio7xx.c | |||
@@ -44,6 +44,8 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = { | |||
44 | .datain = OMAP_MPUIO_INPUT_LATCH / 2, | 44 | .datain = OMAP_MPUIO_INPUT_LATCH / 2, |
45 | .dataout = OMAP_MPUIO_OUTPUT / 2, | 45 | .dataout = OMAP_MPUIO_OUTPUT / 2, |
46 | .irqstatus = OMAP_MPUIO_GPIO_INT / 2, | 46 | .irqstatus = OMAP_MPUIO_GPIO_INT / 2, |
47 | .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2, | ||
48 | .irqenable_inv = true, | ||
47 | }; | 49 | }; |
48 | 50 | ||
49 | static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { | 51 | static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { |
@@ -82,6 +84,8 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = { | |||
82 | .datain = OMAP7XX_GPIO_DATA_INPUT, | 84 | .datain = OMAP7XX_GPIO_DATA_INPUT, |
83 | .dataout = OMAP7XX_GPIO_DATA_OUTPUT, | 85 | .dataout = OMAP7XX_GPIO_DATA_OUTPUT, |
84 | .irqstatus = OMAP7XX_GPIO_INT_STATUS, | 86 | .irqstatus = OMAP7XX_GPIO_INT_STATUS, |
87 | .irqenable = OMAP7XX_GPIO_INT_MASK, | ||
88 | .irqenable_inv = true, | ||
85 | }; | 89 | }; |
86 | 90 | ||
87 | static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { | 91 | static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { |
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c index 7c5e67d0b635..cc26677a12f8 100644 --- a/arch/arm/mach-omap2/gpio.c +++ b/arch/arm/mach-omap2/gpio.c | |||
@@ -78,6 +78,9 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) | |||
78 | pdata->regs->clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT; | 78 | pdata->regs->clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT; |
79 | pdata->regs->irqstatus = OMAP24XX_GPIO_IRQSTATUS1; | 79 | pdata->regs->irqstatus = OMAP24XX_GPIO_IRQSTATUS1; |
80 | pdata->regs->irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2; | 80 | pdata->regs->irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2; |
81 | pdata->regs->irqenable = OMAP24XX_GPIO_IRQENABLE1; | ||
82 | pdata->regs->set_irqenable = OMAP24XX_GPIO_SETIRQENABLE1; | ||
83 | pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1; | ||
81 | break; | 84 | break; |
82 | case 2: | 85 | case 2: |
83 | pdata->bank_type = METHOD_GPIO_44XX; | 86 | pdata->bank_type = METHOD_GPIO_44XX; |
@@ -88,6 +91,9 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) | |||
88 | pdata->regs->clr_dataout = OMAP4_GPIO_CLEARDATAOUT; | 91 | pdata->regs->clr_dataout = OMAP4_GPIO_CLEARDATAOUT; |
89 | pdata->regs->irqstatus = OMAP4_GPIO_IRQSTATUS0; | 92 | pdata->regs->irqstatus = OMAP4_GPIO_IRQSTATUS0; |
90 | pdata->regs->irqstatus2 = OMAP4_GPIO_IRQSTATUS1; | 93 | pdata->regs->irqstatus2 = OMAP4_GPIO_IRQSTATUS1; |
94 | pdata->regs->irqenable = OMAP4_GPIO_IRQSTATUSSET0; | ||
95 | pdata->regs->set_irqenable = OMAP4_GPIO_IRQSTATUSSET0; | ||
96 | pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0; | ||
91 | break; | 97 | break; |
92 | default: | 98 | default: |
93 | WARN(1, "Invalid gpio bank_type\n"); | 99 | WARN(1, "Invalid gpio bank_type\n"); |
diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h index aedd732ef464..c7e3a56340c0 100644 --- a/arch/arm/plat-omap/include/plat/gpio.h +++ b/arch/arm/plat-omap/include/plat/gpio.h | |||
@@ -182,6 +182,11 @@ struct omap_gpio_reg_offs { | |||
182 | u16 clr_dataout; | 182 | u16 clr_dataout; |
183 | u16 irqstatus; | 183 | u16 irqstatus; |
184 | u16 irqstatus2; | 184 | u16 irqstatus2; |
185 | u16 irqenable; | ||
186 | u16 set_irqenable; | ||
187 | u16 clr_irqenable; | ||
188 | |||
189 | bool irqenable_inv; | ||
185 | }; | 190 | }; |
186 | 191 | ||
187 | struct omap_gpio_platform_data { | 192 | struct omap_gpio_platform_data { |
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index bdf0132b70ec..6afca28a8c67 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -502,129 +502,60 @@ static inline void _clear_gpio_irqstatus(struct gpio_bank *bank, int gpio) | |||
502 | static u32 _get_gpio_irqbank_mask(struct gpio_bank *bank) | 502 | static u32 _get_gpio_irqbank_mask(struct gpio_bank *bank) |
503 | { | 503 | { |
504 | void __iomem *reg = bank->base; | 504 | void __iomem *reg = bank->base; |
505 | int inv = 0; | ||
506 | u32 l; | 505 | u32 l; |
507 | u32 mask = (1 << bank->width) - 1; | 506 | u32 mask = (1 << bank->width) - 1; |
508 | 507 | ||
509 | switch (bank->method) { | 508 | reg += bank->regs->irqenable; |
510 | #ifdef CONFIG_ARCH_OMAP1 | ||
511 | case METHOD_MPUIO: | ||
512 | reg += OMAP_MPUIO_GPIO_MASKIT / bank->stride; | ||
513 | inv = 1; | ||
514 | break; | ||
515 | #endif | ||
516 | #ifdef CONFIG_ARCH_OMAP15XX | ||
517 | case METHOD_GPIO_1510: | ||
518 | reg += OMAP1510_GPIO_INT_MASK; | ||
519 | inv = 1; | ||
520 | break; | ||
521 | #endif | ||
522 | #ifdef CONFIG_ARCH_OMAP16XX | ||
523 | case METHOD_GPIO_1610: | ||
524 | reg += OMAP1610_GPIO_IRQENABLE1; | ||
525 | break; | ||
526 | #endif | ||
527 | #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) | ||
528 | case METHOD_GPIO_7XX: | ||
529 | reg += OMAP7XX_GPIO_INT_MASK; | ||
530 | inv = 1; | ||
531 | break; | ||
532 | #endif | ||
533 | #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) | ||
534 | case METHOD_GPIO_24XX: | ||
535 | reg += OMAP24XX_GPIO_IRQENABLE1; | ||
536 | break; | ||
537 | #endif | ||
538 | #if defined(CONFIG_ARCH_OMAP4) | ||
539 | case METHOD_GPIO_44XX: | ||
540 | reg += OMAP4_GPIO_IRQSTATUSSET0; | ||
541 | break; | ||
542 | #endif | ||
543 | default: | ||
544 | WARN_ON(1); | ||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | l = __raw_readl(reg); | 509 | l = __raw_readl(reg); |
549 | if (inv) | 510 | if (bank->regs->irqenable_inv) |
550 | l = ~l; | 511 | l = ~l; |
551 | l &= mask; | 512 | l &= mask; |
552 | return l; | 513 | return l; |
553 | } | 514 | } |
554 | 515 | ||
555 | static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask, int enable) | 516 | static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask) |
556 | { | 517 | { |
557 | void __iomem *reg = bank->base; | 518 | void __iomem *reg = bank->base; |
558 | u32 l; | 519 | u32 l; |
559 | 520 | ||
560 | switch (bank->method) { | 521 | if (bank->regs->set_irqenable) { |
561 | #ifdef CONFIG_ARCH_OMAP1 | 522 | reg += bank->regs->set_irqenable; |
562 | case METHOD_MPUIO: | 523 | l = gpio_mask; |
563 | reg += OMAP_MPUIO_GPIO_MASKIT / bank->stride; | 524 | } else { |
564 | l = __raw_readl(reg); | 525 | reg += bank->regs->irqenable; |
565 | if (enable) | ||
566 | l &= ~(gpio_mask); | ||
567 | else | ||
568 | l |= gpio_mask; | ||
569 | break; | ||
570 | #endif | ||
571 | #ifdef CONFIG_ARCH_OMAP15XX | ||
572 | case METHOD_GPIO_1510: | ||
573 | reg += OMAP1510_GPIO_INT_MASK; | ||
574 | l = __raw_readl(reg); | 526 | l = __raw_readl(reg); |
575 | if (enable) | 527 | if (bank->regs->irqenable_inv) |
576 | l &= ~(gpio_mask); | 528 | l &= ~gpio_mask; |
577 | else | 529 | else |
578 | l |= gpio_mask; | 530 | l |= gpio_mask; |
579 | break; | 531 | } |
580 | #endif | 532 | |
581 | #ifdef CONFIG_ARCH_OMAP16XX | 533 | __raw_writel(l, reg); |
582 | case METHOD_GPIO_1610: | 534 | } |
583 | if (enable) | 535 | |
584 | reg += OMAP1610_GPIO_SET_IRQENABLE1; | 536 | static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask) |
585 | else | 537 | { |
586 | reg += OMAP1610_GPIO_CLEAR_IRQENABLE1; | 538 | void __iomem *reg = bank->base; |
539 | u32 l; | ||
540 | |||
541 | if (bank->regs->clr_irqenable) { | ||
542 | reg += bank->regs->clr_irqenable; | ||
587 | l = gpio_mask; | 543 | l = gpio_mask; |
588 | break; | 544 | } else { |
589 | #endif | 545 | reg += bank->regs->irqenable; |
590 | #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) | ||
591 | case METHOD_GPIO_7XX: | ||
592 | reg += OMAP7XX_GPIO_INT_MASK; | ||
593 | l = __raw_readl(reg); | 546 | l = __raw_readl(reg); |
594 | if (enable) | 547 | if (bank->regs->irqenable_inv) |
595 | l &= ~(gpio_mask); | ||
596 | else | ||
597 | l |= gpio_mask; | 548 | l |= gpio_mask; |
598 | break; | ||
599 | #endif | ||
600 | #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) | ||
601 | case METHOD_GPIO_24XX: | ||
602 | if (enable) | ||
603 | reg += OMAP24XX_GPIO_SETIRQENABLE1; | ||
604 | else | ||
605 | reg += OMAP24XX_GPIO_CLEARIRQENABLE1; | ||
606 | l = gpio_mask; | ||
607 | break; | ||
608 | #endif | ||
609 | #ifdef CONFIG_ARCH_OMAP4 | ||
610 | case METHOD_GPIO_44XX: | ||
611 | if (enable) | ||
612 | reg += OMAP4_GPIO_IRQSTATUSSET0; | ||
613 | else | 549 | else |
614 | reg += OMAP4_GPIO_IRQSTATUSCLR0; | 550 | l &= ~gpio_mask; |
615 | l = gpio_mask; | ||
616 | break; | ||
617 | #endif | ||
618 | default: | ||
619 | WARN_ON(1); | ||
620 | return; | ||
621 | } | 551 | } |
552 | |||
622 | __raw_writel(l, reg); | 553 | __raw_writel(l, reg); |
623 | } | 554 | } |
624 | 555 | ||
625 | static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable) | 556 | static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable) |
626 | { | 557 | { |
627 | _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio), enable); | 558 | _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio)); |
628 | } | 559 | } |
629 | 560 | ||
630 | /* | 561 | /* |
@@ -831,9 +762,9 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | |||
831 | /* clear edge sensitive interrupts before handler(s) are | 762 | /* clear edge sensitive interrupts before handler(s) are |
832 | called so that we don't miss any interrupt occurred while | 763 | called so that we don't miss any interrupt occurred while |
833 | executing them */ | 764 | executing them */ |
834 | _enable_gpio_irqbank(bank, isr_saved & ~level_mask, 0); | 765 | _disable_gpio_irqbank(bank, isr_saved & ~level_mask); |
835 | _clear_gpio_irqbank(bank, isr_saved & ~level_mask); | 766 | _clear_gpio_irqbank(bank, isr_saved & ~level_mask); |
836 | _enable_gpio_irqbank(bank, isr_saved & ~level_mask, 1); | 767 | _enable_gpio_irqbank(bank, isr_saved & ~level_mask); |
837 | 768 | ||
838 | /* if there is only edge sensitive GPIO pin interrupts | 769 | /* if there is only edge sensitive GPIO pin interrupts |
839 | configured, we could unmask GPIO bank interrupt immediately */ | 770 | configured, we could unmask GPIO bank interrupt immediately */ |