linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/7] usb: dwc3-omap: add dt support
@ 2012-10-15 13:27 Kishon Vijay Abraham I
  2012-10-15 13:27 ` [PATCH v4 1/7] usb: dwc3-omap: use device_for_each_child to handle child removal Kishon Vijay Abraham I
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2012-10-15 13:27 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: sshtylyov

This patch series adds dt support to dwc3 core and fixes few minor
stuff in dwc3-omap glue to get dwc3 working.

While at that it also uses *of_platform* to create the child device
(dwc3-core) and fixes to use runtime API's to enable clock and write
to SYSCONFIG register.

Changes from v3:
* rebased to latest commit in balbi's tree
* Fixed few typos in the commit log
* Added *extern* keyword for dwc3_omap_mailbox function declaration

Changes from v2:
* Fixed Sergei comment to use of_property_read_u32 insted of of_get_property

Changes from v1:
* made device_for_each_child() as a seperate patch
* made all other minor fixes wrt typos and function renames

This patch series is developed on:
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git dwc3

Kishon Vijay Abraham I (7):
  usb: dwc3-omap: use device_for_each_child to handle child removal
  usb: dwc3-omap: use of_platform API to create dwc3 core pdev
  usb: dwc3-omap: use runtime API's to enable clocks
  usb: dwc3-omap: Remove explicit writes to SYSCONFIG register
  usb: dwc3-omap: Add an API to write to dwc mailbox
  usb: dwc3-omap: Minor fixes to get dt working
  usb: dwc3: core: add dt support for dwc3 core

 Documentation/devicetree/bindings/usb/dwc3.txt |   23 ++++
 drivers/usb/dwc3/core.c                        |   14 +-
 drivers/usb/dwc3/dwc3-omap.c                   |  172 +++++++++++++-----------
 include/linux/usb/dwc3-omap.h                  |   30 +++++
 4 files changed, 162 insertions(+), 77 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/dwc3.txt
 create mode 100644 include/linux/usb/dwc3-omap.h

-- 
1.7.9.5


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

* [PATCH v4 1/7] usb: dwc3-omap: use device_for_each_child to handle child removal
  2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
@ 2012-10-15 13:27 ` Kishon Vijay Abraham I
  2012-10-15 13:27 ` [PATCH v4 2/7] usb: dwc3-omap: use of_platform API to create dwc3 core pdev Kishon Vijay Abraham I
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2012-10-15 13:27 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: sshtylyov

Used device_for_each_child() to handle child device (dwc3 core) removal
during devexit of dwc3 omap.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index ee57a10..d51c69c 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -262,6 +262,15 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
 	return IRQ_HANDLED;
 }
 
+static int dwc3_omap_remove_core(struct device *dev, void *c)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+
+	platform_device_unregister(pdev);
+
+	return 0;
+}
+
 static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 {
 	struct dwc3_omap_data	*pdata = pdev->dev.platform_data;
@@ -434,11 +443,11 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev)
 {
 	struct dwc3_omap	*omap = platform_get_drvdata(pdev);
 
-	platform_device_unregister(omap->dwc3);
 	platform_device_unregister(omap->usb2_phy);
 	platform_device_unregister(omap->usb3_phy);
 
 	dwc3_put_device_id(omap->dwc3->id);
+	device_for_each_child(&pdev->dev, NULL, dwc3_omap_remove_core);
 
 	return 0;
 }
-- 
1.7.9.5


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

* [PATCH v4 2/7] usb: dwc3-omap: use of_platform API to create dwc3 core pdev
  2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
  2012-10-15 13:27 ` [PATCH v4 1/7] usb: dwc3-omap: use device_for_each_child to handle child removal Kishon Vijay Abraham I
@ 2012-10-15 13:27 ` Kishon Vijay Abraham I
  2012-10-25 14:04   ` Benoit Cousson
  2012-10-15 13:27 ` [PATCH v4 3/7] usb: dwc3-omap: use runtime API's to enable clocks Kishon Vijay Abraham I
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2012-10-15 13:27 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: sshtylyov

Used of_platform_populate() to populate dwc3 core platform_device
from device tree data. Since now the allocation of unique device id is
handled by of_*, removed the call to dwc3_get_device_id.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c |   50 +++++++++---------------------------------
 1 file changed, 10 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index d51c69c..4aaeec4 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -47,6 +47,7 @@
 #include <linux/ioport.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/of_platform.h>
 
 #include <linux/usb/otg.h>
 #include <linux/usb/nop-usb-xceiv.h>
@@ -133,7 +134,6 @@ struct dwc3_omap {
 	/* device lock */
 	spinlock_t		lock;
 
-	struct platform_device	*dwc3;
 	struct platform_device	*usb2_phy;
 	struct platform_device	*usb3_phy;
 	struct device		*dev;
@@ -276,12 +276,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 	struct dwc3_omap_data	*pdata = pdev->dev.platform_data;
 	struct device_node	*node = pdev->dev.of_node;
 
-	struct platform_device	*dwc3;
 	struct dwc3_omap	*omap;
 	struct resource		*res;
 	struct device		*dev = &pdev->dev;
 
-	int			devid;
 	int			size;
 	int			ret = -ENOMEM;
 	int			irq;
@@ -324,34 +322,19 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	devid = dwc3_get_device_id();
-	if (devid < 0)
-		return -ENODEV;
-
-	dwc3 = platform_device_alloc("dwc3", devid);
-	if (!dwc3) {
-		dev_err(dev, "couldn't allocate dwc3 device\n");
-		goto err1;
-	}
-
 	context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL);
 	if (!context) {
 		dev_err(dev, "couldn't allocate dwc3 context memory\n");
-		goto err2;
+		return -ENOMEM;
 	}
 
 	spin_lock_init(&omap->lock);
-	dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask);
 
-	dwc3->dev.parent = dev;
-	dwc3->dev.dma_mask = dev->dma_mask;
-	dwc3->dev.dma_parms = dev->dma_parms;
 	omap->resource_size = resource_size(res);
 	omap->context	= context;
 	omap->dev	= dev;
 	omap->irq	= irq;
 	omap->base	= base;
-	omap->dwc3	= dwc3;
 
 	reg = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
 
@@ -396,7 +379,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(dev, "failed to request IRQ #%d --> %d\n",
 				omap->irq, ret);
-		goto err2;
+		return ret;
 	}
 
 	/* enable all IRQs */
@@ -415,28 +398,16 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 
 	dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_1, reg);
 
-	ret = platform_device_add_resources(dwc3, pdev->resource,
-			pdev->num_resources);
-	if (ret) {
-		dev_err(dev, "couldn't add resources to dwc3 device\n");
-		goto err2;
-	}
-
-	ret = platform_device_add(dwc3);
-	if (ret) {
-		dev_err(dev, "failed to register dwc3 device\n");
-		goto err2;
+	if (node) {
+		ret = of_platform_populate(node, NULL, NULL, dev);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"failed to add create dwc3 core\n");
+			return ret;
+		}
 	}
 
 	return 0;
-
-err2:
-	platform_device_put(dwc3);
-
-err1:
-	dwc3_put_device_id(devid);
-
-	return ret;
 }
 
 static int __devexit dwc3_omap_remove(struct platform_device *pdev)
@@ -446,7 +417,6 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev)
 	platform_device_unregister(omap->usb2_phy);
 	platform_device_unregister(omap->usb3_phy);
 
-	dwc3_put_device_id(omap->dwc3->id);
 	device_for_each_child(&pdev->dev, NULL, dwc3_omap_remove_core);
 
 	return 0;
-- 
1.7.9.5


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

* [PATCH v4 3/7] usb: dwc3-omap: use runtime API's to enable clocks
  2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
  2012-10-15 13:27 ` [PATCH v4 1/7] usb: dwc3-omap: use device_for_each_child to handle child removal Kishon Vijay Abraham I
  2012-10-15 13:27 ` [PATCH v4 2/7] usb: dwc3-omap: use of_platform API to create dwc3 core pdev Kishon Vijay Abraham I
@ 2012-10-15 13:27 ` Kishon Vijay Abraham I
  2012-10-15 13:27 ` [PATCH v4 4/7] usb: dwc3-omap: Remove explicit writes to SYSCONFIG register Kishon Vijay Abraham I
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2012-10-15 13:27 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: sshtylyov

Before accessing any register, runtime API's should be invoked to enable
the clocks. runtime API's are added here to prevent abort during register
access.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 4aaeec4..1fdf7e2 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -43,6 +43,7 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/dwc3-omap.h>
+#include <linux/pm_runtime.h>
 #include <linux/dma-mapping.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
@@ -336,6 +337,13 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 	omap->irq	= irq;
 	omap->base	= base;
 
+	pm_runtime_enable(dev);
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0) {
+		dev_err(dev, "get_sync failed with err %d\n", ret);
+		return ret;
+	}
+
 	reg = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
 
 	utmi_mode = of_get_property(node, "utmi-mode", &size);
@@ -417,6 +425,9 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev)
 	platform_device_unregister(omap->usb2_phy);
 	platform_device_unregister(omap->usb3_phy);
 
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
+
 	device_for_each_child(&pdev->dev, NULL, dwc3_omap_remove_core);
 
 	return 0;
-- 
1.7.9.5


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

* [PATCH v4 4/7] usb: dwc3-omap: Remove explicit writes to SYSCONFIG register
  2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
                   ` (2 preceding siblings ...)
  2012-10-15 13:27 ` [PATCH v4 3/7] usb: dwc3-omap: use runtime API's to enable clocks Kishon Vijay Abraham I
@ 2012-10-15 13:27 ` Kishon Vijay Abraham I
  2012-10-15 13:27 ` [PATCH v4 5/7] usb: dwc3-omap: Add an API to write to dwc mailbox Kishon Vijay Abraham I
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2012-10-15 13:27 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: sshtylyov

The runtime API's takes care of setting the SYSCONFIG register with
appropriate values. Hence explicit writes to SYSCONFIG register is
removed.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c |   26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 1fdf7e2..edc7292 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -80,23 +80,6 @@
 
 /* SYSCONFIG REGISTER */
 #define USBOTGSS_SYSCONFIG_DMADISABLE		(1 << 16)
-#define USBOTGSS_SYSCONFIG_STANDBYMODE(x)	((x) << 4)
-
-#define USBOTGSS_STANDBYMODE_FORCE_STANDBY	0
-#define USBOTGSS_STANDBYMODE_NO_STANDBY		1
-#define USBOTGSS_STANDBYMODE_SMART_STANDBY	2
-#define USBOTGSS_STANDBYMODE_SMART_WAKEUP	3
-
-#define USBOTGSS_STANDBYMODE_MASK		(0x03 << 4)
-
-#define USBOTGSS_SYSCONFIG_IDLEMODE(x)		((x) << 2)
-
-#define USBOTGSS_IDLEMODE_FORCE_IDLE		0
-#define USBOTGSS_IDLEMODE_NO_IDLE		1
-#define USBOTGSS_IDLEMODE_SMART_IDLE		2
-#define USBOTGSS_IDLEMODE_SMART_WAKEUP		3
-
-#define USBOTGSS_IDLEMODE_MASK			(0x03 << 2)
 
 /* IRQ_EOI REGISTER */
 #define USBOTGSS_IRQ_EOI_LINE_NUMBER		(1 << 0)
@@ -373,15 +356,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 	reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
 	omap->dma_status = !!(reg & USBOTGSS_SYSCONFIG_DMADISABLE);
 
-	/* Set No-Idle and No-Standby */
-	reg &= ~(USBOTGSS_STANDBYMODE_MASK
-			| USBOTGSS_IDLEMODE_MASK);
-
-	reg |= (USBOTGSS_SYSCONFIG_STANDBYMODE(USBOTGSS_STANDBYMODE_NO_STANDBY)
-		| USBOTGSS_SYSCONFIG_IDLEMODE(USBOTGSS_IDLEMODE_NO_IDLE));
-
-	dwc3_omap_writel(omap->base, USBOTGSS_SYSCONFIG, reg);
-
 	ret = devm_request_irq(dev, omap->irq, dwc3_omap_interrupt, 0,
 			"dwc3-omap", omap);
 	if (ret) {
-- 
1.7.9.5


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

* [PATCH v4 5/7] usb: dwc3-omap: Add an API to write to dwc mailbox
  2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
                   ` (3 preceding siblings ...)
  2012-10-15 13:27 ` [PATCH v4 4/7] usb: dwc3-omap: Remove explicit writes to SYSCONFIG register Kishon Vijay Abraham I
@ 2012-10-15 13:27 ` Kishon Vijay Abraham I
  2012-10-15 13:27 ` [PATCH v4 6/7] usb: dwc3-omap: Minor fixes to get dt working Kishon Vijay Abraham I
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2012-10-15 13:27 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: sshtylyov

Add an API in the omap glue layer to write to the mailbox register which
can be used by comparator driver(twl). To pass the detection of the attached
device (signified by VBUS, ID) to the dwc3 core, dwc3 glue has to write
to the mailbox regiter.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c  |   60 +++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/dwc3-omap.h |   30 +++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 include/linux/usb/dwc3-omap.h

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index edc7292..b84ddf3 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -43,6 +43,7 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/dwc3-omap.h>
+#include <linux/usb/dwc3-omap.h>
 #include <linux/pm_runtime.h>
 #include <linux/dma-mapping.h>
 #include <linux/ioport.h>
@@ -131,6 +132,8 @@ struct dwc3_omap {
 	u32			dma_status:1;
 };
 
+struct dwc3_omap		*_omap;
+
 static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset)
 {
 	return readl(base + offset);
@@ -141,6 +144,57 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
 	writel(value, base + offset);
 }
 
+void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
+{
+	u32			val;
+	struct dwc3_omap	*omap = _omap;
+
+	switch (status) {
+	case OMAP_DWC3_ID_GROUND:
+		dev_dbg(omap->dev, "ID GND\n");
+
+		val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
+		val &= ~(USBOTGSS_UTMI_OTG_STATUS_IDDIG
+				| USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
+				| USBOTGSS_UTMI_OTG_STATUS_SESSEND);
+		val |= USBOTGSS_UTMI_OTG_STATUS_SESSVALID
+				| USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT;
+		dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, val);
+		break;
+
+	case OMAP_DWC3_VBUS_VALID:
+		dev_dbg(omap->dev, "VBUS Connect\n");
+
+		val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
+		val &= ~USBOTGSS_UTMI_OTG_STATUS_SESSEND;
+		val |= USBOTGSS_UTMI_OTG_STATUS_IDDIG
+				| USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
+				| USBOTGSS_UTMI_OTG_STATUS_SESSVALID
+				| USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT;
+		dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, val);
+		break;
+
+	case OMAP_DWC3_ID_FLOAT:
+	case OMAP_DWC3_VBUS_OFF:
+		dev_dbg(omap->dev, "VBUS Disconnect\n");
+
+		val = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
+		val &= ~(USBOTGSS_UTMI_OTG_STATUS_SESSVALID
+				| USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
+				| USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT);
+		val |= USBOTGSS_UTMI_OTG_STATUS_SESSEND
+				| USBOTGSS_UTMI_OTG_STATUS_IDDIG;
+		dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, val);
+		break;
+
+	default:
+		dev_dbg(omap->dev, "ID float\n");
+	}
+
+	return;
+}
+EXPORT_SYMBOL_GPL(dwc3_omap_mailbox);
+
 static int __devinit dwc3_omap_register_phys(struct dwc3_omap *omap)
 {
 	struct nop_usb_xceiv_platform_data pdata;
@@ -320,6 +374,12 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 	omap->irq	= irq;
 	omap->base	= base;
 
+	/*
+	 * REVISIT if we ever have two instances of the wrapper, we will be
+	 * in big trouble
+	 */
+	_omap	= omap;
+
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
diff --git a/include/linux/usb/dwc3-omap.h b/include/linux/usb/dwc3-omap.h
new file mode 100644
index 0000000..1107d8c
--- /dev/null
+++ b/include/linux/usb/dwc3-omap.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011-2012 by Texas Instruments
+ *
+ * The Inventra Controller Driver for Linux is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU
+ * General Public License version 2 as published by the Free Software
+ * Foundation.
+ */
+
+#ifndef __DWC3_OMAP_H__
+#define __DWC3_OMAP_H__
+
+enum omap_dwc3_vbus_id_status {
+	OMAP_DWC3_UNKNOWN = 0,
+	OMAP_DWC3_ID_GROUND,
+	OMAP_DWC3_ID_FLOAT,
+	OMAP_DWC3_VBUS_VALID,
+	OMAP_DWC3_VBUS_OFF,
+};
+
+#if (defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_DWC3_MODULE))
+extern void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status);
+#else
+static inline void dwc3_omap_mailbox(enum omap_dwc3_vbus_id_status status)
+{
+	return;
+}
+#endif
+
+#endif	/* __DWC3_OMAP_H__ */
-- 
1.7.9.5


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

* [PATCH v4 6/7] usb: dwc3-omap: Minor fixes to get dt working
  2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
                   ` (4 preceding siblings ...)
  2012-10-15 13:27 ` [PATCH v4 5/7] usb: dwc3-omap: Add an API to write to dwc mailbox Kishon Vijay Abraham I
@ 2012-10-15 13:27 ` Kishon Vijay Abraham I
  2012-10-25 13:41   ` Benoit Cousson
  2012-10-15 13:28 ` [PATCH v4 7/7] usb: dwc3: core: add dt support for dwc3 core Kishon Vijay Abraham I
  2012-11-06 11:43 ` [PATCH v4 0/7] usb: dwc3-omap: add dt support Felipe Balbi
  7 siblings, 1 reply; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2012-10-15 13:27 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: sshtylyov

Includes few minor fixes in dwc3-omap like populating the compatible
string in a correct way, extracting the utmi-mode property properly and
changing the index of get_irq since irq of core is removed from hwmod
entry.
Also updated the documentation with dwc3-omap device tree binding
information.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/usb/dwc3/dwc3-omap.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index b84ddf3..10aad46 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -318,11 +318,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 	struct resource		*res;
 	struct device		*dev = &pdev->dev;
 
-	int			size;
 	int			ret = -ENOMEM;
 	int			irq;
 
-	const u32		*utmi_mode;
+	u32			utmi_mode;
 	u32			reg;
 
 	void __iomem		*base;
@@ -336,13 +335,13 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, omap);
 
-	irq = platform_get_irq(pdev, 1);
+	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "missing IRQ resource\n");
 		return -EINVAL;
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		dev_err(dev, "missing memory base resource\n");
 		return -EINVAL;
@@ -389,9 +388,8 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 
 	reg = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
 
-	utmi_mode = of_get_property(node, "utmi-mode", &size);
-	if (utmi_mode && size == sizeof(*utmi_mode)) {
-		reg |= *utmi_mode;
+	if (!of_property_read_u32(node, "utmi-mode", &utmi_mode)) {
+		reg |= utmi_mode;
 	} else {
 		if (!pdata) {
 			dev_dbg(dev, "missing platform data\n");
@@ -469,7 +467,7 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev)
 
 static const struct of_device_id of_dwc3_matach[] = {
 	{
-		"ti,dwc3",
+		.compatible =	"ti,dwc3"
 	},
 	{ },
 };
-- 
1.7.9.5


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

* [PATCH v4 7/7] usb: dwc3: core: add dt support for dwc3 core
  2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
                   ` (5 preceding siblings ...)
  2012-10-15 13:27 ` [PATCH v4 6/7] usb: dwc3-omap: Minor fixes to get dt working Kishon Vijay Abraham I
@ 2012-10-15 13:28 ` Kishon Vijay Abraham I
  2012-11-06 11:43 ` [PATCH v4 0/7] usb: dwc3-omap: add dt support Felipe Balbi
  7 siblings, 0 replies; 14+ messages in thread
From: Kishon Vijay Abraham I @ 2012-10-15 13:28 UTC (permalink / raw)
  To: grant.likely, rob.herring, rob, balbi, gregkh, kishon,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap
  Cc: sshtylyov

Added dwc3 support for dwc3 core and update the documentation with
device tree binding information.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 Documentation/devicetree/bindings/usb/dwc3.txt |   23 +++++++++++++++++++++++
 drivers/usb/dwc3/core.c                        |   14 ++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/dwc3.txt

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt
new file mode 100644
index 0000000..9ec9316
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -0,0 +1,23 @@
+synopsys DWC3 CORE
+
+DWC3- USB3 CONTROLLER
+
+Required properties:
+ - compatible: must be "synopsys,dwc3"
+ - reg : Address and length of the register set for the device
+ - interrupts: Interrupts used by the dwc3 controller.
+ - interrupt-parent: the phandle for the interrupt controller that
+   services interrupts for this device.
+
+Optional properties:
+ - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
+
+This is usually a subnode to DWC3 glue to which it is connected.
+
+dwc3@4a030000 {
+	compatible = "synopsys,dwc3";
+	reg = <0x4a030000 0xcfff>;
+	interrupts = <0 92 4>
+	interrupt-parent = <&gic>
+	tx-fifo-resize;
+};
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index b923183..c76d8e9 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -491,8 +491,7 @@ static int __devinit dwc3_probe(struct platform_device *pdev)
 	else
 		dwc->maximum_speed = DWC3_DCFG_SUPERSPEED;
 
-	if (of_get_property(node, "tx-fifo-resize", NULL))
-		dwc->needs_fifo_resize = true;
+	dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
 
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);
@@ -619,11 +618,22 @@ static int __devexit dwc3_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id of_dwc3_match[] = {
+	{
+		.compatible = "synopsys,dwc3"
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, of_dwc3_match);
+#endif
+
 static struct platform_driver dwc3_driver = {
 	.probe		= dwc3_probe,
 	.remove		= __devexit_p(dwc3_remove),
 	.driver		= {
 		.name	= "dwc3",
+		.of_match_table	= of_match_ptr(of_dwc3_match),
 	},
 };
 
-- 
1.7.9.5


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

* Re: [PATCH v4 6/7] usb: dwc3-omap: Minor fixes to get dt working
  2012-10-15 13:27 ` [PATCH v4 6/7] usb: dwc3-omap: Minor fixes to get dt working Kishon Vijay Abraham I
@ 2012-10-25 13:41   ` Benoit Cousson
  2012-10-25 14:54     ` kishon
  0 siblings, 1 reply; 14+ messages in thread
From: Benoit Cousson @ 2012-10-25 13:41 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: grant.likely, rob.herring, rob, balbi, gregkh,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, sshtylyov

Hi Kishon,

On 10/15/2012 03:27 PM, Kishon Vijay Abraham I wrote:
> Includes few minor fixes in dwc3-omap like populating the compatible
> string in a correct way, extracting the utmi-mode property properly and
> changing the index of get_irq since irq of core is removed from hwmod
> entry.
> Also updated the documentation with dwc3-omap device tree binding
> information.
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/usb/dwc3/dwc3-omap.c |   14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> index b84ddf3..10aad46 100644
> --- a/drivers/usb/dwc3/dwc3-omap.c
> +++ b/drivers/usb/dwc3/dwc3-omap.c
> @@ -318,11 +318,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
>  	struct resource		*res;
>  	struct device		*dev = &pdev->dev;
>  
> -	int			size;
>  	int			ret = -ENOMEM;
>  	int			irq;
>  
> -	const u32		*utmi_mode;
> +	u32			utmi_mode;
>  	u32			reg;
>  
>  	void __iomem		*base;
> @@ -336,13 +335,13 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, omap);
>  
> -	irq = platform_get_irq(pdev, 1);
> +	irq = platform_get_irq(pdev, 0);

Cannot you use the name of the resource to avoid that kind of trick?
This is for that reason that we added the resource name in DTS :-)

>  	if (irq < 0) {
>  		dev_err(dev, "missing IRQ resource\n");
>  		return -EINVAL;
>  	}
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

Same here.

Regards,
Benoit


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

* Re: [PATCH v4 2/7] usb: dwc3-omap: use of_platform API to create dwc3 core pdev
  2012-10-15 13:27 ` [PATCH v4 2/7] usb: dwc3-omap: use of_platform API to create dwc3 core pdev Kishon Vijay Abraham I
@ 2012-10-25 14:04   ` Benoit Cousson
  2012-10-25 14:19     ` Felipe Balbi
  0 siblings, 1 reply; 14+ messages in thread
From: Benoit Cousson @ 2012-10-25 14:04 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: grant.likely, rob.herring, rob, balbi, gregkh,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, sshtylyov

On 10/15/2012 03:27 PM, Kishon Vijay Abraham I wrote:
> Used of_platform_populate() to populate dwc3 core platform_device
> from device tree data. Since now the allocation of unique device id is
> handled by of_*, removed the call to dwc3_get_device_id.

Just for my understanding: How are these devices organized exactly?

Do we have : omap_wrapper -> dwc3-omap -> dwc3-core ?

The DT binding is mentioning some wrapper, but I'm not sure where it
should be located.

Maybe you should add more documentation on that. Or maybe you do have a
other series to add that part?

Regards,
Benoit

> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/usb/dwc3/dwc3-omap.c |   50 +++++++++---------------------------------
>  1 file changed, 10 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> index d51c69c..4aaeec4 100644
> --- a/drivers/usb/dwc3/dwc3-omap.c
> +++ b/drivers/usb/dwc3/dwc3-omap.c
> @@ -47,6 +47,7 @@
>  #include <linux/ioport.h>
>  #include <linux/io.h>
>  #include <linux/of.h>
> +#include <linux/of_platform.h>
>  
>  #include <linux/usb/otg.h>
>  #include <linux/usb/nop-usb-xceiv.h>
> @@ -133,7 +134,6 @@ struct dwc3_omap {
>  	/* device lock */
>  	spinlock_t		lock;
>  
> -	struct platform_device	*dwc3;
>  	struct platform_device	*usb2_phy;
>  	struct platform_device	*usb3_phy;
>  	struct device		*dev;
> @@ -276,12 +276,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
>  	struct dwc3_omap_data	*pdata = pdev->dev.platform_data;
>  	struct device_node	*node = pdev->dev.of_node;
>  
> -	struct platform_device	*dwc3;
>  	struct dwc3_omap	*omap;
>  	struct resource		*res;
>  	struct device		*dev = &pdev->dev;
>  
> -	int			devid;
>  	int			size;
>  	int			ret = -ENOMEM;
>  	int			irq;
> @@ -324,34 +322,19 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	devid = dwc3_get_device_id();
> -	if (devid < 0)
> -		return -ENODEV;
> -
> -	dwc3 = platform_device_alloc("dwc3", devid);
> -	if (!dwc3) {
> -		dev_err(dev, "couldn't allocate dwc3 device\n");
> -		goto err1;
> -	}
> -
>  	context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL);
>  	if (!context) {
>  		dev_err(dev, "couldn't allocate dwc3 context memory\n");
> -		goto err2;
> +		return -ENOMEM;
>  	}
>  
>  	spin_lock_init(&omap->lock);
> -	dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask);
>  
> -	dwc3->dev.parent = dev;
> -	dwc3->dev.dma_mask = dev->dma_mask;
> -	dwc3->dev.dma_parms = dev->dma_parms;
>  	omap->resource_size = resource_size(res);
>  	omap->context	= context;
>  	omap->dev	= dev;
>  	omap->irq	= irq;
>  	omap->base	= base;
> -	omap->dwc3	= dwc3;
>  
>  	reg = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
>  
> @@ -396,7 +379,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
>  	if (ret) {
>  		dev_err(dev, "failed to request IRQ #%d --> %d\n",
>  				omap->irq, ret);
> -		goto err2;
> +		return ret;
>  	}
>  
>  	/* enable all IRQs */
> @@ -415,28 +398,16 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
>  
>  	dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_1, reg);
>  
> -	ret = platform_device_add_resources(dwc3, pdev->resource,
> -			pdev->num_resources);
> -	if (ret) {
> -		dev_err(dev, "couldn't add resources to dwc3 device\n");
> -		goto err2;
> -	}
> -
> -	ret = platform_device_add(dwc3);
> -	if (ret) {
> -		dev_err(dev, "failed to register dwc3 device\n");
> -		goto err2;
> +	if (node) {
> +		ret = of_platform_populate(node, NULL, NULL, dev);
> +		if (ret) {
> +			dev_err(&pdev->dev,
> +				"failed to add create dwc3 core\n");
> +			return ret;
> +		}
>  	}
>  
>  	return 0;
> -
> -err2:
> -	platform_device_put(dwc3);
> -
> -err1:
> -	dwc3_put_device_id(devid);
> -
> -	return ret;
>  }
>  
>  static int __devexit dwc3_omap_remove(struct platform_device *pdev)
> @@ -446,7 +417,6 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev)
>  	platform_device_unregister(omap->usb2_phy);
>  	platform_device_unregister(omap->usb3_phy);
>  
> -	dwc3_put_device_id(omap->dwc3->id);
>  	device_for_each_child(&pdev->dev, NULL, dwc3_omap_remove_core);
>  
>  	return 0;
> 


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

* Re: [PATCH v4 2/7] usb: dwc3-omap: use of_platform API to create dwc3 core pdev
  2012-10-25 14:04   ` Benoit Cousson
@ 2012-10-25 14:19     ` Felipe Balbi
  0 siblings, 0 replies; 14+ messages in thread
From: Felipe Balbi @ 2012-10-25 14:19 UTC (permalink / raw)
  To: Benoit Cousson
  Cc: Kishon Vijay Abraham I, grant.likely, rob.herring, rob, balbi,
	gregkh, devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, sshtylyov

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

On Thu, Oct 25, 2012 at 04:04:44PM +0200, Benoit Cousson wrote:
> On 10/15/2012 03:27 PM, Kishon Vijay Abraham I wrote:
> > Used of_platform_populate() to populate dwc3 core platform_device
> > from device tree data. Since now the allocation of unique device id is
> > handled by of_*, removed the call to dwc3_get_device_id.
> 
> Just for my understanding: How are these devices organized exactly?
> 
> Do we have : omap_wrapper -> dwc3-omap -> dwc3-core ?

omap_wrapper == dwc3-omap, so it becomes:

dwc3-omap -> dwc3-core

-- 
balbi

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

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

* Re: [PATCH v4 6/7] usb: dwc3-omap: Minor fixes to get dt working
  2012-10-25 13:41   ` Benoit Cousson
@ 2012-10-25 14:54     ` kishon
  2012-11-06 11:40       ` Felipe Balbi
  0 siblings, 1 reply; 14+ messages in thread
From: kishon @ 2012-10-25 14:54 UTC (permalink / raw)
  To: Benoit Cousson
  Cc: grant.likely, rob.herring, rob, balbi, gregkh,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, sshtylyov

Hi Benoit,

On Thursday 25 October 2012 07:11 PM, Benoit Cousson wrote:
> Hi Kishon,
>
> On 10/15/2012 03:27 PM, Kishon Vijay Abraham I wrote:
>> Includes few minor fixes in dwc3-omap like populating the compatible
>> string in a correct way, extracting the utmi-mode property properly and
>> changing the index of get_irq since irq of core is removed from hwmod
>> entry.
>> Also updated the documentation with dwc3-omap device tree binding
>> information.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>>   drivers/usb/dwc3/dwc3-omap.c |   14 ++++++--------
>>   1 file changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
>> index b84ddf3..10aad46 100644
>> --- a/drivers/usb/dwc3/dwc3-omap.c
>> +++ b/drivers/usb/dwc3/dwc3-omap.c
>> @@ -318,11 +318,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
>>   	struct resource		*res;
>>   	struct device		*dev = &pdev->dev;
>>
>> -	int			size;
>>   	int			ret = -ENOMEM;
>>   	int			irq;
>>
>> -	const u32		*utmi_mode;
>> +	u32			utmi_mode;
>>   	u32			reg;
>>
>>   	void __iomem		*base;
>> @@ -336,13 +335,13 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
>>
>>   	platform_set_drvdata(pdev, omap);
>>
>> -	irq = platform_get_irq(pdev, 1);
>> +	irq = platform_get_irq(pdev, 0);
>
> Cannot you use the name of the resource to avoid that kind of trick?

*name* is mostly used when we have multiple resource of the same type 
for a single device. Previously we were clubbing wrapper resources and 
core resources in a single hwmod device, so we had to use different 
indexing.
But with dt we have separated those under two different devices and 
hence we can always use index as '0'. But if you think we should have 
*name*, let me know, I can resend this patch :-)

Thanks
Kishon

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

* Re: [PATCH v4 6/7] usb: dwc3-omap: Minor fixes to get dt working
  2012-10-25 14:54     ` kishon
@ 2012-11-06 11:40       ` Felipe Balbi
  0 siblings, 0 replies; 14+ messages in thread
From: Felipe Balbi @ 2012-11-06 11:40 UTC (permalink / raw)
  To: kishon
  Cc: Benoit Cousson, grant.likely, rob.herring, rob, balbi, gregkh,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, sshtylyov

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

Hi,

On Thu, Oct 25, 2012 at 08:24:09PM +0530, kishon wrote:
> Hi Benoit,
> 
> On Thursday 25 October 2012 07:11 PM, Benoit Cousson wrote:
> >Hi Kishon,
> >
> >On 10/15/2012 03:27 PM, Kishon Vijay Abraham I wrote:
> >>Includes few minor fixes in dwc3-omap like populating the compatible
> >>string in a correct way, extracting the utmi-mode property properly and
> >>changing the index of get_irq since irq of core is removed from hwmod
> >>entry.
> >>Also updated the documentation with dwc3-omap device tree binding
> >>information.
> >>
> >>Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> >>---
> >>  drivers/usb/dwc3/dwc3-omap.c |   14 ++++++--------
> >>  1 file changed, 6 insertions(+), 8 deletions(-)
> >>
> >>diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> >>index b84ddf3..10aad46 100644
> >>--- a/drivers/usb/dwc3/dwc3-omap.c
> >>+++ b/drivers/usb/dwc3/dwc3-omap.c
> >>@@ -318,11 +318,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
> >>  	struct resource		*res;
> >>  	struct device		*dev = &pdev->dev;
> >>
> >>-	int			size;
> >>  	int			ret = -ENOMEM;
> >>  	int			irq;
> >>
> >>-	const u32		*utmi_mode;
> >>+	u32			utmi_mode;
> >>  	u32			reg;
> >>
> >>  	void __iomem		*base;
> >>@@ -336,13 +335,13 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
> >>
> >>  	platform_set_drvdata(pdev, omap);
> >>
> >>-	irq = platform_get_irq(pdev, 1);
> >>+	irq = platform_get_irq(pdev, 0);
> >
> >Cannot you use the name of the resource to avoid that kind of trick?
> 
> *name* is mostly used when we have multiple resource of the same type
> for a single device. Previously we were clubbing wrapper resources
> and core resources in a single hwmod device, so we had to use
> different indexing.
> But with dt we have separated those under two different devices and
> hence we can always use index as '0'. But if you think we should have
> *name*, let me know, I can resend this patch :-)

since there were no more replies here, i'm assuming Benoit's happy with
Kishon's explanation. Will apply this series as is.

-- 
balbi

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

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

* Re: [PATCH v4 0/7] usb: dwc3-omap: add dt support
  2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
                   ` (6 preceding siblings ...)
  2012-10-15 13:28 ` [PATCH v4 7/7] usb: dwc3: core: add dt support for dwc3 core Kishon Vijay Abraham I
@ 2012-11-06 11:43 ` Felipe Balbi
  7 siblings, 0 replies; 14+ messages in thread
From: Felipe Balbi @ 2012-11-06 11:43 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: grant.likely, rob.herring, rob, balbi, gregkh,
	devicetree-discuss, linux-doc, linux-kernel, linux-usb,
	linux-omap, sshtylyov

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

On Mon, Oct 15, 2012 at 06:57:53PM +0530, Kishon Vijay Abraham I wrote:
> This patch series adds dt support to dwc3 core and fixes few minor
> stuff in dwc3-omap glue to get dwc3 working.
> 
> While at that it also uses *of_platform* to create the child device
> (dwc3-core) and fixes to use runtime API's to enable clock and write
> to SYSCONFIG register.
> 
> Changes from v3:
> * rebased to latest commit in balbi's tree
> * Fixed few typos in the commit log
> * Added *extern* keyword for dwc3_omap_mailbox function declaration
> 
> Changes from v2:
> * Fixed Sergei comment to use of_property_read_u32 insted of of_get_property
> 
> Changes from v1:
> * made device_for_each_child() as a seperate patch
> * made all other minor fixes wrt typos and function renames
> 
> This patch series is developed on:
> git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git dwc3

please rebase on my dwc3 branch. Because of commit belo, patches 1 and 2
won't apply:

commit 124dafde8f8174caf5cef1c3eaba001657d66f4f
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:   Mon Oct 29 18:09:53 2012 +0100

    usb: dwc3: remove custom unique id handling
    
    The lockless implementation of the unique id is quite impressive (:P)
    but dirver's core can handle it, we can remove it and make our code a
    little smaller.
    
    Cc: Anton Tikhomirov <av.tikhomirov@samsung.com>
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: Felipe Balbi <balbi@ti.com>

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index b923183..d8d327a 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -66,45 +66,6 @@ MODULE_PARM_DESC(maximum_speed, "Maximum supported speed.");
 
 /* -------------------------------------------------------------------------- */
 
-#define DWC3_DEVS_POSSIBLE	32
-
-static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE);
-
-int dwc3_get_device_id(void)
-{
-	int		id;
-
-again:
-	id = find_first_zero_bit(dwc3_devs, DWC3_DEVS_POSSIBLE);
-	if (id < DWC3_DEVS_POSSIBLE) {
-		int old;
-
-		old = test_and_set_bit(id, dwc3_devs);
-		if (old)
-			goto again;
-	} else {
-		pr_err("dwc3: no space for new device\n");
-		id = -ENOMEM;
-	}
-
-	return id;
-}
-EXPORT_SYMBOL_GPL(dwc3_get_device_id);
-
-void dwc3_put_device_id(int id)
-{
-	int			ret;
-
-	if (id < 0)
-		return;
-
-	ret = test_bit(id, dwc3_devs);
-	WARN(!ret, "dwc3: ID %d not in use\n", id);
-	smp_mb__before_clear_bit();
-	clear_bit(id, dwc3_devs);
-}
-EXPORT_SYMBOL_GPL(dwc3_put_device_id);
-
 void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
 {
 	u32 reg;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 243affc..4999563 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -868,7 +868,4 @@ void dwc3_host_exit(struct dwc3 *dwc);
 int dwc3_gadget_init(struct dwc3 *dwc);
 void dwc3_gadget_exit(struct dwc3 *dwc);
 
-extern int dwc3_get_device_id(void);
-extern void dwc3_put_device_id(int id);
-
 #endif /* __DRIVERS_USB_DWC3_CORE_H */
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index ca65978..586f105 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -94,7 +94,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
 	struct dwc3_exynos	*exynos;
 	struct clk		*clk;
 
-	int			devid;
 	int			ret = -ENOMEM;
 
 	exynos = kzalloc(sizeof(*exynos), GFP_KERNEL);
@@ -105,20 +104,16 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, exynos);
 
-	devid = dwc3_get_device_id();
-	if (devid < 0)
-		goto err1;
-
 	ret = dwc3_exynos_register_phys(exynos);
 	if (ret) {
 		dev_err(&pdev->dev, "couldn't register PHYs\n");
 		goto err1;
 	}
 
-	dwc3 = platform_device_alloc("dwc3", devid);
+	dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
 	if (!dwc3) {
 		dev_err(&pdev->dev, "couldn't allocate dwc3 device\n");
-		goto err2;
+		goto err1;
 	}
 
 	clk = clk_get(&pdev->dev, "usbdrd30");
@@ -170,8 +165,6 @@ err4:
 	clk_put(clk);
 err3:
 	platform_device_put(dwc3);
-err2:
-	dwc3_put_device_id(devid);
 err1:
 	kfree(exynos);
 err0:
@@ -187,8 +180,6 @@ static int __devexit dwc3_exynos_remove(struct platform_device *pdev)
 	platform_device_unregister(exynos->usb2_phy);
 	platform_device_unregister(exynos->usb3_phy);
 
-	dwc3_put_device_id(exynos->dwc3->id);
-
 	if (pdata && pdata->phy_exit)
 		pdata->phy_exit(pdev, pdata->phy_type);
 
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index ee57a10..900d435 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -272,7 +272,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 	struct resource		*res;
 	struct device		*dev = &pdev->dev;
 
-	int			devid;
 	int			size;
 	int			ret = -ENOMEM;
 	int			irq;
@@ -315,14 +314,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	devid = dwc3_get_device_id();
-	if (devid < 0)
-		return -ENODEV;
-
-	dwc3 = platform_device_alloc("dwc3", devid);
+	dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
 	if (!dwc3) {
 		dev_err(dev, "couldn't allocate dwc3 device\n");
-		goto err1;
+		return -ENOMEM;
 	}
 
 	context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL);
@@ -423,10 +418,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
 
 err2:
 	platform_device_put(dwc3);
-
-err1:
-	dwc3_put_device_id(devid);
-
 	return ret;
 }
 
@@ -437,9 +428,6 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev)
 	platform_device_unregister(omap->dwc3);
 	platform_device_unregister(omap->usb2_phy);
 	platform_device_unregister(omap->usb3_phy);
-
-	dwc3_put_device_id(omap->dwc3->id);
-
 	return 0;
 }
 
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 94f550e..1396259 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -119,7 +119,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
 	struct platform_device	*dwc3;
 	struct dwc3_pci		*glue;
 	int			ret = -ENOMEM;
-	int			devid;
 	struct device		*dev = &pci->dev;
 
 	glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
@@ -145,13 +144,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
 		return ret;
 	}
 
-	devid = dwc3_get_device_id();
-	if (devid < 0) {
-		ret = -ENOMEM;
-		goto err1;
-	}
-
-	dwc3 = platform_device_alloc("dwc3", devid);
+	dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
 	if (!dwc3) {
 		dev_err(dev, "couldn't allocate dwc3 device\n");
 		ret = -ENOMEM;
@@ -172,7 +165,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
 	ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
 	if (ret) {
 		dev_err(dev, "couldn't add resources to dwc3 device\n");
-		goto err2;
+		goto err1;
 	}
 
 	pci_set_drvdata(pci, glue);
@@ -195,10 +188,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
 err3:
 	pci_set_drvdata(pci, NULL);
 	platform_device_put(dwc3);
-
-err2:
-	dwc3_put_device_id(devid);
-
 err1:
 	pci_disable_device(pci);
 
@@ -211,7 +200,6 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci)
 
 	platform_device_unregister(glue->usb2_phy);
 	platform_device_unregister(glue->usb3_phy);
-	dwc3_put_device_id(glue->dwc3->id);
 	platform_device_unregister(glue->dwc3);
 	pci_set_drvdata(pci, NULL);
 	pci_disable_device(pci);

-- 
balbi

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

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

end of thread, other threads:[~2012-11-06 11:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-15 13:27 [PATCH v4 0/7] usb: dwc3-omap: add dt support Kishon Vijay Abraham I
2012-10-15 13:27 ` [PATCH v4 1/7] usb: dwc3-omap: use device_for_each_child to handle child removal Kishon Vijay Abraham I
2012-10-15 13:27 ` [PATCH v4 2/7] usb: dwc3-omap: use of_platform API to create dwc3 core pdev Kishon Vijay Abraham I
2012-10-25 14:04   ` Benoit Cousson
2012-10-25 14:19     ` Felipe Balbi
2012-10-15 13:27 ` [PATCH v4 3/7] usb: dwc3-omap: use runtime API's to enable clocks Kishon Vijay Abraham I
2012-10-15 13:27 ` [PATCH v4 4/7] usb: dwc3-omap: Remove explicit writes to SYSCONFIG register Kishon Vijay Abraham I
2012-10-15 13:27 ` [PATCH v4 5/7] usb: dwc3-omap: Add an API to write to dwc mailbox Kishon Vijay Abraham I
2012-10-15 13:27 ` [PATCH v4 6/7] usb: dwc3-omap: Minor fixes to get dt working Kishon Vijay Abraham I
2012-10-25 13:41   ` Benoit Cousson
2012-10-25 14:54     ` kishon
2012-11-06 11:40       ` Felipe Balbi
2012-10-15 13:28 ` [PATCH v4 7/7] usb: dwc3: core: add dt support for dwc3 core Kishon Vijay Abraham I
2012-11-06 11:43 ` [PATCH v4 0/7] usb: dwc3-omap: add dt support Felipe Balbi

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