From: Dinh Nguyen <dinguyen@xxxxxxxxxx> Add the proper init calls for either host, gadget or both in platform.c Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxx> --- drivers/usb/dwc2/core.h | 3 +++ drivers/usb/dwc2/gadget.c | 2 +- drivers/usb/dwc2/platform.c | 29 +++++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 0fc4e41..7fbf7f0 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -964,6 +964,7 @@ extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2); extern void s3c_hsotg_disable_gsint(struct dwc2_hsotg *dwc2, u32 ints); extern void s3c_hsotg_irq_fifoempty(struct dwc2_hsotg *dwc2, bool periodic); extern void s3c_hsotg_handle_rx(struct dwc2_hsotg *dwc2); +extern int s3c_hsotg_remove(struct dwc2_hsotg *dwc2); extern void s3c_hsotg_dump(struct dwc2_hsotg *dwc2); extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2); extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2); @@ -980,6 +981,8 @@ static inline void s3c_hsotg_disable_gsint(struct dwc2_hsotg *dwc2, u32 ints) static inline void s3c_hsotg_irq_fifoempty(struct dwc2_hsotg *dwc2, bool periodic) {} static inline void s3c_hsotg_handle_rx(struct dwc2_hsotg *dwc2) {} +static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2) +{ return 0; } static inline void s3c_hsotg_dump(struct dwc2_hsotg *dwc2) {} static inline int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2) { return 0; } diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 42d1d60..b8c466f 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3539,7 +3539,7 @@ err_clk: * s3c_hsotg_remove - remove function for hsotg driver * @pdev: The platform information for the driver */ -static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2) +int s3c_hsotg_remove(struct dwc2_hsotg *dwc2) { usb_del_gadget_udc(&dwc2->gadget); diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 53e6c90..714e128 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -41,6 +41,7 @@ #include <linux/dma-mapping.h> #include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/usb/otg.h> #include "core.h" #include "hcd.h" @@ -90,7 +91,14 @@ static int dwc2_driver_remove(struct platform_device *dev) { struct dwc2_hsotg *hsotg = platform_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 */ + dwc2_hcd_remove(hsotg); + s3c_hsotg_remove(hsotg); + } return 0; } @@ -176,9 +184,22 @@ static int dwc2_driver_probe(struct platform_device *dev) dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n", (unsigned long)res->start, hsotg->regs); - retval = dwc2_hcd_init(hsotg, irq, params); - if (retval) - return retval; + if (IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)) { + retval = dwc2_gadget_init(hsotg, irq); + if (retval) + return retval; + retval = dwc2_hcd_init(hsotg, irq, params); + if (retval) + return retval; + } else if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) { + retval = dwc2_hcd_init(hsotg, irq, params); + if (retval) + return retval; + } else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL)) { + retval = dwc2_gadget_init(hsotg, irq); + if (retval) + return retval; + } platform_set_drvdata(dev, hsotg); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html