aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ohci-at91.c
diff options
context:
space:
mode:
authorNicolas Ferre <nicolas.ferre@atmel.com>2012-03-21 11:58:11 -0400
committerNicolas Ferre <nicolas.ferre@atmel.com>2012-04-04 12:35:15 -0400
commitaaf9f5fc67c18259760d6302e679dcb3e36709a7 (patch)
treecfefa6118d7cdf38cd9c11769f242f784bc7b1c7 /drivers/usb/host/ohci-at91.c
parent74adcb210685e7191425b6203e67c08d759412fa (diff)
USB: ohci-at91: rework and fix initialization
The DT information are filled in a pdata structure and then passed on to the usual check code of the probe function. Thus we do not need to redo the gpio checking and irq configuration in the DT-related code. On the other hand, we setup GPIO direction in driver for vbus and overcurrent. It will be useful when moving to pinctrl subsystem. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Acked-by: Alan Stern <stern@rowland.harvard.edu>
Diffstat (limited to 'drivers/usb/host/ohci-at91.c')
-rw-r--r--drivers/usb/host/ohci-at91.c88
1 files changed, 46 insertions, 42 deletions
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 4d266ae5152d..c30da6ab9f92 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -492,7 +492,7 @@ static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32);
492static int __devinit ohci_at91_of_init(struct platform_device *pdev) 492static int __devinit ohci_at91_of_init(struct platform_device *pdev)
493{ 493{
494 struct device_node *np = pdev->dev.of_node; 494 struct device_node *np = pdev->dev.of_node;
495 int i, ret, gpio; 495 int i, gpio;
496 enum of_gpio_flags flags; 496 enum of_gpio_flags flags;
497 struct at91_usbh_data *pdata; 497 struct at91_usbh_data *pdata;
498 u32 ports; 498 u32 ports;
@@ -520,42 +520,11 @@ static int __devinit ohci_at91_of_init(struct platform_device *pdev)
520 if (!gpio_is_valid(gpio)) 520 if (!gpio_is_valid(gpio))
521 continue; 521 continue;
522 pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW; 522 pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW;
523 ret = gpio_request(gpio, "ohci_vbus");
524 if (ret) {
525 dev_warn(&pdev->dev, "can't request vbus gpio %d", gpio);
526 continue;
527 }
528 ret = gpio_direction_output(gpio, !(flags & OF_GPIO_ACTIVE_LOW) ^ 1);
529 if (ret)
530 dev_warn(&pdev->dev, "can't put vbus gpio %d as output %d",
531 !(flags & OF_GPIO_ACTIVE_LOW) ^ 1, gpio);
532 } 523 }
533 524
534 for (i = 0; i < 2; i++) { 525 for (i = 0; i < 2; i++)
535 gpio = of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags); 526 pdata->overcurrent_pin[i] =
536 pdata->overcurrent_pin[i] = gpio; 527 of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags);
537 if (!gpio_is_valid(gpio))
538 continue;
539 ret = gpio_request(gpio, "ohci_overcurrent");
540 if (ret) {
541 dev_err(&pdev->dev, "can't request overcurrent gpio %d", gpio);
542 continue;
543 }
544
545 ret = gpio_direction_input(gpio);
546 if (ret) {
547 dev_err(&pdev->dev, "can't configure overcurrent gpio %d as input", gpio);
548 continue;
549 }
550
551 ret = request_irq(gpio_to_irq(gpio),
552 ohci_hcd_at91_overcurrent_irq,
553 IRQF_SHARED, "ohci_overcurrent", pdev);
554 if (ret) {
555 gpio_free(gpio);
556 dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n");
557 }
558 }
559 528
560 pdev->dev.platform_data = pdata; 529 pdev->dev.platform_data = pdata;
561 530
@@ -574,6 +543,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
574{ 543{
575 struct at91_usbh_data *pdata; 544 struct at91_usbh_data *pdata;
576 int i; 545 int i;
546 int gpio;
547 int ret;
577 548
578 i = ohci_at91_of_init(pdev); 549 i = ohci_at91_of_init(pdev);
579 550
@@ -586,23 +557,56 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
586 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { 557 for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) {
587 if (!gpio_is_valid(pdata->vbus_pin[i])) 558 if (!gpio_is_valid(pdata->vbus_pin[i]))
588 continue; 559 continue;
589 gpio_request(pdata->vbus_pin[i], "ohci_vbus"); 560 gpio = pdata->vbus_pin[i];
561
562 ret = gpio_request(gpio, "ohci_vbus");
563 if (ret) {
564 dev_err(&pdev->dev,
565 "can't request vbus gpio %d\n", gpio);
566 continue;
567 }
568 ret = gpio_direction_output(gpio,
569 !pdata->vbus_pin_active_low[i]);
570 if (ret) {
571 dev_err(&pdev->dev,
572 "can't put vbus gpio %d as output %d\n",
573 gpio, !pdata->vbus_pin_active_low[i]);
574 gpio_free(gpio);
575 continue;
576 }
577
590 ohci_at91_usb_set_power(pdata, i, 1); 578 ohci_at91_usb_set_power(pdata, i, 1);
591 } 579 }
592 580
593 for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { 581 for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) {
594 int ret;
595
596 if (!gpio_is_valid(pdata->overcurrent_pin[i])) 582 if (!gpio_is_valid(pdata->overcurrent_pin[i]))
597 continue; 583 continue;
598 gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); 584 gpio = pdata->overcurrent_pin[i];
585
586 ret = gpio_request(gpio, "ohci_overcurrent");
587 if (ret) {
588 dev_err(&pdev->dev,
589 "can't request overcurrent gpio %d\n",
590 gpio);
591 continue;
592 }
593
594 ret = gpio_direction_input(gpio);
595 if (ret) {
596 dev_err(&pdev->dev,
597 "can't configure overcurrent gpio %d as input\n",
598 gpio);
599 gpio_free(gpio);
600 continue;
601 }
599 602
600 ret = request_irq(gpio_to_irq(pdata->overcurrent_pin[i]), 603 ret = request_irq(gpio_to_irq(gpio),
601 ohci_hcd_at91_overcurrent_irq, 604 ohci_hcd_at91_overcurrent_irq,
602 IRQF_SHARED, "ohci_overcurrent", pdev); 605 IRQF_SHARED, "ohci_overcurrent", pdev);
603 if (ret) { 606 if (ret) {
604 gpio_free(pdata->overcurrent_pin[i]); 607 gpio_free(gpio);
605 dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n"); 608 dev_err(&pdev->dev,
609 "can't get gpio IRQ for overcurrent\n");
606 } 610 }
607 } 611 }
608 } 612 }