Message ID | a15afd5722f822a21186da1b1c8d296cdce3c5a0.1526480763.git.michal.simek@xilinx.com |
---|---|
State | Superseded |
Delegated to: | Marek Vasut |
Headers | show |
Series | Convert Xilinx ZynqMP to DM_USB with generic DWC3 glue logic driver | expand |
On 05/16/2018 04:26 PM, Michal Simek wrote: > From: Mugunthan V N <mugunthanvnm@ti.com> > > The patch is preparing dwc3 core for enabling DM_USB with peripheral > driver with using driver model support. > The driver will be bound by the DWC3 wrapper driver based on the > dr_mode device tree entry. > > Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> > (Remove dwc3-omap changes) > Signed-off-by: Michal Simek <michal.simek@xilinx.com> > --- [...] > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h > index cbe9850a0bda..ad16c9b7c46c 100644 > --- a/drivers/usb/dwc3/core.h > +++ b/drivers/usb/dwc3/core.h > @@ -712,7 +712,11 @@ struct dwc3 { > /* device lock */ > spinlock_t lock; > > +#ifndef CONFIG_DM_USB Shouldnt this be ifdef __UBOOT__ ? > struct device *dev; > +#else > + struct udevice *dev; > +#endif > > struct platform_device *xhci; > struct resource xhci_resources[DWC3_XHCI_RESOURCES_NUM]; > @@ -987,6 +991,8 @@ struct dwc3_gadget_ep_cmd_params { > > /* prototypes */ > int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc); > +int dwc3_init(struct dwc3 *dwc); > +void dwc3_remove(struct dwc3 *dwc); > > #ifdef CONFIG_USB_DWC3_HOST > int dwc3_host_init(struct dwc3 *dwc); >
On 16.5.2018 16:40, Marek Vasut wrote: > On 05/16/2018 04:26 PM, Michal Simek wrote: >> From: Mugunthan V N <mugunthanvnm@ti.com> >> >> The patch is preparing dwc3 core for enabling DM_USB with peripheral >> driver with using driver model support. >> The driver will be bound by the DWC3 wrapper driver based on the >> dr_mode device tree entry. >> >> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> >> (Remove dwc3-omap changes) >> Signed-off-by: Michal Simek <michal.simek@xilinx.com> >> --- > [...] >> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h >> index cbe9850a0bda..ad16c9b7c46c 100644 >> --- a/drivers/usb/dwc3/core.h >> +++ b/drivers/usb/dwc3/core.h >> @@ -712,7 +712,11 @@ struct dwc3 { >> /* device lock */ >> spinlock_t lock; >> >> +#ifndef CONFIG_DM_USB > > Shouldnt this be ifdef __UBOOT__ ? > >> struct device *dev; >> +#else >> + struct udevice *dev; >> +#endif What about this? #if defined(__UBOOT__) && defined(CONFIG_DM_USB) struct udevice *dev; #else struct device *dev; #endif Thanks, Michal
On 05/17/2018 09:40 AM, Michal Simek wrote: > On 16.5.2018 16:40, Marek Vasut wrote: >> On 05/16/2018 04:26 PM, Michal Simek wrote: >>> From: Mugunthan V N <mugunthanvnm@ti.com> >>> >>> The patch is preparing dwc3 core for enabling DM_USB with peripheral >>> driver with using driver model support. >>> The driver will be bound by the DWC3 wrapper driver based on the >>> dr_mode device tree entry. >>> >>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> >>> (Remove dwc3-omap changes) >>> Signed-off-by: Michal Simek <michal.simek@xilinx.com> >>> --- >> [...] >>> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h >>> index cbe9850a0bda..ad16c9b7c46c 100644 >>> --- a/drivers/usb/dwc3/core.h >>> +++ b/drivers/usb/dwc3/core.h >>> @@ -712,7 +712,11 @@ struct dwc3 { >>> /* device lock */ >>> spinlock_t lock; >>> >>> +#ifndef CONFIG_DM_USB >> >> Shouldnt this be ifdef __UBOOT__ ? >> >>> struct device *dev; >>> +#else >>> + struct udevice *dev; >>> +#endif > > What about this? > > #if defined(__UBOOT__) && defined(CONFIG_DM_USB) > struct udevice *dev; > #else > struct device *dev; > #endif Yes. I am kinda surprised we don't have some udevice<->device mapping layer, but I guess that might have it's own problems.
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index dbdad22d1134..e533325dda07 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -602,6 +602,8 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc) #define DWC3_ALIGN_MASK (16 - 1) +#ifndef CONFIG_DM_USB + /** * dwc3_uboot_init - dwc3 core uboot initialization code * @dwc3_dev: struct dwc3_device containing initialization data @@ -788,3 +790,58 @@ MODULE_ALIAS("platform:dwc3"); MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); + +#else + +int dwc3_init(struct dwc3 *dwc) +{ + int ret; + + dwc3_cache_hwparams(dwc); + + ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); + if (ret) { + dev_err(dwc->dev, "failed to allocate event buffers\n"); + return -ENOMEM; + } + + ret = dwc3_core_init(dwc); + if (ret) { + dev_err(dev, "failed to initialize core\n"); + goto core_fail; + } + + ret = dwc3_event_buffers_setup(dwc); + if (ret) { + dev_err(dwc->dev, "failed to setup event buffers\n"); + goto event_fail; + } + + ret = dwc3_core_init_mode(dwc); + if (ret) + goto mode_fail; + + return 0; + +mode_fail: + dwc3_event_buffers_cleanup(dwc); + +event_fail: + dwc3_core_exit(dwc); + +core_fail: + dwc3_free_event_buffers(dwc); + + return ret; +} + +void dwc3_remove(struct dwc3 *dwc) +{ + dwc3_core_exit_mode(dwc); + dwc3_event_buffers_cleanup(dwc); + dwc3_free_event_buffers(dwc); + dwc3_core_exit(dwc); + kfree(dwc->mem); +} + +#endif diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index cbe9850a0bda..ad16c9b7c46c 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -712,7 +712,11 @@ struct dwc3 { /* device lock */ spinlock_t lock; +#ifndef CONFIG_DM_USB struct device *dev; +#else + struct udevice *dev; +#endif struct platform_device *xhci; struct resource xhci_resources[DWC3_XHCI_RESOURCES_NUM]; @@ -987,6 +991,8 @@ struct dwc3_gadget_ep_cmd_params { /* prototypes */ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc); +int dwc3_init(struct dwc3 *dwc); +void dwc3_remove(struct dwc3 *dwc); #ifdef CONFIG_USB_DWC3_HOST int dwc3_host_init(struct dwc3 *dwc);