* [PATCH v8 03/13] usb: musb: add musb_ida for multi instance support
[not found] ` <1346323825-24385-1-git-send-email-ravibabu-l0cyMroinI0@public.gmane.org>
@ 2012-08-30 10:50 ` Ravi Babu
2012-08-30 10:50 ` [PATCH v8 05/13] usb: musb: am335x: add support for dual instance Ravi Babu
` (4 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Ravi Babu @ 2012-08-30 10:50 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
tony-4v6yS6AI5VpBDgjK7y7TUQ, ajayguptaj-Re5JQEeQqe8AvxtiuMwx3w
Added musb_ida in musb_core.c to manage the multi core ids.
Signed-off-by: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
Signed-off-by: Santhapuri, Damodar <damodar.santhapuri-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
---
drivers/usb/musb/am35x.c | 42 ++++++++++++++++++++++++++++--------------
drivers/usb/musb/blackfin.c | 26 ++++++++++++++++++++------
drivers/usb/musb/da8xx.c | 34 ++++++++++++++++++++++++----------
drivers/usb/musb/davinci.c | 34 ++++++++++++++++++++++++----------
drivers/usb/musb/musb_core.c | 31 +++++++++++++++++++++++++++++++
drivers/usb/musb/musb_core.h | 2 ++
drivers/usb/musb/musb_dsps.c | 25 ++++++++++++++++++-------
drivers/usb/musb/omap2430.c | 26 ++++++++++++++++++++------
drivers/usb/musb/tusb6010.c | 26 ++++++++++++++++++++------
drivers/usb/musb/ux500.c | 33 +++++++++++++++++++++++----------
10 files changed, 210 insertions(+), 69 deletions(-)
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 29b1d60..457f25e 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -459,6 +459,7 @@ static int __devinit am35x_probe(struct platform_device *pdev)
struct clk *clk;
int ret = -ENOMEM;
+ int musbid;
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
@@ -466,38 +467,47 @@ static int __devinit am35x_probe(struct platform_device *pdev)
goto err0;
}
- musb = platform_device_alloc("musb-hdrc", -1);
+ /* get the musb id */
+ musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
+ if (musbid < 0) {
+ dev_err(&pdev->dev, "failed to allocate musb id\n");
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ musb = platform_device_alloc("musb-hdrc", musbid);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err1;
+ goto err2;
}
phy_clk = clk_get(&pdev->dev, "fck");
if (IS_ERR(phy_clk)) {
dev_err(&pdev->dev, "failed to get PHY clock\n");
ret = PTR_ERR(phy_clk);
- goto err2;
+ goto err3;
}
clk = clk_get(&pdev->dev, "ick");
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(clk);
- goto err3;
+ goto err4;
}
ret = clk_enable(phy_clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable PHY clock\n");
- goto err4;
+ goto err5;
}
ret = clk_enable(clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable clock\n");
- goto err5;
+ goto err6;
}
+ musb->id = musbid;
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &am35x_dmamask;
musb->dev.coherent_dma_mask = am35x_dmamask;
@@ -515,38 +525,41 @@ static int __devinit am35x_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err6;
+ goto err7;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err6;
+ goto err7;
}
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err6;
+ goto err7;
}
return 0;
-err6:
+err7:
clk_disable(clk);
-err5:
+err6:
clk_disable(phy_clk);
-err4:
+err5:
clk_put(clk);
-err3:
+err4:
clk_put(phy_clk);
-err2:
+err3:
platform_device_put(musb);
+err2:
+ musb_put_id(&pdev->dev, musbid);
+
err1:
kfree(glue);
@@ -558,6 +571,7 @@ static int __devexit am35x_remove(struct platform_device *pdev)
{
struct am35x_glue *glue = platform_get_drvdata(pdev);
+ musb_put_id(&pdev->dev, glue->musb->id);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
clk_disable(glue->clk);
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 2a80dec..e8cff9b 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -455,6 +455,7 @@ static int __devinit bfin_probe(struct platform_device *pdev)
struct bfin_glue *glue;
int ret = -ENOMEM;
+ int musbid;
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
@@ -462,12 +463,21 @@ static int __devinit bfin_probe(struct platform_device *pdev)
goto err0;
}
- musb = platform_device_alloc("musb-hdrc", -1);
+ /* get the musb id */
+ musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
+ if (musbid < 0) {
+ dev_err(&pdev->dev, "failed to allocate musb id\n");
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ musb = platform_device_alloc("musb-hdrc", musbid);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err1;
+ goto err2;
}
+ musb->id = musbid;
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &bfin_dmamask;
musb->dev.coherent_dma_mask = bfin_dmamask;
@@ -483,26 +493,29 @@ static int __devinit bfin_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err2;
+ goto err3;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err2;
+ goto err3;
}
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err2;
+ goto err3;
}
return 0;
-err2:
+err3:
platform_device_put(musb);
+err2:
+ musb_put_id(&pdev->dev, musbid);
+
err1:
kfree(glue);
@@ -514,6 +527,7 @@ static int __devexit bfin_remove(struct platform_device *pdev)
{
struct bfin_glue *glue = platform_get_drvdata(pdev);
+ musb_put_id(&pdev->dev, glue->musb->id);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
kfree(glue);
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 04858bf..ce11d20 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -480,6 +480,7 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
struct clk *clk;
int ret = -ENOMEM;
+ int musbid;
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
@@ -487,25 +488,34 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
goto err0;
}
- musb = platform_device_alloc("musb-hdrc", -1);
+ /* get the musb id */
+ musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
+ if (musbid < 0) {
+ dev_err(&pdev->dev, "failed to allocate musb id\n");
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ musb = platform_device_alloc("musb-hdrc", musbid);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err1;
+ goto err2;
}
clk = clk_get(&pdev->dev, "usb20");
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(clk);
- goto err2;
+ goto err3;
}
ret = clk_enable(clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable clock\n");
- goto err3;
+ goto err4;
}
+ musb->id = musbid;
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &da8xx_dmamask;
musb->dev.coherent_dma_mask = da8xx_dmamask;
@@ -522,32 +532,35 @@ static int __devinit da8xx_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err4;
+ goto err5;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err4;
+ goto err5;
}
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err4;
+ goto err5;
}
return 0;
-err4:
+err5:
clk_disable(clk);
-err3:
+err4:
clk_put(clk);
-err2:
+err3:
platform_device_put(musb);
+err2:
+ musb_put_id(&pdev->dev, musbid);
+
err1:
kfree(glue);
@@ -559,6 +572,7 @@ static int __devexit da8xx_remove(struct platform_device *pdev)
{
struct da8xx_glue *glue = platform_get_drvdata(pdev);
+ musb_put_id(&pdev->dev, glue->musb->id);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
clk_disable(glue->clk);
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 72d5b7b..606bfd0 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -512,6 +512,7 @@ static int __devinit davinci_probe(struct platform_device *pdev)
struct clk *clk;
int ret = -ENOMEM;
+ int musbid;
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
@@ -519,25 +520,34 @@ static int __devinit davinci_probe(struct platform_device *pdev)
goto err0;
}
- musb = platform_device_alloc("musb-hdrc", -1);
+ /* get the musb id */
+ musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
+ if (musbid < 0) {
+ dev_err(&pdev->dev, "failed to allocate musb id\n");
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ musb = platform_device_alloc("musb-hdrc", musbid);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err1;
+ goto err2;
}
clk = clk_get(&pdev->dev, "usb");
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(clk);
- goto err2;
+ goto err3;
}
ret = clk_enable(clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable clock\n");
- goto err3;
+ goto err4;
}
+ musb->id = musbid;
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &davinci_dmamask;
musb->dev.coherent_dma_mask = davinci_dmamask;
@@ -554,32 +564,35 @@ static int __devinit davinci_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err4;
+ goto err5;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err4;
+ goto err5;
}
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err4;
+ goto err5;
}
return 0;
-err4:
+err5:
clk_disable(clk);
-err3:
+err4:
clk_put(clk);
-err2:
+err3:
platform_device_put(musb);
+err2:
+ musb_put_id(&pdev->dev, musbid);
+
err1:
kfree(glue);
@@ -591,6 +604,7 @@ static int __devexit davinci_remove(struct platform_device *pdev)
{
struct davinci_glue *glue = platform_get_drvdata(pdev);
+ musb_put_id(&pdev->dev, glue->musb->id);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
clk_disable(glue->clk);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index dd24f96..7499fbb 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -99,6 +99,7 @@
#include <linux/prefetch.h>
#include <linux/platform_device.h>
#include <linux/io.h>
+#include <linux/idr.h>
#include "musb_core.h"
@@ -114,6 +115,7 @@
#define MUSB_DRIVER_NAME "musb-hdrc"
const char musb_driver_name[] = MUSB_DRIVER_NAME;
+static DEFINE_IDA(musb_ida);
MODULE_DESCRIPTION(DRIVER_INFO);
MODULE_AUTHOR(DRIVER_AUTHOR);
@@ -130,6 +132,35 @@ static inline struct musb *dev_to_musb(struct device *dev)
/*-------------------------------------------------------------------------*/
+int musb_get_id(struct device *dev, gfp_t gfp_mask)
+{
+ int ret;
+ int id;
+
+ ret = ida_pre_get(&musb_ida, gfp_mask);
+ if (!ret) {
+ dev_err(dev, "failed to reserve resource for id\n");
+ return -ENOMEM;
+ }
+
+ ret = ida_get_new(&musb_ida, &id);
+ if (ret < 0) {
+ dev_err(dev, "failed to allocate a new id\n");
+ return ret;
+ }
+
+ return id;
+}
+EXPORT_SYMBOL_GPL(musb_get_id);
+
+void musb_put_id(struct device *dev, int id)
+{
+
+ dev_dbg(dev, "removing id %d\n", id);
+ ida_remove(&musb_ida, id);
+}
+EXPORT_SYMBOL_GPL(musb_put_id);
+
#ifndef CONFIG_BLACKFIN
static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
{
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index a1a32c6..a69ffd6 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -517,6 +517,8 @@ extern const char musb_driver_name[];
extern void musb_start(struct musb *musb);
extern void musb_stop(struct musb *musb);
+extern int musb_get_id(struct device *dev, gfp_t gfp_mask);
+extern void musb_put_id(struct device *dev, int id);
extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src);
extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index e62fa05..36130ba 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -485,7 +485,7 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
struct resource *res;
struct resource resources[2];
char res_name[10];
- int ret;
+ int ret, musbid;
/* get memory resource for usb control register */
res = platform_get_resource(pdev, IORESOURCE_MEM, 2 * id + 2);
@@ -525,14 +525,22 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
resources[1] = *res;
resources[1].name = "mc";
+ /* get the musb id */
+ musbid = musb_get_id(dev, GFP_KERNEL);
+ if (musbid < 0) {
+ dev_err(dev, "failed to allocate musb id\n");
+ ret = -ENOMEM;
+ goto err0;
+ }
/* allocate the child platform device */
- musb = platform_device_alloc("musb-hdrc", -1);
+ musb = platform_device_alloc("musb-hdrc", musbid);
if (!musb) {
dev_err(dev, "failed to allocate musb device\n");
ret = -ENOMEM;
- goto err0;
+ goto err1;
}
+ musb->id = musbid;
musb->dev.parent = dev;
musb->dev.dma_mask = &musb_dmamask;
musb->dev.coherent_dma_mask = musb_dmamask;
@@ -544,31 +552,34 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
ret = platform_device_add_resources(musb, resources, 2);
if (ret) {
dev_err(dev, "failed to add resources\n");
- goto err1;
+ goto err2;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(dev, "failed to add platform_data\n");
- goto err1;
+ goto err2;
}
ret = platform_device_add(musb);
if (ret) {
dev_err(dev, "failed to register musb device\n");
- goto err1;
+ goto err2;
}
return 0;
-err1:
+err2:
platform_device_put(musb);
+err1:
+ musb_put_id(dev, musbid);
err0:
return ret;
}
static void __devexit dsps_delete_musb_pdev(struct dsps_glue *glue)
{
+ musb_put_id(glue->dev, glue->musb->id);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
}
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 02c39a7..5fb35fe 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -442,6 +442,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
struct platform_device *musb;
struct omap2430_glue *glue;
int ret = -ENOMEM;
+ int musbid;
glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
if (!glue) {
@@ -449,12 +450,21 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
goto err0;
}
- musb = platform_device_alloc("musb-hdrc", -1);
+ /* get the musb id */
+ musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
+ if (musbid < 0) {
+ dev_err(&pdev->dev, "failed to allocate musb id\n");
+ ret = -ENOMEM;
+ goto err0;
+ }
+
+ musb = platform_device_alloc("musb-hdrc", musbid);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err0;
+ goto err1;
}
+ musb->id = musbid;
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &omap2430_dmamask;
musb->dev.coherent_dma_mask = omap2430_dmamask;
@@ -479,13 +489,13 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err1;
+ goto err2;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err1;
+ goto err2;
}
pm_runtime_enable(&pdev->dev);
@@ -493,14 +503,17 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err1;
+ goto err2;
}
return 0;
-err1:
+err2:
platform_device_put(musb);
+err1:
+ musb_put_id(&pdev->dev, musbid);
+
err0:
return ret;
}
@@ -510,6 +523,7 @@ static int __devexit omap2430_remove(struct platform_device *pdev)
struct omap2430_glue *glue = platform_get_drvdata(pdev);
cancel_work_sync(&glue->omap_musb_mailbox_work);
+ musb_put_id(&pdev->dev, glue->musb->id);
platform_device_unregister(glue->musb);
return 0;
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index ab51f7c..dc4d75e 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1160,6 +1160,7 @@ static int __devinit tusb_probe(struct platform_device *pdev)
struct tusb6010_glue *glue;
int ret = -ENOMEM;
+ int musbid;
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
@@ -1167,12 +1168,21 @@ static int __devinit tusb_probe(struct platform_device *pdev)
goto err0;
}
- musb = platform_device_alloc("musb-hdrc", -1);
+ /* get the musb id */
+ musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
+ if (musbid < 0) {
+ dev_err(&pdev->dev, "failed to allocate musb id\n");
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ musb = platform_device_alloc("musb-hdrc", musbid);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err1;
+ goto err2;
}
+ musb->id = musbid;
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &tusb_dmamask;
musb->dev.coherent_dma_mask = tusb_dmamask;
@@ -1188,26 +1198,29 @@ static int __devinit tusb_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err2;
+ goto err3;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err2;
+ goto err3;
}
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err2;
+ goto err3;
}
return 0;
-err2:
+err3:
platform_device_put(musb);
+err2:
+ musb_put_id(&pdev->dev, musbid);
+
err1:
kfree(glue);
@@ -1219,6 +1232,7 @@ static int __devexit tusb_remove(struct platform_device *pdev)
{
struct tusb6010_glue *glue = platform_get_drvdata(pdev);
+ musb_put_id(&pdev->dev, glue->musb->id);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
kfree(glue);
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index a8c0fad..d62a91f 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -74,25 +74,34 @@ static int __devinit ux500_probe(struct platform_device *pdev)
goto err0;
}
- musb = platform_device_alloc("musb-hdrc", -1);
+ /* get the musb id */
+ musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
+ if (musbid < 0) {
+ dev_err(&pdev->dev, "failed to allocate musb id\n");
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ musb = platform_device_alloc("musb-hdrc", musbid);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err1;
+ goto err2;
}
clk = clk_get(&pdev->dev, "usb");
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(clk);
- goto err2;
+ goto err3;
}
ret = clk_enable(clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable clock\n");
- goto err3;
+ goto err4;
}
+ musb->id = musbid;
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = pdev->dev.dma_mask;
musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
@@ -109,32 +118,35 @@ static int __devinit ux500_probe(struct platform_device *pdev)
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err4;
+ goto err5;
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err4;
+ goto err5;
}
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err4;
+ goto err5;
}
return 0;
-err4:
+err5:
clk_disable(clk);
-err3:
+err4:
clk_put(clk);
-err2:
+err3:
platform_device_put(musb);
+err2:
+ musb_put_id(&pdev->dev, musbid);
+
err1:
kfree(glue);
@@ -146,6 +158,7 @@ static int __devexit ux500_remove(struct platform_device *pdev)
{
struct ux500_glue *glue = platform_get_drvdata(pdev);
+ musb_put_id(&pdev->dev, glue->musb->id);
platform_device_del(glue->musb);
platform_device_put(glue->musb);
clk_disable(glue->clk);
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v8 05/13] usb: musb: am335x: add support for dual instance
[not found] ` <1346323825-24385-1-git-send-email-ravibabu-l0cyMroinI0@public.gmane.org>
2012-08-30 10:50 ` [PATCH v8 03/13] usb: musb: add musb_ida for multi instance support Ravi Babu
@ 2012-08-30 10:50 ` Ravi Babu
2012-08-30 10:50 ` [PATCH v8 06/13] usb: otg: nop: add support for multiple tranceiver Ravi Babu
` (3 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Ravi Babu @ 2012-08-30 10:50 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
tony-4v6yS6AI5VpBDgjK7y7TUQ, ajayguptaj-Re5JQEeQqe8AvxtiuMwx3w
AM335x and TI81xx platform has dual musb controller so updating the
musb_dspc.c to support the same.
Changes:
- Moved otg_workaround timer to glue structure
- Moved static local variable last_timer to glue structure
- PHY on/off related cleanups
Signed-off-by: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
Signed-off-by: Santhapuri, Damodar <damodar.santhapuri-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
---
drivers/usb/musb/musb_dsps.c | 112 +++++++++++++++++++++++++-----------------
1 files changed, 66 insertions(+), 46 deletions(-)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 36130ba..f883c25 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -106,6 +106,8 @@ struct dsps_musb_wrapper {
/* miscellaneous stuff */
u32 musb_core_offset;
u8 poll_seconds;
+ /* number of musb instances */
+ u8 instances;
};
/**
@@ -113,16 +115,18 @@ struct dsps_musb_wrapper {
*/
struct dsps_glue {
struct device *dev;
- struct platform_device *musb; /* child musb pdev */
+ struct platform_device *musb[2]; /* child musb pdev */
const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
- struct timer_list timer; /* otg_workaround timer */
- u32 __iomem *usb_ctrl;
+ struct timer_list timer[2]; /* otg_workaround timer */
+ unsigned long last_timer[2]; /* last timer data for each instance */
+ u32 __iomem *usb_ctrl[2];
u8 usbss_rev;
};
/**
* musb_dsps_phy_control - phy on/off
* @glue: struct dsps_glue *
+ * @id: musb instance
* @on: flag for phy to be switched on or off
*
* This is to enable the PHY using usb_ctrl register in system control
@@ -131,11 +135,11 @@ struct dsps_glue {
* XXX: This function will be removed once we have a seperate driver for
* control module
*/
-static void musb_dsps_phy_control(struct dsps_glue *glue, u8 on)
+static void musb_dsps_phy_control(struct dsps_glue *glue, u8 id, u8 on)
{
u32 usbphycfg;
- usbphycfg = __raw_readl(glue->usb_ctrl);
+ usbphycfg = __raw_readl(glue->usb_ctrl[id]);
if (on) {
if (glue->usbss_rev == MUSB_USBSS_REV_816X) {
@@ -158,7 +162,7 @@ static void musb_dsps_phy_control(struct dsps_glue *glue, u8 on)
glue->usbss_rev == MUSB_USBSS_REV_33XX)
usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;
}
- __raw_writel(usbphycfg, glue->usb_ctrl);
+ __raw_writel(usbphycfg, glue->usb_ctrl[id]);
}
/**
* dsps_musb_enable - enable interrupts
@@ -207,8 +211,8 @@ static void otg_timer(unsigned long _musb)
struct musb *musb = (void *)_musb;
void __iomem *mregs = musb->mregs;
struct device *dev = musb->controller;
- struct platform_device *pdev = to_platform_device(dev->parent);
- struct dsps_glue *glue = platform_get_drvdata(pdev);
+ struct platform_device *pdev = to_platform_device(dev);
+ struct dsps_glue *glue = dev_get_drvdata(dev->parent);
const struct dsps_musb_wrapper *wrp = glue->wrp;
u8 devctl;
unsigned long flags;
@@ -244,7 +248,7 @@ static void otg_timer(unsigned long _musb)
case OTG_STATE_B_IDLE:
devctl = dsps_readb(mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE)
- mod_timer(&glue->timer,
+ mod_timer(&glue->timer[pdev->id],
jiffies + wrp->poll_seconds * HZ);
else
musb->xceiv->state = OTG_STATE_A_IDLE;
@@ -258,9 +262,8 @@ static void otg_timer(unsigned long _musb)
static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
{
struct device *dev = musb->controller;
- struct platform_device *pdev = to_platform_device(dev->parent);
- struct dsps_glue *glue = platform_get_drvdata(pdev);
- static unsigned long last_timer;
+ struct platform_device *pdev = to_platform_device(dev);
+ struct dsps_glue *glue = dev_get_drvdata(dev->parent);
if (timeout == 0)
timeout = jiffies + msecs_to_jiffies(3);
@@ -270,22 +273,23 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n",
otg_state_string(musb->xceiv->state));
- del_timer(&glue->timer);
- last_timer = jiffies;
+ del_timer(&glue->timer[pdev->id]);
+ glue->last_timer[pdev->id] = jiffies;
return;
}
- if (time_after(last_timer, timeout) && timer_pending(&glue->timer)) {
+ if (time_after(glue->last_timer[pdev->id], timeout) &&
+ timer_pending(&glue->timer[pdev->id])) {
dev_dbg(musb->controller,
"Longer idle timer already pending, ignoring...\n");
return;
}
- last_timer = timeout;
+ glue->last_timer[pdev->id] = timeout;
dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
otg_state_string(musb->xceiv->state),
jiffies_to_msecs(timeout - jiffies));
- mod_timer(&glue->timer, timeout);
+ mod_timer(&glue->timer[pdev->id], timeout);
}
static irqreturn_t dsps_interrupt(int irq, void *hci)
@@ -293,8 +297,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
struct musb *musb = hci;
void __iomem *reg_base = musb->ctrl_base;
struct device *dev = musb->controller;
- struct platform_device *pdev = to_platform_device(dev->parent);
- struct dsps_glue *glue = platform_get_drvdata(pdev);
+ struct platform_device *pdev = to_platform_device(dev);
+ struct dsps_glue *glue = dev_get_drvdata(dev->parent);
const struct dsps_musb_wrapper *wrp = glue->wrp;
unsigned long flags;
irqreturn_t ret = IRQ_NONE;
@@ -353,7 +357,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
*/
musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
- mod_timer(&glue->timer,
+ mod_timer(&glue->timer[pdev->id],
jiffies + wrp->poll_seconds * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) {
@@ -361,7 +365,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
- del_timer(&glue->timer);
+ del_timer(&glue->timer[pdev->id]);
} else {
musb->is_active = 0;
MUSB_DEV_MODE(musb);
@@ -388,7 +392,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
/* Poll for ID change */
if (musb->xceiv->state == OTG_STATE_B_IDLE)
- mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
+ mod_timer(&glue->timer[pdev->id],
+ jiffies + wrp->poll_seconds * HZ);
spin_unlock_irqrestore(&musb->lock, flags);
@@ -398,8 +403,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
static int dsps_musb_init(struct musb *musb)
{
struct device *dev = musb->controller;
- struct platform_device *pdev = to_platform_device(dev->parent);
- struct dsps_glue *glue = platform_get_drvdata(pdev);
+ struct platform_device *pdev = to_platform_device(dev);
+ struct dsps_glue *glue = dev_get_drvdata(dev->parent);
const struct dsps_musb_wrapper *wrp = glue->wrp;
void __iomem *reg_base = musb->ctrl_base;
u32 rev, val;
@@ -421,13 +426,13 @@ static int dsps_musb_init(struct musb *musb)
goto err0;
}
- setup_timer(&glue->timer, otg_timer, (unsigned long) musb);
+ setup_timer(&glue->timer[pdev->id], otg_timer, (unsigned long) musb);
/* Reset the musb */
dsps_writel(reg_base, wrp->control, (1 << wrp->reset));
/* Start the on-chip PHY and its PLL. */
- musb_dsps_phy_control(glue, 1);
+ musb_dsps_phy_control(glue, pdev->id, 1);
musb->isr = dsps_interrupt;
@@ -449,13 +454,13 @@ err0:
static int dsps_musb_exit(struct musb *musb)
{
struct device *dev = musb->controller;
- struct platform_device *pdev = to_platform_device(dev->parent);
- struct dsps_glue *glue = platform_get_drvdata(pdev);
+ struct platform_device *pdev = to_platform_device(dev);
+ struct dsps_glue *glue = dev_get_drvdata(dev->parent);
- del_timer_sync(&glue->timer);
+ del_timer_sync(&glue->timer[pdev->id]);
/* Shutdown the on-chip PHY and its PLL. */
- musb_dsps_phy_control(glue, 0);
+ musb_dsps_phy_control(glue, pdev->id, 0);
/* NOP driver needs change if supporting dual instance */
usb_put_phy(musb->xceiv);
@@ -495,8 +500,8 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
goto err0;
}
- glue->usb_ctrl = devm_request_and_ioremap(&pdev->dev, res);
- if (glue->usb_ctrl == NULL) {
+ glue->usb_ctrl[id] = devm_request_and_ioremap(&pdev->dev, res);
+ if (glue->usb_ctrl[id] == NULL) {
dev_err(dev, "Failed to obtain usb_ctrl%d memory\n", id);
ret = -ENODEV;
goto err0;
@@ -545,7 +550,7 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
musb->dev.dma_mask = &musb_dmamask;
musb->dev.coherent_dma_mask = musb_dmamask;
- glue->musb = musb;
+ glue->musb[id] = musb;
pdata->platform_ops = &dsps_ops;
@@ -577,11 +582,11 @@ err0:
return ret;
}
-static void __devexit dsps_delete_musb_pdev(struct dsps_glue *glue)
+static void __devexit dsps_delete_musb_pdev(struct dsps_glue *glue, u8 id)
{
- musb_put_id(glue->dev, glue->musb->id);
- platform_device_del(glue->musb);
- platform_device_put(glue->musb);
+ musb_put_id(glue->dev, glue->musb[id]->id);
+ platform_device_del(glue->musb[id]);
+ platform_device_put(glue->musb[id]);
}
static int __devinit dsps_probe(struct platform_device *pdev)
@@ -592,7 +597,7 @@ static int __devinit dsps_probe(struct platform_device *pdev)
struct dsps_glue *glue;
struct resource *iomem;
u32 __iomem *usbss;
- int ret;
+ int ret, i;
/* allocate glue */
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
@@ -636,11 +641,16 @@ static int __devinit dsps_probe(struct platform_device *pdev)
goto err2;
}
- /* create the child platform device for first instances of musb */
- ret = dsps_create_musb_pdev(glue, 0);
- if (ret != 0) {
- dev_err(&pdev->dev, "failed to create child pdev\n");
- goto err3;
+ /* create the child platform device for all instances of musb */
+ for (i = 0; i < wrp->instances ; i++) {
+ ret = dsps_create_musb_pdev(glue, i);
+ if (ret != 0) {
+ dev_err(&pdev->dev, "failed to create child pdev\n");
+ /* release resources of previously created instances */
+ for (i--; i >= 0 ; i--)
+ dsps_delete_musb_pdev(glue, i);
+ goto err3;
+ }
}
/* read the usbss revision register */
@@ -661,9 +671,12 @@ err0:
static int __devexit dsps_remove(struct platform_device *pdev)
{
struct dsps_glue *glue = platform_get_drvdata(pdev);
+ const struct dsps_musb_wrapper *wrp = glue->wrp;
+ int i;
/* delete the child platform device */
- dsps_delete_musb_pdev(glue);
+ for (i = 0; i < wrp->instances ; i++)
+ dsps_delete_musb_pdev(glue, i);
/* disable usbss clocks */
pm_runtime_put(&pdev->dev);
@@ -678,9 +691,12 @@ static int dsps_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev->parent);
struct dsps_glue *glue = platform_get_drvdata(pdev);
+ const struct dsps_musb_wrapper *wrp = glue->wrp;
+ int i;
/* Shutdown the on-chip PHY and its PLL. */
- musb_dsps_phy_control(glue, 0);
+ for (i = 0 ; i < wrp->instances ; i++)
+ musb_dsps_phy_control(glue, i, 0);
return 0;
}
@@ -689,9 +705,12 @@ static int dsps_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev->parent);
struct dsps_glue *glue = platform_get_drvdata(pdev);
+ const struct dsps_musb_wrapper *wrp = glue->wrp;
+ int i;
/* Start the on-chip PHY and its PLL. */
- musb_dsps_phy_control(glue, 1);
+ for (i = 0 ; i < wrp->instances ; i++)
+ musb_dsps_phy_control(glue, i, 1);
return 0;
}
@@ -727,6 +746,7 @@ static const struct dsps_musb_wrapper ti81xx_driver_data __devinitconst = {
.rxep_bitmap = (0xfffe << 16),
.musb_core_offset = 0x400,
.poll_seconds = 2,
+ .instances = 2,
};
static const struct platform_device_id musb_dsps_id_table[] __devinitconst = {
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v8 06/13] usb: otg: nop: add support for multiple tranceiver
[not found] ` <1346323825-24385-1-git-send-email-ravibabu-l0cyMroinI0@public.gmane.org>
2012-08-30 10:50 ` [PATCH v8 03/13] usb: musb: add musb_ida for multi instance support Ravi Babu
2012-08-30 10:50 ` [PATCH v8 05/13] usb: musb: am335x: add support for dual instance Ravi Babu
@ 2012-08-30 10:50 ` Ravi Babu
2012-08-30 10:50 ` [PATCH v8 09/13] arm/dts: am33xx: add dt data for usb nop phy Ravi Babu
` (2 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Ravi Babu @ 2012-08-30 10:50 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
tony-4v6yS6AI5VpBDgjK7y7TUQ, ajayguptaj-Re5JQEeQqe8AvxtiuMwx3w
From: Santhapuri, Damodar <damodar.santhapuri-l0cyMroinI0@public.gmane.org>
Currently we have one single nop transceiver support as same is
defined as a global variable in drivers/usb/otg/nop-usb-xceiv.c.
This need to be changed to support multiple otg controller each
using nop transceiver on a platform such as am335x.
Signed-off-by: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
Signed-off-by: Santhapuri, Damodar <damodar.santhapuri-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
---
drivers/usb/musb/am35x.c | 2 +-
drivers/usb/musb/blackfin.c | 2 +-
drivers/usb/musb/da8xx.c | 2 +-
drivers/usb/musb/davinci.c | 4 +-
drivers/usb/musb/musb_dsps.c | 8 +++---
drivers/usb/musb/tusb6010.c | 4 +-
drivers/usb/otg/nop-usb-xceiv.c | 54 ++++++++++++++++++++++++++++++++-----
include/linux/usb/nop-usb-xceiv.h | 4 +-
8 files changed, 60 insertions(+), 20 deletions(-)
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 457f25e..e3099fc 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -399,7 +399,7 @@ static int am35x_musb_exit(struct musb *musb)
data->set_phy_power(0);
usb_put_phy(musb->xceiv);
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
return 0;
}
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index e8cff9b..32b4fe4 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -427,7 +427,7 @@ static int bfin_musb_exit(struct musb *musb)
gpio_free(musb->config->gpio_vrsel);
usb_put_phy(musb->xceiv);
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
return 0;
}
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index ce11d20..f86a1c7 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -451,7 +451,7 @@ static int da8xx_musb_exit(struct musb *musb)
phy_off();
usb_put_phy(musb->xceiv);
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
return 0;
}
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 606bfd0..e12d20a 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -437,7 +437,7 @@ static int davinci_musb_init(struct musb *musb)
fail:
usb_put_phy(musb->xceiv);
unregister:
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
return -ENODEV;
}
@@ -485,7 +485,7 @@ static int davinci_musb_exit(struct musb *musb)
phy_off();
usb_put_phy(musb->xceiv);
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
return 0;
}
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index f883c25..25e395b 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -413,7 +413,7 @@ static int dsps_musb_init(struct musb *musb)
/* mentor core register starts at offset of 0x400 from musb base */
musb->mregs += wrp->musb_core_offset;
- /* NOP driver needs change if supporting dual instance */
+ /* Register NOP driver */
usb_nop_xceiv_register();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (IS_ERR_OR_NULL(musb->xceiv))
@@ -447,7 +447,7 @@ static int dsps_musb_init(struct musb *musb)
return 0;
err0:
usb_put_phy(musb->xceiv);
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
return status;
}
@@ -462,9 +462,9 @@ static int dsps_musb_exit(struct musb *musb)
/* Shutdown the on-chip PHY and its PLL. */
musb_dsps_phy_control(glue, pdev->id, 0);
- /* NOP driver needs change if supporting dual instance */
+ /* Unregister NOP driver */
usb_put_phy(musb->xceiv);
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
return 0;
}
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index dc4d75e..71c4778 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1117,7 +1117,7 @@ done:
iounmap(sync);
usb_put_phy(musb->xceiv);
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
}
return ret;
}
@@ -1133,7 +1133,7 @@ static int tusb_musb_exit(struct musb *musb)
iounmap(musb->sync_va);
usb_put_phy(musb->xceiv);
- usb_nop_xceiv_unregister();
+ usb_nop_xceiv_unregister(musb->xceiv);
return 0;
}
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index e52e35e..7e0dba3 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -32,30 +32,69 @@
#include <linux/usb/otg.h>
#include <linux/usb/nop-usb-xceiv.h>
#include <linux/slab.h>
+#include <linux/idr.h>
struct nop_usb_xceiv {
struct usb_phy phy;
struct device *dev;
+ struct platform_device *pd;
};
-static struct platform_device *pd;
+static DEFINE_IDA(nop_ida);
-void usb_nop_xceiv_register(void)
+static int nop_get_id(gfp_t gfp_mask)
{
- if (pd)
+ int ret, id;
+
+ ret = ida_pre_get(&nop_ida, gfp_mask);
+ if (!ret) {
+ pr_err("failed to reserve resource for id\n");
+ return -ENOMEM;
+ }
+
+ ret = ida_get_new(&nop_ida, &id);
+ if (ret < 0) {
+ pr_err("failed to allocate a new id\n");
+ return ret;
+ }
+
+ return id;
+}
+
+static void nop_put_id(int id)
+{
+
+ pr_debug("removing id %d\n", id);
+ ida_remove(&nop_ida, id);
+}
+
+void usb_nop_xceiv_register()
+{
+ struct platform_device *pd;
+ int id;
+
+ id = nop_get_id(GFP_KERNEL);
+ if (id < 0) {
+ pr_err("failed to allocate a new id\n");
return;
- pd = platform_device_register_simple("nop_usb_xceiv", -1, NULL, 0);
+ }
+
+ pd = platform_device_register_simple("nop_usb_xceiv", id, NULL, 0);
if (!pd) {
- printk(KERN_ERR "Unable to register usb nop transceiver\n");
+ pr_err("Unable to register usb nop transceiver\n");
return;
}
}
EXPORT_SYMBOL(usb_nop_xceiv_register);
-void usb_nop_xceiv_unregister(void)
+void usb_nop_xceiv_unregister(struct usb_phy *phy)
{
+ struct nop_usb_xceiv *nop = container_of(phy,
+ struct nop_usb_xceiv, phy);
+ struct platform_device *pd = nop->pd;
+
platform_device_unregister(pd);
- pd = NULL;
+ nop_put_id(pd->id);
}
EXPORT_SYMBOL(usb_nop_xceiv_unregister);
@@ -113,6 +152,7 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
if (pdata)
type = pdata->type;
+ nop->pd = pdev;
nop->dev = &pdev->dev;
nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv";
diff --git a/include/linux/usb/nop-usb-xceiv.h b/include/linux/usb/nop-usb-xceiv.h
index 28884c7..c12fc10 100644
--- a/include/linux/usb/nop-usb-xceiv.h
+++ b/include/linux/usb/nop-usb-xceiv.h
@@ -10,13 +10,13 @@ struct nop_usb_xceiv_platform_data {
#if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE))
/* sometimes transceivers are accessed only through e.g. ULPI */
extern void usb_nop_xceiv_register(void);
-extern void usb_nop_xceiv_unregister(void);
+extern void usb_nop_xceiv_unregister(struct usb_phy *);
#else
static inline void usb_nop_xceiv_register(void)
{
}
-static inline void usb_nop_xceiv_unregister(void)
+static inline void usb_nop_xceiv_unregister(struct usb_phy *phy)
{
}
#endif
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v8 09/13] arm/dts: am33xx: add dt data for usb nop phy
[not found] ` <1346323825-24385-1-git-send-email-ravibabu-l0cyMroinI0@public.gmane.org>
` (2 preceding siblings ...)
2012-08-30 10:50 ` [PATCH v8 06/13] usb: otg: nop: add support for multiple tranceiver Ravi Babu
@ 2012-08-30 10:50 ` Ravi Babu
2012-08-30 10:50 ` [PATCH v8 10/13] usb: musb: dsps: remove explicit NOP device creation Ravi Babu
2012-08-30 10:50 ` [PATCH v8 11/13] usb: musb: dsps: get the PHY using phandle api Ravi Babu
5 siblings, 0 replies; 19+ messages in thread
From: Ravi Babu @ 2012-08-30 10:50 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
tony-4v6yS6AI5VpBDgjK7y7TUQ, ajayguptaj-Re5JQEeQqe8AvxtiuMwx3w
From: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
AM33xx has two musb controller and they have one NOP PHY each.
Added the device tree data for NOP PHY.
Signed-off-by: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
Signed-off-by: Santhapuri, Damodar <damodar.santhapuri-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
---
arch/arm/boot/dts/am33xx.dtsi | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 778b95e..789c384 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -155,6 +155,14 @@
ti,hwmods = "i2c3";
};
+ usb0_phy: phy0 {
+ compatible = "nop-xceiv-usb";
+ };
+
+ usb1_phy: phy1 {
+ compatible = "nop-xceiv-usb";
+ };
+
usb_otg_hs: usb_otg_hs {
compatible = "ti,musb-am33xx";
ti,hwmods = "usb_otg_hs";
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v8 10/13] usb: musb: dsps: remove explicit NOP device creation
[not found] ` <1346323825-24385-1-git-send-email-ravibabu-l0cyMroinI0@public.gmane.org>
` (3 preceding siblings ...)
2012-08-30 10:50 ` [PATCH v8 09/13] arm/dts: am33xx: add dt data for usb nop phy Ravi Babu
@ 2012-08-30 10:50 ` Ravi Babu
2012-08-30 10:50 ` [PATCH v8 11/13] usb: musb: dsps: get the PHY using phandle api Ravi Babu
5 siblings, 0 replies; 19+ messages in thread
From: Ravi Babu @ 2012-08-30 10:50 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
tony-4v6yS6AI5VpBDgjK7y7TUQ, ajayguptaj-Re5JQEeQqe8AvxtiuMwx3w
From: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
As NOP device node is now added in am33xx tree so remove the call
which creates the NOP platform_device.
Signed-off-by: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
Signed-off-by: Santhapuri, Damodar <damodar.santhapuri-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
---
drivers/usb/musb/musb_dsps.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 2c104bf..2775496 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -418,8 +418,7 @@ static int dsps_musb_init(struct musb *musb)
/* mentor core register starts at offset of 0x400 from musb base */
musb->mregs += wrp->musb_core_offset;
- /* Register NOP driver */
- usb_nop_xceiv_register();
+ /* Get the NOP PHY */
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (IS_ERR_OR_NULL(musb->xceiv))
return -ENODEV;
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v8 11/13] usb: musb: dsps: get the PHY using phandle api
[not found] ` <1346323825-24385-1-git-send-email-ravibabu-l0cyMroinI0@public.gmane.org>
` (4 preceding siblings ...)
2012-08-30 10:50 ` [PATCH v8 10/13] usb: musb: dsps: remove explicit NOP device creation Ravi Babu
@ 2012-08-30 10:50 ` Ravi Babu
5 siblings, 0 replies; 19+ messages in thread
From: Ravi Babu @ 2012-08-30 10:50 UTC (permalink / raw)
To: linux-usb-u79uwXL29TY76Z2rM5mHXA
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
tony-4v6yS6AI5VpBDgjK7y7TUQ, ajayguptaj-Re5JQEeQqe8AvxtiuMwx3w
From: Santhapuri, Damodar <damodar.santhapuri-l0cyMroinI0@public.gmane.org>
AM33xx has two PHY of same type used by each musb controller so
use phandle of phy nodes to get the phy pointer.
Signed-off-by: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
Signed-off-by: Santhapuri, Damodar <damodar.santhapuri-l0cyMroinI0@public.gmane.org>
Signed-off-by: Ravi Babu <ravibabu-l0cyMroinI0@public.gmane.org>
---
.../devicetree/bindings/usb/am33xx-usb.txt | 2 ++
drivers/usb/musb/musb_dsps.c | 5 ++++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/am33xx-usb.txt b/Documentation/devicetree/bindings/usb/am33xx-usb.txt
index ca8fa56..b0caac3 100644
--- a/Documentation/devicetree/bindings/usb/am33xx-usb.txt
+++ b/Documentation/devicetree/bindings/usb/am33xx-usb.txt
@@ -12,3 +12,5 @@ AM33XX MUSB GLUE
represents PERIPHERAL.
- power : Should be "250". This signifies the controller can supply upto
500mA when operating in host mode.
+ - usb0-phy : phandle for usb0 NOP PHY
+ - usb1-phy : phandle for usb1 NOP PHY
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 2775496..46a2344 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -409,9 +409,11 @@ static int dsps_musb_init(struct musb *musb)
{
struct device *dev = musb->controller;
struct platform_device *pdev = to_platform_device(dev);
+ struct platform_device *parent_pdev = to_platform_device(dev->parent);
struct dsps_glue *glue = dev_get_drvdata(dev->parent);
const struct dsps_musb_wrapper *wrp = glue->wrp;
void __iomem *reg_base = musb->ctrl_base;
+ char name[10];
u32 rev, val;
int status;
@@ -419,7 +421,8 @@ static int dsps_musb_init(struct musb *musb)
musb->mregs += wrp->musb_core_offset;
/* Get the NOP PHY */
- musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
+ sprintf(name, "usb%d-phy", pdev->id);
+ musb->xceiv = devm_usb_get_phy_by_phandle(&parent_pdev->dev, name);
if (IS_ERR_OR_NULL(musb->xceiv))
return -ENODEV;
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 19+ messages in thread