aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-u300/gpio.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@stericsson.com>2009-05-08 03:59:51 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-05-18 11:48:55 -0400
commitf7a9a4d782628b4bd2392d931b95bd49732a2918 (patch)
treeff8289780c6f9de55d118486c16a1220eb530d0b /arch/arm/mach-u300/gpio.c
parentd98aac7592114241f378bc8d5b3e424cced7ded2 (diff)
[ARM] 5510/1: U300 GPIO debug and init fixes
This moves the GPIO driver away from using __devinit and __devexit It also removes all printk() in favor of using dev_* print macros on pdev->dev struct instead. Surplus prints are removed, and the platform_device_probe() function is used instead of putting a .probe function in the platform driver struct. Signed-off-by: Linus Walleij <linus.walleij@stericsson.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-u300/gpio.c')
-rw-r--r--arch/arm/mach-u300/gpio.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/arch/arm/mach-u300/gpio.c b/arch/arm/mach-u300/gpio.c
index 2d5ae8ecb8c8..308cdb197a92 100644
--- a/arch/arm/mach-u300/gpio.c
+++ b/arch/arm/mach-u300/gpio.c
@@ -36,6 +36,7 @@ static struct clk *clk;
36/* Memory resource */ 36/* Memory resource */
37static struct resource *memres; 37static struct resource *memres;
38static void __iomem *virtbase; 38static void __iomem *virtbase;
39static struct device *gpiodev;
39 40
40struct u300_gpio_port { 41struct u300_gpio_port {
41 const char *name; 42 const char *name;
@@ -264,8 +265,8 @@ static struct gpio_struct gpio_pin[U300_GPIO_MAX];
264int gpio_register_callback(unsigned gpio, int (*func)(void *arg), void *data) 265int gpio_register_callback(unsigned gpio, int (*func)(void *arg), void *data)
265{ 266{
266 if (gpio_pin[gpio].callback) 267 if (gpio_pin[gpio].callback)
267 printk(KERN_WARNING "GPIO: %s: WARNING: callback already " \ 268 dev_warn(gpiodev, "%s: WARNING: callback already "
268 "registered for gpio pin#%d\n", __func__, gpio); 269 "registered for gpio pin#%d\n", __func__, gpio);
269 gpio_pin[gpio].callback = func; 270 gpio_pin[gpio].callback = func;
270 gpio_pin[gpio].data = data; 271 gpio_pin[gpio].data = data;
271 272
@@ -276,8 +277,8 @@ EXPORT_SYMBOL(gpio_register_callback);
276int gpio_unregister_callback(unsigned gpio) 277int gpio_unregister_callback(unsigned gpio)
277{ 278{
278 if (!gpio_pin[gpio].callback) 279 if (!gpio_pin[gpio].callback)
279 printk(KERN_WARNING "GPIO: %s: WARNING: callback already " \ 280 dev_warn(gpiodev, "%s: WARNING: callback already "
280 "unregistered for gpio pin#%d\n", __func__, gpio); 281 "unregistered for gpio pin#%d\n", __func__, gpio);
281 gpio_pin[gpio].callback = NULL; 282 gpio_pin[gpio].callback = NULL;
282 gpio_pin[gpio].data = NULL; 283 gpio_pin[gpio].data = NULL;
283 284
@@ -303,8 +304,8 @@ void gpio_free(unsigned gpio)
303 gpio_users--; 304 gpio_users--;
304 gpio_pin[gpio].users--; 305 gpio_pin[gpio].users--;
305 if (unlikely(gpio_pin[gpio].users < 0)) { 306 if (unlikely(gpio_pin[gpio].users < 0)) {
306 printk(KERN_WARNING "GPIO: Warning: gpio#%d release mismatch\n", 307 dev_warn(gpiodev, "warning: gpio#%d release mismatch\n",
307 gpio); 308 gpio);
308 gpio_pin[gpio].users = 0; 309 gpio_pin[gpio].users = 0;
309 } 310 }
310 311
@@ -492,7 +493,7 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
492 if (gpio_pin[gpio].callback) 493 if (gpio_pin[gpio].callback)
493 (void)gpio_pin[gpio].callback(gpio_pin[gpio].data); 494 (void)gpio_pin[gpio].callback(gpio_pin[gpio].data);
494 else 495 else
495 printk(KERN_DEBUG "GPIO: Stray GPIO IRQ on line %d\n", 496 dev_dbg(gpiodev, "stray GPIO IRQ on line %d\n",
496 gpio); 497 gpio);
497 } 498 }
498 return IRQ_HANDLED; 499 return IRQ_HANDLED;
@@ -548,25 +549,26 @@ static void gpio_set_initial_values(void)
548#endif 549#endif
549} 550}
550 551
551static int __devinit gpio_probe(struct platform_device *pdev) 552static int __init gpio_probe(struct platform_device *pdev)
552{ 553{
553 u32 val; 554 u32 val;
554 int err = 0; 555 int err = 0;
555 int i; 556 int i;
556 int num_irqs; 557 int num_irqs;
557 558
559 gpiodev = &pdev->dev;
558 memset(gpio_pin, 0, sizeof(gpio_pin)); 560 memset(gpio_pin, 0, sizeof(gpio_pin));
559 561
560 /* Get GPIO clock */ 562 /* Get GPIO clock */
561 clk = clk_get(&pdev->dev, NULL); 563 clk = clk_get(&pdev->dev, NULL);
562 if (IS_ERR(clk)) { 564 if (IS_ERR(clk)) {
563 err = PTR_ERR(clk); 565 err = PTR_ERR(clk);
564 printk(KERN_ERR "GPIO: could not get GPIO clock\n"); 566 dev_err(gpiodev, "could not get GPIO clock\n");
565 goto err_no_clk; 567 goto err_no_clk;
566 } 568 }
567 err = clk_enable(clk); 569 err = clk_enable(clk);
568 if (err) { 570 if (err) {
569 printk(KERN_ERR "GPIO: could not enable GPIO clock\n"); 571 dev_err(gpiodev, "could not enable GPIO clock\n");
570 goto err_no_clk_enable; 572 goto err_no_clk_enable;
571 } 573 }
572 574
@@ -580,22 +582,24 @@ static int __devinit gpio_probe(struct platform_device *pdev)
580 goto err_no_ioregion; 582 goto err_no_ioregion;
581 } 583 }
582 584
583 virtbase = ioremap(memres->start, memres->end - memres->start + 1); 585 virtbase = ioremap(memres->start, resource_size(memres));
584 if (!virtbase) { 586 if (!virtbase) {
585 err = -ENOMEM; 587 err = -ENOMEM;
586 goto err_no_ioremap; 588 goto err_no_ioremap;
587 } 589 }
590 dev_info(gpiodev, "remapped 0x%08x to %p\n",
591 memres->start, virtbase);
588 592
589#ifdef U300_COH901335 593#ifdef U300_COH901335
590 printk(KERN_INFO "GPIO: Initializing GPIO Controller COH 901 335\n"); 594 dev_info(gpiodev, "initializing GPIO Controller COH 901 335\n");
591 /* Turn on the GPIO block */ 595 /* Turn on the GPIO block */
592 writel(U300_GPIO_CR_BLOCK_CLOCK_ENABLE, virtbase + U300_GPIO_CR); 596 writel(U300_GPIO_CR_BLOCK_CLOCK_ENABLE, virtbase + U300_GPIO_CR);
593#endif 597#endif
594 598
595#ifdef U300_COH901571_3 599#ifdef U300_COH901571_3
596 printk(KERN_INFO "GPIO: Initializing GPIO Controller COH 901 571/3\n"); 600 dev_info(gpiodev, "initializing GPIO Controller COH 901 571/3\n");
597 val = readl(virtbase + U300_GPIO_CR); 601 val = readl(virtbase + U300_GPIO_CR);
598 printk(KERN_INFO "GPIO: COH901571/3 block version: %d, " \ 602 dev_info(gpiodev, "COH901571/3 block version: %d, " \
599 "number of cores: %d\n", 603 "number of cores: %d\n",
600 ((val & 0x0000FE00) >> 9), 604 ((val & 0x0000FE00) >> 9),
601 ((val & 0x000001FC) >> 2)); 605 ((val & 0x000001FC) >> 2));
@@ -623,15 +627,14 @@ static int __devinit gpio_probe(struct platform_device *pdev)
623 gpio_ports[num_irqs].name, 627 gpio_ports[num_irqs].name,
624 &gpio_ports[num_irqs]); 628 &gpio_ports[num_irqs]);
625 if (err) { 629 if (err) {
626 printk(KERN_CRIT "GPIO: Cannot allocate IRQ for %s!\n", 630 dev_err(gpiodev, "cannot allocate IRQ for %s!\n",
627 gpio_ports[num_irqs].name); 631 gpio_ports[num_irqs].name);
628 goto err_no_irq; 632 goto err_no_irq;
629 } 633 }
630 /* Turns off PortX_irq_force */ 634 /* Turns off PortX_irq_force */
631 writel(0x0, virtbase + U300_GPIO_PXIFR + 635 writel(0x0, virtbase + U300_GPIO_PXIFR +
632 num_irqs * U300_GPIO_PORTX_SPACING); 636 num_irqs * U300_GPIO_PORTX_SPACING);
633 } 637 }
634 printk(KERN_INFO "GPIO: U300 gpio module loaded\n");
635 638
636 return 0; 639 return 0;
637 640
@@ -647,11 +650,11 @@ static int __devinit gpio_probe(struct platform_device *pdev)
647 err_no_clk_enable: 650 err_no_clk_enable:
648 clk_put(clk); 651 clk_put(clk);
649 err_no_clk: 652 err_no_clk:
650 printk(KERN_INFO "GPIO: module ERROR:%d\n", err); 653 dev_info(gpiodev, "module ERROR:%d\n", err);
651 return err; 654 return err;
652} 655}
653 656
654static int __devexit gpio_remove(struct platform_device *pdev) 657static int __exit gpio_remove(struct platform_device *pdev)
655{ 658{
656 int i; 659 int i;
657 660
@@ -670,14 +673,13 @@ static struct platform_driver gpio_driver = {
670 .driver = { 673 .driver = {
671 .name = "u300-gpio", 674 .name = "u300-gpio",
672 }, 675 },
673 .probe = gpio_probe, 676 .remove = __exit_p(gpio_remove),
674 .remove = __devexit_p(gpio_remove),
675}; 677};
676 678
677 679
678static int __init u300_gpio_init(void) 680static int __init u300_gpio_init(void)
679{ 681{
680 return platform_driver_register(&gpio_driver); 682 return platform_driver_probe(&gpio_driver, gpio_probe);
681} 683}
682 684
683static void __exit u300_gpio_exit(void) 685static void __exit u300_gpio_exit(void)