linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver
@ 2013-02-27 14:20 Marc Kleine-Budde
  2013-02-27 14:20 ` [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata Marc Kleine-Budde
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2013-02-27 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

this series depends on the series "[PATCH 0/3] otg-for-v3.10-v1: separate phy
code and add DT helper" (a.k.a. tags/otg-for-v3.10-v1) posted earlier and is
intended for v3.10. The chipidea driver is converted to make use of the DT
helper functions.

regards,
Marc


The following changes since commit 8a4c9f8489b2fce9e7bf0eb43fdb160ab51adc2c:

  USB mxs-phy: Register phy with framework (2013-02-27 13:48:21 +0100)

are available in the git repository at:

  git://git.pengutronix.de/git/mkl/linux.git tags/chipidea-for-v3.10-v1

for you to fetch changes up to 5d837224ea36da50f3e744a65fb23af1fa0a480d:

  USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy (2013-02-27 13:49:07 +0100)

----------------------------------------------------------------
USB chipidea: make use of DT helpers in chipidea driver

Make use of DT helper functions for handling the dr_mode and phy_type property.

----------------------------------------------------------------
Michael Grzeschik (2):
      USB chipidea: ci13xxx-imx: create dynamic platformdata
      USB chipidea: add PTW and PTS handling

Sascha Hauer (3):
      USB chipidea: introduce dual role mode pdata flags
      USB chipidea i.MX: introduce dr_mode property
      USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy

 .../devicetree/bindings/usb/ci13xxx-imx.txt        |    6 ++
 drivers/usb/chipidea/bits.h                        |   14 +++-
 drivers/usb/chipidea/ci13xxx_imx.c                 |   67 +++++++++++---------
 drivers/usb/chipidea/core.c                        |   61 ++++++++++++++++--
 include/linux/usb/chipidea.h                       |    3 +-
 5 files changed, 112 insertions(+), 39 deletions(-)

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

* [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata
  2013-02-27 14:20 [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Marc Kleine-Budde
@ 2013-02-27 14:20 ` Marc Kleine-Budde
  2013-02-27 14:20 ` [PATCH 2/5] USB chipidea: add PTW and PTS handling Marc Kleine-Budde
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2013-02-27 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

From: Michael Grzeschik <m.grzeschik@pengutronix.de>

This patch removes the limitation of having only one instance of the
ci13xxx-imx platformdata and makes different configurations possible.

Reviewed-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/usb/chipidea/ci13xxx_imx.c |   25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 8c29122..69024e0 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -85,17 +85,10 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
 
 /* End of common functions shared by usbmisc drivers*/
 
-static struct ci13xxx_platform_data ci13xxx_imx_platdata  = {
-	.name			= "ci13xxx_imx",
-	.flags			= CI13XXX_REQUIRE_TRANSCEIVER |
-				  CI13XXX_PULLUP_ON_VBUS |
-				  CI13XXX_DISABLE_STREAMING,
-	.capoffset		= DEF_CAPOFFSET,
-};
-
 static int ci13xxx_imx_probe(struct platform_device *pdev)
 {
 	struct ci13xxx_imx_data *data;
+	struct ci13xxx_platform_data *pdata;
 	struct platform_device *plat_ci, *phy_pdev;
 	struct device_node *phy_np;
 	struct resource *res;
@@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		&& !usbmisc_ops)
 		return -EPROBE_DEFER;
 
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata) {
+		dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX pdata!\n");
+		return -ENOMEM;
+	}
+
+	pdata->name = "ci13xxx_imx";
+	pdata->capoffset = DEF_CAPOFFSET;
+	pdata->flags = CI13XXX_REQUIRE_TRANSCEIVER |
+		       CI13XXX_PULLUP_ON_VBUS |
+		       CI13XXX_DISABLE_STREAMING;
+
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n");
@@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		reg_vbus = NULL;
 	}
 
-	ci13xxx_imx_platdata.phy = data->phy;
+	pdata->phy = data->phy;
 
 	if (!pdev->dev.dma_mask) {
 		pdev->dev.dma_mask = devm_kzalloc(&pdev->dev,
@@ -193,7 +198,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 
 	plat_ci = ci13xxx_add_device(&pdev->dev,
 				pdev->resource, pdev->num_resources,
-				&ci13xxx_imx_platdata);
+				pdata);
 	if (IS_ERR(plat_ci)) {
 		ret = PTR_ERR(plat_ci);
 		dev_err(&pdev->dev,
-- 
1.7.10.4

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

* [PATCH 2/5] USB chipidea: add PTW and PTS handling
  2013-02-27 14:20 [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Marc Kleine-Budde
  2013-02-27 14:20 ` [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata Marc Kleine-Budde
@ 2013-02-27 14:20 ` Marc Kleine-Budde
  2013-02-27 14:20 ` [PATCH 3/5] USB chipidea: introduce dual role mode pdata flags Marc Kleine-Budde
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2013-02-27 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

From: Michael Grzeschik <m.grzeschik@pengutronix.de>

This patch makes it possible to configure the PTW and PTS bits inside
the portsc register for host and device mode before the driver starts
and the phy can be addressed as hardware implementation is designed.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt        |    5 +++
 drivers/usb/chipidea/bits.h                        |   14 ++++++-
 drivers/usb/chipidea/ci13xxx_imx.c                 |    3 ++
 drivers/usb/chipidea/core.c                        |   39 ++++++++++++++++++++
 include/linux/usb/chipidea.h                       |    1 +
 5 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 5778b9c..dd42ccd 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -5,6 +5,11 @@ Required properties:
 - reg: Should contain registers location and length
 - interrupts: Should contain controller interrupt
 
+Recommended properies:
+- phy_type: the type of the phy connected to the core. Should be one
+  of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
+  property the PORTSC register won't be touched
+
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
 - fsl,usbmisc: phandler of non-core register device, with one argument
diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 050de85..d8ffc2f 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -48,10 +48,22 @@
 #define PORTSC_SUSP           BIT(7)
 #define PORTSC_HSP            BIT(9)
 #define PORTSC_PTC            (0x0FUL << 16)
+/* PTS and PTW for non lpm version only */
+#define PORTSC_PTS(d)         ((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0))
+#define PORTSC_PTW            BIT(28)
 
 /* DEVLC */
 #define DEVLC_PSPD            (0x03UL << 25)
-#define    DEVLC_PSPD_HS      (0x02UL << 25)
+#define DEVLC_PSPD_HS         (0x02UL << 25)
+#define DEVLC_PTW             BIT(27)
+#define DEVLC_STS             BIT(28)
+#define DEVLC_PTS(d)          (((d) & 0x7) << 29)
+
+/* Encoding for DEVLC_PTS and PORTSC_PTS */
+#define PTS_UTMI              0
+#define PTS_ULPI              2
+#define PTS_SERIAL            3
+#define PTS_HSIC              4
 
 /* OTGSC */
 #define OTGSC_IDPU	      BIT(5)
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 69024e0..ebc1148 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -21,6 +21,7 @@
 #include <linux/clk.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/usb/of.h>
 
 #include "ci.h"
 #include "ci13xxx_imx.h"
@@ -112,6 +113,8 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		       CI13XXX_PULLUP_ON_VBUS |
 		       CI13XXX_DISABLE_STREAMING;
 
+	pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node);
+
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n");
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 57cae1f..04d68cb 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -67,6 +67,8 @@
 #include <linux/usb/gadget.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/chipidea.h>
+#include <linux/usb/of.h>
+#include <linux/phy.h>
 
 #include "ci.h"
 #include "udc.h"
@@ -211,6 +213,41 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
 	return 0;
 }
 
+static void hw_phymode_configure(struct ci13xxx *ci)
+{
+	u32 portsc, lpm;
+
+	switch (ci->platdata->phy_mode) {
+	case USBPHY_INTERFACE_MODE_UTMI:
+		portsc = PORTSC_PTS(PTS_UTMI);
+		lpm = DEVLC_PTS(PTS_UTMI);
+		break;
+	case USBPHY_INTERFACE_MODE_UTMIW:
+		portsc = PORTSC_PTS(PTS_UTMI) | PORTSC_PTW;
+		lpm = DEVLC_PTS(PTS_UTMI) | DEVLC_PTW;
+		break;
+	case USBPHY_INTERFACE_MODE_ULPI:
+		portsc = PORTSC_PTS(PTS_ULPI);
+		lpm = DEVLC_PTS(PTS_ULPI);
+		break;
+	case USBPHY_INTERFACE_MODE_SERIAL:
+		portsc = PORTSC_PTS(PTS_SERIAL);
+		lpm = DEVLC_PTS(PTS_SERIAL);
+		break;
+	case USBPHY_INTERFACE_MODE_HSIC:
+		portsc = PORTSC_PTS(PTS_HSIC);
+		lpm = DEVLC_PTS(PTS_HSIC);
+		break;
+	default:
+		return;
+	}
+
+	if (ci->hw_bank.lpm)
+		hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
+	else
+		hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
+}
+
 /**
  * hw_device_reset: resets chip (execute without interruption)
  * @ci: the controller
@@ -476,6 +513,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 			: CI_ROLE_GADGET;
 	}
 
+	hw_phymode_configure(ci);
+
 	ret = ci_role_start(ci, ci->role);
 	if (ret) {
 		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 544825d..1a2aa18 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -14,6 +14,7 @@ struct ci13xxx_platform_data {
 	uintptr_t	 capoffset;
 	unsigned	 power_budget;
 	struct usb_phy	*phy;
+	enum usb_phy_interface phy_mode;
 	unsigned long	 flags;
 #define CI13XXX_REGS_SHARED		BIT(0)
 #define CI13XXX_REQUIRE_TRANSCEIVER	BIT(1)
-- 
1.7.10.4

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

* [PATCH 3/5] USB chipidea: introduce dual role mode pdata flags
  2013-02-27 14:20 [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Marc Kleine-Budde
  2013-02-27 14:20 ` [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata Marc Kleine-Budde
  2013-02-27 14:20 ` [PATCH 2/5] USB chipidea: add PTW and PTS handling Marc Kleine-Budde
@ 2013-02-27 14:20 ` Marc Kleine-Budde
  2013-02-27 14:20 ` [PATCH 4/5] USB chipidea i.MX: introduce dr_mode property Marc Kleine-Budde
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2013-02-27 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

From: Sascha Hauer <s.hauer@pengutronix.de>

Even if a chipidea core is otg capable the board may not. This allows
to explicitly set the core to host/peripheral mode. Without these
flags the driver falls back to the old behaviour.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/usb/chipidea/core.c  |   22 ++++++++++++++++------
 include/linux/usb/chipidea.h |    2 +-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 04d68cb..ec27060 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -435,6 +435,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 	struct resource	*res;
 	void __iomem	*base;
 	int		ret;
+	enum usb_dr_mode dr_mode;
 
 	if (!dev->platform_data) {
 		dev_err(dev, "platform data missing\n");
@@ -487,14 +488,23 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	/* For now we treat dual-role as otg */
+	dr_mode = ci->platdata->dr_mode;
+	if (dr_mode == USB_DR_MODE_UNKNOWN || dr_mode == USB_DR_MODE_DUAL_ROLE)
+		dr_mode = USB_DR_MODE_OTG;
+
 	/* initialize role(s) before the interrupt is requested */
-	ret = ci_hdrc_host_init(ci);
-	if (ret)
-		dev_info(dev, "doesn't support host\n");
+	if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
+		ret = ci_hdrc_host_init(ci);
+		if (ret)
+			dev_info(dev, "doesn't support host\n");
+	}
 
-	ret = ci_hdrc_gadget_init(ci);
-	if (ret)
-		dev_info(dev, "doesn't support gadget\n");
+	if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
+		ret = ci_hdrc_gadget_init(ci);
+		if (ret)
+			dev_info(dev, "doesn't support gadget\n");
+	}
 
 	if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
 		dev_err(dev, "no supported roles\n");
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 1a2aa18..b314647 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -20,7 +20,7 @@ struct ci13xxx_platform_data {
 #define CI13XXX_REQUIRE_TRANSCEIVER	BIT(1)
 #define CI13XXX_PULLUP_ON_VBUS		BIT(2)
 #define CI13XXX_DISABLE_STREAMING	BIT(3)
-
+	enum usb_dr_mode	dr_mode;
 #define CI13XXX_CONTROLLER_RESET_EVENT		0
 #define CI13XXX_CONTROLLER_STOPPED_EVENT	1
 	void	(*notify_event) (struct ci13xxx *ci, unsigned event);
-- 
1.7.10.4

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

* [PATCH 4/5] USB chipidea i.MX: introduce dr_mode property
  2013-02-27 14:20 [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2013-02-27 14:20 ` [PATCH 3/5] USB chipidea: introduce dual role mode pdata flags Marc Kleine-Budde
@ 2013-02-27 14:20 ` Marc Kleine-Budde
  2013-02-27 14:20 ` [PATCH 5/5] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy Marc Kleine-Budde
  2013-02-27 16:31 ` [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Steffen Trumtrar
  5 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2013-02-27 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

From: Sascha Hauer <s.hauer@pengutronix.de>

The dr_mode devicetree property allows to explicitly specify the
host/peripheral/otg mode. This is necessary for boards without proper
ID pin handling.

Reviewed-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 Documentation/devicetree/bindings/usb/ci13xxx-imx.txt |    1 +
 drivers/usb/chipidea/ci13xxx_imx.c                    |    1 +
 2 files changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index dd42ccd..493a414 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -9,6 +9,7 @@ Recommended properies:
 - phy_type: the type of the phy connected to the core. Should be one
   of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
   property the PORTSC register won't be touched
+- dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg"
 
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index ebc1148..b598bb8 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -114,6 +114,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		       CI13XXX_DISABLE_STREAMING;
 
 	pdata->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node);
+	pdata->dr_mode = of_usb_get_dr_mode(pdev->dev.of_node);
 
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
-- 
1.7.10.4

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

* [PATCH 5/5] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
  2013-02-27 14:20 [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2013-02-27 14:20 ` [PATCH 4/5] USB chipidea i.MX: introduce dr_mode property Marc Kleine-Budde
@ 2013-02-27 14:20 ` Marc Kleine-Budde
  2013-02-27 16:31 ` [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Steffen Trumtrar
  5 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2013-02-27 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

From: Sascha Hauer <s.hauer@pengutronix.de>

This patch replaces the hand crafted code to retrieve the phy's phandle from
the DT by the helper function devm_usb_get_phy_by_phandle() which has been
added in commit:

    "5d3c28b usb: otg: add device tree support to otg library"

Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
Reviewed-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/usb/chipidea/ci13xxx_imx.c |   38 ++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index b598bb8..6e720ce 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -30,7 +30,6 @@
 	((struct usb_phy *)platform_get_drvdata(pdev))
 
 struct ci13xxx_imx_data {
-	struct device_node *phy_np;
 	struct usb_phy *phy;
 	struct platform_device *ci_pdev;
 	struct clk *clk;
@@ -90,12 +89,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 {
 	struct ci13xxx_imx_data *data;
 	struct ci13xxx_platform_data *pdata;
-	struct platform_device *plat_ci, *phy_pdev;
-	struct device_node *phy_np;
+	struct platform_device *plat_ci;
 	struct resource *res;
 	struct regulator *reg_vbus;
 	struct pinctrl *pinctrl;
 	int ret;
+	struct usb_phy *phy;
 
 	if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL)
 		&& !usbmisc_ops)
@@ -147,19 +146,20 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	phy_np = of_parse_phandle(pdev->dev.of_node, "fsl,usbphy", 0);
-	if (phy_np) {
-		data->phy_np = phy_np;
-		phy_pdev = of_find_device_by_node(phy_np);
-		if (phy_pdev) {
-			struct usb_phy *phy;
-			phy = pdev_to_phy(phy_pdev);
-			if (phy &&
-			    try_module_get(phy_pdev->dev.driver->owner)) {
-				usb_phy_init(phy);
-				data->phy = phy;
-			}
+	phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0);
+	if (PTR_ERR(phy) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto err_clk;
+	}
+
+	if (!IS_ERR(phy)) {
+		ret = usb_phy_init(phy);
+		if (ret) {
+			dev_err(&pdev->dev, "unable to init phy: %d\n", ret);
+			goto err_clk;
 		}
+
+		data->phy = phy;
 	}
 
 	/* we only support host now, so enable vbus here */
@@ -170,7 +170,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"Failed to enable vbus regulator, err=%d\n",
 				ret);
-			goto put_np;
+			goto err_clk;
 		}
 		data->reg_vbus = reg_vbus;
 	} else {
@@ -222,9 +222,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 err:
 	if (reg_vbus)
 		regulator_disable(reg_vbus);
-put_np:
-	if (phy_np)
-		of_node_put(phy_np);
+err_clk:
 	clk_disable_unprepare(data->clk);
 	return ret;
 }
@@ -244,8 +242,6 @@ static int ci13xxx_imx_remove(struct platform_device *pdev)
 		module_put(data->phy->dev->driver->owner);
 	}
 
-	of_node_put(data->phy_np);
-
 	clk_disable_unprepare(data->clk);
 
 	platform_set_drvdata(pdev, NULL);
-- 
1.7.10.4

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

* [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver
  2013-02-27 14:20 [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2013-02-27 14:20 ` [PATCH 5/5] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy Marc Kleine-Budde
@ 2013-02-27 16:31 ` Steffen Trumtrar
  5 siblings, 0 replies; 9+ messages in thread
From: Steffen Trumtrar @ 2013-02-27 16:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Feb 27, 2013 at 03:20:25PM +0100, Marc Kleine-Budde wrote:
> Hello,
> 
> this series depends on the series "[PATCH 0/3] otg-for-v3.10-v1: separate phy
> code and add DT helper" (a.k.a. tags/otg-for-v3.10-v1) posted earlier and is
> intended for v3.10. The chipidea driver is converted to make use of the DT
> helper functions.
> 
> regards,
> Marc
> 
> 
> The following changes since commit 8a4c9f8489b2fce9e7bf0eb43fdb160ab51adc2c:
> 
>   USB mxs-phy: Register phy with framework (2013-02-27 13:48:21 +0100)
> 
> are available in the git repository at:
> 
>   git://git.pengutronix.de/git/mkl/linux.git tags/chipidea-for-v3.10-v1
> 
> for you to fetch changes up to 5d837224ea36da50f3e744a65fb23af1fa0a480d:
> 
>   USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy (2013-02-27 13:49:07 +0100)
> 
> ----------------------------------------------------------------
> USB chipidea: make use of DT helpers in chipidea driver
> 
> Make use of DT helper functions for handling the dr_mode and phy_type property.
> 
> ----------------------------------------------------------------
> Michael Grzeschik (2):
>       USB chipidea: ci13xxx-imx: create dynamic platformdata
>       USB chipidea: add PTW and PTS handling
> 
> Sascha Hauer (3):
>       USB chipidea: introduce dual role mode pdata flags
>       USB chipidea i.MX: introduce dr_mode property
>       USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
> 
>  .../devicetree/bindings/usb/ci13xxx-imx.txt        |    6 ++
>  drivers/usb/chipidea/bits.h                        |   14 +++-
>  drivers/usb/chipidea/ci13xxx_imx.c                 |   67 +++++++++++---------
>  drivers/usb/chipidea/core.c                        |   61 ++++++++++++++++--
>  include/linux/usb/chipidea.h                       |    3 +-
>  5 files changed, 112 insertions(+), 39 deletions(-)
> 
> 
> 
> 

Hi,

with this series plus
        otg-for-v3.9-v1: USB otg: fix usage of try_module_get() and module_put()
	otg-for-v3.10-v1: separate phy code and add DT helper
	v9: Add tested id switch and vbus connect detect support for Chipidea

and

diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 13b7053..1eeff3c 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -907,7 +907,8 @@
                        compatible = "fsl,imx28-usb", "fsl,imx27-usb";
                        reg = <0x80080000 0x10000>;
                        interrupts = <93>;
-                       clocks = <&clks 60>;
+                       clocks = <&clks 60>, <&clks 60>, <&clks 60>;
+                       clock-names = "ipg", "ahb", "per";
                        fsl,usbphy = <&usbphy0>;
                        status = "disabled";
                };
@@ -916,7 +917,8 @@
                        compatible = "fsl,imx28-usb", "fsl,imx27-usb";
                        reg = <0x80090000 0x10000>;
                        interrupts = <92>;
-                       clocks = <&clks 61>;
+                       clocks = <&clks 61>, <&clks 61>, <&clks 61>;
+                       clock-names = "ipg", "ahb", "per";
                        fsl,usbphy = <&usbphy1>;
                        status = "disabled";
                };

I have USB otg+host working on v3.8 on an i.MX28.

So,
        Tested-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>

Regards,
Steffen


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata
  2013-02-28 10:56 [PATCH 0/5] chipidea-for-v3.10-v2: " Marc Kleine-Budde
@ 2013-02-28 10:57 ` Marc Kleine-Budde
  2013-03-08 16:30   ` Felipe Balbi
  0 siblings, 1 reply; 9+ messages in thread
From: Marc Kleine-Budde @ 2013-02-28 10:57 UTC (permalink / raw)
  To: linux-arm-kernel

From: Michael Grzeschik <m.grzeschik@pengutronix.de>

This patch removes the limitation of having only one instance of the
ci13xxx-imx platformdata and makes different configurations possible.

Reviewed-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/usb/chipidea/ci13xxx_imx.c |   25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 8c29122..69024e0 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -85,17 +85,10 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
 
 /* End of common functions shared by usbmisc drivers*/
 
-static struct ci13xxx_platform_data ci13xxx_imx_platdata  = {
-	.name			= "ci13xxx_imx",
-	.flags			= CI13XXX_REQUIRE_TRANSCEIVER |
-				  CI13XXX_PULLUP_ON_VBUS |
-				  CI13XXX_DISABLE_STREAMING,
-	.capoffset		= DEF_CAPOFFSET,
-};
-
 static int ci13xxx_imx_probe(struct platform_device *pdev)
 {
 	struct ci13xxx_imx_data *data;
+	struct ci13xxx_platform_data *pdata;
 	struct platform_device *plat_ci, *phy_pdev;
 	struct device_node *phy_np;
 	struct resource *res;
@@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		&& !usbmisc_ops)
 		return -EPROBE_DEFER;
 
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata) {
+		dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX pdata!\n");
+		return -ENOMEM;
+	}
+
+	pdata->name = "ci13xxx_imx";
+	pdata->capoffset = DEF_CAPOFFSET;
+	pdata->flags = CI13XXX_REQUIRE_TRANSCEIVER |
+		       CI13XXX_PULLUP_ON_VBUS |
+		       CI13XXX_DISABLE_STREAMING;
+
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		dev_err(&pdev->dev, "Failed to allocate CI13xxx-IMX data!\n");
@@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		reg_vbus = NULL;
 	}
 
-	ci13xxx_imx_platdata.phy = data->phy;
+	pdata->phy = data->phy;
 
 	if (!pdev->dev.dma_mask) {
 		pdev->dev.dma_mask = devm_kzalloc(&pdev->dev,
@@ -193,7 +198,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 
 	plat_ci = ci13xxx_add_device(&pdev->dev,
 				pdev->resource, pdev->num_resources,
-				&ci13xxx_imx_platdata);
+				pdata);
 	if (IS_ERR(plat_ci)) {
 		ret = PTR_ERR(plat_ci);
 		dev_err(&pdev->dev,
-- 
1.7.10.4

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

* [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata
  2013-02-28 10:57 ` [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata Marc Kleine-Budde
@ 2013-03-08 16:30   ` Felipe Balbi
  0 siblings, 0 replies; 9+ messages in thread
From: Felipe Balbi @ 2013-03-08 16:30 UTC (permalink / raw)
  To: linux-arm-kernel

HI,

Hi,

On Thu, Feb 28, 2013 at 11:57:00AM +0100, Marc Kleine-Budde wrote:
> @@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
>  		&& !usbmisc_ops)
>  		return -EPROBE_DEFER;
>  
> +	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);

this isn't necessary. Look at how platform_device_add_data() is
implemented. It will duplicate whatever you pass to it. Which means you
can change ci13xxx_imx_platdata as much as you want ;-)

> @@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
>  		reg_vbus = NULL;
>  	}
>  
> -	ci13xxx_imx_platdata.phy = data->phy;
> +	pdata->phy = data->phy;

it would be pretty cool to start seeing patches teaching chipidea core
how to handle its own resources (regulators, phys, clocks, etc).

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

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

end of thread, other threads:[~2013-03-08 16:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-27 14:20 [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Marc Kleine-Budde
2013-02-27 14:20 ` [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata Marc Kleine-Budde
2013-02-27 14:20 ` [PATCH 2/5] USB chipidea: add PTW and PTS handling Marc Kleine-Budde
2013-02-27 14:20 ` [PATCH 3/5] USB chipidea: introduce dual role mode pdata flags Marc Kleine-Budde
2013-02-27 14:20 ` [PATCH 4/5] USB chipidea i.MX: introduce dr_mode property Marc Kleine-Budde
2013-02-27 14:20 ` [PATCH 5/5] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy Marc Kleine-Budde
2013-02-27 16:31 ` [PATCH 0/5] chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver Steffen Trumtrar
  -- strict thread matches above, loose matches on Subject: below --
2013-02-28 10:56 [PATCH 0/5] chipidea-for-v3.10-v2: " Marc Kleine-Budde
2013-02-28 10:57 ` [PATCH 1/5] USB chipidea: ci13xxx-imx: create dynamic platformdata Marc Kleine-Budde
2013-03-08 16:30   ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).