All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/7] USB: add devicetree helpers for determining dr_mode and phy_type
@ 2013-05-31 18:38 Michael Grzeschik
       [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-05-31 18:38 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, balbi-l0cyMroinI0

changes since v5:
- fixed compiling issues with non dt kernels in helper functions
- moved ci13xxx_imx glue calls into dr_mode and phy_type helpers to core.c
- added missing PTS option into PTW, PTS patch
- added kernel parameter patch to force core into fullspeed mode
- fixed kmalloc pdata patch in ci13xxx_imx.c

Michael Grzeschik (4):
  USB: add devicetree helpers for determining dr_mode and phy_type
  USB: chipidea: ci13xxx-imx: move static pdata into probe function
  USB: chipidea: add PTW, PTS and STS handling
  usb: chipidea: udc: add force-full-speed option

Philipp Zabel (1):
  usb: chipidea: usbmisc: use module_platform_driver

Sascha Hauer (2):
  USB chipidea: introduce dual role mode pdata flags
  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                        | 17 ++++-
 drivers/usb/chipidea/ci13xxx_imx.c                 | 60 ++++++++--------
 drivers/usb/chipidea/core.c                        | 84 ++++++++++++++++++++--
 drivers/usb/chipidea/usbmisc_imx.c                 | 12 +---
 drivers/usb/phy/Makefile                           |  1 +
 drivers/usb/phy/of.c                               | 47 ++++++++++++
 drivers/usb/usb-common.c                           | 35 +++++++++
 include/linux/usb/chipidea.h                       |  3 +-
 include/linux/usb/of.h                             | 28 ++++++++
 include/linux/usb/otg.h                            |  7 ++
 include/linux/usb/phy.h                            |  9 +++
 12 files changed, 258 insertions(+), 51 deletions(-)
 create mode 100644 drivers/usb/phy/of.c
 create mode 100644 include/linux/usb/of.h

-- 
1.8.2.rc2

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

* [PATCH 1/7] USB: add devicetree helpers for determining dr_mode and phy_type
       [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-05-31 18:38   ` Michael Grzeschik
       [not found]     ` <1370025529-7414-2-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 18:38   ` [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function Michael Grzeschik
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-05-31 18:38 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

This adds two little devicetree helper functions for determining the
dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from
the devicetree.

Signed-off-by: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/usb/phy/Makefile |  1 +
 drivers/usb/phy/of.c     | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/usb/usb-common.c | 35 +++++++++++++++++++++++++++++++++++
 include/linux/usb/of.h   | 28 ++++++++++++++++++++++++++++
 include/linux/usb/otg.h  |  7 +++++++
 include/linux/usb/phy.h  |  9 +++++++++
 6 files changed, 127 insertions(+)
 create mode 100644 drivers/usb/phy/of.c
 create mode 100644 include/linux/usb/of.h

diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index a9169cb..070eca3 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,6 +5,7 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_PHY)			+= phy.o
+obj-$(CONFIG_OF)			+= of.o
 
 # transceiver drivers, keep the list sorted
 
diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
new file mode 100644
index 0000000..e6f3b74
--- /dev/null
+++ b/drivers/usb/phy/of.c
@@ -0,0 +1,47 @@
+/*
+ * USB of helper code
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/usb/of.h>
+#include <linux/usb/otg.h>
+
+static const char *usbphy_modes[] = {
+	[USBPHY_INTERFACE_MODE_UNKNOWN]	= "",
+	[USBPHY_INTERFACE_MODE_UTMI]	= "utmi",
+	[USBPHY_INTERFACE_MODE_UTMIW]	= "utmi_wide",
+	[USBPHY_INTERFACE_MODE_ULPI]	= "ulpi",
+	[USBPHY_INTERFACE_MODE_SERIAL]	= "serial",
+	[USBPHY_INTERFACE_MODE_HSIC]	= "hsic",
+};
+
+/**
+ * of_usb_get_phy_mode - Get phy mode for given device_node
+ * @np:	Pointer to the given device_node
+ *
+ * The function gets phy interface string from property 'phy_type',
+ * and returns the correspondig enum usb_phy_interface
+ */
+enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
+{
+	const char *phy_type;
+	int err, i;
+
+	err = of_property_read_string(np, "phy_type", &phy_type);
+	if (err < 0)
+		return USBPHY_INTERFACE_MODE_UNKNOWN;
+
+	for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++)
+		if (!strcmp(phy_type, usbphy_modes[i]))
+			return i;
+
+	return USBPHY_INTERFACE_MODE_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
index 0db0a91..027582d 100644
--- a/drivers/usb/usb-common.c
+++ b/drivers/usb/usb-common.c
@@ -13,7 +13,9 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/usb/ch9.h>
+#include <linux/usb/of.h>
 #include <linux/usb/otg.h>
 
 const char *usb_otg_state_string(enum usb_otg_state state)
@@ -79,4 +81,37 @@ const char *usb_state_string(enum usb_device_state state)
 }
 EXPORT_SYMBOL_GPL(usb_state_string);
 
+#ifdef CONFIG_OF
+static const char *usb_dr_modes[] = {
+	[USB_DR_MODE_UNKNOWN]		= "",
+	[USB_DR_MODE_HOST]		= "host",
+	[USB_DR_MODE_PERIPHERAL]	= "peripheral",
+	[USB_DR_MODE_OTG]		= "otg",
+};
+
+/**
+ * of_usb_get_dr_mode - Get dual role mode for given device_node
+ * @np:	Pointer to the given device_node
+ *
+ * The function gets phy interface string from property 'dr_mode',
+ * and returns the correspondig enum usb_dr_mode
+ */
+enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
+{
+	const char *dr_mode;
+	int err, i;
+
+	err = of_property_read_string(np, "dr_mode", &dr_mode);
+	if (err < 0)
+		return USB_DR_MODE_UNKNOWN;
+
+	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
+		if (!strcmp(dr_mode, usb_dr_modes[i]))
+			return i;
+
+	return USB_DR_MODE_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
+#endif
+
 MODULE_LICENSE("GPL");
diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
new file mode 100644
index 0000000..e460a24
--- /dev/null
+++ b/include/linux/usb/of.h
@@ -0,0 +1,28 @@
+/*
+ * OF helpers for usb devices.
+ *
+ * This file is released under the GPLv2
+ */
+
+#ifndef __LINUX_USB_OF_H
+#define __LINUX_USB_OF_H
+
+#include <linux/usb/otg.h>
+#include <linux/usb/phy.h>
+
+#ifdef CONFIG_OF
+enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np);
+enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
+#else
+static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
+{
+	return USBPHY_INTERFACE_MODE_UNKNOWN;
+}
+
+static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
+{
+	return USB_DR_MODE_UNKNOWN;
+}
+#endif
+
+#endif /* __LINUX_USB_OF_H */
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 291e01b..154332b 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -92,4 +92,11 @@ otg_start_srp(struct usb_otg *otg)
 /* for OTG controller drivers (and maybe other stuff) */
 extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
 
+enum usb_dr_mode {
+	USB_DR_MODE_UNKNOWN,
+	USB_DR_MODE_HOST,
+	USB_DR_MODE_PERIPHERAL,
+	USB_DR_MODE_OTG,
+};
+
 #endif /* __LINUX_USB_OTG_H */
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 6b5978f..4403680 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -12,6 +12,15 @@
 #include <linux/notifier.h>
 #include <linux/usb.h>
 
+enum usb_phy_interface {
+	USBPHY_INTERFACE_MODE_UNKNOWN,
+	USBPHY_INTERFACE_MODE_UTMI,
+	USBPHY_INTERFACE_MODE_UTMIW,
+	USBPHY_INTERFACE_MODE_ULPI,
+	USBPHY_INTERFACE_MODE_SERIAL,
+	USBPHY_INTERFACE_MODE_HSIC,
+};
+
 enum usb_phy_events {
 	USB_EVENT_NONE,         /* no events or cable disconnected */
 	USB_EVENT_VBUS,         /* vbus valid event */
-- 
1.8.2.rc2

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

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

* [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function
       [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 18:38   ` [PATCH 1/7] " Michael Grzeschik
@ 2013-05-31 18:38   ` Michael Grzeschik
       [not found]     ` <1370025529-7414-3-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 18:38   ` [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling Michael Grzeschik
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-05-31 18:38 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

The pdata structure gets copied anyway inside ci13xxx_add_device
by platform_device_add. We don't need to have it static.

Signed-off-by: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Reviewed-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 drivers/usb/chipidea/ci13xxx_imx.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 73f9d5f..4d64541 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -88,17 +88,16 @@ 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 = {
+		.name		= "ci13xxx_imx",
+		.capoffset	= DEF_CAPOFFSET,
+		.flags		= CI13XXX_REQUIRE_TRANSCEIVER |
+				  CI13XXX_PULLUP_ON_VBUS |
+				  CI13XXX_DISABLE_STREAMING,
+	};
 	struct platform_device *plat_ci, *phy_pdev;
 	struct device_node *phy_np;
 	struct resource *res;
@@ -171,7 +170,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 = &pdev->dev.coherent_dma_mask;
@@ -189,7 +188,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.8.2.rc2

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

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

* [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling
       [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 18:38   ` [PATCH 1/7] " Michael Grzeschik
  2013-05-31 18:38   ` [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function Michael Grzeschik
@ 2013-05-31 18:38   ` Michael Grzeschik
       [not found]     ` <1370025529-7414-4-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 18:38   ` [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags Michael Grzeschik
                     ` (3 subsequent siblings)
  6 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-05-31 18:38 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Michael Grzeschik,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, balbi-l0cyMroinI0

From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

This patch makes it possible to configure the PTW, PTS and STS 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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt        |  5 +++
 drivers/usb/chipidea/bits.h                        | 15 ++++++-
 drivers/usb/chipidea/core.c                        | 49 ++++++++++++++++++++++
 include/linux/usb/chipidea.h                       |  1 +
 4 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 1c04a4c..184a8e0 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..93efe4e 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -48,10 +48,23 @@
 #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)
+#define PORTSC_STS            BIT(29)
 
 /* 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/core.c b/drivers/usb/chipidea/core.c
index 49b098b..b49b682 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -64,6 +64,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"
@@ -208,6 +210,45 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
 	return 0;
 }
 
+static void hw_phymode_configure(struct ci13xxx *ci)
+{
+	u32 portsc, lpm, sts;
+
+	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);
+		sts = 1;
+		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);
+		hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
+	} else {
+		hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
+		hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
+	}
+}
+
 /**
  * hw_device_reset: resets chip (execute without interruption)
  * @ci: the controller
@@ -369,6 +410,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	if (!dev->of_node && dev->parent)
+		dev->of_node = dev->parent->of_node;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(base))
@@ -408,6 +452,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	if (!ci->platdata->phy_mode)
+		ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
+
 	/* initialize role(s) before the interrupt is requested */
 	ret = ci_hdrc_host_init(ci);
 	if (ret)
@@ -434,6 +481,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.8.2.rc2

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

* [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags
       [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
                     ` (2 preceding siblings ...)
  2013-05-31 18:38   ` [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling Michael Grzeschik
@ 2013-05-31 18:38   ` Michael Grzeschik
       [not found]     ` <1370025529-7414-5-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 18:38   ` [PATCH 5/7] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy Michael Grzeschik
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-05-31 18:38 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Sascha Hauer

From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt        |  1 +
 drivers/usb/chipidea/core.c                        | 24 ++++++++++++++++------
 include/linux/usb/chipidea.h                       |  2 +-
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 184a8e0..b4b5b79 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/core.c b/drivers/usb/chipidea/core.c
index b49b682..dcf2a0b 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -404,6 +404,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");
@@ -455,14 +456,25 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 	if (!ci->platdata->phy_mode)
 		ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
 
+	if (!ci->platdata->dr_mode)
+		ci->platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);
+
+	if (ci->platdata->dr_mode == USB_DR_MODE_UNKNOWN)
+		ci->platdata->dr_mode = USB_DR_MODE_OTG;
+
+	dr_mode = ci->platdata->dr_mode;
 	/* 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)

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

* [PATCH 5/7] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
       [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
                     ` (3 preceding siblings ...)
  2013-05-31 18:38   ` [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags Michael Grzeschik
@ 2013-05-31 18:38   ` Michael Grzeschik
       [not found]     ` <1370025529-7414-6-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 18:38   ` [PATCH 6/7] usb: chipidea: udc: add force-full-speed option Michael Grzeschik
  2013-05-31 18:38   ` [PATCH 7/7] usb: chipidea: usbmisc: use module_platform_driver Michael Grzeschik
  6 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-05-31 18:38 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Sascha Hauer,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, balbi-l0cyMroinI0

From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/usb/chipidea/ci13xxx_imx.c | 41 ++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 4d64541..48c446b 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -29,7 +29,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;
@@ -98,12 +97,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 				  CI13XXX_PULLUP_ON_VBUS |
 				  CI13XXX_DISABLE_STREAMING,
 	};
-	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)
@@ -140,19 +139,21 @@ 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 */
@@ -163,7 +164,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 {
@@ -202,7 +203,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
 		if (ret) {
 			dev_err(&pdev->dev,
 				"usbmisc post failed, ret=%d\n", ret);
-			goto put_np;
+			goto err;
 		}
 	}
 
@@ -217,9 +218,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;
 }
@@ -239,8 +238,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.8.2.rc2

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

* [PATCH 6/7] usb: chipidea: udc: add force-full-speed option
       [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
                     ` (4 preceding siblings ...)
  2013-05-31 18:38   ` [PATCH 5/7] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy Michael Grzeschik
@ 2013-05-31 18:38   ` Michael Grzeschik
       [not found]     ` <1370025529-7414-7-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 18:38   ` [PATCH 7/7] usb: chipidea: usbmisc: use module_platform_driver Michael Grzeschik
  6 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-05-31 18:38 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

This patch makes it possible to set the chipidea udc
into full-speed only mode. It can be set by the oftree
property "force-full-speed".

Signed-off-by: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/usb/chipidea/bits.h |  2 ++
 drivers/usb/chipidea/core.c | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 93efe4e..4c14ab7 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -49,11 +49,13 @@
 #define PORTSC_HSP            BIT(9)
 #define PORTSC_PTC            (0x0FUL << 16)
 /* PTS and PTW for non lpm version only */
+#define PORTSC_PFSC           BIT(24)
 #define PORTSC_PTS(d)         ((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0))
 #define PORTSC_PTW            BIT(28)
 #define PORTSC_STS            BIT(29)
 
 /* DEVLC */
+#define DEVLC_PFSC            BIT(23)
 #define DEVLC_PSPD            (0x03UL << 25)
 #define DEVLC_PSPD_HS         (0x02UL << 25)
 #define DEVLC_PTW             BIT(27)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index dcf2a0b..4b8b3e7 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -73,6 +73,11 @@
 #include "host.h"
 #include "debug.h"
 
+/* force full-speed operation */
+static bool full_speed;
+module_param(full_speed, bool, 0444);
+MODULE_PARM_DESC(full_speed, "force full-speed mode");
+
 /* Controller register map */
 static uintptr_t ci_regs_nolpm[] = {
 	[CAP_CAPLENGTH]		= 0x000UL,
@@ -265,6 +270,12 @@ int hw_device_reset(struct ci13xxx *ci, u32 mode)
 	while (hw_read(ci, OP_USBCMD, USBCMD_RST))
 		udelay(10);		/* not RTOS friendly */
 
+	if (full_speed) {
+		if (ci->hw_bank.lpm)
+			hw_write(ci, OP_PORTSC, DEVLC_PFSC, DEVLC_PFSC);
+		else
+			hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
+	}
 
 	if (ci->platdata->notify_event)
 		ci->platdata->notify_event(ci,
-- 
1.8.2.rc2

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

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

* [PATCH 7/7] usb: chipidea: usbmisc: use module_platform_driver
       [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
                     ` (5 preceding siblings ...)
  2013-05-31 18:38   ` [PATCH 6/7] usb: chipidea: udc: add force-full-speed option Michael Grzeschik
@ 2013-05-31 18:38   ` Michael Grzeschik
       [not found]     ` <1370025529-7414-8-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  6 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-05-31 18:38 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Philipp Zabel

From: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Signed-off-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/usb/chipidea/usbmisc_imx.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 714a6bd..588bae8 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -243,17 +243,7 @@ static struct platform_driver usbmisc_imx_driver = {
 	 },
 };
 
-int usbmisc_imx_drv_init(void)
-{
-	return platform_driver_register(&usbmisc_imx_driver);
-}
-subsys_initcall(usbmisc_imx_drv_init);

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

* Re: [PATCH 5/7] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
       [not found]     ` <1370025529-7414-6-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-05-31 19:23       ` Sergei Shtylyov
  2013-06-03 12:39       ` Alexander Shishkin
  1 sibling, 0 replies; 29+ messages in thread
From: Sergei Shtylyov @ 2013-05-31 19:23 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Sascha Hauer

Hello.

On 05/31/2013 10:38 PM, Michael Grzeschik wrote:

> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>
> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
>   drivers/usb/chipidea/ci13xxx_imx.c | 41 ++++++++++++++++++--------------------
>   1 file changed, 19 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
> index 4d64541..48c446b 100644
> --- a/drivers/usb/chipidea/ci13xxx_imx.c
> +++ b/drivers/usb/chipidea/ci13xxx_imx.c
[...]
> @@ -140,19 +139,21 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)
[...]
> +	phy = devm_usb_get_phy_by_phandle(&pdev->dev, "fsl,usbphy", 0);
> +

     Empty line is not really needed here, don't you think?

> +	if (PTR_ERR(phy) == -EPROBE_DEFER) {

    Hm, can PTR_ERR() be called on non-error pointers? Seems so...

> +		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;
>   	}

     Shouldn't this come first instead, with the above PTR_ERR() 
condition in
the *else* branch?

WBR, Sergei

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

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

* Re: [PATCH 6/7] usb: chipidea: udc: add force-full-speed option
       [not found]     ` <1370025529-7414-7-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-01  7:39       ` Sascha Hauer
       [not found]         ` <20130601073933.GK32299-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Sascha Hauer @ 2013-06-01  7:39 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

On Fri, May 31, 2013 at 08:38:48PM +0200, Michael Grzeschik wrote:
> From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> 
> This patch makes it possible to set the chipidea udc
> into full-speed only mode. It can be set by the oftree
> property "force-full-speed".

[...]

> +/* force full-speed operation */
> +static bool full_speed;
> +module_param(full_speed, bool, 0444);
> +MODULE_PARM_DESC(full_speed, "force full-speed mode");
> +

???

Sascha

-- 
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 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 6/7] usb: chipidea: udc: add force-full-speed option
       [not found]         ` <20130601073933.GK32299-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-01  8:19           ` Michael Grzeschik
       [not found]             ` <20130601081932.GA28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-06-01  8:19 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

On Sat, Jun 01, 2013 at 09:39:33AM +0200, Sascha Hauer wrote:
> On Fri, May 31, 2013 at 08:38:48PM +0200, Michael Grzeschik wrote:
> > From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > 
> > This patch makes it possible to set the chipidea udc
> > into full-speed only mode. It can be set by the oftree
> > property "force-full-speed".
> 
> [...]
> 
> > +/* force full-speed operation */
> > +static bool full_speed;
> > +module_param(full_speed, bool, 0444);
> > +MODULE_PARM_DESC(full_speed, "force full-speed mode");
> > +
> 
> ???

Right, i reworked that one to get rid of yet another of property.
But i forgot to change the description. I will fix that, thanks.

Regards,
Michael

-- 
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 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 6/7] usb: chipidea: udc: add force-full-speed option
       [not found]             ` <20130601081932.GA28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-01  9:21               ` Sascha Hauer
       [not found]                 ` <20130601092151.GP32299-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Sascha Hauer @ 2013-06-01  9:21 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

On Sat, Jun 01, 2013 at 10:19:32AM +0200, Michael Grzeschik wrote:
> On Sat, Jun 01, 2013 at 09:39:33AM +0200, Sascha Hauer wrote:
> > On Fri, May 31, 2013 at 08:38:48PM +0200, Michael Grzeschik wrote:
> > > From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > > 
> > > This patch makes it possible to set the chipidea udc
> > > into full-speed only mode. It can be set by the oftree
> > > property "force-full-speed".
> > 
> > [...]
> > 
> > > +/* force full-speed operation */
> > > +static bool full_speed;
> > > +module_param(full_speed, bool, 0444);
> > > +MODULE_PARM_DESC(full_speed, "force full-speed mode");
> > > +
> > 
> > ???
> 
> Right, i reworked that one to get rid of yet another of property.
> But i forgot to change the description. I will fix that, thanks.

But a module parameter limits all instances to full speed. Is that what
you want? I like a devicetree property better.

Sascha


-- 
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 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/7] USB: add devicetree helpers for determining dr_mode and phy_type
       [not found]     ` <1370025529-7414-2-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-03 12:32       ` Alexander Shishkin
       [not found]         ` <8761xvjrwt.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-03 12:32 UTC (permalink / raw)
  To: Michael Grzeschik, linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: balbi-l0cyMroinI0, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:

> From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>
> This adds two little devicetree helper functions for determining the
> dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from
> the devicetree.

This one needs an ack from Felipe.

>
> Signed-off-by: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
>  drivers/usb/phy/Makefile |  1 +
>  drivers/usb/phy/of.c     | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/usb/usb-common.c | 35 +++++++++++++++++++++++++++++++++++
>  include/linux/usb/of.h   | 28 ++++++++++++++++++++++++++++
>  include/linux/usb/otg.h  |  7 +++++++
>  include/linux/usb/phy.h  |  9 +++++++++
>  6 files changed, 127 insertions(+)
>  create mode 100644 drivers/usb/phy/of.c
>  create mode 100644 include/linux/usb/of.h
>
> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> index a9169cb..070eca3 100644
> --- a/drivers/usb/phy/Makefile
> +++ b/drivers/usb/phy/Makefile
> @@ -5,6 +5,7 @@
>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>  
>  obj-$(CONFIG_USB_PHY)			+= phy.o
> +obj-$(CONFIG_OF)			+= of.o
>  
>  # transceiver drivers, keep the list sorted
>  
> diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
> new file mode 100644
> index 0000000..e6f3b74
> --- /dev/null
> +++ b/drivers/usb/phy/of.c
> @@ -0,0 +1,47 @@
> +/*
> + * USB of helper code
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/usb/of.h>
> +#include <linux/usb/otg.h>
> +
> +static const char *usbphy_modes[] = {
> +	[USBPHY_INTERFACE_MODE_UNKNOWN]	= "",
> +	[USBPHY_INTERFACE_MODE_UTMI]	= "utmi",
> +	[USBPHY_INTERFACE_MODE_UTMIW]	= "utmi_wide",
> +	[USBPHY_INTERFACE_MODE_ULPI]	= "ulpi",
> +	[USBPHY_INTERFACE_MODE_SERIAL]	= "serial",
> +	[USBPHY_INTERFACE_MODE_HSIC]	= "hsic",
> +};
> +
> +/**
> + * of_usb_get_phy_mode - Get phy mode for given device_node
> + * @np:	Pointer to the given device_node
> + *
> + * The function gets phy interface string from property 'phy_type',
> + * and returns the correspondig enum usb_phy_interface
> + */
> +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
> +{
> +	const char *phy_type;
> +	int err, i;
> +
> +	err = of_property_read_string(np, "phy_type", &phy_type);
> +	if (err < 0)
> +		return USBPHY_INTERFACE_MODE_UNKNOWN;
> +
> +	for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++)
> +		if (!strcmp(phy_type, usbphy_modes[i]))
> +			return i;
> +
> +	return USBPHY_INTERFACE_MODE_UNKNOWN;
> +}
> +EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
> diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
> index 0db0a91..027582d 100644
> --- a/drivers/usb/usb-common.c
> +++ b/drivers/usb/usb-common.c
> @@ -13,7 +13,9 @@
>  
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
>  #include <linux/usb/ch9.h>
> +#include <linux/usb/of.h>
>  #include <linux/usb/otg.h>
>  
>  const char *usb_otg_state_string(enum usb_otg_state state)
> @@ -79,4 +81,37 @@ const char *usb_state_string(enum usb_device_state state)
>  }
>  EXPORT_SYMBOL_GPL(usb_state_string);
>  
> +#ifdef CONFIG_OF
> +static const char *usb_dr_modes[] = {
> +	[USB_DR_MODE_UNKNOWN]		= "",
> +	[USB_DR_MODE_HOST]		= "host",
> +	[USB_DR_MODE_PERIPHERAL]	= "peripheral",
> +	[USB_DR_MODE_OTG]		= "otg",
> +};
> +
> +/**
> + * of_usb_get_dr_mode - Get dual role mode for given device_node
> + * @np:	Pointer to the given device_node
> + *
> + * The function gets phy interface string from property 'dr_mode',
> + * and returns the correspondig enum usb_dr_mode
> + */
> +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
> +{
> +	const char *dr_mode;
> +	int err, i;
> +
> +	err = of_property_read_string(np, "dr_mode", &dr_mode);
> +	if (err < 0)
> +		return USB_DR_MODE_UNKNOWN;
> +
> +	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
> +		if (!strcmp(dr_mode, usb_dr_modes[i]))
> +			return i;
> +
> +	return USB_DR_MODE_UNKNOWN;
> +}
> +EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
> +#endif
> +
>  MODULE_LICENSE("GPL");
> diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
> new file mode 100644
> index 0000000..e460a24
> --- /dev/null
> +++ b/include/linux/usb/of.h
> @@ -0,0 +1,28 @@
> +/*
> + * OF helpers for usb devices.
> + *
> + * This file is released under the GPLv2
> + */
> +
> +#ifndef __LINUX_USB_OF_H
> +#define __LINUX_USB_OF_H
> +
> +#include <linux/usb/otg.h>
> +#include <linux/usb/phy.h>
> +
> +#ifdef CONFIG_OF
> +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np);
> +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
> +#else
> +static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
> +{
> +	return USBPHY_INTERFACE_MODE_UNKNOWN;
> +}
> +
> +static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
> +{
> +	return USB_DR_MODE_UNKNOWN;
> +}
> +#endif
> +
> +#endif /* __LINUX_USB_OF_H */
> diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
> index 291e01b..154332b 100644
> --- a/include/linux/usb/otg.h
> +++ b/include/linux/usb/otg.h
> @@ -92,4 +92,11 @@ otg_start_srp(struct usb_otg *otg)
>  /* for OTG controller drivers (and maybe other stuff) */
>  extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
>  
> +enum usb_dr_mode {
> +	USB_DR_MODE_UNKNOWN,
> +	USB_DR_MODE_HOST,
> +	USB_DR_MODE_PERIPHERAL,
> +	USB_DR_MODE_OTG,
> +};
> +

I would suggest turning this into a bitmask, so that further tests look
like

  if (dr_mode & USB_DR_MODE_HOST) {...}

instead of how they currently look like in the other patch.

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

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

* Re: [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling
       [not found]     ` <1370025529-7414-4-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-03 12:35       ` Alexander Shishkin
       [not found]         ` <8738szjrs6.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
  2013-06-06 10:54       ` Michael Grzeschik
  1 sibling, 1 reply; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-03 12:35 UTC (permalink / raw)
  To: Michael Grzeschik, linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: balbi-l0cyMroinI0, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:

> From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>
> This patch makes it possible to configure the PTW, PTS and STS 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.

The bulk of this patch is good, but the OF part should still go to
ci13xxx_imx along with the dt bindings description.

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

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

* Re: [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags
       [not found]     ` <1370025529-7414-5-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-03 12:37       ` Alexander Shishkin
       [not found]         ` <87zjv7id52.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-03 12:37 UTC (permalink / raw)
  To: Michael Grzeschik, linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: balbi-l0cyMroinI0, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Sascha Hauer

Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:

> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>
> Even if a chipidea core is otg capable the board may not. This allows

"may not be"

> 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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---

[snip]

> +	if (!ci->platdata->dr_mode)
> +		ci->platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);

same as previous one, let's keep it in the platform.

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

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

* Re: [PATCH 5/7] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
       [not found]     ` <1370025529-7414-6-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-05-31 19:23       ` Sergei Shtylyov
@ 2013-06-03 12:39       ` Alexander Shishkin
  1 sibling, 0 replies; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-03 12:39 UTC (permalink / raw)
  To: Michael Grzeschik, linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: balbi-l0cyMroinI0, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Sascha Hauer

Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:

> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>
> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Also please add a description.

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

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

* Re: [PATCH 6/7] usb: chipidea: udc: add force-full-speed option
       [not found]                 ` <20130601092151.GP32299-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-03 12:40                   ` Alexander Shishkin
  0 siblings, 0 replies; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-03 12:40 UTC (permalink / raw)
  To: Sascha Hauer, Michael Grzeschik
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:

> On Sat, Jun 01, 2013 at 10:19:32AM +0200, Michael Grzeschik wrote:
>> On Sat, Jun 01, 2013 at 09:39:33AM +0200, Sascha Hauer wrote:
>> > On Fri, May 31, 2013 at 08:38:48PM +0200, Michael Grzeschik wrote:
>> > > From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> > > 
>> > > This patch makes it possible to set the chipidea udc
>> > > into full-speed only mode. It can be set by the oftree
>> > > property "force-full-speed".
>> > 
>> > [...]
>> > 
>> > > +/* force full-speed operation */
>> > > +static bool full_speed;
>> > > +module_param(full_speed, bool, 0444);
>> > > +MODULE_PARM_DESC(full_speed, "force full-speed mode");
>> > > +
>> > 
>> > ???
>> 
>> Right, i reworked that one to get rid of yet another of property.
>> But i forgot to change the description. I will fix that, thanks.
>
> But a module parameter limits all instances to full speed. Is that what
> you want? I like a devicetree property better.

+1

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

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

* Re: [PATCH 7/7] usb: chipidea: usbmisc: use module_platform_driver
       [not found]     ` <1370025529-7414-8-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-03 12:41       ` Alexander Shishkin
  0 siblings, 0 replies; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-03 12:41 UTC (permalink / raw)
  To: Michael Grzeschik, linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: balbi-l0cyMroinI0, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Philipp Zabel

Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:

> From: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>

Please say something in the description.

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

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

* Re: [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling
       [not found]         ` <8738szjrs6.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
@ 2013-06-03 16:11           ` Michael Grzeschik
       [not found]             ` <20130603161136.GB28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-06-03 16:11 UTC (permalink / raw)
  To: Alexander Shishkin
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

Hey Alex,

On Mon, Jun 03, 2013 at 03:35:37PM +0300, Alexander Shishkin wrote:
> Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:
> 
> > From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> >
> > This patch makes it possible to configure the PTW, PTS and STS 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.
> 
> The bulk of this patch is good, but the OF part should still go to
> ci13xxx_imx along with the dt bindings description.

referring to the last discussion [¹] about what should be handled
where, your last statement is pretty confusing. We might say we
somehow stuck in a loop if i would repost this patch again
and somebody (probably you :]) is telling me to do the opposite again!

If you have a closer look, you can see that we are checking for
valid pdata:

@@ -408,6 +452,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
                return -ENODEV;
        }

+       if (!ci->platdata->phy_mode)
+               ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
+

This way we can ensure that platforms without OF still
can use the pdata. _But_ we always fall back to OF in the
core _if_ nobody cared. This should be done with all properties
that are not SoC, but _common_ device specific settings.

[¹] https://patchwork.kernel.org/patch/2196981/

Thanks,
Michael

-- 
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 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags
       [not found]         ` <87zjv7id52.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
@ 2013-06-04  1:42           ` Peter Chen
       [not found]             ` <CAL411-pMnJC55M3n5bAuffH3pwRZTzhBfDiEfT+egtGN29c7uw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Peter Chen @ 2013-06-04  1:42 UTC (permalink / raw)
  To: Alexander Shishkin
  Cc: Michael Grzeschik, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	balbi-l0cyMroinI0, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Sascha Hauer

On Mon, Jun 3, 2013 at 8:37 PM, Alexander Shishkin
<alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:
>
>> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>>
>> Even if a chipidea core is otg capable the board may not. This allows
>
> "may not be"
>
>> 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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> ---
>
> [snip]
>
>> +     if (!ci->platdata->dr_mode)
>> +             ci->platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);
>
> same as previous one, let's keep it in the platform.

Alex, have you made the conclusion with Felipe, whether we need DT support
at core driver to handle such kinds of things or use platform data is ok?
Last time, I remember he disagreed the way this patch uses.

--
BR,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling
       [not found]             ` <20130603161136.GB28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-04  9:22               ` Alexander Shishkin
  0 siblings, 0 replies; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-04  9:22 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:

> Hey Alex,
>
> On Mon, Jun 03, 2013 at 03:35:37PM +0300, Alexander Shishkin wrote:
>> Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:
>> 
>> > From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> >
>> > This patch makes it possible to configure the PTW, PTS and STS 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.
>> 
>> The bulk of this patch is good, but the OF part should still go to
>> ci13xxx_imx along with the dt bindings description.
>
> referring to the last discussion [1] about what should be handled
> where, your last statement is pretty confusing. We might say we
> somehow stuck in a loop if i would repost this patch again
> and somebody (probably you :]) is telling me to do the opposite again!

I know it's a difficult topic and I'm sorry for all the confusion. It
was Felipe, he's a big proponent of core drivers fetching everything
related to the core from DT. It's right there in the followups to that
patch.

> If you have a closer look, you can see that we are checking for
> valid pdata:
>
> @@ -408,6 +452,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>                 return -ENODEV;
>         }
>
> +       if (!ci->platdata->phy_mode)
> +               ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
> +
>
> This way we can ensure that platforms without OF still
> can use the pdata. _But_ we always fall back to OF in the
> core _if_ nobody cared. This should be done with all properties
> that are not SoC, but _common_ device specific settings.

Ok, let's leave it like this.

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

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

* Re: [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags
       [not found]             ` <CAL411-pMnJC55M3n5bAuffH3pwRZTzhBfDiEfT+egtGN29c7uw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-06-04  9:31               ` Alexander Shishkin
       [not found]                 ` <87ehcii5n0.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-04  9:31 UTC (permalink / raw)
  To: Peter Chen
  Cc: Michael Grzeschik, linux-usb@vger.kernel.org, balbi@ti.com,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Sascha Hauer

Peter Chen <hzpeterchen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> On Mon, Jun 3, 2013 at 8:37 PM, Alexander Shishkin
> <alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
>> Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:
>>
>>> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>>>
>>> Even if a chipidea core is otg capable the board may not. This allows
>>
>> "may not be"
>>
>>> 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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>>> ---
>>
>> [snip]
>>
>>> +     if (!ci->platdata->dr_mode)
>>> +             ci->platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);
>>
>> same as previous one, let's keep it in the platform.
>
> Alex, have you made the conclusion with Felipe, whether we need DT support
> at core driver to handle such kinds of things or use platform data is ok?
> Last time, I remember he disagreed the way this patch uses.

He wanted everything to be fetched from the core driver, I wanted
most things to be fetched from the platform driver, we never came to a
common denominator, though. This (and the other one) patch is made to
fetch phy_mode and dr_mode from the core if it's not passed from the
platform driver, so pretty much Felipe's idea. The more I think about it
now, the more it makes sense to me too. For instance, this way we can
avoid any extra boilerplate platform code.

So, we're going to have it this way for now.

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

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

* Re: [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags
       [not found]                 ` <87ehcii5n0.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
@ 2013-06-04 10:09                   ` Peter Chen
       [not found]                     ` <CAL411-pyrFXxyEX_GAFRS5ubh_Pf2yWLZXYC3PJevu1WSJS78g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Peter Chen @ 2013-06-04 10:09 UTC (permalink / raw)
  To: Alexander Shishkin
  Cc: Michael Grzeschik, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	balbi-l0cyMroinI0, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Sascha Hauer

On Tue, Jun 4, 2013 at 5:31 PM, Alexander Shishkin
<alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> Peter Chen <hzpeterchen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> On Mon, Jun 3, 2013 at 8:37 PM, Alexander Shishkin
>> <alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
>>> Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:
>>>
>>>> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>>>>
>>>> Even if a chipidea core is otg capable the board may not. This allows
>>>
>>> "may not be"
>>>
>>>> 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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>>>> ---
>>>
>>> [snip]
>>>
>>>> +     if (!ci->platdata->dr_mode)
>>>> +             ci->platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);
>>>
>>> same as previous one, let's keep it in the platform.
>>
>> Alex, have you made the conclusion with Felipe, whether we need DT support
>> at core driver to handle such kinds of things or use platform data is ok?
>> Last time, I remember he disagreed the way this patch uses.
>
> He wanted everything to be fetched from the core driver, I wanted
> most things to be fetched from the platform driver, we never came to a
> common denominator, though. This (and the other one) patch is made to
> fetch phy_mode and dr_mode from the core if it's not passed from the
> platform driver, so pretty much Felipe's idea. The more I think about it
> now, the more it makes sense to me too. For instance, this way we can
> avoid any extra boilerplate platform code.
>
> So, we're going to have it this way for now.
>

For this patch, there may be wrong since it wants get the phy_mode and dr_mode
from the core DT node, but seems there is no core DT node at all, and the device
tree binding doc add dr_mode is for gluy layer.

OK, so you have accepted the way we pass something from glue layer DT
node, and using
ci->platdata->xxx (dr_mode, phy_mode, vbus, force_full_speed, etc) at
core driver, right?



--
BR,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags
       [not found]                     ` <CAL411-pyrFXxyEX_GAFRS5ubh_Pf2yWLZXYC3PJevu1WSJS78g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-06-04 11:09                       ` Alexander Shishkin
  0 siblings, 0 replies; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-04 11:09 UTC (permalink / raw)
  To: Peter Chen
  Cc: Michael Grzeschik, linux-usb@vger.kernel.org, balbi@ti.com,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Sascha Hauer

Peter Chen <hzpeterchen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> On Tue, Jun 4, 2013 at 5:31 PM, Alexander Shishkin
> <alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
>> Peter Chen <hzpeterchen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>>
>>> On Mon, Jun 3, 2013 at 8:37 PM, Alexander Shishkin
>>> <alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
>>>> Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:
>>>>
>>>>> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>>>>>
>>>>> Even if a chipidea core is otg capable the board may not. This allows
>>>>
>>>> "may not be"
>>>>
>>>>> 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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>>>>> ---
>>>>
>>>> [snip]
>>>>
>>>>> +     if (!ci->platdata->dr_mode)
>>>>> +             ci->platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);
>>>>
>>>> same as previous one, let's keep it in the platform.
>>>
>>> Alex, have you made the conclusion with Felipe, whether we need DT support
>>> at core driver to handle such kinds of things or use platform data is ok?
>>> Last time, I remember he disagreed the way this patch uses.
>>
>> He wanted everything to be fetched from the core driver, I wanted
>> most things to be fetched from the platform driver, we never came to a
>> common denominator, though. This (and the other one) patch is made to
>> fetch phy_mode and dr_mode from the core if it's not passed from the
>> platform driver, so pretty much Felipe's idea. The more I think about it
>> now, the more it makes sense to me too. For instance, this way we can
>> avoid any extra boilerplate platform code.
>>
>> So, we're going to have it this way for now.
>>
>
> For this patch, there may be wrong since it wants get the phy_mode and dr_mode
> from the core DT node, but seems there is no core DT node at all, and the device
> tree binding doc add dr_mode is for gluy layer.

I don't follow. In the previous patch it sets core's of_node to that of
platform glue, so here the core fetches phy_mode and dr_mode from the
platform device's of_node.

Of course, if the core driver is taking care of some of the DT
properties, it might make sense to document them as such, as opposed to
documenting them for each and every platform device, but I'll leave that
up to DT savants.

> OK, so you have accepted the way we pass something from glue layer DT
> node, and using
> ci->platdata->xxx (dr_mode, phy_mode, vbus, force_full_speed, etc) at
> core driver, right?

Yes, let's do it this way.

Another related matter is ownership of phys and clocks.

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

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

* Re: [PATCH 1/7] USB: add devicetree helpers for determining dr_mode and phy_type
       [not found]         ` <8761xvjrwt.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
@ 2013-06-04 13:01           ` Michael Grzeschik
       [not found]             ` <20130604130140.GF28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-06-04 13:01 UTC (permalink / raw)
  To: Alexander Shishkin
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

On Mon, Jun 03, 2013 at 03:32:50PM +0300, Alexander Shishkin wrote:
> Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:
> 
> > From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> >
> > This adds two little devicetree helper functions for determining the
> > dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from
> > the devicetree.
> 
> This one needs an ack from Felipe.

Right, we currently also wait for his answer in another thread.

http://www.spinics.net/lists/linux-usb/msg86906.html

> > Signed-off-by: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > ---
> >  drivers/usb/phy/Makefile |  1 +
> >  drivers/usb/phy/of.c     | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> >  drivers/usb/usb-common.c | 35 +++++++++++++++++++++++++++++++++++
> >  include/linux/usb/of.h   | 28 ++++++++++++++++++++++++++++
> >  include/linux/usb/otg.h  |  7 +++++++
> >  include/linux/usb/phy.h  |  9 +++++++++
> >  6 files changed, 127 insertions(+)
> >  create mode 100644 drivers/usb/phy/of.c
> >  create mode 100644 include/linux/usb/of.h
> >
> > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> > index a9169cb..070eca3 100644
> > --- a/drivers/usb/phy/Makefile
> > +++ b/drivers/usb/phy/Makefile
> > @@ -5,6 +5,7 @@
> >  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
> >  
> >  obj-$(CONFIG_USB_PHY)			+= phy.o
> > +obj-$(CONFIG_OF)			+= of.o
> >  
> >  # transceiver drivers, keep the list sorted
> >  
> > diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
> > new file mode 100644
> > index 0000000..e6f3b74
> > --- /dev/null
> > +++ b/drivers/usb/phy/of.c
> > @@ -0,0 +1,47 @@
> > +/*
> > + * USB of helper code
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + */
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/usb/of.h>
> > +#include <linux/usb/otg.h>
> > +
> > +static const char *usbphy_modes[] = {
> > +	[USBPHY_INTERFACE_MODE_UNKNOWN]	= "",
> > +	[USBPHY_INTERFACE_MODE_UTMI]	= "utmi",
> > +	[USBPHY_INTERFACE_MODE_UTMIW]	= "utmi_wide",
> > +	[USBPHY_INTERFACE_MODE_ULPI]	= "ulpi",
> > +	[USBPHY_INTERFACE_MODE_SERIAL]	= "serial",
> > +	[USBPHY_INTERFACE_MODE_HSIC]	= "hsic",
> > +};
> > +
> > +/**
> > + * of_usb_get_phy_mode - Get phy mode for given device_node
> > + * @np:	Pointer to the given device_node
> > + *
> > + * The function gets phy interface string from property 'phy_type',
> > + * and returns the correspondig enum usb_phy_interface
> > + */
> > +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
> > +{
> > +	const char *phy_type;
> > +	int err, i;
> > +
> > +	err = of_property_read_string(np, "phy_type", &phy_type);
> > +	if (err < 0)
> > +		return USBPHY_INTERFACE_MODE_UNKNOWN;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++)
> > +		if (!strcmp(phy_type, usbphy_modes[i]))
> > +			return i;
> > +
> > +	return USBPHY_INTERFACE_MODE_UNKNOWN;
> > +}
> > +EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
> > diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
> > index 0db0a91..027582d 100644
> > --- a/drivers/usb/usb-common.c
> > +++ b/drivers/usb/usb-common.c
> > @@ -13,7 +13,9 @@
> >  
> >  #include <linux/kernel.h>
> >  #include <linux/module.h>
> > +#include <linux/of.h>
> >  #include <linux/usb/ch9.h>
> > +#include <linux/usb/of.h>
> >  #include <linux/usb/otg.h>
> >  
> >  const char *usb_otg_state_string(enum usb_otg_state state)
> > @@ -79,4 +81,37 @@ const char *usb_state_string(enum usb_device_state state)
> >  }
> >  EXPORT_SYMBOL_GPL(usb_state_string);
> >  
> > +#ifdef CONFIG_OF
> > +static const char *usb_dr_modes[] = {
> > +	[USB_DR_MODE_UNKNOWN]		= "",
> > +	[USB_DR_MODE_HOST]		= "host",
> > +	[USB_DR_MODE_PERIPHERAL]	= "peripheral",
> > +	[USB_DR_MODE_OTG]		= "otg",
> > +};
> > +
> > +/**
> > + * of_usb_get_dr_mode - Get dual role mode for given device_node
> > + * @np:	Pointer to the given device_node
> > + *
> > + * The function gets phy interface string from property 'dr_mode',
> > + * and returns the correspondig enum usb_dr_mode
> > + */
> > +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
> > +{
> > +	const char *dr_mode;
> > +	int err, i;
> > +
> > +	err = of_property_read_string(np, "dr_mode", &dr_mode);
> > +	if (err < 0)
> > +		return USB_DR_MODE_UNKNOWN;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
> > +		if (!strcmp(dr_mode, usb_dr_modes[i]))
> > +			return i;
> > +
> > +	return USB_DR_MODE_UNKNOWN;
> > +}
> > +EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
> > +#endif
> > +
> >  MODULE_LICENSE("GPL");
> > diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
> > new file mode 100644
> > index 0000000..e460a24
> > --- /dev/null
> > +++ b/include/linux/usb/of.h
> > @@ -0,0 +1,28 @@
> > +/*
> > + * OF helpers for usb devices.
> > + *
> > + * This file is released under the GPLv2
> > + */
> > +
> > +#ifndef __LINUX_USB_OF_H
> > +#define __LINUX_USB_OF_H
> > +
> > +#include <linux/usb/otg.h>
> > +#include <linux/usb/phy.h>
> > +
> > +#ifdef CONFIG_OF
> > +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np);
> > +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
> > +#else
> > +static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
> > +{
> > +	return USBPHY_INTERFACE_MODE_UNKNOWN;
> > +}
> > +
> > +static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
> > +{
> > +	return USB_DR_MODE_UNKNOWN;
> > +}
> > +#endif
> > +
> > +#endif /* __LINUX_USB_OF_H */
> > diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
> > index 291e01b..154332b 100644
> > --- a/include/linux/usb/otg.h
> > +++ b/include/linux/usb/otg.h
> > @@ -92,4 +92,11 @@ otg_start_srp(struct usb_otg *otg)
> >  /* for OTG controller drivers (and maybe other stuff) */
> >  extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
> >  
> > +enum usb_dr_mode {
> > +	USB_DR_MODE_UNKNOWN,
> > +	USB_DR_MODE_HOST,
> > +	USB_DR_MODE_PERIPHERAL,
> > +	USB_DR_MODE_OTG,
> > +};
> > +
> 
> I would suggest turning this into a bitmask, so that further tests look
> like
> 
>   if (dr_mode & USB_DR_MODE_HOST) {...}
>
> instead of how they currently look like in the other patch.

You mean 32 modes will be enough? :)

These helpers are derived from drivers/of/of_net.c. Its enums are
commonly used all over the kernel. We should align to already used
coding patterns. I also prefer to switch over an enum than compare bits.

Thanks,
Michael

-- 
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 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/7] USB: add devicetree helpers for determining dr_mode and phy_type
       [not found]             ` <20130604130140.GF28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-04 20:25               ` Felipe Balbi
  0 siblings, 0 replies; 29+ messages in thread
From: Felipe Balbi @ 2013-06-04 20:25 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: Michael Grzeschik, Alexander Shishkin,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ


[-- Attachment #1.1: Type: text/plain, Size: 7888 bytes --]

HI,

On Tue, Jun 04, 2013 at 03:01:40PM +0200, Michael Grzeschik wrote:
> On Mon, Jun 03, 2013 at 03:32:50PM +0300, Alexander Shishkin wrote:
> > Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:
> > 
> > > From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > >
> > > This adds two little devicetree helper functions for determining the
> > > dr_mode (host, peripheral, otg) and phy_type (utmi, ulpi,...) from
> > > the devicetree.
> > 
> > This one needs an ack from Felipe.
> 
> Right, we currently also wait for his answer in another thread.
> 
> http://www.spinics.net/lists/linux-usb/msg86906.html

heh, it's so difficult to take vacations :-p

I think this patch is good to go.

Acked-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>


> > > Signed-off-by: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > > Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > > Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > > ---
> > >  drivers/usb/phy/Makefile |  1 +
> > >  drivers/usb/phy/of.c     | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> > >  drivers/usb/usb-common.c | 35 +++++++++++++++++++++++++++++++++++
> > >  include/linux/usb/of.h   | 28 ++++++++++++++++++++++++++++
> > >  include/linux/usb/otg.h  |  7 +++++++
> > >  include/linux/usb/phy.h  |  9 +++++++++
> > >  6 files changed, 127 insertions(+)
> > >  create mode 100644 drivers/usb/phy/of.c
> > >  create mode 100644 include/linux/usb/of.h
> > >
> > > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> > > index a9169cb..070eca3 100644
> > > --- a/drivers/usb/phy/Makefile
> > > +++ b/drivers/usb/phy/Makefile
> > > @@ -5,6 +5,7 @@
> > >  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
> > >  
> > >  obj-$(CONFIG_USB_PHY)			+= phy.o
> > > +obj-$(CONFIG_OF)			+= of.o
> > >  
> > >  # transceiver drivers, keep the list sorted
> > >  
> > > diff --git a/drivers/usb/phy/of.c b/drivers/usb/phy/of.c
> > > new file mode 100644
> > > index 0000000..e6f3b74
> > > --- /dev/null
> > > +++ b/drivers/usb/phy/of.c
> > > @@ -0,0 +1,47 @@
> > > +/*
> > > + * USB of helper code
> > > + *
> > > + * This program is free software; you can redistribute it and/or modify
> > > + * it under the terms of the GNU General Public License as published by
> > > + * the Free Software Foundation; either version 2 of the License, or
> > > + * (at your option) any later version.
> > > + */
> > > +
> > > +#include <linux/kernel.h>
> > > +#include <linux/module.h>
> > > +#include <linux/of.h>
> > > +#include <linux/usb/of.h>
> > > +#include <linux/usb/otg.h>
> > > +
> > > +static const char *usbphy_modes[] = {
> > > +	[USBPHY_INTERFACE_MODE_UNKNOWN]	= "",
> > > +	[USBPHY_INTERFACE_MODE_UTMI]	= "utmi",
> > > +	[USBPHY_INTERFACE_MODE_UTMIW]	= "utmi_wide",
> > > +	[USBPHY_INTERFACE_MODE_ULPI]	= "ulpi",
> > > +	[USBPHY_INTERFACE_MODE_SERIAL]	= "serial",
> > > +	[USBPHY_INTERFACE_MODE_HSIC]	= "hsic",
> > > +};
> > > +
> > > +/**
> > > + * of_usb_get_phy_mode - Get phy mode for given device_node
> > > + * @np:	Pointer to the given device_node
> > > + *
> > > + * The function gets phy interface string from property 'phy_type',
> > > + * and returns the correspondig enum usb_phy_interface
> > > + */
> > > +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
> > > +{
> > > +	const char *phy_type;
> > > +	int err, i;
> > > +
> > > +	err = of_property_read_string(np, "phy_type", &phy_type);
> > > +	if (err < 0)
> > > +		return USBPHY_INTERFACE_MODE_UNKNOWN;
> > > +
> > > +	for (i = 0; i < ARRAY_SIZE(usbphy_modes); i++)
> > > +		if (!strcmp(phy_type, usbphy_modes[i]))
> > > +			return i;
> > > +
> > > +	return USBPHY_INTERFACE_MODE_UNKNOWN;
> > > +}
> > > +EXPORT_SYMBOL_GPL(of_usb_get_phy_mode);
> > > diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
> > > index 0db0a91..027582d 100644
> > > --- a/drivers/usb/usb-common.c
> > > +++ b/drivers/usb/usb-common.c
> > > @@ -13,7 +13,9 @@
> > >  
> > >  #include <linux/kernel.h>
> > >  #include <linux/module.h>
> > > +#include <linux/of.h>
> > >  #include <linux/usb/ch9.h>
> > > +#include <linux/usb/of.h>
> > >  #include <linux/usb/otg.h>
> > >  
> > >  const char *usb_otg_state_string(enum usb_otg_state state)
> > > @@ -79,4 +81,37 @@ const char *usb_state_string(enum usb_device_state state)
> > >  }
> > >  EXPORT_SYMBOL_GPL(usb_state_string);
> > >  
> > > +#ifdef CONFIG_OF
> > > +static const char *usb_dr_modes[] = {
> > > +	[USB_DR_MODE_UNKNOWN]		= "",
> > > +	[USB_DR_MODE_HOST]		= "host",
> > > +	[USB_DR_MODE_PERIPHERAL]	= "peripheral",
> > > +	[USB_DR_MODE_OTG]		= "otg",
> > > +};
> > > +
> > > +/**
> > > + * of_usb_get_dr_mode - Get dual role mode for given device_node
> > > + * @np:	Pointer to the given device_node
> > > + *
> > > + * The function gets phy interface string from property 'dr_mode',
> > > + * and returns the correspondig enum usb_dr_mode
> > > + */
> > > +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
> > > +{
> > > +	const char *dr_mode;
> > > +	int err, i;
> > > +
> > > +	err = of_property_read_string(np, "dr_mode", &dr_mode);
> > > +	if (err < 0)
> > > +		return USB_DR_MODE_UNKNOWN;
> > > +
> > > +	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
> > > +		if (!strcmp(dr_mode, usb_dr_modes[i]))
> > > +			return i;
> > > +
> > > +	return USB_DR_MODE_UNKNOWN;
> > > +}
> > > +EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
> > > +#endif
> > > +
> > >  MODULE_LICENSE("GPL");
> > > diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
> > > new file mode 100644
> > > index 0000000..e460a24
> > > --- /dev/null
> > > +++ b/include/linux/usb/of.h
> > > @@ -0,0 +1,28 @@
> > > +/*
> > > + * OF helpers for usb devices.
> > > + *
> > > + * This file is released under the GPLv2
> > > + */
> > > +
> > > +#ifndef __LINUX_USB_OF_H
> > > +#define __LINUX_USB_OF_H
> > > +
> > > +#include <linux/usb/otg.h>
> > > +#include <linux/usb/phy.h>
> > > +
> > > +#ifdef CONFIG_OF
> > > +enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np);
> > > +enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
> > > +#else
> > > +static inline enum usb_phy_interface of_usb_get_phy_mode(struct device_node *np)
> > > +{
> > > +	return USBPHY_INTERFACE_MODE_UNKNOWN;
> > > +}
> > > +
> > > +static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
> > > +{
> > > +	return USB_DR_MODE_UNKNOWN;
> > > +}
> > > +#endif
> > > +
> > > +#endif /* __LINUX_USB_OF_H */
> > > diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
> > > index 291e01b..154332b 100644
> > > --- a/include/linux/usb/otg.h
> > > +++ b/include/linux/usb/otg.h
> > > @@ -92,4 +92,11 @@ otg_start_srp(struct usb_otg *otg)
> > >  /* for OTG controller drivers (and maybe other stuff) */
> > >  extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
> > >  
> > > +enum usb_dr_mode {
> > > +	USB_DR_MODE_UNKNOWN,
> > > +	USB_DR_MODE_HOST,
> > > +	USB_DR_MODE_PERIPHERAL,
> > > +	USB_DR_MODE_OTG,
> > > +};
> > > +
> > 
> > I would suggest turning this into a bitmask, so that further tests look
> > like
> > 
> >   if (dr_mode & USB_DR_MODE_HOST) {...}
> >
> > instead of how they currently look like in the other patch.
> 
> You mean 32 modes will be enough? :)
> 
> These helpers are derived from drivers/of/of_net.c. Its enums are
> commonly used all over the kernel. We should align to already used
> coding patterns. I also prefer to switch over an enum than compare bits.

I will agree with you Michael here. Besides, bitmasks would make OTG
mode useless. Matter of taste, I guess.

-- 
balbi

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function
       [not found]     ` <1370025529-7414-3-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-05 12:29       ` Michael Grzeschik
       [not found]         ` <20130605122906.GB20095-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Michael Grzeschik @ 2013-06-05 12:29 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

Hi Alexander,

On Fri, May 31, 2013 at 08:38:44PM +0200, Michael Grzeschik wrote:
> From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> 
> The pdata structure gets copied anyway inside ci13xxx_add_device
> by platform_device_add. We don't need to have it static.
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Reviewed-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> ---
>  drivers/usb/chipidea/ci13xxx_imx.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
> index 73f9d5f..4d64541 100644
> --- a/drivers/usb/chipidea/ci13xxx_imx.c
> +++ b/drivers/usb/chipidea/ci13xxx_imx.c
> @@ -88,17 +88,16 @@ 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 = {
> +		.name		= "ci13xxx_imx",
> +		.capoffset	= DEF_CAPOFFSET,
> +		.flags		= CI13XXX_REQUIRE_TRANSCEIVER |
> +				  CI13XXX_PULLUP_ON_VBUS |
> +				  CI13XXX_DISABLE_STREAMING,
> +	};
>  	struct platform_device *plat_ci, *phy_pdev;
>  	struct device_node *phy_np;
>  	struct resource *res;
> @@ -171,7 +170,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 = &pdev->dev.coherent_dma_mask;
> @@ -189,7 +188,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,

This and Patch 5, 6 and 7 of this series doesn't got much to do with
the the dr_mode/phy_type features. I will repost them in another series.
Beside the others, this one is missing any comments. If it's already good
to be taken, will you directly apply it?

Regards,
Michael

-- 
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 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function
       [not found]         ` <20130605122906.GB20095-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-06-05 13:04           ` Alexander Shishkin
  0 siblings, 0 replies; 29+ messages in thread
From: Alexander Shishkin @ 2013-06-05 13:04 UTC (permalink / raw)
  To: Michael Grzeschik, linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: balbi-l0cyMroinI0, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

Michael Grzeschik <mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> writes:

> Hi Alexander,
>
> On Fri, May 31, 2013 at 08:38:44PM +0200, Michael Grzeschik wrote:
>> From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> 
>> The pdata structure gets copied anyway inside ci13xxx_add_device
>> by platform_device_add. We don't need to have it static.
>> 
>> Signed-off-by: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> Reviewed-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>> ---
>>  drivers/usb/chipidea/ci13xxx_imx.c | 19 +++++++++----------
>>  1 file changed, 9 insertions(+), 10 deletions(-)
>> 
>> diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
>> index 73f9d5f..4d64541 100644
>> --- a/drivers/usb/chipidea/ci13xxx_imx.c
>> +++ b/drivers/usb/chipidea/ci13xxx_imx.c
>> @@ -88,17 +88,16 @@ 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 = {
>> +		.name		= "ci13xxx_imx",
>> +		.capoffset	= DEF_CAPOFFSET,
>> +		.flags		= CI13XXX_REQUIRE_TRANSCEIVER |
>> +				  CI13XXX_PULLUP_ON_VBUS |
>> +				  CI13XXX_DISABLE_STREAMING,
>> +	};
>>  	struct platform_device *plat_ci, *phy_pdev;
>>  	struct device_node *phy_np;
>>  	struct resource *res;
>> @@ -171,7 +170,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 = &pdev->dev.coherent_dma_mask;
>> @@ -189,7 +188,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,
>
> This and Patch 5, 6 and 7 of this series doesn't got much to do with
> the the dr_mode/phy_type features. I will repost them in another series.
> Beside the others, this one is missing any comments. If it's already good
> to be taken, will you directly apply it?

Ok, I'll take those. I'll let you know if there are any conflicts. :)

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

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

* Re: [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling
       [not found]     ` <1370025529-7414-4-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-06-03 12:35       ` Alexander Shishkin
@ 2013-06-06 10:54       ` Michael Grzeschik
  1 sibling, 0 replies; 29+ messages in thread
From: Michael Grzeschik @ 2013-06-06 10:54 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA, balbi-l0cyMroinI0,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Michael Grzeschik

Hi,

On Fri, May 31, 2013 at 08:38:45PM +0200, Michael Grzeschik wrote:
> From: Michael Grzeschik <m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> 
> This patch makes it possible to configure the PTW, PTS and STS 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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
>  .../devicetree/bindings/usb/ci13xxx-imx.txt        |  5 +++
>  drivers/usb/chipidea/bits.h                        | 15 ++++++-
>  drivers/usb/chipidea/core.c                        | 49 ++++++++++++++++++++++
>  include/linux/usb/chipidea.h                       |  1 +
>  4 files changed, 69 insertions(+), 1 deletion(-)
> 

[snip]

> diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
> index 050de85..93efe4e 100644
> --- a/drivers/usb/chipidea/bits.h
> +++ b/drivers/usb/chipidea/bits.h

[snip]

>  /**
>   * hw_device_reset: resets chip (execute without interruption)
>   * @ci: the controller
> @@ -369,6 +410,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> +	if (!dev->of_node && dev->parent)
> +		dev->of_node = dev->parent->of_node;
> +
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	base = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(base))
> @@ -408,6 +452,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> +	if (!ci->platdata->phy_mode)
> +		ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
> +
>  	/* initialize role(s) before the interrupt is requested */
>  	ret = ci_hdrc_host_init(ci);
>  	if (ret)
> @@ -434,6 +481,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>  			: CI_ROLE_GADGET;
>  	}
>  
> +	hw_phymode_configure(ci);
> +

I just realised that this call has to be moved to hw_device_reset. As
otherwise we will loose the configuration on any OTG case while changing
from Host to Device and vice versa. The datasheet says that its value
got reset on every controller reset. I will fix it in the next series.

>  	ret = ci_role_start(ci, ci->role);
>  	if (ret) {
>  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);


Michael

-- 
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 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2013-06-06 10:54 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-31 18:38 [PATCH v6 0/7] USB: add devicetree helpers for determining dr_mode and phy_type Michael Grzeschik
     [not found] ` <1370025529-7414-1-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-05-31 18:38   ` [PATCH 1/7] " Michael Grzeschik
     [not found]     ` <1370025529-7414-2-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:32       ` Alexander Shishkin
     [not found]         ` <8761xvjrwt.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2013-06-04 13:01           ` Michael Grzeschik
     [not found]             ` <20130604130140.GF28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-04 20:25               ` Felipe Balbi
2013-05-31 18:38   ` [PATCH 2/7] USB: chipidea: ci13xxx-imx: move static pdata into probe function Michael Grzeschik
     [not found]     ` <1370025529-7414-3-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-05 12:29       ` Michael Grzeschik
     [not found]         ` <20130605122906.GB20095-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-05 13:04           ` Alexander Shishkin
2013-05-31 18:38   ` [PATCH 3/7] USB: chipidea: add PTW, PTS and STS handling Michael Grzeschik
     [not found]     ` <1370025529-7414-4-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:35       ` Alexander Shishkin
     [not found]         ` <8738szjrs6.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2013-06-03 16:11           ` Michael Grzeschik
     [not found]             ` <20130603161136.GB28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-04  9:22               ` Alexander Shishkin
2013-06-06 10:54       ` Michael Grzeschik
2013-05-31 18:38   ` [PATCH 4/7] USB chipidea: introduce dual role mode pdata flags Michael Grzeschik
     [not found]     ` <1370025529-7414-5-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:37       ` Alexander Shishkin
     [not found]         ` <87zjv7id52.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2013-06-04  1:42           ` Peter Chen
     [not found]             ` <CAL411-pMnJC55M3n5bAuffH3pwRZTzhBfDiEfT+egtGN29c7uw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-04  9:31               ` Alexander Shishkin
     [not found]                 ` <87ehcii5n0.fsf-qxRn5AmX6ZD9BXuAQUXR0fooFf0ArEBIu+b9c/7xato@public.gmane.org>
2013-06-04 10:09                   ` Peter Chen
     [not found]                     ` <CAL411-pyrFXxyEX_GAFRS5ubh_Pf2yWLZXYC3PJevu1WSJS78g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-04 11:09                       ` Alexander Shishkin
2013-05-31 18:38   ` [PATCH 5/7] USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy Michael Grzeschik
     [not found]     ` <1370025529-7414-6-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-05-31 19:23       ` Sergei Shtylyov
2013-06-03 12:39       ` Alexander Shishkin
2013-05-31 18:38   ` [PATCH 6/7] usb: chipidea: udc: add force-full-speed option Michael Grzeschik
     [not found]     ` <1370025529-7414-7-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-01  7:39       ` Sascha Hauer
     [not found]         ` <20130601073933.GK32299-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-01  8:19           ` Michael Grzeschik
     [not found]             ` <20130601081932.GA28181-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-01  9:21               ` Sascha Hauer
     [not found]                 ` <20130601092151.GP32299-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:40                   ` Alexander Shishkin
2013-05-31 18:38   ` [PATCH 7/7] usb: chipidea: usbmisc: use module_platform_driver Michael Grzeschik
     [not found]     ` <1370025529-7414-8-git-send-email-mgr-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-03 12:41       ` Alexander Shishkin

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.