Re: [V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-17 Thread Chao Xie
On Thu, Feb 7, 2013 at 1:57 PM, kishon kis...@ti.com wrote:
 Hi,


 On Thursday 07 February 2013 07:56 AM, Chao Xie wrote:

 On Wed, Feb 6, 2013 at 6:35 PM, kishon kis...@ti.com wrote:

 Hi,


 On Wednesday 06 February 2013 01:48 PM, Chao Xie wrote:


 On Wed, Feb 6, 2013 at 4:10 PM, kishon kis...@ti.com wrote:


 Hi,


 On Wednesday 06 February 2013 12:53 PM, Chao Xie wrote:



 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 chao@marvell.com
 ---
 drivers/usb/phy/Kconfig  |7 +
 drivers/usb/phy/Makefile |1 +
 drivers/usb/phy/mv_usb2_phy.c|  454
 ++
 include/linux/platform_data/mv_usb.h |9 +-
 include/linux/usb/mv_usb2.h  |   43 
 5 files changed, 511 insertions(+), 3 deletions(-)
 create mode 100644 drivers/usb/phy/mv_usb2_phy.c
 create mode 100644 include/linux/usb/mv_usb2.h

 diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
 index 65217a5..5479760 100644
 --- a/drivers/usb/phy/Kconfig
 +++ b/drivers/usb/phy/Kconfig
 @@ -73,3 +73,10 @@ config SAMSUNG_USBPHY
   help
 Enable this to support Samsung USB phy controller for
 samsung
 SoCs.
 +
 +config MV_USB2_PHY
 +   tristate Marvell USB 2.0 PHY Driver
 +   depends on USB || USB_GADGET
 +   help
 + Enable this to support Marvell USB 2.0 phy driver for
 Marvell
 + SoC.
 diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
 index b13faa1..3835316 100644
 --- a/drivers/usb/phy/Makefile
 +++ b/drivers/usb/phy/Makefile
 @@ -12,3 +12,4 @@ obj-$(CONFIG_MV_U3D_PHY)  +=
 mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
 obj-$(CONFIG_USB_RCAR_PHY)+= rcar-phy.o
 obj-$(CONFIG_SAMSUNG_USBPHY)  += samsung-usbphy.o
 +obj-$(CONFIG_MV_USB2_PHY)  += mv_usb2_phy.o
 diff --git a/drivers/usb/phy/mv_usb2_phy.c
 b/drivers/usb/phy/mv_usb2_phy.c
 new file mode 100644
 index 000..c2bccae
 --- /dev/null
 +++ b/drivers/usb/phy/mv_usb2_phy.c
 @@ -0,0 +1,454 @@
 +/*
 + * Copyright (C) 2010 Google, Inc.
 + *
 + * Author:
 + * Chao Xie xiechao.m...@gmail.com
 + *
 + * 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 linux/resource.h
 +#include linux/delay.h
 +#include linux/slab.h
 +#include linux/of.h
 +#include linux/of_device.h
 +#include linux/io.h
 +#include linux/err.h
 +#include linux/clk.h
 +#include linux/export.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/platform_data/mv_usb.h
 +#include linux/usb/mv_usb2.h
 +
 +/* phy regs */
 +#define UTMI_REVISION  0x0
 +#define UTMI_CTRL  0x4
 +#define UTMI_PLL   0x8
 +#define UTMI_TX0xc
 +#define UTMI_RX0x10
 +#define UTMI_IVREF 0x14
 +#define UTMI_T00x18
 +#define UTMI_T10x1c
 +#define UTMI_T20x20
 +#define UTMI_T30x24
 +#define UTMI_T40x28
 +#define UTMI_T50x2c
 +#define UTMI_RESERVE   0x30
 +#define UTMI_USB_INT   0x34
 +#define UTMI_DBG_CTL   0x38
 +#define UTMI_OTG_ADDON 0x3c
 +
 +/* For UTMICTRL Register */
 +#define UTMI_CTRL_USB_CLK_EN(1  31)
 +/* pxa168 */
 +#define UTMI_CTRL_SUSPEND_SET1  (1  30)
 +#define UTMI_CTRL_SUSPEND_SET2  (1  29)
 +#define UTMI_CTRL_RXBUF_PDWN(1  24)
 +#define UTMI_CTRL_TXBUF_PDWN(1  11)
 +
 +#define UTMI_CTRL_INPKT_DELAY_SHIFT 30
 +#define UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
 +#define UTMI_CTRL_PU_REF_SHIFT 20
 +#define UTMI_CTRL_ARC_PULLDN_SHIFT  12
 +#define UTMI_CTRL_PLL_PWR_UP_SHIFT  1
 +#define UTMI_CTRL_PWR_UP_SHIFT  0
 +
 +/* For UTMI_PLL Register */
 +#define UTMI_PLL_PLLCALI12_SHIFT   29
 +#define UTMI_PLL_PLLCALI12_MASK(0x3  29)
 +
 +#define UTMI_PLL_PLLVDD18_SHIFT 

Re: [V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-06 Thread kishon

Hi,

On Wednesday 06 February 2013 12:53 PM, Chao Xie wrote:

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 chao@marvell.com
---
  drivers/usb/phy/Kconfig  |7 +
  drivers/usb/phy/Makefile |1 +
  drivers/usb/phy/mv_usb2_phy.c|  454 ++
  include/linux/platform_data/mv_usb.h |9 +-
  include/linux/usb/mv_usb2.h  |   43 
  5 files changed, 511 insertions(+), 3 deletions(-)
  create mode 100644 drivers/usb/phy/mv_usb2_phy.c
  create mode 100644 include/linux/usb/mv_usb2.h

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 65217a5..5479760 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -73,3 +73,10 @@ config SAMSUNG_USBPHY
help
  Enable this to support Samsung USB phy controller for samsung
  SoCs.
+
+config MV_USB2_PHY
+   tristate Marvell USB 2.0 PHY Driver
+   depends on USB || USB_GADGET
+   help
+ Enable this to support Marvell USB 2.0 phy driver for Marvell
+ SoC.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b13faa1..3835316 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
  obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
  obj-$(CONFIG_USB_RCAR_PHY)+= rcar-phy.o
  obj-$(CONFIG_SAMSUNG_USBPHY)  += samsung-usbphy.o
+obj-$(CONFIG_MV_USB2_PHY)  += mv_usb2_phy.o
diff --git a/drivers/usb/phy/mv_usb2_phy.c b/drivers/usb/phy/mv_usb2_phy.c
new file mode 100644
index 000..c2bccae
--- /dev/null
+++ b/drivers/usb/phy/mv_usb2_phy.c
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * Author:
+ * Chao Xie xiechao.m...@gmail.com
+ *
+ * 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 linux/resource.h
+#include linux/delay.h
+#include linux/slab.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/io.h
+#include linux/err.h
+#include linux/clk.h
+#include linux/export.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/platform_data/mv_usb.h
+#include linux/usb/mv_usb2.h
+
+/* phy regs */
+#define UTMI_REVISION  0x0
+#define UTMI_CTRL  0x4
+#define UTMI_PLL   0x8
+#define UTMI_TX0xc
+#define UTMI_RX0x10
+#define UTMI_IVREF 0x14
+#define UTMI_T00x18
+#define UTMI_T10x1c
+#define UTMI_T20x20
+#define UTMI_T30x24
+#define UTMI_T40x28
+#define UTMI_T50x2c
+#define UTMI_RESERVE   0x30
+#define UTMI_USB_INT   0x34
+#define UTMI_DBG_CTL   0x38
+#define UTMI_OTG_ADDON 0x3c
+
+/* For UTMICTRL Register */
+#define UTMI_CTRL_USB_CLK_EN(1  31)
+/* pxa168 */
+#define UTMI_CTRL_SUSPEND_SET1  (1  30)
+#define UTMI_CTRL_SUSPEND_SET2  (1  29)
+#define UTMI_CTRL_RXBUF_PDWN(1  24)
+#define UTMI_CTRL_TXBUF_PDWN(1  11)
+
+#define UTMI_CTRL_INPKT_DELAY_SHIFT 30
+#define UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
+#define UTMI_CTRL_PU_REF_SHIFT 20
+#define UTMI_CTRL_ARC_PULLDN_SHIFT  12
+#define UTMI_CTRL_PLL_PWR_UP_SHIFT  1
+#define UTMI_CTRL_PWR_UP_SHIFT  0
+
+/* For UTMI_PLL Register */
+#define UTMI_PLL_PLLCALI12_SHIFT   29
+#define UTMI_PLL_PLLCALI12_MASK(0x3  29)
+
+#define UTMI_PLL_PLLVDD18_SHIFT27
+#define UTMI_PLL_PLLVDD18_MASK (0x3  27)
+
+#define UTMI_PLL_PLLVDD12_SHIFT25
+#define UTMI_PLL_PLLVDD12_MASK (0x3  25)
+
+#define UTMI_PLL_CLK_BLK_EN_SHIFT   24
+#define CLK_BLK_EN  (0x1  24)
+#define PLL_READY   (0x1  23)
+#define KVCO_EXT(0x1  22)
+#define VCOCAL_START

Re: [V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-06 Thread Chao Xie
On Wed, Feb 6, 2013 at 4:10 PM, kishon kis...@ti.com wrote:
 Hi,


 On Wednesday 06 February 2013 12:53 PM, Chao Xie wrote:

 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 chao@marvell.com
 ---
   drivers/usb/phy/Kconfig  |7 +
   drivers/usb/phy/Makefile |1 +
   drivers/usb/phy/mv_usb2_phy.c|  454
 ++
   include/linux/platform_data/mv_usb.h |9 +-
   include/linux/usb/mv_usb2.h  |   43 
   5 files changed, 511 insertions(+), 3 deletions(-)
   create mode 100644 drivers/usb/phy/mv_usb2_phy.c
   create mode 100644 include/linux/usb/mv_usb2.h

 diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
 index 65217a5..5479760 100644
 --- a/drivers/usb/phy/Kconfig
 +++ b/drivers/usb/phy/Kconfig
 @@ -73,3 +73,10 @@ config SAMSUNG_USBPHY
 help
   Enable this to support Samsung USB phy controller for samsung
   SoCs.
 +
 +config MV_USB2_PHY
 +   tristate Marvell USB 2.0 PHY Driver
 +   depends on USB || USB_GADGET
 +   help
 + Enable this to support Marvell USB 2.0 phy driver for Marvell
 + SoC.
 diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
 index b13faa1..3835316 100644
 --- a/drivers/usb/phy/Makefile
 +++ b/drivers/usb/phy/Makefile
 @@ -12,3 +12,4 @@ obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
   obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
   obj-$(CONFIG_USB_RCAR_PHY)+= rcar-phy.o
   obj-$(CONFIG_SAMSUNG_USBPHY)  += samsung-usbphy.o
 +obj-$(CONFIG_MV_USB2_PHY)  += mv_usb2_phy.o
 diff --git a/drivers/usb/phy/mv_usb2_phy.c b/drivers/usb/phy/mv_usb2_phy.c
 new file mode 100644
 index 000..c2bccae
 --- /dev/null
 +++ b/drivers/usb/phy/mv_usb2_phy.c
 @@ -0,0 +1,454 @@
 +/*
 + * Copyright (C) 2010 Google, Inc.
 + *
 + * Author:
 + * Chao Xie xiechao.m...@gmail.com
 + *
 + * 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 linux/resource.h
 +#include linux/delay.h
 +#include linux/slab.h
 +#include linux/of.h
 +#include linux/of_device.h
 +#include linux/io.h
 +#include linux/err.h
 +#include linux/clk.h
 +#include linux/export.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/platform_data/mv_usb.h
 +#include linux/usb/mv_usb2.h
 +
 +/* phy regs */
 +#define UTMI_REVISION  0x0
 +#define UTMI_CTRL  0x4
 +#define UTMI_PLL   0x8
 +#define UTMI_TX0xc
 +#define UTMI_RX0x10
 +#define UTMI_IVREF 0x14
 +#define UTMI_T00x18
 +#define UTMI_T10x1c
 +#define UTMI_T20x20
 +#define UTMI_T30x24
 +#define UTMI_T40x28
 +#define UTMI_T50x2c
 +#define UTMI_RESERVE   0x30
 +#define UTMI_USB_INT   0x34
 +#define UTMI_DBG_CTL   0x38
 +#define UTMI_OTG_ADDON 0x3c
 +
 +/* For UTMICTRL Register */
 +#define UTMI_CTRL_USB_CLK_EN(1  31)
 +/* pxa168 */
 +#define UTMI_CTRL_SUSPEND_SET1  (1  30)
 +#define UTMI_CTRL_SUSPEND_SET2  (1  29)
 +#define UTMI_CTRL_RXBUF_PDWN(1  24)
 +#define UTMI_CTRL_TXBUF_PDWN(1  11)
 +
 +#define UTMI_CTRL_INPKT_DELAY_SHIFT 30
 +#define UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
 +#define UTMI_CTRL_PU_REF_SHIFT 20
 +#define UTMI_CTRL_ARC_PULLDN_SHIFT  12
 +#define UTMI_CTRL_PLL_PWR_UP_SHIFT  1
 +#define UTMI_CTRL_PWR_UP_SHIFT  0
 +
 +/* For UTMI_PLL Register */
 +#define UTMI_PLL_PLLCALI12_SHIFT   29
 +#define UTMI_PLL_PLLCALI12_MASK(0x3  29)
 +
 +#define UTMI_PLL_PLLVDD18_SHIFT27
 +#define UTMI_PLL_PLLVDD18_MASK (0x3  27)
 +
 +#define UTMI_PLL_PLLVDD12_SHIFT25
 +#define UTMI_PLL_PLLVDD12_MASK (0x3  25)
 +
 +#define UTMI_PLL_CLK_BLK_EN_SHIFT   24
 +#define CLK_BLK_EN

Re: [V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-06 Thread kishon

Hi,

On Wednesday 06 February 2013 01:48 PM, Chao Xie wrote:

On Wed, Feb 6, 2013 at 4:10 PM, kishon kis...@ti.com wrote:

Hi,


On Wednesday 06 February 2013 12:53 PM, Chao Xie wrote:


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 chao@marvell.com
---
   drivers/usb/phy/Kconfig  |7 +
   drivers/usb/phy/Makefile |1 +
   drivers/usb/phy/mv_usb2_phy.c|  454
++
   include/linux/platform_data/mv_usb.h |9 +-
   include/linux/usb/mv_usb2.h  |   43 
   5 files changed, 511 insertions(+), 3 deletions(-)
   create mode 100644 drivers/usb/phy/mv_usb2_phy.c
   create mode 100644 include/linux/usb/mv_usb2.h

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 65217a5..5479760 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -73,3 +73,10 @@ config SAMSUNG_USBPHY
 help
   Enable this to support Samsung USB phy controller for samsung
   SoCs.
+
+config MV_USB2_PHY
+   tristate Marvell USB 2.0 PHY Driver
+   depends on USB || USB_GADGET
+   help
+ Enable this to support Marvell USB 2.0 phy driver for Marvell
+ SoC.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b13faa1..3835316 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
   obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
   obj-$(CONFIG_USB_RCAR_PHY)+= rcar-phy.o
   obj-$(CONFIG_SAMSUNG_USBPHY)  += samsung-usbphy.o
+obj-$(CONFIG_MV_USB2_PHY)  += mv_usb2_phy.o
diff --git a/drivers/usb/phy/mv_usb2_phy.c b/drivers/usb/phy/mv_usb2_phy.c
new file mode 100644
index 000..c2bccae
--- /dev/null
+++ b/drivers/usb/phy/mv_usb2_phy.c
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * Author:
+ * Chao Xie xiechao.m...@gmail.com
+ *
+ * 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 linux/resource.h
+#include linux/delay.h
+#include linux/slab.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/io.h
+#include linux/err.h
+#include linux/clk.h
+#include linux/export.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/platform_data/mv_usb.h
+#include linux/usb/mv_usb2.h
+
+/* phy regs */
+#define UTMI_REVISION  0x0
+#define UTMI_CTRL  0x4
+#define UTMI_PLL   0x8
+#define UTMI_TX0xc
+#define UTMI_RX0x10
+#define UTMI_IVREF 0x14
+#define UTMI_T00x18
+#define UTMI_T10x1c
+#define UTMI_T20x20
+#define UTMI_T30x24
+#define UTMI_T40x28
+#define UTMI_T50x2c
+#define UTMI_RESERVE   0x30
+#define UTMI_USB_INT   0x34
+#define UTMI_DBG_CTL   0x38
+#define UTMI_OTG_ADDON 0x3c
+
+/* For UTMICTRL Register */
+#define UTMI_CTRL_USB_CLK_EN(1  31)
+/* pxa168 */
+#define UTMI_CTRL_SUSPEND_SET1  (1  30)
+#define UTMI_CTRL_SUSPEND_SET2  (1  29)
+#define UTMI_CTRL_RXBUF_PDWN(1  24)
+#define UTMI_CTRL_TXBUF_PDWN(1  11)
+
+#define UTMI_CTRL_INPKT_DELAY_SHIFT 30
+#define UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
+#define UTMI_CTRL_PU_REF_SHIFT 20
+#define UTMI_CTRL_ARC_PULLDN_SHIFT  12
+#define UTMI_CTRL_PLL_PWR_UP_SHIFT  1
+#define UTMI_CTRL_PWR_UP_SHIFT  0
+
+/* For UTMI_PLL Register */
+#define UTMI_PLL_PLLCALI12_SHIFT   29
+#define UTMI_PLL_PLLCALI12_MASK(0x3  29)
+
+#define UTMI_PLL_PLLVDD18_SHIFT27
+#define UTMI_PLL_PLLVDD18_MASK (0x3  27)
+
+#define UTMI_PLL_PLLVDD12_SHIFT25
+#define UTMI_PLL_PLLVDD12_MASK (0x3  25)
+
+#define UTMI_PLL_CLK_BLK_EN_SHIFT   24
+#define CLK_BLK_EN  (0x1  24)
+#define PLL_READY  

Re: [V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-06 Thread Mark Rutland
Hi,

I have a few comments on the devicetree binding and the way it's parsed.

I note many are similar to those I commented on for the mv_udc and ehci-mv
devicetree code.

On Wed, Feb 06, 2013 at 07:23:36AM +, Chao Xie wrote:
 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 chao@marvell.com
 ---
  drivers/usb/phy/Kconfig  |7 +
  drivers/usb/phy/Makefile |1 +
  drivers/usb/phy/mv_usb2_phy.c|  454 
 ++
  include/linux/platform_data/mv_usb.h |9 +-
  include/linux/usb/mv_usb2.h  |   43 
  5 files changed, 511 insertions(+), 3 deletions(-)
  create mode 100644 drivers/usb/phy/mv_usb2_phy.c
  create mode 100644 include/linux/usb/mv_usb2.h


[...]

 +static struct of_device_id usb_phy_dt_ids[] = {
 +   { .compatible = mrvl,pxa168-usb-phy,  .data = (void *)PXA168_USB},
 +   { .compatible = mrvl,pxa910-usb-phy,  .data = (void *)PXA910_USB},
 +   { .compatible = mrvl,mmp2-usb-phy,.data = (void *)MMP2_USB},
 +   {}
 +};
 +MODULE_DEVICE_TABLE(of, usb_phy_dt_ids);

The binding (including these compatible string) needs to be documented.

 +
 +static int usb_phy_parse_dt(struct platform_device *pdev,
 +   struct mv_usb2_phy *mv_phy)
 +{
 +   struct device_node *np = pdev-dev.of_node;
 +   const struct of_device_id *of_id =
 +   of_match_device(usb_phy_dt_ids, pdev-dev);
 +   unsigned int clks_num;
 +   int i, ret;
 +   const char *clk_name;
 +
 +   if (!np)
 +   return 1;

An actual error code please.

-ENODEV? -EINVAL?

 +
 +   clks_num = of_property_count_strings(np, clocks);
 +   if (clks_num  0) {
 +   dev_err(pdev-dev, failed to get clock number\n);
 +   return clks_num;
 +   }

The common clock bindings use clocks as a list of phandle and clock-specifier
pairs. It seems bad to reuse that name in a different sense for this binding.

I'd recommend you use the common clock binding. There doesn't seem to be an
of_clk_count, but it should be a relatively simple addition, and it'd make this
code clearer and more consistent with other drivers.

See Documentation/devicetree/bindings/clock/clock-bindings.txt

 +
 +   mv_phy-clks = devm_kzalloc(pdev-dev,
 +   sizeof(struct clk *) * clks_num, GFP_KERNEL);
 +   if (mv_phy-clks == NULL) {
 +   dev_err(pdev-dev,
 +   failed to allocate mempory for clocks);

s/mempory/memory/

 +   return -ENOMEM;
 +   }
 +
 +   for (i = 0; i  clks_num; i++) {
 +   ret = of_property_read_string_index(np, clocks, i,
 +   clk_name);
 +   if (ret) {
 +   dev_err(pdev-dev, failed to read clocks\n);
 +   return ret;
 +   }
 +   mv_phy-clks[i] = devm_clk_get(pdev-dev, clk_name);
 +   if (IS_ERR(mv_phy-clks[i])) {
 +   dev_err(pdev-dev, failed to get clock %s\n,
 +   clk_name);
 +   return PTR_ERR(mv_phy-clks[i]);
 +   }
 +   }
 +
 +   mv_phy-clks_num = clks_num;
 +   mv_phy-type = (enum mv_usb2_phy_type)(of_id-data);
 +
 +   return 0;
 +}

There's probably a need for something like devm_of_clk_get to make it easier to
write of-backed drivers.

 +
 +static int usb_phy_probe(struct platform_device *pdev)
 +{
 +   struct mv_usb2_phy *mv_phy;
 +   struct resource *r;
 +   int ret, i;
 +
 +   mv_phy = devm_kzalloc(pdev-dev, sizeof(*mv_phy), GFP_KERNEL);
 +   if (mv_phy == NULL) {
 +   dev_err(pdev-dev, failed to allocate memory\n);
 +   return -ENOMEM;
 +   }
 +   mutex_init(mv_phy-phy_lock);
 +
 +   ret = usb_phy_parse_dt(pdev, mv_phy);
 +   /* no CONFIG_OF */
 +   if (ret  0) {

Reorganise this so you test for pdev-dev.of_node, and based of that you either
call usb_phy_parse_dt or do this stuff in the block below. That way you don't 
need
the positive return code from usb_phy_parse_dt.

 +   struct mv_usb_phy_platform_data *pdata
 +   = pdev-dev.platform_data;
 +   const struct platform_device_id *id
 +   = platform_get_device_id(pdev);
 +
 +   if (pdata == NULL || id == NULL) {
 +   dev_err(pdev-dev,
 +   missing platform_data or id_entry\n);
 +   return -ENODEV;
 +   

Re: [V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-06 Thread Chao Xie
On Wed, Feb 6, 2013 at 10:42 PM, Mark Rutland mark.rutl...@arm.com wrote:
 Hi,

 I have a few comments on the devicetree binding and the way it's parsed.

 I note many are similar to those I commented on for the mv_udc and ehci-mv
 devicetree code.

 On Wed, Feb 06, 2013 at 07:23:36AM +, Chao Xie wrote:
 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 chao@marvell.com
 ---
  drivers/usb/phy/Kconfig  |7 +
  drivers/usb/phy/Makefile |1 +
  drivers/usb/phy/mv_usb2_phy.c|  454 
 ++
  include/linux/platform_data/mv_usb.h |9 +-
  include/linux/usb/mv_usb2.h  |   43 
  5 files changed, 511 insertions(+), 3 deletions(-)
  create mode 100644 drivers/usb/phy/mv_usb2_phy.c
  create mode 100644 include/linux/usb/mv_usb2.h


 [...]

 +static struct of_device_id usb_phy_dt_ids[] = {
 +   { .compatible = mrvl,pxa168-usb-phy,  .data = (void *)PXA168_USB},
 +   { .compatible = mrvl,pxa910-usb-phy,  .data = (void *)PXA910_USB},
 +   { .compatible = mrvl,mmp2-usb-phy,.data = (void *)MMP2_USB},
 +   {}
 +};
 +MODULE_DEVICE_TABLE(of, usb_phy_dt_ids);

 The binding (including these compatible string) needs to be documented.

 +
 +static int usb_phy_parse_dt(struct platform_device *pdev,
 +   struct mv_usb2_phy *mv_phy)
 +{
 +   struct device_node *np = pdev-dev.of_node;
 +   const struct of_device_id *of_id =
 +   of_match_device(usb_phy_dt_ids, pdev-dev);
 +   unsigned int clks_num;
 +   int i, ret;
 +   const char *clk_name;
 +
 +   if (!np)
 +   return 1;

 An actual error code please.

 -ENODEV? -EINVAL?

 +
 +   clks_num = of_property_count_strings(np, clocks);
 +   if (clks_num  0) {
 +   dev_err(pdev-dev, failed to get clock number\n);
 +   return clks_num;
 +   }

 The common clock bindings use clocks as a list of phandle and 
 clock-specifier
 pairs. It seems bad to reuse that name in a different sense for this binding.

 I'd recommend you use the common clock binding. There doesn't seem to be an
 of_clk_count, but it should be a relatively simple addition, and it'd make 
 this
 code clearer and more consistent with other drivers.

 See Documentation/devicetree/bindings/clock/clock-bindings.txt

 +
 +   mv_phy-clks = devm_kzalloc(pdev-dev,
 +   sizeof(struct clk *) * clks_num, GFP_KERNEL);
 +   if (mv_phy-clks == NULL) {
 +   dev_err(pdev-dev,
 +   failed to allocate mempory for clocks);

 s/mempory/memory/

 +   return -ENOMEM;
 +   }
 +
 +   for (i = 0; i  clks_num; i++) {
 +   ret = of_property_read_string_index(np, clocks, i,
 +   clk_name);
 +   if (ret) {
 +   dev_err(pdev-dev, failed to read clocks\n);
 +   return ret;
 +   }
 +   mv_phy-clks[i] = devm_clk_get(pdev-dev, clk_name);
 +   if (IS_ERR(mv_phy-clks[i])) {
 +   dev_err(pdev-dev, failed to get clock %s\n,
 +   clk_name);
 +   return PTR_ERR(mv_phy-clks[i]);
 +   }
 +   }
 +
 +   mv_phy-clks_num = clks_num;
 +   mv_phy-type = (enum mv_usb2_phy_type)(of_id-data);
 +
 +   return 0;
 +}

 There's probably a need for something like devm_of_clk_get to make it easier 
 to
 write of-backed drivers.

 +
 +static int usb_phy_probe(struct platform_device *pdev)
 +{
 +   struct mv_usb2_phy *mv_phy;
 +   struct resource *r;
 +   int ret, i;
 +
 +   mv_phy = devm_kzalloc(pdev-dev, sizeof(*mv_phy), GFP_KERNEL);
 +   if (mv_phy == NULL) {
 +   dev_err(pdev-dev, failed to allocate memory\n);
 +   return -ENOMEM;
 +   }
 +   mutex_init(mv_phy-phy_lock);
 +
 +   ret = usb_phy_parse_dt(pdev, mv_phy);
 +   /* no CONFIG_OF */
 +   if (ret  0) {

 Reorganise this so you test for pdev-dev.of_node, and based of that you 
 either
 call usb_phy_parse_dt or do this stuff in the block below. That way you don't 
 need
 the positive return code from usb_phy_parse_dt.

 +   struct mv_usb_phy_platform_data *pdata
 +   = pdev-dev.platform_data;
 +   const struct platform_device_id *id
 +   = platform_get_device_id(pdev);
 +
 +   if (pdata == NULL || id == NULL) {
 +   dev_err(pdev-dev,
 +

Re: [V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-06 Thread Chao Xie
On Wed, Feb 6, 2013 at 6:35 PM, kishon kis...@ti.com wrote:
 Hi,


 On Wednesday 06 February 2013 01:48 PM, Chao Xie wrote:

 On Wed, Feb 6, 2013 at 4:10 PM, kishon kis...@ti.com wrote:

 Hi,


 On Wednesday 06 February 2013 12:53 PM, Chao Xie wrote:


 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 chao@marvell.com
 ---
drivers/usb/phy/Kconfig  |7 +
drivers/usb/phy/Makefile |1 +
drivers/usb/phy/mv_usb2_phy.c|  454
 ++
include/linux/platform_data/mv_usb.h |9 +-
include/linux/usb/mv_usb2.h  |   43 
5 files changed, 511 insertions(+), 3 deletions(-)
create mode 100644 drivers/usb/phy/mv_usb2_phy.c
create mode 100644 include/linux/usb/mv_usb2.h

 diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
 index 65217a5..5479760 100644
 --- a/drivers/usb/phy/Kconfig
 +++ b/drivers/usb/phy/Kconfig
 @@ -73,3 +73,10 @@ config SAMSUNG_USBPHY
  help
Enable this to support Samsung USB phy controller for samsung
SoCs.
 +
 +config MV_USB2_PHY
 +   tristate Marvell USB 2.0 PHY Driver
 +   depends on USB || USB_GADGET
 +   help
 + Enable this to support Marvell USB 2.0 phy driver for Marvell
 + SoC.
 diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
 index b13faa1..3835316 100644
 --- a/drivers/usb/phy/Makefile
 +++ b/drivers/usb/phy/Makefile
 @@ -12,3 +12,4 @@ obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
obj-$(CONFIG_USB_RCAR_PHY)+= rcar-phy.o
obj-$(CONFIG_SAMSUNG_USBPHY)  += samsung-usbphy.o
 +obj-$(CONFIG_MV_USB2_PHY)  += mv_usb2_phy.o
 diff --git a/drivers/usb/phy/mv_usb2_phy.c
 b/drivers/usb/phy/mv_usb2_phy.c
 new file mode 100644
 index 000..c2bccae
 --- /dev/null
 +++ b/drivers/usb/phy/mv_usb2_phy.c
 @@ -0,0 +1,454 @@
 +/*
 + * Copyright (C) 2010 Google, Inc.
 + *
 + * Author:
 + * Chao Xie xiechao.m...@gmail.com
 + *
 + * 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 linux/resource.h
 +#include linux/delay.h
 +#include linux/slab.h
 +#include linux/of.h
 +#include linux/of_device.h
 +#include linux/io.h
 +#include linux/err.h
 +#include linux/clk.h
 +#include linux/export.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/platform_data/mv_usb.h
 +#include linux/usb/mv_usb2.h
 +
 +/* phy regs */
 +#define UTMI_REVISION  0x0
 +#define UTMI_CTRL  0x4
 +#define UTMI_PLL   0x8
 +#define UTMI_TX0xc
 +#define UTMI_RX0x10
 +#define UTMI_IVREF 0x14
 +#define UTMI_T00x18
 +#define UTMI_T10x1c
 +#define UTMI_T20x20
 +#define UTMI_T30x24
 +#define UTMI_T40x28
 +#define UTMI_T50x2c
 +#define UTMI_RESERVE   0x30
 +#define UTMI_USB_INT   0x34
 +#define UTMI_DBG_CTL   0x38
 +#define UTMI_OTG_ADDON 0x3c
 +
 +/* For UTMICTRL Register */
 +#define UTMI_CTRL_USB_CLK_EN(1  31)
 +/* pxa168 */
 +#define UTMI_CTRL_SUSPEND_SET1  (1  30)
 +#define UTMI_CTRL_SUSPEND_SET2  (1  29)
 +#define UTMI_CTRL_RXBUF_PDWN(1  24)
 +#define UTMI_CTRL_TXBUF_PDWN(1  11)
 +
 +#define UTMI_CTRL_INPKT_DELAY_SHIFT 30
 +#define UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
 +#define UTMI_CTRL_PU_REF_SHIFT 20
 +#define UTMI_CTRL_ARC_PULLDN_SHIFT  12
 +#define UTMI_CTRL_PLL_PWR_UP_SHIFT  1
 +#define UTMI_CTRL_PWR_UP_SHIFT  0
 +
 +/* For UTMI_PLL Register */
 +#define UTMI_PLL_PLLCALI12_SHIFT   29
 +#define UTMI_PLL_PLLCALI12_MASK(0x3  29)
 +
 +#define UTMI_PLL_PLLVDD18_SHIFT27
 +#define UTMI_PLL_PLLVDD18_MASK (0x3  27)
 +
 +#define UTMI_PLL_PLLVDD12_SHIFT25
 +#define 

Re: [V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-06 Thread kishon

Hi,

On Thursday 07 February 2013 07:56 AM, Chao Xie wrote:

On Wed, Feb 6, 2013 at 6:35 PM, kishon kis...@ti.com wrote:

Hi,


On Wednesday 06 February 2013 01:48 PM, Chao Xie wrote:


On Wed, Feb 6, 2013 at 4:10 PM, kishon kis...@ti.com wrote:


Hi,


On Wednesday 06 February 2013 12:53 PM, Chao Xie wrote:



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 chao@marvell.com
---
drivers/usb/phy/Kconfig  |7 +
drivers/usb/phy/Makefile |1 +
drivers/usb/phy/mv_usb2_phy.c|  454
++
include/linux/platform_data/mv_usb.h |9 +-
include/linux/usb/mv_usb2.h  |   43 
5 files changed, 511 insertions(+), 3 deletions(-)
create mode 100644 drivers/usb/phy/mv_usb2_phy.c
create mode 100644 include/linux/usb/mv_usb2.h

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 65217a5..5479760 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -73,3 +73,10 @@ config SAMSUNG_USBPHY
  help
Enable this to support Samsung USB phy controller for samsung
SoCs.
+
+config MV_USB2_PHY
+   tristate Marvell USB 2.0 PHY Driver
+   depends on USB || USB_GADGET
+   help
+ Enable this to support Marvell USB 2.0 phy driver for Marvell
+ SoC.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b13faa1..3835316 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
obj-$(CONFIG_USB_EHCI_TEGRA)  += tegra_usb_phy.o
obj-$(CONFIG_USB_RCAR_PHY)+= rcar-phy.o
obj-$(CONFIG_SAMSUNG_USBPHY)  += samsung-usbphy.o
+obj-$(CONFIG_MV_USB2_PHY)  += mv_usb2_phy.o
diff --git a/drivers/usb/phy/mv_usb2_phy.c
b/drivers/usb/phy/mv_usb2_phy.c
new file mode 100644
index 000..c2bccae
--- /dev/null
+++ b/drivers/usb/phy/mv_usb2_phy.c
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * Author:
+ * Chao Xie xiechao.m...@gmail.com
+ *
+ * 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 linux/resource.h
+#include linux/delay.h
+#include linux/slab.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/io.h
+#include linux/err.h
+#include linux/clk.h
+#include linux/export.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/platform_data/mv_usb.h
+#include linux/usb/mv_usb2.h
+
+/* phy regs */
+#define UTMI_REVISION  0x0
+#define UTMI_CTRL  0x4
+#define UTMI_PLL   0x8
+#define UTMI_TX0xc
+#define UTMI_RX0x10
+#define UTMI_IVREF 0x14
+#define UTMI_T00x18
+#define UTMI_T10x1c
+#define UTMI_T20x20
+#define UTMI_T30x24
+#define UTMI_T40x28
+#define UTMI_T50x2c
+#define UTMI_RESERVE   0x30
+#define UTMI_USB_INT   0x34
+#define UTMI_DBG_CTL   0x38
+#define UTMI_OTG_ADDON 0x3c
+
+/* For UTMICTRL Register */
+#define UTMI_CTRL_USB_CLK_EN(1  31)
+/* pxa168 */
+#define UTMI_CTRL_SUSPEND_SET1  (1  30)
+#define UTMI_CTRL_SUSPEND_SET2  (1  29)
+#define UTMI_CTRL_RXBUF_PDWN(1  24)
+#define UTMI_CTRL_TXBUF_PDWN(1  11)
+
+#define UTMI_CTRL_INPKT_DELAY_SHIFT 30
+#define UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
+#define UTMI_CTRL_PU_REF_SHIFT 20
+#define UTMI_CTRL_ARC_PULLDN_SHIFT  12
+#define UTMI_CTRL_PLL_PWR_UP_SHIFT  1
+#define UTMI_CTRL_PWR_UP_SHIFT  0
+
+/* For UTMI_PLL Register */
+#define UTMI_PLL_PLLCALI12_SHIFT   29
+#define UTMI_PLL_PLLCALI12_MASK(0x3  29)
+
+#define UTMI_PLL_PLLVDD18_SHIFT27
+#define UTMI_PLL_PLLVDD18_MASK (0x3  27)
+
+#define UTMI_PLL_PLLVDD12_SHIFT25
+#define UTMI_PLL_PLLVDD12_MASK (0x3  25)

[V6 PATCH 01/16] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller

2013-02-05 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 chao@marvell.com
---
 drivers/usb/phy/Kconfig  |7 +
 drivers/usb/phy/Makefile |1 +
 drivers/usb/phy/mv_usb2_phy.c|  454 ++
 include/linux/platform_data/mv_usb.h |9 +-
 include/linux/usb/mv_usb2.h  |   43 
 5 files changed, 511 insertions(+), 3 deletions(-)
 create mode 100644 drivers/usb/phy/mv_usb2_phy.c
 create mode 100644 include/linux/usb/mv_usb2.h

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 65217a5..5479760 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -73,3 +73,10 @@ config SAMSUNG_USBPHY
help
  Enable this to support Samsung USB phy controller for samsung
  SoCs.
+
+config MV_USB2_PHY
+   tristate Marvell USB 2.0 PHY Driver
+   depends on USB || USB_GADGET
+   help
+ Enable this to support Marvell USB 2.0 phy driver for Marvell
+ SoC.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b13faa1..3835316 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_MV_U3D_PHY)  += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
 obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
 obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
+obj-$(CONFIG_MV_USB2_PHY)  += mv_usb2_phy.o
diff --git a/drivers/usb/phy/mv_usb2_phy.c b/drivers/usb/phy/mv_usb2_phy.c
new file mode 100644
index 000..c2bccae
--- /dev/null
+++ b/drivers/usb/phy/mv_usb2_phy.c
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * Author:
+ * Chao Xie xiechao.m...@gmail.com
+ *
+ * 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 linux/resource.h
+#include linux/delay.h
+#include linux/slab.h
+#include linux/of.h
+#include linux/of_device.h
+#include linux/io.h
+#include linux/err.h
+#include linux/clk.h
+#include linux/export.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/platform_data/mv_usb.h
+#include linux/usb/mv_usb2.h
+
+/* phy regs */
+#define UTMI_REVISION  0x0
+#define UTMI_CTRL  0x4
+#define UTMI_PLL   0x8
+#define UTMI_TX0xc
+#define UTMI_RX0x10
+#define UTMI_IVREF 0x14
+#define UTMI_T00x18
+#define UTMI_T10x1c
+#define UTMI_T20x20
+#define UTMI_T30x24
+#define UTMI_T40x28
+#define UTMI_T50x2c
+#define UTMI_RESERVE   0x30
+#define UTMI_USB_INT   0x34
+#define UTMI_DBG_CTL   0x38
+#define UTMI_OTG_ADDON 0x3c
+
+/* For UTMICTRL Register */
+#define UTMI_CTRL_USB_CLK_EN(1  31)
+/* pxa168 */
+#define UTMI_CTRL_SUSPEND_SET1  (1  30)
+#define UTMI_CTRL_SUSPEND_SET2  (1  29)
+#define UTMI_CTRL_RXBUF_PDWN(1  24)
+#define UTMI_CTRL_TXBUF_PDWN(1  11)
+
+#define UTMI_CTRL_INPKT_DELAY_SHIFT 30
+#define UTMI_CTRL_INPKT_DELAY_SOF_SHIFT28
+#define UTMI_CTRL_PU_REF_SHIFT 20
+#define UTMI_CTRL_ARC_PULLDN_SHIFT  12
+#define UTMI_CTRL_PLL_PWR_UP_SHIFT  1
+#define UTMI_CTRL_PWR_UP_SHIFT  0
+
+/* For UTMI_PLL Register */
+#define UTMI_PLL_PLLCALI12_SHIFT   29
+#define UTMI_PLL_PLLCALI12_MASK(0x3  29)
+
+#define UTMI_PLL_PLLVDD18_SHIFT27
+#define UTMI_PLL_PLLVDD18_MASK (0x3  27)
+
+#define UTMI_PLL_PLLVDD12_SHIFT25
+#define UTMI_PLL_PLLVDD12_MASK (0x3  25)
+
+#define UTMI_PLL_CLK_BLK_EN_SHIFT   24
+#define CLK_BLK_EN  (0x1  24)
+#define PLL_READY   (0x1  23)
+#define KVCO_EXT(0x1  22)
+#define VCOCAL_START(0x1  21)
+
+#define UTMI_PLL_KVCO_SHIFT15