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/gadget.c | 6 ++---- drivers/usb/dwc2/hcd.c | 1 + drivers/usb/dwc2/platform.c | 29 +++++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 51ee052..8992fe1 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3189,7 +3189,7 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg *dwc2) * @irq: The IRQ number for the controller. */ -static int dwc2_gadget_init(struct dwc2_hsotg *dwc2, int irq) +int dwc2_gadget_init(struct dwc2_hsotg *dwc2, int irq) { struct s3c_hsotg_plat *plat = dwc2->dev->platform_data; struct phy *phy; @@ -3351,7 +3351,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) +void s3c_hsotg_remove(struct dwc2_hsotg *dwc2) { usb_del_gadget_udc(&dwc2->gadget); @@ -3367,8 +3367,6 @@ static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2) phy_exit(dwc2->s3c_hsotg->phy); if (dwc2->s3c_hsotg->clk) clk_disable_unprepare(dwc2->s3c_hsotg->clk); - - return 0; } static int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 4d918ed..07a7bcd 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -1355,6 +1355,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work) hsotg->op_state = OTG_STATE_B_PERIPHERAL; dwc2_core_init(hsotg, false, -1); dwc2_enable_global_interrupts(hsotg); + s3c_hsotg_core_init(hsotg); } else { /* A-Device connector (Host Mode) */ dev_dbg(hsotg->dev, "connId A\n"); diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index e5747f2..259d3f4 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 */ + s3c_hsotg_remove(hsotg); + dwc2_hcd_remove(hsotg); + } return 0; } @@ -172,9 +180,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