]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/host/ohci-at91.c
usb host: fix platform driver hotplug/coldplug
[linux-2.6-omap-h63xx.git] / drivers / usb / host / ohci-at91.c
index d849c809acbdca97394fa7b8dcd8225733a91f5a..d72dc07dda017de12a51eaedc68b9c0626d26cb3 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <asm/mach-types.h>
 #include <asm/hardware.h>
+#include <asm/gpio.h>
+
 #include <asm/arch/board.h>
 #include <asm/arch/cpu.h>
 
@@ -271,12 +273,41 @@ static const struct hc_driver ohci_at91_hc_driver = {
 
 static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
 {
+       struct at91_usbh_data   *pdata = pdev->dev.platform_data;
+       int                     i;
+
+       if (pdata) {
+               /* REVISIT make the driver support per-port power switching,
+                * and also overcurrent detection.  Here we assume the ports
+                * are always powered while this driver is active, and use
+                * active-low power switches.
+                */
+               for (i = 0; i < pdata->ports; i++) {
+                       if (pdata->vbus_pin[i] <= 0)
+                               continue;
+                       gpio_request(pdata->vbus_pin[i], "ohci_vbus");
+                       gpio_direction_output(pdata->vbus_pin[i], 0);
+               }
+       }
+
        device_init_wakeup(&pdev->dev, 1);
        return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev);
 }
 
 static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
 {
+       struct at91_usbh_data   *pdata = pdev->dev.platform_data;
+       int                     i;
+
+       if (pdata) {
+               for (i = 0; i < pdata->ports; i++) {
+                       if (pdata->vbus_pin[i] <= 0)
+                               continue;
+                       gpio_direction_output(pdata->vbus_pin[i], 1);
+                       gpio_free(pdata->vbus_pin[i]);
+               }
+       }
+
        device_init_wakeup(&pdev->dev, 0);
        return usb_hcd_at91_remove(platform_get_drvdata(pdev), pdev);
 }
@@ -324,7 +355,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
 #define ohci_hcd_at91_drv_resume  NULL
 #endif
 
-MODULE_ALIAS("at91_ohci");
+MODULE_ALIAS("platform:at91_ohci");
 
 static struct platform_driver ohci_hcd_at91_driver = {
        .probe          = ohci_hcd_at91_drv_probe,
@@ -337,4 +368,3 @@ static struct platform_driver ohci_hcd_at91_driver = {
                .owner  = THIS_MODULE,
        },
 };
-