From: Dinh Nguyen <dingu...@altera.com>

Update pci portion of the dwc2 driver to call the appropriate init functions
for host, gadget, and dual-role.

Signed-off-by: Dinh Nguyen <dingu...@altera.com>
---
 drivers/usb/dwc2/pci.c |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index c291fca..69bd27a 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -102,7 +102,14 @@ static void dwc2_driver_remove(struct pci_dev *dev)
 {
        struct dwc2_hsotg *hsotg = pci_get_drvdata(dev);
 
-       dwc2_hcd_remove(hsotg);
+       if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
+               s3c_hsotg_remove(hsotg);
+       else if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
+               dwc2_hcd_remove(hsotg);
+       else { /* dual role */
+               s3c_hsotg_remove(hsotg);
+               dwc2_hcd_remove(hsotg);
+       }
        pci_disable_device(dev);
 }
 
@@ -141,13 +148,30 @@ static int dwc2_driver_probe(struct pci_dev *dev,
 
        pci_set_master(dev);
 
-       retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+       if (IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)) {
+               retval = dwc2_gadget_init(hsotg, dev->irq);
+               if (retval)
+                       return retval;
+               retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+               if (retval)
+                       return retval;
+       } else if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
+               retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+               if (retval)
+                       return retval;
+       } else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL)) {
+               retval = dwc2_gadget_init(hsotg, dev->irq);
+               if (retval)
+                       return retval;
+       }
+
        if (retval) {
                pci_disable_device(dev);
                return retval;
        }
 
        pci_set_drvdata(dev, hsotg);
+       spin_lock_init(&hsotg->lock);
 
        return retval;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to