All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] Convert ehci-mv to DT
@ 2018-08-22 20:42 ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

Hi,

This patch set makes it possible to use the Marvell EHCI driver with
DT-based machines.

Tested on a marvell,mmp2-based OLPC XO 1.75 laptop. (With a custom
appended DT that will be submitted in a separate patch set. The
machine's OpenFirmware provides a device tree, but that one is too
buggy to boot a pure marvell,mmp2 FDT kernel.)

Lubo





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

* [PATCH 00/14] Convert ehci-mv to DT
@ 2018-08-22 20:42 ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

This patch set makes it possible to use the Marvell EHCI driver with
DT-based machines.

Tested on a marvell,mmp2-based OLPC XO 1.75 laptop. (With a custom
appended DT that will be submitted in a separate patch set. The
machine's OpenFirmware provides a device tree, but that one is too
buggy to boot a pure marvell,mmp2 FDT kernel.)

Lubo

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

* [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver, so
that in can be instantiated from a DT.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/phy/marvell/Kconfig       |  11 +
 drivers/phy/marvell/Makefile      |   1 +
 drivers/phy/marvell/phy-pxa-usb.c | 345 ++++++++++++++++++++++++++++++
 3 files changed, 357 insertions(+)
 create mode 100644 drivers/phy/marvell/phy-pxa-usb.c

diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig
index 68e321225400..6fb4b56e4c14 100644
--- a/drivers/phy/marvell/Kconfig
+++ b/drivers/phy/marvell/Kconfig
@@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
 	  The PHY driver will be used by Marvell udc/ehci/otg driver.
 
 	  To compile this driver as a module, choose M here.
+
+config PHY_PXA_USB
+	tristate "Marvell PXA USB PHY Driver"
+	depends on ARCH_PXA || ARCH_MMP
+	select GENERIC_PHY
+	help
+	  Enable this to support Marvell PXA USB 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.
diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile
index 5c3ec5d10e0d..3975b144f8ec 100644
--- a/drivers/phy/marvell/Makefile
+++ b/drivers/phy/marvell/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-mvebu-cp110-comphy.o
 obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
 obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
 obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
+obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
diff --git a/drivers/phy/marvell/phy-pxa-usb.c b/drivers/phy/marvell/phy-pxa-usb.c
new file mode 100644
index 000000000000..87ff7550b912
--- /dev/null
+++ b/drivers/phy/marvell/phy-pxa-usb.c
@@ -0,0 +1,345 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
+ * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
+ */
+
+#include <dt-bindings/phy/phy.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+
+/* phy regs */
+#define UTMI_REVISION		0x0
+#define UTMI_CTRL		0x4
+#define UTMI_PLL		0x8
+#define UTMI_TX			0xc
+#define UTMI_RX			0x10
+#define UTMI_IVREF		0x14
+#define UTMI_T0			0x18
+#define UTMI_T1			0x1c
+#define UTMI_T2			0x20
+#define UTMI_T3			0x24
+#define UTMI_T4			0x28
+#define UTMI_T5			0x2c
+#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_SHIFT		28
+#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			27
+#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
+
+#define UTMI_PLL_PLLVDD12_SHIFT			25
+#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_SHIFT			15
+#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
+
+#define UTMI_PLL_ICP_SHIFT			12
+#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
+
+#define UTMI_PLL_FBDIV_SHIFT                    4
+#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
+
+#define UTMI_PLL_REFDIV_SHIFT                   0
+#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
+
+/* For UTMI_TX Register */
+#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
+#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
+
+#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
+#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
+
+#define UTMI_TX_TXVDD12_SHIFT                   22
+#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
+
+#define UTMI_TX_CK60_PHSEL_SHIFT                17
+#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
+
+#define UTMI_TX_IMPCAL_VTH_SHIFT                14
+#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
+
+#define REG_RCAL_START                          (0x1 << 12)
+
+#define UTMI_TX_LOW_VDD_EN_SHIFT                11
+
+#define UTMI_TX_AMP_SHIFT			0
+#define UTMI_TX_AMP_MASK			(0x7 << 0)
+
+/* For UTMI_RX Register */
+#define UTMI_REG_SQ_LENGTH_SHIFT                15
+#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
+
+#define UTMI_RX_SQ_THRESH_SHIFT                 4
+#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
+
+#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
+
+enum pxa_usb_phy_version {
+	PXA_USB_PHY_MMP2,
+	PXA_USB_PHY_PXA910,
+	PXA_USB_PHY_PXA168,
+};
+
+struct pxa_usb_phy {
+	struct phy *phy;
+	void __iomem *base;
+	enum pxa_usb_phy_version version;
+};
+
+/*****************************************************************************
+ * The registers read/write routines
+ *****************************************************************************/
+
+static unsigned int u2o_get(void __iomem *base, unsigned int offset)
+{
+	return readl_relaxed(base + offset);
+}
+
+static void u2o_set(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	u32 reg;
+
+	reg = readl_relaxed(base + offset);
+	reg |= value;
+	writel_relaxed(reg, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static void u2o_clear(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	u32 reg;
+
+	reg = readl_relaxed(base + offset);
+	reg &= ~value;
+	writel_relaxed(reg, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static void u2o_write(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	writel_relaxed(value, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static int pxa_usb_phy_init(struct phy *phy)
+{
+	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
+	void __iomem *base = pxa_usb_phy->base;
+	int loops;
+
+	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
+
+	/* Initialize the USB PHY power */
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
+		u2o_set(base, UTMI_CTRL, (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
+			| (1<<UTMI_CTRL_PU_REF_SHIFT));
+	}
+
+	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
+	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
+
+	/* UTMI_PLL settings */
+	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
+		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
+		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
+		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
+
+	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
+		| 0xb<<UTMI_PLL_REFDIV_SHIFT | 3<<UTMI_PLL_PLLVDD18_SHIFT
+		| 3<<UTMI_PLL_PLLVDD12_SHIFT | 3<<UTMI_PLL_PLLCALI12_SHIFT
+		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
+
+	/* UTMI_TX */
+	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
+		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
+		| UTMI_TX_IMPCAL_VTH_MASK | UTMI_TX_REG_EXT_FS_RCAL_MASK
+		| UTMI_TX_AMP_MASK);
+	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
+		| 4<<UTMI_TX_CK60_PHSEL_SHIFT | 4<<UTMI_TX_IMPCAL_VTH_SHIFT
+		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT | 3<<UTMI_TX_AMP_SHIFT);
+
+	/* UTMI_RX */
+	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
+		| UTMI_REG_SQ_LENGTH_MASK);
+	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
+		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
+
+	/* UTMI_IVREF */
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
+		/*
+		 * fixing Microsoft Altair board interface with NEC hub issue -
+		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
+		 */
+		u2o_write(base, UTMI_IVREF, 0x4bf);
+	}
+
+	/* toggle VCOCAL_START bit of UTMI_PLL */
+	udelay(200);
+	u2o_set(base, UTMI_PLL, VCOCAL_START);
+	udelay(40);
+	u2o_clear(base, UTMI_PLL, VCOCAL_START);
+
+	/* toggle REG_RCAL_START bit of UTMI_TX */
+	udelay(400);
+	u2o_set(base, UTMI_TX, REG_RCAL_START);
+	udelay(40);
+	u2o_clear(base, UTMI_TX, REG_RCAL_START);
+	udelay(400);
+
+	/* Make sure PHY PLL is ready */
+	loops = 0;
+	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
+		mdelay(1);
+		loops++;
+		if (loops > 100) {
+			dev_warn(&phy->dev, "calibrate timeout, UTMI_PLL %x\n",
+						u2o_get(base, UTMI_PLL));
+			break;
+		}
+	}
+
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
+		u2o_set(base, UTMI_RESERVE, 1 << 5);
+		/* Turn on UTMI PHY OTG extension */
+		u2o_write(base, UTMI_OTG_ADDON, 1);
+	}
+
+	return 0;
+
+}
+
+static int pxa_usb_phy_exit(struct phy *phy)
+{
+	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
+	void __iomem *base = pxa_usb_phy->base;
+
+	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
+
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
+		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
+
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
+	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
+	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
+
+	return 0;
+}
+
+static const struct phy_ops pxa_usb_phy_ops = {
+	.init	= pxa_usb_phy_init,
+	.exit	= pxa_usb_phy_exit,
+	.owner	= THIS_MODULE,
+};
+
+static const struct of_device_id pxa_usb_phy_of_match[] = {
+	{
+		.compatible = "marvell,mmp2-usb-phy",
+		.data = (void *)PXA_USB_PHY_MMP2,
+	}, {
+		.compatible = "marvell,pxa910-usb-phy",
+		.data = (void *)PXA_USB_PHY_PXA910,
+	}, {
+		.compatible = "marvell,pxa168-usb-phy",
+		.data = (void *)PXA_USB_PHY_PXA168,
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
+
+static int pxa_usb_phy_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct resource *resource;
+	struct pxa_usb_phy *pxa_usb_phy;
+	struct phy_provider *provider;
+	const struct of_device_id *of_id;
+
+	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy), GFP_KERNEL);
+	if (!pxa_usb_phy)
+		return -ENOMEM;
+
+	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
+	if (of_id)
+		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id->data;
+	else
+		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
+
+	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
+	if (IS_ERR(pxa_usb_phy->base)) {
+		dev_err(dev, "failed to remap PHY regs\n");
+		return PTR_ERR(pxa_usb_phy->base);
+	}
+
+	pxa_usb_phy->phy = devm_phy_create(dev, NULL, &pxa_usb_phy_ops);
+	if (IS_ERR(pxa_usb_phy->phy)) {
+		dev_err(dev, "failed to create PHY\n");
+		return PTR_ERR(pxa_usb_phy->phy);
+	}
+
+	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
+	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+	if (IS_ERR(provider)) {
+		dev_err(dev, "failed to register PHY provider\n");
+		return PTR_ERR(provider);
+	}
+
+	if (!dev->of_node) {
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-u2oehci");
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
+	}
+
+	dev_info(dev, "Marvell PXA USB PHY");
+	return 0;
+}
+
+static struct platform_driver pxa_usb_phy_driver = {
+	.probe		= pxa_usb_phy_probe,
+	.driver		= {
+		.name	= "pxa-usb-phy",
+		.of_match_table = pxa_usb_phy_of_match,
+	},
+};
+module_platform_driver(pxa_usb_phy_driver);
+
+MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
+MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
+MODULE_LICENSE("GPL v2");
-- 
2.17.1


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

* [01/14] phy: phy-pxa-usb: add a new driver
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver, so
that in can be instantiated from a DT.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/phy/marvell/Kconfig       |  11 +
 drivers/phy/marvell/Makefile      |   1 +
 drivers/phy/marvell/phy-pxa-usb.c | 345 ++++++++++++++++++++++++++++++
 3 files changed, 357 insertions(+)
 create mode 100644 drivers/phy/marvell/phy-pxa-usb.c

diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig
index 68e321225400..6fb4b56e4c14 100644
--- a/drivers/phy/marvell/Kconfig
+++ b/drivers/phy/marvell/Kconfig
@@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
 	  The PHY driver will be used by Marvell udc/ehci/otg driver.
 
 	  To compile this driver as a module, choose M here.
+
+config PHY_PXA_USB
+	tristate "Marvell PXA USB PHY Driver"
+	depends on ARCH_PXA || ARCH_MMP
+	select GENERIC_PHY
+	help
+	  Enable this to support Marvell PXA USB 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.
diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile
index 5c3ec5d10e0d..3975b144f8ec 100644
--- a/drivers/phy/marvell/Makefile
+++ b/drivers/phy/marvell/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-mvebu-cp110-comphy.o
 obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
 obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
 obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
+obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
diff --git a/drivers/phy/marvell/phy-pxa-usb.c b/drivers/phy/marvell/phy-pxa-usb.c
new file mode 100644
index 000000000000..87ff7550b912
--- /dev/null
+++ b/drivers/phy/marvell/phy-pxa-usb.c
@@ -0,0 +1,345 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
+ * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
+ */
+
+#include <dt-bindings/phy/phy.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+
+/* phy regs */
+#define UTMI_REVISION		0x0
+#define UTMI_CTRL		0x4
+#define UTMI_PLL		0x8
+#define UTMI_TX			0xc
+#define UTMI_RX			0x10
+#define UTMI_IVREF		0x14
+#define UTMI_T0			0x18
+#define UTMI_T1			0x1c
+#define UTMI_T2			0x20
+#define UTMI_T3			0x24
+#define UTMI_T4			0x28
+#define UTMI_T5			0x2c
+#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_SHIFT		28
+#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			27
+#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
+
+#define UTMI_PLL_PLLVDD12_SHIFT			25
+#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_SHIFT			15
+#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
+
+#define UTMI_PLL_ICP_SHIFT			12
+#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
+
+#define UTMI_PLL_FBDIV_SHIFT                    4
+#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
+
+#define UTMI_PLL_REFDIV_SHIFT                   0
+#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
+
+/* For UTMI_TX Register */
+#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
+#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
+
+#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
+#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
+
+#define UTMI_TX_TXVDD12_SHIFT                   22
+#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
+
+#define UTMI_TX_CK60_PHSEL_SHIFT                17
+#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
+
+#define UTMI_TX_IMPCAL_VTH_SHIFT                14
+#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
+
+#define REG_RCAL_START                          (0x1 << 12)
+
+#define UTMI_TX_LOW_VDD_EN_SHIFT                11
+
+#define UTMI_TX_AMP_SHIFT			0
+#define UTMI_TX_AMP_MASK			(0x7 << 0)
+
+/* For UTMI_RX Register */
+#define UTMI_REG_SQ_LENGTH_SHIFT                15
+#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
+
+#define UTMI_RX_SQ_THRESH_SHIFT                 4
+#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
+
+#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
+
+enum pxa_usb_phy_version {
+	PXA_USB_PHY_MMP2,
+	PXA_USB_PHY_PXA910,
+	PXA_USB_PHY_PXA168,
+};
+
+struct pxa_usb_phy {
+	struct phy *phy;
+	void __iomem *base;
+	enum pxa_usb_phy_version version;
+};
+
+/*****************************************************************************
+ * The registers read/write routines
+ *****************************************************************************/
+
+static unsigned int u2o_get(void __iomem *base, unsigned int offset)
+{
+	return readl_relaxed(base + offset);
+}
+
+static void u2o_set(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	u32 reg;
+
+	reg = readl_relaxed(base + offset);
+	reg |= value;
+	writel_relaxed(reg, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static void u2o_clear(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	u32 reg;
+
+	reg = readl_relaxed(base + offset);
+	reg &= ~value;
+	writel_relaxed(reg, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static void u2o_write(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	writel_relaxed(value, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static int pxa_usb_phy_init(struct phy *phy)
+{
+	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
+	void __iomem *base = pxa_usb_phy->base;
+	int loops;
+
+	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
+
+	/* Initialize the USB PHY power */
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
+		u2o_set(base, UTMI_CTRL, (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
+			| (1<<UTMI_CTRL_PU_REF_SHIFT));
+	}
+
+	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
+	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
+
+	/* UTMI_PLL settings */
+	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
+		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
+		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
+		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
+
+	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
+		| 0xb<<UTMI_PLL_REFDIV_SHIFT | 3<<UTMI_PLL_PLLVDD18_SHIFT
+		| 3<<UTMI_PLL_PLLVDD12_SHIFT | 3<<UTMI_PLL_PLLCALI12_SHIFT
+		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
+
+	/* UTMI_TX */
+	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
+		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
+		| UTMI_TX_IMPCAL_VTH_MASK | UTMI_TX_REG_EXT_FS_RCAL_MASK
+		| UTMI_TX_AMP_MASK);
+	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
+		| 4<<UTMI_TX_CK60_PHSEL_SHIFT | 4<<UTMI_TX_IMPCAL_VTH_SHIFT
+		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT | 3<<UTMI_TX_AMP_SHIFT);
+
+	/* UTMI_RX */
+	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
+		| UTMI_REG_SQ_LENGTH_MASK);
+	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
+		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
+
+	/* UTMI_IVREF */
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
+		/*
+		 * fixing Microsoft Altair board interface with NEC hub issue -
+		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
+		 */
+		u2o_write(base, UTMI_IVREF, 0x4bf);
+	}
+
+	/* toggle VCOCAL_START bit of UTMI_PLL */
+	udelay(200);
+	u2o_set(base, UTMI_PLL, VCOCAL_START);
+	udelay(40);
+	u2o_clear(base, UTMI_PLL, VCOCAL_START);
+
+	/* toggle REG_RCAL_START bit of UTMI_TX */
+	udelay(400);
+	u2o_set(base, UTMI_TX, REG_RCAL_START);
+	udelay(40);
+	u2o_clear(base, UTMI_TX, REG_RCAL_START);
+	udelay(400);
+
+	/* Make sure PHY PLL is ready */
+	loops = 0;
+	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
+		mdelay(1);
+		loops++;
+		if (loops > 100) {
+			dev_warn(&phy->dev, "calibrate timeout, UTMI_PLL %x\n",
+						u2o_get(base, UTMI_PLL));
+			break;
+		}
+	}
+
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
+		u2o_set(base, UTMI_RESERVE, 1 << 5);
+		/* Turn on UTMI PHY OTG extension */
+		u2o_write(base, UTMI_OTG_ADDON, 1);
+	}
+
+	return 0;
+
+}
+
+static int pxa_usb_phy_exit(struct phy *phy)
+{
+	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
+	void __iomem *base = pxa_usb_phy->base;
+
+	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
+
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
+		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
+
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
+	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
+	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
+
+	return 0;
+}
+
+static const struct phy_ops pxa_usb_phy_ops = {
+	.init	= pxa_usb_phy_init,
+	.exit	= pxa_usb_phy_exit,
+	.owner	= THIS_MODULE,
+};
+
+static const struct of_device_id pxa_usb_phy_of_match[] = {
+	{
+		.compatible = "marvell,mmp2-usb-phy",
+		.data = (void *)PXA_USB_PHY_MMP2,
+	}, {
+		.compatible = "marvell,pxa910-usb-phy",
+		.data = (void *)PXA_USB_PHY_PXA910,
+	}, {
+		.compatible = "marvell,pxa168-usb-phy",
+		.data = (void *)PXA_USB_PHY_PXA168,
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
+
+static int pxa_usb_phy_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct resource *resource;
+	struct pxa_usb_phy *pxa_usb_phy;
+	struct phy_provider *provider;
+	const struct of_device_id *of_id;
+
+	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy), GFP_KERNEL);
+	if (!pxa_usb_phy)
+		return -ENOMEM;
+
+	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
+	if (of_id)
+		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id->data;
+	else
+		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
+
+	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
+	if (IS_ERR(pxa_usb_phy->base)) {
+		dev_err(dev, "failed to remap PHY regs\n");
+		return PTR_ERR(pxa_usb_phy->base);
+	}
+
+	pxa_usb_phy->phy = devm_phy_create(dev, NULL, &pxa_usb_phy_ops);
+	if (IS_ERR(pxa_usb_phy->phy)) {
+		dev_err(dev, "failed to create PHY\n");
+		return PTR_ERR(pxa_usb_phy->phy);
+	}
+
+	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
+	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+	if (IS_ERR(provider)) {
+		dev_err(dev, "failed to register PHY provider\n");
+		return PTR_ERR(provider);
+	}
+
+	if (!dev->of_node) {
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-u2oehci");
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
+	}
+
+	dev_info(dev, "Marvell PXA USB PHY");
+	return 0;
+}
+
+static struct platform_driver pxa_usb_phy_driver = {
+	.probe		= pxa_usb_phy_probe,
+	.driver		= {
+		.name	= "pxa-usb-phy",
+		.of_match_table = pxa_usb_phy_of_match,
+	},
+};
+module_platform_driver(pxa_usb_phy_driver);
+
+MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
+MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
+MODULE_LICENSE("GPL v2");

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

* [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver, so
that in can be instantiated from a DT.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/phy/marvell/Kconfig       |  11 +
 drivers/phy/marvell/Makefile      |   1 +
 drivers/phy/marvell/phy-pxa-usb.c | 345 ++++++++++++++++++++++++++++++
 3 files changed, 357 insertions(+)
 create mode 100644 drivers/phy/marvell/phy-pxa-usb.c

diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig
index 68e321225400..6fb4b56e4c14 100644
--- a/drivers/phy/marvell/Kconfig
+++ b/drivers/phy/marvell/Kconfig
@@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
 	  The PHY driver will be used by Marvell udc/ehci/otg driver.
 
 	  To compile this driver as a module, choose M here.
+
+config PHY_PXA_USB
+	tristate "Marvell PXA USB PHY Driver"
+	depends on ARCH_PXA || ARCH_MMP
+	select GENERIC_PHY
+	help
+	  Enable this to support Marvell PXA USB 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.
diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile
index 5c3ec5d10e0d..3975b144f8ec 100644
--- a/drivers/phy/marvell/Makefile
+++ b/drivers/phy/marvell/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-mvebu-cp110-comphy.o
 obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
 obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
 obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
+obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
diff --git a/drivers/phy/marvell/phy-pxa-usb.c b/drivers/phy/marvell/phy-pxa-usb.c
new file mode 100644
index 000000000000..87ff7550b912
--- /dev/null
+++ b/drivers/phy/marvell/phy-pxa-usb.c
@@ -0,0 +1,345 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
+ * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
+ */
+
+#include <dt-bindings/phy/phy.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+
+/* phy regs */
+#define UTMI_REVISION		0x0
+#define UTMI_CTRL		0x4
+#define UTMI_PLL		0x8
+#define UTMI_TX			0xc
+#define UTMI_RX			0x10
+#define UTMI_IVREF		0x14
+#define UTMI_T0			0x18
+#define UTMI_T1			0x1c
+#define UTMI_T2			0x20
+#define UTMI_T3			0x24
+#define UTMI_T4			0x28
+#define UTMI_T5			0x2c
+#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_SHIFT		28
+#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			27
+#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
+
+#define UTMI_PLL_PLLVDD12_SHIFT			25
+#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_SHIFT			15
+#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
+
+#define UTMI_PLL_ICP_SHIFT			12
+#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
+
+#define UTMI_PLL_FBDIV_SHIFT                    4
+#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
+
+#define UTMI_PLL_REFDIV_SHIFT                   0
+#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
+
+/* For UTMI_TX Register */
+#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
+#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
+
+#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
+#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
+
+#define UTMI_TX_TXVDD12_SHIFT                   22
+#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
+
+#define UTMI_TX_CK60_PHSEL_SHIFT                17
+#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
+
+#define UTMI_TX_IMPCAL_VTH_SHIFT                14
+#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
+
+#define REG_RCAL_START                          (0x1 << 12)
+
+#define UTMI_TX_LOW_VDD_EN_SHIFT                11
+
+#define UTMI_TX_AMP_SHIFT			0
+#define UTMI_TX_AMP_MASK			(0x7 << 0)
+
+/* For UTMI_RX Register */
+#define UTMI_REG_SQ_LENGTH_SHIFT                15
+#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
+
+#define UTMI_RX_SQ_THRESH_SHIFT                 4
+#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
+
+#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
+
+enum pxa_usb_phy_version {
+	PXA_USB_PHY_MMP2,
+	PXA_USB_PHY_PXA910,
+	PXA_USB_PHY_PXA168,
+};
+
+struct pxa_usb_phy {
+	struct phy *phy;
+	void __iomem *base;
+	enum pxa_usb_phy_version version;
+};
+
+/*****************************************************************************
+ * The registers read/write routines
+ *****************************************************************************/
+
+static unsigned int u2o_get(void __iomem *base, unsigned int offset)
+{
+	return readl_relaxed(base + offset);
+}
+
+static void u2o_set(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	u32 reg;
+
+	reg = readl_relaxed(base + offset);
+	reg |= value;
+	writel_relaxed(reg, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static void u2o_clear(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	u32 reg;
+
+	reg = readl_relaxed(base + offset);
+	reg &= ~value;
+	writel_relaxed(reg, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static void u2o_write(void __iomem *base, unsigned int offset,
+		unsigned int value)
+{
+	writel_relaxed(value, base + offset);
+	readl_relaxed(base + offset);
+}
+
+static int pxa_usb_phy_init(struct phy *phy)
+{
+	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
+	void __iomem *base = pxa_usb_phy->base;
+	int loops;
+
+	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
+
+	/* Initialize the USB PHY power */
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
+		u2o_set(base, UTMI_CTRL, (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
+			| (1<<UTMI_CTRL_PU_REF_SHIFT));
+	}
+
+	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
+	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
+
+	/* UTMI_PLL settings */
+	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
+		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
+		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
+		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
+
+	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
+		| 0xb<<UTMI_PLL_REFDIV_SHIFT | 3<<UTMI_PLL_PLLVDD18_SHIFT
+		| 3<<UTMI_PLL_PLLVDD12_SHIFT | 3<<UTMI_PLL_PLLCALI12_SHIFT
+		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
+
+	/* UTMI_TX */
+	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
+		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
+		| UTMI_TX_IMPCAL_VTH_MASK | UTMI_TX_REG_EXT_FS_RCAL_MASK
+		| UTMI_TX_AMP_MASK);
+	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
+		| 4<<UTMI_TX_CK60_PHSEL_SHIFT | 4<<UTMI_TX_IMPCAL_VTH_SHIFT
+		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT | 3<<UTMI_TX_AMP_SHIFT);
+
+	/* UTMI_RX */
+	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
+		| UTMI_REG_SQ_LENGTH_MASK);
+	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
+		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
+
+	/* UTMI_IVREF */
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
+		/*
+		 * fixing Microsoft Altair board interface with NEC hub issue -
+		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
+		 */
+		u2o_write(base, UTMI_IVREF, 0x4bf);
+	}
+
+	/* toggle VCOCAL_START bit of UTMI_PLL */
+	udelay(200);
+	u2o_set(base, UTMI_PLL, VCOCAL_START);
+	udelay(40);
+	u2o_clear(base, UTMI_PLL, VCOCAL_START);
+
+	/* toggle REG_RCAL_START bit of UTMI_TX */
+	udelay(400);
+	u2o_set(base, UTMI_TX, REG_RCAL_START);
+	udelay(40);
+	u2o_clear(base, UTMI_TX, REG_RCAL_START);
+	udelay(400);
+
+	/* Make sure PHY PLL is ready */
+	loops = 0;
+	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
+		mdelay(1);
+		loops++;
+		if (loops > 100) {
+			dev_warn(&phy->dev, "calibrate timeout, UTMI_PLL %x\n",
+						u2o_get(base, UTMI_PLL));
+			break;
+		}
+	}
+
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
+		u2o_set(base, UTMI_RESERVE, 1 << 5);
+		/* Turn on UTMI PHY OTG extension */
+		u2o_write(base, UTMI_OTG_ADDON, 1);
+	}
+
+	return 0;
+
+}
+
+static int pxa_usb_phy_exit(struct phy *phy)
+{
+	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
+	void __iomem *base = pxa_usb_phy->base;
+
+	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
+
+	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
+		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
+
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
+	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
+	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
+	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
+
+	return 0;
+}
+
+static const struct phy_ops pxa_usb_phy_ops = {
+	.init	= pxa_usb_phy_init,
+	.exit	= pxa_usb_phy_exit,
+	.owner	= THIS_MODULE,
+};
+
+static const struct of_device_id pxa_usb_phy_of_match[] = {
+	{
+		.compatible = "marvell,mmp2-usb-phy",
+		.data = (void *)PXA_USB_PHY_MMP2,
+	}, {
+		.compatible = "marvell,pxa910-usb-phy",
+		.data = (void *)PXA_USB_PHY_PXA910,
+	}, {
+		.compatible = "marvell,pxa168-usb-phy",
+		.data = (void *)PXA_USB_PHY_PXA168,
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
+
+static int pxa_usb_phy_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct resource *resource;
+	struct pxa_usb_phy *pxa_usb_phy;
+	struct phy_provider *provider;
+	const struct of_device_id *of_id;
+
+	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy), GFP_KERNEL);
+	if (!pxa_usb_phy)
+		return -ENOMEM;
+
+	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
+	if (of_id)
+		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id->data;
+	else
+		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
+
+	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
+	if (IS_ERR(pxa_usb_phy->base)) {
+		dev_err(dev, "failed to remap PHY regs\n");
+		return PTR_ERR(pxa_usb_phy->base);
+	}
+
+	pxa_usb_phy->phy = devm_phy_create(dev, NULL, &pxa_usb_phy_ops);
+	if (IS_ERR(pxa_usb_phy->phy)) {
+		dev_err(dev, "failed to create PHY\n");
+		return PTR_ERR(pxa_usb_phy->phy);
+	}
+
+	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
+	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+	if (IS_ERR(provider)) {
+		dev_err(dev, "failed to register PHY provider\n");
+		return PTR_ERR(provider);
+	}
+
+	if (!dev->of_node) {
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-u2oehci");
+		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
+	}
+
+	dev_info(dev, "Marvell PXA USB PHY");
+	return 0;
+}
+
+static struct platform_driver pxa_usb_phy_driver = {
+	.probe		= pxa_usb_phy_probe,
+	.driver		= {
+		.name	= "pxa-usb-phy",
+		.of_match_table = pxa_usb_phy_of_match,
+	},
+};
+module_platform_driver(pxa_usb_phy_driver);
+
+MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
+MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
+MODULE_LICENSE("GPL v2");
-- 
2.17.1

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

* [PATCH 02/14] dt-bindings: phy-pxa-usb: add bindings
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This is the PHY chip for USB OTG on PXA platforms.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 .../devicetree/bindings/phy/phy-pxa-usb.txt     | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-pxa-usb.txt

diff --git a/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
new file mode 100644
index 000000000000..5b12ab44c9e6
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
@@ -0,0 +1,17 @@
+Marvell PXA USB PHY
+-------------------
+
+Required properties:
+- compatible: one of: "marvell,mmp2-usb-phy", "marvell,pxa910-usb-phy",
+	"marvell,pxa168-usb-phy",
+- #phy-cells: must be 0
+
+Example:
+	usb-phy: usbphy@d4207000 {
+		compatible = "marvell,mmp2-usb-phy";
+		reg = <0xd4207000 0x40>;
+		#phy-cells = <0>;
+		status = "okay";
+	};
+This document explains only the device tree data binding. For general
+information about PHY subsystem refer to Documentation/phy.txt
-- 
2.17.1


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

* [02/14] dt-bindings: phy-pxa-usb: add bindings
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This is the PHY chip for USB OTG on PXA platforms.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 .../devicetree/bindings/phy/phy-pxa-usb.txt     | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-pxa-usb.txt

diff --git a/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
new file mode 100644
index 000000000000..5b12ab44c9e6
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
@@ -0,0 +1,17 @@
+Marvell PXA USB PHY
+-------------------
+
+Required properties:
+- compatible: one of: "marvell,mmp2-usb-phy", "marvell,pxa910-usb-phy",
+	"marvell,pxa168-usb-phy",
+- #phy-cells: must be 0
+
+Example:
+	usb-phy: usbphy@d4207000 {
+		compatible = "marvell,mmp2-usb-phy";
+		reg = <0xd4207000 0x40>;
+		#phy-cells = <0>;
+		status = "okay";
+	};
+This document explains only the device tree data binding. For general
+information about PHY subsystem refer to Documentation/phy.txt

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

* [PATCH 02/14] dt-bindings: phy-pxa-usb: add bindings
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

This is the PHY chip for USB OTG on PXA platforms.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 .../devicetree/bindings/phy/phy-pxa-usb.txt     | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-pxa-usb.txt

diff --git a/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
new file mode 100644
index 000000000000..5b12ab44c9e6
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
@@ -0,0 +1,17 @@
+Marvell PXA USB PHY
+-------------------
+
+Required properties:
+- compatible: one of: "marvell,mmp2-usb-phy", "marvell,pxa910-usb-phy",
+	"marvell,pxa168-usb-phy",
+- #phy-cells: must be 0
+
+Example:
+	usb-phy: usbphy at d4207000 {
+		compatible = "marvell,mmp2-usb-phy";
+		reg = <0xd4207000 0x40>;
+		#phy-cells = <0>;
+		status = "okay";
+	};
+This document explains only the device tree data binding. For general
+information about PHY subsystem refer to Documentation/phy.txt
-- 
2.17.1

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

* [PATCH 03/14] USB: EHCI: make ehci-mv a separate driver
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This is done do that it could be enabled alongside other platform EHCI
glue drivers on multiplatform kernels.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/Kconfig    |  2 +-
 drivers/usb/host/Makefile   |  1 +
 drivers/usb/host/ehci-hcd.c |  5 --
 drivers/usb/host/ehci-mv.c  | 98 ++++++++++++++++---------------------
 4 files changed, 44 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1a4ea98cac2a..16758b12a5e9 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -276,7 +276,7 @@ config USB_EHCI_EXYNOS
 	Enable support for the Samsung Exynos SOC's on-chip EHCI controller.
 
 config USB_EHCI_MV
-	bool "EHCI support for Marvell PXA/MMP USB controller"
+	tristate "EHCI support for Marvell PXA/MMP USB controller"
 	depends on (ARCH_PXA || ARCH_MMP)
 	select USB_EHCI_ROOT_HUB_TT
 	---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e6235269c151..84514f71ae44 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_USB_IMX21_HCD)	+= imx21-hcd.o
 obj-$(CONFIG_USB_FSL_USB2)	+= fsl-mph-dr-of.o
 obj-$(CONFIG_USB_EHCI_FSL)	+= fsl-mph-dr-of.o
 obj-$(CONFIG_USB_EHCI_FSL)	+= ehci-fsl.o
+obj-$(CONFIG_USB_EHCI_MV)	+= ehci-mv.o
 obj-$(CONFIG_USB_HCD_BCMA)	+= bcma-hcd.o
 obj-$(CONFIG_USB_HCD_SSB)	+= ssb-hcd.o
 obj-$(CONFIG_USB_FOTG210_HCD)	+= fotg210-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 8608ac513fb7..e8d7667828eb 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1286,11 +1286,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		ehci_grlib_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_MV
-#include "ehci-mv.c"
-#define        PLATFORM_DRIVER         ehci_mv_driver
-#endif
-
 static int __init ehci_hcd_init(void)
 {
 	int retval = 0;
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index de764459e05a..77a4ab1dcd07 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -12,12 +12,17 @@
 #include <linux/err.h>
 #include <linux/usb/otg.h>
 #include <linux/platform_data/mv_usb.h>
+#include <linux/io.h>
+
+#include <linux/usb/hcd.h>
+
+#include "ehci.h"
 
 #define CAPLENGTH_MASK         (0xff)
 
-struct ehci_hcd_mv {
-	struct usb_hcd *hcd;
+#define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
 
+struct ehci_hcd_mv {
 	/* Which mode does this ehci running OTG/Host ? */
 	int mode;
 
@@ -66,7 +71,7 @@ static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv)
 static int mv_ehci_reset(struct usb_hcd *hcd)
 {
 	struct device *dev = hcd->self.controller;
-	struct ehci_hcd_mv *ehci_mv = dev_get_drvdata(dev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	int retval;
 
 	if (ehci_mv == NULL) {
@@ -83,46 +88,11 @@ static int mv_ehci_reset(struct usb_hcd *hcd)
 	return retval;
 }
 
-static const struct hc_driver mv_ehci_hc_driver = {
-	.description = hcd_name,
-	.product_desc = "Marvell EHCI",
-	.hcd_priv_size = sizeof(struct ehci_hcd),
-
-	/*
-	 * generic hardware linkage
-	 */
-	.irq = ehci_irq,
-	.flags = HCD_MEMORY | HCD_USB2 | HCD_BH,
-
-	/*
-	 * basic lifecycle operations
-	 */
-	.reset = mv_ehci_reset,
-	.start = ehci_run,
-	.stop = ehci_stop,
-	.shutdown = ehci_shutdown,
-
-	/*
-	 * managing i/o requests and associated device resources
-	 */
-	.urb_enqueue = ehci_urb_enqueue,
-	.urb_dequeue = ehci_urb_dequeue,
-	.endpoint_disable = ehci_endpoint_disable,
-	.endpoint_reset = ehci_endpoint_reset,
-	.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
-
-	/*
-	 * scheduling support
-	 */
-	.get_frame_number = ehci_get_frame,
-
-	/*
-	 * root hub support
-	 */
-	.hub_status_data = ehci_hub_status_data,
-	.hub_control = ehci_hub_control,
-	.bus_suspend = ehci_bus_suspend,
-	.bus_resume = ehci_bus_resume,
+static struct hc_driver __read_mostly ehci_platform_hc_driver;
+
+static const struct ehci_driver_overrides platform_overrides __initconst = {
+	.reset =		mv_ehci_reset,
+	.extra_priv_size =	sizeof(struct ehci_hcd_mv),
 };
 
 static int mv_ehci_probe(struct platform_device *pdev)
@@ -143,19 +113,13 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	if (usb_disabled())
 		return -ENODEV;
 
-	hcd = usb_create_hcd(&mv_ehci_hc_driver, &pdev->dev, "mv ehci");
+	hcd = usb_create_hcd(&ehci_platform_hc_driver, &pdev->dev, "mv ehci");
 	if (!hcd)
 		return -ENOMEM;
 
-	ehci_mv = devm_kzalloc(&pdev->dev, sizeof(*ehci_mv), GFP_KERNEL);
-	if (ehci_mv == NULL) {
-		retval = -ENOMEM;
-		goto err_put_hcd;
-	}
-
-	platform_set_drvdata(pdev, ehci_mv);
+	platform_set_drvdata(pdev, hcd);
+	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	ehci_mv->pdata = pdata;
-	ehci_mv->hcd = hcd;
 
 	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(ehci_mv->clk)) {
@@ -262,8 +226,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 
 static int mv_ehci_remove(struct platform_device *pdev)
 {
-	struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = ehci_mv->hcd;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (hcd->rh_registered)
 		usb_remove_hcd(hcd);
@@ -295,8 +259,8 @@ static const struct platform_device_id ehci_id_table[] = {
 
 static void mv_ehci_shutdown(struct platform_device *pdev)
 {
-	struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = ehci_mv->hcd;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (!hcd->rh_registered)
 		return;
@@ -315,3 +279,25 @@ static struct platform_driver ehci_mv_driver = {
 		   },
 	.id_table = ehci_id_table,
 };
+
+static int __init ehci_platform_init(void)
+{
+	if (usb_disabled())
+		return -ENODEV;
+
+	ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides);
+	return platform_driver_register(&ehci_mv_driver);
+}
+module_init(ehci_platform_init);
+
+static void __exit ehci_platform_cleanup(void)
+{
+	platform_driver_unregister(&ehci_mv_driver);
+}
+module_exit(ehci_platform_cleanup);
+
+MODULE_DESCRIPTION("Marvell EHCI driver");
+MODULE_AUTHOR("Chao Xie <chao.xie@marvell.com>");
+MODULE_AUTHOR("Neil Zhang <zhangwm@marvell.com>");
+MODULE_ALIAS("mv-ehci");
+MODULE_LICENSE("GPL");
-- 
2.17.1


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

* [03/14] USB: EHCI: make ehci-mv a separate driver
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This is done do that it could be enabled alongside other platform EHCI
glue drivers on multiplatform kernels.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/Kconfig    |  2 +-
 drivers/usb/host/Makefile   |  1 +
 drivers/usb/host/ehci-hcd.c |  5 --
 drivers/usb/host/ehci-mv.c  | 98 ++++++++++++++++---------------------
 4 files changed, 44 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1a4ea98cac2a..16758b12a5e9 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -276,7 +276,7 @@ config USB_EHCI_EXYNOS
 	Enable support for the Samsung Exynos SOC's on-chip EHCI controller.
 
 config USB_EHCI_MV
-	bool "EHCI support for Marvell PXA/MMP USB controller"
+	tristate "EHCI support for Marvell PXA/MMP USB controller"
 	depends on (ARCH_PXA || ARCH_MMP)
 	select USB_EHCI_ROOT_HUB_TT
 	---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e6235269c151..84514f71ae44 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_USB_IMX21_HCD)	+= imx21-hcd.o
 obj-$(CONFIG_USB_FSL_USB2)	+= fsl-mph-dr-of.o
 obj-$(CONFIG_USB_EHCI_FSL)	+= fsl-mph-dr-of.o
 obj-$(CONFIG_USB_EHCI_FSL)	+= ehci-fsl.o
+obj-$(CONFIG_USB_EHCI_MV)	+= ehci-mv.o
 obj-$(CONFIG_USB_HCD_BCMA)	+= bcma-hcd.o
 obj-$(CONFIG_USB_HCD_SSB)	+= ssb-hcd.o
 obj-$(CONFIG_USB_FOTG210_HCD)	+= fotg210-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 8608ac513fb7..e8d7667828eb 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1286,11 +1286,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		ehci_grlib_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_MV
-#include "ehci-mv.c"
-#define        PLATFORM_DRIVER         ehci_mv_driver
-#endif
-
 static int __init ehci_hcd_init(void)
 {
 	int retval = 0;
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index de764459e05a..77a4ab1dcd07 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -12,12 +12,17 @@
 #include <linux/err.h>
 #include <linux/usb/otg.h>
 #include <linux/platform_data/mv_usb.h>
+#include <linux/io.h>
+
+#include <linux/usb/hcd.h>
+
+#include "ehci.h"
 
 #define CAPLENGTH_MASK         (0xff)
 
-struct ehci_hcd_mv {
-	struct usb_hcd *hcd;
+#define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
 
+struct ehci_hcd_mv {
 	/* Which mode does this ehci running OTG/Host ? */
 	int mode;
 
@@ -66,7 +71,7 @@ static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv)
 static int mv_ehci_reset(struct usb_hcd *hcd)
 {
 	struct device *dev = hcd->self.controller;
-	struct ehci_hcd_mv *ehci_mv = dev_get_drvdata(dev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	int retval;
 
 	if (ehci_mv == NULL) {
@@ -83,46 +88,11 @@ static int mv_ehci_reset(struct usb_hcd *hcd)
 	return retval;
 }
 
-static const struct hc_driver mv_ehci_hc_driver = {
-	.description = hcd_name,
-	.product_desc = "Marvell EHCI",
-	.hcd_priv_size = sizeof(struct ehci_hcd),
-
-	/*
-	 * generic hardware linkage
-	 */
-	.irq = ehci_irq,
-	.flags = HCD_MEMORY | HCD_USB2 | HCD_BH,
-
-	/*
-	 * basic lifecycle operations
-	 */
-	.reset = mv_ehci_reset,
-	.start = ehci_run,
-	.stop = ehci_stop,
-	.shutdown = ehci_shutdown,
-
-	/*
-	 * managing i/o requests and associated device resources
-	 */
-	.urb_enqueue = ehci_urb_enqueue,
-	.urb_dequeue = ehci_urb_dequeue,
-	.endpoint_disable = ehci_endpoint_disable,
-	.endpoint_reset = ehci_endpoint_reset,
-	.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
-
-	/*
-	 * scheduling support
-	 */
-	.get_frame_number = ehci_get_frame,
-
-	/*
-	 * root hub support
-	 */
-	.hub_status_data = ehci_hub_status_data,
-	.hub_control = ehci_hub_control,
-	.bus_suspend = ehci_bus_suspend,
-	.bus_resume = ehci_bus_resume,
+static struct hc_driver __read_mostly ehci_platform_hc_driver;
+
+static const struct ehci_driver_overrides platform_overrides __initconst = {
+	.reset =		mv_ehci_reset,
+	.extra_priv_size =	sizeof(struct ehci_hcd_mv),
 };
 
 static int mv_ehci_probe(struct platform_device *pdev)
@@ -143,19 +113,13 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	if (usb_disabled())
 		return -ENODEV;
 
-	hcd = usb_create_hcd(&mv_ehci_hc_driver, &pdev->dev, "mv ehci");
+	hcd = usb_create_hcd(&ehci_platform_hc_driver, &pdev->dev, "mv ehci");
 	if (!hcd)
 		return -ENOMEM;
 
-	ehci_mv = devm_kzalloc(&pdev->dev, sizeof(*ehci_mv), GFP_KERNEL);
-	if (ehci_mv == NULL) {
-		retval = -ENOMEM;
-		goto err_put_hcd;
-	}
-
-	platform_set_drvdata(pdev, ehci_mv);
+	platform_set_drvdata(pdev, hcd);
+	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	ehci_mv->pdata = pdata;
-	ehci_mv->hcd = hcd;
 
 	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(ehci_mv->clk)) {
@@ -262,8 +226,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 
 static int mv_ehci_remove(struct platform_device *pdev)
 {
-	struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = ehci_mv->hcd;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (hcd->rh_registered)
 		usb_remove_hcd(hcd);
@@ -295,8 +259,8 @@ static const struct platform_device_id ehci_id_table[] = {
 
 static void mv_ehci_shutdown(struct platform_device *pdev)
 {
-	struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = ehci_mv->hcd;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (!hcd->rh_registered)
 		return;
@@ -315,3 +279,25 @@ static struct platform_driver ehci_mv_driver = {
 		   },
 	.id_table = ehci_id_table,
 };
+
+static int __init ehci_platform_init(void)
+{
+	if (usb_disabled())
+		return -ENODEV;
+
+	ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides);
+	return platform_driver_register(&ehci_mv_driver);
+}
+module_init(ehci_platform_init);
+
+static void __exit ehci_platform_cleanup(void)
+{
+	platform_driver_unregister(&ehci_mv_driver);
+}
+module_exit(ehci_platform_cleanup);
+
+MODULE_DESCRIPTION("Marvell EHCI driver");
+MODULE_AUTHOR("Chao Xie <chao.xie@marvell.com>");
+MODULE_AUTHOR("Neil Zhang <zhangwm@marvell.com>");
+MODULE_ALIAS("mv-ehci");
+MODULE_LICENSE("GPL");

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

* [PATCH 03/14] USB: EHCI: make ehci-mv a separate driver
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

This is done do that it could be enabled alongside other platform EHCI
glue drivers on multiplatform kernels.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/Kconfig    |  2 +-
 drivers/usb/host/Makefile   |  1 +
 drivers/usb/host/ehci-hcd.c |  5 --
 drivers/usb/host/ehci-mv.c  | 98 ++++++++++++++++---------------------
 4 files changed, 44 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1a4ea98cac2a..16758b12a5e9 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -276,7 +276,7 @@ config USB_EHCI_EXYNOS
 	Enable support for the Samsung Exynos SOC's on-chip EHCI controller.
 
 config USB_EHCI_MV
-	bool "EHCI support for Marvell PXA/MMP USB controller"
+	tristate "EHCI support for Marvell PXA/MMP USB controller"
 	depends on (ARCH_PXA || ARCH_MMP)
 	select USB_EHCI_ROOT_HUB_TT
 	---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e6235269c151..84514f71ae44 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_USB_IMX21_HCD)	+= imx21-hcd.o
 obj-$(CONFIG_USB_FSL_USB2)	+= fsl-mph-dr-of.o
 obj-$(CONFIG_USB_EHCI_FSL)	+= fsl-mph-dr-of.o
 obj-$(CONFIG_USB_EHCI_FSL)	+= ehci-fsl.o
+obj-$(CONFIG_USB_EHCI_MV)	+= ehci-mv.o
 obj-$(CONFIG_USB_HCD_BCMA)	+= bcma-hcd.o
 obj-$(CONFIG_USB_HCD_SSB)	+= ssb-hcd.o
 obj-$(CONFIG_USB_FOTG210_HCD)	+= fotg210-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 8608ac513fb7..e8d7667828eb 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1286,11 +1286,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		ehci_grlib_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_MV
-#include "ehci-mv.c"
-#define        PLATFORM_DRIVER         ehci_mv_driver
-#endif
-
 static int __init ehci_hcd_init(void)
 {
 	int retval = 0;
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index de764459e05a..77a4ab1dcd07 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -12,12 +12,17 @@
 #include <linux/err.h>
 #include <linux/usb/otg.h>
 #include <linux/platform_data/mv_usb.h>
+#include <linux/io.h>
+
+#include <linux/usb/hcd.h>
+
+#include "ehci.h"
 
 #define CAPLENGTH_MASK         (0xff)
 
-struct ehci_hcd_mv {
-	struct usb_hcd *hcd;
+#define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
 
+struct ehci_hcd_mv {
 	/* Which mode does this ehci running OTG/Host ? */
 	int mode;
 
@@ -66,7 +71,7 @@ static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv)
 static int mv_ehci_reset(struct usb_hcd *hcd)
 {
 	struct device *dev = hcd->self.controller;
-	struct ehci_hcd_mv *ehci_mv = dev_get_drvdata(dev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	int retval;
 
 	if (ehci_mv == NULL) {
@@ -83,46 +88,11 @@ static int mv_ehci_reset(struct usb_hcd *hcd)
 	return retval;
 }
 
-static const struct hc_driver mv_ehci_hc_driver = {
-	.description = hcd_name,
-	.product_desc = "Marvell EHCI",
-	.hcd_priv_size = sizeof(struct ehci_hcd),
-
-	/*
-	 * generic hardware linkage
-	 */
-	.irq = ehci_irq,
-	.flags = HCD_MEMORY | HCD_USB2 | HCD_BH,
-
-	/*
-	 * basic lifecycle operations
-	 */
-	.reset = mv_ehci_reset,
-	.start = ehci_run,
-	.stop = ehci_stop,
-	.shutdown = ehci_shutdown,
-
-	/*
-	 * managing i/o requests and associated device resources
-	 */
-	.urb_enqueue = ehci_urb_enqueue,
-	.urb_dequeue = ehci_urb_dequeue,
-	.endpoint_disable = ehci_endpoint_disable,
-	.endpoint_reset = ehci_endpoint_reset,
-	.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
-
-	/*
-	 * scheduling support
-	 */
-	.get_frame_number = ehci_get_frame,
-
-	/*
-	 * root hub support
-	 */
-	.hub_status_data = ehci_hub_status_data,
-	.hub_control = ehci_hub_control,
-	.bus_suspend = ehci_bus_suspend,
-	.bus_resume = ehci_bus_resume,
+static struct hc_driver __read_mostly ehci_platform_hc_driver;
+
+static const struct ehci_driver_overrides platform_overrides __initconst = {
+	.reset =		mv_ehci_reset,
+	.extra_priv_size =	sizeof(struct ehci_hcd_mv),
 };
 
 static int mv_ehci_probe(struct platform_device *pdev)
@@ -143,19 +113,13 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	if (usb_disabled())
 		return -ENODEV;
 
-	hcd = usb_create_hcd(&mv_ehci_hc_driver, &pdev->dev, "mv ehci");
+	hcd = usb_create_hcd(&ehci_platform_hc_driver, &pdev->dev, "mv ehci");
 	if (!hcd)
 		return -ENOMEM;
 
-	ehci_mv = devm_kzalloc(&pdev->dev, sizeof(*ehci_mv), GFP_KERNEL);
-	if (ehci_mv == NULL) {
-		retval = -ENOMEM;
-		goto err_put_hcd;
-	}
-
-	platform_set_drvdata(pdev, ehci_mv);
+	platform_set_drvdata(pdev, hcd);
+	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	ehci_mv->pdata = pdata;
-	ehci_mv->hcd = hcd;
 
 	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(ehci_mv->clk)) {
@@ -262,8 +226,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 
 static int mv_ehci_remove(struct platform_device *pdev)
 {
-	struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = ehci_mv->hcd;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (hcd->rh_registered)
 		usb_remove_hcd(hcd);
@@ -295,8 +259,8 @@ static const struct platform_device_id ehci_id_table[] = {
 
 static void mv_ehci_shutdown(struct platform_device *pdev)
 {
-	struct ehci_hcd_mv *ehci_mv = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = ehci_mv->hcd;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (!hcd->rh_registered)
 		return;
@@ -315,3 +279,25 @@ static struct platform_driver ehci_mv_driver = {
 		   },
 	.id_table = ehci_id_table,
 };
+
+static int __init ehci_platform_init(void)
+{
+	if (usb_disabled())
+		return -ENODEV;
+
+	ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides);
+	return platform_driver_register(&ehci_mv_driver);
+}
+module_init(ehci_platform_init);
+
+static void __exit ehci_platform_cleanup(void)
+{
+	platform_driver_unregister(&ehci_mv_driver);
+}
+module_exit(ehci_platform_cleanup);
+
+MODULE_DESCRIPTION("Marvell EHCI driver");
+MODULE_AUTHOR("Chao Xie <chao.xie@marvell.com>");
+MODULE_AUTHOR("Neil Zhang <zhangwm@marvell.com>");
+MODULE_ALIAS("mv-ehci");
+MODULE_LICENSE("GPL");
-- 
2.17.1

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

* [PATCH 04/14] ARM: mmp: add a pxa-usb-phy device
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This is to replace the USB PHY initialization code (pxa_usb_phy_init(),
pxa_usb_phy_deinit()) with a proper PHY driver.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c | 21 +++++++++++++++++++++
 arch/arm/mach-mmp/pxa910.h  |  1 +
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index 671c7a09ab3d..d162fabd38e7 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -240,6 +240,27 @@ void pxa_usb_phy_deinit(void __iomem *phy_reg)
 #if IS_ENABLED(CONFIG_USB_SUPPORT)
 static u64 __maybe_unused usb_dma_mask = ~(u32)0;
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+struct resource pxa168_usb_phy_resources[] = {
+	[0] = {
+		.start	= PXA168_U2O_PHYBASE,
+		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+struct platform_device pxa168_device_usb_phy = {
+	.name		= "pxa-usb-phy",
+	.id		= -1,
+	.resource	= pxa168_usb_phy_resources,
+	.num_resources	= ARRAY_SIZE(pxa168_usb_phy_resources),
+	.dev		=  {
+		.dma_mask	= &usb_dma_mask,
+		.coherent_dma_mask = 0xffffffff,
+	}
+};
+#endif /* CONFIG_PHY_PXA_USB */
+
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 struct resource pxa168_u2o_resources[] = {
 	/* regbase */
diff --git a/arch/arm/mach-mmp/pxa910.h b/arch/arm/mach-mmp/pxa910.h
index 42009c349eae..2dfe38e4acc1 100644
--- a/arch/arm/mach-mmp/pxa910.h
+++ b/arch/arm/mach-mmp/pxa910.h
@@ -22,6 +22,7 @@ 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_usb_phy;
 extern struct platform_device pxa168_device_u2o;
 extern struct platform_device pxa168_device_u2ootg;
 extern struct platform_device pxa168_device_u2oehci;
-- 
2.17.1


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

* [04/14] ARM: mmp: add a pxa-usb-phy device
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This is to replace the USB PHY initialization code (pxa_usb_phy_init(),
pxa_usb_phy_deinit()) with a proper PHY driver.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c | 21 +++++++++++++++++++++
 arch/arm/mach-mmp/pxa910.h  |  1 +
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index 671c7a09ab3d..d162fabd38e7 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -240,6 +240,27 @@ void pxa_usb_phy_deinit(void __iomem *phy_reg)
 #if IS_ENABLED(CONFIG_USB_SUPPORT)
 static u64 __maybe_unused usb_dma_mask = ~(u32)0;
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+struct resource pxa168_usb_phy_resources[] = {
+	[0] = {
+		.start	= PXA168_U2O_PHYBASE,
+		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+struct platform_device pxa168_device_usb_phy = {
+	.name		= "pxa-usb-phy",
+	.id		= -1,
+	.resource	= pxa168_usb_phy_resources,
+	.num_resources	= ARRAY_SIZE(pxa168_usb_phy_resources),
+	.dev		=  {
+		.dma_mask	= &usb_dma_mask,
+		.coherent_dma_mask = 0xffffffff,
+	}
+};
+#endif /* CONFIG_PHY_PXA_USB */
+
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 struct resource pxa168_u2o_resources[] = {
 	/* regbase */
diff --git a/arch/arm/mach-mmp/pxa910.h b/arch/arm/mach-mmp/pxa910.h
index 42009c349eae..2dfe38e4acc1 100644
--- a/arch/arm/mach-mmp/pxa910.h
+++ b/arch/arm/mach-mmp/pxa910.h
@@ -22,6 +22,7 @@ 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_usb_phy;
 extern struct platform_device pxa168_device_u2o;
 extern struct platform_device pxa168_device_u2ootg;
 extern struct platform_device pxa168_device_u2oehci;

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

* [PATCH 04/14] ARM: mmp: add a pxa-usb-phy device
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

This is to replace the USB PHY initialization code (pxa_usb_phy_init(),
pxa_usb_phy_deinit()) with a proper PHY driver.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c | 21 +++++++++++++++++++++
 arch/arm/mach-mmp/pxa910.h  |  1 +
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index 671c7a09ab3d..d162fabd38e7 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -240,6 +240,27 @@ void pxa_usb_phy_deinit(void __iomem *phy_reg)
 #if IS_ENABLED(CONFIG_USB_SUPPORT)
 static u64 __maybe_unused usb_dma_mask = ~(u32)0;
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+struct resource pxa168_usb_phy_resources[] = {
+	[0] = {
+		.start	= PXA168_U2O_PHYBASE,
+		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+struct platform_device pxa168_device_usb_phy = {
+	.name		= "pxa-usb-phy",
+	.id		= -1,
+	.resource	= pxa168_usb_phy_resources,
+	.num_resources	= ARRAY_SIZE(pxa168_usb_phy_resources),
+	.dev		=  {
+		.dma_mask	= &usb_dma_mask,
+		.coherent_dma_mask = 0xffffffff,
+	}
+};
+#endif /* CONFIG_PHY_PXA_USB */
+
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 struct resource pxa168_u2o_resources[] = {
 	/* regbase */
diff --git a/arch/arm/mach-mmp/pxa910.h b/arch/arm/mach-mmp/pxa910.h
index 42009c349eae..2dfe38e4acc1 100644
--- a/arch/arm/mach-mmp/pxa910.h
+++ b/arch/arm/mach-mmp/pxa910.h
@@ -22,6 +22,7 @@ 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_usb_phy;
 extern struct platform_device pxa168_device_u2o;
 extern struct platform_device pxa168_device_u2ootg;
 extern struct platform_device pxa168_device_u2oehci;
-- 
2.17.1

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

* [PATCH 05/14] ARM: ttc_dkb: add an instance of pxa-usb-phy
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This will replace the ttc_usb_pdata.phy_{de,}init()>

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/ttc_dkb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index c7897fb2b6da..767dcb23ee1c 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -282,6 +282,10 @@ static void __init ttc_dkb_init(void)
 				 sizeof(struct pxa_gpio_platform_data));
 	platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+	platform_device_register(&pxa168_device_usb_phy);
+#endif
+
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 	pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
 	platform_device_register(&pxa168_device_u2o);
-- 
2.17.1


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

* [05/14] ARM: ttc_dkb: add an instance of pxa-usb-phy
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This will replace the ttc_usb_pdata.phy_{de,}init()>

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/ttc_dkb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index c7897fb2b6da..767dcb23ee1c 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -282,6 +282,10 @@ static void __init ttc_dkb_init(void)
 				 sizeof(struct pxa_gpio_platform_data));
 	platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+	platform_device_register(&pxa168_device_usb_phy);
+#endif
+
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 	pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
 	platform_device_register(&pxa168_device_u2o);

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

* [PATCH 05/14] ARM: ttc_dkb: add an instance of pxa-usb-phy
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

This will replace the ttc_usb_pdata.phy_{de,}init()>

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/ttc_dkb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index c7897fb2b6da..767dcb23ee1c 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -282,6 +282,10 @@ static void __init ttc_dkb_init(void)
 				 sizeof(struct pxa_gpio_platform_data));
 	platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+	platform_device_register(&pxa168_device_usb_phy);
+#endif
+
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 	pxa168_device_u2o.dev.platform_data = &ttc_usb_pdata;
 	platform_device_register(&pxa168_device_u2o);
-- 
2.17.1

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

* [PATCH 06/14] ARM: aspenite: add an instance of pxa-usb-phy
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This will replace the pxa168_sph_pdata.phy_{de,}init().

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/aspenite.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c
index 6c2ebf01893a..23f99976b5f5 100644
--- a/arch/arm/mach-mmp/aspenite.c
+++ b/arch/arm/mach-mmp/aspenite.c
@@ -256,6 +256,10 @@ static void __init common_init(void)
 	/* off-chip devices */
 	platform_device_register(&smc91x_device);
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+	platform_device_register(&pxa168_device_usb_phy);
+#endif
+
 #if IS_ENABLED(CONFIG_USB_EHCI_MV)
 	pxa168_add_usb_host(&pxa168_sph_pdata);
 #endif
-- 
2.17.1


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

* [06/14] ARM: aspenite: add an instance of pxa-usb-phy
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

This will replace the pxa168_sph_pdata.phy_{de,}init().

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/aspenite.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c
index 6c2ebf01893a..23f99976b5f5 100644
--- a/arch/arm/mach-mmp/aspenite.c
+++ b/arch/arm/mach-mmp/aspenite.c
@@ -256,6 +256,10 @@ static void __init common_init(void)
 	/* off-chip devices */
 	platform_device_register(&smc91x_device);
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+	platform_device_register(&pxa168_device_usb_phy);
+#endif
+
 #if IS_ENABLED(CONFIG_USB_EHCI_MV)
 	pxa168_add_usb_host(&pxa168_sph_pdata);
 #endif

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

* [PATCH 06/14] ARM: aspenite: add an instance of pxa-usb-phy
@ 2018-08-22 20:42   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

This will replace the pxa168_sph_pdata.phy_{de,}init().

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/aspenite.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c
index 6c2ebf01893a..23f99976b5f5 100644
--- a/arch/arm/mach-mmp/aspenite.c
+++ b/arch/arm/mach-mmp/aspenite.c
@@ -256,6 +256,10 @@ static void __init common_init(void)
 	/* off-chip devices */
 	platform_device_register(&smc91x_device);
 
+#if IS_ENABLED(CONFIG_PHY_PXA_USB)
+	platform_device_register(&pxa168_device_usb_phy);
+#endif
+
 #if IS_ENABLED(CONFIG_USB_EHCI_MV)
 	pxa168_add_usb_host(&pxa168_sph_pdata);
 #endif
-- 
2.17.1

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

* [PATCH 07/14] USB: EHCI: ehci-mv: remove private_init
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

It's unused.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/ehci-mv.c           | 4 ----
 include/linux/platform_data/mv_usb.h | 1 -
 2 files changed, 5 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 77a4ab1dcd07..705d1b43b2dd 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -203,9 +203,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		device_wakeup_enable(hcd->self.controller);
 	}
 
-	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,
@@ -260,7 +257,6 @@ static const struct platform_device_id ehci_id_table[] = {
 static void mv_ehci_shutdown(struct platform_device *pdev)
 {
 	struct usb_hcd *hcd = platform_get_drvdata(pdev);
-	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (!hcd->rh_registered)
 		return;
diff --git a/include/linux/platform_data/mv_usb.h b/include/linux/platform_data/mv_usb.h
index 98b7925f1a2d..c0f624aca81c 100644
--- a/include/linux/platform_data/mv_usb.h
+++ b/include/linux/platform_data/mv_usb.h
@@ -48,6 +48,5 @@ struct mv_usb_platform_data {
 	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
-- 
2.17.1


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

* [07/14] USB: EHCI: ehci-mv: remove private_init
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

It's unused.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/ehci-mv.c           | 4 ----
 include/linux/platform_data/mv_usb.h | 1 -
 2 files changed, 5 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 77a4ab1dcd07..705d1b43b2dd 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -203,9 +203,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		device_wakeup_enable(hcd->self.controller);
 	}
 
-	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,
@@ -260,7 +257,6 @@ static const struct platform_device_id ehci_id_table[] = {
 static void mv_ehci_shutdown(struct platform_device *pdev)
 {
 	struct usb_hcd *hcd = platform_get_drvdata(pdev);
-	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (!hcd->rh_registered)
 		return;
diff --git a/include/linux/platform_data/mv_usb.h b/include/linux/platform_data/mv_usb.h
index 98b7925f1a2d..c0f624aca81c 100644
--- a/include/linux/platform_data/mv_usb.h
+++ b/include/linux/platform_data/mv_usb.h
@@ -48,6 +48,5 @@ struct mv_usb_platform_data {
 	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

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

* [PATCH 07/14] USB: EHCI: ehci-mv: remove private_init
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-arm-kernel

It's unused.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/ehci-mv.c           | 4 ----
 include/linux/platform_data/mv_usb.h | 1 -
 2 files changed, 5 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 77a4ab1dcd07..705d1b43b2dd 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -203,9 +203,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		device_wakeup_enable(hcd->self.controller);
 	}
 
-	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,
@@ -260,7 +257,6 @@ static const struct platform_device_id ehci_id_table[] = {
 static void mv_ehci_shutdown(struct platform_device *pdev)
 {
 	struct usb_hcd *hcd = platform_get_drvdata(pdev);
-	struct ehci_hcd_mv *ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 
 	if (!hcd->rh_registered)
 		return;
diff --git a/include/linux/platform_data/mv_usb.h b/include/linux/platform_data/mv_usb.h
index 98b7925f1a2d..c0f624aca81c 100644
--- a/include/linux/platform_data/mv_usb.h
+++ b/include/linux/platform_data/mv_usb.h
@@ -48,6 +48,5 @@ struct mv_usb_platform_data {
 	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
-- 
2.17.1

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

* [PATCH 08/14] USB: EHCI: ehci-mv: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c | 11 +---------
 drivers/usb/host/ehci-mv.c  | 44 ++++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index d162fabd38e7..822b8be042b9 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -298,21 +298,12 @@ struct platform_device pxa168_device_u2o = {
 
 #if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
 struct resource pxa168_u2oehci_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 705d1b43b2dd..43b300c90875 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -18,6 +18,9 @@
 
 #include "ehci.h"
 
+/* registers */
+#define U2x_CAPREGS_OFFSET       0x100
+
 #define CAPLENGTH_MASK         (0xff)
 
 #define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
@@ -26,13 +29,14 @@ struct ehci_hcd_mv {
 	/* Which mode does this ehci running OTG/Host ? */
 	int mode;
 
-	void __iomem *phy_regs;
+	void __iomem *base;
 	void __iomem *cap_regs;
 	void __iomem *op_regs;
 
 	struct usb_phy *otg;
 
 	struct mv_usb_platform_data *pdata;
+	struct phy *phy;
 
 	struct clk *clk;
 };
@@ -49,22 +53,13 @@ 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 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);
+	phy_exit(ehci_mv->phy);
 	ehci_clock_disable(ehci_mv);
 }
 
@@ -121,6 +116,14 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	ehci_mv->pdata = pdata;
 
+	ehci_mv->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(ehci_mv->phy)) {
+		retval = PTR_ERR(ehci_mv->phy);
+		if (retval != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Failed to get phy.\n");
+		goto err_put_hcd;
+	}
+
 	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(ehci_mv->clk)) {
 		dev_err(&pdev->dev, "error getting clock\n");
@@ -128,17 +131,12 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		goto err_put_hcd;
 	}
 
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs");
-	ehci_mv->phy_regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(ehci_mv->phy_regs)) {
-		retval = PTR_ERR(ehci_mv->phy_regs);
-		goto err_put_hcd;
-	}
 
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs");
-	ehci_mv->cap_regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(ehci_mv->cap_regs)) {
-		retval = PTR_ERR(ehci_mv->cap_regs);
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	ehci_mv->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(ehci_mv->base)) {
+		retval = PTR_ERR(ehci_mv->base);
 		goto err_put_hcd;
 	}
 
@@ -148,6 +146,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		goto err_put_hcd;
 	}
 
+	ehci_mv->cap_regs =
+		(void __iomem *) ((unsigned long) ehci_mv->base + U2x_CAPREGS_OFFSET);
 	offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK;
 	ehci_mv->op_regs =
 		(void __iomem *) ((unsigned long) ehci_mv->cap_regs + offset);
-- 
2.17.1


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

* [08/14] USB: EHCI: ehci-mv: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c | 11 +---------
 drivers/usb/host/ehci-mv.c  | 44 ++++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index d162fabd38e7..822b8be042b9 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -298,21 +298,12 @@ struct platform_device pxa168_device_u2o = {
 
 #if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
 struct resource pxa168_u2oehci_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 705d1b43b2dd..43b300c90875 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -18,6 +18,9 @@
 
 #include "ehci.h"
 
+/* registers */
+#define U2x_CAPREGS_OFFSET       0x100
+
 #define CAPLENGTH_MASK         (0xff)
 
 #define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
@@ -26,13 +29,14 @@ struct ehci_hcd_mv {
 	/* Which mode does this ehci running OTG/Host ? */
 	int mode;
 
-	void __iomem *phy_regs;
+	void __iomem *base;
 	void __iomem *cap_regs;
 	void __iomem *op_regs;
 
 	struct usb_phy *otg;
 
 	struct mv_usb_platform_data *pdata;
+	struct phy *phy;
 
 	struct clk *clk;
 };
@@ -49,22 +53,13 @@ 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 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);
+	phy_exit(ehci_mv->phy);
 	ehci_clock_disable(ehci_mv);
 }
 
@@ -121,6 +116,14 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	ehci_mv->pdata = pdata;
 
+	ehci_mv->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(ehci_mv->phy)) {
+		retval = PTR_ERR(ehci_mv->phy);
+		if (retval != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Failed to get phy.\n");
+		goto err_put_hcd;
+	}
+
 	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(ehci_mv->clk)) {
 		dev_err(&pdev->dev, "error getting clock\n");
@@ -128,17 +131,12 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		goto err_put_hcd;
 	}
 
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs");
-	ehci_mv->phy_regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(ehci_mv->phy_regs)) {
-		retval = PTR_ERR(ehci_mv->phy_regs);
-		goto err_put_hcd;
-	}
 
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs");
-	ehci_mv->cap_regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(ehci_mv->cap_regs)) {
-		retval = PTR_ERR(ehci_mv->cap_regs);
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	ehci_mv->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(ehci_mv->base)) {
+		retval = PTR_ERR(ehci_mv->base);
 		goto err_put_hcd;
 	}
 
@@ -148,6 +146,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		goto err_put_hcd;
 	}
 
+	ehci_mv->cap_regs =
+		(void __iomem *) ((unsigned long) ehci_mv->base + U2x_CAPREGS_OFFSET);
 	offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK;
 	ehci_mv->op_regs =
 		(void __iomem *) ((unsigned long) ehci_mv->cap_regs + offset);

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

* [PATCH 08/14] USB: EHCI: ehci-mv: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-arm-kernel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c | 11 +---------
 drivers/usb/host/ehci-mv.c  | 44 ++++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index d162fabd38e7..822b8be042b9 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -298,21 +298,12 @@ struct platform_device pxa168_device_u2o = {
 
 #if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O)
 struct resource pxa168_u2oehci_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 705d1b43b2dd..43b300c90875 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -18,6 +18,9 @@
 
 #include "ehci.h"
 
+/* registers */
+#define U2x_CAPREGS_OFFSET       0x100
+
 #define CAPLENGTH_MASK         (0xff)
 
 #define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
@@ -26,13 +29,14 @@ struct ehci_hcd_mv {
 	/* Which mode does this ehci running OTG/Host ? */
 	int mode;
 
-	void __iomem *phy_regs;
+	void __iomem *base;
 	void __iomem *cap_regs;
 	void __iomem *op_regs;
 
 	struct usb_phy *otg;
 
 	struct mv_usb_platform_data *pdata;
+	struct phy *phy;
 
 	struct clk *clk;
 };
@@ -49,22 +53,13 @@ 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 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);
+	phy_exit(ehci_mv->phy);
 	ehci_clock_disable(ehci_mv);
 }
 
@@ -121,6 +116,14 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
 	ehci_mv->pdata = pdata;
 
+	ehci_mv->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(ehci_mv->phy)) {
+		retval = PTR_ERR(ehci_mv->phy);
+		if (retval != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Failed to get phy.\n");
+		goto err_put_hcd;
+	}
+
 	ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(ehci_mv->clk)) {
 		dev_err(&pdev->dev, "error getting clock\n");
@@ -128,17 +131,12 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		goto err_put_hcd;
 	}
 
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs");
-	ehci_mv->phy_regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(ehci_mv->phy_regs)) {
-		retval = PTR_ERR(ehci_mv->phy_regs);
-		goto err_put_hcd;
-	}
 
-	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs");
-	ehci_mv->cap_regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(ehci_mv->cap_regs)) {
-		retval = PTR_ERR(ehci_mv->cap_regs);
+
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	ehci_mv->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(ehci_mv->base)) {
+		retval = PTR_ERR(ehci_mv->base);
 		goto err_put_hcd;
 	}
 
@@ -148,6 +146,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		goto err_put_hcd;
 	}
 
+	ehci_mv->cap_regs =
+		(void __iomem *) ((unsigned long) ehci_mv->base + U2x_CAPREGS_OFFSET);
 	offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK;
 	ehci_mv->op_regs =
 		(void __iomem *) ((unsigned long) ehci_mv->cap_regs + offset);
-- 
2.17.1

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

* [PATCH 09/14] USB: phy-mv-usb: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c  |  11 +---
 drivers/usb/phy/phy-mv-usb.c | 123 ++++++++++++++++-------------------
 drivers/usb/phy/phy-mv-usb.h |   8 ++-
 3 files changed, 62 insertions(+), 80 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index 822b8be042b9..eb9b3c34e90a 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -325,21 +325,12 @@ struct platform_device pxa168_device_u2oehci = {
 
 #if IS_ENABLED(CONFIG_USB_MV_OTG)
 struct resource pxa168_u2ootg_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index cfd9add10bf4..0f67c5b65fe9 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -50,7 +50,7 @@ static char *state_string[] = {
 
 static int mv_otg_set_vbus(struct usb_otg *otg, bool on)
 {
-	struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, phy);
+	struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, usb_phy);
 	if (mvotg->pdata->set_vbus == NULL)
 		return -ENODEV;
 
@@ -193,7 +193,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg)
 static void mv_otg_start_host(struct mv_otg *mvotg, int on)
 {
 #ifdef CONFIG_USB
-	struct usb_otg *otg = mvotg->phy.otg;
+	struct usb_otg *otg = mvotg->usb_phy.otg;
 	struct usb_hcd *hcd;
 
 	if (!otg->host)
@@ -214,12 +214,12 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on)
 
 static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
 {
-	struct usb_otg *otg = mvotg->phy.otg;
+	struct usb_otg *otg = mvotg->usb_phy.otg;
 
 	if (!otg->gadget)
 		return;
 
-	dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off");
+	dev_info(mvotg->usb_phy.dev, "gadget %s\n", on ? "on" : "off");
 
 	if (on)
 		usb_gadget_vbus_connect(otg->gadget);
@@ -247,14 +247,11 @@ 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 = phy_init(mvotg->phy);
+	if (retval) {
+		dev_err(&mvotg->pdev->dev, "init phy error %d\n", retval);
+		otg_clock_disable(mvotg);
+		return retval;
 	}
 	mvotg->active = 1;
 
@@ -274,8 +271,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);
+		phy_exit(mvotg->phy);
 		otg_clock_disable(mvotg);
 		mvotg->active = 0;
 	}
@@ -329,68 +325,68 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg)
 static void mv_otg_update_state(struct mv_otg *mvotg)
 {
 	struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
-	int old_state = mvotg->phy.otg->state;
+	int old_state = mvotg->usb_phy.otg->state;
 
 	switch (old_state) {
 	case OTG_STATE_UNDEFINED:
-		mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+		mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		/* FALL THROUGH */
 	case OTG_STATE_B_IDLE:
 		if (otg_ctrl->id == 0)
-			mvotg->phy.otg->state = OTG_STATE_A_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_IDLE;
 		else if (otg_ctrl->b_sess_vld)
-			mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_PERIPHERAL;
 		break;
 	case OTG_STATE_B_PERIPHERAL:
 		if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
-			mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		break;
 	case OTG_STATE_A_IDLE:
 		if (otg_ctrl->id)
-			mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		else if (!(otg_ctrl->a_bus_drop) &&
 			 (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VRISE;
 		break;
 	case OTG_STATE_A_WAIT_VRISE:
 		if (otg_ctrl->a_vbus_vld)
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_BCON;
 		break;
 	case OTG_STATE_A_WAIT_BCON:
 		if (otg_ctrl->id || otg_ctrl->a_bus_drop
 		    || otg_ctrl->a_wait_bcon_timeout) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VFALL;
 			otg_ctrl->a_bus_req = 0;
 		} else if (!otg_ctrl->a_vbus_vld) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_VBUS_ERR;
 		} else if (otg_ctrl->b_conn) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_HOST;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_HOST;
 		}
 		break;
 	case OTG_STATE_A_HOST:
 		if (otg_ctrl->id || !otg_ctrl->b_conn
 		    || otg_ctrl->a_bus_drop)
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_BCON;
 		else if (!otg_ctrl->a_vbus_vld)
-			mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_VBUS_ERR;
 		break;
 	case OTG_STATE_A_WAIT_VFALL:
 		if (otg_ctrl->id
 		    || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
 		    || otg_ctrl->a_bus_req)
-			mvotg->phy.otg->state = OTG_STATE_A_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_IDLE;
 		break;
 	case OTG_STATE_A_VBUS_ERR:
 		if (otg_ctrl->id || otg_ctrl->a_clr_err
 		    || otg_ctrl->a_bus_drop) {
 			otg_ctrl->a_clr_err = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VFALL;
 		}
 		break;
 	default:
@@ -409,8 +405,8 @@ static void mv_otg_work(struct work_struct *work)
 
 run:
 	/* work queue is single thread, or we need spin_lock to protect */
-	phy = &mvotg->phy;
-	otg = mvotg->phy.otg;
+	phy = &mvotg->usb_phy;
+	otg = mvotg->usb_phy.otg;
 	old_state = otg->state;
 
 	if (!mvotg->active)
@@ -419,24 +415,24 @@ static void mv_otg_work(struct work_struct *work)
 	mv_otg_update_inputs(mvotg);
 	mv_otg_update_state(mvotg);
 
-	if (old_state != mvotg->phy.otg->state) {
+	if (old_state != mvotg->usb_phy.otg->state) {
 		dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
 			 state_string[old_state],
-			 state_string[mvotg->phy.otg->state]);
+			 state_string[mvotg->usb_phy.otg->state]);
 
-		switch (mvotg->phy.otg->state) {
+		switch (mvotg->usb_phy.otg->state) {
 		case OTG_STATE_B_IDLE:
 			otg->default_a = 0;
 			if (old_state == OTG_STATE_B_PERIPHERAL)
 				mv_otg_start_periphrals(mvotg, 0);
 			mv_otg_reset(mvotg);
 			mv_otg_disable(mvotg);
-			usb_phy_set_event(&mvotg->phy, USB_EVENT_NONE);
+			usb_phy_set_event(&mvotg->usb_phy, USB_EVENT_NONE);
 			break;
 		case OTG_STATE_B_PERIPHERAL:
 			mv_otg_enable(mvotg);
 			mv_otg_start_periphrals(mvotg, 1);
-			usb_phy_set_event(&mvotg->phy, USB_EVENT_ENUMERATED);
+			usb_phy_set_event(&mvotg->usb_phy, USB_EVENT_ENUMERATED);
 			break;
 		case OTG_STATE_A_IDLE:
 			otg->default_a = 1;
@@ -536,8 +532,8 @@ a_bus_req_store(struct device *dev, struct device_attribute *attr,
 		return -1;
 
 	/* We will use this interface to change to A device */
-	if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
-	    && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
+	if (mvotg->usb_phy.otg->state != OTG_STATE_B_IDLE
+	    && mvotg->usb_phy.otg->state != OTG_STATE_A_IDLE)
 		return -1;
 
 	/* The clock may disabled and we need to set irq for ID detected */
@@ -566,7 +562,7 @@ a_clr_err_store(struct device *dev, struct device_attribute *attr,
 	      const char *buf, size_t count)
 {
 	struct mv_otg *mvotg = dev_get_drvdata(dev);
-	if (!mvotg->phy.otg->default_a)
+	if (!mvotg->usb_phy.otg->default_a)
 		return -1;
 
 	if (count > 2)
@@ -602,7 +598,7 @@ a_bus_drop_store(struct device *dev, struct device_attribute *attr,
 	       const char *buf, size_t count)
 {
 	struct mv_otg *mvotg = dev_get_drvdata(dev);
-	if (!mvotg->phy.otg->default_a)
+	if (!mvotg->usb_phy.otg->default_a)
 		return -1;
 
 	if (count > 2)
@@ -656,7 +652,7 @@ static int mv_otg_remove(struct platform_device *pdev)
 
 	mv_otg_disable(mvotg);
 
-	usb_remove_phy(&mvotg->phy);
+	usb_remove_phy(&mvotg->usb_phy);
 
 	return 0;
 }
@@ -687,6 +683,10 @@ static int mv_otg_probe(struct platform_device *pdev)
 	mvotg->pdev = pdev;
 	mvotg->pdata = pdata;
 
+	mvotg->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(mvotg->phy))
+		return PTR_ERR(mvotg->phy);
+
 	mvotg->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(mvotg->clk))
 		return PTR_ERR(mvotg->clk);
@@ -701,12 +701,12 @@ static int mv_otg_probe(struct platform_device *pdev)
 
 	/* OTG common part */
 	mvotg->pdev = pdev;
-	mvotg->phy.dev = &pdev->dev;
-	mvotg->phy.otg = otg;
-	mvotg->phy.label = driver_name;
+	mvotg->usb_phy.dev = &pdev->dev;
+	mvotg->usb_phy.otg = otg;
+	mvotg->usb_phy.label = driver_name;
 
 	otg->state = OTG_STATE_UNDEFINED;
-	otg->usb_phy = &mvotg->phy;
+	otg->usb_phy = &mvotg->usb_phy;
 	otg->set_host = mv_otg_set_host;
 	otg->set_peripheral = mv_otg_set_peripheral;
 	otg->set_vbus = mv_otg_set_vbus;
@@ -715,36 +715,23 @@ static int mv_otg_probe(struct platform_device *pdev)
 		timer_setup(&mvotg->otg_ctrl.timer[i],
 			    mv_otg_timer_await_bcon, 0);
 
-	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;
 		goto err_destroy_workqueue;
 	}
 
-	mvotg->cap_regs = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (mvotg->cap_regs == NULL) {
+	mvotg->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
+	if (mvotg->base == NULL) {
 		dev_err(&pdev->dev, "failed to map I/O memory\n");
 		retval = -EFAULT;
 		goto err_destroy_workqueue;
 	}
 
+	mvotg->cap_regs =
+		(void __iomem *) ((unsigned long)mvotg->base + U2x_CAPREGS_OFFSET);
+
 	/* we will acces controller register, so enable the udc controller */
 	retval = mv_otg_enable_internal(mvotg);
 	if (retval) {
@@ -804,7 +791,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(&mvotg->usb_phy, USB_PHY_TYPE_USB2);
 	if (retval < 0) {
 		dev_err(&pdev->dev, "can't register transceiver, %d\n",
 			retval);
@@ -831,7 +818,7 @@ static int mv_otg_probe(struct platform_device *pdev)
 	return 0;
 
 err_remove_phy:
-	usb_remove_phy(&mvotg->phy);
+	usb_remove_phy(&mvotg->usb_phy);
 err_disable_clk:
 	mv_otg_disable_internal(mvotg);
 err_destroy_workqueue:
@@ -846,10 +833,10 @@ static int mv_otg_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	struct mv_otg *mvotg = platform_get_drvdata(pdev);
 
-	if (mvotg->phy.otg->state != OTG_STATE_B_IDLE) {
+	if (mvotg->usb_phy.otg->state != OTG_STATE_B_IDLE) {
 		dev_info(&pdev->dev,
 			 "OTG state is not B_IDLE, it is %d!\n",
-			 mvotg->phy.otg->state);
+			 mvotg->usb_phy.otg->state);
 		return -EAGAIN;
 	}
 
diff --git a/drivers/usb/phy/phy-mv-usb.h b/drivers/usb/phy/phy-mv-usb.h
index 96701a1229ad..9b7bc6d958a8 100644
--- a/drivers/usb/phy/phy-mv-usb.h
+++ b/drivers/usb/phy/phy-mv-usb.h
@@ -8,6 +8,9 @@
 
 #include <linux/types.h>
 
+/* registers */
+#define U2x_CAPREGS_OFFSET       0x100
+
 /* Command Register Bit Masks */
 #define USBCMD_RUN_STOP			(0x00000001)
 #define USBCMD_CTRL_RESET		(0x00000002)
@@ -132,11 +135,11 @@ struct mv_otg_regs {
 };
 
 struct mv_otg {
-	struct usb_phy phy;
+	struct usb_phy usb_phy;
 	struct mv_otg_ctrl otg_ctrl;
 
 	/* base address */
-	void __iomem *phy_regs;
+	void __iomem *base;
 	void __iomem *cap_regs;
 	struct mv_otg_regs __iomem *op_regs;
 
@@ -155,6 +158,7 @@ struct mv_otg {
 	unsigned int active;
 	unsigned int clock_gating;
 	struct clk *clk;
+	struct phy *phy;
 };
 
 #endif
-- 
2.17.1


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

* [09/14] USB: phy-mv-usb: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c  |  11 +---
 drivers/usb/phy/phy-mv-usb.c | 123 ++++++++++++++++-------------------
 drivers/usb/phy/phy-mv-usb.h |   8 ++-
 3 files changed, 62 insertions(+), 80 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index 822b8be042b9..eb9b3c34e90a 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -325,21 +325,12 @@ struct platform_device pxa168_device_u2oehci = {
 
 #if IS_ENABLED(CONFIG_USB_MV_OTG)
 struct resource pxa168_u2ootg_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index cfd9add10bf4..0f67c5b65fe9 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -50,7 +50,7 @@ static char *state_string[] = {
 
 static int mv_otg_set_vbus(struct usb_otg *otg, bool on)
 {
-	struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, phy);
+	struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, usb_phy);
 	if (mvotg->pdata->set_vbus == NULL)
 		return -ENODEV;
 
@@ -193,7 +193,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg)
 static void mv_otg_start_host(struct mv_otg *mvotg, int on)
 {
 #ifdef CONFIG_USB
-	struct usb_otg *otg = mvotg->phy.otg;
+	struct usb_otg *otg = mvotg->usb_phy.otg;
 	struct usb_hcd *hcd;
 
 	if (!otg->host)
@@ -214,12 +214,12 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on)
 
 static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
 {
-	struct usb_otg *otg = mvotg->phy.otg;
+	struct usb_otg *otg = mvotg->usb_phy.otg;
 
 	if (!otg->gadget)
 		return;
 
-	dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off");
+	dev_info(mvotg->usb_phy.dev, "gadget %s\n", on ? "on" : "off");
 
 	if (on)
 		usb_gadget_vbus_connect(otg->gadget);
@@ -247,14 +247,11 @@ 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 = phy_init(mvotg->phy);
+	if (retval) {
+		dev_err(&mvotg->pdev->dev, "init phy error %d\n", retval);
+		otg_clock_disable(mvotg);
+		return retval;
 	}
 	mvotg->active = 1;
 
@@ -274,8 +271,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);
+		phy_exit(mvotg->phy);
 		otg_clock_disable(mvotg);
 		mvotg->active = 0;
 	}
@@ -329,68 +325,68 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg)
 static void mv_otg_update_state(struct mv_otg *mvotg)
 {
 	struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
-	int old_state = mvotg->phy.otg->state;
+	int old_state = mvotg->usb_phy.otg->state;
 
 	switch (old_state) {
 	case OTG_STATE_UNDEFINED:
-		mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+		mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		/* FALL THROUGH */
 	case OTG_STATE_B_IDLE:
 		if (otg_ctrl->id == 0)
-			mvotg->phy.otg->state = OTG_STATE_A_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_IDLE;
 		else if (otg_ctrl->b_sess_vld)
-			mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_PERIPHERAL;
 		break;
 	case OTG_STATE_B_PERIPHERAL:
 		if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
-			mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		break;
 	case OTG_STATE_A_IDLE:
 		if (otg_ctrl->id)
-			mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		else if (!(otg_ctrl->a_bus_drop) &&
 			 (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VRISE;
 		break;
 	case OTG_STATE_A_WAIT_VRISE:
 		if (otg_ctrl->a_vbus_vld)
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_BCON;
 		break;
 	case OTG_STATE_A_WAIT_BCON:
 		if (otg_ctrl->id || otg_ctrl->a_bus_drop
 		    || otg_ctrl->a_wait_bcon_timeout) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VFALL;
 			otg_ctrl->a_bus_req = 0;
 		} else if (!otg_ctrl->a_vbus_vld) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_VBUS_ERR;
 		} else if (otg_ctrl->b_conn) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_HOST;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_HOST;
 		}
 		break;
 	case OTG_STATE_A_HOST:
 		if (otg_ctrl->id || !otg_ctrl->b_conn
 		    || otg_ctrl->a_bus_drop)
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_BCON;
 		else if (!otg_ctrl->a_vbus_vld)
-			mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_VBUS_ERR;
 		break;
 	case OTG_STATE_A_WAIT_VFALL:
 		if (otg_ctrl->id
 		    || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
 		    || otg_ctrl->a_bus_req)
-			mvotg->phy.otg->state = OTG_STATE_A_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_IDLE;
 		break;
 	case OTG_STATE_A_VBUS_ERR:
 		if (otg_ctrl->id || otg_ctrl->a_clr_err
 		    || otg_ctrl->a_bus_drop) {
 			otg_ctrl->a_clr_err = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VFALL;
 		}
 		break;
 	default:
@@ -409,8 +405,8 @@ static void mv_otg_work(struct work_struct *work)
 
 run:
 	/* work queue is single thread, or we need spin_lock to protect */
-	phy = &mvotg->phy;
-	otg = mvotg->phy.otg;
+	phy = &mvotg->usb_phy;
+	otg = mvotg->usb_phy.otg;
 	old_state = otg->state;
 
 	if (!mvotg->active)
@@ -419,24 +415,24 @@ static void mv_otg_work(struct work_struct *work)
 	mv_otg_update_inputs(mvotg);
 	mv_otg_update_state(mvotg);
 
-	if (old_state != mvotg->phy.otg->state) {
+	if (old_state != mvotg->usb_phy.otg->state) {
 		dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
 			 state_string[old_state],
-			 state_string[mvotg->phy.otg->state]);
+			 state_string[mvotg->usb_phy.otg->state]);
 
-		switch (mvotg->phy.otg->state) {
+		switch (mvotg->usb_phy.otg->state) {
 		case OTG_STATE_B_IDLE:
 			otg->default_a = 0;
 			if (old_state == OTG_STATE_B_PERIPHERAL)
 				mv_otg_start_periphrals(mvotg, 0);
 			mv_otg_reset(mvotg);
 			mv_otg_disable(mvotg);
-			usb_phy_set_event(&mvotg->phy, USB_EVENT_NONE);
+			usb_phy_set_event(&mvotg->usb_phy, USB_EVENT_NONE);
 			break;
 		case OTG_STATE_B_PERIPHERAL:
 			mv_otg_enable(mvotg);
 			mv_otg_start_periphrals(mvotg, 1);
-			usb_phy_set_event(&mvotg->phy, USB_EVENT_ENUMERATED);
+			usb_phy_set_event(&mvotg->usb_phy, USB_EVENT_ENUMERATED);
 			break;
 		case OTG_STATE_A_IDLE:
 			otg->default_a = 1;
@@ -536,8 +532,8 @@ a_bus_req_store(struct device *dev, struct device_attribute *attr,
 		return -1;
 
 	/* We will use this interface to change to A device */
-	if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
-	    && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
+	if (mvotg->usb_phy.otg->state != OTG_STATE_B_IDLE
+	    && mvotg->usb_phy.otg->state != OTG_STATE_A_IDLE)
 		return -1;
 
 	/* The clock may disabled and we need to set irq for ID detected */
@@ -566,7 +562,7 @@ a_clr_err_store(struct device *dev, struct device_attribute *attr,
 	      const char *buf, size_t count)
 {
 	struct mv_otg *mvotg = dev_get_drvdata(dev);
-	if (!mvotg->phy.otg->default_a)
+	if (!mvotg->usb_phy.otg->default_a)
 		return -1;
 
 	if (count > 2)
@@ -602,7 +598,7 @@ a_bus_drop_store(struct device *dev, struct device_attribute *attr,
 	       const char *buf, size_t count)
 {
 	struct mv_otg *mvotg = dev_get_drvdata(dev);
-	if (!mvotg->phy.otg->default_a)
+	if (!mvotg->usb_phy.otg->default_a)
 		return -1;
 
 	if (count > 2)
@@ -656,7 +652,7 @@ static int mv_otg_remove(struct platform_device *pdev)
 
 	mv_otg_disable(mvotg);
 
-	usb_remove_phy(&mvotg->phy);
+	usb_remove_phy(&mvotg->usb_phy);
 
 	return 0;
 }
@@ -687,6 +683,10 @@ static int mv_otg_probe(struct platform_device *pdev)
 	mvotg->pdev = pdev;
 	mvotg->pdata = pdata;
 
+	mvotg->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(mvotg->phy))
+		return PTR_ERR(mvotg->phy);
+
 	mvotg->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(mvotg->clk))
 		return PTR_ERR(mvotg->clk);
@@ -701,12 +701,12 @@ static int mv_otg_probe(struct platform_device *pdev)
 
 	/* OTG common part */
 	mvotg->pdev = pdev;
-	mvotg->phy.dev = &pdev->dev;
-	mvotg->phy.otg = otg;
-	mvotg->phy.label = driver_name;
+	mvotg->usb_phy.dev = &pdev->dev;
+	mvotg->usb_phy.otg = otg;
+	mvotg->usb_phy.label = driver_name;
 
 	otg->state = OTG_STATE_UNDEFINED;
-	otg->usb_phy = &mvotg->phy;
+	otg->usb_phy = &mvotg->usb_phy;
 	otg->set_host = mv_otg_set_host;
 	otg->set_peripheral = mv_otg_set_peripheral;
 	otg->set_vbus = mv_otg_set_vbus;
@@ -715,36 +715,23 @@ static int mv_otg_probe(struct platform_device *pdev)
 		timer_setup(&mvotg->otg_ctrl.timer[i],
 			    mv_otg_timer_await_bcon, 0);
 
-	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;
 		goto err_destroy_workqueue;
 	}
 
-	mvotg->cap_regs = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (mvotg->cap_regs == NULL) {
+	mvotg->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
+	if (mvotg->base == NULL) {
 		dev_err(&pdev->dev, "failed to map I/O memory\n");
 		retval = -EFAULT;
 		goto err_destroy_workqueue;
 	}
 
+	mvotg->cap_regs =
+		(void __iomem *) ((unsigned long)mvotg->base + U2x_CAPREGS_OFFSET);
+
 	/* we will acces controller register, so enable the udc controller */
 	retval = mv_otg_enable_internal(mvotg);
 	if (retval) {
@@ -804,7 +791,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(&mvotg->usb_phy, USB_PHY_TYPE_USB2);
 	if (retval < 0) {
 		dev_err(&pdev->dev, "can't register transceiver, %d\n",
 			retval);
@@ -831,7 +818,7 @@ static int mv_otg_probe(struct platform_device *pdev)
 	return 0;
 
 err_remove_phy:
-	usb_remove_phy(&mvotg->phy);
+	usb_remove_phy(&mvotg->usb_phy);
 err_disable_clk:
 	mv_otg_disable_internal(mvotg);
 err_destroy_workqueue:
@@ -846,10 +833,10 @@ static int mv_otg_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	struct mv_otg *mvotg = platform_get_drvdata(pdev);
 
-	if (mvotg->phy.otg->state != OTG_STATE_B_IDLE) {
+	if (mvotg->usb_phy.otg->state != OTG_STATE_B_IDLE) {
 		dev_info(&pdev->dev,
 			 "OTG state is not B_IDLE, it is %d!\n",
-			 mvotg->phy.otg->state);
+			 mvotg->usb_phy.otg->state);
 		return -EAGAIN;
 	}
 
diff --git a/drivers/usb/phy/phy-mv-usb.h b/drivers/usb/phy/phy-mv-usb.h
index 96701a1229ad..9b7bc6d958a8 100644
--- a/drivers/usb/phy/phy-mv-usb.h
+++ b/drivers/usb/phy/phy-mv-usb.h
@@ -8,6 +8,9 @@
 
 #include <linux/types.h>
 
+/* registers */
+#define U2x_CAPREGS_OFFSET       0x100
+
 /* Command Register Bit Masks */
 #define USBCMD_RUN_STOP			(0x00000001)
 #define USBCMD_CTRL_RESET		(0x00000002)
@@ -132,11 +135,11 @@ struct mv_otg_regs {
 };
 
 struct mv_otg {
-	struct usb_phy phy;
+	struct usb_phy usb_phy;
 	struct mv_otg_ctrl otg_ctrl;
 
 	/* base address */
-	void __iomem *phy_regs;
+	void __iomem *base;
 	void __iomem *cap_regs;
 	struct mv_otg_regs __iomem *op_regs;
 
@@ -155,6 +158,7 @@ struct mv_otg {
 	unsigned int active;
 	unsigned int clock_gating;
 	struct clk *clk;
+	struct phy *phy;
 };
 
 #endif

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

* [PATCH 09/14] USB: phy-mv-usb: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-arm-kernel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c  |  11 +---
 drivers/usb/phy/phy-mv-usb.c | 123 ++++++++++++++++-------------------
 drivers/usb/phy/phy-mv-usb.h |   8 ++-
 3 files changed, 62 insertions(+), 80 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index 822b8be042b9..eb9b3c34e90a 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -325,21 +325,12 @@ struct platform_device pxa168_device_u2oehci = {
 
 #if IS_ENABLED(CONFIG_USB_MV_OTG)
 struct resource pxa168_u2ootg_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index cfd9add10bf4..0f67c5b65fe9 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -50,7 +50,7 @@ static char *state_string[] = {
 
 static int mv_otg_set_vbus(struct usb_otg *otg, bool on)
 {
-	struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, phy);
+	struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, usb_phy);
 	if (mvotg->pdata->set_vbus == NULL)
 		return -ENODEV;
 
@@ -193,7 +193,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg)
 static void mv_otg_start_host(struct mv_otg *mvotg, int on)
 {
 #ifdef CONFIG_USB
-	struct usb_otg *otg = mvotg->phy.otg;
+	struct usb_otg *otg = mvotg->usb_phy.otg;
 	struct usb_hcd *hcd;
 
 	if (!otg->host)
@@ -214,12 +214,12 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on)
 
 static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
 {
-	struct usb_otg *otg = mvotg->phy.otg;
+	struct usb_otg *otg = mvotg->usb_phy.otg;
 
 	if (!otg->gadget)
 		return;
 
-	dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off");
+	dev_info(mvotg->usb_phy.dev, "gadget %s\n", on ? "on" : "off");
 
 	if (on)
 		usb_gadget_vbus_connect(otg->gadget);
@@ -247,14 +247,11 @@ 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 = phy_init(mvotg->phy);
+	if (retval) {
+		dev_err(&mvotg->pdev->dev, "init phy error %d\n", retval);
+		otg_clock_disable(mvotg);
+		return retval;
 	}
 	mvotg->active = 1;
 
@@ -274,8 +271,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);
+		phy_exit(mvotg->phy);
 		otg_clock_disable(mvotg);
 		mvotg->active = 0;
 	}
@@ -329,68 +325,68 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg)
 static void mv_otg_update_state(struct mv_otg *mvotg)
 {
 	struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
-	int old_state = mvotg->phy.otg->state;
+	int old_state = mvotg->usb_phy.otg->state;
 
 	switch (old_state) {
 	case OTG_STATE_UNDEFINED:
-		mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+		mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		/* FALL THROUGH */
 	case OTG_STATE_B_IDLE:
 		if (otg_ctrl->id == 0)
-			mvotg->phy.otg->state = OTG_STATE_A_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_IDLE;
 		else if (otg_ctrl->b_sess_vld)
-			mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_PERIPHERAL;
 		break;
 	case OTG_STATE_B_PERIPHERAL:
 		if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
-			mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		break;
 	case OTG_STATE_A_IDLE:
 		if (otg_ctrl->id)
-			mvotg->phy.otg->state = OTG_STATE_B_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_B_IDLE;
 		else if (!(otg_ctrl->a_bus_drop) &&
 			 (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VRISE;
 		break;
 	case OTG_STATE_A_WAIT_VRISE:
 		if (otg_ctrl->a_vbus_vld)
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_BCON;
 		break;
 	case OTG_STATE_A_WAIT_BCON:
 		if (otg_ctrl->id || otg_ctrl->a_bus_drop
 		    || otg_ctrl->a_wait_bcon_timeout) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VFALL;
 			otg_ctrl->a_bus_req = 0;
 		} else if (!otg_ctrl->a_vbus_vld) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_VBUS_ERR;
 		} else if (otg_ctrl->b_conn) {
 			mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
 			mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_HOST;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_HOST;
 		}
 		break;
 	case OTG_STATE_A_HOST:
 		if (otg_ctrl->id || !otg_ctrl->b_conn
 		    || otg_ctrl->a_bus_drop)
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_BCON;
 		else if (!otg_ctrl->a_vbus_vld)
-			mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_VBUS_ERR;
 		break;
 	case OTG_STATE_A_WAIT_VFALL:
 		if (otg_ctrl->id
 		    || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
 		    || otg_ctrl->a_bus_req)
-			mvotg->phy.otg->state = OTG_STATE_A_IDLE;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_IDLE;
 		break;
 	case OTG_STATE_A_VBUS_ERR:
 		if (otg_ctrl->id || otg_ctrl->a_clr_err
 		    || otg_ctrl->a_bus_drop) {
 			otg_ctrl->a_clr_err = 0;
-			mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
+			mvotg->usb_phy.otg->state = OTG_STATE_A_WAIT_VFALL;
 		}
 		break;
 	default:
@@ -409,8 +405,8 @@ static void mv_otg_work(struct work_struct *work)
 
 run:
 	/* work queue is single thread, or we need spin_lock to protect */
-	phy = &mvotg->phy;
-	otg = mvotg->phy.otg;
+	phy = &mvotg->usb_phy;
+	otg = mvotg->usb_phy.otg;
 	old_state = otg->state;
 
 	if (!mvotg->active)
@@ -419,24 +415,24 @@ static void mv_otg_work(struct work_struct *work)
 	mv_otg_update_inputs(mvotg);
 	mv_otg_update_state(mvotg);
 
-	if (old_state != mvotg->phy.otg->state) {
+	if (old_state != mvotg->usb_phy.otg->state) {
 		dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
 			 state_string[old_state],
-			 state_string[mvotg->phy.otg->state]);
+			 state_string[mvotg->usb_phy.otg->state]);
 
-		switch (mvotg->phy.otg->state) {
+		switch (mvotg->usb_phy.otg->state) {
 		case OTG_STATE_B_IDLE:
 			otg->default_a = 0;
 			if (old_state == OTG_STATE_B_PERIPHERAL)
 				mv_otg_start_periphrals(mvotg, 0);
 			mv_otg_reset(mvotg);
 			mv_otg_disable(mvotg);
-			usb_phy_set_event(&mvotg->phy, USB_EVENT_NONE);
+			usb_phy_set_event(&mvotg->usb_phy, USB_EVENT_NONE);
 			break;
 		case OTG_STATE_B_PERIPHERAL:
 			mv_otg_enable(mvotg);
 			mv_otg_start_periphrals(mvotg, 1);
-			usb_phy_set_event(&mvotg->phy, USB_EVENT_ENUMERATED);
+			usb_phy_set_event(&mvotg->usb_phy, USB_EVENT_ENUMERATED);
 			break;
 		case OTG_STATE_A_IDLE:
 			otg->default_a = 1;
@@ -536,8 +532,8 @@ a_bus_req_store(struct device *dev, struct device_attribute *attr,
 		return -1;
 
 	/* We will use this interface to change to A device */
-	if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
-	    && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
+	if (mvotg->usb_phy.otg->state != OTG_STATE_B_IDLE
+	    && mvotg->usb_phy.otg->state != OTG_STATE_A_IDLE)
 		return -1;
 
 	/* The clock may disabled and we need to set irq for ID detected */
@@ -566,7 +562,7 @@ a_clr_err_store(struct device *dev, struct device_attribute *attr,
 	      const char *buf, size_t count)
 {
 	struct mv_otg *mvotg = dev_get_drvdata(dev);
-	if (!mvotg->phy.otg->default_a)
+	if (!mvotg->usb_phy.otg->default_a)
 		return -1;
 
 	if (count > 2)
@@ -602,7 +598,7 @@ a_bus_drop_store(struct device *dev, struct device_attribute *attr,
 	       const char *buf, size_t count)
 {
 	struct mv_otg *mvotg = dev_get_drvdata(dev);
-	if (!mvotg->phy.otg->default_a)
+	if (!mvotg->usb_phy.otg->default_a)
 		return -1;
 
 	if (count > 2)
@@ -656,7 +652,7 @@ static int mv_otg_remove(struct platform_device *pdev)
 
 	mv_otg_disable(mvotg);
 
-	usb_remove_phy(&mvotg->phy);
+	usb_remove_phy(&mvotg->usb_phy);
 
 	return 0;
 }
@@ -687,6 +683,10 @@ static int mv_otg_probe(struct platform_device *pdev)
 	mvotg->pdev = pdev;
 	mvotg->pdata = pdata;
 
+	mvotg->phy = devm_phy_get(&pdev->dev, "usb");
+	if (IS_ERR(mvotg->phy))
+		return PTR_ERR(mvotg->phy);
+
 	mvotg->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(mvotg->clk))
 		return PTR_ERR(mvotg->clk);
@@ -701,12 +701,12 @@ static int mv_otg_probe(struct platform_device *pdev)
 
 	/* OTG common part */
 	mvotg->pdev = pdev;
-	mvotg->phy.dev = &pdev->dev;
-	mvotg->phy.otg = otg;
-	mvotg->phy.label = driver_name;
+	mvotg->usb_phy.dev = &pdev->dev;
+	mvotg->usb_phy.otg = otg;
+	mvotg->usb_phy.label = driver_name;
 
 	otg->state = OTG_STATE_UNDEFINED;
-	otg->usb_phy = &mvotg->phy;
+	otg->usb_phy = &mvotg->usb_phy;
 	otg->set_host = mv_otg_set_host;
 	otg->set_peripheral = mv_otg_set_peripheral;
 	otg->set_vbus = mv_otg_set_vbus;
@@ -715,36 +715,23 @@ static int mv_otg_probe(struct platform_device *pdev)
 		timer_setup(&mvotg->otg_ctrl.timer[i],
 			    mv_otg_timer_await_bcon, 0);
 
-	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;
 		goto err_destroy_workqueue;
 	}
 
-	mvotg->cap_regs = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (mvotg->cap_regs == NULL) {
+	mvotg->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
+	if (mvotg->base == NULL) {
 		dev_err(&pdev->dev, "failed to map I/O memory\n");
 		retval = -EFAULT;
 		goto err_destroy_workqueue;
 	}
 
+	mvotg->cap_regs =
+		(void __iomem *) ((unsigned long)mvotg->base + U2x_CAPREGS_OFFSET);
+
 	/* we will acces controller register, so enable the udc controller */
 	retval = mv_otg_enable_internal(mvotg);
 	if (retval) {
@@ -804,7 +791,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(&mvotg->usb_phy, USB_PHY_TYPE_USB2);
 	if (retval < 0) {
 		dev_err(&pdev->dev, "can't register transceiver, %d\n",
 			retval);
@@ -831,7 +818,7 @@ static int mv_otg_probe(struct platform_device *pdev)
 	return 0;
 
 err_remove_phy:
-	usb_remove_phy(&mvotg->phy);
+	usb_remove_phy(&mvotg->usb_phy);
 err_disable_clk:
 	mv_otg_disable_internal(mvotg);
 err_destroy_workqueue:
@@ -846,10 +833,10 @@ static int mv_otg_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	struct mv_otg *mvotg = platform_get_drvdata(pdev);
 
-	if (mvotg->phy.otg->state != OTG_STATE_B_IDLE) {
+	if (mvotg->usb_phy.otg->state != OTG_STATE_B_IDLE) {
 		dev_info(&pdev->dev,
 			 "OTG state is not B_IDLE, it is %d!\n",
-			 mvotg->phy.otg->state);
+			 mvotg->usb_phy.otg->state);
 		return -EAGAIN;
 	}
 
diff --git a/drivers/usb/phy/phy-mv-usb.h b/drivers/usb/phy/phy-mv-usb.h
index 96701a1229ad..9b7bc6d958a8 100644
--- a/drivers/usb/phy/phy-mv-usb.h
+++ b/drivers/usb/phy/phy-mv-usb.h
@@ -8,6 +8,9 @@
 
 #include <linux/types.h>
 
+/* registers */
+#define U2x_CAPREGS_OFFSET       0x100
+
 /* Command Register Bit Masks */
 #define USBCMD_RUN_STOP			(0x00000001)
 #define USBCMD_CTRL_RESET		(0x00000002)
@@ -132,11 +135,11 @@ struct mv_otg_regs {
 };
 
 struct mv_otg {
-	struct usb_phy phy;
+	struct usb_phy usb_phy;
 	struct mv_otg_ctrl otg_ctrl;
 
 	/* base address */
-	void __iomem *phy_regs;
+	void __iomem *base;
 	void __iomem *cap_regs;
 	struct mv_otg_regs __iomem *op_regs;
 
@@ -155,6 +158,7 @@ struct mv_otg {
 	unsigned int active;
 	unsigned int clock_gating;
 	struct clk *clk;
+	struct phy *phy;
 };
 
 #endif
-- 
2.17.1

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

* [PATCH 10/14] USB: gadget: mv-udc: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c          | 11 +-------
 drivers/usb/gadget/udc/mv_udc.h      |  7 ++++-
 drivers/usb/gadget/udc/mv_udc_core.c | 38 ++++++++--------------------
 3 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index eb9b3c34e90a..d925be9f14a9 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -263,21 +263,12 @@ struct platform_device pxa168_device_usb_phy = {
 
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 struct resource pxa168_u2o_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/gadget/udc/mv_udc.h b/drivers/usb/gadget/udc/mv_udc.h
index b3f759c0962c..6f04f432964d 100644
--- a/drivers/usb/gadget/udc/mv_udc.h
+++ b/drivers/usb/gadget/udc/mv_udc.h
@@ -6,6 +6,9 @@
 #ifndef __MV_UDC_H
 #define __MV_UDC_H
 
+/* registers */
+#define U2x_CAPREGS_OFFSET	0x100
+
 #define VUSBHS_MAX_PORTS	8
 
 #define DQH_ALIGNMENT		2048
@@ -174,9 +177,9 @@ struct mv_udc {
 	struct platform_device		*dev;
 	int				irq;
 
+	void __iomem                    *base;
 	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;
@@ -219,6 +222,8 @@ struct mv_udc {
 
 	/* some SOC has mutiple clock sources for USB*/
 	struct clk      *clk;
+
+	struct phy	*phy;
 };
 
 /* endpoint data structure */
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index 95f52232493b..c701c83d3af5 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -1069,14 +1069,11 @@ static int mv_udc_enable_internal(struct mv_udc *udc)
 	if (retval)
 		return retval;
 
-	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 = 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;
 
@@ -1095,8 +1092,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);
+		phy_exit(udc->phy);
 		udc_clock_disable(udc);
 		udc->active = 0;
 	}
@@ -2147,30 +2143,16 @@ 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;
 	}
 
-	udc->cap_regs = (struct mv_cap_regs __iomem *)
-		devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (udc->cap_regs == NULL) {
-		dev_err(&pdev->dev, "failed to map I/O memory\n");
-		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->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
 
-	udc->phy_regs = devm_ioremap(&pdev->dev, 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->cap_regs =
+		(void __iomem *) ((unsigned long)udc->base + U2x_CAPREGS_OFFSET);
 
 	/* we will acces controller register, so enable the clk */
 	retval = mv_udc_enable_internal(udc);
-- 
2.17.1


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

* [10/14] USB: gadget: mv-udc: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c          | 11 +-------
 drivers/usb/gadget/udc/mv_udc.h      |  7 ++++-
 drivers/usb/gadget/udc/mv_udc_core.c | 38 ++++++++--------------------
 3 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index eb9b3c34e90a..d925be9f14a9 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -263,21 +263,12 @@ struct platform_device pxa168_device_usb_phy = {
 
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 struct resource pxa168_u2o_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/gadget/udc/mv_udc.h b/drivers/usb/gadget/udc/mv_udc.h
index b3f759c0962c..6f04f432964d 100644
--- a/drivers/usb/gadget/udc/mv_udc.h
+++ b/drivers/usb/gadget/udc/mv_udc.h
@@ -6,6 +6,9 @@
 #ifndef __MV_UDC_H
 #define __MV_UDC_H
 
+/* registers */
+#define U2x_CAPREGS_OFFSET	0x100
+
 #define VUSBHS_MAX_PORTS	8
 
 #define DQH_ALIGNMENT		2048
@@ -174,9 +177,9 @@ struct mv_udc {
 	struct platform_device		*dev;
 	int				irq;
 
+	void __iomem                    *base;
 	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;
@@ -219,6 +222,8 @@ struct mv_udc {
 
 	/* some SOC has mutiple clock sources for USB*/
 	struct clk      *clk;
+
+	struct phy	*phy;
 };
 
 /* endpoint data structure */
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index 95f52232493b..c701c83d3af5 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -1069,14 +1069,11 @@ static int mv_udc_enable_internal(struct mv_udc *udc)
 	if (retval)
 		return retval;
 
-	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 = 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;
 
@@ -1095,8 +1092,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);
+		phy_exit(udc->phy);
 		udc_clock_disable(udc);
 		udc->active = 0;
 	}
@@ -2147,30 +2143,16 @@ 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;
 	}
 
-	udc->cap_regs = (struct mv_cap_regs __iomem *)
-		devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (udc->cap_regs == NULL) {
-		dev_err(&pdev->dev, "failed to map I/O memory\n");
-		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->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
 
-	udc->phy_regs = devm_ioremap(&pdev->dev, 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->cap_regs =
+		(void __iomem *) ((unsigned long)udc->base + U2x_CAPREGS_OFFSET);
 
 	/* we will acces controller register, so enable the clk */
 	retval = mv_udc_enable_internal(udc);

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

* [PATCH 10/14] USB: gadget: mv-udc: use phy-pxa-usb
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-arm-kernel

Use a proper PHY driver, instead of hooks to a board support package.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/mach-mmp/devices.c          | 11 +-------
 drivers/usb/gadget/udc/mv_udc.h      |  7 ++++-
 drivers/usb/gadget/udc/mv_udc_core.c | 38 ++++++++--------------------
 3 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index eb9b3c34e90a..d925be9f14a9 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -263,21 +263,12 @@ struct platform_device pxa168_device_usb_phy = {
 
 #if IS_ENABLED(CONFIG_USB_MV_UDC)
 struct resource pxa168_u2o_resources[] = {
-	/* regbase */
 	[0] = {
-		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
+		.start	= PXA168_U2O_REGBASE,
 		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
 		.flags	= IORESOURCE_MEM,
-		.name	= "capregs",
 	},
-	/* phybase */
 	[1] = {
-		.start	= PXA168_U2O_PHYBASE,
-		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
-		.flags	= IORESOURCE_MEM,
-		.name	= "phyregs",
-	},
-	[2] = {
 		.start	= IRQ_PXA168_USB1,
 		.end	= IRQ_PXA168_USB1,
 		.flags	= IORESOURCE_IRQ,
diff --git a/drivers/usb/gadget/udc/mv_udc.h b/drivers/usb/gadget/udc/mv_udc.h
index b3f759c0962c..6f04f432964d 100644
--- a/drivers/usb/gadget/udc/mv_udc.h
+++ b/drivers/usb/gadget/udc/mv_udc.h
@@ -6,6 +6,9 @@
 #ifndef __MV_UDC_H
 #define __MV_UDC_H
 
+/* registers */
+#define U2x_CAPREGS_OFFSET	0x100
+
 #define VUSBHS_MAX_PORTS	8
 
 #define DQH_ALIGNMENT		2048
@@ -174,9 +177,9 @@ struct mv_udc {
 	struct platform_device		*dev;
 	int				irq;
 
+	void __iomem                    *base;
 	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;
@@ -219,6 +222,8 @@ struct mv_udc {
 
 	/* some SOC has mutiple clock sources for USB*/
 	struct clk      *clk;
+
+	struct phy	*phy;
 };
 
 /* endpoint data structure */
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index 95f52232493b..c701c83d3af5 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -1069,14 +1069,11 @@ static int mv_udc_enable_internal(struct mv_udc *udc)
 	if (retval)
 		return retval;
 
-	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 = 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;
 
@@ -1095,8 +1092,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);
+		phy_exit(udc->phy);
 		udc_clock_disable(udc);
 		udc->active = 0;
 	}
@@ -2147,30 +2143,16 @@ 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;
 	}
 
-	udc->cap_regs = (struct mv_cap_regs __iomem *)
-		devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (udc->cap_regs == NULL) {
-		dev_err(&pdev->dev, "failed to map I/O memory\n");
-		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->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
 
-	udc->phy_regs = devm_ioremap(&pdev->dev, 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->cap_regs =
+		(void __iomem *) ((unsigned long)udc->base + U2x_CAPREGS_OFFSET);
 
 	/* we will acces controller register, so enable the clk */
 	retval = mv_udc_enable_internal(udc);
-- 
2.17.1

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

* [PATCH 11/14] USB: EHCI: ehci-mv: add DT support
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Add Device tree support.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/ehci-mv.c | 41 +++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 43b300c90875..f26109eafdbf 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -34,11 +34,11 @@ struct ehci_hcd_mv {
 	void __iomem *op_regs;
 
 	struct usb_phy *otg;
+	struct clk *clk;
 
-	struct mv_usb_platform_data *pdata;
 	struct phy *phy;
 
-	struct clk *clk;
+	int (*set_vbus)(unsigned int vbus);
 };
 
 static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv)
@@ -100,11 +100,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	int retval = -ENODEV;
 	u32 offset;
 
-	if (!pdata) {
-		dev_err(&pdev->dev, "missing platform_data\n");
-		return -ENODEV;
-	}
-
 	if (usb_disabled())
 		return -ENODEV;
 
@@ -114,7 +109,12 @@ static int mv_ehci_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, hcd);
 	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
-	ehci_mv->pdata = pdata;
+
+	ehci_mv->mode = MV_USB_MODE_HOST;
+	if (pdata) {
+		ehci_mv->mode = pdata->mode;
+		ehci_mv->set_vbus = pdata->set_vbus;
+	}
 
 	ehci_mv->phy = devm_phy_get(&pdev->dev, "usb");
 	if (IS_ERR(ehci_mv->phy)) {
@@ -166,7 +166,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci = hcd_to_ehci(hcd);
 	ehci->caps = (struct ehci_caps *) ehci_mv->cap_regs;
 
-	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);
 		if (IS_ERR(ehci_mv->otg)) {
@@ -191,8 +190,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		/* otg will enable clock before use as host */
 		mv_ehci_disable(ehci_mv);
 	} else {
-		if (pdata->set_vbus)
-			pdata->set_vbus(1);
+		if (ehci_mv->set_vbus)
+			ehci_mv->set_vbus(1);
 
 		retval = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
 		if (retval) {
@@ -211,8 +210,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	return 0;
 
 err_set_vbus:
-	if (pdata->set_vbus)
-		pdata->set_vbus(0);
+	if (ehci_mv->set_vbus)
+		ehci_mv->set_vbus(0);
 err_disable_clk:
 	mv_ehci_disable(ehci_mv);
 err_put_hcd:
@@ -233,8 +232,8 @@ static int mv_ehci_remove(struct platform_device *pdev)
 		otg_set_host(ehci_mv->otg->otg, NULL);
 
 	if (ehci_mv->mode == MV_USB_MODE_HOST) {
-		if (ehci_mv->pdata->set_vbus)
-			ehci_mv->pdata->set_vbus(0);
+		if (ehci_mv->set_vbus)
+			ehci_mv->set_vbus(0);
 
 		mv_ehci_disable(ehci_mv);
 	}
@@ -265,14 +264,20 @@ static void mv_ehci_shutdown(struct platform_device *pdev)
 		hcd->driver->shutdown(hcd);
 }
 
+static const struct of_device_id ehci_mv_dt_ids[] = {
+	{ .compatible = "marvell,pxau2o-ehci", },
+	{},
+};
+
 static struct platform_driver ehci_mv_driver = {
 	.probe = mv_ehci_probe,
 	.remove = mv_ehci_remove,
 	.shutdown = mv_ehci_shutdown,
 	.driver = {
-		   .name = "mv-ehci",
-		   .bus = &platform_bus_type,
-		   },
+		.name = "mv-ehci",
+		.bus = &platform_bus_type,
+		.of_match_table = ehci_mv_dt_ids,
+	},
 	.id_table = ehci_id_table,
 };
 
-- 
2.17.1


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

* [11/14] USB: EHCI: ehci-mv: add DT support
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Add Device tree support.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/ehci-mv.c | 41 +++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 43b300c90875..f26109eafdbf 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -34,11 +34,11 @@ struct ehci_hcd_mv {
 	void __iomem *op_regs;
 
 	struct usb_phy *otg;
+	struct clk *clk;
 
-	struct mv_usb_platform_data *pdata;
 	struct phy *phy;
 
-	struct clk *clk;
+	int (*set_vbus)(unsigned int vbus);
 };
 
 static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv)
@@ -100,11 +100,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	int retval = -ENODEV;
 	u32 offset;
 
-	if (!pdata) {
-		dev_err(&pdev->dev, "missing platform_data\n");
-		return -ENODEV;
-	}
-
 	if (usb_disabled())
 		return -ENODEV;
 
@@ -114,7 +109,12 @@ static int mv_ehci_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, hcd);
 	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
-	ehci_mv->pdata = pdata;
+
+	ehci_mv->mode = MV_USB_MODE_HOST;
+	if (pdata) {
+		ehci_mv->mode = pdata->mode;
+		ehci_mv->set_vbus = pdata->set_vbus;
+	}
 
 	ehci_mv->phy = devm_phy_get(&pdev->dev, "usb");
 	if (IS_ERR(ehci_mv->phy)) {
@@ -166,7 +166,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci = hcd_to_ehci(hcd);
 	ehci->caps = (struct ehci_caps *) ehci_mv->cap_regs;
 
-	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);
 		if (IS_ERR(ehci_mv->otg)) {
@@ -191,8 +190,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		/* otg will enable clock before use as host */
 		mv_ehci_disable(ehci_mv);
 	} else {
-		if (pdata->set_vbus)
-			pdata->set_vbus(1);
+		if (ehci_mv->set_vbus)
+			ehci_mv->set_vbus(1);
 
 		retval = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
 		if (retval) {
@@ -211,8 +210,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	return 0;
 
 err_set_vbus:
-	if (pdata->set_vbus)
-		pdata->set_vbus(0);
+	if (ehci_mv->set_vbus)
+		ehci_mv->set_vbus(0);
 err_disable_clk:
 	mv_ehci_disable(ehci_mv);
 err_put_hcd:
@@ -233,8 +232,8 @@ static int mv_ehci_remove(struct platform_device *pdev)
 		otg_set_host(ehci_mv->otg->otg, NULL);
 
 	if (ehci_mv->mode == MV_USB_MODE_HOST) {
-		if (ehci_mv->pdata->set_vbus)
-			ehci_mv->pdata->set_vbus(0);
+		if (ehci_mv->set_vbus)
+			ehci_mv->set_vbus(0);
 
 		mv_ehci_disable(ehci_mv);
 	}
@@ -265,14 +264,20 @@ static void mv_ehci_shutdown(struct platform_device *pdev)
 		hcd->driver->shutdown(hcd);
 }
 
+static const struct of_device_id ehci_mv_dt_ids[] = {
+	{ .compatible = "marvell,pxau2o-ehci", },
+	{},
+};
+
 static struct platform_driver ehci_mv_driver = {
 	.probe = mv_ehci_probe,
 	.remove = mv_ehci_remove,
 	.shutdown = mv_ehci_shutdown,
 	.driver = {
-		   .name = "mv-ehci",
-		   .bus = &platform_bus_type,
-		   },
+		.name = "mv-ehci",
+		.bus = &platform_bus_type,
+		.of_match_table = ehci_mv_dt_ids,
+	},
 	.id_table = ehci_id_table,
 };
 

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

* [PATCH 11/14] USB: EHCI: ehci-mv: add DT support
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-arm-kernel

Add Device tree support.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/ehci-mv.c | 41 +++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 43b300c90875..f26109eafdbf 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -34,11 +34,11 @@ struct ehci_hcd_mv {
 	void __iomem *op_regs;
 
 	struct usb_phy *otg;
+	struct clk *clk;
 
-	struct mv_usb_platform_data *pdata;
 	struct phy *phy;
 
-	struct clk *clk;
+	int (*set_vbus)(unsigned int vbus);
 };
 
 static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv)
@@ -100,11 +100,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	int retval = -ENODEV;
 	u32 offset;
 
-	if (!pdata) {
-		dev_err(&pdev->dev, "missing platform_data\n");
-		return -ENODEV;
-	}
-
 	if (usb_disabled())
 		return -ENODEV;
 
@@ -114,7 +109,12 @@ static int mv_ehci_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, hcd);
 	ehci_mv = hcd_to_ehci_hcd_mv(hcd);
-	ehci_mv->pdata = pdata;
+
+	ehci_mv->mode = MV_USB_MODE_HOST;
+	if (pdata) {
+		ehci_mv->mode = pdata->mode;
+		ehci_mv->set_vbus = pdata->set_vbus;
+	}
 
 	ehci_mv->phy = devm_phy_get(&pdev->dev, "usb");
 	if (IS_ERR(ehci_mv->phy)) {
@@ -166,7 +166,6 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	ehci = hcd_to_ehci(hcd);
 	ehci->caps = (struct ehci_caps *) ehci_mv->cap_regs;
 
-	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);
 		if (IS_ERR(ehci_mv->otg)) {
@@ -191,8 +190,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 		/* otg will enable clock before use as host */
 		mv_ehci_disable(ehci_mv);
 	} else {
-		if (pdata->set_vbus)
-			pdata->set_vbus(1);
+		if (ehci_mv->set_vbus)
+			ehci_mv->set_vbus(1);
 
 		retval = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
 		if (retval) {
@@ -211,8 +210,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	return 0;
 
 err_set_vbus:
-	if (pdata->set_vbus)
-		pdata->set_vbus(0);
+	if (ehci_mv->set_vbus)
+		ehci_mv->set_vbus(0);
 err_disable_clk:
 	mv_ehci_disable(ehci_mv);
 err_put_hcd:
@@ -233,8 +232,8 @@ static int mv_ehci_remove(struct platform_device *pdev)
 		otg_set_host(ehci_mv->otg->otg, NULL);
 
 	if (ehci_mv->mode == MV_USB_MODE_HOST) {
-		if (ehci_mv->pdata->set_vbus)
-			ehci_mv->pdata->set_vbus(0);
+		if (ehci_mv->set_vbus)
+			ehci_mv->set_vbus(0);
 
 		mv_ehci_disable(ehci_mv);
 	}
@@ -265,14 +264,20 @@ static void mv_ehci_shutdown(struct platform_device *pdev)
 		hcd->driver->shutdown(hcd);
 }
 
+static const struct of_device_id ehci_mv_dt_ids[] = {
+	{ .compatible = "marvell,pxau2o-ehci", },
+	{},
+};
+
 static struct platform_driver ehci_mv_driver = {
 	.probe = mv_ehci_probe,
 	.remove = mv_ehci_remove,
 	.shutdown = mv_ehci_shutdown,
 	.driver = {
-		   .name = "mv-ehci",
-		   .bus = &platform_bus_type,
-		   },
+		.name = "mv-ehci",
+		.bus = &platform_bus_type,
+		.of_match_table = ehci_mv_dt_ids,
+	},
 	.id_table = ehci_id_table,
 };
 
-- 
2.17.1

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

* [PATCH 12/14] dt-bindings: ehci-mv: add bindings
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 .../devicetree/bindings/usb/ehci-mv.txt       | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-mv.txt

diff --git a/Documentation/devicetree/bindings/usb/ehci-mv.txt b/Documentation/devicetree/bindings/usb/ehci-mv.txt
new file mode 100644
index 000000000000..335589895763
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ehci-mv.txt
@@ -0,0 +1,23 @@
+* Marvell PXA/MMP EHCI controller.
+
+Required properties:
+
+- compatible: must be "marvell,pxau2o-ehci"
+- reg: physical base addresses of the controller and length of memory mapped region
+- interrupts: one EHCI controller interrupt should be described here
+- clocks: phandle list of usb clocks
+- clock-names: should be "USBCLK"
+- phys: phandle for the PHY device
+- phy-names: should be "usb"
+
+Example:
+
+	ehci0: usb-ehci@d4208000 {
+		compatible = "marvell,pxau2o-ehci";
+		reg = <0xd4208000 0x200>;
+		interrupts = <44>;
+		clocks = <&soc_clocks MMP2_CLK_USB>;
+		clock-names = "USBCLK";
+		phys = <&usb_otg_phy>;
+		phy-names = "usb";
+	};
-- 
2.17.1


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

* [12/14] dt-bindings: ehci-mv: add bindings
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 .../devicetree/bindings/usb/ehci-mv.txt       | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-mv.txt

diff --git a/Documentation/devicetree/bindings/usb/ehci-mv.txt b/Documentation/devicetree/bindings/usb/ehci-mv.txt
new file mode 100644
index 000000000000..335589895763
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ehci-mv.txt
@@ -0,0 +1,23 @@
+* Marvell PXA/MMP EHCI controller.
+
+Required properties:
+
+- compatible: must be "marvell,pxau2o-ehci"
+- reg: physical base addresses of the controller and length of memory mapped region
+- interrupts: one EHCI controller interrupt should be described here
+- clocks: phandle list of usb clocks
+- clock-names: should be "USBCLK"
+- phys: phandle for the PHY device
+- phy-names: should be "usb"
+
+Example:
+
+	ehci0: usb-ehci@d4208000 {
+		compatible = "marvell,pxau2o-ehci";
+		reg = <0xd4208000 0x200>;
+		interrupts = <44>;
+		clocks = <&soc_clocks MMP2_CLK_USB>;
+		clock-names = "USBCLK";
+		phys = <&usb_otg_phy>;
+		phy-names = "usb";
+	};

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

* [PATCH 12/14] dt-bindings: ehci-mv: add bindings
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 .../devicetree/bindings/usb/ehci-mv.txt       | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-mv.txt

diff --git a/Documentation/devicetree/bindings/usb/ehci-mv.txt b/Documentation/devicetree/bindings/usb/ehci-mv.txt
new file mode 100644
index 000000000000..335589895763
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ehci-mv.txt
@@ -0,0 +1,23 @@
+* Marvell PXA/MMP EHCI controller.
+
+Required properties:
+
+- compatible: must be "marvell,pxau2o-ehci"
+- reg: physical base addresses of the controller and length of memory mapped region
+- interrupts: one EHCI controller interrupt should be described here
+- clocks: phandle list of usb clocks
+- clock-names: should be "USBCLK"
+- phys: phandle for the PHY device
+- phy-names: should be "usb"
+
+Example:
+
+	ehci0: usb-ehci at d4208000 {
+		compatible = "marvell,pxau2o-ehci";
+		reg = <0xd4208000 0x200>;
+		interrupts = <44>;
+		clocks = <&soc_clocks MMP2_CLK_USB>;
+		clock-names = "USBCLK";
+		phys = <&usb_otg_phy>;
+		phy-names = "usb";
+	};
-- 
2.17.1

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

* [PATCH 13/14] DT: marvell,mmp2: add OTG PHY
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

The USB OTG PHY chip. To be used by the OTG controller.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/boot/dts/mmp2.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
index 766bbb8495b6..14a3448f38b9 100644
--- a/arch/arm/boot/dts/mmp2.dtsi
+++ b/arch/arm/boot/dts/mmp2.dtsi
@@ -117,6 +117,13 @@
 				reg-names = "mux status", "mux mask";
 				mrvl,intc-nr-irqs = <2>;
 			};
+
+			usb_otg_phy0: usb-otg-phy@d4207000 {
+				compatible = "marvell,mmp2-usb-phy";
+				reg = <0xd4207000 0x40>;
+				#phy-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		apb@d4000000 {	/* APB */
-- 
2.17.1


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

* [13/14] DT: marvell,mmp2: add OTG PHY
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

The USB OTG PHY chip. To be used by the OTG controller.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/boot/dts/mmp2.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
index 766bbb8495b6..14a3448f38b9 100644
--- a/arch/arm/boot/dts/mmp2.dtsi
+++ b/arch/arm/boot/dts/mmp2.dtsi
@@ -117,6 +117,13 @@
 				reg-names = "mux status", "mux mask";
 				mrvl,intc-nr-irqs = <2>;
 			};
+
+			usb_otg_phy0: usb-otg-phy@d4207000 {
+				compatible = "marvell,mmp2-usb-phy";
+				reg = <0xd4207000 0x40>;
+				#phy-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		apb@d4000000 {	/* APB */

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

* [PATCH 13/14] DT: marvell,mmp2: add OTG PHY
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-arm-kernel

The USB OTG PHY chip. To be used by the OTG controller.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/boot/dts/mmp2.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
index 766bbb8495b6..14a3448f38b9 100644
--- a/arch/arm/boot/dts/mmp2.dtsi
+++ b/arch/arm/boot/dts/mmp2.dtsi
@@ -117,6 +117,13 @@
 				reg-names = "mux status", "mux mask";
 				mrvl,intc-nr-irqs = <2>;
 			};
+
+			usb_otg_phy0: usb-otg-phy at d4207000 {
+				compatible = "marvell,mmp2-usb-phy";
+				reg = <0xd4207000 0x40>;
+				#phy-cells = <0>;
+				status = "disabled";
+			};
 		};
 
 		apb at d4000000 {	/* APB */
-- 
2.17.1

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

* [PATCH 14/14] DT: marvell,mmp2: add USB OTG host controller
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/boot/dts/mmp2.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
index 14a3448f38b9..63d4d5c6fd83 100644
--- a/arch/arm/boot/dts/mmp2.dtsi
+++ b/arch/arm/boot/dts/mmp2.dtsi
@@ -124,6 +124,17 @@
 				#phy-cells = <0>;
 				status = "disabled";
 			};
+
+			usb_otg0: usb-otg@d4208000 {
+				compatible = "marvell,pxau2o-ehci";
+				reg = <0xd4208000 0x200>;
+				interrupts = <44>;
+				clocks = <&soc_clocks MMP2_CLK_USB>;
+				clock-names = "USBCLK";
+				phys = <&usb_otg_phy0>;
+				phy-names = "usb";
+				status = "disabled";
+			};
 		};
 
 		apb@d4000000 {	/* APB */
-- 
2.17.1


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

* [14/14] DT: marvell,mmp2: add USB OTG host controller
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern, Lubomir Rintel

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/boot/dts/mmp2.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
index 14a3448f38b9..63d4d5c6fd83 100644
--- a/arch/arm/boot/dts/mmp2.dtsi
+++ b/arch/arm/boot/dts/mmp2.dtsi
@@ -124,6 +124,17 @@
 				#phy-cells = <0>;
 				status = "disabled";
 			};
+
+			usb_otg0: usb-otg@d4208000 {
+				compatible = "marvell,pxau2o-ehci";
+				reg = <0xd4208000 0x200>;
+				interrupts = <44>;
+				clocks = <&soc_clocks MMP2_CLK_USB>;
+				clock-names = "USBCLK";
+				phys = <&usb_otg_phy0>;
+				phy-names = "usb";
+				status = "disabled";
+			};
 		};
 
 		apb@d4000000 {	/* APB */

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

* [PATCH 14/14] DT: marvell,mmp2: add USB OTG host controller
@ 2018-08-22 20:43   ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-08-22 20:43 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/arm/boot/dts/mmp2.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
index 14a3448f38b9..63d4d5c6fd83 100644
--- a/arch/arm/boot/dts/mmp2.dtsi
+++ b/arch/arm/boot/dts/mmp2.dtsi
@@ -124,6 +124,17 @@
 				#phy-cells = <0>;
 				status = "disabled";
 			};
+
+			usb_otg0: usb-otg at d4208000 {
+				compatible = "marvell,pxau2o-ehci";
+				reg = <0xd4208000 0x200>;
+				interrupts = <44>;
+				clocks = <&soc_clocks MMP2_CLK_USB>;
+				clock-names = "USBCLK";
+				phys = <&usb_otg_phy0>;
+				phy-names = "usb";
+				status = "disabled";
+			};
 		};
 
 		apb at d4000000 {	/* APB */
-- 
2.17.1

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

* Re: [PATCH 00/14] Convert ehci-mv to DT
  2018-08-22 20:42 ` Lubomir Rintel
@ 2018-08-28 15:04   ` Alan Stern
  -1 siblings, 0 replies; 85+ messages in thread
From: Alan Stern @ 2018-08-28 15:04 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I

On Wed, 22 Aug 2018, Lubomir Rintel wrote:

> Hi,
> 
> This patch set makes it possible to use the Marvell EHCI driver with
> DT-based machines.
> 
> Tested on a marvell,mmp2-based OLPC XO 1.75 laptop. (With a custom
> appended DT that will be submitted in a separate patch set. The
> machine's OpenFirmware provides a device tree, but that one is too
> buggy to boot a pure marvell,mmp2 FDT kernel.)

For all the EHCI parts of this series:

Acked-by: Alan Stern <stern@rowland.harvard.edu>


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

* [PATCH 00/14] Convert ehci-mv to DT
@ 2018-08-28 15:04   ` Alan Stern
  0 siblings, 0 replies; 85+ messages in thread
From: Alan Stern @ 2018-08-28 15:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 22 Aug 2018, Lubomir Rintel wrote:

> Hi,
> 
> This patch set makes it possible to use the Marvell EHCI driver with
> DT-based machines.
> 
> Tested on a marvell,mmp2-based OLPC XO 1.75 laptop. (With a custom
> appended DT that will be submitted in a separate patch set. The
> machine's OpenFirmware provides a device tree, but that one is too
> buggy to boot a pure marvell,mmp2 FDT kernel.)

For all the EHCI parts of this series:

Acked-by: Alan Stern <stern@rowland.harvard.edu>

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

* Re: [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-09-25  5:23     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 85+ messages in thread
From: Kishon Vijay Abraham I @ 2018-09-25  5:23 UTC (permalink / raw)
  To: Lubomir Rintel, linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang, Alan Stern



On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver, so
> that in can be instantiated from a DT.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>

If this has to be merged via linux-phy tree, please let me know.

Thanks
Kishon

> ---
>  drivers/phy/marvell/Kconfig       |  11 +
>  drivers/phy/marvell/Makefile      |   1 +
>  drivers/phy/marvell/phy-pxa-usb.c | 345 ++++++++++++++++++++++++++++++
>  3 files changed, 357 insertions(+)
>  create mode 100644 drivers/phy/marvell/phy-pxa-usb.c
> 
> diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig
> index 68e321225400..6fb4b56e4c14 100644
> --- a/drivers/phy/marvell/Kconfig
> +++ b/drivers/phy/marvell/Kconfig
> @@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
>  	  The PHY driver will be used by Marvell udc/ehci/otg driver.
>  
>  	  To compile this driver as a module, choose M here.
> +
> +config PHY_PXA_USB
> +	tristate "Marvell PXA USB PHY Driver"
> +	depends on ARCH_PXA || ARCH_MMP
> +	select GENERIC_PHY
> +	help
> +	  Enable this to support Marvell PXA USB 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.
> diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile
> index 5c3ec5d10e0d..3975b144f8ec 100644
> --- a/drivers/phy/marvell/Makefile
> +++ b/drivers/phy/marvell/Makefile
> @@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-mvebu-cp110-comphy.o
>  obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
>  obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
>  obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
> +obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
> diff --git a/drivers/phy/marvell/phy-pxa-usb.c b/drivers/phy/marvell/phy-pxa-usb.c
> new file mode 100644
> index 000000000000..87ff7550b912
> --- /dev/null
> +++ b/drivers/phy/marvell/phy-pxa-usb.c
> @@ -0,0 +1,345 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
> + * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
> + */
> +
> +#include <dt-bindings/phy/phy.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of_address.h>
> +#include <linux/phy/phy.h>
> +#include <linux/platform_device.h>
> +
> +/* phy regs */
> +#define UTMI_REVISION		0x0
> +#define UTMI_CTRL		0x4
> +#define UTMI_PLL		0x8
> +#define UTMI_TX			0xc
> +#define UTMI_RX			0x10
> +#define UTMI_IVREF		0x14
> +#define UTMI_T0			0x18
> +#define UTMI_T1			0x1c
> +#define UTMI_T2			0x20
> +#define UTMI_T3			0x24
> +#define UTMI_T4			0x28
> +#define UTMI_T5			0x2c
> +#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_SHIFT		28
> +#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			27
> +#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
> +
> +#define UTMI_PLL_PLLVDD12_SHIFT			25
> +#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_SHIFT			15
> +#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
> +
> +#define UTMI_PLL_ICP_SHIFT			12
> +#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
> +
> +#define UTMI_PLL_FBDIV_SHIFT                    4
> +#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
> +
> +#define UTMI_PLL_REFDIV_SHIFT                   0
> +#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
> +
> +/* For UTMI_TX Register */
> +#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
> +#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
> +
> +#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
> +#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
> +
> +#define UTMI_TX_TXVDD12_SHIFT                   22
> +#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
> +
> +#define UTMI_TX_CK60_PHSEL_SHIFT                17
> +#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
> +
> +#define UTMI_TX_IMPCAL_VTH_SHIFT                14
> +#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
> +
> +#define REG_RCAL_START                          (0x1 << 12)
> +
> +#define UTMI_TX_LOW_VDD_EN_SHIFT                11
> +
> +#define UTMI_TX_AMP_SHIFT			0
> +#define UTMI_TX_AMP_MASK			(0x7 << 0)
> +
> +/* For UTMI_RX Register */
> +#define UTMI_REG_SQ_LENGTH_SHIFT                15
> +#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
> +
> +#define UTMI_RX_SQ_THRESH_SHIFT                 4
> +#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
> +
> +#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
> +
> +enum pxa_usb_phy_version {
> +	PXA_USB_PHY_MMP2,
> +	PXA_USB_PHY_PXA910,
> +	PXA_USB_PHY_PXA168,
> +};
> +
> +struct pxa_usb_phy {
> +	struct phy *phy;
> +	void __iomem *base;
> +	enum pxa_usb_phy_version version;
> +};
> +
> +/*****************************************************************************
> + * The registers read/write routines
> + *****************************************************************************/
> +
> +static unsigned int u2o_get(void __iomem *base, unsigned int offset)
> +{
> +	return readl_relaxed(base + offset);
> +}
> +
> +static void u2o_set(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	u32 reg;
> +
> +	reg = readl_relaxed(base + offset);
> +	reg |= value;
> +	writel_relaxed(reg, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static void u2o_clear(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	u32 reg;
> +
> +	reg = readl_relaxed(base + offset);
> +	reg &= ~value;
> +	writel_relaxed(reg, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static void u2o_write(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	writel_relaxed(value, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static int pxa_usb_phy_init(struct phy *phy)
> +{
> +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> +	void __iomem *base = pxa_usb_phy->base;
> +	int loops;
> +
> +	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
> +
> +	/* Initialize the USB PHY power */
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
> +		u2o_set(base, UTMI_CTRL, (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
> +			| (1<<UTMI_CTRL_PU_REF_SHIFT));
> +	}
> +
> +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> +
> +	/* UTMI_PLL settings */
> +	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
> +		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
> +		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
> +		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
> +
> +	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
> +		| 0xb<<UTMI_PLL_REFDIV_SHIFT | 3<<UTMI_PLL_PLLVDD18_SHIFT
> +		| 3<<UTMI_PLL_PLLVDD12_SHIFT | 3<<UTMI_PLL_PLLCALI12_SHIFT
> +		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
> +
> +	/* UTMI_TX */
> +	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
> +		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
> +		| UTMI_TX_IMPCAL_VTH_MASK | UTMI_TX_REG_EXT_FS_RCAL_MASK
> +		| UTMI_TX_AMP_MASK);
> +	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
> +		| 4<<UTMI_TX_CK60_PHSEL_SHIFT | 4<<UTMI_TX_IMPCAL_VTH_SHIFT
> +		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT | 3<<UTMI_TX_AMP_SHIFT);
> +
> +	/* UTMI_RX */
> +	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
> +		| UTMI_REG_SQ_LENGTH_MASK);
> +	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
> +		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
> +
> +	/* UTMI_IVREF */
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> +		/*
> +		 * fixing Microsoft Altair board interface with NEC hub issue -
> +		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
> +		 */
> +		u2o_write(base, UTMI_IVREF, 0x4bf);
> +	}
> +
> +	/* toggle VCOCAL_START bit of UTMI_PLL */
> +	udelay(200);
> +	u2o_set(base, UTMI_PLL, VCOCAL_START);
> +	udelay(40);
> +	u2o_clear(base, UTMI_PLL, VCOCAL_START);
> +
> +	/* toggle REG_RCAL_START bit of UTMI_TX */
> +	udelay(400);
> +	u2o_set(base, UTMI_TX, REG_RCAL_START);
> +	udelay(40);
> +	u2o_clear(base, UTMI_TX, REG_RCAL_START);
> +	udelay(400);
> +
> +	/* Make sure PHY PLL is ready */
> +	loops = 0;
> +	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
> +		mdelay(1);
> +		loops++;
> +		if (loops > 100) {
> +			dev_warn(&phy->dev, "calibrate timeout, UTMI_PLL %x\n",
> +						u2o_get(base, UTMI_PLL));
> +			break;
> +		}
> +	}
> +
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> +		u2o_set(base, UTMI_RESERVE, 1 << 5);
> +		/* Turn on UTMI PHY OTG extension */
> +		u2o_write(base, UTMI_OTG_ADDON, 1);
> +	}
> +
> +	return 0;
> +
> +}
> +
> +static int pxa_usb_phy_exit(struct phy *phy)
> +{
> +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> +	void __iomem *base = pxa_usb_phy->base;
> +
> +	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
> +
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
> +		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
> +
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
> +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> +
> +	return 0;
> +}
> +
> +static const struct phy_ops pxa_usb_phy_ops = {
> +	.init	= pxa_usb_phy_init,
> +	.exit	= pxa_usb_phy_exit,
> +	.owner	= THIS_MODULE,
> +};
> +
> +static const struct of_device_id pxa_usb_phy_of_match[] = {
> +	{
> +		.compatible = "marvell,mmp2-usb-phy",
> +		.data = (void *)PXA_USB_PHY_MMP2,
> +	}, {
> +		.compatible = "marvell,pxa910-usb-phy",
> +		.data = (void *)PXA_USB_PHY_PXA910,
> +	}, {
> +		.compatible = "marvell,pxa168-usb-phy",
> +		.data = (void *)PXA_USB_PHY_PXA168,
> +	},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
> +
> +static int pxa_usb_phy_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct resource *resource;
> +	struct pxa_usb_phy *pxa_usb_phy;
> +	struct phy_provider *provider;
> +	const struct of_device_id *of_id;
> +
> +	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy), GFP_KERNEL);
> +	if (!pxa_usb_phy)
> +		return -ENOMEM;
> +
> +	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
> +	if (of_id)
> +		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id->data;
> +	else
> +		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
> +
> +	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
> +	if (IS_ERR(pxa_usb_phy->base)) {
> +		dev_err(dev, "failed to remap PHY regs\n");
> +		return PTR_ERR(pxa_usb_phy->base);
> +	}
> +
> +	pxa_usb_phy->phy = devm_phy_create(dev, NULL, &pxa_usb_phy_ops);
> +	if (IS_ERR(pxa_usb_phy->phy)) {
> +		dev_err(dev, "failed to create PHY\n");
> +		return PTR_ERR(pxa_usb_phy->phy);
> +	}
> +
> +	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
> +	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> +	if (IS_ERR(provider)) {
> +		dev_err(dev, "failed to register PHY provider\n");
> +		return PTR_ERR(provider);
> +	}
> +
> +	if (!dev->of_node) {
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-u2oehci");
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
> +	}
> +
> +	dev_info(dev, "Marvell PXA USB PHY");
> +	return 0;
> +}
> +
> +static struct platform_driver pxa_usb_phy_driver = {
> +	.probe		= pxa_usb_phy_probe,
> +	.driver		= {
> +		.name	= "pxa-usb-phy",
> +		.of_match_table = pxa_usb_phy_of_match,
> +	},
> +};
> +module_platform_driver(pxa_usb_phy_driver);
> +
> +MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
> +MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
> +MODULE_LICENSE("GPL v2");
> 

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

* [01/14] phy: phy-pxa-usb: add a new driver
@ 2018-09-25  5:23     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 85+ messages in thread
From: Kishon Vijay Abraham I @ 2018-09-25  5:23 UTC (permalink / raw)
  To: Lubomir Rintel, linux-kernel
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Greg Kroah-Hartman, Eric Miao, Haojian Zhuang, Alan Stern

On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver, so
> that in can be instantiated from a DT.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>

If this has to be merged via linux-phy tree, please let me know.

Thanks
Kishon

> ---
>  drivers/phy/marvell/Kconfig       |  11 +
>  drivers/phy/marvell/Makefile      |   1 +
>  drivers/phy/marvell/phy-pxa-usb.c | 345 ++++++++++++++++++++++++++++++
>  3 files changed, 357 insertions(+)
>  create mode 100644 drivers/phy/marvell/phy-pxa-usb.c
> 
> diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig
> index 68e321225400..6fb4b56e4c14 100644
> --- a/drivers/phy/marvell/Kconfig
> +++ b/drivers/phy/marvell/Kconfig
> @@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
>  	  The PHY driver will be used by Marvell udc/ehci/otg driver.
>  
>  	  To compile this driver as a module, choose M here.
> +
> +config PHY_PXA_USB
> +	tristate "Marvell PXA USB PHY Driver"
> +	depends on ARCH_PXA || ARCH_MMP
> +	select GENERIC_PHY
> +	help
> +	  Enable this to support Marvell PXA USB 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.
> diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile
> index 5c3ec5d10e0d..3975b144f8ec 100644
> --- a/drivers/phy/marvell/Makefile
> +++ b/drivers/phy/marvell/Makefile
> @@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-mvebu-cp110-comphy.o
>  obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
>  obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
>  obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
> +obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
> diff --git a/drivers/phy/marvell/phy-pxa-usb.c b/drivers/phy/marvell/phy-pxa-usb.c
> new file mode 100644
> index 000000000000..87ff7550b912
> --- /dev/null
> +++ b/drivers/phy/marvell/phy-pxa-usb.c
> @@ -0,0 +1,345 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
> + * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
> + */
> +
> +#include <dt-bindings/phy/phy.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of_address.h>
> +#include <linux/phy/phy.h>
> +#include <linux/platform_device.h>
> +
> +/* phy regs */
> +#define UTMI_REVISION		0x0
> +#define UTMI_CTRL		0x4
> +#define UTMI_PLL		0x8
> +#define UTMI_TX			0xc
> +#define UTMI_RX			0x10
> +#define UTMI_IVREF		0x14
> +#define UTMI_T0			0x18
> +#define UTMI_T1			0x1c
> +#define UTMI_T2			0x20
> +#define UTMI_T3			0x24
> +#define UTMI_T4			0x28
> +#define UTMI_T5			0x2c
> +#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_SHIFT		28
> +#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			27
> +#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
> +
> +#define UTMI_PLL_PLLVDD12_SHIFT			25
> +#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_SHIFT			15
> +#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
> +
> +#define UTMI_PLL_ICP_SHIFT			12
> +#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
> +
> +#define UTMI_PLL_FBDIV_SHIFT                    4
> +#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
> +
> +#define UTMI_PLL_REFDIV_SHIFT                   0
> +#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
> +
> +/* For UTMI_TX Register */
> +#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
> +#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
> +
> +#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
> +#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
> +
> +#define UTMI_TX_TXVDD12_SHIFT                   22
> +#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
> +
> +#define UTMI_TX_CK60_PHSEL_SHIFT                17
> +#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
> +
> +#define UTMI_TX_IMPCAL_VTH_SHIFT                14
> +#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
> +
> +#define REG_RCAL_START                          (0x1 << 12)
> +
> +#define UTMI_TX_LOW_VDD_EN_SHIFT                11
> +
> +#define UTMI_TX_AMP_SHIFT			0
> +#define UTMI_TX_AMP_MASK			(0x7 << 0)
> +
> +/* For UTMI_RX Register */
> +#define UTMI_REG_SQ_LENGTH_SHIFT                15
> +#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
> +
> +#define UTMI_RX_SQ_THRESH_SHIFT                 4
> +#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
> +
> +#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
> +
> +enum pxa_usb_phy_version {
> +	PXA_USB_PHY_MMP2,
> +	PXA_USB_PHY_PXA910,
> +	PXA_USB_PHY_PXA168,
> +};
> +
> +struct pxa_usb_phy {
> +	struct phy *phy;
> +	void __iomem *base;
> +	enum pxa_usb_phy_version version;
> +};
> +
> +/*****************************************************************************
> + * The registers read/write routines
> + *****************************************************************************/
> +
> +static unsigned int u2o_get(void __iomem *base, unsigned int offset)
> +{
> +	return readl_relaxed(base + offset);
> +}
> +
> +static void u2o_set(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	u32 reg;
> +
> +	reg = readl_relaxed(base + offset);
> +	reg |= value;
> +	writel_relaxed(reg, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static void u2o_clear(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	u32 reg;
> +
> +	reg = readl_relaxed(base + offset);
> +	reg &= ~value;
> +	writel_relaxed(reg, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static void u2o_write(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	writel_relaxed(value, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static int pxa_usb_phy_init(struct phy *phy)
> +{
> +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> +	void __iomem *base = pxa_usb_phy->base;
> +	int loops;
> +
> +	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
> +
> +	/* Initialize the USB PHY power */
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
> +		u2o_set(base, UTMI_CTRL, (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
> +			| (1<<UTMI_CTRL_PU_REF_SHIFT));
> +	}
> +
> +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> +
> +	/* UTMI_PLL settings */
> +	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
> +		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
> +		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
> +		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
> +
> +	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
> +		| 0xb<<UTMI_PLL_REFDIV_SHIFT | 3<<UTMI_PLL_PLLVDD18_SHIFT
> +		| 3<<UTMI_PLL_PLLVDD12_SHIFT | 3<<UTMI_PLL_PLLCALI12_SHIFT
> +		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
> +
> +	/* UTMI_TX */
> +	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
> +		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
> +		| UTMI_TX_IMPCAL_VTH_MASK | UTMI_TX_REG_EXT_FS_RCAL_MASK
> +		| UTMI_TX_AMP_MASK);
> +	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
> +		| 4<<UTMI_TX_CK60_PHSEL_SHIFT | 4<<UTMI_TX_IMPCAL_VTH_SHIFT
> +		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT | 3<<UTMI_TX_AMP_SHIFT);
> +
> +	/* UTMI_RX */
> +	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
> +		| UTMI_REG_SQ_LENGTH_MASK);
> +	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
> +		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
> +
> +	/* UTMI_IVREF */
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> +		/*
> +		 * fixing Microsoft Altair board interface with NEC hub issue -
> +		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
> +		 */
> +		u2o_write(base, UTMI_IVREF, 0x4bf);
> +	}
> +
> +	/* toggle VCOCAL_START bit of UTMI_PLL */
> +	udelay(200);
> +	u2o_set(base, UTMI_PLL, VCOCAL_START);
> +	udelay(40);
> +	u2o_clear(base, UTMI_PLL, VCOCAL_START);
> +
> +	/* toggle REG_RCAL_START bit of UTMI_TX */
> +	udelay(400);
> +	u2o_set(base, UTMI_TX, REG_RCAL_START);
> +	udelay(40);
> +	u2o_clear(base, UTMI_TX, REG_RCAL_START);
> +	udelay(400);
> +
> +	/* Make sure PHY PLL is ready */
> +	loops = 0;
> +	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
> +		mdelay(1);
> +		loops++;
> +		if (loops > 100) {
> +			dev_warn(&phy->dev, "calibrate timeout, UTMI_PLL %x\n",
> +						u2o_get(base, UTMI_PLL));
> +			break;
> +		}
> +	}
> +
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> +		u2o_set(base, UTMI_RESERVE, 1 << 5);
> +		/* Turn on UTMI PHY OTG extension */
> +		u2o_write(base, UTMI_OTG_ADDON, 1);
> +	}
> +
> +	return 0;
> +
> +}
> +
> +static int pxa_usb_phy_exit(struct phy *phy)
> +{
> +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> +	void __iomem *base = pxa_usb_phy->base;
> +
> +	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
> +
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
> +		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
> +
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
> +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> +
> +	return 0;
> +}
> +
> +static const struct phy_ops pxa_usb_phy_ops = {
> +	.init	= pxa_usb_phy_init,
> +	.exit	= pxa_usb_phy_exit,
> +	.owner	= THIS_MODULE,
> +};
> +
> +static const struct of_device_id pxa_usb_phy_of_match[] = {
> +	{
> +		.compatible = "marvell,mmp2-usb-phy",
> +		.data = (void *)PXA_USB_PHY_MMP2,
> +	}, {
> +		.compatible = "marvell,pxa910-usb-phy",
> +		.data = (void *)PXA_USB_PHY_PXA910,
> +	}, {
> +		.compatible = "marvell,pxa168-usb-phy",
> +		.data = (void *)PXA_USB_PHY_PXA168,
> +	},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
> +
> +static int pxa_usb_phy_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct resource *resource;
> +	struct pxa_usb_phy *pxa_usb_phy;
> +	struct phy_provider *provider;
> +	const struct of_device_id *of_id;
> +
> +	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy), GFP_KERNEL);
> +	if (!pxa_usb_phy)
> +		return -ENOMEM;
> +
> +	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
> +	if (of_id)
> +		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id->data;
> +	else
> +		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
> +
> +	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
> +	if (IS_ERR(pxa_usb_phy->base)) {
> +		dev_err(dev, "failed to remap PHY regs\n");
> +		return PTR_ERR(pxa_usb_phy->base);
> +	}
> +
> +	pxa_usb_phy->phy = devm_phy_create(dev, NULL, &pxa_usb_phy_ops);
> +	if (IS_ERR(pxa_usb_phy->phy)) {
> +		dev_err(dev, "failed to create PHY\n");
> +		return PTR_ERR(pxa_usb_phy->phy);
> +	}
> +
> +	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
> +	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> +	if (IS_ERR(provider)) {
> +		dev_err(dev, "failed to register PHY provider\n");
> +		return PTR_ERR(provider);
> +	}
> +
> +	if (!dev->of_node) {
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-u2oehci");
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
> +	}
> +
> +	dev_info(dev, "Marvell PXA USB PHY");
> +	return 0;
> +}
> +
> +static struct platform_driver pxa_usb_phy_driver = {
> +	.probe		= pxa_usb_phy_probe,
> +	.driver		= {
> +		.name	= "pxa-usb-phy",
> +		.of_match_table = pxa_usb_phy_of_match,
> +	},
> +};
> +module_platform_driver(pxa_usb_phy_driver);
> +
> +MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
> +MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
> +MODULE_LICENSE("GPL v2");
>

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

* [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-09-25  5:23     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 85+ messages in thread
From: Kishon Vijay Abraham I @ 2018-09-25  5:23 UTC (permalink / raw)
  To: linux-arm-kernel



On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver, so
> that in can be instantiated from a DT.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>

If this has to be merged via linux-phy tree, please let me know.

Thanks
Kishon

> ---
>  drivers/phy/marvell/Kconfig       |  11 +
>  drivers/phy/marvell/Makefile      |   1 +
>  drivers/phy/marvell/phy-pxa-usb.c | 345 ++++++++++++++++++++++++++++++
>  3 files changed, 357 insertions(+)
>  create mode 100644 drivers/phy/marvell/phy-pxa-usb.c
> 
> diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig
> index 68e321225400..6fb4b56e4c14 100644
> --- a/drivers/phy/marvell/Kconfig
> +++ b/drivers/phy/marvell/Kconfig
> @@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
>  	  The PHY driver will be used by Marvell udc/ehci/otg driver.
>  
>  	  To compile this driver as a module, choose M here.
> +
> +config PHY_PXA_USB
> +	tristate "Marvell PXA USB PHY Driver"
> +	depends on ARCH_PXA || ARCH_MMP
> +	select GENERIC_PHY
> +	help
> +	  Enable this to support Marvell PXA USB 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.
> diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile
> index 5c3ec5d10e0d..3975b144f8ec 100644
> --- a/drivers/phy/marvell/Makefile
> +++ b/drivers/phy/marvell/Makefile
> @@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-mvebu-cp110-comphy.o
>  obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
>  obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
>  obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
> +obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
> diff --git a/drivers/phy/marvell/phy-pxa-usb.c b/drivers/phy/marvell/phy-pxa-usb.c
> new file mode 100644
> index 000000000000..87ff7550b912
> --- /dev/null
> +++ b/drivers/phy/marvell/phy-pxa-usb.c
> @@ -0,0 +1,345 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2011 Marvell International Ltd. All rights reserved.
> + * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
> + */
> +
> +#include <dt-bindings/phy/phy.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of_address.h>
> +#include <linux/phy/phy.h>
> +#include <linux/platform_device.h>
> +
> +/* phy regs */
> +#define UTMI_REVISION		0x0
> +#define UTMI_CTRL		0x4
> +#define UTMI_PLL		0x8
> +#define UTMI_TX			0xc
> +#define UTMI_RX			0x10
> +#define UTMI_IVREF		0x14
> +#define UTMI_T0			0x18
> +#define UTMI_T1			0x1c
> +#define UTMI_T2			0x20
> +#define UTMI_T3			0x24
> +#define UTMI_T4			0x28
> +#define UTMI_T5			0x2c
> +#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_SHIFT		28
> +#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			27
> +#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
> +
> +#define UTMI_PLL_PLLVDD12_SHIFT			25
> +#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_SHIFT			15
> +#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
> +
> +#define UTMI_PLL_ICP_SHIFT			12
> +#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
> +
> +#define UTMI_PLL_FBDIV_SHIFT                    4
> +#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
> +
> +#define UTMI_PLL_REFDIV_SHIFT                   0
> +#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
> +
> +/* For UTMI_TX Register */
> +#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
> +#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
> +
> +#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
> +#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
> +
> +#define UTMI_TX_TXVDD12_SHIFT                   22
> +#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
> +
> +#define UTMI_TX_CK60_PHSEL_SHIFT                17
> +#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
> +
> +#define UTMI_TX_IMPCAL_VTH_SHIFT                14
> +#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
> +
> +#define REG_RCAL_START                          (0x1 << 12)
> +
> +#define UTMI_TX_LOW_VDD_EN_SHIFT                11
> +
> +#define UTMI_TX_AMP_SHIFT			0
> +#define UTMI_TX_AMP_MASK			(0x7 << 0)
> +
> +/* For UTMI_RX Register */
> +#define UTMI_REG_SQ_LENGTH_SHIFT                15
> +#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
> +
> +#define UTMI_RX_SQ_THRESH_SHIFT                 4
> +#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
> +
> +#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
> +
> +enum pxa_usb_phy_version {
> +	PXA_USB_PHY_MMP2,
> +	PXA_USB_PHY_PXA910,
> +	PXA_USB_PHY_PXA168,
> +};
> +
> +struct pxa_usb_phy {
> +	struct phy *phy;
> +	void __iomem *base;
> +	enum pxa_usb_phy_version version;
> +};
> +
> +/*****************************************************************************
> + * The registers read/write routines
> + *****************************************************************************/
> +
> +static unsigned int u2o_get(void __iomem *base, unsigned int offset)
> +{
> +	return readl_relaxed(base + offset);
> +}
> +
> +static void u2o_set(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	u32 reg;
> +
> +	reg = readl_relaxed(base + offset);
> +	reg |= value;
> +	writel_relaxed(reg, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static void u2o_clear(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	u32 reg;
> +
> +	reg = readl_relaxed(base + offset);
> +	reg &= ~value;
> +	writel_relaxed(reg, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static void u2o_write(void __iomem *base, unsigned int offset,
> +		unsigned int value)
> +{
> +	writel_relaxed(value, base + offset);
> +	readl_relaxed(base + offset);
> +}
> +
> +static int pxa_usb_phy_init(struct phy *phy)
> +{
> +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> +	void __iomem *base = pxa_usb_phy->base;
> +	int loops;
> +
> +	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
> +
> +	/* Initialize the USB PHY power */
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
> +		u2o_set(base, UTMI_CTRL, (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
> +			| (1<<UTMI_CTRL_PU_REF_SHIFT));
> +	}
> +
> +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> +
> +	/* UTMI_PLL settings */
> +	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
> +		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
> +		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
> +		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
> +
> +	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
> +		| 0xb<<UTMI_PLL_REFDIV_SHIFT | 3<<UTMI_PLL_PLLVDD18_SHIFT
> +		| 3<<UTMI_PLL_PLLVDD12_SHIFT | 3<<UTMI_PLL_PLLCALI12_SHIFT
> +		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
> +
> +	/* UTMI_TX */
> +	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
> +		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
> +		| UTMI_TX_IMPCAL_VTH_MASK | UTMI_TX_REG_EXT_FS_RCAL_MASK
> +		| UTMI_TX_AMP_MASK);
> +	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
> +		| 4<<UTMI_TX_CK60_PHSEL_SHIFT | 4<<UTMI_TX_IMPCAL_VTH_SHIFT
> +		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT | 3<<UTMI_TX_AMP_SHIFT);
> +
> +	/* UTMI_RX */
> +	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
> +		| UTMI_REG_SQ_LENGTH_MASK);
> +	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
> +		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
> +
> +	/* UTMI_IVREF */
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> +		/*
> +		 * fixing Microsoft Altair board interface with NEC hub issue -
> +		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
> +		 */
> +		u2o_write(base, UTMI_IVREF, 0x4bf);
> +	}
> +
> +	/* toggle VCOCAL_START bit of UTMI_PLL */
> +	udelay(200);
> +	u2o_set(base, UTMI_PLL, VCOCAL_START);
> +	udelay(40);
> +	u2o_clear(base, UTMI_PLL, VCOCAL_START);
> +
> +	/* toggle REG_RCAL_START bit of UTMI_TX */
> +	udelay(400);
> +	u2o_set(base, UTMI_TX, REG_RCAL_START);
> +	udelay(40);
> +	u2o_clear(base, UTMI_TX, REG_RCAL_START);
> +	udelay(400);
> +
> +	/* Make sure PHY PLL is ready */
> +	loops = 0;
> +	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
> +		mdelay(1);
> +		loops++;
> +		if (loops > 100) {
> +			dev_warn(&phy->dev, "calibrate timeout, UTMI_PLL %x\n",
> +						u2o_get(base, UTMI_PLL));
> +			break;
> +		}
> +	}
> +
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> +		u2o_set(base, UTMI_RESERVE, 1 << 5);
> +		/* Turn on UTMI PHY OTG extension */
> +		u2o_write(base, UTMI_OTG_ADDON, 1);
> +	}
> +
> +	return 0;
> +
> +}
> +
> +static int pxa_usb_phy_exit(struct phy *phy)
> +{
> +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> +	void __iomem *base = pxa_usb_phy->base;
> +
> +	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
> +
> +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
> +		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
> +
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
> +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
> +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> +
> +	return 0;
> +}
> +
> +static const struct phy_ops pxa_usb_phy_ops = {
> +	.init	= pxa_usb_phy_init,
> +	.exit	= pxa_usb_phy_exit,
> +	.owner	= THIS_MODULE,
> +};
> +
> +static const struct of_device_id pxa_usb_phy_of_match[] = {
> +	{
> +		.compatible = "marvell,mmp2-usb-phy",
> +		.data = (void *)PXA_USB_PHY_MMP2,
> +	}, {
> +		.compatible = "marvell,pxa910-usb-phy",
> +		.data = (void *)PXA_USB_PHY_PXA910,
> +	}, {
> +		.compatible = "marvell,pxa168-usb-phy",
> +		.data = (void *)PXA_USB_PHY_PXA168,
> +	},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
> +
> +static int pxa_usb_phy_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct resource *resource;
> +	struct pxa_usb_phy *pxa_usb_phy;
> +	struct phy_provider *provider;
> +	const struct of_device_id *of_id;
> +
> +	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy), GFP_KERNEL);
> +	if (!pxa_usb_phy)
> +		return -ENOMEM;
> +
> +	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
> +	if (of_id)
> +		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id->data;
> +	else
> +		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
> +
> +	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
> +	if (IS_ERR(pxa_usb_phy->base)) {
> +		dev_err(dev, "failed to remap PHY regs\n");
> +		return PTR_ERR(pxa_usb_phy->base);
> +	}
> +
> +	pxa_usb_phy->phy = devm_phy_create(dev, NULL, &pxa_usb_phy_ops);
> +	if (IS_ERR(pxa_usb_phy->phy)) {
> +		dev_err(dev, "failed to create PHY\n");
> +		return PTR_ERR(pxa_usb_phy->phy);
> +	}
> +
> +	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
> +	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> +	if (IS_ERR(provider)) {
> +		dev_err(dev, "failed to register PHY provider\n");
> +		return PTR_ERR(provider);
> +	}
> +
> +	if (!dev->of_node) {
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-u2oehci");
> +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
> +	}
> +
> +	dev_info(dev, "Marvell PXA USB PHY");
> +	return 0;
> +}
> +
> +static struct platform_driver pxa_usb_phy_driver = {
> +	.probe		= pxa_usb_phy_probe,
> +	.driver		= {
> +		.name	= "pxa-usb-phy",
> +		.of_match_table = pxa_usb_phy_of_match,
> +	},
> +};
> +module_platform_driver(pxa_usb_phy_driver);
> +
> +MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
> +MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
> +MODULE_LICENSE("GPL v2");
> 

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

* Re: [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-07 18:47       ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-10-07 18:47 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, linux-kernel, Greg Kroah-Hartman
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Eric Miao, Haojian Zhuang, Alan Stern

On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> 
> On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > so
> > that in can be instantiated from a DT.
> > 
> > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> 
> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> 
> If this has to be merged via linux-phy tree, please let me know.

Yes, either linux-phy or the usb tree.

The EHCI patches have already been pulled into the usb tree, presumably
because they got an Ack from Alan Stern. That includes "USB: EHCI:
ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
the patches can go via the same tree?

I haven't submitted a patchset that would have dependencies spanning
across different subsystems before. I don't know what's usually done in
such cases. Advice welcome.

Greg?

> Thanks
> Kishon

Thank you
Lubo

> 
> > ---
> >  drivers/phy/marvell/Kconfig       |  11 +
> >  drivers/phy/marvell/Makefile      |   1 +
> >  drivers/phy/marvell/phy-pxa-usb.c | 345
> > ++++++++++++++++++++++++++++++
> >  3 files changed, 357 insertions(+)
> >  create mode 100644 drivers/phy/marvell/phy-pxa-usb.c
> > 
> > diff --git a/drivers/phy/marvell/Kconfig
> > b/drivers/phy/marvell/Kconfig
> > index 68e321225400..6fb4b56e4c14 100644
> > --- a/drivers/phy/marvell/Kconfig
> > +++ b/drivers/phy/marvell/Kconfig
> > @@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
> >  	  The PHY driver will be used by Marvell udc/ehci/otg driver.
> >  
> >  	  To compile this driver as a module, choose M here.
> > +
> > +config PHY_PXA_USB
> > +	tristate "Marvell PXA USB PHY Driver"
> > +	depends on ARCH_PXA || ARCH_MMP
> > +	select GENERIC_PHY
> > +	help
> > +	  Enable this to support Marvell PXA USB 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.
> > diff --git a/drivers/phy/marvell/Makefile
> > b/drivers/phy/marvell/Makefile
> > index 5c3ec5d10e0d..3975b144f8ec 100644
> > --- a/drivers/phy/marvell/Makefile
> > +++ b/drivers/phy/marvell/Makefile
> > @@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-
> > mvebu-cp110-comphy.o
> >  obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
> >  obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
> >  obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
> > +obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
> > diff --git a/drivers/phy/marvell/phy-pxa-usb.c
> > b/drivers/phy/marvell/phy-pxa-usb.c
> > new file mode 100644
> > index 000000000000..87ff7550b912
> > --- /dev/null
> > +++ b/drivers/phy/marvell/phy-pxa-usb.c
> > @@ -0,0 +1,345 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2011 Marvell International Ltd. All rights
> > reserved.
> > + * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
> > + */
> > +
> > +#include <dt-bindings/phy/phy.h>
> > +#include <linux/clk.h>
> > +#include <linux/delay.h>
> > +#include <linux/io.h>
> > +#include <linux/module.h>
> > +#include <linux/of_address.h>
> > +#include <linux/phy/phy.h>
> > +#include <linux/platform_device.h>
> > +
> > +/* phy regs */
> > +#define UTMI_REVISION		0x0
> > +#define UTMI_CTRL		0x4
> > +#define UTMI_PLL		0x8
> > +#define UTMI_TX			0xc
> > +#define UTMI_RX			0x10
> > +#define UTMI_IVREF		0x14
> > +#define UTMI_T0			0x18
> > +#define UTMI_T1			0x1c
> > +#define UTMI_T2			0x20
> > +#define UTMI_T3			0x24
> > +#define UTMI_T4			0x28
> > +#define UTMI_T5			0x2c
> > +#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_SHIFT		28
> > +#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			27
> > +#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
> > +
> > +#define UTMI_PLL_PLLVDD12_SHIFT			25
> > +#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_SHIFT			15
> > +#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
> > +
> > +#define UTMI_PLL_ICP_SHIFT			12
> > +#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
> > +
> > +#define UTMI_PLL_FBDIV_SHIFT                    4
> > +#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
> > +
> > +#define UTMI_PLL_REFDIV_SHIFT                   0
> > +#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
> > +
> > +/* For UTMI_TX Register */
> > +#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
> > +#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
> > +
> > +#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
> > +#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
> > +
> > +#define UTMI_TX_TXVDD12_SHIFT                   22
> > +#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
> > +
> > +#define UTMI_TX_CK60_PHSEL_SHIFT                17
> > +#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
> > +
> > +#define UTMI_TX_IMPCAL_VTH_SHIFT                14
> > +#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
> > +
> > +#define REG_RCAL_START                          (0x1 << 12)
> > +
> > +#define UTMI_TX_LOW_VDD_EN_SHIFT                11
> > +
> > +#define UTMI_TX_AMP_SHIFT			0
> > +#define UTMI_TX_AMP_MASK			(0x7 << 0)
> > +
> > +/* For UTMI_RX Register */
> > +#define UTMI_REG_SQ_LENGTH_SHIFT                15
> > +#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
> > +
> > +#define UTMI_RX_SQ_THRESH_SHIFT                 4
> > +#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
> > +
> > +#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
> > +
> > +enum pxa_usb_phy_version {
> > +	PXA_USB_PHY_MMP2,
> > +	PXA_USB_PHY_PXA910,
> > +	PXA_USB_PHY_PXA168,
> > +};
> > +
> > +struct pxa_usb_phy {
> > +	struct phy *phy;
> > +	void __iomem *base;
> > +	enum pxa_usb_phy_version version;
> > +};
> > +
> > +/*****************************************************************
> > ************
> > + * The registers read/write routines
> > +
> > *******************************************************************
> > **********/
> > +
> > +static unsigned int u2o_get(void __iomem *base, unsigned int
> > offset)
> > +{
> > +	return readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_set(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	u32 reg;
> > +
> > +	reg = readl_relaxed(base + offset);
> > +	reg |= value;
> > +	writel_relaxed(reg, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_clear(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	u32 reg;
> > +
> > +	reg = readl_relaxed(base + offset);
> > +	reg &= ~value;
> > +	writel_relaxed(reg, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_write(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	writel_relaxed(value, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static int pxa_usb_phy_init(struct phy *phy)
> > +{
> > +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> > +	void __iomem *base = pxa_usb_phy->base;
> > +	int loops;
> > +
> > +	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
> > +
> > +	/* Initialize the USB PHY power */
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
> > +		u2o_set(base, UTMI_CTRL,
> > (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
> > +			| (1<<UTMI_CTRL_PU_REF_SHIFT));
> > +	}
> > +
> > +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> > +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> > +
> > +	/* UTMI_PLL settings */
> > +	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
> > +		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
> > +		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
> > +		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
> > +
> > +	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
> > +		| 0xb<<UTMI_PLL_REFDIV_SHIFT |
> > 3<<UTMI_PLL_PLLVDD18_SHIFT
> > +		| 3<<UTMI_PLL_PLLVDD12_SHIFT |
> > 3<<UTMI_PLL_PLLCALI12_SHIFT
> > +		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
> > +
> > +	/* UTMI_TX */
> > +	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
> > +		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
> > +		| UTMI_TX_IMPCAL_VTH_MASK |
> > UTMI_TX_REG_EXT_FS_RCAL_MASK
> > +		| UTMI_TX_AMP_MASK);
> > +	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
> > +		| 4<<UTMI_TX_CK60_PHSEL_SHIFT |
> > 4<<UTMI_TX_IMPCAL_VTH_SHIFT
> > +		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT |
> > 3<<UTMI_TX_AMP_SHIFT);
> > +
> > +	/* UTMI_RX */
> > +	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
> > +		| UTMI_REG_SQ_LENGTH_MASK);
> > +	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
> > +		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
> > +
> > +	/* UTMI_IVREF */
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> > +		/*
> > +		 * fixing Microsoft Altair board interface with NEC hub
> > issue -
> > +		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
> > +		 */
> > +		u2o_write(base, UTMI_IVREF, 0x4bf);
> > +	}
> > +
> > +	/* toggle VCOCAL_START bit of UTMI_PLL */
> > +	udelay(200);
> > +	u2o_set(base, UTMI_PLL, VCOCAL_START);
> > +	udelay(40);
> > +	u2o_clear(base, UTMI_PLL, VCOCAL_START);
> > +
> > +	/* toggle REG_RCAL_START bit of UTMI_TX */
> > +	udelay(400);
> > +	u2o_set(base, UTMI_TX, REG_RCAL_START);
> > +	udelay(40);
> > +	u2o_clear(base, UTMI_TX, REG_RCAL_START);
> > +	udelay(400);
> > +
> > +	/* Make sure PHY PLL is ready */
> > +	loops = 0;
> > +	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
> > +		mdelay(1);
> > +		loops++;
> > +		if (loops > 100) {
> > +			dev_warn(&phy->dev, "calibrate timeout,
> > UTMI_PLL %x\n",
> > +						u2o_get(base,
> > UTMI_PLL));
> > +			break;
> > +		}
> > +	}
> > +
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> > +		u2o_set(base, UTMI_RESERVE, 1 << 5);
> > +		/* Turn on UTMI PHY OTG extension */
> > +		u2o_write(base, UTMI_OTG_ADDON, 1);
> > +	}
> > +
> > +	return 0;
> > +
> > +}
> > +
> > +static int pxa_usb_phy_exit(struct phy *phy)
> > +{
> > +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> > +	void __iomem *base = pxa_usb_phy->base;
> > +
> > +	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
> > +
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
> > +		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
> > +
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
> > +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> > +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct phy_ops pxa_usb_phy_ops = {
> > +	.init	= pxa_usb_phy_init,
> > +	.exit	= pxa_usb_phy_exit,
> > +	.owner	= THIS_MODULE,
> > +};
> > +
> > +static const struct of_device_id pxa_usb_phy_of_match[] = {
> > +	{
> > +		.compatible = "marvell,mmp2-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_MMP2,
> > +	}, {
> > +		.compatible = "marvell,pxa910-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_PXA910,
> > +	}, {
> > +		.compatible = "marvell,pxa168-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_PXA168,
> > +	},
> > +	{ },
> > +};
> > +MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
> > +
> > +static int pxa_usb_phy_probe(struct platform_device *pdev)
> > +{
> > +	struct device *dev = &pdev->dev;
> > +	struct resource *resource;
> > +	struct pxa_usb_phy *pxa_usb_phy;
> > +	struct phy_provider *provider;
> > +	const struct of_device_id *of_id;
> > +
> > +	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy),
> > GFP_KERNEL);
> > +	if (!pxa_usb_phy)
> > +		return -ENOMEM;
> > +
> > +	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
> > +	if (of_id)
> > +		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id-
> > >data;
> > +	else
> > +		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
> > +
> > +	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
> > +	if (IS_ERR(pxa_usb_phy->base)) {
> > +		dev_err(dev, "failed to remap PHY regs\n");
> > +		return PTR_ERR(pxa_usb_phy->base);
> > +	}
> > +
> > +	pxa_usb_phy->phy = devm_phy_create(dev, NULL,
> > &pxa_usb_phy_ops);
> > +	if (IS_ERR(pxa_usb_phy->phy)) {
> > +		dev_err(dev, "failed to create PHY\n");
> > +		return PTR_ERR(pxa_usb_phy->phy);
> > +	}
> > +
> > +	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
> > +	provider = devm_of_phy_provider_register(dev,
> > of_phy_simple_xlate);
> > +	if (IS_ERR(provider)) {
> > +		dev_err(dev, "failed to register PHY provider\n");
> > +		return PTR_ERR(provider);
> > +	}
> > +
> > +	if (!dev->of_node) {
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-
> > u2oehci");
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
> > +	}
> > +
> > +	dev_info(dev, "Marvell PXA USB PHY");
> > +	return 0;
> > +}
> > +
> > +static struct platform_driver pxa_usb_phy_driver = {
> > +	.probe		= pxa_usb_phy_probe,
> > +	.driver		= {
> > +		.name	= "pxa-usb-phy",
> > +		.of_match_table = pxa_usb_phy_of_match,
> > +	},
> > +};
> > +module_platform_driver(pxa_usb_phy_driver);
> > +
> > +MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
> > +MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
> > +MODULE_LICENSE("GPL v2");
> > 


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

* [01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-07 18:47       ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-10-07 18:47 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, linux-kernel, Greg Kroah-Hartman
  Cc: linux-usb, linux-arm-kernel, Rob Herring, Mark Rutland,
	Eric Miao, Haojian Zhuang, Alan Stern

On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> 
> On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > so
> > that in can be instantiated from a DT.
> > 
> > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> 
> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> 
> If this has to be merged via linux-phy tree, please let me know.

Yes, either linux-phy or the usb tree.

The EHCI patches have already been pulled into the usb tree, presumably
because they got an Ack from Alan Stern. That includes "USB: EHCI:
ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
the patches can go via the same tree?

I haven't submitted a patchset that would have dependencies spanning
across different subsystems before. I don't know what's usually done in
such cases. Advice welcome.

Greg?

> Thanks
> Kishon

Thank you
Lubo

> 
> > ---
> >  drivers/phy/marvell/Kconfig       |  11 +
> >  drivers/phy/marvell/Makefile      |   1 +
> >  drivers/phy/marvell/phy-pxa-usb.c | 345
> > ++++++++++++++++++++++++++++++
> >  3 files changed, 357 insertions(+)
> >  create mode 100644 drivers/phy/marvell/phy-pxa-usb.c
> > 
> > diff --git a/drivers/phy/marvell/Kconfig
> > b/drivers/phy/marvell/Kconfig
> > index 68e321225400..6fb4b56e4c14 100644
> > --- a/drivers/phy/marvell/Kconfig
> > +++ b/drivers/phy/marvell/Kconfig
> > @@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
> >  	  The PHY driver will be used by Marvell udc/ehci/otg driver.
> >  
> >  	  To compile this driver as a module, choose M here.
> > +
> > +config PHY_PXA_USB
> > +	tristate "Marvell PXA USB PHY Driver"
> > +	depends on ARCH_PXA || ARCH_MMP
> > +	select GENERIC_PHY
> > +	help
> > +	  Enable this to support Marvell PXA USB 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.
> > diff --git a/drivers/phy/marvell/Makefile
> > b/drivers/phy/marvell/Makefile
> > index 5c3ec5d10e0d..3975b144f8ec 100644
> > --- a/drivers/phy/marvell/Makefile
> > +++ b/drivers/phy/marvell/Makefile
> > @@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-
> > mvebu-cp110-comphy.o
> >  obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
> >  obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
> >  obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
> > +obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
> > diff --git a/drivers/phy/marvell/phy-pxa-usb.c
> > b/drivers/phy/marvell/phy-pxa-usb.c
> > new file mode 100644
> > index 000000000000..87ff7550b912
> > --- /dev/null
> > +++ b/drivers/phy/marvell/phy-pxa-usb.c
> > @@ -0,0 +1,345 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2011 Marvell International Ltd. All rights
> > reserved.
> > + * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
> > + */
> > +
> > +#include <dt-bindings/phy/phy.h>
> > +#include <linux/clk.h>
> > +#include <linux/delay.h>
> > +#include <linux/io.h>
> > +#include <linux/module.h>
> > +#include <linux/of_address.h>
> > +#include <linux/phy/phy.h>
> > +#include <linux/platform_device.h>
> > +
> > +/* phy regs */
> > +#define UTMI_REVISION		0x0
> > +#define UTMI_CTRL		0x4
> > +#define UTMI_PLL		0x8
> > +#define UTMI_TX			0xc
> > +#define UTMI_RX			0x10
> > +#define UTMI_IVREF		0x14
> > +#define UTMI_T0			0x18
> > +#define UTMI_T1			0x1c
> > +#define UTMI_T2			0x20
> > +#define UTMI_T3			0x24
> > +#define UTMI_T4			0x28
> > +#define UTMI_T5			0x2c
> > +#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_SHIFT		28
> > +#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			27
> > +#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
> > +
> > +#define UTMI_PLL_PLLVDD12_SHIFT			25
> > +#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_SHIFT			15
> > +#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
> > +
> > +#define UTMI_PLL_ICP_SHIFT			12
> > +#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
> > +
> > +#define UTMI_PLL_FBDIV_SHIFT                    4
> > +#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
> > +
> > +#define UTMI_PLL_REFDIV_SHIFT                   0
> > +#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
> > +
> > +/* For UTMI_TX Register */
> > +#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
> > +#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
> > +
> > +#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
> > +#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
> > +
> > +#define UTMI_TX_TXVDD12_SHIFT                   22
> > +#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
> > +
> > +#define UTMI_TX_CK60_PHSEL_SHIFT                17
> > +#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
> > +
> > +#define UTMI_TX_IMPCAL_VTH_SHIFT                14
> > +#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
> > +
> > +#define REG_RCAL_START                          (0x1 << 12)
> > +
> > +#define UTMI_TX_LOW_VDD_EN_SHIFT                11
> > +
> > +#define UTMI_TX_AMP_SHIFT			0
> > +#define UTMI_TX_AMP_MASK			(0x7 << 0)
> > +
> > +/* For UTMI_RX Register */
> > +#define UTMI_REG_SQ_LENGTH_SHIFT                15
> > +#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
> > +
> > +#define UTMI_RX_SQ_THRESH_SHIFT                 4
> > +#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
> > +
> > +#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
> > +
> > +enum pxa_usb_phy_version {
> > +	PXA_USB_PHY_MMP2,
> > +	PXA_USB_PHY_PXA910,
> > +	PXA_USB_PHY_PXA168,
> > +};
> > +
> > +struct pxa_usb_phy {
> > +	struct phy *phy;
> > +	void __iomem *base;
> > +	enum pxa_usb_phy_version version;
> > +};
> > +
> > +/*****************************************************************
> > ************
> > + * The registers read/write routines
> > +
> > *******************************************************************
> > **********/
> > +
> > +static unsigned int u2o_get(void __iomem *base, unsigned int
> > offset)
> > +{
> > +	return readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_set(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	u32 reg;
> > +
> > +	reg = readl_relaxed(base + offset);
> > +	reg |= value;
> > +	writel_relaxed(reg, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_clear(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	u32 reg;
> > +
> > +	reg = readl_relaxed(base + offset);
> > +	reg &= ~value;
> > +	writel_relaxed(reg, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_write(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	writel_relaxed(value, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static int pxa_usb_phy_init(struct phy *phy)
> > +{
> > +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> > +	void __iomem *base = pxa_usb_phy->base;
> > +	int loops;
> > +
> > +	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
> > +
> > +	/* Initialize the USB PHY power */
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
> > +		u2o_set(base, UTMI_CTRL,
> > (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
> > +			| (1<<UTMI_CTRL_PU_REF_SHIFT));
> > +	}
> > +
> > +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> > +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> > +
> > +	/* UTMI_PLL settings */
> > +	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
> > +		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
> > +		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
> > +		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
> > +
> > +	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
> > +		| 0xb<<UTMI_PLL_REFDIV_SHIFT |
> > 3<<UTMI_PLL_PLLVDD18_SHIFT
> > +		| 3<<UTMI_PLL_PLLVDD12_SHIFT |
> > 3<<UTMI_PLL_PLLCALI12_SHIFT
> > +		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
> > +
> > +	/* UTMI_TX */
> > +	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
> > +		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
> > +		| UTMI_TX_IMPCAL_VTH_MASK |
> > UTMI_TX_REG_EXT_FS_RCAL_MASK
> > +		| UTMI_TX_AMP_MASK);
> > +	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
> > +		| 4<<UTMI_TX_CK60_PHSEL_SHIFT |
> > 4<<UTMI_TX_IMPCAL_VTH_SHIFT
> > +		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT |
> > 3<<UTMI_TX_AMP_SHIFT);
> > +
> > +	/* UTMI_RX */
> > +	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
> > +		| UTMI_REG_SQ_LENGTH_MASK);
> > +	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
> > +		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
> > +
> > +	/* UTMI_IVREF */
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> > +		/*
> > +		 * fixing Microsoft Altair board interface with NEC hub
> > issue -
> > +		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
> > +		 */
> > +		u2o_write(base, UTMI_IVREF, 0x4bf);
> > +	}
> > +
> > +	/* toggle VCOCAL_START bit of UTMI_PLL */
> > +	udelay(200);
> > +	u2o_set(base, UTMI_PLL, VCOCAL_START);
> > +	udelay(40);
> > +	u2o_clear(base, UTMI_PLL, VCOCAL_START);
> > +
> > +	/* toggle REG_RCAL_START bit of UTMI_TX */
> > +	udelay(400);
> > +	u2o_set(base, UTMI_TX, REG_RCAL_START);
> > +	udelay(40);
> > +	u2o_clear(base, UTMI_TX, REG_RCAL_START);
> > +	udelay(400);
> > +
> > +	/* Make sure PHY PLL is ready */
> > +	loops = 0;
> > +	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
> > +		mdelay(1);
> > +		loops++;
> > +		if (loops > 100) {
> > +			dev_warn(&phy->dev, "calibrate timeout,
> > UTMI_PLL %x\n",
> > +						u2o_get(base,
> > UTMI_PLL));
> > +			break;
> > +		}
> > +	}
> > +
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> > +		u2o_set(base, UTMI_RESERVE, 1 << 5);
> > +		/* Turn on UTMI PHY OTG extension */
> > +		u2o_write(base, UTMI_OTG_ADDON, 1);
> > +	}
> > +
> > +	return 0;
> > +
> > +}
> > +
> > +static int pxa_usb_phy_exit(struct phy *phy)
> > +{
> > +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> > +	void __iomem *base = pxa_usb_phy->base;
> > +
> > +	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
> > +
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
> > +		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
> > +
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
> > +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> > +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct phy_ops pxa_usb_phy_ops = {
> > +	.init	= pxa_usb_phy_init,
> > +	.exit	= pxa_usb_phy_exit,
> > +	.owner	= THIS_MODULE,
> > +};
> > +
> > +static const struct of_device_id pxa_usb_phy_of_match[] = {
> > +	{
> > +		.compatible = "marvell,mmp2-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_MMP2,
> > +	}, {
> > +		.compatible = "marvell,pxa910-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_PXA910,
> > +	}, {
> > +		.compatible = "marvell,pxa168-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_PXA168,
> > +	},
> > +	{ },
> > +};
> > +MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
> > +
> > +static int pxa_usb_phy_probe(struct platform_device *pdev)
> > +{
> > +	struct device *dev = &pdev->dev;
> > +	struct resource *resource;
> > +	struct pxa_usb_phy *pxa_usb_phy;
> > +	struct phy_provider *provider;
> > +	const struct of_device_id *of_id;
> > +
> > +	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy),
> > GFP_KERNEL);
> > +	if (!pxa_usb_phy)
> > +		return -ENOMEM;
> > +
> > +	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
> > +	if (of_id)
> > +		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id-
> > >data;
> > +	else
> > +		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
> > +
> > +	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
> > +	if (IS_ERR(pxa_usb_phy->base)) {
> > +		dev_err(dev, "failed to remap PHY regs\n");
> > +		return PTR_ERR(pxa_usb_phy->base);
> > +	}
> > +
> > +	pxa_usb_phy->phy = devm_phy_create(dev, NULL,
> > &pxa_usb_phy_ops);
> > +	if (IS_ERR(pxa_usb_phy->phy)) {
> > +		dev_err(dev, "failed to create PHY\n");
> > +		return PTR_ERR(pxa_usb_phy->phy);
> > +	}
> > +
> > +	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
> > +	provider = devm_of_phy_provider_register(dev,
> > of_phy_simple_xlate);
> > +	if (IS_ERR(provider)) {
> > +		dev_err(dev, "failed to register PHY provider\n");
> > +		return PTR_ERR(provider);
> > +	}
> > +
> > +	if (!dev->of_node) {
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-
> > u2oehci");
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
> > +	}
> > +
> > +	dev_info(dev, "Marvell PXA USB PHY");
> > +	return 0;
> > +}
> > +
> > +static struct platform_driver pxa_usb_phy_driver = {
> > +	.probe		= pxa_usb_phy_probe,
> > +	.driver		= {
> > +		.name	= "pxa-usb-phy",
> > +		.of_match_table = pxa_usb_phy_of_match,
> > +	},
> > +};
> > +module_platform_driver(pxa_usb_phy_driver);
> > +
> > +MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
> > +MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
> > +MODULE_LICENSE("GPL v2");
> >

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

* [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-07 18:47       ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-10-07 18:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> 
> On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > so
> > that in can be instantiated from a DT.
> > 
> > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> 
> Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> 
> If this has to be merged via linux-phy tree, please let me know.

Yes, either linux-phy or the usb tree.

The EHCI patches have already been pulled into the usb tree, presumably
because they got an Ack from Alan Stern. That includes "USB: EHCI:
ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
the patches can go via the same tree?

I haven't submitted a patchset that would have dependencies spanning
across different subsystems before. I don't know what's usually done in
such cases. Advice welcome.

Greg?

> Thanks
> Kishon

Thank you
Lubo

> 
> > ---
> >  drivers/phy/marvell/Kconfig       |  11 +
> >  drivers/phy/marvell/Makefile      |   1 +
> >  drivers/phy/marvell/phy-pxa-usb.c | 345
> > ++++++++++++++++++++++++++++++
> >  3 files changed, 357 insertions(+)
> >  create mode 100644 drivers/phy/marvell/phy-pxa-usb.c
> > 
> > diff --git a/drivers/phy/marvell/Kconfig
> > b/drivers/phy/marvell/Kconfig
> > index 68e321225400..6fb4b56e4c14 100644
> > --- a/drivers/phy/marvell/Kconfig
> > +++ b/drivers/phy/marvell/Kconfig
> > @@ -59,3 +59,14 @@ config PHY_PXA_28NM_USB2
> >  	  The PHY driver will be used by Marvell udc/ehci/otg driver.
> >  
> >  	  To compile this driver as a module, choose M here.
> > +
> > +config PHY_PXA_USB
> > +	tristate "Marvell PXA USB PHY Driver"
> > +	depends on ARCH_PXA || ARCH_MMP
> > +	select GENERIC_PHY
> > +	help
> > +	  Enable this to support Marvell PXA USB 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.
> > diff --git a/drivers/phy/marvell/Makefile
> > b/drivers/phy/marvell/Makefile
> > index 5c3ec5d10e0d..3975b144f8ec 100644
> > --- a/drivers/phy/marvell/Makefile
> > +++ b/drivers/phy/marvell/Makefile
> > @@ -6,3 +6,4 @@ obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY)	+= phy-
> > mvebu-cp110-comphy.o
> >  obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
> >  obj-$(CONFIG_PHY_PXA_28NM_HSIC)		+= phy-pxa-28nm-hsic.o
> >  obj-$(CONFIG_PHY_PXA_28NM_USB2)		+= phy-pxa-28nm-usb2.o
> > +obj-$(CONFIG_PHY_PXA_USB)		+= phy-pxa-usb.o
> > diff --git a/drivers/phy/marvell/phy-pxa-usb.c
> > b/drivers/phy/marvell/phy-pxa-usb.c
> > new file mode 100644
> > index 000000000000..87ff7550b912
> > --- /dev/null
> > +++ b/drivers/phy/marvell/phy-pxa-usb.c
> > @@ -0,0 +1,345 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2011 Marvell International Ltd. All rights
> > reserved.
> > + * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
> > + */
> > +
> > +#include <dt-bindings/phy/phy.h>
> > +#include <linux/clk.h>
> > +#include <linux/delay.h>
> > +#include <linux/io.h>
> > +#include <linux/module.h>
> > +#include <linux/of_address.h>
> > +#include <linux/phy/phy.h>
> > +#include <linux/platform_device.h>
> > +
> > +/* phy regs */
> > +#define UTMI_REVISION		0x0
> > +#define UTMI_CTRL		0x4
> > +#define UTMI_PLL		0x8
> > +#define UTMI_TX			0xc
> > +#define UTMI_RX			0x10
> > +#define UTMI_IVREF		0x14
> > +#define UTMI_T0			0x18
> > +#define UTMI_T1			0x1c
> > +#define UTMI_T2			0x20
> > +#define UTMI_T3			0x24
> > +#define UTMI_T4			0x28
> > +#define UTMI_T5			0x2c
> > +#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_SHIFT		28
> > +#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			27
> > +#define UTMI_PLL_PLLVDD18_MASK			(0x3 << 27)
> > +
> > +#define UTMI_PLL_PLLVDD12_SHIFT			25
> > +#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_SHIFT			15
> > +#define UTMI_PLL_KVCO_MASK                      (0x7 << 15)
> > +
> > +#define UTMI_PLL_ICP_SHIFT			12
> > +#define UTMI_PLL_ICP_MASK                       (0x7 << 12)
> > +
> > +#define UTMI_PLL_FBDIV_SHIFT                    4
> > +#define UTMI_PLL_FBDIV_MASK                     (0xFF << 4)
> > +
> > +#define UTMI_PLL_REFDIV_SHIFT                   0
> > +#define UTMI_PLL_REFDIV_MASK                    (0xF << 0)
> > +
> > +/* For UTMI_TX Register */
> > +#define UTMI_TX_REG_EXT_FS_RCAL_SHIFT		27
> > +#define UTMI_TX_REG_EXT_FS_RCAL_MASK		(0xf << 27)
> > +
> > +#define UTMI_TX_REG_EXT_FS_RCAL_EN_SHIFT	26
> > +#define UTMI_TX_REG_EXT_FS_RCAL_EN_MASK		(0x1 << 26)
> > +
> > +#define UTMI_TX_TXVDD12_SHIFT                   22
> > +#define UTMI_TX_TXVDD12_MASK                    (0x3 << 22)
> > +
> > +#define UTMI_TX_CK60_PHSEL_SHIFT                17
> > +#define UTMI_TX_CK60_PHSEL_MASK                 (0xf << 17)
> > +
> > +#define UTMI_TX_IMPCAL_VTH_SHIFT                14
> > +#define UTMI_TX_IMPCAL_VTH_MASK                 (0x7 << 14)
> > +
> > +#define REG_RCAL_START                          (0x1 << 12)
> > +
> > +#define UTMI_TX_LOW_VDD_EN_SHIFT                11
> > +
> > +#define UTMI_TX_AMP_SHIFT			0
> > +#define UTMI_TX_AMP_MASK			(0x7 << 0)
> > +
> > +/* For UTMI_RX Register */
> > +#define UTMI_REG_SQ_LENGTH_SHIFT                15
> > +#define UTMI_REG_SQ_LENGTH_MASK                 (0x3 << 15)
> > +
> > +#define UTMI_RX_SQ_THRESH_SHIFT                 4
> > +#define UTMI_RX_SQ_THRESH_MASK                  (0xf << 4)
> > +
> > +#define UTMI_OTG_ADDON_OTG_ON			(1 << 0)
> > +
> > +enum pxa_usb_phy_version {
> > +	PXA_USB_PHY_MMP2,
> > +	PXA_USB_PHY_PXA910,
> > +	PXA_USB_PHY_PXA168,
> > +};
> > +
> > +struct pxa_usb_phy {
> > +	struct phy *phy;
> > +	void __iomem *base;
> > +	enum pxa_usb_phy_version version;
> > +};
> > +
> > +/*****************************************************************
> > ************
> > + * The registers read/write routines
> > +
> > *******************************************************************
> > **********/
> > +
> > +static unsigned int u2o_get(void __iomem *base, unsigned int
> > offset)
> > +{
> > +	return readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_set(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	u32 reg;
> > +
> > +	reg = readl_relaxed(base + offset);
> > +	reg |= value;
> > +	writel_relaxed(reg, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_clear(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	u32 reg;
> > +
> > +	reg = readl_relaxed(base + offset);
> > +	reg &= ~value;
> > +	writel_relaxed(reg, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static void u2o_write(void __iomem *base, unsigned int offset,
> > +		unsigned int value)
> > +{
> > +	writel_relaxed(value, base + offset);
> > +	readl_relaxed(base + offset);
> > +}
> > +
> > +static int pxa_usb_phy_init(struct phy *phy)
> > +{
> > +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> > +	void __iomem *base = pxa_usb_phy->base;
> > +	int loops;
> > +
> > +	dev_info(&phy->dev, "initializing Marvell PXA USB PHY");
> > +
> > +	/* Initialize the USB PHY power */
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA910) {
> > +		u2o_set(base, UTMI_CTRL,
> > (1<<UTMI_CTRL_INPKT_DELAY_SOF_SHIFT)
> > +			| (1<<UTMI_CTRL_PU_REF_SHIFT));
> > +	}
> > +
> > +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> > +	u2o_set(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> > +
> > +	/* UTMI_PLL settings */
> > +	u2o_clear(base, UTMI_PLL, UTMI_PLL_PLLVDD18_MASK
> > +		| UTMI_PLL_PLLVDD12_MASK | UTMI_PLL_PLLCALI12_MASK
> > +		| UTMI_PLL_FBDIV_MASK | UTMI_PLL_REFDIV_MASK
> > +		| UTMI_PLL_ICP_MASK | UTMI_PLL_KVCO_MASK);
> > +
> > +	u2o_set(base, UTMI_PLL, 0xee<<UTMI_PLL_FBDIV_SHIFT
> > +		| 0xb<<UTMI_PLL_REFDIV_SHIFT |
> > 3<<UTMI_PLL_PLLVDD18_SHIFT
> > +		| 3<<UTMI_PLL_PLLVDD12_SHIFT |
> > 3<<UTMI_PLL_PLLCALI12_SHIFT
> > +		| 1<<UTMI_PLL_ICP_SHIFT | 3<<UTMI_PLL_KVCO_SHIFT);
> > +
> > +	/* UTMI_TX */
> > +	u2o_clear(base, UTMI_TX, UTMI_TX_REG_EXT_FS_RCAL_EN_MASK
> > +		| UTMI_TX_TXVDD12_MASK | UTMI_TX_CK60_PHSEL_MASK
> > +		| UTMI_TX_IMPCAL_VTH_MASK |
> > UTMI_TX_REG_EXT_FS_RCAL_MASK
> > +		| UTMI_TX_AMP_MASK);
> > +	u2o_set(base, UTMI_TX, 3<<UTMI_TX_TXVDD12_SHIFT
> > +		| 4<<UTMI_TX_CK60_PHSEL_SHIFT |
> > 4<<UTMI_TX_IMPCAL_VTH_SHIFT
> > +		| 8<<UTMI_TX_REG_EXT_FS_RCAL_SHIFT |
> > 3<<UTMI_TX_AMP_SHIFT);
> > +
> > +	/* UTMI_RX */
> > +	u2o_clear(base, UTMI_RX, UTMI_RX_SQ_THRESH_MASK
> > +		| UTMI_REG_SQ_LENGTH_MASK);
> > +	u2o_set(base, UTMI_RX, 7<<UTMI_RX_SQ_THRESH_SHIFT
> > +		| 2<<UTMI_REG_SQ_LENGTH_SHIFT);
> > +
> > +	/* UTMI_IVREF */
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> > +		/*
> > +		 * fixing Microsoft Altair board interface with NEC hub
> > issue -
> > +		 * Set UTMI_IVREF from 0x4a3 to 0x4bf
> > +		 */
> > +		u2o_write(base, UTMI_IVREF, 0x4bf);
> > +	}
> > +
> > +	/* toggle VCOCAL_START bit of UTMI_PLL */
> > +	udelay(200);
> > +	u2o_set(base, UTMI_PLL, VCOCAL_START);
> > +	udelay(40);
> > +	u2o_clear(base, UTMI_PLL, VCOCAL_START);
> > +
> > +	/* toggle REG_RCAL_START bit of UTMI_TX */
> > +	udelay(400);
> > +	u2o_set(base, UTMI_TX, REG_RCAL_START);
> > +	udelay(40);
> > +	u2o_clear(base, UTMI_TX, REG_RCAL_START);
> > +	udelay(400);
> > +
> > +	/* Make sure PHY PLL is ready */
> > +	loops = 0;
> > +	while ((u2o_get(base, UTMI_PLL) & PLL_READY) == 0) {
> > +		mdelay(1);
> > +		loops++;
> > +		if (loops > 100) {
> > +			dev_warn(&phy->dev, "calibrate timeout,
> > UTMI_PLL %x\n",
> > +						u2o_get(base,
> > UTMI_PLL));
> > +			break;
> > +		}
> > +	}
> > +
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168) {
> > +		u2o_set(base, UTMI_RESERVE, 1 << 5);
> > +		/* Turn on UTMI PHY OTG extension */
> > +		u2o_write(base, UTMI_OTG_ADDON, 1);
> > +	}
> > +
> > +	return 0;
> > +
> > +}
> > +
> > +static int pxa_usb_phy_exit(struct phy *phy)
> > +{
> > +	struct pxa_usb_phy *pxa_usb_phy = phy_get_drvdata(phy);
> > +	void __iomem *base = pxa_usb_phy->base;
> > +
> > +	dev_info(&phy->dev, "deinitializing Marvell PXA USB PHY");
> > +
> > +	if (pxa_usb_phy->version == PXA_USB_PHY_PXA168)
> > +		u2o_clear(base, UTMI_OTG_ADDON, UTMI_OTG_ADDON_OTG_ON);
> > +
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_RXBUF_PDWN);
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_TXBUF_PDWN);
> > +	u2o_clear(base, UTMI_CTRL, UTMI_CTRL_USB_CLK_EN);
> > +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PWR_UP_SHIFT);
> > +	u2o_clear(base, UTMI_CTRL, 1<<UTMI_CTRL_PLL_PWR_UP_SHIFT);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct phy_ops pxa_usb_phy_ops = {
> > +	.init	= pxa_usb_phy_init,
> > +	.exit	= pxa_usb_phy_exit,
> > +	.owner	= THIS_MODULE,
> > +};
> > +
> > +static const struct of_device_id pxa_usb_phy_of_match[] = {
> > +	{
> > +		.compatible = "marvell,mmp2-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_MMP2,
> > +	}, {
> > +		.compatible = "marvell,pxa910-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_PXA910,
> > +	}, {
> > +		.compatible = "marvell,pxa168-usb-phy",
> > +		.data = (void *)PXA_USB_PHY_PXA168,
> > +	},
> > +	{ },
> > +};
> > +MODULE_DEVICE_TABLE(of, pxa_usb_phy_of_match);
> > +
> > +static int pxa_usb_phy_probe(struct platform_device *pdev)
> > +{
> > +	struct device *dev = &pdev->dev;
> > +	struct resource *resource;
> > +	struct pxa_usb_phy *pxa_usb_phy;
> > +	struct phy_provider *provider;
> > +	const struct of_device_id *of_id;
> > +
> > +	pxa_usb_phy = devm_kzalloc(dev, sizeof(struct pxa_usb_phy),
> > GFP_KERNEL);
> > +	if (!pxa_usb_phy)
> > +		return -ENOMEM;
> > +
> > +	of_id = of_match_node(pxa_usb_phy_of_match, dev->of_node);
> > +	if (of_id)
> > +		pxa_usb_phy->version = (enum pxa_usb_phy_version)of_id-
> > >data;
> > +	else
> > +		pxa_usb_phy->version = PXA_USB_PHY_MMP2;
> > +
> > +	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	pxa_usb_phy->base = devm_ioremap_resource(dev, resource);
> > +	if (IS_ERR(pxa_usb_phy->base)) {
> > +		dev_err(dev, "failed to remap PHY regs\n");
> > +		return PTR_ERR(pxa_usb_phy->base);
> > +	}
> > +
> > +	pxa_usb_phy->phy = devm_phy_create(dev, NULL,
> > &pxa_usb_phy_ops);
> > +	if (IS_ERR(pxa_usb_phy->phy)) {
> > +		dev_err(dev, "failed to create PHY\n");
> > +		return PTR_ERR(pxa_usb_phy->phy);
> > +	}
> > +
> > +	phy_set_drvdata(pxa_usb_phy->phy, pxa_usb_phy);
> > +	provider = devm_of_phy_provider_register(dev,
> > of_phy_simple_xlate);
> > +	if (IS_ERR(provider)) {
> > +		dev_err(dev, "failed to register PHY provider\n");
> > +		return PTR_ERR(provider);
> > +	}
> > +
> > +	if (!dev->of_node) {
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-udc");
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "pxa-
> > u2oehci");
> > +		phy_create_lookup(pxa_usb_phy->phy, "usb", "mv-otg");
> > +	}
> > +
> > +	dev_info(dev, "Marvell PXA USB PHY");
> > +	return 0;
> > +}
> > +
> > +static struct platform_driver pxa_usb_phy_driver = {
> > +	.probe		= pxa_usb_phy_probe,
> > +	.driver		= {
> > +		.name	= "pxa-usb-phy",
> > +		.of_match_table = pxa_usb_phy_of_match,
> > +	},
> > +};
> > +module_platform_driver(pxa_usb_phy_driver);
> > +
> > +MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
> > +MODULE_DESCRIPTION("Marvell PXA USB PHY Driver");
> > +MODULE_LICENSE("GPL v2");
> > 

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

* Re: [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-08 13:21         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 85+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-08 13:21 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: Kishon Vijay Abraham I, linux-kernel, linux-usb,
	linux-arm-kernel, Rob Herring, Mark Rutland, Eric Miao,
	Haojian Zhuang, Alan Stern

On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > 
> > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > so
> > > that in can be instantiated from a DT.
> > > 
> > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > 
> > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > 
> > If this has to be merged via linux-phy tree, please let me know.
> 
> Yes, either linux-phy or the usb tree.
> 
> The EHCI patches have already been pulled into the usb tree, presumably
> because they got an Ack from Alan Stern. That includes "USB: EHCI:
> ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> the patches can go via the same tree?
> 
> I haven't submitted a patchset that would have dependencies spanning
> across different subsystems before. I don't know what's usually done in
> such cases. Advice welcome.
> 
> Greg?

You can either send them through the same tree, or wait a release cycle
and get the rest in through a different one.  As I usually take the phy
tree into the USB tree for issues like this, I can take them all if you
get the phy maintainer to ack them.

thanks,

greg k-h

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

* [01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-08 13:21         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 85+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-08 13:21 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: Kishon Vijay Abraham I, linux-kernel, linux-usb,
	linux-arm-kernel, Rob Herring, Mark Rutland, Eric Miao,
	Haojian Zhuang, Alan Stern

On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > 
> > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > so
> > > that in can be instantiated from a DT.
> > > 
> > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > 
> > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > 
> > If this has to be merged via linux-phy tree, please let me know.
> 
> Yes, either linux-phy or the usb tree.
> 
> The EHCI patches have already been pulled into the usb tree, presumably
> because they got an Ack from Alan Stern. That includes "USB: EHCI:
> ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> the patches can go via the same tree?
> 
> I haven't submitted a patchset that would have dependencies spanning
> across different subsystems before. I don't know what's usually done in
> such cases. Advice welcome.
> 
> Greg?

You can either send them through the same tree, or wait a release cycle
and get the rest in through a different one.  As I usually take the phy
tree into the USB tree for issues like this, I can take them all if you
get the phy maintainer to ack them.

thanks,

greg k-h

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

* [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-08 13:21         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 85+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-08 13:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > 
> > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > so
> > > that in can be instantiated from a DT.
> > > 
> > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > 
> > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > 
> > If this has to be merged via linux-phy tree, please let me know.
> 
> Yes, either linux-phy or the usb tree.
> 
> The EHCI patches have already been pulled into the usb tree, presumably
> because they got an Ack from Alan Stern. That includes "USB: EHCI:
> ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> the patches can go via the same tree?
> 
> I haven't submitted a patchset that would have dependencies spanning
> across different subsystems before. I don't know what's usually done in
> such cases. Advice welcome.
> 
> Greg?

You can either send them through the same tree, or wait a release cycle
and get the rest in through a different one.  As I usually take the phy
tree into the USB tree for issues like this, I can take them all if you
get the phy maintainer to ack them.

thanks,

greg k-h

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

* Re: [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-09 14:51           ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-10-09 14:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Kishon Vijay Abraham I, linux-kernel, linux-usb,
	linux-arm-kernel, Rob Herring, Mark Rutland, Eric Miao,
	Haojian Zhuang, Alan Stern

On Mon, 2018-10-08 at 15:21 +0200, Greg Kroah-Hartman wrote:
> On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> > On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > > so
> > > > that in can be instantiated from a DT.
> > > > 
> > > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > > 
> > > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > > 
> > > If this has to be merged via linux-phy tree, please let me know.
> > 
> > Yes, either linux-phy or the usb tree.
> > 
> > The EHCI patches have already been pulled into the usb tree, presumably
> > because they got an Ack from Alan Stern. That includes "USB: EHCI:
> > ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> > the patches can go via the same tree?
> > 
> > I haven't submitted a patchset that would have dependencies spanning
> > across different subsystems before. I don't know what's usually done in
> > such cases. Advice welcome.
> > 
> > Greg?
> 
> You can either send them through the same tree, or wait a release cycle
> and get the rest in through a different one.  As I usually take the phy
> tree into the USB tree for issues like this, I can take them all if you
> get the phy maintainer to ack them.

I believe that would be Kishton, who acked this one (see above). Please
add it ("PATCH 01/14] phy: phy-pxa-usb: add a new driver") to the usb
tree than.

The rest is DT bindings and MMP2 platform changes (DT, board files and
removal of dead code) which are not strictly dependent on this and
don't need to go through phy or usb trees. I still need to get someone
to review them.

Thank you
Lubo

> 
> thanks,
> 
> greg k-h


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

* [01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-09 14:51           ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-10-09 14:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Kishon Vijay Abraham I, linux-kernel, linux-usb,
	linux-arm-kernel, Rob Herring, Mark Rutland, Eric Miao,
	Haojian Zhuang, Alan Stern

On Mon, 2018-10-08 at 15:21 +0200, Greg Kroah-Hartman wrote:
> On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> > On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > > so
> > > > that in can be instantiated from a DT.
> > > > 
> > > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > > 
> > > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > > 
> > > If this has to be merged via linux-phy tree, please let me know.
> > 
> > Yes, either linux-phy or the usb tree.
> > 
> > The EHCI patches have already been pulled into the usb tree, presumably
> > because they got an Ack from Alan Stern. That includes "USB: EHCI:
> > ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> > the patches can go via the same tree?
> > 
> > I haven't submitted a patchset that would have dependencies spanning
> > across different subsystems before. I don't know what's usually done in
> > such cases. Advice welcome.
> > 
> > Greg?
> 
> You can either send them through the same tree, or wait a release cycle
> and get the rest in through a different one.  As I usually take the phy
> tree into the USB tree for issues like this, I can take them all if you
> get the phy maintainer to ack them.

I believe that would be Kishton, who acked this one (see above). Please
add it ("PATCH 01/14] phy: phy-pxa-usb: add a new driver") to the usb
tree than.

The rest is DT bindings and MMP2 platform changes (DT, board files and
removal of dead code) which are not strictly dependent on this and
don't need to go through phy or usb trees. I still need to get someone
to review them.

Thank you
Lubo

> 
> thanks,
> 
> greg k-h

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

* [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-09 14:51           ` Lubomir Rintel
  0 siblings, 0 replies; 85+ messages in thread
From: Lubomir Rintel @ 2018-10-09 14:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2018-10-08 at 15:21 +0200, Greg Kroah-Hartman wrote:
> On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> > On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > > so
> > > > that in can be instantiated from a DT.
> > > > 
> > > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > > 
> > > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > > 
> > > If this has to be merged via linux-phy tree, please let me know.
> > 
> > Yes, either linux-phy or the usb tree.
> > 
> > The EHCI patches have already been pulled into the usb tree, presumably
> > because they got an Ack from Alan Stern. That includes "USB: EHCI:
> > ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> > the patches can go via the same tree?
> > 
> > I haven't submitted a patchset that would have dependencies spanning
> > across different subsystems before. I don't know what's usually done in
> > such cases. Advice welcome.
> > 
> > Greg?
> 
> You can either send them through the same tree, or wait a release cycle
> and get the rest in through a different one.  As I usually take the phy
> tree into the USB tree for issues like this, I can take them all if you
> get the phy maintainer to ack them.

I believe that would be Kishton, who acked this one (see above). Please
add it ("PATCH 01/14] phy: phy-pxa-usb: add a new driver") to the usb
tree than.

The rest is DT bindings and MMP2 platform changes (DT, board files and
removal of dead code) which are not strictly dependent on this and
don't need to go through phy or usb trees. I still need to get someone
to review them.

Thank you
Lubo

> 
> thanks,
> 
> greg k-h

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

* Re: [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-09 14:57             ` Greg Kroah-Hartman
  0 siblings, 0 replies; 85+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-09 14:57 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: Kishon Vijay Abraham I, linux-kernel, linux-usb,
	linux-arm-kernel, Rob Herring, Mark Rutland, Eric Miao,
	Haojian Zhuang, Alan Stern

On Tue, Oct 09, 2018 at 04:51:03PM +0200, Lubomir Rintel wrote:
> On Mon, 2018-10-08 at 15:21 +0200, Greg Kroah-Hartman wrote:
> > On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> > > On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > > > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > > > so
> > > > > that in can be instantiated from a DT.
> > > > > 
> > > > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > > > 
> > > > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > > > 
> > > > If this has to be merged via linux-phy tree, please let me know.
> > > 
> > > Yes, either linux-phy or the usb tree.
> > > 
> > > The EHCI patches have already been pulled into the usb tree, presumably
> > > because they got an Ack from Alan Stern. That includes "USB: EHCI:
> > > ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> > > the patches can go via the same tree?
> > > 
> > > I haven't submitted a patchset that would have dependencies spanning
> > > across different subsystems before. I don't know what's usually done in
> > > such cases. Advice welcome.
> > > 
> > > Greg?
> > 
> > You can either send them through the same tree, or wait a release cycle
> > and get the rest in through a different one.  As I usually take the phy
> > tree into the USB tree for issues like this, I can take them all if you
> > get the phy maintainer to ack them.
> 
> I believe that would be Kishton, who acked this one (see above). Please
> add it ("PATCH 01/14] phy: phy-pxa-usb: add a new driver") to the usb
> tree than.
> 
> The rest is DT bindings and MMP2 platform changes (DT, board files and
> removal of dead code) which are not strictly dependent on this and
> don't need to go through phy or usb trees. I still need to get someone
> to review them.

When you get that done, please resend.

thanks,

greg k-h

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

* [01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-09 14:57             ` Greg Kroah-Hartman
  0 siblings, 0 replies; 85+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-09 14:57 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: Kishon Vijay Abraham I, linux-kernel, linux-usb,
	linux-arm-kernel, Rob Herring, Mark Rutland, Eric Miao,
	Haojian Zhuang, Alan Stern

On Tue, Oct 09, 2018 at 04:51:03PM +0200, Lubomir Rintel wrote:
> On Mon, 2018-10-08 at 15:21 +0200, Greg Kroah-Hartman wrote:
> > On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> > > On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > > > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > > > so
> > > > > that in can be instantiated from a DT.
> > > > > 
> > > > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > > > 
> > > > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > > > 
> > > > If this has to be merged via linux-phy tree, please let me know.
> > > 
> > > Yes, either linux-phy or the usb tree.
> > > 
> > > The EHCI patches have already been pulled into the usb tree, presumably
> > > because they got an Ack from Alan Stern. That includes "USB: EHCI:
> > > ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> > > the patches can go via the same tree?
> > > 
> > > I haven't submitted a patchset that would have dependencies spanning
> > > across different subsystems before. I don't know what's usually done in
> > > such cases. Advice welcome.
> > > 
> > > Greg?
> > 
> > You can either send them through the same tree, or wait a release cycle
> > and get the rest in through a different one.  As I usually take the phy
> > tree into the USB tree for issues like this, I can take them all if you
> > get the phy maintainer to ack them.
> 
> I believe that would be Kishton, who acked this one (see above). Please
> add it ("PATCH 01/14] phy: phy-pxa-usb: add a new driver") to the usb
> tree than.
> 
> The rest is DT bindings and MMP2 platform changes (DT, board files and
> removal of dead code) which are not strictly dependent on this and
> don't need to go through phy or usb trees. I still need to get someone
> to review them.

When you get that done, please resend.

thanks,

greg k-h

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

* [PATCH 01/14] phy: phy-pxa-usb: add a new driver
@ 2018-10-09 14:57             ` Greg Kroah-Hartman
  0 siblings, 0 replies; 85+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-09 14:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 09, 2018 at 04:51:03PM +0200, Lubomir Rintel wrote:
> On Mon, 2018-10-08 at 15:21 +0200, Greg Kroah-Hartman wrote:
> > On Sun, Oct 07, 2018 at 08:47:28PM +0200, Lubomir Rintel wrote:
> > > On Tue, 2018-09-25 at 10:53 +0530, Kishon Vijay Abraham I wrote:
> > > > On Thursday 23 August 2018 02:12 AM, Lubomir Rintel wrote:
> > > > > Turned from arch/arm/mach-mmp/devices.c into a proper PHY driver,
> > > > > so
> > > > > that in can be instantiated from a DT.
> > > > > 
> > > > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > > > 
> > > > Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> > > > 
> > > > If this has to be merged via linux-phy tree, please let me know.
> > > 
> > > Yes, either linux-phy or the usb tree.
> > > 
> > > The EHCI patches have already been pulled into the usb tree, presumably
> > > because they got an Ack from Alan Stern. That includes "USB: EHCI:
> > > ehci-mv: use phy-pxa-usb" that depends on this. Perhaps the  rest of
> > > the patches can go via the same tree?
> > > 
> > > I haven't submitted a patchset that would have dependencies spanning
> > > across different subsystems before. I don't know what's usually done in
> > > such cases. Advice welcome.
> > > 
> > > Greg?
> > 
> > You can either send them through the same tree, or wait a release cycle
> > and get the rest in through a different one.  As I usually take the phy
> > tree into the USB tree for issues like this, I can take them all if you
> > get the phy maintainer to ack them.
> 
> I believe that would be Kishton, who acked this one (see above). Please
> add it ("PATCH 01/14] phy: phy-pxa-usb: add a new driver") to the usb
> tree than.
> 
> The rest is DT bindings and MMP2 platform changes (DT, board files and
> removal of dead code) which are not strictly dependent on this and
> don't need to go through phy or usb trees. I still need to get someone
> to review them.

When you get that done, please resend.

thanks,

greg k-h

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

* Re: [PATCH 12/14] dt-bindings: ehci-mv: add bindings
@ 2018-11-02 20:47     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-02 20:47 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

Hi!

> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  .../devicetree/bindings/usb/ehci-mv.txt       | 23 +++++++++++++++++++
>  1 file changed, 23 insertions(+)
>  create mode 100644
> Documentation/devicetree/bindings/usb/ehci-mv.txt

I see this is pending in -next, but I don't see Rob's Ack anywhere. Is
that expected?

Anyway,

Acked-by: Pavel Machek <pavel@ucw.cz>

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* [12/14] dt-bindings: ehci-mv: add bindings
@ 2018-11-02 20:47     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-02 20:47 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

Hi!

> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  .../devicetree/bindings/usb/ehci-mv.txt       | 23 +++++++++++++++++++
>  1 file changed, 23 insertions(+)
>  create mode 100644
> Documentation/devicetree/bindings/usb/ehci-mv.txt

I see this is pending in -next, but I don't see Rob's Ack anywhere. Is
that expected?

Anyway,

Acked-by: Pavel Machek <pavel@ucw.cz>

									Pavel

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

* [PATCH 12/14] dt-bindings: ehci-mv: add bindings
@ 2018-11-02 20:47     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-02 20:47 UTC (permalink / raw)
  To: linux-arm-kernel

Hi!

> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  .../devicetree/bindings/usb/ehci-mv.txt       | 23 +++++++++++++++++++
>  1 file changed, 23 insertions(+)
>  create mode 100644
> Documentation/devicetree/bindings/usb/ehci-mv.txt

I see this is pending in -next, but I don't see Rob's Ack anywhere. Is
that expected?

Anyway,

Acked-by: Pavel Machek <pavel@ucw.cz>

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181102/bbf6c695/attachment.sig>

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

* Re: [PATCH 02/14] dt-bindings: phy-pxa-usb: add bindings
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

[-- Attachment #1: Type: text/plain, Size: 1446 bytes --]

On Wed 2018-08-22 22:42:55, Lubomir Rintel wrote:
> This is the PHY chip for USB OTG on PXA platforms.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  .../devicetree/bindings/phy/phy-pxa-usb.txt     | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> 
> diff --git a/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> new file mode 100644
> index 000000000000..5b12ab44c9e6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> @@ -0,0 +1,17 @@
> +Marvell PXA USB PHY
> +-------------------
> +
> +Required properties:
> +- compatible: one of: "marvell,mmp2-usb-phy", "marvell,pxa910-usb-phy",
> +	"marvell,pxa168-usb-phy",
> +- #phy-cells: must be 0
> +
> +Example:
> +	usb-phy: usbphy@d4207000 {
> +		compatible = "marvell,mmp2-usb-phy";
> +		reg = <0xd4207000 0x40>;
> +		#phy-cells = <0>;
> +		status = "okay";
> +	};
> +This document explains only the device tree data binding. For general
> +information about PHY subsystem refer to Documentation/phy.txt

Add empty space between last paragraph?

Delete "only" and "data"?

Acked-by: Pavel Machek <pavel@ucw.cz>
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* [02/14] dt-bindings: phy-pxa-usb: add bindings
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

On Wed 2018-08-22 22:42:55, Lubomir Rintel wrote:
> This is the PHY chip for USB OTG on PXA platforms.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  .../devicetree/bindings/phy/phy-pxa-usb.txt     | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> 
> diff --git a/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> new file mode 100644
> index 000000000000..5b12ab44c9e6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> @@ -0,0 +1,17 @@
> +Marvell PXA USB PHY
> +-------------------
> +
> +Required properties:
> +- compatible: one of: "marvell,mmp2-usb-phy", "marvell,pxa910-usb-phy",
> +	"marvell,pxa168-usb-phy",
> +- #phy-cells: must be 0
> +
> +Example:
> +	usb-phy: usbphy@d4207000 {
> +		compatible = "marvell,mmp2-usb-phy";
> +		reg = <0xd4207000 0x40>;
> +		#phy-cells = <0>;
> +		status = "okay";
> +	};
> +This document explains only the device tree data binding. For general
> +information about PHY subsystem refer to Documentation/phy.txt

Add empty space between last paragraph?

Delete "only" and "data"?

Acked-by: Pavel Machek <pavel@ucw.cz>
									Pavel

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

* [PATCH 02/14] dt-bindings: phy-pxa-usb: add bindings
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed 2018-08-22 22:42:55, Lubomir Rintel wrote:
> This is the PHY chip for USB OTG on PXA platforms.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  .../devicetree/bindings/phy/phy-pxa-usb.txt     | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> 
> diff --git a/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> new file mode 100644
> index 000000000000..5b12ab44c9e6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/phy-pxa-usb.txt
> @@ -0,0 +1,17 @@
> +Marvell PXA USB PHY
> +-------------------
> +
> +Required properties:
> +- compatible: one of: "marvell,mmp2-usb-phy", "marvell,pxa910-usb-phy",
> +	"marvell,pxa168-usb-phy",
> +- #phy-cells: must be 0
> +
> +Example:
> +	usb-phy: usbphy at d4207000 {
> +		compatible = "marvell,mmp2-usb-phy";
> +		reg = <0xd4207000 0x40>;
> +		#phy-cells = <0>;
> +		status = "okay";
> +	};
> +This document explains only the device tree data binding. For general
> +information about PHY subsystem refer to Documentation/phy.txt

Add empty space between last paragraph?

Delete "only" and "data"?

Acked-by: Pavel Machek <pavel@ucw.cz>
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181105/1100b3ac/attachment.sig>

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

* Re: [PATCH 05/14] ARM: ttc_dkb: add an instance of pxa-usb-phy
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

[-- Attachment #1: Type: text/plain, Size: 913 bytes --]

On Wed 2018-08-22 22:42:58, Lubomir Rintel wrote:
> This will replace the ttc_usb_pdata.phy_{de,}init()>

">" -> "."?

> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

>  arch/arm/mach-mmp/ttc_dkb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
> index c7897fb2b6da..767dcb23ee1c 100644
> --- a/arch/arm/mach-mmp/ttc_dkb.c
> +++ b/arch/arm/mach-mmp/ttc_dkb.c
> @@ -282,6 +282,10 @@ static void __init ttc_dkb_init(void)
>  				 sizeof(struct pxa_gpio_platform_data));
>  	platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
>  
> +#if IS_ENABLED(CONFIG_PHY_PXA_USB)
> +	platform_device_register(&pxa168_device_usb_phy);
> +#endif


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* [05/14] ARM: ttc_dkb: add an instance of pxa-usb-phy
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

On Wed 2018-08-22 22:42:58, Lubomir Rintel wrote:
> This will replace the ttc_usb_pdata.phy_{de,}init()>

">" -> "."?

> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

>  arch/arm/mach-mmp/ttc_dkb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
> index c7897fb2b6da..767dcb23ee1c 100644
> --- a/arch/arm/mach-mmp/ttc_dkb.c
> +++ b/arch/arm/mach-mmp/ttc_dkb.c
> @@ -282,6 +282,10 @@ static void __init ttc_dkb_init(void)
>  				 sizeof(struct pxa_gpio_platform_data));
>  	platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
>  
> +#if IS_ENABLED(CONFIG_PHY_PXA_USB)
> +	platform_device_register(&pxa168_device_usb_phy);
> +#endif

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

* [PATCH 05/14] ARM: ttc_dkb: add an instance of pxa-usb-phy
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed 2018-08-22 22:42:58, Lubomir Rintel wrote:
> This will replace the ttc_usb_pdata.phy_{de,}init()>

">" -> "."?

> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

>  arch/arm/mach-mmp/ttc_dkb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
> index c7897fb2b6da..767dcb23ee1c 100644
> --- a/arch/arm/mach-mmp/ttc_dkb.c
> +++ b/arch/arm/mach-mmp/ttc_dkb.c
> @@ -282,6 +282,10 @@ static void __init ttc_dkb_init(void)
>  				 sizeof(struct pxa_gpio_platform_data));
>  	platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
>  
> +#if IS_ENABLED(CONFIG_PHY_PXA_USB)
> +	platform_device_register(&pxa168_device_usb_phy);
> +#endif


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181105/a273ff2c/attachment.sig>

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

* Re: [PATCH 06/14] ARM: aspenite: add an instance of pxa-usb-phy
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

[-- Attachment #1: Type: text/plain, Size: 454 bytes --]

On Wed 2018-08-22 22:42:59, Lubomir Rintel wrote:
> This will replace the pxa168_sph_pdata.phy_{de,}init().
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

I'd merge this with the previous patch if it is easy. Your patches are
a bit too small...
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* [06/14] ARM: aspenite: add an instance of pxa-usb-phy
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

On Wed 2018-08-22 22:42:59, Lubomir Rintel wrote:
> This will replace the pxa168_sph_pdata.phy_{de,}init().
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

I'd merge this with the previous patch if it is easy. Your patches are
a bit too small...
									Pavel

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

* [PATCH 06/14] ARM: aspenite: add an instance of pxa-usb-phy
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed 2018-08-22 22:42:59, Lubomir Rintel wrote:
> This will replace the pxa168_sph_pdata.phy_{de,}init().
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

I'd merge this with the previous patch if it is easy. Your patches are
a bit too small...
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181105/a79cf79b/attachment.sig>

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

* Re: [PATCH 09/14] USB: phy-mv-usb: use phy-pxa-usb
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

On Wed 2018-08-22 22:43:02, Lubomir Rintel wrote:
> Use a proper PHY driver, instead of hooks to a board support package.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* [09/14] USB: phy-mv-usb: use phy-pxa-usb
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

On Wed 2018-08-22 22:43:02, Lubomir Rintel wrote:
> Use a proper PHY driver, instead of hooks to a board support package.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

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

* [PATCH 09/14] USB: phy-mv-usb: use phy-pxa-usb
@ 2018-11-05  9:19     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed 2018-08-22 22:43:02, Lubomir Rintel wrote:
> Use a proper PHY driver, instead of hooks to a board support package.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181105/2231767f/attachment.sig>

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

* Re: [PATCH 10/14] USB: gadget: mv-udc: use phy-pxa-usb
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

[-- Attachment #1: Type: text/plain, Size: 4873 bytes --]

On Wed 2018-08-22 22:43:03, Lubomir Rintel wrote:
> Use a proper PHY driver, instead of hooks to a board support package.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

> ---
>  arch/arm/mach-mmp/devices.c          | 11 +-------
>  drivers/usb/gadget/udc/mv_udc.h      |  7 ++++-
>  drivers/usb/gadget/udc/mv_udc_core.c | 38 ++++++++--------------------
>  3 files changed, 17 insertions(+), 39 deletions(-)
> 
> diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
> index eb9b3c34e90a..d925be9f14a9 100644
> --- a/arch/arm/mach-mmp/devices.c
> +++ b/arch/arm/mach-mmp/devices.c
> @@ -263,21 +263,12 @@ struct platform_device pxa168_device_usb_phy = {
>  
>  #if IS_ENABLED(CONFIG_USB_MV_UDC)
>  struct resource pxa168_u2o_resources[] = {
> -	/* regbase */
>  	[0] = {
> -		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
> +		.start	= PXA168_U2O_REGBASE,
>  		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
>  		.flags	= IORESOURCE_MEM,
> -		.name	= "capregs",
>  	},
> -	/* phybase */
>  	[1] = {
> -		.start	= PXA168_U2O_PHYBASE,
> -		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
> -		.flags	= IORESOURCE_MEM,
> -		.name	= "phyregs",
> -	},
> -	[2] = {
>  		.start	= IRQ_PXA168_USB1,
>  		.end	= IRQ_PXA168_USB1,
>  		.flags	= IORESOURCE_IRQ,
> diff --git a/drivers/usb/gadget/udc/mv_udc.h b/drivers/usb/gadget/udc/mv_udc.h
> index b3f759c0962c..6f04f432964d 100644
> --- a/drivers/usb/gadget/udc/mv_udc.h
> +++ b/drivers/usb/gadget/udc/mv_udc.h
> @@ -6,6 +6,9 @@
>  #ifndef __MV_UDC_H
>  #define __MV_UDC_H
>  
> +/* registers */
> +#define U2x_CAPREGS_OFFSET	0x100
> +
>  #define VUSBHS_MAX_PORTS	8
>  
>  #define DQH_ALIGNMENT		2048
> @@ -174,9 +177,9 @@ struct mv_udc {
>  	struct platform_device		*dev;
>  	int				irq;
>  
> +	void __iomem                    *base;
>  	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;
> @@ -219,6 +222,8 @@ struct mv_udc {
>  
>  	/* some SOC has mutiple clock sources for USB*/
>  	struct clk      *clk;
> +
> +	struct phy	*phy;
>  };
>  
>  /* endpoint data structure */
> diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
> index 95f52232493b..c701c83d3af5 100644
> --- a/drivers/usb/gadget/udc/mv_udc_core.c
> +++ b/drivers/usb/gadget/udc/mv_udc_core.c
> @@ -1069,14 +1069,11 @@ static int mv_udc_enable_internal(struct mv_udc *udc)
>  	if (retval)
>  		return retval;
>  
> -	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 = 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;
>  
> @@ -1095,8 +1092,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);
> +		phy_exit(udc->phy);
>  		udc_clock_disable(udc);
>  		udc->active = 0;
>  	}
> @@ -2147,30 +2143,16 @@ 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;
>  	}
>  
> -	udc->cap_regs = (struct mv_cap_regs __iomem *)
> -		devm_ioremap(&pdev->dev, r->start, resource_size(r));
> -	if (udc->cap_regs == NULL) {
> -		dev_err(&pdev->dev, "failed to map I/O memory\n");
> -		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->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
>  
> -	udc->phy_regs = devm_ioremap(&pdev->dev, 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->cap_regs =
> +		(void __iomem *) ((unsigned long)udc->base + U2x_CAPREGS_OFFSET);
>  
>  	/* we will acces controller register, so enable the clk */
>  	retval = mv_udc_enable_internal(udc);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* [10/14] USB: gadget: mv-udc: use phy-pxa-usb
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

On Wed 2018-08-22 22:43:03, Lubomir Rintel wrote:
> Use a proper PHY driver, instead of hooks to a board support package.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

> ---
>  arch/arm/mach-mmp/devices.c          | 11 +-------
>  drivers/usb/gadget/udc/mv_udc.h      |  7 ++++-
>  drivers/usb/gadget/udc/mv_udc_core.c | 38 ++++++++--------------------
>  3 files changed, 17 insertions(+), 39 deletions(-)
> 
> diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
> index eb9b3c34e90a..d925be9f14a9 100644
> --- a/arch/arm/mach-mmp/devices.c
> +++ b/arch/arm/mach-mmp/devices.c
> @@ -263,21 +263,12 @@ struct platform_device pxa168_device_usb_phy = {
>  
>  #if IS_ENABLED(CONFIG_USB_MV_UDC)
>  struct resource pxa168_u2o_resources[] = {
> -	/* regbase */
>  	[0] = {
> -		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
> +		.start	= PXA168_U2O_REGBASE,
>  		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
>  		.flags	= IORESOURCE_MEM,
> -		.name	= "capregs",
>  	},
> -	/* phybase */
>  	[1] = {
> -		.start	= PXA168_U2O_PHYBASE,
> -		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
> -		.flags	= IORESOURCE_MEM,
> -		.name	= "phyregs",
> -	},
> -	[2] = {
>  		.start	= IRQ_PXA168_USB1,
>  		.end	= IRQ_PXA168_USB1,
>  		.flags	= IORESOURCE_IRQ,
> diff --git a/drivers/usb/gadget/udc/mv_udc.h b/drivers/usb/gadget/udc/mv_udc.h
> index b3f759c0962c..6f04f432964d 100644
> --- a/drivers/usb/gadget/udc/mv_udc.h
> +++ b/drivers/usb/gadget/udc/mv_udc.h
> @@ -6,6 +6,9 @@
>  #ifndef __MV_UDC_H
>  #define __MV_UDC_H
>  
> +/* registers */
> +#define U2x_CAPREGS_OFFSET	0x100
> +
>  #define VUSBHS_MAX_PORTS	8
>  
>  #define DQH_ALIGNMENT		2048
> @@ -174,9 +177,9 @@ struct mv_udc {
>  	struct platform_device		*dev;
>  	int				irq;
>  
> +	void __iomem                    *base;
>  	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;
> @@ -219,6 +222,8 @@ struct mv_udc {
>  
>  	/* some SOC has mutiple clock sources for USB*/
>  	struct clk      *clk;
> +
> +	struct phy	*phy;
>  };
>  
>  /* endpoint data structure */
> diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
> index 95f52232493b..c701c83d3af5 100644
> --- a/drivers/usb/gadget/udc/mv_udc_core.c
> +++ b/drivers/usb/gadget/udc/mv_udc_core.c
> @@ -1069,14 +1069,11 @@ static int mv_udc_enable_internal(struct mv_udc *udc)
>  	if (retval)
>  		return retval;
>  
> -	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 = 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;
>  
> @@ -1095,8 +1092,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);
> +		phy_exit(udc->phy);
>  		udc_clock_disable(udc);
>  		udc->active = 0;
>  	}
> @@ -2147,30 +2143,16 @@ 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;
>  	}
>  
> -	udc->cap_regs = (struct mv_cap_regs __iomem *)
> -		devm_ioremap(&pdev->dev, r->start, resource_size(r));
> -	if (udc->cap_regs == NULL) {
> -		dev_err(&pdev->dev, "failed to map I/O memory\n");
> -		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->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
>  
> -	udc->phy_regs = devm_ioremap(&pdev->dev, 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->cap_regs =
> +		(void __iomem *) ((unsigned long)udc->base + U2x_CAPREGS_OFFSET);
>  
>  	/* we will acces controller register, so enable the clk */
>  	retval = mv_udc_enable_internal(udc);

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

* [PATCH 10/14] USB: gadget: mv-udc: use phy-pxa-usb
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed 2018-08-22 22:43:03, Lubomir Rintel wrote:
> Use a proper PHY driver, instead of hooks to a board support package.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

> ---
>  arch/arm/mach-mmp/devices.c          | 11 +-------
>  drivers/usb/gadget/udc/mv_udc.h      |  7 ++++-
>  drivers/usb/gadget/udc/mv_udc_core.c | 38 ++++++++--------------------
>  3 files changed, 17 insertions(+), 39 deletions(-)
> 
> diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
> index eb9b3c34e90a..d925be9f14a9 100644
> --- a/arch/arm/mach-mmp/devices.c
> +++ b/arch/arm/mach-mmp/devices.c
> @@ -263,21 +263,12 @@ struct platform_device pxa168_device_usb_phy = {
>  
>  #if IS_ENABLED(CONFIG_USB_MV_UDC)
>  struct resource pxa168_u2o_resources[] = {
> -	/* regbase */
>  	[0] = {
> -		.start	= PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET,
> +		.start	= PXA168_U2O_REGBASE,
>  		.end	= PXA168_U2O_REGBASE + USB_REG_RANGE,
>  		.flags	= IORESOURCE_MEM,
> -		.name	= "capregs",
>  	},
> -	/* phybase */
>  	[1] = {
> -		.start	= PXA168_U2O_PHYBASE,
> -		.end	= PXA168_U2O_PHYBASE + USB_PHY_RANGE,
> -		.flags	= IORESOURCE_MEM,
> -		.name	= "phyregs",
> -	},
> -	[2] = {
>  		.start	= IRQ_PXA168_USB1,
>  		.end	= IRQ_PXA168_USB1,
>  		.flags	= IORESOURCE_IRQ,
> diff --git a/drivers/usb/gadget/udc/mv_udc.h b/drivers/usb/gadget/udc/mv_udc.h
> index b3f759c0962c..6f04f432964d 100644
> --- a/drivers/usb/gadget/udc/mv_udc.h
> +++ b/drivers/usb/gadget/udc/mv_udc.h
> @@ -6,6 +6,9 @@
>  #ifndef __MV_UDC_H
>  #define __MV_UDC_H
>  
> +/* registers */
> +#define U2x_CAPREGS_OFFSET	0x100
> +
>  #define VUSBHS_MAX_PORTS	8
>  
>  #define DQH_ALIGNMENT		2048
> @@ -174,9 +177,9 @@ struct mv_udc {
>  	struct platform_device		*dev;
>  	int				irq;
>  
> +	void __iomem                    *base;
>  	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;
> @@ -219,6 +222,8 @@ struct mv_udc {
>  
>  	/* some SOC has mutiple clock sources for USB*/
>  	struct clk      *clk;
> +
> +	struct phy	*phy;
>  };
>  
>  /* endpoint data structure */
> diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
> index 95f52232493b..c701c83d3af5 100644
> --- a/drivers/usb/gadget/udc/mv_udc_core.c
> +++ b/drivers/usb/gadget/udc/mv_udc_core.c
> @@ -1069,14 +1069,11 @@ static int mv_udc_enable_internal(struct mv_udc *udc)
>  	if (retval)
>  		return retval;
>  
> -	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 = 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;
>  
> @@ -1095,8 +1092,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);
> +		phy_exit(udc->phy);
>  		udc_clock_disable(udc);
>  		udc->active = 0;
>  	}
> @@ -2147,30 +2143,16 @@ 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;
>  	}
>  
> -	udc->cap_regs = (struct mv_cap_regs __iomem *)
> -		devm_ioremap(&pdev->dev, r->start, resource_size(r));
> -	if (udc->cap_regs == NULL) {
> -		dev_err(&pdev->dev, "failed to map I/O memory\n");
> -		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->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
>  
> -	udc->phy_regs = devm_ioremap(&pdev->dev, 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->cap_regs =
> +		(void __iomem *) ((unsigned long)udc->base + U2x_CAPREGS_OFFSET);
>  
>  	/* we will acces controller register, so enable the clk */
>  	retval = mv_udc_enable_internal(udc);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181105/ea64a276/attachment-0001.sig>

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

* Re: [PATCH 13/14] DT: marvell,mmp2: add OTG PHY
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

On Wed 2018-08-22 22:43:06, Lubomir Rintel wrote:
> The USB OTG PHY chip. To be used by the OTG controller.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

>  arch/arm/boot/dts/mmp2.dtsi | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
> index 766bbb8495b6..14a3448f38b9 100644
> --- a/arch/arm/boot/dts/mmp2.dtsi
> +++ b/arch/arm/boot/dts/mmp2.dtsi
> @@ -117,6 +117,13 @@
>  				reg-names = "mux status", "mux mask";
>  				mrvl,intc-nr-irqs = <2>;
>  			};
> +
> +			usb_otg_phy0: usb-otg-phy@d4207000 {
> +				compatible = "marvell,mmp2-usb-phy";
> +				reg = <0xd4207000 0x40>;
> +				#phy-cells = <0>;
> +				status = "disabled";
> +			};
>  		};
>  
>  		apb@d4000000 {	/* APB */

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* [13/14] DT: marvell,mmp2: add OTG PHY
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

On Wed 2018-08-22 22:43:06, Lubomir Rintel wrote:
> The USB OTG PHY chip. To be used by the OTG controller.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

>  arch/arm/boot/dts/mmp2.dtsi | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
> index 766bbb8495b6..14a3448f38b9 100644
> --- a/arch/arm/boot/dts/mmp2.dtsi
> +++ b/arch/arm/boot/dts/mmp2.dtsi
> @@ -117,6 +117,13 @@
>  				reg-names = "mux status", "mux mask";
>  				mrvl,intc-nr-irqs = <2>;
>  			};
> +
> +			usb_otg_phy0: usb-otg-phy@d4207000 {
> +				compatible = "marvell,mmp2-usb-phy";
> +				reg = <0xd4207000 0x40>;
> +				#phy-cells = <0>;
> +				status = "disabled";
> +			};
>  		};
>  
>  		apb@d4000000 {	/* APB */

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

* [PATCH 13/14] DT: marvell,mmp2: add OTG PHY
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed 2018-08-22 22:43:06, Lubomir Rintel wrote:
> The USB OTG PHY chip. To be used by the OTG controller.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Pavel Machek <pavel@ucw.cz>

>  arch/arm/boot/dts/mmp2.dtsi | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
> index 766bbb8495b6..14a3448f38b9 100644
> --- a/arch/arm/boot/dts/mmp2.dtsi
> +++ b/arch/arm/boot/dts/mmp2.dtsi
> @@ -117,6 +117,13 @@
>  				reg-names = "mux status", "mux mask";
>  				mrvl,intc-nr-irqs = <2>;
>  			};
> +
> +			usb_otg_phy0: usb-otg-phy at d4207000 {
> +				compatible = "marvell,mmp2-usb-phy";
> +				reg = <0xd4207000 0x40>;
> +				#phy-cells = <0>;
> +				status = "disabled";
> +			};
>  		};
>  
>  		apb at d4000000 {	/* APB */

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181105/727a271a/attachment.sig>

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

* Re: [PATCH 14/14] DT: marvell,mmp2: add USB OTG host controller
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

On Wed 2018-08-22 22:43:07, Lubomir Rintel wrote:
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  arch/arm/boot/dts/mmp2.dtsi | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Again, I guess this could be merged with the previous patch. Anyway,
it is also good to go as-is.

Acked-by: Pavel Machek <pavel@ucw.cz>

> diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
> index 14a3448f38b9..63d4d5c6fd83 100644
> --- a/arch/arm/boot/dts/mmp2.dtsi
> +++ b/arch/arm/boot/dts/mmp2.dtsi
> @@ -124,6 +124,17 @@
>  				#phy-cells = <0>;
>  				status = "disabled";
>  			};
> +
> +			usb_otg0: usb-otg@d4208000 {
> +				compatible = "marvell,pxau2o-ehci";
> +				reg = <0xd4208000 0x200>;
> +				interrupts = <44>;
> +				clocks = <&soc_clocks MMP2_CLK_USB>;
> +				clock-names = "USBCLK";
> +				phys = <&usb_otg_phy0>;
> +				phy-names = "usb";
> +				status = "disabled";
> +			};
>  		};
>  
>  		apb@d4000000 {	/* APB */

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* [14/14] DT: marvell,mmp2: add USB OTG host controller
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, linux-usb, linux-arm-kernel, Rob Herring,
	Mark Rutland, Greg Kroah-Hartman, Eric Miao, Haojian Zhuang,
	Kishon Vijay Abraham I, Alan Stern

On Wed 2018-08-22 22:43:07, Lubomir Rintel wrote:
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  arch/arm/boot/dts/mmp2.dtsi | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Again, I guess this could be merged with the previous patch. Anyway,
it is also good to go as-is.

Acked-by: Pavel Machek <pavel@ucw.cz>

> diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
> index 14a3448f38b9..63d4d5c6fd83 100644
> --- a/arch/arm/boot/dts/mmp2.dtsi
> +++ b/arch/arm/boot/dts/mmp2.dtsi
> @@ -124,6 +124,17 @@
>  				#phy-cells = <0>;
>  				status = "disabled";
>  			};
> +
> +			usb_otg0: usb-otg@d4208000 {
> +				compatible = "marvell,pxau2o-ehci";
> +				reg = <0xd4208000 0x200>;
> +				interrupts = <44>;
> +				clocks = <&soc_clocks MMP2_CLK_USB>;
> +				clock-names = "USBCLK";
> +				phys = <&usb_otg_phy0>;
> +				phy-names = "usb";
> +				status = "disabled";
> +			};
>  		};
>  
>  		apb@d4000000 {	/* APB */

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

* [PATCH 14/14] DT: marvell,mmp2: add USB OTG host controller
@ 2018-11-05  9:20     ` Pavel Machek
  0 siblings, 0 replies; 85+ messages in thread
From: Pavel Machek @ 2018-11-05  9:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed 2018-08-22 22:43:07, Lubomir Rintel wrote:
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  arch/arm/boot/dts/mmp2.dtsi | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Again, I guess this could be merged with the previous patch. Anyway,
it is also good to go as-is.

Acked-by: Pavel Machek <pavel@ucw.cz>

> diff --git a/arch/arm/boot/dts/mmp2.dtsi b/arch/arm/boot/dts/mmp2.dtsi
> index 14a3448f38b9..63d4d5c6fd83 100644
> --- a/arch/arm/boot/dts/mmp2.dtsi
> +++ b/arch/arm/boot/dts/mmp2.dtsi
> @@ -124,6 +124,17 @@
>  				#phy-cells = <0>;
>  				status = "disabled";
>  			};
> +
> +			usb_otg0: usb-otg at d4208000 {
> +				compatible = "marvell,pxau2o-ehci";
> +				reg = <0xd4208000 0x200>;
> +				interrupts = <44>;
> +				clocks = <&soc_clocks MMP2_CLK_USB>;
> +				clock-names = "USBCLK";
> +				phys = <&usb_otg_phy0>;
> +				phy-names = "usb";
> +				status = "disabled";
> +			};
>  		};
>  
>  		apb at d4000000 {	/* APB */

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181105/72251b82/attachment.sig>

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

end of thread, other threads:[~2018-11-05  9:20 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-22 20:42 [PATCH 00/14] Convert ehci-mv to DT Lubomir Rintel
2018-08-22 20:42 ` Lubomir Rintel
2018-08-22 20:42 ` [PATCH 01/14] phy: phy-pxa-usb: add a new driver Lubomir Rintel
2018-08-22 20:42   ` Lubomir Rintel
2018-08-22 20:42   ` [01/14] " Lubomir Rintel
2018-09-25  5:23   ` [PATCH 01/14] " Kishon Vijay Abraham I
2018-09-25  5:23     ` Kishon Vijay Abraham I
2018-09-25  5:23     ` [01/14] " Kishon Vijay Abraham I
2018-10-07 18:47     ` [PATCH 01/14] " Lubomir Rintel
2018-10-07 18:47       ` Lubomir Rintel
2018-10-07 18:47       ` [01/14] " Lubomir Rintel
2018-10-08 13:21       ` [PATCH 01/14] " Greg Kroah-Hartman
2018-10-08 13:21         ` Greg Kroah-Hartman
2018-10-08 13:21         ` [01/14] " Greg Kroah-Hartman
2018-10-09 14:51         ` [PATCH 01/14] " Lubomir Rintel
2018-10-09 14:51           ` Lubomir Rintel
2018-10-09 14:51           ` [01/14] " Lubomir Rintel
2018-10-09 14:57           ` [PATCH 01/14] " Greg Kroah-Hartman
2018-10-09 14:57             ` Greg Kroah-Hartman
2018-10-09 14:57             ` [01/14] " Greg Kroah-Hartman
2018-08-22 20:42 ` [PATCH 02/14] dt-bindings: phy-pxa-usb: add bindings Lubomir Rintel
2018-08-22 20:42   ` Lubomir Rintel
2018-08-22 20:42   ` [02/14] " Lubomir Rintel
2018-11-05  9:19   ` [PATCH 02/14] " Pavel Machek
2018-11-05  9:19     ` Pavel Machek
2018-11-05  9:19     ` [02/14] " Pavel Machek
2018-08-22 20:42 ` [PATCH 03/14] USB: EHCI: make ehci-mv a separate driver Lubomir Rintel
2018-08-22 20:42   ` Lubomir Rintel
2018-08-22 20:42   ` [03/14] " Lubomir Rintel
2018-08-22 20:42 ` [PATCH 04/14] ARM: mmp: add a pxa-usb-phy device Lubomir Rintel
2018-08-22 20:42   ` Lubomir Rintel
2018-08-22 20:42   ` [04/14] " Lubomir Rintel
2018-08-22 20:42 ` [PATCH 05/14] ARM: ttc_dkb: add an instance of pxa-usb-phy Lubomir Rintel
2018-08-22 20:42   ` Lubomir Rintel
2018-08-22 20:42   ` [05/14] " Lubomir Rintel
2018-11-05  9:19   ` [PATCH 05/14] " Pavel Machek
2018-11-05  9:19     ` Pavel Machek
2018-11-05  9:19     ` [05/14] " Pavel Machek
2018-08-22 20:42 ` [PATCH 06/14] ARM: aspenite: " Lubomir Rintel
2018-08-22 20:42   ` Lubomir Rintel
2018-08-22 20:42   ` [06/14] " Lubomir Rintel
2018-11-05  9:19   ` [PATCH 06/14] " Pavel Machek
2018-11-05  9:19     ` Pavel Machek
2018-11-05  9:19     ` [06/14] " Pavel Machek
2018-08-22 20:43 ` [PATCH 07/14] USB: EHCI: ehci-mv: remove private_init Lubomir Rintel
2018-08-22 20:43   ` Lubomir Rintel
2018-08-22 20:43   ` [07/14] " Lubomir Rintel
2018-08-22 20:43 ` [PATCH 08/14] USB: EHCI: ehci-mv: use phy-pxa-usb Lubomir Rintel
2018-08-22 20:43   ` Lubomir Rintel
2018-08-22 20:43   ` [08/14] " Lubomir Rintel
2018-08-22 20:43 ` [PATCH 09/14] USB: phy-mv-usb: " Lubomir Rintel
2018-08-22 20:43   ` Lubomir Rintel
2018-08-22 20:43   ` [09/14] " Lubomir Rintel
2018-11-05  9:19   ` [PATCH 09/14] " Pavel Machek
2018-11-05  9:19     ` Pavel Machek
2018-11-05  9:19     ` [09/14] " Pavel Machek
2018-08-22 20:43 ` [PATCH 10/14] USB: gadget: mv-udc: " Lubomir Rintel
2018-08-22 20:43   ` Lubomir Rintel
2018-08-22 20:43   ` [10/14] " Lubomir Rintel
2018-11-05  9:20   ` [PATCH 10/14] " Pavel Machek
2018-11-05  9:20     ` Pavel Machek
2018-11-05  9:20     ` [10/14] " Pavel Machek
2018-08-22 20:43 ` [PATCH 11/14] USB: EHCI: ehci-mv: add DT support Lubomir Rintel
2018-08-22 20:43   ` Lubomir Rintel
2018-08-22 20:43   ` [11/14] " Lubomir Rintel
2018-08-22 20:43 ` [PATCH 12/14] dt-bindings: ehci-mv: add bindings Lubomir Rintel
2018-08-22 20:43   ` Lubomir Rintel
2018-08-22 20:43   ` [12/14] " Lubomir Rintel
2018-11-02 20:47   ` [PATCH 12/14] " Pavel Machek
2018-11-02 20:47     ` Pavel Machek
2018-11-02 20:47     ` [12/14] " Pavel Machek
2018-08-22 20:43 ` [PATCH 13/14] DT: marvell,mmp2: add OTG PHY Lubomir Rintel
2018-08-22 20:43   ` Lubomir Rintel
2018-08-22 20:43   ` [13/14] " Lubomir Rintel
2018-11-05  9:20   ` [PATCH 13/14] " Pavel Machek
2018-11-05  9:20     ` Pavel Machek
2018-11-05  9:20     ` [13/14] " Pavel Machek
2018-08-22 20:43 ` [PATCH 14/14] DT: marvell,mmp2: add USB OTG host controller Lubomir Rintel
2018-08-22 20:43   ` Lubomir Rintel
2018-08-22 20:43   ` [14/14] " Lubomir Rintel
2018-11-05  9:20   ` [PATCH 14/14] " Pavel Machek
2018-11-05  9:20     ` Pavel Machek
2018-11-05  9:20     ` [14/14] " Pavel Machek
2018-08-28 15:04 ` [PATCH 00/14] Convert ehci-mv to DT Alan Stern
2018-08-28 15:04   ` Alan Stern

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.