aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-pxa.c
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@linaro.org>2013-04-07 04:44:33 -0400
committerHaojian Zhuang <haojian.zhuang@linaro.org>2013-04-10 21:59:23 -0400
commit2cab0292285ce3180224c130d2fb1104aee44ff1 (patch)
treea3f8bea618053618e7e1461b743ac7cb6e444454 /drivers/gpio/gpio-pxa.c
parent31880c37c11e28cb81c70757e38392b42e695dc6 (diff)
ARM: pxa: remove cpu_is_xxx in gpio driver
Avoid to use cpu_is_xxx() in pxa gpio driver. Use platform_device_id to identify the difference. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-pxa.c')
-rw-r--r--drivers/gpio/gpio-pxa.c106
1 files changed, 73 insertions, 33 deletions
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 9cc108d2b770..fe74b0cc2bcb 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -86,20 +86,61 @@ struct pxa_gpio_chip {
86#endif 86#endif
87}; 87};
88 88
89enum { 89enum pxa_gpio_type {
90 PXA25X_GPIO = 0, 90 PXA25X_GPIO = 0,
91 PXA26X_GPIO, 91 PXA26X_GPIO,
92 PXA27X_GPIO, 92 PXA27X_GPIO,
93 PXA3XX_GPIO, 93 PXA3XX_GPIO,
94 PXA93X_GPIO, 94 PXA93X_GPIO,
95 MMP_GPIO = 0x10, 95 MMP_GPIO = 0x10,
96 MMP2_GPIO,
97};
98
99struct pxa_gpio_id {
100 enum pxa_gpio_type type;
101 int gpio_nums;
96}; 102};
97 103
98static DEFINE_SPINLOCK(gpio_lock); 104static DEFINE_SPINLOCK(gpio_lock);
99static struct pxa_gpio_chip *pxa_gpio_chips; 105static struct pxa_gpio_chip *pxa_gpio_chips;
100static int gpio_type; 106static enum pxa_gpio_type gpio_type;
101static void __iomem *gpio_reg_base; 107static void __iomem *gpio_reg_base;
102 108
109static struct pxa_gpio_id pxa25x_id = {
110 .type = PXA25X_GPIO,
111 .gpio_nums = 85,
112};
113
114static struct pxa_gpio_id pxa26x_id = {
115 .type = PXA26X_GPIO,
116 .gpio_nums = 90,
117};
118
119static struct pxa_gpio_id pxa27x_id = {
120 .type = PXA27X_GPIO,
121 .gpio_nums = 121,
122};
123
124static struct pxa_gpio_id pxa3xx_id = {
125 .type = PXA3XX_GPIO,
126 .gpio_nums = 128,
127};
128
129static struct pxa_gpio_id pxa93x_id = {
130 .type = PXA93X_GPIO,
131 .gpio_nums = 192,
132};
133
134static struct pxa_gpio_id mmp_id = {
135 .type = MMP_GPIO,
136 .gpio_nums = 128,
137};
138
139static struct pxa_gpio_id mmp2_id = {
140 .type = MMP2_GPIO,
141 .gpio_nums = 192,
142};
143
103#define for_each_gpio_chip(i, c) \ 144#define for_each_gpio_chip(i, c) \
104 for (i = 0, c = &pxa_gpio_chips[0]; i <= pxa_last_gpio; i += 32, c++) 145 for (i = 0, c = &pxa_gpio_chips[0]; i <= pxa_last_gpio; i += 32, c++)
105 146
@@ -432,40 +473,27 @@ static struct irq_chip pxa_muxed_gpio_chip = {
432 .irq_set_wake = pxa_gpio_set_wake, 473 .irq_set_wake = pxa_gpio_set_wake,
433}; 474};
434 475
435static int pxa_gpio_nums(void) 476static int pxa_gpio_nums(struct platform_device *pdev)
436{ 477{
478 const struct platform_device_id *id = platform_get_device_id(pdev);
479 struct pxa_gpio_id *pxa_id = (struct pxa_gpio_id *)id->driver_data;
437 int count = 0; 480 int count = 0;
438 481
439#ifdef CONFIG_ARCH_PXA 482 switch (pxa_id->type) {
440 if (cpu_is_pxa25x()) { 483 case PXA25X_GPIO:
441#ifdef CONFIG_CPU_PXA26x 484 case PXA26X_GPIO:
442 count = 89; 485 case PXA27X_GPIO:
443 gpio_type = PXA26X_GPIO; 486 case PXA3XX_GPIO:
444#elif defined(CONFIG_PXA25x) 487 case PXA93X_GPIO:
445 count = 84; 488 case MMP_GPIO:
446 gpio_type = PXA26X_GPIO; 489 case MMP2_GPIO:
447#endif /* CONFIG_CPU_PXA26x */ 490 gpio_type = pxa_id->type;
448 } else if (cpu_is_pxa27x()) { 491 count = pxa_id->gpio_nums - 1;
449 count = 120; 492 break;
450 gpio_type = PXA27X_GPIO; 493 default:
451 } else if (cpu_is_pxa93x()) { 494 count = -EINVAL;
452 count = 191; 495 break;
453 gpio_type = PXA93X_GPIO;
454 } else if (cpu_is_pxa3xx()) {
455 count = 127;
456 gpio_type = PXA3XX_GPIO;
457 }
458#endif /* CONFIG_ARCH_PXA */
459
460#ifdef CONFIG_ARCH_MMP
461 if (cpu_is_pxa168() || cpu_is_pxa910()) {
462 count = 127;
463 gpio_type = MMP_GPIO;
464 } else if (cpu_is_mmp2()) {
465 count = 191;
466 gpio_type = MMP_GPIO;
467 } 496 }
468#endif /* CONFIG_ARCH_MMP */
469 return count; 497 return count;
470} 498}
471 499
@@ -548,7 +576,7 @@ static int pxa_gpio_probe(struct platform_device *pdev)
548 576
549 ret = pxa_gpio_probe_dt(pdev); 577 ret = pxa_gpio_probe_dt(pdev);
550 if (ret < 0) { 578 if (ret < 0) {
551 pxa_last_gpio = pxa_gpio_nums(); 579 pxa_last_gpio = pxa_gpio_nums(pdev);
552#ifdef CONFIG_ARCH_PXA 580#ifdef CONFIG_ARCH_PXA
553 if (gpio_is_pxa_type(gpio_type)) 581 if (gpio_is_pxa_type(gpio_type))
554 irq_base = PXA_GPIO_TO_IRQ(0); 582 irq_base = PXA_GPIO_TO_IRQ(0);
@@ -635,12 +663,24 @@ static int pxa_gpio_probe(struct platform_device *pdev)
635 return 0; 663 return 0;
636} 664}
637 665
666static const struct platform_device_id gpio_id_table[] = {
667 { "pxa25x-gpio", (unsigned long)&pxa25x_id },
668 { "pxa26x-gpio", (unsigned long)&pxa26x_id },
669 { "pxa27x-gpio", (unsigned long)&pxa27x_id },
670 { "pxa3xx-gpio", (unsigned long)&pxa3xx_id },
671 { "pxa93x-gpio", (unsigned long)&pxa93x_id },
672 { "mmp-gpio", (unsigned long)&mmp_id },
673 { "mmp2-gpio", (unsigned long)&mmp2_id },
674 { },
675};
676
638static struct platform_driver pxa_gpio_driver = { 677static struct platform_driver pxa_gpio_driver = {
639 .probe = pxa_gpio_probe, 678 .probe = pxa_gpio_probe,
640 .driver = { 679 .driver = {
641 .name = "pxa-gpio", 680 .name = "pxa-gpio",
642 .of_match_table = of_match_ptr(pxa_gpio_dt_ids), 681 .of_match_table = of_match_ptr(pxa_gpio_dt_ids),
643 }, 682 },
683 .id_table = gpio_id_table,
644}; 684};
645module_platform_driver(pxa_gpio_driver); 685module_platform_driver(pxa_gpio_driver);
646 686