All of lore.kernel.org
 help / color / mirror / Atom feed
* [V9 PATCH 00/12] mv-usb phy driver
@ 2013-04-24  6:23 Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces Chao Xie
                   ` (11 more replies)
  0 siblings, 12 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-29 18:24   ` Felipe Balbi
  2013-04-24  6:23 ` [V9 PATCH 02/12] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller Chao Xie
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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 <chao.xie@marvell.com>
---
 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_head	head;
 
+	/*
+	 * PHY may be shared by multiple devices.
+	 * mutex and refcount are used to make sure PHY only initialize or
+	 * shutdown once.
+	 */
+	struct mutex		phy_mutex;
+	unsigned int		refcount;
+
 	/* 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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 02/12] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 03/12] usb: gadget: mv_udc: use PHY driver for udc Chao Xie
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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.xie@marvell.com>
---
 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 0000000..43459ef
--- /dev/null
+++ b/drivers/usb/phy/phy-mv-usb2.c
@@ -0,0 +1,379 @@
+/*
+ * Copyright (C) 2013 Marvell Inc.
+ *
+ * Author:
+ *	Chao Xie <xiechao.mail@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/phy.h>
+#include <linux/usb/mv_usb2.h>
+
+/* 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_TX			0xc
+#define MV_USB2_UTMI_RX			0x10
+#define MV_USB2_UTMI_IVREF		0x14
+#define MV_USB2_UTMI_T0			0x18
+#define MV_USB2_UTMI_T1			0x1c
+#define MV_USB2_UTMI_T2			0x20
+#define MV_USB2_UTMI_T3			0x24
+#define MV_USB2_UTMI_T4			0x28
+#define MV_USB2_UTMI_T5			0x2c
+#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_SHIFT		30
+#define MV_USB2_UTMI_CTRL_INPKT_DELAY_SOF_SHIFT		28
+#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_SHIFT			27
+#define MV_USB2_UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
+
+#define MV_USB2_UTMI_PLL_PLLVDD12_SHIFT			25
+#define MV_USB2_UTMI_PLL_PLLVDD12_MASK			(0x3 << 25)
+
+#define MV_USB2_UTMI_PLL_PLL_READY			(0x1 << 23)
+#define MV_USB2_UTMI_PLL_KVCO_EXT			(0x1 << 22)
+#define MV_USB2_UTMI_PLL_VCOCAL_START			(0x1 << 21)
+
+#define MV_USB2_UTMI_PLL_KVCO_SHIFT			15
+#define MV_USB2_UTMI_PLL_KVCO_MASK			(0x7 << 15)
+
+#define MV_USB2_UTMI_PLL_ICP_SHIFT			12
+#define MV_USB2_UTMI_PLL_ICP_MASK			(0x7 << 12)
+
+#define MV_USB2_UTMI_PLL_FBDIV_SHIFT			4
+#define MV_USB2_UTMI_PLL_FBDIV_MASK			(0xFF << 4)
+
+#define MV_USB2_UTMI_PLL_REFDIV_SHIFT			0
+#define MV_USB2_UTMI_PLL_REFDIV_MASK			(0xF << 0)
+
+/* For UTMI_TX Register */
+#define MV_USB2_UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
+#define MV_USB2_UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
+
+#define MV_USB2_UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
+#define MV_USB2_UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
+
+#define MV_USB2_UTMI_TX_TXVDD12_SHIFT			22
+#define MV_USB2_UTMI_TX_TXVDD12_MASK			(0x3 << 22)
+
+#define MV_USB2_UTMI_TX_CK60_PHSEL_SHIFT		17
+#define MV_USB2_UTMI_TX_CK60_PHSEL_MASK			(0xf << 17)
+
+#define MV_USB2_UTMI_TX_IMPCAL_VTH_SHIFT		14
+#define MV_USB2_UTMI_TX_IMPCAL_VTH_MASK			(0x7 << 14)
+
+#define MV_USB2_UTMI_TX_REG_RCAL_START			(0x1 << 12)
+
+#define MV_USB2_UTMI_TX_LOW_VDD_EN_SHIFT		11
+
+#define MV_USB2_UTMI_TX_AMP_SHIFT			0
+#define MV_USB2_UTMI_TX_AMP_MASK			(0x7 << 0)
+
+/* For UTMI_RX Register */
+#define MV_USB2_UTMI_RX_REG_SQ_LENGTH_SHIFT		15
+#define MV_USB2_UTMI_RX_REG_SQ_LENGTH_MASK		(0x3 << 15)
+
+#define MV_USB2_UTMI_RX_SQ_THRESH_SHIFT			4
+#define MV_USB2_UTMI_RX_SQ_THRESH_MASK			(0xf << 4)
+
+/* For UTMI_OTG_ADDON Register. Only for pxa168 */
+#define MV_USB2_UTMI_OTG_ADDON_OTG_ON			(1 << 0)
+
+enum mv_usb2_phy_type {
+	PXA168_USB,
+	PXA910_USB,
+	MMP2_USB,
+};
+
+static int _mv_usb2_phy_init(struct mv_usb2_phy *mv_phy)
+{
+	struct platform_device *pdev = mv_phy->pdev;
+	unsigned int loops = 0;
+	void __iomem *base = mv_phy->base;
+	unsigned int val;
+
+	val = readl(base + MV_USB2_UTMI_CTRL);
+	/* Initialize the USB PHY power */
+	if (mv_phy->type == PXA910_USB) {
+		val |= (1 << MV_USB2_UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
+			| (1 << MV_USB2_UTMI_CTRL_PU_REF_SHIFT);
+	}
+
+	val |= (1 << MV_USB2_UTMI_CTRL_PLL_PWR_UP_SHIFT)
+		| (1 << MV_USB2_UTMI_CTRL_PWR_UP_SHIFT);
+	writel(val, base + MV_USB2_UTMI_CTRL);
+
+	/* UTMI_PLL settings */
+	val = readl(base + MV_USB2_UTMI_PLL);
+	val &= ~(MV_USB2_UTMI_PLL_PLLVDD18_MASK
+		| MV_USB2_UTMI_PLL_PLLVDD12_MASK
+		| MV_USB2_UTMI_PLL_PLLCALI12_MASK
+		| MV_USB2_UTMI_PLL_FBDIV_MASK
+		| MV_USB2_UTMI_PLL_REFDIV_MASK
+		| MV_USB2_UTMI_PLL_ICP_MASK
+		| MV_USB2_UTMI_PLL_KVCO_MASK
+		| MV_USB2_UTMI_PLL_VCOCAL_START);
+
+	val |= (0xee << MV_USB2_UTMI_PLL_FBDIV_SHIFT)
+		| (0xb << MV_USB2_UTMI_PLL_REFDIV_SHIFT)
+		| (3 << MV_USB2_UTMI_PLL_PLLVDD18_SHIFT)
+		| (3 << MV_USB2_UTMI_PLL_PLLVDD12_SHIFT)
+		| (3 << MV_USB2_UTMI_PLL_PLLCALI12_SHIFT)
+		| (1 << MV_USB2_UTMI_PLL_ICP_SHIFT)
+		| (3 << MV_USB2_UTMI_PLL_KVCO_SHIFT);
+	writel(val, base + MV_USB2_UTMI_PLL);
+
+	/* UTMI_TX */
+	val = readl(base + MV_USB2_UTMI_TX);
+	val &= ~(MV_USB2_UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
+		| MV_USB2_UTMI_TX_TXVDD12_MASK
+		| MV_USB2_UTMI_TX_CK60_PHSEL_MASK
+		| MV_USB2_UTMI_TX_IMPCAL_VTH_MASK
+		| MV_USB2_UTMI_TX_REG_EXT_FS_RCAL_MASK
+		| MV_USB2_UTMI_TX_AMP_MASK
+		| MV_USB2_UTMI_TX_REG_RCAL_START);
+	val |= (3 << MV_USB2_UTMI_TX_TXVDD12_SHIFT)
+		| (4 << MV_USB2_UTMI_TX_CK60_PHSEL_SHIFT)
+		| (4 << MV_USB2_UTMI_TX_IMPCAL_VTH_SHIFT)
+		| (8 << MV_USB2_UTMI_TX_REG_EXT_FS_RCAL_SHIFT)
+		| (3 << MV_USB2_UTMI_TX_AMP_SHIFT);
+	writel(val, base + MV_USB2_UTMI_TX);
+
+	/* UTMI_RX */
+	val = readl(base + MV_USB2_UTMI_RX);
+	val &= ~(MV_USB2_UTMI_RX_SQ_THRESH_MASK
+		| MV_USB2_UTMI_RX_REG_SQ_LENGTH_MASK);
+	val |= (7 << MV_USB2_UTMI_RX_SQ_THRESH_SHIFT)
+		| (2 << MV_USB2_UTMI_RX_REG_SQ_LENGTH_SHIFT);
+	writel(val, base + MV_USB2_UTMI_RX);
+
+	/* UTMI_IVREF */
+	if (mv_phy->type == PXA168_USB)
+		/*
+		 * Fixing Microsoft Altair board interface with NEC hub issue -
+		 * Set UTMI_IVREF from 0x4a3 to 0x4bf.
+		 */
+		writel(0x4bf, base + MV_USB2_UTMI_IVREF);
+
+	/*
+	 * Toggle VCOCAL_START bit of UTMI_PLL. It is active at rising edge.
+	 * It is low level by UTMI_PLL initialization above.
+	 */
+	val = readl(base + MV_USB2_UTMI_PLL);
+	/*
+	 * Delay 200us for low level, and 40us for high level.
+	 * Make sure we can get a effective rising edege.
+	 * It should be set to low after issue rising edge.
+	 * The delay value is suggested by DE.
+	 */
+	usleep_range(200, 300);
+	val |= MV_USB2_UTMI_PLL_VCOCAL_START;
+	writel(val, base + MV_USB2_UTMI_PLL);
+	usleep_range(40, 50);
+	val &= ~MV_USB2_UTMI_PLL_VCOCAL_START;
+	writel(val, base + MV_USB2_UTMI_PLL);
+
+	/*
+	 * Toggle REG_RCAL_START bit of UTMI_TX.
+	 * it is low level by UTMI_TX initialization above.
+	 */
+	val = readl(base + MV_USB2_UTMI_TX);
+	/* same as VCOCAL_START, except it is triggered by low->high->low */
+	usleep_range(400, 500);
+	val |= MV_USB2_UTMI_TX_REG_RCAL_START;
+	writel(val, base + MV_USB2_UTMI_TX);
+	usleep_range(40, 50);
+	val &= ~MV_USB2_UTMI_TX_REG_RCAL_START;
+	writel(val, base + MV_USB2_UTMI_TX);
+	usleep_range(400, 500);
+
+	/* Make sure PHY PLL is ready */
+	loops = 0;
+	while (1) {
+		val = readl(base + MV_USB2_UTMI_PLL);
+		if (val & MV_USB2_UTMI_PLL_PLL_READY)
+			break;
+		usleep_range(1000, 1100);
+		loops++;
+		if (loops > 100) {
+			dev_warn(&pdev->dev, "calibrate timeout, UTMI_PLL %x\n",
+				 readl(base + MV_USB2_UTMI_PLL));
+			return -ETIME;
+		}
+	}
+
+	if (mv_phy->type == PXA168_USB) {
+		val = readl(base + MV_USB2_UTMI_RESERVE);
+		val |= (1 << 5);
+		writel(val, base + MV_USB2_UTMI_RESERVE);
+		/* Turn on UTMI PHY OTG extension */
+		writel(MV_USB2_UTMI_OTG_ADDON_OTG_ON,
+		       base + MV_USB2_UTMI_OTG_ADDON);
+	}
+
+	return 0;
+}
+
+static int _mv_usb2_phy_shutdown(struct mv_usb2_phy *mv_phy)
+{
+	void __iomem *base = mv_phy->base;
+	unsigned int val;
+
+	if (mv_phy->type == PXA168_USB)
+		writel(0, base + MV_USB2_UTMI_OTG_ADDON);
+
+	val = readl(base + MV_USB2_UTMI_CTRL);
+	val &= ~(MV_USB2_UTMI_CTRL_RXBUF_PDWN
+		| MV_USB2_UTMI_CTRL_TXBUF_PDWN
+		| MV_USB2_UTMI_CTRL_USB_CLK_EN
+		| (1 << MV_USB2_UTMI_CTRL_PWR_UP_SHIFT)
+		| (1 << MV_USB2_UTMI_CTRL_PLL_PWR_UP_SHIFT));
+
+	writel(val, base + MV_USB2_UTMI_CTRL);
+
+	return 0;
+}
+
+static int mv_usb2_phy_init(struct usb_phy *phy)
+{
+	struct mv_usb2_phy *mv_phy = container_of(phy, struct mv_usb2_phy, phy);
+
+	clk_prepare_enable(mv_phy->clk);
+	_mv_usb2_phy_init(mv_phy);
+
+	return 0;
+}
+
+static void mv_usb2_phy_shutdown(struct usb_phy *phy)
+{
+	struct mv_usb2_phy *mv_phy = container_of(phy, struct mv_usb2_phy, phy);
+
+	_mv_usb2_phy_shutdown(mv_phy);
+	clk_disable_unprepare(mv_phy->clk);
+}
+
+static int mv_usb2_phy_probe(struct platform_device *pdev)
+{
+	struct mv_usb2_phy *mv_phy;
+	struct resource *r;
+	const struct platform_device_id *id;
+
+	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;
+	}
+
+	id = platform_get_device_id(pdev);
+
+	if (id == NULL) {
+		dev_err(&pdev->dev, "missing id_entry\n");
+		return -ENODEV;
+	}
+
+	mv_phy->type = (unsigned int)(id->driver_data);
+	mv_phy->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(mv_phy->clk)) {
+		dev_err(&pdev->dev, "failed to get clock.\n");
+		return PTR_ERR(mv_phy->clk);
+	}
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (r == NULL) {
+		dev_err(&pdev->dev, "no phy I/O memory resource defined\n");
+		return -ENODEV;
+	}
+	mv_phy->base = devm_ioremap_resource(&pdev->dev, r);
+	if (mv_phy->base == NULL) {
+		dev_err(&pdev->dev, "error map register base\n");
+		return -EBUSY;
+	}
+
+	mv_phy->phy.dev = &pdev->dev;
+	mv_phy->phy.label = "mv-usb2";
+	mv_phy->phy.type = USB_PHY_TYPE_USB2;
+	mv_phy->phy.init = mv_usb2_phy_init;
+	mv_phy->phy.shutdown = mv_usb2_phy_shutdown;
+
+	usb_add_phy_dev(&mv_phy->phy);
+
+	platform_set_drvdata(pdev, mv_phy);
+
+	return 0;
+}
+
+static int mv_usb2_phy_remove(struct platform_device *pdev)
+{
+	struct mv_usb2_phy *mv_phy = platform_get_drvdata(pdev);
+
+	usb_remove_phy(&mv_phy->phy);
+
+	platform_set_drvdata(pdev, NULL);
+
+	return 0;
+}
+
+static struct platform_device_id mv_usb2_phy_ids[] = {
+	{ .name = "pxa168-usb-phy",	.driver_data = PXA168_USB },
+	{ .name = "pxa910-usb-phy",	.driver_data = PXA910_USB },
+	{ .name = "mmp2-usb-phy",	.driver_data = MMP2_USB },
+	{}
+};
+
+static struct platform_driver mv_usb2_phy_driver = {
+	.probe	= mv_usb2_phy_probe,
+	.remove = mv_usb2_phy_remove,
+	.driver = {
+		.name   = "pxa168-usb-phy",
+	},
+	.id_table = mv_usb2_phy_ids,
+};
+
+module_platform_driver(mv_usb2_phy_driver);
+MODULE_ALIAS("platform: mv_usb2");
+MODULE_AUTHOR("Marvell Inc.");
+MODULE_DESCRIPTION("Marvell USB2 phy driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/usb/mv_usb2.h b/include/linux/usb/mv_usb2.h
new file mode 100644
index 0000000..dfabd4e
--- /dev/null
+++ b/include/linux/usb/mv_usb2.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2013 Marvell Inc.
+ *
+ * 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.
+ *
+ */
+
+#ifndef __MV_USB2_H
+#define __MV_USB2_H
+
+#define MV_USB2_PHY_INDEX	0
+#define MV_USB2_OTG_PHY_INDEX	1
+
+struct mv_usb2_phy {
+	struct usb_phy		phy;
+	struct platform_device	*pdev;
+	unsigned int		type;
+	void __iomem		*base;
+	struct clk		*clk;
+};
+
+#endif
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 03/12] usb: gadget: mv_udc: use PHY driver for udc
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 02/12] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 04/12] usb: ehci: ehci-mv: use PHY driver for ehci Chao Xie
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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 <chao.xie@marvell.com>
---
 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 int			max_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 <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/platform_data/mv_usb.h>
+#include <linux/usb/mv_usb2.h>
 #include <asm/unaligned.h>
 
 #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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 04/12] usb: ehci: ehci-mv: use PHY driver for ehci
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (2 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 03/12] usb: gadget: mv_udc: use PHY driver for udc Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 05/12] usb: phy: phy-mv-usb: use USB2 PHY driver for otg Chao Xie
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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 <chao.xie@marvell.com>
---
 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 <linux/clk.h>
 #include <linux/err.h>
 #include <linux/usb/otg.h>
+#include <linux/usb/mv_usb2.h>
 #include <linux/platform_data/mv_usb.h>
 
 #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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 05/12] usb: phy: phy-mv-usb: use USB2 PHY driver for otg
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (3 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 04/12] usb: ehci: ehci-mv: use PHY driver for ehci Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 06/12] usb: mv_u3d: usb phy drivers for phy operation Chao Xie
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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 <chao.xie@marvell.com>
---
 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 <linux/usb/otg.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/hcd.h>
+#include <linux/usb/mv_usb2.h>
 #include <linux/platform_data/mv_usb.h>
 
 #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_phy:
 	usb_remove_phy(&mvotg->phy);
 err_disable_clk:
 	mv_otg_disable_internal(mvotg);
diff --git a/drivers/usb/phy/phy-mv-usb.h b/drivers/usb/phy/phy-mv-usb.h
index 551da6e..6df6219 100644
--- a/drivers/usb/phy/phy-mv-usb.h
+++ b/drivers/usb/phy/phy-mv-usb.h
@@ -137,10 +137,10 @@ struct mv_otg_regs {
 
 struct mv_otg {
 	struct usb_phy phy;
+	struct usb_phy *outer_phy;
 	struct mv_otg_ctrl otg_ctrl;
 
 	/* base address */
-	void __iomem *phy_regs;
 	void __iomem *cap_regs;
 	struct mv_otg_regs __iomem *op_regs;
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 06/12] usb: mv_u3d: usb phy drivers for phy operation
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (4 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 05/12] usb: phy: phy-mv-usb: use USB2 PHY driver for otg Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 07/12] arm: mmp2: change the defintion of usb devices Chao Xie
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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 <chao.xie@marvell.com>
---
 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 int			max_eps;
 	struct mv_u3d_ep_context	*ep_context;
@@ -283,6 +282,8 @@ struct mv_u3d {
 	struct mv_usb_addon_irq *vbus;
 	unsigned int		power;
 
+	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 <linux/device.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
+#include <linux/usb/phy.h>
 #include <linux/pm.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -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)
 			(unsigned long) u3d->cap_regs);
 	}
 
-	/* we will access controller register, so enable the u3d controller */
-	clk_enable(u3d->clk);
+	u3d->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB3);
+	if (IS_ERR_OR_NULL(u3d->phy))
+		goto err_u3d_enable;
 
-	if (pdata->phy_init) {
-		retval = pdata->phy_init(u3d->phy_regs);
-		if (retval) {
-			dev_err(&dev->dev, "init phy error %d\n", retval);
-			goto err_u3d_enable;
-		}
+	retval = usb_phy_init(u3d->phy);
+	if (retval) {
+		dev_err(&dev->dev, "init phy error %d\n", retval);
+		goto err_u3d_enable;
 	}
 
 	u3d->op_regs = (struct mv_u3d_op_regs __iomem *)(u3d->cap_regs
@@ -1872,8 +1862,7 @@ static int mv_u3d_probe(struct platform_device *dev)
 	mv_u3d_controller_stop(u3d);
 	iowrite32(0xFFFFFFFF, &u3d->vuc_regs->intrcause);
 
-	if (pdata->phy_deinit)
-		pdata->phy_deinit(u3d->phy_regs);
+	usb_phy_shutdown(u3d->phy);
 	clk_disable(u3d->clk);
 
 	size = u3d->max_eps * sizeof(struct mv_u3d_ep_context) * 2;
@@ -1988,8 +1977,7 @@ err_alloc_trb_pool:
 	dma_free_coherent(&dev->dev, u3d->ep_context_size,
 		u3d->ep_context, u3d->ep_context_dma);
 err_alloc_ep_context:
-	if (pdata->phy_deinit)
-		pdata->phy_deinit(u3d->phy_regs);
+	usb_phy_shutdown(u3d->phy);
 	clk_disable(u3d->clk);
 err_u3d_enable:
 	iounmap(u3d->cap_regs);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 07/12] arm: mmp2: change the defintion of usb devices
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (5 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 06/12] usb: mv_u3d: usb phy drivers for phy operation Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 08/12] arm: pxa910: " Chao Xie
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

add the udc/otg/ehci devices for mmp2

Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
 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, 0xe0000000, 0x4000);
 /* 0xd1000000 ~ 0xd101ffff is reserved for secure processor */
 MMP2_DEVICE(isram, "isram", -1, NONE, 0xd1020000, 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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 08/12] arm: pxa910: change the defintion of usb devices
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (6 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 07/12] arm: mmp2: change the defintion of usb devices Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 09/12] arm: ttc_dkb: modify usb support Chao Xie
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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 <chao.xie@marvell.com>
---
 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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 09/12] arm: ttc_dkb: modify usb support
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (7 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 08/12] arm: pxa910: " Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 10/12] arm: mmp: remove unused usb devices Chao Xie
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

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 <chao.xie@marvell.com>
---
 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 <linux/i2c/pca953x.h>
 #include <linux/gpio.h>
 #include <linux/mfd/88pm860x.h>
+#include <linux/usb/phy.h>
+#include <linux/usb/mv_usb2.h>
 #include <linux/platform_data/mv_usb.h>
 #include <linux/spi/spi.h>
 #include <linux/delay.h>
@@ -29,7 +31,6 @@
 #include <mach/mfp-pxa910.h>
 #include <mach/pxa910.h>
 #include <mach/irqs.h>
-#include <mach/regs-usb.h>
 
 #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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 10/12] arm: mmp: remove unused usb devices
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (8 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 09/12] arm: ttc_dkb: modify usb support Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 11/12] arm: brownstone: add usb support for the board Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 12/12] usb: mv_usb: remove the phy callbacks in pdata Chao Xie
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

We defined new usb devices for usb ehci/udc/otg/phy.
So remove the old definitions.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
 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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 11/12] arm: brownstone: add usb support for the board
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (9 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 10/12] arm: mmp: remove unused usb devices Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  2013-04-24  6:23 ` [V9 PATCH 12/12] usb: mv_usb: remove the phy callbacks in pdata Chao Xie
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

for brownstone board, add the udc/otg/ehci support

Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
 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 <linux/regulator/max8649.h>
 #include <linux/regulator/fixed.h>
 #include <linux/mfd/max8925.h>
+#include <linux/usb/phy.h>
+#include <linux/usb/mv_usb2.h>
+#include <linux/platform_data/mv_usb.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 12/12] usb: mv_usb: remove the phy callbacks in pdata
  2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
                   ` (10 preceding siblings ...)
  2013-04-24  6:23 ` [V9 PATCH 11/12] arm: brownstone: add usb support for the board Chao Xie
@ 2013-04-24  6:23 ` Chao Xie
  11 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-04-24  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

The phy initialization code will be done by phy driver.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
 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 int    otg_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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces
  2013-04-24  6:23 ` [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces Chao Xie
@ 2013-04-29 18:24   ` Felipe Balbi
  2013-04-29 19:26     ` Russell King - ARM Linux
  2013-05-06  7:22     ` Chao Xie
  0 siblings, 2 replies; 21+ messages in thread
From: Felipe Balbi @ 2013-04-29 18:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 24, 2013 at 02:23:15AM -0400, Chao Xie wrote:
> 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_head	head;
>  
> +	/*
> +	 * PHY may be shared by multiple devices.
> +	 * mutex and refcount are used to make sure PHY only initialize or
> +	 * shutdown once.

bad grammar in this sentence.

> +	 */
> +	struct mutex		phy_mutex;
> +	unsigned int		refcount;

why don't you use an atomic_t ?

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130429/810dec42/attachment.sig>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces
  2013-04-29 18:24   ` Felipe Balbi
@ 2013-04-29 19:26     ` Russell King - ARM Linux
  2013-05-06  7:22     ` Chao Xie
  1 sibling, 0 replies; 21+ messages in thread
From: Russell King - ARM Linux @ 2013-04-29 19:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 29, 2013 at 09:24:41PM +0300, Felipe Balbi wrote:
> On Wed, Apr 24, 2013 at 02:23:15AM -0400, Chao Xie wrote:
> > 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_head	head;
> >  
> > +	/*
> > +	 * PHY may be shared by multiple devices.
> > +	 * mutex and refcount are used to make sure PHY only initialize or
> > +	 * shutdown once.
> 
> bad grammar in this sentence.
> 
> > +	 */
> > +	struct mutex		phy_mutex;
> > +	unsigned int		refcount;
> 
> why don't you use an atomic_t ?

Possibly because of this:

+       mutex_lock(&x->phy_mutex);                                              
+       if (x->refcount++ == 0 && x->init)                                      
+               ret = x->init(x);                                               
+       mutex_unlock(&x->phy_mutex);                                            

This code structure has the effect that with two concurrent callers, one
will be blocked while the other calls the init function, and both will
not pass until the init function has completed.

Using an atomic type does not provide that guarantee.  Consider:

	if (atomic_inc_return(&x->atomic) == 1 && x->init)
		ret = x->init(x);

when two concurrent callers occur.  Or even consider one caller to the
shutdown function and another which comes into the init path while the
shutdown function is still running.

Atomic types are all well and good but they are also horrendously
dangerous when abused in ways like you're suggesting.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces
  2013-04-29 18:24   ` Felipe Balbi
  2013-04-29 19:26     ` Russell King - ARM Linux
@ 2013-05-06  7:22     ` Chao Xie
  1 sibling, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-05-06  7:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 30, 2013 at 2:24 AM, Felipe Balbi <balbi@ti.com> wrote:
> On Wed, Apr 24, 2013 at 02:23:15AM -0400, Chao Xie wrote:
>> 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_head        head;
>>
>> +     /*
>> +      * PHY may be shared by multiple devices.
>> +      * mutex and refcount are used to make sure PHY only initialize or
>> +      * shutdown once.
>
> bad grammar in this sentence.
>

I will fix it in the next version.

>> +      */
>> +     struct mutex            phy_mutex;
>> +     unsigned int            refcount;
>
> why don't you use an atomic_t ?
>

Mutex will protect both ->init and ->shutdown routines. Thanks for
Russell's explanation.

> --
> balbi

Can you help to review other patches in this series? So I can fix all
the errors in the next version.
Thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [V9 PATCH 00/12] mv-usb phy driver
  2013-04-17  1:22   ` Chao Xie
@ 2013-05-15 14:35     ` Felipe Balbi
  0 siblings, 0 replies; 21+ messages in thread
From: Felipe Balbi @ 2013-05-15 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Wed, Apr 17, 2013 at 09:22:36AM +0800, Chao Xie wrote:
> On Wed, Apr 17, 2013 at 9:17 AM, Chao Xie <xiechao.mail@gmail.com> wrote:
> >
> > On Sun, Apr 7, 2013 at 6:29 PM, Chao Xie <chao.xie@marvell.com> wrote:
> >>
> >> The patches create the mv-usb 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
> >>
> >>
> >
> hi, balbi
> You have given many valuable comments and suggestions for previous version.
> So i modified the driver based on your review feedback. Can you help to
> review the new version? Thanks.

sure, just give me a few more days and I'll get to these.

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130515/682cf9ac/attachment.sig>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [V9 PATCH 00/12] mv-usb phy driver
@ 2013-05-13  5:51 Chao Xie
  0 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-05-13  5:51 UTC (permalink / raw)
  To: linux-arm-kernel

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

V10->V9
  Grammar fix in comments.

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [V9 PATCH 00/12] mv-usb phy driver
@ 2013-05-13  5:51 Chao Xie
  0 siblings, 0 replies; 21+ messages in thread
From: Chao Xie @ 2013-05-13  5:51 UTC (permalink / raw)
  To: linux-arm-kernel

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

V10->V9
  Grammar fix in comments.

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [V9 PATCH 00/12] mv-usb phy driver
       [not found] ` <CADApbeg4BSUubbTw8tC-fuQ06JrRtAW9+rOdg=3rP_0Dr=LwkQ@mail.gmail.com>
@ 2013-04-17  1:22   ` Chao Xie
  2013-05-15 14:35     ` Felipe Balbi
  0 siblings, 1 reply; 21+ messages in thread
From: Chao Xie @ 2013-04-17  1:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 17, 2013 at 9:17 AM, Chao Xie <xiechao.mail@gmail.com> wrote:
>
> On Sun, Apr 7, 2013 at 6:29 PM, Chao Xie <chao.xie@marvell.com> wrote:
>>
>> The patches create the mv-usb 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
>>
>>
>
hi, balbi
You have given many valuable comments and suggestions for previous version.
So i modified the driver based on your review feedback. Can you help to
review the new version? Thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [V9 PATCH 00/12] mv-usb phy driver
@ 2013-04-07 10:29 Chao Xie
       [not found] ` <CADApbeg4BSUubbTw8tC-fuQ06JrRtAW9+rOdg=3rP_0Dr=LwkQ@mail.gmail.com>
  0 siblings, 1 reply; 21+ messages in thread
From: Chao Xie @ 2013-04-07 10:29 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2013-05-15 14:35 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-24  6:23 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
2013-04-24  6:23 ` [V9 PATCH 01/12] usb: phy: protect phy init and shutdown for mutiple deivces Chao Xie
2013-04-29 18:24   ` Felipe Balbi
2013-04-29 19:26     ` Russell King - ARM Linux
2013-05-06  7:22     ` Chao Xie
2013-04-24  6:23 ` [V9 PATCH 02/12] usb: phy: mv_usb2: add PHY driver for marvell usb2 controller Chao Xie
2013-04-24  6:23 ` [V9 PATCH 03/12] usb: gadget: mv_udc: use PHY driver for udc Chao Xie
2013-04-24  6:23 ` [V9 PATCH 04/12] usb: ehci: ehci-mv: use PHY driver for ehci Chao Xie
2013-04-24  6:23 ` [V9 PATCH 05/12] usb: phy: phy-mv-usb: use USB2 PHY driver for otg Chao Xie
2013-04-24  6:23 ` [V9 PATCH 06/12] usb: mv_u3d: usb phy drivers for phy operation Chao Xie
2013-04-24  6:23 ` [V9 PATCH 07/12] arm: mmp2: change the defintion of usb devices Chao Xie
2013-04-24  6:23 ` [V9 PATCH 08/12] arm: pxa910: " Chao Xie
2013-04-24  6:23 ` [V9 PATCH 09/12] arm: ttc_dkb: modify usb support Chao Xie
2013-04-24  6:23 ` [V9 PATCH 10/12] arm: mmp: remove unused usb devices Chao Xie
2013-04-24  6:23 ` [V9 PATCH 11/12] arm: brownstone: add usb support for the board Chao Xie
2013-04-24  6:23 ` [V9 PATCH 12/12] usb: mv_usb: remove the phy callbacks in pdata Chao Xie
  -- strict thread matches above, loose matches on Subject: below --
2013-05-13  5:51 [V9 PATCH 00/12] mv-usb phy driver Chao Xie
2013-05-13  5:51 Chao Xie
2013-04-07 10:29 Chao Xie
     [not found] ` <CADApbeg4BSUubbTw8tC-fuQ06JrRtAW9+rOdg=3rP_0Dr=LwkQ@mail.gmail.com>
2013-04-17  1:22   ` Chao Xie
2013-05-15 14:35     ` Felipe Balbi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.