[V9 PATCH 05/12] usb: phy: phy-mv-usb: use USB2 PHY driver for otg

2013-04-07 Thread Chao Xie
Originaly, otg driver will call the callbacks in platform data
for PHY initialization and shut down.
With PHY driver, it will call the APIs provided by PHY driver
for PHY initialization and shut down. It removes the callbacks
in platform data, and at same time it removes one block in the
way of enabling device tree for otg driver.

Signed-off-by: Chao Xie 
---
 drivers/usb/phy/phy-mv-usb.c |   53 ++---
 drivers/usb/phy/phy-mv-usb.h |2 +-
 2 files changed, 24 insertions(+), 31 deletions(-)

diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index c987bbe..9938904 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "phy-mv-usb.h"
@@ -255,15 +256,14 @@ static int mv_otg_enable_internal(struct mv_otg *mvotg)
dev_dbg(&mvotg->pdev->dev, "otg enabled\n");
 
otg_clock_enable(mvotg);
-   if (mvotg->pdata->phy_init) {
-   retval = mvotg->pdata->phy_init(mvotg->phy_regs);
-   if (retval) {
-   dev_err(&mvotg->pdev->dev,
-   "init phy error %d\n", retval);
-   otg_clock_disable(mvotg);
-   return retval;
-   }
+   retval = usb_phy_init(mvotg->outer_phy);
+   if (retval) {
+   dev_err(&mvotg->pdev->dev,
+   "failed to initialize phy %d\n", retval);
+   otg_clock_disable(mvotg);
+   return retval;
}
+
mvotg->active = 1;
 
return 0;
@@ -282,8 +282,7 @@ static void mv_otg_disable_internal(struct mv_otg *mvotg)
 {
if (mvotg->active) {
dev_dbg(&mvotg->pdev->dev, "otg disabled\n");
-   if (mvotg->pdata->phy_deinit)
-   mvotg->pdata->phy_deinit(mvotg->phy_regs);
+   usb_phy_shutdown(mvotg->outer_phy);
otg_clock_disable(mvotg);
mvotg->active = 0;
}
@@ -715,6 +714,7 @@ static int mv_otg_probe(struct platform_device *pdev)
/* OTG common part */
mvotg->pdev = pdev;
mvotg->phy.dev = &pdev->dev;
+   mvotg->phy.type = USB_PHY_TYPE_USB2;
mvotg->phy.otg = otg;
mvotg->phy.label = driver_name;
mvotg->phy.state = OTG_STATE_UNDEFINED;
@@ -727,23 +727,8 @@ static int mv_otg_probe(struct platform_device *pdev)
for (i = 0; i < OTG_TIMER_NUM; i++)
init_timer(&mvotg->otg_ctrl.timer[i]);
 
-   r = platform_get_resource_byname(mvotg->pdev,
-IORESOURCE_MEM, "phyregs");
-   if (r == NULL) {
-   dev_err(&pdev->dev, "no phy I/O memory resource defined\n");
-   retval = -ENODEV;
-   goto err_destroy_workqueue;
-   }
-
-   mvotg->phy_regs = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-   if (mvotg->phy_regs == NULL) {
-   dev_err(&pdev->dev, "failed to map phy I/O memory\n");
-   retval = -EFAULT;
-   goto err_destroy_workqueue;
-   }
-
-   r = platform_get_resource_byname(mvotg->pdev,
-IORESOURCE_MEM, "capregs");
+   r = platform_get_resource(mvotg->pdev,
+IORESOURCE_MEM, 0);
if (r == NULL) {
dev_err(&pdev->dev, "no I/O memory resource defined\n");
retval = -ENODEV;
@@ -757,6 +742,14 @@ static int mv_otg_probe(struct platform_device *pdev)
goto err_destroy_workqueue;
}
 
+   mvotg->outer_phy = devm_usb_get_phy_dev(&pdev->dev, MV_USB2_PHY_INDEX);
+   if (IS_ERR_OR_NULL(mvotg->outer_phy)) {
+   retval = PTR_ERR(mvotg->outer_phy);
+   if (retval != -EPROBE_DEFER)
+   dev_err(&pdev->dev, "can not find outer phy\n");
+   goto err_destroy_workqueue;
+   }
+
/* we will acces controller register, so enable the udc controller */
retval = mv_otg_enable_internal(mvotg);
if (retval) {
@@ -816,7 +809,7 @@ static int mv_otg_probe(struct platform_device *pdev)
goto err_disable_clk;
}
 
-   retval = usb_add_phy(&mvotg->phy, USB_PHY_TYPE_USB2);
+   retval = usb_add_phy_dev(&mvotg->phy);
if (retval < 0) {
dev_err(&pdev->dev, "can't register transceiver, %d\n",
retval);
@@ -827,7 +820,7 @@ static int mv_otg_probe(struct platform_device *pdev)
if (retval < 0) {
dev_dbg(&pdev->dev,
"Can't register sysfs attr group: %d\n", retval);
-   goto err_remove_phy;
+   goto err_remove_otg_phy;
}
 
spin_lock_init(&mvotg->wq_lock);
@@ -842,7 +835,7 @@ static int mv_otg_probe(struct platform_device *pdev)
 
return 0;
 
-err_remove_phy:
+err_remove_otg_

[V9 PATCH 09/12] arm: ttc_dkb: modify usb support

2013-04-07 Thread Chao Xie
for ttc_dkb board, we use phy driver for usb support.
Modify the usb support for udc/otg/ehci support.

Signed-off-by: Chao Xie 
---
 arch/arm/mach-mmp/ttc_dkb.c |   39 ++-
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index 6528a5f..c8b9ed8 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -18,6 +18,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -29,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "common.h"
 
@@ -166,8 +167,6 @@ static struct mv_usb_platform_data ttc_usb_pdata = {
.vbus   = NULL,
.mode   = MV_USB_MODE_OTG,
.otg_force_a_bus_req = 1,
-   .phy_init   = pxa_usb_phy_init,
-   .phy_deinit = pxa_usb_phy_deinit,
.set_vbus   = NULL,
 };
 #endif
@@ -280,19 +279,41 @@ static void __init ttc_dkb_init(void)
pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
 
+#ifdef CONFIG_USB_SUPPORT
+   pxa_register_device(&pxa910_device_u2ophy, NULL, 0);
+#endif
+
 #ifdef CONFIG_USB_MV_UDC
-   pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
-   platform_device_register(&pxa168_device_u2o);
+   /* for usb2 phy */
+   usb_bind_phy(pxa910_device_u2o.drv_name, MV_USB2_PHY_INDEX,
+pxa910_device_u2ophy.drv_name);
+#ifdef CONFIG_USB_MV_OTG
+   /* for usb2 otg phy */
+   usb_bind_phy(pxa910_device_u2o.drv_name, MV_USB2_OTG_PHY_INDEX,
+pxa910_device_u2ootg.drv_name);
+#endif
+   pxa_register_device(&pxa910_device_u2o, &ttc_usb_pdata,
+   sizeof(ttc_usb_pdata));
 #endif
 
 #ifdef CONFIG_USB_EHCI_MV_U2O
-   pxa168_device_u2oehci.dev.platform_data = &ttc_usb_pdata;
-   platform_device_register(&pxa168_device_u2oehci);
+   /* for usb2 phy */
+   usb_bind_phy(pxa910_device_u2oehci.drv_name, MV_USB2_PHY_INDEX,
+pxa910_device_u2ophy.drv_name);
+#ifdef CONFIG_USB_MV_OTG
+   /* for usb2 otg phy */
+   usb_bind_phy(pxa910_device_u2oehci.drv_name, MV_USB2_OTG_PHY_INDEX,
+pxa910_device_u2ootg.drv_name);
+#endif
+   pxa_register_device(&pxa910_device_u2oehci, &ttc_usb_pdata,
+   sizeof(ttc_usb_pdata));
 #endif
 
 #ifdef CONFIG_USB_MV_OTG
-   pxa168_device_u2ootg.dev.platform_data = &ttc_usb_pdata;
-   platform_device_register(&pxa168_device_u2ootg);
+   usb_bind_phy(pxa910_device_u2ootg.drv_name, MV_USB2_PHY_INDEX,
+pxa910_device_u2ophy.drv_name);
+   pxa_register_device(&pxa910_device_u2ootg, &ttc_usb_pdata,
+   sizeof(ttc_usb_pdata));
 #endif
 
 #ifdef CONFIG_MMP_DISP
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 00/12] mv-usb phy driver

2013-04-07 Thread Chao Xie
The patches create the mv-usb phy driver

The patches remove the callbacks in the platform data for phy
initialization and shutdown, and directly write a phy driver
and make udc/ehci/otg to call it.

  usb: phy: protect phy init and shutdown for mutiple deivces
  usb: phy: mv_usb2: add PHY driver for marvell usb2 controller
Above patches are marvell usb PHY driver support.

  usb: gadget: mv_udc: use PHY driver for udc
  usb: ehci: ehci-mv: use PHY driver for ehci
  usb: phy: phy-mv-usb: use USB2 PHY driver for otg
Above patches modify the udc/ehci/otg drivers to make use of PHY
driver.

  usb: mv_u3d: usb phy drivers for phy operation
Above patch is the fix for marvel usb3 gadget driver. It will make
use of PHY driver.

  arm: mmp2: change the defintion of usb devices
  arm: pxa910: change the defintion of usb devices
  arm: ttc_dkb: modify usb support
  arm: mmp: remove unused usb devices
  arm: brownstone: add usb support for the board
Above patches are the changes from SOCes.

  usb: mv_usb: remove the phy callbacks in pdata
Above patch finally remove the callbacks for PHY in pdata.

V2->V1:
  Change the Signed-off-by to be right email address

v3->v2
  re-format the patches to new code base

v4->v3
  1. make mv udc gadget driver depend on ARCH_PXA and ARCH_MMP
  2. remove __devinit and __devexit
  3. make the driver compiled successful if CONFIG_MV_USB2_PHY is not defined.
  The modified patches are
  usb: gadget: mv_udc: make mv_udc depends on ARCH_MMP or ARCH_PXA
  usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

v5->v4
  make the struct mv_usb2_extern_chip member ->head to be
  struct atomic_notifier_head instead of struct atomic_notifier_head *.

v6->v5
  the bug fix patches are merged.
  Removed the dependcy of ARCH_MMP and ARCH_PXA, and make the driver can be
  compiled for x86.
  The device tree support patches need modification, remove them from this
  patch series, and they will be submitted in another series.


v7->v6
  Use usb_add_phy_dev and related APIs to add PHY drivers.
  Removed the device tree support in PHY driver. It will be added in another
  patch series.

v8->v7
  bugs fix in phy driver.
  directly use devm_usb_get_phy_dev return value for error return.

v9->v8
  Remove u2o_xxx.
  Add prefix for register definition
  Move mutex to common PHY layer
  Use module_platform_driver() to register driver
  Use usleep_range to replace udelay

Chao Xie (12):
  usb: phy: protect phy init and shutdown for mutiple deivces
  usb: phy: mv_usb2: add PHY driver for marvell usb2 controller
  usb: gadget: mv_udc: use PHY driver for udc
  usb: ehci: ehci-mv: use PHY driver for ehci
  usb: phy: phy-mv-usb: use USB2 PHY driver for otg
  usb: mv_u3d: usb phy drivers for phy operation
  arm: mmp2: change the defintion of usb devices
  arm: pxa910: change the defintion of usb devices
  arm: ttc_dkb: modify usb support
  arm: mmp: remove unused usb devices
  arm: brownstone: add usb support for the board
  usb: mv_usb: remove the phy callbacks in pdata

 arch/arm/mach-mmp/brownstone.c  |   56 +
 arch/arm/mach-mmp/include/mach/mmp2.h   |4 +
 arch/arm/mach-mmp/include/mach/pxa910.h |7 +-
 arch/arm/mach-mmp/mmp2.c|4 +
 arch/arm/mach-mmp/pxa910.c  |4 +
 arch/arm/mach-mmp/ttc_dkb.c |   39 +++-
 drivers/usb/gadget/mv_u3d.h |3 +-
 drivers/usb/gadget/mv_u3d_core.c|   54 ++---
 drivers/usb/gadget/mv_udc.h |2 +-
 drivers/usb/gadget/mv_udc_core.c|   50 ++---
 drivers/usb/host/ehci-mv.c  |   49 ++---
 drivers/usb/phy/Kconfig |6 +
 drivers/usb/phy/Makefile|1 +
 drivers/usb/phy/phy-mv-usb.c|   53 ++---
 drivers/usb/phy/phy-mv-usb.h|2 +-
 drivers/usb/phy/phy-mv-usb2.c   |  380 +++
 drivers/usb/phy/phy.c   |6 +
 include/linux/platform_data/mv_usb.h|3 -
 include/linux/usb/mv_usb2.h |   29 +++
 include/linux/usb/phy.h |   22 ++-
 20 files changed, 624 insertions(+), 150 deletions(-)
 create mode 100644 drivers/usb/phy/phy-mv-usb2.c
 create mode 100644 include/linux/usb/mv_usb2.h

-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 03/12] usb: gadget: mv_udc: use PHY driver for udc

2013-04-07 Thread Chao Xie
Originaly, udc driver will call the callbacks in platform data
for PHY initialization and shut down.
With PHY driver, it will call the APIs provided by PHY driver
for PHY initialization and shut down. It removes the callbacks
in platform data, and at same time it removes one block in the
way of enabling device tree for udc driver.

Signed-off-by: Chao Xie 
---
 drivers/usb/gadget/mv_udc.h  |2 +-
 drivers/usb/gadget/mv_udc_core.c |   50 +-
 2 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc.h b/drivers/usb/gadget/mv_udc.h
index be77f20..02f36fe 100644
--- a/drivers/usb/gadget/mv_udc.h
+++ b/drivers/usb/gadget/mv_udc.h
@@ -180,7 +180,6 @@ struct mv_udc {
 
struct mv_cap_regs __iomem  *cap_regs;
struct mv_op_regs __iomem   *op_regs;
-   void __iomem*phy_regs;
unsigned intmax_eps;
struct mv_dqh   *ep_dqh;
size_t  ep_dqh_size;
@@ -217,6 +216,7 @@ struct mv_udc {
struct work_struct  vbus_work;
struct workqueue_struct *qwork;
 
+   struct usb_phy  *phy;
struct usb_phy  *transceiver;
 
struct mv_usb_platform_data *pdata;
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index c2a5702..a6beef6 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "mv_udc.h"
@@ -1083,15 +1084,14 @@ static int mv_udc_enable_internal(struct mv_udc *udc)
 
dev_dbg(&udc->dev->dev, "enable udc\n");
udc_clock_enable(udc);
-   if (udc->pdata->phy_init) {
-   retval = udc->pdata->phy_init(udc->phy_regs);
-   if (retval) {
-   dev_err(&udc->dev->dev,
-   "init phy error %d\n", retval);
-   udc_clock_disable(udc);
-   return retval;
-   }
+   retval = usb_phy_init(udc->phy);
+   if (retval) {
+   dev_err(&udc->dev->dev,
+   "init phy error %d\n", retval);
+   udc_clock_disable(udc);
+   return retval;
}
+
udc->active = 1;
 
return 0;
@@ -1109,8 +1109,7 @@ static void mv_udc_disable_internal(struct mv_udc *udc)
 {
if (udc->active) {
dev_dbg(&udc->dev->dev, "disable udc\n");
-   if (udc->pdata->phy_deinit)
-   udc->pdata->phy_deinit(udc->phy_regs);
+   usb_phy_shutdown(udc->phy);
udc_clock_disable(udc);
udc->active = 0;
}
@@ -2124,17 +2123,10 @@ static int mv_udc_probe(struct platform_device *pdev)
udc->dev = pdev;
 
if (pdata->mode == MV_USB_MODE_OTG) {
-   udc->transceiver = devm_usb_get_phy(&pdev->dev,
-   USB_PHY_TYPE_USB2);
-   if (IS_ERR(udc->transceiver)) {
-   retval = PTR_ERR(udc->transceiver);
-
-   if (retval == -ENXIO)
-   return retval;
-
-   udc->transceiver = NULL;
-   return -EPROBE_DEFER;
-   }
+   udc->transceiver = devm_usb_get_phy_dev(&pdev->dev,
+   MV_USB2_OTG_PHY_INDEX);
+   if (IS_ERR_OR_NULL(udc->transceiver))
+   return PTR_ERR(udc->transceiver);
}
 
/* udc only have one sysclk. */
@@ -2142,7 +2134,7 @@ static int mv_udc_probe(struct platform_device *pdev)
if (IS_ERR(udc->clk))
return PTR_ERR(udc->clk);
 
-   r = platform_get_resource_byname(udc->dev, IORESOURCE_MEM, "capregs");
+   r = platform_get_resource(udc->dev, IORESOURCE_MEM, 0);
if (r == NULL) {
dev_err(&pdev->dev, "no I/O memory resource defined\n");
return -ENODEV;
@@ -2155,17 +2147,9 @@ static int mv_udc_probe(struct platform_device *pdev)
return -EBUSY;
}
 
-   r = platform_get_resource_byname(udc->dev, IORESOURCE_MEM, "phyregs");
-   if (r == NULL) {
-   dev_err(&pdev->dev, "no phy I/O memory resource defined\n");
-   return -ENODEV;
-   }
-
-   udc->phy_regs = ioremap(r->start, resource_size(r));
-   if (udc->phy_regs == NULL) {
-   dev_err(&pdev->dev, "failed to map phy I/O memory\n");
-   return -EBUSY;
-   }
+   udc->phy = devm_usb_get_phy_dev(&pdev->dev, MV_USB2_PHY_INDEX);
+   if (IS_ERR_OR_NULL(udc->phy))
+   return PTR_ERR(udc->phy);
 
/* we will acces controller register, so enable the clk */
retval = mv_udc_enable_internal(udc);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb

[V9 PATCH 06/12] usb: mv_u3d: usb phy drivers for phy operation

2013-04-07 Thread Chao Xie
The phy_init and phy_deinit APIs are removed from the pdata.
Directly get the phy driver and invoke the callbacks of phy
drivers for phy initialization and shutdown.

Signed-off-by: Chao Xie 
---
 drivers/usb/gadget/mv_u3d.h  |3 +-
 drivers/usb/gadget/mv_u3d_core.c |   54 ++---
 2 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/gadget/mv_u3d.h b/drivers/usb/gadget/mv_u3d.h
index e32a787..0a0c7e3 100644
--- a/drivers/usb/gadget/mv_u3d.h
+++ b/drivers/usb/gadget/mv_u3d.h
@@ -251,7 +251,6 @@ struct mv_u3d {
struct mv_u3d_cap_regs __iomem  *cap_regs;
struct mv_u3d_op_regs __iomem   *op_regs;
struct mv_u3d_vuc_regs __iomem  *vuc_regs;
-   void __iomem*phy_regs;
 
unsigned intmax_eps;
struct mv_u3d_ep_context*ep_context;
@@ -283,6 +282,8 @@ struct mv_u3d {
struct mv_usb_addon_irq *vbus;
unsigned intpower;
 
+   struct usb_phy  *phy;
+
struct clk  *clk;
 };
 
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c
index 58288e9..bb92c5b 100644
--- a/drivers/usb/gadget/mv_u3d_core.c
+++ b/drivers/usb/gadget/mv_u3d_core.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1109,7 +1110,6 @@ static int mv_u3d_controller_reset(struct mv_u3d *u3d)
 
 static int mv_u3d_enable(struct mv_u3d *u3d)
 {
-   struct mv_usb_platform_data *pdata = u3d->dev->platform_data;
int retval;
 
if (u3d->active)
@@ -1122,14 +1122,12 @@ static int mv_u3d_enable(struct mv_u3d *u3d)
 
dev_dbg(u3d->dev, "enable u3d\n");
clk_enable(u3d->clk);
-   if (pdata->phy_init) {
-   retval = pdata->phy_init(u3d->phy_regs);
-   if (retval) {
-   dev_err(u3d->dev,
-   "init phy error %d\n", retval);
-   clk_disable(u3d->clk);
-   return retval;
-   }
+   retval = usb_phy_init(u3d->phy);
+   if (retval) {
+   dev_err(u3d->dev,
+   "init phy error %d\n", retval);
+   clk_disable(u3d->clk);
+   return retval;
}
u3d->active = 1;
 
@@ -1138,11 +1136,9 @@ static int mv_u3d_enable(struct mv_u3d *u3d)
 
 static void mv_u3d_disable(struct mv_u3d *u3d)
 {
-   struct mv_usb_platform_data *pdata = u3d->dev->platform_data;
if (u3d->clock_gating && u3d->active) {
dev_dbg(u3d->dev, "disable u3d\n");
-   if (pdata->phy_deinit)
-   pdata->phy_deinit(u3d->phy_regs);
+   usb_phy_shutdown(u3d->phy);
clk_disable(u3d->clk);
u3d->active = 0;
}
@@ -1246,7 +1242,6 @@ static int mv_u3d_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
 {
struct mv_u3d *u3d = container_of(g, struct mv_u3d, gadget);
-   struct mv_usb_platform_data *pdata = u3d->dev->platform_data;
unsigned long flags;
 
if (u3d->driver)
@@ -1256,8 +1251,7 @@ static int mv_u3d_start(struct usb_gadget *g,
 
if (!u3d->clock_gating) {
clk_enable(u3d->clk);
-   if (pdata->phy_init)
-   pdata->phy_init(u3d->phy_regs);
+   usb_phy_init(u3d->phy);
}
 
/* hook up the driver ... */
@@ -1277,7 +1271,6 @@ static int mv_u3d_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
 {
struct mv_u3d *u3d = container_of(g, struct mv_u3d, gadget);
-   struct mv_usb_platform_data *pdata = u3d->dev->platform_data;
unsigned long flags;
 
u3d->vbus_valid_detect = 0;
@@ -1285,8 +1278,7 @@ static int mv_u3d_stop(struct usb_gadget *g,
 
/* enable clock to access controller register */
clk_enable(u3d->clk);
-   if (pdata->phy_init)
-   pdata->phy_init(u3d->phy_regs);
+   usb_phy_init(u3d->phy);
 
mv_u3d_controller_stop(u3d);
/* stop all usb activities */
@@ -1294,8 +1286,7 @@ static int mv_u3d_stop(struct usb_gadget *g,
mv_u3d_stop_activity(u3d, driver);
mv_u3d_disable(u3d);
 
-   if (pdata->phy_deinit)
-   pdata->phy_deinit(u3d->phy_regs);
+   usb_phy_shutdown(u3d->phy);
clk_disable(u3d->clk);
 
spin_unlock_irqrestore(&u3d->lock, flags);
@@ -1827,7 +1818,7 @@ static int mv_u3d_probe(struct platform_device *dev)
goto err_get_clk;
}
 
-   r = platform_get_resource_byname(dev, IORESOURCE_MEM, "capregs");
+   r = platform_get_resource_byname(dev, IORESOURCE_MEM, 0);
if (!r) {
dev_err(&dev->dev, "no I/O memory resource defined\n");
retval = -ENODEV;
@@ -1846,15 +1837,14 @@ static int mv_u3d_probe(struct platform_device *dev)
(uns

[V9 PATCH 12/12] usb: mv_usb: remove the phy callbacks in pdata

2013-04-07 Thread Chao Xie
The phy initialization code will be done by phy driver.

Signed-off-by: Chao Xie 
---
 include/linux/platform_data/mv_usb.h |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/include/linux/platform_data/mv_usb.h 
b/include/linux/platform_data/mv_usb.h
index 98b7925..b4b5d6f 100644
--- a/include/linux/platform_data/mv_usb.h
+++ b/include/linux/platform_data/mv_usb.h
@@ -45,9 +45,6 @@ struct mv_usb_platform_data {
/* Force a_bus_req to be asserted */
 unsigned intotg_force_a_bus_req:1;
 
-   int (*phy_init)(void __iomem *regbase);
-   void(*phy_deinit)(void __iomem *regbase);
int (*set_vbus)(unsigned int vbus);
-   int (*private_init)(void __iomem *opregs, void __iomem *phyregs);
 };
 #endif
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 07/12] arm: mmp2: change the defintion of usb devices

2013-04-07 Thread Chao Xie
add the udc/otg/ehci devices for mmp2

Signed-off-by: Chao Xie 
---
 arch/arm/mach-mmp/include/mach/mmp2.h |4 
 arch/arm/mach-mmp/mmp2.c  |4 
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mmp/include/mach/mmp2.h 
b/arch/arm/mach-mmp/include/mach/mmp2.h
index 0764f4e..95b6bd7 100644
--- a/arch/arm/mach-mmp/include/mach/mmp2.h
+++ b/arch/arm/mach-mmp/include/mach/mmp2.h
@@ -29,6 +29,10 @@ extern struct pxa_device_desc mmp2_device_sdh2;
 extern struct pxa_device_desc mmp2_device_sdh3;
 extern struct pxa_device_desc mmp2_device_asram;
 extern struct pxa_device_desc mmp2_device_isram;
+extern struct pxa_device_desc mmp2_device_u2o;
+extern struct pxa_device_desc mmp2_device_u2ootg;
+extern struct pxa_device_desc mmp2_device_u2oehci;
+extern struct pxa_device_desc mmp2_device_u2ophy;
 
 extern struct platform_device mmp2_device_gpio;
 
diff --git a/arch/arm/mach-mmp/mmp2.c b/arch/arm/mach-mmp/mmp2.c
index d94d114..e7b7642 100644
--- a/arch/arm/mach-mmp/mmp2.c
+++ b/arch/arm/mach-mmp/mmp2.c
@@ -149,6 +149,10 @@ MMP2_DEVICE(sdh3, "sdhci-pxav3", 3, MMC4, 0xd4281800, 
0x120);
 MMP2_DEVICE(asram, "asram", -1, NONE, 0xe000, 0x4000);
 /* 0xd100 ~ 0xd101 is reserved for secure processor */
 MMP2_DEVICE(isram, "isram", -1, NONE, 0xd102, 0x18000);
+MMP2_DEVICE(u2ophy, "mmp2-usb-phy", -1, NONE, 0xd4207000, 0x1ff);
+MMP2_DEVICE(u2o, "mv-udc", -1, USB_OTG, 0xd4208100, 0x1ff);
+MMP2_DEVICE(u2ootg, "mv-otg", -1, USB_OTG, 0xd4208100, 0x1ff);
+MMP2_DEVICE(u2oehci, "mv-ehci", -1, USB_OTG, 0xd4208100, 0x1ff);
 
 struct resource mmp2_resource_gpio[] = {
{
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 10/12] arm: mmp: remove unused usb devices

2013-04-07 Thread Chao Xie
We defined new usb devices for usb ehci/udc/otg/phy.
So remove the old definitions.

Signed-off-by: Chao Xie 
---
 arch/arm/mach-mmp/include/mach/pxa910.h |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-mmp/include/mach/pxa910.h 
b/arch/arm/mach-mmp/include/mach/pxa910.h
index c695982..d17ffee 100644
--- a/arch/arm/mach-mmp/include/mach/pxa910.h
+++ b/arch/arm/mach-mmp/include/mach/pxa910.h
@@ -19,9 +19,6 @@ extern struct pxa_device_desc pxa910_device_pwm2;
 extern struct pxa_device_desc pxa910_device_pwm3;
 extern struct pxa_device_desc pxa910_device_pwm4;
 extern struct pxa_device_desc pxa910_device_nand;
-extern struct platform_device pxa168_device_u2o;
-extern struct platform_device pxa168_device_u2ootg;
-extern struct platform_device pxa168_device_u2oehci;
 extern struct pxa_device_desc pxa910_device_u2o;
 extern struct pxa_device_desc pxa910_device_u2ootg;
 extern struct pxa_device_desc pxa910_device_u2oehci;
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 11/12] arm: brownstone: add usb support for the board

2013-04-07 Thread Chao Xie
for brownstone board, add the udc/otg/ehci support

Signed-off-by: Chao Xie 
---
 arch/arm/mach-mmp/brownstone.c |   56 
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index 2358011..aed553a 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -18,6 +18,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -195,6 +198,20 @@ static struct sram_platdata mmp2_isram_platdata = {
.granularity= SRAM_GRANULARITY,
 };
 
+#ifdef CONFIG_USB_SUPPORT
+
+#if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O)
+
+static struct mv_usb_platform_data brownstone_usb_pdata = {
+   .vbus   = NULL,
+   .mode   = MV_USB_MODE_OTG,
+   .otg_force_a_bus_req = 1,
+   .set_vbus   = NULL,
+};
+#endif
+#endif
+
+
 static void __init brownstone_init(void)
 {
mfp_config(ARRAY_AND_SIZE(brownstone_pin_config));
@@ -211,6 +228,45 @@ static void __init brownstone_init(void)
 
/* enable 5v regulator */
platform_device_register(&brownstone_v_5vp_device);
+
+#ifdef CONFIG_USB_SUPPORT
+   pxa_register_device(&mmp2_device_u2ophy, NULL, 0);
+#endif
+
+#ifdef CONFIG_USB_MV_UDC
+   /* for usb2 phy */
+   usb_bind_phy(mmp2_device_u2o.drv_name, MV_USB2_PHY_INDEX,
+mmp2_device_u2ophy.drv_name);
+#ifdef CONFIG_USB_MV_OTG
+   /* for usb2 otg phy */
+   usb_bind_phy(mmp2_device_u2o.drv_name, MV_USB2_OTG_PHY_INDEX,
+mmp2_device_u2ootg.drv_name);
+#endif
+   pxa_register_device(&mmp2_device_u2o, &brownstone_usb_pdata,
+   sizeof(brownstone_usb_pdata));
+#endif
+
+#ifdef CONFIG_USB_EHCI_MV_U2O
+   /* for usb2 phy */
+   usb_bind_phy(mmp2_device_u2oehci.dev_name, MV_USB2_PHY_INDEX,
+mmp2_device_u2ophy.dev_name);
+#ifdef CONFIG_USB_MV_OTG
+   /* for usb2 otg phy */
+   usb_bind_phy(mmp2_device_u2oehci.drv_name, MV_USB2_OTG_PHY_INDEX,
+mmp2_device_u2ootg.drv_name);
+#endif
+   pxa_register_device(&mmp2_device_u2oehci, &brownstone_usb_pdata,
+   sizeof(brownstone_usb_pdata));
+#endif
+
+#ifdef CONFIG_USB_MV_OTG
+   /* for usb2 phy */
+   usb_bind_phy(mmp2_device_u2ootg.dev_name, MV_USB2_PHY_INDEX,
+mmp2_device_u2ophy.dev_name);
+   pxa_register_device(&mmp2_device_u2ootg, &brownstone_usb_pdata,
+   sizeof(brownstone_usb_pdata));
+#endif
+
 }
 
 MACHINE_START(BROWNSTONE, "Brownstone Development Platform")
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces

2013-04-07 Thread Chao Xie
Some USB devices will share same phy, so make the ->init
and ->shutdown to be protected.
Only first device will initialize the phy, and only last device
can shutdown phy.

Signed-off-by: Chao Xie 
---
 drivers/usb/phy/phy.c   |6 ++
 include/linux/usb/phy.h |   22 ++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index f52c006..168332b 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -329,6 +329,9 @@ int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
return -EINVAL;
}
 
+   mutex_init(&x->phy_mutex);
+   x->refcount = 0;
+
spin_lock_irqsave(&phy_lock, flags);
 
list_for_each_entry(phy, &phy_list, head) {
@@ -367,6 +370,9 @@ int usb_add_phy_dev(struct usb_phy *x)
return -EINVAL;
}
 
+   mutex_init(&x->phy_mutex);
+   x->refcount = 0;
+
spin_lock_irqsave(&phy_lock, flags);
list_for_each_entry(phy_bind, &phy_bind_list, list)
if (!(strcmp(phy_bind->phy_dev_name, dev_name(x->dev
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 6b5978f..98d7e60 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -87,6 +87,14 @@ struct usb_phy {
/* to support controllers that have multiple transceivers */
struct list_headhead;
 
+   /*
+* PHY may be shared by multiple devices.
+* mutex and refcount are used to make sure PHY only initialize or
+* shutdown once.
+*/
+   struct mutexphy_mutex;
+   unsigned intrefcount;
+
/* initialize/shutdown the OTG controller */
int (*init)(struct usb_phy *x);
void(*shutdown)(struct usb_phy *x);
@@ -150,17 +158,23 @@ static inline int usb_phy_io_write(struct usb_phy *x, u32 
val, u32 reg)
 static inline int
 usb_phy_init(struct usb_phy *x)
 {
-   if (x->init)
-   return x->init(x);
+   int ret = 0;
 
-   return 0;
+   mutex_lock(&x->phy_mutex);
+   if (x->refcount++ == 0 && x->init)
+   ret = x->init(x);
+   mutex_unlock(&x->phy_mutex);
+
+   return ret;
 }
 
 static inline void
 usb_phy_shutdown(struct usb_phy *x)
 {
-   if (x->shutdown)
+   mutex_lock(&x->phy_mutex);
+   if (--x->refcount == 0 && x->shutdown)
x->shutdown(x);
+   mutex_unlock(&x->phy_mutex);
 }
 
 static inline int
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 08/12] arm: pxa910: change the defintion of usb devices

2013-04-07 Thread Chao Xie
because phy is seperated from the usb controller driver,
we can use the common pxa_device_desc for device register.

Signed-off-by: Chao Xie 
---
 arch/arm/mach-mmp/include/mach/pxa910.h |4 
 arch/arm/mach-mmp/pxa910.c  |4 
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mmp/include/mach/pxa910.h 
b/arch/arm/mach-mmp/include/mach/pxa910.h
index b914afa..c695982 100644
--- a/arch/arm/mach-mmp/include/mach/pxa910.h
+++ b/arch/arm/mach-mmp/include/mach/pxa910.h
@@ -22,6 +22,10 @@ extern struct pxa_device_desc pxa910_device_nand;
 extern struct platform_device pxa168_device_u2o;
 extern struct platform_device pxa168_device_u2ootg;
 extern struct platform_device pxa168_device_u2oehci;
+extern struct pxa_device_desc pxa910_device_u2o;
+extern struct pxa_device_desc pxa910_device_u2ootg;
+extern struct pxa_device_desc pxa910_device_u2oehci;
+extern struct pxa_device_desc pxa910_device_u2ophy;
 extern struct pxa_device_desc pxa910_device_disp;
 extern struct pxa_device_desc pxa910_device_fb;
 extern struct pxa_device_desc pxa910_device_panel;
diff --git a/arch/arm/mach-mmp/pxa910.c b/arch/arm/mach-mmp/pxa910.c
index 36cb321..28fdce5 100644
--- a/arch/arm/mach-mmp/pxa910.c
+++ b/arch/arm/mach-mmp/pxa910.c
@@ -134,6 +134,10 @@ PXA910_DEVICE(pwm2, "pxa910-pwm", 1, NONE, 0xd401a400, 
0x10);
 PXA910_DEVICE(pwm3, "pxa910-pwm", 2, NONE, 0xd401a800, 0x10);
 PXA910_DEVICE(pwm4, "pxa910-pwm", 3, NONE, 0xd401ac00, 0x10);
 PXA910_DEVICE(nand, "pxa3xx-nand", -1, NAND, 0xd4283000, 0x80, 97, 99);
+PXA910_DEVICE(u2ophy, "pxa910-usb-phy", -1, NONE, 0xd4207000, 0x1ff);
+PXA910_DEVICE(u2o, "mv-udc", -1, USB1, 0xd4208100, 0x1ff);
+PXA910_DEVICE(u2ootg, "mv-otg", -1, USB1, 0xd4208100, 0x1ff);
+PXA910_DEVICE(u2oehci, "mv-ehci", -1, USB1, 0xd4208100, 0x1ff);
 PXA910_DEVICE(disp, "mmp-disp", 0, LCD, 0xd420b000, 0x1ec);
 PXA910_DEVICE(fb, "mmp-fb", -1, NONE, 0, 0);
 PXA910_DEVICE(panel, "tpo-hvga", -1, NONE, 0, 0);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 04/12] usb: ehci: ehci-mv: use PHY driver for ehci

2013-04-07 Thread Chao Xie
Originaly, ehci driver will call the callbacks in platform data
for PHY initialization and shut down.
With PHY driver, it will call the APIs provided by PHY driver
for PHY initialization and shut down. It removes the callbacks
in platform data, and at same time it removes one block in the
way of enabling device tree for ehci driver.

Signed-off-by: Chao Xie 
---
 drivers/usb/host/ehci-mv.c |   49 +++
 1 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 6bad41a..adfc11f 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -15,17 +15,18 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define CAPLENGTH_MASK (0xff)
 
 struct ehci_hcd_mv {
struct usb_hcd *hcd;
+   struct usb_phy *phy;
 
/* Which mode does this ehci running OTG/Host ? */
int mode;
 
-   void __iomem *phy_regs;
void __iomem *cap_regs;
void __iomem *op_regs;
 
@@ -48,22 +49,15 @@ static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv)
 
 static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv)
 {
-   int retval;
-
ehci_clock_enable(ehci_mv);
-   if (ehci_mv->pdata->phy_init) {
-   retval = ehci_mv->pdata->phy_init(ehci_mv->phy_regs);
-   if (retval)
-   return retval;
-   }
 
-   return 0;
+   return usb_phy_init(ehci_mv->phy);
 }
 
 static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv)
 {
-   if (ehci_mv->pdata->phy_deinit)
-   ehci_mv->pdata->phy_deinit(ehci_mv->phy_regs);
+   usb_phy_shutdown(ehci_mv->phy);
+
ehci_clock_disable(ehci_mv);
 }
 
@@ -169,22 +163,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
goto err_clear_drvdata;
}
 
-   r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs");
-   if (r == NULL) {
-   dev_err(&pdev->dev, "no phy I/O memory resource defined\n");
-   retval = -ENODEV;
-   goto err_clear_drvdata;
-   }
-
-   ehci_mv->phy_regs = devm_ioremap(&pdev->dev, r->start,
-resource_size(r));
-   if (ehci_mv->phy_regs == 0) {
-   dev_err(&pdev->dev, "failed to map phy I/O memory\n");
-   retval = -EFAULT;
-   goto err_clear_drvdata;
-   }
-
-   r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs");
+   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) {
dev_err(&pdev->dev, "no I/O memory resource defined\n");
retval = -ENODEV;
@@ -199,6 +178,14 @@ static int mv_ehci_probe(struct platform_device *pdev)
goto err_clear_drvdata;
}
 
+   ehci_mv->phy = devm_usb_get_phy_dev(&pdev->dev, MV_USB2_PHY_INDEX);
+   if (IS_ERR_OR_NULL(ehci_mv->phy)) {
+   retval = PTR_ERR(ehci_mv->phy);
+   if (retval != -EPROBE_DEFER)
+   dev_err(&pdev->dev, "failed to get the outer phy\n");
+   goto err_clear_drvdata;
+   }
+
retval = mv_ehci_enable(ehci_mv);
if (retval) {
dev_err(&pdev->dev, "init phy error %d\n", retval);
@@ -225,14 +212,15 @@ static int mv_ehci_probe(struct platform_device *pdev)
 
ehci_mv->mode = pdata->mode;
if (ehci_mv->mode == MV_USB_MODE_OTG) {
-   ehci_mv->otg = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
+   ehci_mv->otg = devm_usb_get_phy_dev(&pdev->dev,
+   MV_USB2_OTG_PHY_INDEX);
if (IS_ERR(ehci_mv->otg)) {
retval = PTR_ERR(ehci_mv->otg);
 
if (retval == -ENXIO)
dev_info(&pdev->dev, "MV_USB_MODE_OTG "
"must have CONFIG_USB_PHY 
enabled\n");
-   else
+   else if (retval != -EPROBE_DEFER)
dev_err(&pdev->dev,
"unable to find transceiver\n");
goto err_disable_clk;
@@ -259,9 +247,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
}
}
 
-   if (pdata->private_init)
-   pdata->private_init(ehci_mv->op_regs, ehci_mv->phy_regs);
-
dev_info(&pdev->dev,
 "successful find EHCI device with regs 0x%p irq %d"
 " working in %s mode\n", hcd->regs, hcd->irq,
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[V9 PATCH 02/12] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-04-07 Thread Chao Xie
The PHY is seperated from usb controller.
The usb controller used in marvell pxa168/pxa910/mmp2 are same,
but PHY initialization may be different.
the usb controller can support udc/otg/ehci, and for each of
the mode, it need PHY to initialized before use the controller.
Direclty writing the phy driver will make the usb controller
driver to be simple and portable.
The PHY driver will be used by marvell udc/otg/ehci.

Signed-off-by: Chao Xie 
---
 drivers/usb/phy/Kconfig   |9 +
 drivers/usb/phy/Makefile  |1 +
 drivers/usb/phy/phy-mv-usb2.c |  379 +
 include/linux/usb/mv_usb2.h   |   29 +++
 4 files changed, 418 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/phy/phy-mv-usb2.c
 create mode 100644 include/linux/usb/mv_usb2.h

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 372db48..bdc7603 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -170,6 +170,15 @@ config USB_MV_OTG
 
  To compile this driver as a module, choose M here.
 
+config MV_USB2_PHY
+   tristate "Marvell USB 2.0 PHY Driver"
+   help
+ Enable this to support Marvell USB 2.0 phy driver for Marvell
+ SoC. This driver will do the PHY initialization and shutdown.
+ The PHY driver will be used by Marvell udc/ehci/otg driver.
+
+ To compile this driver as a module, choose M here.
+
 config USB_MXS_PHY
tristate "Freescale MXS USB PHY support"
depends on ARCH_MXC || ARCH_MXS
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 33863c0..90cc5f5 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_USB_EHCI_TEGRA)  += phy-tegra-usb.o
 obj-$(CONFIG_USB_GPIO_VBUS)+= phy-gpio-vbus-usb.o
 obj-$(CONFIG_USB_ISP1301)  += phy-isp1301.o
 obj-$(CONFIG_USB_MSM_OTG)  += phy-msm-usb.o
+obj-$(CONFIG_MV_USB2_PHY)  += phy-mv-usb2.o
 obj-$(CONFIG_USB_MV_OTG)   += phy-mv-usb.o
 obj-$(CONFIG_USB_MXS_PHY)  += phy-mxs-usb.o
 obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o
diff --git a/drivers/usb/phy/phy-mv-usb2.c b/drivers/usb/phy/phy-mv-usb2.c
new file mode 100644
index 000..43459ef
--- /dev/null
+++ b/drivers/usb/phy/phy-mv-usb2.c
@@ -0,0 +1,379 @@
+/*
+ * Copyright (C) 2013 Marvell Inc.
+ *
+ * Author:
+ * Chao Xie 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* phy regs */
+/* for pxa910 and mmp2, there is no revision register */
+#define MV_USB2_UTMI_REVISION  0x0
+#define MV_USB2_UTMI_CTRL  0x4
+#define MV_USB2_UTMI_PLL   0x8
+#define MV_USB2_UTMI_TX0xc
+#define MV_USB2_UTMI_RX0x10
+#define MV_USB2_UTMI_IVREF 0x14
+#define MV_USB2_UTMI_T00x18
+#define MV_USB2_UTMI_T10x1c
+#define MV_USB2_UTMI_T20x20
+#define MV_USB2_UTMI_T30x24
+#define MV_USB2_UTMI_T40x28
+#define MV_USB2_UTMI_T50x2c
+#define MV_USB2_UTMI_RESERVE   0x30
+#define MV_USB2_UTMI_USB_INT   0x34
+#define MV_USB2_UTMI_DBG_CTL   0x38
+#define MV_USB2_UTMI_OTG_ADDON 0x3c
+
+/* For UTMICTRL Register */
+#define MV_USB2_UTMI_CTRL_USB_CLK_EN   (1 << 31)
+/* pxa168 */
+#define MV_USB2_UTMI_CTRL_SUSPEND_SET1 (1 << 30)
+#define MV_USB2_UTMI_CTRL_SUSPEND_SET2 (1 << 29)
+#define MV_USB2_UTMI_CTRL_RXBUF_PDWN   (1 << 24)
+#define MV_USB2_UTMI_CTRL_TXBUF_PDWN   (1 << 11)
+
+#define MV_USB2_UTMI_CTRL_INPKT_DELAY_SHIFT30
+#define MV_USB2_UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
+#define MV_USB2_UTMI_CTRL_PU_REF_SHIFT 20
+#define MV_USB2_UTMI_CTRL_ARC_PULLDN_SHIFT 12
+#define MV_USB2_UTMI_CTRL_PLL_PWR_UP_SHIFT 1
+#define MV_USB2_UTMI_CTRL_PWR_UP_SHIFT 0
+
+/* For UTMI_PLL Register */
+#define MV_USB2_UTMI_PLL_PLLCALI12_SHIFT   29
+#define MV_USB2_UTMI_PLL_PLLCALI12_MASK(0x3 << 29)
+
+#define MV_USB2_UTMI_PLL_PLLVDD18_SHIFT27
+#define MV_USB2_UTMI_PLL_PLLVDD18_MASK (0x3 << 27)
+
+#define MV_USB2_UTMI_PLL_PLLVDD12_SHIFT

[PATCH] add ftdi_sio USB ID for GDM Boost V1.x

2013-04-07 Thread Stefani Seibold
This patch add a missing usb device id for the GDMBoost V1.x device

The patch is against 3.9-rc5

Signed-off-by: Stefani Seibold 
---
 ftdi_sio.c |1 +
 ftdi_sio_ids.h |1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 9886180..145979f 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -189,6 +189,7 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) },
+   { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_BOOST_PID) },
{ USB_DEVICE(NEWPORT_VID, NEWPORT_AGILIS_PID) },
{ USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
{ USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
diff --git a/drivers/usb/serial/ftdi_sio_ids.h 
b/drivers/usb/serial/ftdi_sio_ids.h
index e79861e..3c00351 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -74,6 +74,7 @@
 #define FTDI_OPENDCC_THROTTLE_PID  0xBFDA
 #define FTDI_OPENDCC_GATEWAY_PID   0xBFDB
 #define FTDI_OPENDCC_GBM_PID   0xBFDC
+#define FTDI_OPENDCC_GBM_BOOST_PID 0xBFDD
 
 /* NZR SEM 16+ USB (http://www.nzr.de) */
 #define FTDI_NZR_SEM_USB_PID   0xC1E0  /* NZR SEM-LOG16+ */
--
1.8.1.5


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 【PATCH】USB:add new zte 3g-dongle's pid to option.c

2013-04-07 Thread Greg KH
On Sun, Apr 07, 2013 at 02:25:23PM +0800, li.ru...@zte.com.cn wrote:
> 
> LINUX KRENEL: next-20130405
> SOURCE CODE PATH:linux-next-refs/tags/next-20130405/drivers/usb/serial/

I don't need these two lines, what are they for?

> Signed-off-by: Rui li 
> 
> 
> --- linux-next-refs/tags/next-20130405/drivers/usb/serial/option.c.orig  
>  2013-04-05 13:47:30.0 +0800
> +++ linux-next-refs/tags/next-20130405/drivers/usb/serial/option.c  
>  2013-04-07 14:16:56.0 +0800
> @@ -1166,6 +1166,22 @@
>  { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff,
> 0xff),
>  .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
>  { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff,
> 0xff),  /* ZTE MF91 */
> +{ USB_DEVICE_AND_INTERFACE_INFO(zte_VENDOR_ID, 0x1533, 0xff, 0xff, 0xff)
> },  

Can you please resend this, not in html or as a base64 attachment, and
not such that the tabs are converted to spaces (run it through
'scripts/checkpatch.pl' first) so that I can properly apply it?

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch -next] usb, gadget: use appropriate warning accessors

2013-04-07 Thread David Rientjes
Use the appropriate WARN() and WARN_ON() accessors to avoid a build error 
when CONFIG_BUG=n:

drivers/usb/gadget/configfs.c: In function 'config_usb_cfg_unlink':
drivers/usb/gadget/configfs.c:442:2: error: implicit declaration of 
function '__WARN_printf'
drivers/usb/gadget/configfs.c: In function 'configfs_do_nothing':
drivers/usb/gadget/configfs.c:733:2: error: implicit declaration of 
function '__WARN'

Reported-by: Randy Dunlap 
Signed-off-by: David Rientjes 
---
 drivers/usb/gadget/configfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -439,7 +439,7 @@ static int config_usb_cfg_unlink(
}
}
mutex_unlock(&gi->lock);
-   __WARN_printf("Unable to locate function to unbind\n");
+   WARN(1, "Unable to locate function to unbind\n");
return 0;
 }
 
@@ -730,7 +730,7 @@ USB_CONFIG_STRINGS_LANG(gadget_strings, gadget_info);
 
 static int configfs_do_nothing(struct usb_composite_dev *cdev)
 {
-   __WARN();
+   WARN_ON(1);
return -EINVAL;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: IMX23 usb instability on 3.9-rc5

2013-04-07 Thread Alexandre Pereira da Silva
On Sat, Apr 6, 2013 at 4:44 PM, Fabio Estevam  wrote:
> Maybe bad DDR initialization? Are using U-boot or bootlets to setup the DDR?
>
> What is your DDR frequency: 133 or 96MHz? I saw some posts in the
> olimex forum that people had to run it at 96MHz to get stable
> operation.

Thanks Fabio,

That seems to be the case. I did two of the mods sugested on olimex forums.
1) Remove R17.
2) Drop DDR speed to 96MHZ.

The first improved the behavior a lot, but still have crashes. The
second have almost eliminated them.

On Sat, Apr 6, 2013 at 4:44 PM, Fabio Estevam  wrote:
> Alexandre,
>
> On Sat, Apr 6, 2013 at 4:39 PM, Alexandre Pereira da Silva
>  wrote:
>> Hello,
>>
>> I am testing a usb key connected on a IMX23-Olinuxino board. The
>> kernel panics at heavy usb trafic. This was build with the mxs
>> defconfig
>>
>> This happens everytime with "dd if=/dev/sda of=/dev/null bs=4k". The
>> messages of the failure varies a lot from run to run.
>
> Maybe bad DDR initialization? Are using U-boot or bootlets to setup the DDR?
>
> What is your DDR frequency: 133 or 96MHz? I saw some posts in the
> olimex forum that people had to run it at 96MHz to get stable
> operation.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/8] Reorganize R8A7779/Marzen USB code

2013-04-07 Thread Simon Horman
On Sat, Apr 06, 2013 at 02:35:34AM +0400, Sergei Shtylyov wrote:
> Hello.
> 
> On 04/05/2013 08:40 PM, Sergei Shtylyov wrote:
> 
> >
> >>>Here's the set of 4 patches against the Simon Horman's
> >>>'renesas.git' repo,
> >>>'renesas-next-20130404v2' tag and the 2 Ether patches I've
> >>>reposted yesterday.
> >>>It was created to fix the shortcomings in the R8A7779/Marzen
> >>>USB platform code
> >>>and R8A7779 USB common PHY driver, and so spans both
> >>>arch/arm/mach-shmobile/
> >>>and drivers/usb/ subtrees (some patches have to touch both subtrees).
> >>>The patches were conceived with the complete bisectability
> >>>goal in mind.
> >
> >>>[1/8] ARM: shmobile:Marzen: move USB EHCI, OHCI, and PHY
> >>>devices to R8A7779 code
> >>>[2/8] ehci-platform: add init() method to platform data
> >>>[3/8] ARM: shmobile: R8A7779: setup EHCI internal buffer
> >>>[4/8] rcar-phy: remove EHCI internal buffer setup
> >>>[5/8] rcar-phy: correct base address
> >>>[6/8] rcar-phy: add platform data
> >>>[7/8] ARM: shmobile: Marzen: pass platform data to USB PHY device
> >>>[8/8] rcar-phy: handle platform data
> >
> >>>I'm not sure thru which tree this patchset should be
> >>>merged, however it turns
> >>>out that it's too late now to push it thru Felipe Balbi's USB
> >>>tree for 3.10, so
> >>>maybe the patchset can be merged thru Simon's tree with
> >>>Felipe's and Alan
> >>>Stern's ACKs.
> >
> >>I guess you already got request about patch style from Simon.
> >
> >   It's not about style. I tried to keep the series copmpletely
> >bisectable, and granting almost all requests about splitting the
> >patches would have broken the bisection.
> >
> >>When you send v2 patch, could you please add "this patch is
> >>tested on  bard"
> >>on each patch's comment area ?
> >
> >   I'm not sure it's worth doing v2, although in one place I can
> >indeed readily split the patch. All patches were tested on the
> >Marzen board, I forgot to mention that in the cover letter.
> 
>Well, there's gonna be version 2 now, mainly because Alan Stern
> wasn't content with the patch #2.

When you spin v2 could you note in the change log of each patch that
includes both SoC and board of SoC and river code that the reason for this
is to avoid breaking bisection?

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Linux USB file storage gadget with new UDC

2013-04-07 Thread victor yeo
Hi,

>> Now i insmod g_file_storage gadget with file=/mnt/sd/backing_file, the
>> SCSI_READ_10 command is still not working properly.
>
> What makes you think that?

Because the SCSI_READ_10 is able to read the MBR from the backing
file, and after that, SCSI_READ_10 reads all zeroes (fails to read
boot sector).

>> g_file_storage gadget: ep0-setup, length 8:
>> : 80 06 00 01 00 00 40 00
>> g_file_storage gadget: get device descriptor
>
> But something is definitely wrong here.  Before sending this
> Get-Device-Descriptor request, the host should have done a USB port
> reset.  Either the host isn't performing the reset correctly or else
> your UDC driver didn't inform g_file_storage when the reset occurred.

Yes, the UDC driver didn't inform g_file_storage when the reset
occurred. What is to be done to inform g_file_storage when the reset
occurs?

Thanks,
victor
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


USB3.0 Interrupt transfer in u-boot

2013-04-07 Thread Puneet Sharma
Hello,

I want to test USB keyboard for XHCI in u-boot and to do that i need the
Interrupt transfer code in XHCI controller driver in u-boot. If
possible, can you help me to give that piece of code or can you help me
to figure out in kernel where can i find it so that i can try to
replicate it in u-boot and make it work.

Thanks
Puneet


The information contained in this email and any attachments is confidential and 
may be subject to copyright or other intellectual property protection. If you 
are not the intended recipient, you are not authorized to use or disclose this 
information, and we request that you notify us by reply mail or telephone and 
delete the original message from your mail system.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: fix an incorrect table index in comment

2013-04-07 Thread Huang Rui
Signed-off-by: Huang Rui 
---
 include/uapi/linux/usb/ch9.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
index f738e25..aa33fd1 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -138,7 +138,7 @@
 
 /*
  * New Feature Selectors as added by USB 3.0
- * See USB 3.0 spec Table 9-6
+ * See USB 3.0 spec Table 9-7
  */
 #define USB_DEVICE_U1_ENABLE   48  /* dev may initiate U1 transition */
 #define USB_DEVICE_U2_ENABLE   49  /* dev may initiate U2 transition */
@@ -147,7 +147,7 @@
 
 #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
 /*
- * Suspend Options, Table 9-7 USB 3.0 spec
+ * Suspend Options, Table 9-8 USB 3.0 spec
  */
 #define USB_INTRF_FUNC_SUSPEND_LP  (1 << (8 + 0))
 #define USB_INTRF_FUNC_SUSPEND_RW  (1 << (8 + 1))
-- 
1.7.11.7


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB3.0 Interrupt transfer in u-boot

2013-04-07 Thread Greg KH
On Mon, Apr 08, 2013 at 09:45:52AM +0530, Puneet Sharma wrote:
> The information contained in this email and any attachments is confidential 
> and may be subject to copyright or other intellectual property protection. If 
> you are not the intended recipient, you are not authorized to use or disclose 
> this information, and we request that you notify us by reply mail or 
> telephone and delete the original message from your mail system.

You forgot to include the phone number I need to call to notify you...

Now deleted.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html