From 457e84b6624b4d97e6ffae437887ea51a22d54a0 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 18 Jan 2012 18:04:09 +0200 Subject: usb: dwc3: gadget: dynamically re-size TxFifos We need to dynamically re-size TxFifos for the cases where default values will not do. While at that, we create a simple function which, for now, will just allocate one full packet fifo space for each of the enabled endpoints. This can be improved later in order to allow for better throughput by allocating more space for endpoints which could make good use of that like isochronous and bulk. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/usb/dwc3/core.c') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 7c9df63..d119a1f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -404,6 +405,7 @@ static void dwc3_core_exit(struct dwc3 *dwc) static int __devinit dwc3_probe(struct platform_device *pdev) { + struct device_node *node = pdev->dev.of_node; struct resource *res; struct dwc3 *dwc; @@ -469,6 +471,9 @@ static int __devinit dwc3_probe(struct platform_device *pdev) else dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; + if (of_get_property(node, "tx-fifo-resize", NULL)) + dwc->needs_fifo_resize = true; + pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); pm_runtime_forbid(&pdev->dev); -- cgit v1.1 From 802ca85067e11cdeddeb34ef53de03e5a7d509da Mon Sep 17 00:00:00 2001 From: Chanho Park Date: Wed, 15 Feb 2012 18:27:55 +0900 Subject: usb: dwc3: use devm_xxx functions This patch enables to use devm_xxx functions during probing driver. The devm_xxx series functions are able to release resource when the driver is detatched. We can remove several codes to release resources in the probe function. Signed-off-by: Chanho Park Signed-off-by: Kyungmin Park Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 84 +++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 48 deletions(-) (limited to 'drivers/usb/dwc3/core.c') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index d119a1f..c181f3e 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -408,6 +408,7 @@ static int __devinit dwc3_probe(struct platform_device *pdev) struct device_node *node = pdev->dev.of_node; struct resource *res; struct dwc3 *dwc; + struct device *dev = &pdev->dev; int ret = -ENOMEM; int irq; @@ -417,39 +418,39 @@ static int __devinit dwc3_probe(struct platform_device *pdev) u8 mode; - mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); + mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); if (!mem) { - dev_err(&pdev->dev, "not enough memory\n"); - goto err0; + dev_err(dev, "not enough memory\n"); + return -ENOMEM; } dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); dwc->mem = mem; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&pdev->dev, "missing resource\n"); - goto err1; + dev_err(dev, "missing resource\n"); + return -ENODEV; } dwc->res = res; - res = request_mem_region(res->start, resource_size(res), - dev_name(&pdev->dev)); + res = devm_request_mem_region(dev, res->start, resource_size(res), + dev_name(dev)); if (!res) { - dev_err(&pdev->dev, "can't request mem region\n"); - goto err1; + dev_err(dev, "can't request mem region\n"); + return -ENOMEM; } - regs = ioremap(res->start, resource_size(res)); + regs = devm_ioremap(dev, res->start, resource_size(res)); if (!regs) { - dev_err(&pdev->dev, "ioremap failed\n"); - goto err2; + dev_err(dev, "ioremap failed\n"); + return -ENOMEM; } irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&pdev->dev, "missing IRQ\n"); - goto err3; + dev_err(dev, "missing IRQ\n"); + return -ENODEV; } spin_lock_init(&dwc->lock); @@ -457,7 +458,7 @@ static int __devinit dwc3_probe(struct platform_device *pdev) dwc->regs = regs; dwc->regs_size = resource_size(res); - dwc->dev = &pdev->dev; + dwc->dev = dev; dwc->irq = irq; if (!strncmp("super", maximum_speed, 5)) @@ -474,14 +475,14 @@ static int __devinit dwc3_probe(struct platform_device *pdev) if (of_get_property(node, "tx-fifo-resize", NULL)) dwc->needs_fifo_resize = true; - pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(&pdev->dev); - pm_runtime_forbid(&pdev->dev); + pm_runtime_enable(dev); + pm_runtime_get_sync(dev); + pm_runtime_forbid(dev); ret = dwc3_core_init(dwc); if (ret) { - dev_err(&pdev->dev, "failed to initialize core\n"); - goto err3; + dev_err(dev, "failed to initialize core\n"); + return ret; } mode = DWC3_MODE(dwc->hwparams.hwparams0); @@ -491,49 +492,49 @@ static int __devinit dwc3_probe(struct platform_device *pdev) dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); ret = dwc3_gadget_init(dwc); if (ret) { - dev_err(&pdev->dev, "failed to initialize gadget\n"); - goto err4; + dev_err(dev, "failed to initialize gadget\n"); + goto err1; } break; case DWC3_MODE_HOST: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); ret = dwc3_host_init(dwc); if (ret) { - dev_err(&pdev->dev, "failed to initialize host\n"); - goto err4; + dev_err(dev, "failed to initialize host\n"); + goto err1; } break; case DWC3_MODE_DRD: dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); ret = dwc3_host_init(dwc); if (ret) { - dev_err(&pdev->dev, "failed to initialize host\n"); - goto err4; + dev_err(dev, "failed to initialize host\n"); + goto err1; } ret = dwc3_gadget_init(dwc); if (ret) { - dev_err(&pdev->dev, "failed to initialize gadget\n"); - goto err4; + dev_err(dev, "failed to initialize gadget\n"); + goto err1; } break; default: - dev_err(&pdev->dev, "Unsupported mode of operation %d\n", mode); - goto err4; + dev_err(dev, "Unsupported mode of operation %d\n", mode); + goto err1; } dwc->mode = mode; ret = dwc3_debugfs_init(dwc); if (ret) { - dev_err(&pdev->dev, "failed to initialize debugfs\n"); - goto err5; + dev_err(dev, "failed to initialize debugfs\n"); + goto err2; } - pm_runtime_allow(&pdev->dev); + pm_runtime_allow(dev); return 0; -err5: +err2: switch (mode) { case DWC3_MODE_DEVICE: dwc3_gadget_exit(dwc); @@ -550,19 +551,9 @@ err5: break; } -err4: - dwc3_core_exit(dwc); - -err3: - iounmap(regs); - -err2: - release_mem_region(res->start, resource_size(res)); - err1: - kfree(dwc->mem); + dwc3_core_exit(dwc); -err0: return ret; } @@ -595,9 +586,6 @@ static int __devexit dwc3_remove(struct platform_device *pdev) } dwc3_core_exit(dwc); - release_mem_region(res->start, resource_size(res)); - iounmap(dwc->regs); - kfree(dwc->mem); return 0; } -- cgit v1.1 From 2cd0e8512169b125fb0ff1f9ec3f8505eecb3012 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Wed, 15 Feb 2012 18:55:51 +0100 Subject: usb: dwc3: linux/module.h included twice drivers/usb/dwc3/core.c and drivers/usb/dwc3/dwc3-omap.c included 'linux/module.h' twice, remove the duplicates. Signed-off-by: Danny Kukawka Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/usb/dwc3/core.c') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c181f3e..a1576f0 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -52,7 +52,6 @@ #include #include -#include #include "core.h" #include "gadget.h" -- cgit v1.1 From 1d046793958f128dd43d42a4a0dac48bf6914273 Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Wed, 15 Feb 2012 18:56:56 -0800 Subject: usb: dwc3: clean up whitespace damage, typos, missing parens, etc. trivial patch, no functional changes Signed-off-by: Paul Zimmerman Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/usb/dwc3/core.c') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a1576f0..33d9868 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -167,11 +167,11 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, } /** - * dwc3_alloc_one_event_buffer - Allocated one event buffer structure + * dwc3_alloc_one_event_buffer - Allocates one event buffer structure * @dwc: Pointer to our controller context structure * @length: size of the event buffer * - * Returns a pointer to the allocated event buffer structure on succes + * Returns a pointer to the allocated event buffer structure on success * otherwise ERR_PTR(errno). */ static struct dwc3_event_buffer *__devinit @@ -215,10 +215,10 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) /** * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length - * @dwc: Pointer to out controller context structure + * @dwc: pointer to our controller context structure * @length: size of event buffer * - * Returns 0 on success otherwise negative errno. In error the case, dwc + * Returns 0 on success otherwise negative errno. In the error case, dwc * may contain some buffers allocated but not all which were requested. */ static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) @@ -251,7 +251,7 @@ static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) /** * dwc3_event_buffers_setup - setup our allocated event buffers - * @dwc: Pointer to out controller context structure + * @dwc: pointer to our controller context structure * * Returns 0 on success otherwise negative errno. */ @@ -363,9 +363,9 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) /* * WORKAROUND: DWC3 revisions <1.90a have a bug - * when The device fails to connect at SuperSpeed + * where the device can fail to connect at SuperSpeed * and falls back to high-speed mode which causes - * the device to enter in a Connect/Disconnect loop + * the device to enter a Connect/Disconnect loop */ if (dwc->revision < DWC3_REVISION_190A) reg |= DWC3_GCTL_U2RSTECN; -- cgit v1.1 From 075cd14d2a8d35afc39ad28fc7b968275881266b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 4 Feb 2012 16:37:14 +0300 Subject: usb: dwc3: make dwc3_get_device_id() return the id We always return zero instead of the id we found. Cc: stable@vger.kernel.org Signed-off-by: Dan Carpenter Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/dwc3/core.c') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 33d9868..3fd4e84 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -86,7 +86,7 @@ again: id = -ENOMEM; } - return 0; + return id; } EXPORT_SYMBOL_GPL(dwc3_get_device_id); -- cgit v1.1 From 3e87c42a29f14c7a346f912e084f6ab13ea8288b Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Fri, 24 Feb 2012 17:32:13 -0800 Subject: usb: dwc3: replace hard-coded constant in DWC3_GCTL_SCALEDOWN(3) Define DWC3_GCTL_SCALEDOWN_MASK and use it in place of DWC3_GCTL_SCALEDOWN(3). Signed-off-by: Paul Zimmerman Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/dwc3/core.c') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 3fd4e84..fd6917b 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -350,7 +350,7 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) dwc3_cache_hwparams(dwc); reg = dwc3_readl(dwc->regs, DWC3_GCTL); - reg &= ~DWC3_GCTL_SCALEDOWN(3); + reg &= ~DWC3_GCTL_SCALEDOWN_MASK; reg &= ~DWC3_GCTL_DISSCRAMBLE; switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { -- cgit v1.1 From b1116dcc63a91ee79a122abea025aab15ea2c8e7 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 28 Feb 2012 12:57:20 +0100 Subject: usb: dwc3: core: Convert to module_platform_driver Use the module_platform_driver macro. Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/core.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers/usb/dwc3/core.c') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index fd6917b..7bd815a 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -597,19 +597,9 @@ static struct platform_driver dwc3_driver = { }, }; +module_platform_driver(dwc3_driver); + MODULE_ALIAS("platform:dwc3"); MODULE_AUTHOR("Felipe Balbi "); MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); - -static int __devinit dwc3_init(void) -{ - return platform_driver_register(&dwc3_driver); -} -module_init(dwc3_init); - -static void __exit dwc3_exit(void) -{ - platform_driver_unregister(&dwc3_driver); -} -module_exit(dwc3_exit); -- cgit v1.1