This patch adapts the dwc3 to use the device tree helper "of_usb_get_dr_mode" for the mode of operation of the dwc3 instance being probed. Signed-off-by: Ruchika Kharwar <ruchika@xxxxxx> --- drivers/usb/dwc3/core.c | 51 +++++++++++++++++++++++++---------------------- drivers/usb/dwc3/core.h | 5 ----- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c35d49d..7b98e4f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -517,14 +517,17 @@ static int dwc3_probe(struct platform_device *pdev) } if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) - mode = DWC3_MODE_HOST; + mode = USB_DR_MODE_HOST; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) - mode = DWC3_MODE_DEVICE; + mode = USB_DR_MODE_PERIPHERAL; else - mode = DWC3_MODE_DRD; + mode = of_usb_get_dr_mode(node); + + if (mode == USB_DR_MODE_UNKNOWN) + mode = USB_DR_MODE_OTG; switch (mode) { - case DWC3_MODE_DEVICE: + case USB_DR_MODE_PERIPHERAL: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); ret = dwc3_gadget_init(dwc); if (ret) { @@ -532,7 +535,7 @@ static int dwc3_probe(struct platform_device *pdev) goto err2; } break; - case DWC3_MODE_HOST: + case USB_DR_MODE_HOST: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); ret = dwc3_host_init(dwc); if (ret) { @@ -540,7 +543,7 @@ static int dwc3_probe(struct platform_device *pdev) goto err2; } break; - case DWC3_MODE_DRD: + case USB_DR_MODE_OTG: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); ret = dwc3_host_init(dwc); if (ret) { @@ -572,13 +575,13 @@ static int dwc3_probe(struct platform_device *pdev) err3: switch (mode) { - case DWC3_MODE_DEVICE: + case USB_DR_MODE_PERIPHERAL: dwc3_gadget_exit(dwc); break; - case DWC3_MODE_HOST: + case USB_DR_MODE_HOST: dwc3_host_exit(dwc); break; - case DWC3_MODE_DRD: + case USB_DR_MODE_OTG: dwc3_host_exit(dwc); dwc3_gadget_exit(dwc); break; @@ -612,13 +615,13 @@ static int dwc3_remove(struct platform_device *pdev) dwc3_debugfs_exit(dwc); switch (dwc->mode) { - case DWC3_MODE_DEVICE: + case USB_DR_MODE_PERIPHERAL: dwc3_gadget_exit(dwc); break; - case DWC3_MODE_HOST: + case USB_DR_MODE_HOST: dwc3_host_exit(dwc); break; - case DWC3_MODE_DRD: + case USB_DR_MODE_OTG: dwc3_host_exit(dwc); dwc3_gadget_exit(dwc); break; @@ -643,11 +646,11 @@ static int dwc3_prepare(struct device *dev) spin_lock_irqsave(&dwc->lock, flags); switch (dwc->mode) { - case DWC3_MODE_DEVICE: - case DWC3_MODE_DRD: + case USB_DR_MODE_PERIPHERAL: + case USB_DR_MODE_OTG: dwc3_gadget_prepare(dwc); /* FALLTHROUGH */ - case DWC3_MODE_HOST: + case USB_DR_MODE_HOST: default: dwc3_event_buffers_cleanup(dwc); break; @@ -666,11 +669,11 @@ static void dwc3_complete(struct device *dev) spin_lock_irqsave(&dwc->lock, flags); switch (dwc->mode) { - case DWC3_MODE_DEVICE: - case DWC3_MODE_DRD: + case USB_DR_MODE_PERIPHERAL: + case USB_DR_MODE_OTG: dwc3_gadget_complete(dwc); /* FALLTHROUGH */ - case DWC3_MODE_HOST: + case USB_DR_MODE_HOST: default: dwc3_event_buffers_setup(dwc); break; @@ -687,11 +690,11 @@ static int dwc3_suspend(struct device *dev) spin_lock_irqsave(&dwc->lock, flags); switch (dwc->mode) { - case DWC3_MODE_DEVICE: - case DWC3_MODE_DRD: + case USB_DR_MODE_PERIPHERAL: + case USB_DR_MODE_OTG: dwc3_gadget_suspend(dwc); /* FALLTHROUGH */ - case DWC3_MODE_HOST: + case USB_DR_MODE_HOST: default: /* do nothing */ break; @@ -720,11 +723,11 @@ static int dwc3_resume(struct device *dev) dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl); switch (dwc->mode) { - case DWC3_MODE_DEVICE: - case DWC3_MODE_DRD: + case USB_DR_MODE_PERIPHERAL: + case USB_DR_MODE_OTG: dwc3_gadget_resume(dwc); /* FALLTHROUGH */ - case DWC3_MODE_HOST: + case USB_DR_MODE_HOST: default: /* do nothing */ break; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index b69d322..a3376ea 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -566,11 +566,6 @@ struct dwc3_hwparams { /* HWPARAMS0 */ #define DWC3_MODE(n) ((n) & 0x7) -#define DWC3_MODE_DEVICE 0 -#define DWC3_MODE_HOST 1 -#define DWC3_MODE_DRD 2 -#define DWC3_MODE_HUB 3 - #define DWC3_MDWIDTH(n) (((n) & 0xff00) >> 8) /* HWPARAMS1 */ -- 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