Skip to contentSkip to conversation

add imx usb driver based on Greg next tree

PATCH Superseded Richard Zhao 7 participants 32 messages Jun 21, 2012 – Jul 30, 2012

Subsystems (4)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v6 cover add imx usb driver based on Greg next tree

The work is based on ci13xxx rework done by Alexander Shishkin.

To let Greg pick up, I also added patches Alex queued that I depends on. Patch #1 - #9 : It can also be found at
http://github.com/virtuoso/linux-ci.git ci

This patch series can also be found at:
https://github.com/riczhao/kernel-imx/commits/topics/usb-driver

Status:
- this version only support host
- usbotg controler works at host role

Changes since last version:
- Add patches from Alex's git tree that it depends
- Rebase to Greg's git tree
- Move arch/arm patches to other series
- dev_err fixes as Sascha comment
- Add MODULE_DEVICE_TABLE

Alexander Shishkin (1):
usb: chipidea: remove unneeded NULL check

Felipe Balbi (3):
usb: chipidea: drop useless arch-check
usb: chipidea: msm: add missing section annotation
usb: chipidea: msm: add remove method

Richard Zhao (10):
USB: Chipidea: rename struct ci13xxx_udc_driver to struct
ci13xxx_platform_data
USB: Chipidea: rename struct ci13xxx variables from udc to ci
USB: Chipidea: add unified ci13xxx_{add,remove}_device for platform
drivers
USB: Chipidea: add ci13xxx device id management
usb: chipidea: select USB_EHCI_ROOT_HUB_TT in USB_CHIPIDEA_HOST of
Kconfig
usb: otg: add notify_connect/notify_disconnect callback
USB: notify phy when root hub port connect change
usb: chipidea: permit driver bindings pass phy pointer
usb: otg: add basic mxs phy driver support
usb: chipidea: add imx platform driver

 .../devicetree/bindings/usb/ci13xxx-imx.txt        |   20 +
 Documentation/devicetree/bindings/usb/mxs-phy.txt  |   13 +
 drivers/usb/chipidea/Kconfig                       |    1 +
 drivers/usb/chipidea/Makefile                      |    9 +-
 drivers/usb/chipidea/ci.h                          |   32 +-
 drivers/usb/chipidea/ci13xxx_imx.c                 |  197 ++++++
 drivers/usb/chipidea/ci13xxx_msm.c                 |   62 +-
 drivers/usb/chipidea/ci13xxx_pci.c                 |   52 +-
 drivers/usb/chipidea/core.c                        |   70 ++-
 drivers/usb/chipidea/debug.c                       |  146 ++---
 drivers/usb/chipidea/host.c                        |    3 +-
 drivers/usb/chipidea/udc.c                         |  636 ++++++++++----------
 drivers/usb/core/hub.c                             |    8 +
 drivers/usb/otg/Kconfig                            |    9 +
 drivers/usb/otg/Makefile                           |    1 +
 drivers/usb/otg/mxs-phy.c                          |  197 ++++++
 include/linux/usb/chipidea.h                       |   14 +-
 include/linux/usb/otg.h                            |   21 +
 18 files changed, 1000 insertions(+), 491 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
 create mode 100644 Documentation/devicetree/bindings/usb/mxs-phy.txt
 create mode 100644 drivers/usb/chipidea/ci13xxx_imx.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v6 1/14 usb: chipidea: remove unneeded NULL check

From: Alexander Shishkin <[email protected]>

As reported by Dan Carpenter, there is a NULL check in udc_start() that follows a dereference of the pointer that's being checked. However, at that point udc pointer shouldn't ever be NULL and if it is, the dereference should cause an oops.

---
 drivers/usb/chipidea/udc.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/usb/chipidea/udc.c +0 -3
index 51f9694..cdb9212 100644
@@ -1647,9 +1647,6 @@ static int udc_start(struct ci13xxx *udc)
 	struct device *dev = udc->dev;
 	int retval = 0;
 
-	if (!udc)
-		return -EINVAL;
-
 	spin_lock_init(&udc->lock);
 
 	udc->gadget.ops          = &usb_gadget_ops;
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v6 2/14 usb: chipidea: drop useless arch-check

In reply to Richard Zhao

From: Felipe Balbi <[email protected]>

msm glue layer compiles on all arches just fine. Let's drop the unnecessary ARCH check so we have easier compile tests.

---
 drivers/usb/chipidea/Makefile |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/usb/chipidea/Makefile +5 -3
index cc34937..b69900a 100644
@@ -5,10 +5,12 @@ ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC)	+= udc.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)	+= host.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG)	+= debug.o
 
+# Glue/Bridge layers go here
+
+obj-$(CONFIG_USB_CHIPIDEA)	+= ci13xxx_msm.o
+
+# PCI doesn't provide stubs, need to check
 ifneq ($(CONFIG_PCI),)
 	obj-$(CONFIG_USB_CHIPIDEA)	+= ci13xxx_pci.o
 endif
 
-ifneq ($(CONFIG_ARCH_MSM),)
-	obj-$(CONFIG_USB_CHIPIDEA)	+= ci13xxx_msm.o
-endif
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v6 3/14 usb: chipidea: msm: add missing section annotation

In reply to Richard Zhao

From: Felipe Balbi <[email protected]>

no functional changes, it will just free up some
code if we don't have hotplug.

---
 drivers/usb/chipidea/ci13xxx_msm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/chipidea/ci13xxx_msm.c +1 -1
index 958069e..8d438b8 100644
@@ -55,7 +55,7 @@ static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver = {
 	.notify_event		= ci13xxx_msm_notify_event,
 };
 
-static int ci13xxx_msm_probe(struct platform_device *pdev)
+static int __devinit ci13xxx_msm_probe(struct platform_device *pdev)
 {
 	struct platform_device *plat_ci;
 	int ret;
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v6 4/14 usb: chipidea: msm: add remove method

In reply to Richard Zhao

From: Felipe Balbi <[email protected]>

allow this driver to be removed too.

---
 drivers/usb/chipidea/ci13xxx_msm.c |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/usb/chipidea/ci13xxx_msm.c +14 -6
index 8d438b8..68512d4 100644
@@ -84,6 +84,8 @@ static int __devinit ci13xxx_msm_probe(struct platform_device *pdev)
 	if (ret)
 		goto put_platform;
 
+	platform_set_drvdata(pdev, plat_ci);
+
 	pm_runtime_no_callbacks(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 
@@ -95,16 +97,22 @@ put_platform:
 	return ret;
 }
 
+static int __devexit ci13xxx_msm_remove(struct platform_device *pdev)
+{
+	struct platform_device *plat_ci = platform_get_drvdata(pdev);
+
+	platform_device_unregister(plat_ci);
+
+	return 0;
+}
+
 static struct platform_driver ci13xxx_msm_driver = {
 	.probe = ci13xxx_msm_probe,
+	.remove = __devexit_p(ci13xxx_msm_remove),
 	.driver = { .name = "msm_hsusb", },
 };
-MODULE_ALIAS("platform:msm_hsusb");
 
-static int __init ci13xxx_msm_init(void)
-{
-	return platform_driver_register(&ci13xxx_msm_driver);
-}
-module_init(ci13xxx_msm_init);
+module_platform_driver(ci13xxx_msm_driver);
 
+MODULE_ALIAS("platform:msm_hsusb");
 MODULE_LICENSE("GPL v2");
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v6 5/14 USB: Chipidea: rename struct ci13xxx_udc_driver to struct ci13xxx_platform_data

In reply to Richard Zhao

This patch rename struct ci13xxx_udc_driver and var with the type.

ci13xxx_platform_data reflect it's passed from platfrom driver.

---
 drivers/usb/chipidea/ci.h          |    4 ++--
 drivers/usb/chipidea/ci13xxx_msm.c |    6 +++---
 drivers/usb/chipidea/ci13xxx_pci.c |   20 ++++++++++----------
 drivers/usb/chipidea/core.c        |   12 ++++++------
 drivers/usb/chipidea/host.c        |    2 +-
 drivers/usb/chipidea/udc.c         |   24 ++++++++++++------------
 include/linux/usb/chipidea.h       |    2 +-
 7 files changed, 35 insertions(+), 35 deletions(-)
drivers/usb/chipidea/ci.h +2 -2
index 50911f8..0b09330 100644
@@ -125,7 +125,7 @@ struct hw_bank {
  * @remote_wakeup: host-enabled remote wakeup
  * @suspended: suspended by host
  * @test_mode: the selected test mode
- * @udc_driver: platform specific information supplied by parent device
+ * @platdata: platform specific information supplied by parent device
  * @vbus_active: is VBUS active
  * @transceiver: pointer to USB PHY, if any
  * @hcd: pointer to usb_hcd for ehci host driver
@@ -158,7 +158,7 @@ struct ci13xxx {
 	u8				suspended;
 	u8				test_mode;
 
-	struct ci13xxx_udc_driver	*udc_driver;
+	struct ci13xxx_platform_data	*platdata;
 	int				vbus_active;
 	struct usb_phy			*transceiver;
 	struct usb_hcd			*hcd;
drivers/usb/chipidea/ci13xxx_msm.c +3 -3
index 68512d4..21a7c2e 100644
@@ -45,7 +45,7 @@ static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
 	}
 }
 
-static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver = {
+static struct ci13xxx_platform_data ci13xxx_msm_platdata = {
 	.name			= "ci13xxx_msm",
 	.flags			= CI13XXX_REGS_SHARED |
 				  CI13XXX_REQUIRE_TRANSCEIVER |
@@ -75,8 +75,8 @@ static int __devinit ci13xxx_msm_probe(struct platform_device *pdev)
 		goto put_platform;
 	}
 
-	ret = platform_device_add_data(plat_ci, &ci13xxx_msm_udc_driver,
-				       sizeof(ci13xxx_msm_udc_driver));
+	ret = platform_device_add_data(plat_ci, &ci13xxx_msm_platdata,
+				       sizeof(ci13xxx_msm_platdata));
 	if (ret)
 		goto put_platform;
 
drivers/usb/chipidea/ci13xxx_pci.c +10 -10
index e3dab27..cdcac3a 100644
@@ -23,17 +23,17 @@
 /******************************************************************************
  * PCI block
  *****************************************************************************/
-struct ci13xxx_udc_driver pci_driver = {
+struct ci13xxx_platform_data pci_platdata = {
 	.name		= UDC_DRIVER_NAME,
 	.capoffset	= DEF_CAPOFFSET,
 };
 
-struct ci13xxx_udc_driver langwell_pci_driver = {
+struct ci13xxx_platform_data langwell_pci_platdata = {
 	.name		= UDC_DRIVER_NAME,
 	.capoffset	= 0,
 };
 
-struct ci13xxx_udc_driver penwell_pci_driver = {
+struct ci13xxx_platform_data penwell_pci_platdata = {
 	.name		= UDC_DRIVER_NAME,
 	.capoffset	= 0,
 	.power_budget	= 200,
@@ -51,12 +51,12 @@ struct ci13xxx_udc_driver penwell_pci_driver = {
 static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
 				       const struct pci_device_id *id)
 {
-	struct ci13xxx_udc_driver *driver = (void *)id->driver_data;
+	struct ci13xxx_platform_data *platdata = (void *)id->driver_data;
 	struct platform_device *plat_ci;
 	struct resource res[3];
 	int retval = 0, nres = 2;
 
-	if (!driver) {
+	if (!platdata) {
 		dev_err(&pdev->dev, "device doesn't provide driver data\n");
 		return -ENODEV;
 	}
@@ -95,7 +95,7 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
 		goto put_platform;
 	}
 
-	retval = platform_device_add_data(plat_ci, driver, sizeof(*driver));
+	retval = platform_device_add_data(plat_ci, platdata, sizeof(*platdata));
 	if (retval)
 		goto put_platform;
 
@@ -147,19 +147,19 @@ static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
 static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
 	{
 		PCI_DEVICE(0x153F, 0x1004),
-		.driver_data = (kernel_ulong_t)&pci_driver,
+		.driver_data = (kernel_ulong_t)&pci_platdata,
 	},
 	{
 		PCI_DEVICE(0x153F, 0x1006),
-		.driver_data = (kernel_ulong_t)&pci_driver,
+		.driver_data = (kernel_ulong_t)&pci_platdata,
 	},
 	{
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811),
-		.driver_data = (kernel_ulong_t)&langwell_pci_driver,
+		.driver_data = (kernel_ulong_t)&langwell_pci_platdata,
 	},
 	{
 		PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829),
-		.driver_data = (kernel_ulong_t)&penwell_pci_driver,
+		.driver_data = (kernel_ulong_t)&penwell_pci_platdata,
 	},
 	{ 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
 };
drivers/usb/chipidea/core.c +6 -6
index 15e03b3..9a883bd 100644
@@ -179,7 +179,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
 	ci->hw_bank.abs = base;
 
 	ci->hw_bank.cap = ci->hw_bank.abs;
-	ci->hw_bank.cap += ci->udc_driver->capoffset;
+	ci->hw_bank.cap += ci->platdata->capoffset;
 	ci->hw_bank.op = ci->hw_bank.cap + ioread8(ci->hw_bank.cap);
 
 	hw_alloc_regmap(ci, false);
@@ -227,11 +227,11 @@ int hw_device_reset(struct ci13xxx *ci, u32 mode)
 		udelay(10);		/* not RTOS friendly */
 
 
-	if (ci->udc_driver->notify_event)
-		ci->udc_driver->notify_event(ci,
+	if (ci->platdata->notify_event)
+		ci->platdata->notify_event(ci,
 			CI13XXX_CONTROLLER_RESET_EVENT);
 
-	if (ci->udc_driver->flags & CI13XXX_DISABLE_STREAMING)
+	if (ci->platdata->flags & CI13XXX_DISABLE_STREAMING)
 		hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
 
 	/* USBMODE should be configured step by step */
@@ -364,7 +364,7 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
 	}
 
 	ci->dev = dev;
-	ci->udc_driver = dev->platform_data;
+	ci->platdata = dev->platform_data;
 
 	ret = hw_device_init(ci, base);
 	if (ret < 0) {
@@ -419,7 +419,7 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, ci);
-	ret = request_irq(ci->irq, ci_irq, IRQF_SHARED, ci->udc_driver->name,
+	ret = request_irq(ci->irq, ci_irq, IRQF_SHARED, ci->platdata->name,
 			  ci);
 	if (ret)
 		goto stop;
drivers/usb/chipidea/host.c +1 -1
index 9eacd21..4a4fdb8 100644
@@ -116,7 +116,7 @@ static int host_start(struct ci13xxx *ci)
 	hcd->regs = ci->hw_bank.abs;
 	hcd->has_tt = 1;
 
-	hcd->power_budget = ci->udc_driver->power_budget;
+	hcd->power_budget = ci->platdata->power_budget;
 
 	ehci = hcd_to_ehci(hcd);
 	ehci->caps = ci->hw_bank.cap;
drivers/usb/chipidea/udc.c +12 -12
index cdb9212..68584bb 100644
@@ -1362,7 +1362,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
 	unsigned long flags;
 	int gadget_ready = 0;
 
-	if (!(udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS))
+	if (!(udc->platdata->flags & CI13XXX_PULLUP_ON_VBUS))
 		return -EOPNOTSUPP;
 
 	spin_lock_irqsave(&udc->lock, flags);
@@ -1378,8 +1378,8 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
 			hw_device_state(udc, udc->ep0out->qh.dma);
 		} else {
 			hw_device_state(udc, 0);
-			if (udc->udc_driver->notify_event)
-				udc->udc_driver->notify_event(udc,
+			if (udc->platdata->notify_event)
+				udc->platdata->notify_event(udc,
 				CI13XXX_CONTROLLER_STOPPED_EVENT);
 			_gadget_stop_activity(&udc->gadget);
 			pm_runtime_put_sync(&_gadget->dev);
@@ -1514,9 +1514,9 @@ static int ci13xxx_start(struct usb_gadget *gadget,
 
 	udc->driver = driver;
 	pm_runtime_get_sync(&udc->gadget.dev);
-	if (udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) {
+	if (udc->platdata->flags & CI13XXX_PULLUP_ON_VBUS) {
 		if (udc->vbus_active) {
-			if (udc->udc_driver->flags & CI13XXX_REGS_SHARED)
+			if (udc->platdata->flags & CI13XXX_REGS_SHARED)
 				hw_device_reset(udc, USBMODE_CM_DC);
 		} else {
 			pm_runtime_put_sync(&udc->gadget.dev);
@@ -1544,11 +1544,11 @@ static int ci13xxx_stop(struct usb_gadget *gadget,
 
 	spin_lock_irqsave(&udc->lock, flags);
 
-	if (!(udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) ||
+	if (!(udc->platdata->flags & CI13XXX_PULLUP_ON_VBUS) ||
 			udc->vbus_active) {
 		hw_device_state(udc, 0);
-		if (udc->udc_driver->notify_event)
-			udc->udc_driver->notify_event(udc,
+		if (udc->platdata->notify_event)
+			udc->platdata->notify_event(udc,
 			CI13XXX_CONTROLLER_STOPPED_EVENT);
 		udc->driver = NULL;
 		spin_unlock_irqrestore(&udc->lock, flags);
@@ -1581,7 +1581,7 @@ static irqreturn_t udc_irq(struct ci13xxx *udc)
 
 	spin_lock(&udc->lock);
 
-	if (udc->udc_driver->flags & CI13XXX_REGS_SHARED) {
+	if (udc->platdata->flags & CI13XXX_REGS_SHARED) {
 		if (hw_read(udc, OP_USBMODE, USBMODE_CM) !=
 				USBMODE_CM_DC) {
 			spin_unlock(&udc->lock);
@@ -1653,7 +1653,7 @@ static int udc_start(struct ci13xxx *udc)
 	udc->gadget.speed        = USB_SPEED_UNKNOWN;
 	udc->gadget.max_speed    = USB_SPEED_HIGH;
 	udc->gadget.is_otg       = 0;
-	udc->gadget.name         = udc->udc_driver->name;
+	udc->gadget.name         = udc->platdata->name;
 
 	INIT_LIST_HEAD(&udc->gadget.ep_list);
 
@@ -1686,14 +1686,14 @@ static int udc_start(struct ci13xxx *udc)
 
 	udc->transceiver = usb_get_transceiver();
 
-	if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
+	if (udc->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
 		if (udc->transceiver == NULL) {
 			retval = -ENODEV;
 			goto free_pools;
 		}
 	}
 
-	if (!(udc->udc_driver->flags & CI13XXX_REGS_SHARED)) {
+	if (!(udc->platdata->flags & CI13XXX_REGS_SHARED)) {
 		retval = hw_device_reset(udc, USBMODE_CM_DC);
 		if (retval)
 			goto put_transceiver;
include/linux/usb/chipidea.h +1 -1
index edb90d6..d4cf9706 100644
@@ -6,7 +6,7 @@
 #define __LINUX_USB_CHIPIDEA_H
 
 struct ci13xxx;
-struct ci13xxx_udc_driver {
+struct ci13xxx_platform_data {
 	const char	*name;
 	/* offset of the capability registers */
 	uintptr_t	 capoffset;
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v6 6/14 USB: Chipidea: rename struct ci13xxx variables from udc to ci

In reply to Richard Zhao

struct ci13xxx represent the controller, which may be device or host, so name its variables as ci.

---
 drivers/usb/chipidea/ci.h          |   26 +-
 drivers/usb/chipidea/ci13xxx_msm.c |   12 +-
 drivers/usb/chipidea/debug.c       |  146 ++++-----
 drivers/usb/chipidea/udc.c         |  630 ++++++++++++++++++------------------
 include/linux/usb/chipidea.h       |    2 +-
 5 files changed, 408 insertions(+), 408 deletions(-)
drivers/usb/chipidea/ci.h +13 -13
index 0b09330..9655e35 100644
@@ -36,7 +36,7 @@
  * @name: string description of the endpoint
  * @qh: queue head for this endpoint
  * @wedge: is the endpoint wedged
- * @udc: pointer to the controller
+ * @ci: pointer to the controller
  * @lock: pointer to controller's spinlock
  * @td_pool: pointer to controller's TD pool
  */
@@ -54,7 +54,7 @@ struct ci13xxx_ep {
 	int					wedge;
 
 	/* global resources */
-	struct ci13xxx				*udc;
+	struct ci13xxx				*ci;
 	spinlock_t				*lock;
 	struct dma_pool				*td_pool;
 };
@@ -250,9 +250,9 @@ static inline int ffs_nr(u32 x)
  *
  * This function returns register contents
  */
-static inline u32 hw_read(struct ci13xxx *udc, enum ci13xxx_regs reg, u32 mask)
+static inline u32 hw_read(struct ci13xxx *ci, enum ci13xxx_regs reg, u32 mask)
 {
-	return ioread32(udc->hw_bank.regmap[reg]) & mask;
+	return ioread32(ci->hw_bank.regmap[reg]) & mask;
 }
 
 /**
@@ -261,14 +261,14 @@ static inline u32 hw_read(struct ci13xxx *udc, enum ci13xxx_regs reg, u32 mask)
  * @mask: bitfield mask
  * @data: new value
  */
-static inline void hw_write(struct ci13xxx *udc, enum ci13xxx_regs reg,
+static inline void hw_write(struct ci13xxx *ci, enum ci13xxx_regs reg,
 			    u32 mask, u32 data)
 {
 	if (~mask)
-		data = (ioread32(udc->hw_bank.regmap[reg]) & ~mask)
+		data = (ioread32(ci->hw_bank.regmap[reg]) & ~mask)
 			| (data & mask);
 
-	iowrite32(data, udc->hw_bank.regmap[reg]);
+	iowrite32(data, ci->hw_bank.regmap[reg]);
 }
 
 /**
@@ -278,12 +278,12 @@ static inline void hw_write(struct ci13xxx *udc, enum ci13xxx_regs reg,
  *
  * This function returns register contents
  */
-static inline u32 hw_test_and_clear(struct ci13xxx *udc, enum ci13xxx_regs reg,
+static inline u32 hw_test_and_clear(struct ci13xxx *ci, enum ci13xxx_regs reg,
 				    u32 mask)
 {
-	u32 val = ioread32(udc->hw_bank.regmap[reg]) & mask;
+	u32 val = ioread32(ci->hw_bank.regmap[reg]) & mask;
 
-	iowrite32(val, udc->hw_bank.regmap[reg]);
+	iowrite32(val, ci->hw_bank.regmap[reg]);
 	return val;
 }
 
@@ -295,12 +295,12 @@ static inline u32 hw_test_and_clear(struct ci13xxx *udc, enum ci13xxx_regs reg,
  *
  * This function returns register contents
  */
-static inline u32 hw_test_and_write(struct ci13xxx *udc, enum ci13xxx_regs reg,
+static inline u32 hw_test_and_write(struct ci13xxx *ci, enum ci13xxx_regs reg,
 				    u32 mask, u32 data)
 {
-	u32 val = hw_read(udc, reg, ~0);
+	u32 val = hw_read(ci, reg, ~0);
 
-	hw_write(udc, reg, mask, data);
+	hw_write(ci, reg, mask, data);
 	return (val & mask) >> ffs_nr(mask);
 }
 
drivers/usb/chipidea/ci13xxx_msm.c +6 -6
index 21a7c2e..a7dd9f1 100644
@@ -15,11 +15,11 @@
 
 #include "ci.h"
 
-#define MSM_USB_BASE	(udc->hw_bank.abs)
+#define MSM_USB_BASE	(ci->hw_bank.abs)
 
-static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
+static void ci13xxx_msm_notify_event(struct ci13xxx *ci, unsigned event)
 {
-	struct device *dev = udc->gadget.dev.parent;
+	struct device *dev = ci->gadget.dev.parent;
 	int val;
 
 	switch (event) {
@@ -34,13 +34,13 @@ static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
 		 * Put the transceiver in non-driving mode. Otherwise host
 		 * may not detect soft-disconnection.
 		 */
-		val = usb_phy_io_read(udc->transceiver, ULPI_FUNC_CTRL);
+		val = usb_phy_io_read(ci->transceiver, ULPI_FUNC_CTRL);
 		val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
 		val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
-		usb_phy_io_write(udc->transceiver, val, ULPI_FUNC_CTRL);
+		usb_phy_io_write(ci->transceiver, val, ULPI_FUNC_CTRL);
 		break;
 	default:
-		dev_dbg(dev, "unknown ci13xxx_udc event\n");
+		dev_dbg(dev, "unknown ci13xxx event\n");
 		break;
 	}
 }
drivers/usb/chipidea/debug.c +73 -73

366 lines not on this page · raw message

drivers/usb/chipidea/udc.c +315 -315

1,358 lines not on this page · raw message

include/linux/usb/chipidea.h +1 -1
index d4cf9706..d2f7e49 100644
@@ -19,7 +19,7 @@ struct ci13xxx_platform_data {
 
 #define CI13XXX_CONTROLLER_RESET_EVENT		0
 #define CI13XXX_CONTROLLER_STOPPED_EVENT	1
-	void	(*notify_event) (struct ci13xxx *udc, unsigned event);
+	void	(*notify_event) (struct ci13xxx *ci, unsigned event);
 };
 
 /* Default offset of capability registers */
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v6 7/14 USB: Chipidea: add unified ci13xxx_{add, remove}_device for platform drivers

In reply to Richard Zhao

Platform drivers do the similar things to add/remove ci13xxx device, so create a unified one.

---
 drivers/usb/chipidea/ci13xxx_msm.c |   34 ++++++----------------------
 drivers/usb/chipidea/ci13xxx_pci.c |   34 +++++-----------------------
 drivers/usb/chipidea/core.c        |   43 ++++++++++++++++++++++++++++++++++++
 include/linux/usb/chipidea.h       |    7 ++++++
 4 files changed, 63 insertions(+), 55 deletions(-)
drivers/usb/chipidea/ci13xxx_msm.c +7 -27
index a7dd9f1..92bfe36 100644
@@ -58,50 +58,30 @@ static struct ci13xxx_platform_data ci13xxx_msm_platdata = {
 static int __devinit ci13xxx_msm_probe(struct platform_device *pdev)
 {
 	struct platform_device *plat_ci;
-	int ret;
 
 	dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n");
 
-	plat_ci = platform_device_alloc("ci_hdrc", -1);
-	if (!plat_ci) {
-		dev_err(&pdev->dev, "can't allocate ci_hdrc platform device\n");
-		return -ENOMEM;
+	plat_ci = ci13xxx_add_device(&pdev->dev,
+				pdev->resource, pdev->num_resources,
+				&ci13xxx_msm_platdata);
+	if (IS_ERR(plat_ci)) {
+		dev_err(&pdev->dev, "ci13xxx_add_device failed!\n");
+		return PTR_ERR(plat_ci);
 	}
 
-	ret = platform_device_add_resources(plat_ci, pdev->resource,
-					    pdev->num_resources);
-	if (ret) {
-		dev_err(&pdev->dev, "can't add resources to platform device\n");
-		goto put_platform;
-	}
-
-	ret = platform_device_add_data(plat_ci, &ci13xxx_msm_platdata,
-				       sizeof(ci13xxx_msm_platdata));
-	if (ret)
-		goto put_platform;
-
-	ret = platform_device_add(plat_ci);
-	if (ret)
-		goto put_platform;
-
 	platform_set_drvdata(pdev, plat_ci);
 
 	pm_runtime_no_callbacks(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 
 	return 0;
-
-put_platform:
-	platform_device_put(plat_ci);
-
-	return ret;
 }
 
 static int __devexit ci13xxx_msm_remove(struct platform_device *pdev)
 {
 	struct platform_device *plat_ci = platform_get_drvdata(pdev);
 
-	platform_device_unregister(plat_ci);
+	ci13xxx_remove_device(plat_ci);
 
 	return 0;
 }
drivers/usb/chipidea/ci13xxx_pci.c +6 -28
index cdcac3a..918e149 100644
@@ -75,13 +75,6 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	plat_ci = platform_device_alloc("ci_hdrc", -1);
-	if (!plat_ci) {
-		dev_err(&pdev->dev, "can't allocate ci_hdrc platform device\n");
-		retval = -ENOMEM;
-		goto disable_device;
-	}
-
 	memset(res, 0, sizeof(res));
 	res[0].start	= pci_resource_start(pdev, 0);
 	res[0].end	= pci_resource_end(pdev, 0);
@@ -89,32 +82,17 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
 	res[1].start	= pdev->irq;
 	res[1].flags	= IORESOURCE_IRQ;
 
-	retval = platform_device_add_resources(plat_ci, res, nres);
-	if (retval) {
-		dev_err(&pdev->dev, "can't add resources to platform device\n");
-		goto put_platform;
+	plat_ci = ci13xxx_add_device(&pdev->dev, res, nres, platdata);
+	if (IS_ERR(plat_ci)) {
+		dev_err(&pdev->dev, "ci13xxx_add_device failed!\n");
+		retval = PTR_ERR(plat_ci);
+		goto disable_device;
 	}
 
-	retval = platform_device_add_data(plat_ci, platdata, sizeof(*platdata));
-	if (retval)
-		goto put_platform;
-
-	dma_set_coherent_mask(&plat_ci->dev, pdev->dev.coherent_dma_mask);
-	plat_ci->dev.dma_mask = pdev->dev.dma_mask;
-	plat_ci->dev.dma_parms = pdev->dev.dma_parms;
-	plat_ci->dev.parent = &pdev->dev;
-
 	pci_set_drvdata(pdev, plat_ci);
 
-	retval = platform_device_add(plat_ci);
-	if (retval)
-		goto put_platform;
-
 	return 0;
 
- put_platform:
-	pci_set_drvdata(pdev, NULL);
-	platform_device_put(plat_ci);
  disable_device:
 	pci_disable_device(pdev);
  done:
@@ -133,7 +111,7 @@ static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
 {
 	struct platform_device *plat_ci = pci_get_drvdata(pdev);
 
-	platform_device_unregister(plat_ci);
+	ci13xxx_remove_device(plat_ci);
 	pci_set_drvdata(pdev, NULL);
 	pci_disable_device(pdev);
 }
drivers/usb/chipidea/core.c +43 -0

49 lines not on this page · raw message

include/linux/usb/chipidea.h +7 -0
index d2f7e49..be078f0 100644
@@ -25,4 +25,11 @@ struct ci13xxx_platform_data {
 /* Default offset of capability registers */
 #define DEF_CAPOFFSET		0x100
 
+/* Add ci13xxx device */
+struct platform_device *ci13xxx_add_device(struct device *dev,
+			struct resource *res, int nres,
+			struct ci13xxx_platform_data *platdata);
+/* Remove ci13xxx device */
+void ci13xxx_remove_device(struct platform_device *pdev);
+
 #endif
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v6 7/14 USB: Chipidea: add unified ci13xxx_{add,remove}_device for platform drivers

Quoted 178 lines · Richard Zhao

Platform drivers do the similar things to add/remove ci13xxx device, so create a unified one.

---
 drivers/usb/chipidea/ci13xxx_msm.c |   34 ++++++----------------------
 drivers/usb/chipidea/ci13xxx_pci.c |   34 +++++-----------------------
 drivers/usb/chipidea/core.c        |   43 ++++++++++++++++++++++++++++++++++++
 include/linux/usb/chipidea.h       |    7 ++++++
 4 files changed, 63 insertions(+), 55 deletions(-)
drivers/usb/chipidea/ci13xxx_msm.c +7 -27
index a7dd9f1..92bfe36 100644
@@ -58,50 +58,30 @@ static struct ci13xxx_platform_data ci13xxx_msm_platdata = {
 static int __devinit ci13xxx_msm_probe(struct platform_device *pdev)
 {
 	struct platform_device *plat_ci;
-	int ret;
 
 	dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n");
 
-	plat_ci = platform_device_alloc("ci_hdrc", -1);
-	if (!plat_ci) {
-		dev_err(&pdev->dev, "can't allocate ci_hdrc platform device\n");
-		return -ENOMEM;
+	plat_ci = ci13xxx_add_device(&pdev->dev,
+				pdev->resource, pdev->num_resources,
+				&ci13xxx_msm_platdata);
+	if (IS_ERR(plat_ci)) {
+		dev_err(&pdev->dev, "ci13xxx_add_device failed!\n");
+		return PTR_ERR(plat_ci);
 	}
 
-	ret = platform_device_add_resources(plat_ci, pdev->resource,
-					    pdev->num_resources);
-	if (ret) {
-		dev_err(&pdev->dev, "can't add resources to platform device\n");
-		goto put_platform;
-	}
-
-	ret = platform_device_add_data(plat_ci, &ci13xxx_msm_platdata,
-				       sizeof(ci13xxx_msm_platdata));
-	if (ret)
-		goto put_platform;
-
-	ret = platform_device_add(plat_ci);
-	if (ret)
-		goto put_platform;
-
 	platform_set_drvdata(pdev, plat_ci);
 
 	pm_runtime_no_callbacks(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 
 	return 0;
-
-put_platform:
-	platform_device_put(plat_ci);
-
-	return ret;
 }
 
 static int __devexit ci13xxx_msm_remove(struct platform_device *pdev)
 {
 	struct platform_device *plat_ci = platform_get_drvdata(pdev);
 
-	platform_device_unregister(plat_ci);
+	ci13xxx_remove_device(plat_ci);
 
 	return 0;
 }
drivers/usb/chipidea/ci13xxx_pci.c +6 -28
index cdcac3a..918e149 100644
@@ -75,13 +75,6 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
 	pci_set_master(pdev);
 	pci_try_set_mwi(pdev);
 
-	plat_ci = platform_device_alloc("ci_hdrc", -1);
-	if (!plat_ci) {
-		dev_err(&pdev->dev, "can't allocate ci_hdrc platform device\n");
-		retval = -ENOMEM;
-		goto disable_device;
-	}
-
 	memset(res, 0, sizeof(res));
 	res[0].start	= pci_resource_start(pdev, 0);
 	res[0].end	= pci_resource_end(pdev, 0);
@@ -89,32 +82,17 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
 	res[1].start	= pdev->irq;
 	res[1].flags	= IORESOURCE_IRQ;
 
-	retval = platform_device_add_resources(plat_ci, res, nres);
-	if (retval) {
-		dev_err(&pdev->dev, "can't add resources to platform device\n");
-		goto put_platform;
+	plat_ci = ci13xxx_add_device(&pdev->dev, res, nres, platdata);
+	if (IS_ERR(plat_ci)) {
+		dev_err(&pdev->dev, "ci13xxx_add_device failed!\n");
+		retval = PTR_ERR(plat_ci);
+		goto disable_device;
 	}
 
-	retval = platform_device_add_data(plat_ci, platdata, sizeof(*platdata));
-	if (retval)
-		goto put_platform;
-
-	dma_set_coherent_mask(&plat_ci->dev, pdev->dev.coherent_dma_mask);
-	plat_ci->dev.dma_mask = pdev->dev.dma_mask;
-	plat_ci->dev.dma_parms = pdev->dev.dma_parms;
-	plat_ci->dev.parent = &pdev->dev;
-
 	pci_set_drvdata(pdev, plat_ci);
 
-	retval = platform_device_add(plat_ci);
-	if (retval)
-		goto put_platform;
-
 	return 0;
 
- put_platform:
-	pci_set_drvdata(pdev, NULL);
-	platform_device_put(plat_ci);
  disable_device:
 	pci_disable_device(pdev);
  done:
@@ -133,7 +111,7 @@ static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
 {
 	struct platform_device *plat_ci = pci_get_drvdata(pdev);
 
-	platform_device_unregister(plat_ci);
+	ci13xxx_remove_device(plat_ci);
 	pci_set_drvdata(pdev, NULL);
 	pci_disable_device(pdev);
 }
drivers/usb/chipidea/core.c +30 -0
index 9a883bd..8eccd1b 100644
@@ -332,6 +332,49 @@ static irqreturn_t ci_irq(int irq, void *data)
 	return ci->role == CI_ROLE_END ? ret : ci_role(ci)->irq(ci);
 }
 
+struct platform_device *ci13xxx_add_device(struct device *dev,
+			struct resource *res, int nres,
+			struct ci13xxx_platform_data *platdata)
+{
+	struct platform_device *pdev;
+	int ret;
+
+	/* FIXME: find a way to choose id */
+	pdev = platform_device_alloc("ci_hdrc", -1);
+	if (!pdev)
+		return ERR_PTR(-ENOMEM);
+
+	pdev->dev.parent = dev;
+	pdev->dev.dma_mask = dev->dma_mask;
+	pdev->dev.dma_parms = dev->dma_parms;
+	dma_set_coherent_mask(&pdev->dev, dev->coherent_dma_mask);
+
+	ret = platform_device_add_resources(pdev, res, nres);
+	if (ret)
+		goto err;
+
+	ret = platform_device_add_data(pdev, platdata, sizeof(*platdata));
+	if (ret)
+		goto err;
+
+	ret = platform_device_add(pdev);
+	if (ret)
+		goto err;
+
+	return pdev;

drivers/usb/chipidea/core.c static irqreturn_t ci_irq(int irq, void *data) · line 374

Quoted 10 lines
drivers/usb/chipidea/core.c +10 -0
+
+err:
+	platform_device_put(pdev);
+	return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(ci13xxx_add_device);
+
+void ci13xxx_remove_device(struct platform_device *pdev)
+{
+	platform_device_put(pdev);

It's supposed to be

	platform_device_unregister(pdev);

Thanks
Richard

Quoted 2 lines
drivers/usb/chipidea/core.c +2 -0
+}
+EXPORT_SYMBOL_GPL(ci13xxx_remove_device);
#9 lore raw

PATCH v6 8/14 USB: Chipidea: add ci13xxx device id management

In reply to Richard Zhao

We use ida_simple_get and ida_simple_remove to manage the ids.

---
 drivers/usb/chipidea/core.c |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/usb/chipidea/core.c +16 -5
index 8eccd1b..c14ce2b 100644
@@ -56,6 +56,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/module.h>
+#include <linux/idr.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -332,17 +333,24 @@ static irqreturn_t ci_irq(int irq, void *data)
 	return ci->role == CI_ROLE_END ? ret : ci_role(ci)->irq(ci);
 }
 
+static DEFINE_IDA(ci_ida);
+
 struct platform_device *ci13xxx_add_device(struct device *dev,
 			struct resource *res, int nres,
 			struct ci13xxx_platform_data *platdata)
 {
 	struct platform_device *pdev;
-	int ret;
+	int id, ret;
 
-	/* FIXME: find a way to choose id */
-	pdev = platform_device_alloc("ci_hdrc", -1);
-	if (!pdev)
-		return ERR_PTR(-ENOMEM);
+	id = ida_simple_get(&ci_ida, 0, 0, GFP_KERNEL);
+	if (id < 0)
+		return ERR_PTR(id);
+
+	pdev = platform_device_alloc("ci_hdrc", id);
+	if (!pdev) {
+		ret = -ENOMEM;
+		goto put_id;
+	}
 
 	pdev->dev.parent = dev;
 	pdev->dev.dma_mask = dev->dma_mask;
@@ -365,12 +373,15 @@ struct platform_device *ci13xxx_add_device(struct device *dev,
 
 err:
 	platform_device_put(pdev);
+put_id:
+	ida_simple_remove(&ci_ida, id);
 	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(ci13xxx_add_device);
 
 void ci13xxx_remove_device(struct platform_device *pdev)
 {
+	ida_simple_remove(&ci_ida, pdev->id);
 	platform_device_put(pdev);
 }
 EXPORT_SYMBOL_GPL(ci13xxx_remove_device);
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v6 9/14 usb: chipidea: select USB_EHCI_ROOT_HUB_TT in USB_CHIPIDEA_HOST of Kconfig

In reply to Richard Zhao

ci13xxx host needs Root Hub Transaction Translators.

---
 drivers/usb/chipidea/Kconfig |    1 +
 1 file changed, 1 insertion(+)
drivers/usb/chipidea/Kconfig +1 -0
index fd36dc8..8337fb5 100644
@@ -20,6 +20,7 @@ config USB_CHIPIDEA_UDC
 
 config USB_CHIPIDEA_HOST
 	bool "ChipIdea host controller"
+	select USB_EHCI_ROOT_HUB_TT
 	help
 	  Say Y here to enable host controller functionality of the
 	  ChipIdea driver.
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH v6 10/14 usb: otg: add notify_connect/notify_disconnect callback

In reply to Richard Zhao

This let usb phy driver has a chance to change hw settings when connect status change.

---
 include/linux/usb/otg.h |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
include/linux/usb/otg.h +21 -0
index 38ab3f4..6dfdc8d 100644
@@ -117,6 +117,9 @@ struct usb_phy {
 	int	(*set_suspend)(struct usb_phy *x,
 				int suspend);
 
+	/* notify phy connect status change */
+	int	(*notify_connect)(struct usb_phy *x, int port);
+	int	(*notify_disconnect)(struct usb_phy *x, int port);
 };
 
 
@@ -252,6 +255,24 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend)
 }
 
 static inline int
+usb_phy_notify_connect(struct usb_phy *x, int port)
+{
+	if (x->notify_connect)
+		return x->notify_connect(x, port);
+	else
+		return 0;
+}
+
+static inline int
+usb_phy_notify_disconnect(struct usb_phy *x, int port)
+{
+	if (x->notify_disconnect)
+		return x->notify_disconnect(x, port);
+	else
+		return 0;
+}
+
+static inline int
 otg_start_srp(struct usb_otg *otg)
 {
 	if (otg && otg->start_srp)
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v6 11/14 USB: notify phy when root hub port connect change

In reply to Richard Zhao

Phy may need to change settings when port connect change.

---
 drivers/usb/core/hub.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/core/hub.c +8 -0
index 25a7422..6ecfb5e 100644
@@ -20,6 +20,7 @@
 #include <linux/usb.h>
 #include <linux/usbdevice_fs.h>
 #include <linux/usb/hcd.h>
+#include <linux/usb/otg.h>
 #include <linux/usb/quirks.h>
 #include <linux/kthread.h>
 #include <linux/mutex.h>
@@ -4034,6 +4035,13 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
 		}
 	}
 
+	if (unlikely(hcd->phy && !hdev->parent)) {
+		if (portstatus & USB_PORT_STAT_CONNECTION)
+			usb_phy_notify_connect(hcd->phy, port1);
+		else
+			usb_phy_notify_disconnect(hcd->phy, port1);
+	}
+
 	/* Return now if debouncing failed or nothing is connected or
 	 * the device was "removed".
 	 */
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH v6 12/14 usb: chipidea: permit driver bindings pass phy pointer

In reply to Richard Zhao

Sometimes, the driver bindings may know what phy they use. For example, when using device tree, the usb controller may have a phandler pointing to usb phy.

---
 drivers/usb/chipidea/ci.h    |    2 ++
 drivers/usb/chipidea/core.c  |    4 ++++
 drivers/usb/chipidea/host.c  |    1 +
 drivers/usb/chipidea/udc.c   |   11 +++++++----
 include/linux/usb/chipidea.h |    3 +++
 5 files changed, 17 insertions(+), 4 deletions(-)
drivers/usb/chipidea/ci.h +2 -0
index 9655e35..d738603 100644
@@ -160,6 +160,8 @@ struct ci13xxx {
 
 	struct ci13xxx_platform_data	*platdata;
 	int				vbus_active;
+	/* FIXME: some day, we'll not use global phy */
+	bool				global_phy;
 	struct usb_phy			*transceiver;
 	struct usb_hcd			*hcd;
 };
drivers/usb/chipidea/core.c +4 -0
index c14ce2b..21407e7 100644
@@ -419,6 +419,10 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
 
 	ci->dev = dev;
 	ci->platdata = dev->platform_data;
+	if (ci->platdata->phy)
+		ci->transceiver = ci->platdata->phy;
+	else
+		ci->global_phy = true;
 
 	ret = hw_device_init(ci, base);
 	if (ret < 0) {
drivers/usb/chipidea/host.c +1 -0
index 4a4fdb8..ebff9f4 100644
@@ -117,6 +117,7 @@ static int host_start(struct ci13xxx *ci)
 	hcd->has_tt = 1;
 
 	hcd->power_budget = ci->platdata->power_budget;
+	hcd->phy = ci->transceiver;
 
 	ehci = hcd_to_ehci(hcd);
 	ehci->caps = ci->hw_bank.cap;
drivers/usb/chipidea/udc.c +7 -4
index ca9b387..b43b29c 100644
@@ -1684,7 +1684,8 @@ static int udc_start(struct ci13xxx *ci)
 
 	ci->gadget.ep0 = &ci->ep0in->ep;
 
-	ci->transceiver = usb_get_transceiver();
+	if (ci->global_phy) {
+		ci->transceiver = usb_get_transceiver();
 
 	if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
 		if (ci->transceiver == NULL) {
@@ -1728,7 +1729,8 @@ static int udc_start(struct ci13xxx *ci)
 remove_trans:
 	if (ci->transceiver) {
 		otg_set_peripheral(ci->transceiver->otg, &ci->gadget);
-		usb_put_transceiver(ci->transceiver);
+		if (ci->global_phy)
+			usb_put_transceiver(ci->transceiver);
 	}
 
 	dev_err(dev, "error = %i\n", retval);
@@ -1737,7 +1739,7 @@ remove_dbg:
 unreg_device:
 	device_unregister(&ci->gadget.dev);
 put_transceiver:
-	if (ci->transceiver)
+	if (ci->transceiver && ci->global_phy)
 		usb_put_transceiver(ci->transceiver);
 free_pools:
 	dma_pool_destroy(ci->td_pool);
@@ -1771,7 +1773,8 @@ static void udc_stop(struct ci13xxx *ci)
 
 	if (ci->transceiver) {
 		otg_set_peripheral(ci->transceiver->otg, NULL);
-		usb_put_transceiver(ci->transceiver);
+		if (ci->global_phy)
+			usb_put_transceiver(ci->transceiver);
 	}
 	dbg_remove_files(&ci->gadget.dev);
 	device_unregister(&ci->gadget.dev);
include/linux/usb/chipidea.h +3 -0
index be078f0..544825d 100644
@@ -5,12 +5,15 @@
 #ifndef __LINUX_USB_CHIPIDEA_H
 #define __LINUX_USB_CHIPIDEA_H
 
+#include <linux/usb/otg.h>
+
 struct ci13xxx;
 struct ci13xxx_platform_data {
 	const char	*name;
 	/* offset of the capability registers */
 	uintptr_t	 capoffset;
 	unsigned	 power_budget;
+	struct usb_phy	*phy;
 	unsigned long	 flags;
 #define CI13XXX_REGS_SHARED		BIT(0)
 #define CI13XXX_REQUIRE_TRANSCEIVER	BIT(1)
Signature · 1 line
1.7.9.5
#14 lore raw

PATCH v6 12/14 usb: chipidea: permit driver bindings pass phy pointer

Quoted 8 lines · Richard Zhao

Sometimes, the driver bindings may know what phy they use. For example, when using device tree, the usb controller may have a phandler pointing to usb phy.

[...]

drivers/usb/chipidea/udc.c static int udc_start(struct ci13xxx *ci) · line 1687

Quoted 8 lines
drivers/usb/chipidea/udc.c +1 -1
@@ -1684,7 +1684,8 @@ static int udc_start(struct ci13xxx *ci)
 
 	ci->gadget.ep0 = &ci->ep0in->ep;
 
-	ci->transceiver = usb_get_transceiver();
+	if (ci->global_phy) {
                           ^^^

This doesn't compile, closing curly brackets are missing.

include/linux/usb/chipidea.h

Quoted 35 lines
drivers/usb/chipidea/udc.c +6 -3
+		ci->transceiver = usb_get_transceiver();
 
 	if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
 		if (ci->transceiver == NULL) {
@@ -1728,7 +1729,8 @@ static int udc_start(struct ci13xxx *ci)
 remove_trans:
 	if (ci->transceiver) {
 		otg_set_peripheral(ci->transceiver->otg, &ci->gadget);
-		usb_put_transceiver(ci->transceiver);
+		if (ci->global_phy)
+			usb_put_transceiver(ci->transceiver);
 	}
 
 	dev_err(dev, "error = %i\n", retval);
@@ -1737,7 +1739,7 @@ remove_dbg:
 unreg_device:
 	device_unregister(&ci->gadget.dev);
 put_transceiver:
-	if (ci->transceiver)
+	if (ci->transceiver && ci->global_phy)
 		usb_put_transceiver(ci->transceiver);
 free_pools:
 	dma_pool_destroy(ci->td_pool);
@@ -1771,7 +1773,8 @@ static void udc_stop(struct ci13xxx *ci)
 
 	if (ci->transceiver) {
 		otg_set_peripheral(ci->transceiver->otg, NULL);
-		usb_put_transceiver(ci->transceiver);
+		if (ci->global_phy)
+			usb_put_transceiver(ci->transceiver);
 	}
 	dbg_remove_files(&ci->gadget.dev);
 	device_unregister(&ci->gadget.dev);
include/linux/usb/chipidea.h +0 -0
index be078f0..544825d 100644

Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120621/92e518aa/attachment.sig>
#15 lore raw

PATCH v6 12/14 usb: chipidea: permit driver bindings pass phy pointer

Quoted 16 lines · Marc Kleine-Budde
Quoted 8 lines · Richard Zhao

Sometimes, the driver bindings may know what phy they use. For example, when using device tree, the usb controller may have a phandler pointing to usb phy.

[...]

Quoted 4 lines
drivers/usb/chipidea/udc.c +0 -0
@@ -1684,7 +1684,8 @@ static int udc_start(struct ci13xxx *ci)
 
Quoted 8 lines

drivers/usb/chipidea/udc.c static int udc_start(struct ci13xxx *ci) · line 1687

Quoted 4 lines
drivers/usb/chipidea/udc.c +1 -1
 	ci->gadget.ep0 = &ci->ep0in->ep;
 
-	ci->transceiver = usb_get_transceiver();
+	if (ci->global_phy) {
                           ^^^

This doesn't compile, closing curly brackets are missing.

Nice catch.

Thanks
Richard

#16 lore raw

PATCH v7 1/1 usb: chipidea: permit driver bindings pass phy pointer

In reply to Marc Kleine-Budde

Sometimes, the driver bindings may know what phy they use. For example, when using device tree, the usb controller may have a phandler pointing to usb phy.

---
 drivers/usb/chipidea/ci.h    |    2 ++
 drivers/usb/chipidea/core.c  |    4 ++++
 drivers/usb/chipidea/host.c  |    1 +
 drivers/usb/chipidea/udc.c   |   11 +++++++----
 include/linux/usb/chipidea.h |    3 +++
 5 files changed, 17 insertions(+), 4 deletions(-)
drivers/usb/chipidea/ci.h +2 -0
index 9655e35..d738603 100644
@@ -160,6 +160,8 @@ struct ci13xxx {
 
 	struct ci13xxx_platform_data	*platdata;
 	int				vbus_active;
+	/* FIXME: some day, we'll not use global phy */
+	bool				global_phy;
 	struct usb_phy			*transceiver;
 	struct usb_hcd			*hcd;
 };
drivers/usb/chipidea/core.c +4 -0
index c14ce2b..21407e7 100644
@@ -419,6 +419,10 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
 
 	ci->dev = dev;
 	ci->platdata = dev->platform_data;
+	if (ci->platdata->phy)
+		ci->transceiver = ci->platdata->phy;
+	else
+		ci->global_phy = true;
 
 	ret = hw_device_init(ci, base);
 	if (ret < 0) {
drivers/usb/chipidea/host.c +1 -0
index 4a4fdb8..ebff9f4 100644
@@ -117,6 +117,7 @@ static int host_start(struct ci13xxx *ci)
 	hcd->has_tt = 1;
 
 	hcd->power_budget = ci->platdata->power_budget;
+	hcd->phy = ci->transceiver;
 
 	ehci = hcd_to_ehci(hcd);
 	ehci->caps = ci->hw_bank.cap;
drivers/usb/chipidea/udc.c +7 -4
index ca9b387..ebc88c1 100644
@@ -1684,7 +1684,8 @@ static int udc_start(struct ci13xxx *ci)
 
 	ci->gadget.ep0 = &ci->ep0in->ep;
 
-	ci->transceiver = usb_get_transceiver();
+	if (ci->global_phy)
+		ci->transceiver = usb_get_transceiver();
 
 	if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
 		if (ci->transceiver == NULL) {
@@ -1728,7 +1729,8 @@ static int udc_start(struct ci13xxx *ci)
 remove_trans:
 	if (ci->transceiver) {
 		otg_set_peripheral(ci->transceiver->otg, &ci->gadget);
-		usb_put_transceiver(ci->transceiver);
+		if (ci->global_phy)
+			usb_put_transceiver(ci->transceiver);
 	}
 
 	dev_err(dev, "error = %i\n", retval);
@@ -1737,7 +1739,7 @@ remove_dbg:
 unreg_device:
 	device_unregister(&ci->gadget.dev);
 put_transceiver:
-	if (ci->transceiver)
+	if (ci->transceiver && ci->global_phy)
 		usb_put_transceiver(ci->transceiver);
 free_pools:
 	dma_pool_destroy(ci->td_pool);
@@ -1771,7 +1773,8 @@ static void udc_stop(struct ci13xxx *ci)
 
 	if (ci->transceiver) {
 		otg_set_peripheral(ci->transceiver->otg, NULL);
-		usb_put_transceiver(ci->transceiver);
+		if (ci->global_phy)
+			usb_put_transceiver(ci->transceiver);
 	}
 	dbg_remove_files(&ci->gadget.dev);
 	device_unregister(&ci->gadget.dev);
include/linux/usb/chipidea.h +3 -0
index be078f0..544825d 100644
@@ -5,12 +5,15 @@
 #ifndef __LINUX_USB_CHIPIDEA_H
 #define __LINUX_USB_CHIPIDEA_H
 
+#include <linux/usb/otg.h>
+
 struct ci13xxx;
 struct ci13xxx_platform_data {
 	const char	*name;
 	/* offset of the capability registers */
 	uintptr_t	 capoffset;
 	unsigned	 power_budget;
+	struct usb_phy	*phy;
 	unsigned long	 flags;
 #define CI13XXX_REGS_SHARED		BIT(0)
 #define CI13XXX_REQUIRE_TRANSCEIVER	BIT(1)
Signature · 1 line
1.7.9.5
#17 lore raw

PATCH v7 1/1 usb: chipidea: permit driver bindings pass phy pointer

Quoted 3 lines · Richard Zhao

Sometimes, the driver bindings may know what phy they use. For example, when using device tree, the usb controller may have a phandler pointing to usb phy.

Remove the module doesn't remove the platform device. A subsequent modprobe fails with:

------------[ cut here ]------------
WARNING: at fs/sysfs/dir.c:529 sysfs_add_one+0x8c/0xbc()
sysfs: cannot create duplicate filename '/devices/80080000.ahb/80080000.usb/ci_hdrc.0'
Modules linked in: ci13xxx_imx(+) ci_hdrc udc_core [last unloaded: ci13xxx_imx]
[<c000e6c8>] (unwind_backtrace+0x0/0xf0) from [<c0015c70>] (warn_slowpath_common+0x4c/0x64)
[<c0015c70>] (warn_slowpath_common+0x4c/0x64) from [<c0015d1c>] (warn_slowpath_fmt+0x30/0x40)
[<c0015d1c>] (warn_slowpath_fmt+0x30/0x40) from [<c00dbbbc>] (sysfs_add_one+0x8c/0xbc)
[<c00dbbbc>] (sysfs_add_one+0x8c/0xbc) from [<c00dbd2c>] (create_dir+0x60/0xc0)
[<c00dbd2c>] (create_dir+0x60/0xc0) from [<c00dc08c>] (sysfs_create_dir+0x64/0xa8)
[<c00dc08c>] (sysfs_create_dir+0x64/0xa8) from [<c0151f28>] (kobject_add_internal+0xa4/0x1e8)
[<c0151f28>] (kobject_add_internal+0xa4/0x1e8) from [<c0152434>] (kobject_add+0x50/0x98)
[<c0152434>] (kobject_add+0x50/0x98) from [<c0187fe4>] (device_add+0xb8/0x358)
[<c0187fe4>] (device_add+0xb8/0x358) from [<c018b76c>] (platform_device_add+0xf8/0x1a0)
[<c018b76c>] (platform_device_add+0xf8/0x1a0) from [<bf006250>] (ci13xxx_add_device+0xd4/0x114 [ci_hdrc])
[<bf006250>] (ci13xxx_add_device+0xd4/0x114 [ci_hdrc]) from [<bf022264>] (ci13xxx_imx_probe+0x1e0/0x288 [ci13xxx_imx])
[<bf022264>] (ci13xxx_imx_probe+0x1e0/0x288 [ci13xxx_imx]) from [<c018b378>] (platform_drv_probe+0x14/0x18)
[<c018b378>] (platform_drv_probe+0x14/0x18) from [<c018a230>] (really_probe+0x68/0x1e0)
[<c018a230>] (really_probe+0x68/0x1e0) from [<c018a530>] (__driver_attach+0x8c/0x90)
[<c018a530>] (__driver_attach+0x8c/0x90) from [<c0188c0c>] (bus_for_each_dev+0x54/0x7c)
[<c0188c0c>] (bus_for_each_dev+0x54/0x7c) from [<c0189b74>] (bus_add_driver+0x17c/0x248)
[<c0189b74>] (bus_add_driver+0x17c/0x248) from [<c018a7e4>] (driver_register+0x78/0x12c)
[<c018a7e4>] (driver_register+0x78/0x12c) from [<c00086c4>] (do_one_initcall+0x30/0x168)
[<c00086c4>] (do_one_initcall+0x30/0x168) from [<c004c824>] (sys_init_module+0x74/0x198)
[<c004c824>] (sys_init_module+0x74/0x198) from [<c0009260>] (ret_fast_syscall+0x0/0x2c)
---[ end trace e152599aa12f31d8 ]---
------------[ cut here ]------------
WARNING: at lib/kobject.c:196 kobject_add_internal+0x1cc/0x1e8()
kobject_add_internal failed for ci_hdrc.0 with -EEXIST, don't try to register things with the same name in the same directory.
Modules linked in: ci13xxx_imx(+) ci_hdrc udc_core [last unloaded: ci13xxx_imx]
[<c000e6c8>] (unwind_backtrace+0x0/0xf0) from [<c0015c70>] (warn_slowpath_common+0x4c/0x64)
[<c0015c70>] (warn_slowpath_common+0x4c/0x64) from [<c0015d1c>] (warn_slowpath_fmt+0x30/0x40)
[<c0015d1c>] (warn_slowpath_fmt+0x30/0x40) from [<c0152050>] (kobject_add_internal+0x1cc/0x1e8)
[<c0152050>] (kobject_add_internal+0x1cc/0x1e8) from [<c0152434>] (kobject_add+0x50/0x98)
[<c0152434>] (kobject_add+0x50/0x98) from [<c0187fe4>] (device_add+0xb8/0x358)
[<c0187fe4>] (device_add+0xb8/0x358) from [<c018b76c>] (platform_device_add+0xf8/0x1a0)
[<c018b76c>] (platform_device_add+0xf8/0x1a0) from [<bf006250>] (ci13xxx_add_device+0xd4/0x114 [ci_hdrc])
[<bf006250>] (ci13xxx_add_device+0xd4/0x114 [ci_hdrc]) from [<bf022264>] (ci13xxx_imx_probe+0x1e0/0x288 [ci13xxx_imx])
[<bf022264>] (ci13xxx_imx_probe+0x1e0/0x288 [ci13xxx_imx]) from [<c018b378>] (platform_drv_probe+0x14/0x18)
[<c018b378>] (platform_drv_probe+0x14/0x18) from [<c018a230>] (really_probe+0x68/0x1e0)
[<c018a230>] (really_probe+0x68/0x1e0) from [<c018a530>] (__driver_attach+0x8c/0x90)
[<c018a530>] (__driver_attach+0x8c/0x90) from [<c0188c0c>] (bus_for_each_dev+0x54/0x7c)
[<c0188c0c>] (bus_for_each_dev+0x54/0x7c) from [<c0189b74>] (bus_add_driver+0x17c/0x248)
[<c0189b74>] (bus_add_driver+0x17c/0x248) from [<c018a7e4>] (driver_register+0x78/0x12c)
[<c018a7e4>] (driver_register+0x78/0x12c) from [<c00086c4>] (do_one_initcall+0x30/0x168)
[<c00086c4>] (do_one_initcall+0x30/0x168) from [<c004c824>] (sys_init_module+0x74/0x198)
[<c004c824>] (sys_init_module+0x74/0x198) from [<c0009260>] (ret_fast_syscall+0x0/0x2c)
---[ end trace e152599aa12f31d9 ]---

imx_usb 80080000.usb: Can't register ci_hdrc platform device, err=-17
imx_usb: probe of 80080000.usb failed with error -17

Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120621/a8372925/attachment.sig>
#18 lore raw

PATCH v7 1/1 usb: chipidea: permit driver bindings pass phy pointer

Quoted 54 lines · Marc Kleine-Budde
Quoted 3 lines · Richard Zhao

Sometimes, the driver bindings may know what phy they use. For example, when using device tree, the usb controller may have a phandler pointing to usb phy.

Remove the module doesn't remove the platform device. A subsequent modprobe fails with:

------------[ cut here ]------------
WARNING: at fs/sysfs/dir.c:529 sysfs_add_one+0x8c/0xbc()
sysfs: cannot create duplicate filename '/devices/80080000.ahb/80080000.usb/ci_hdrc.0'
Modules linked in: ci13xxx_imx(+) ci_hdrc udc_core [last unloaded: ci13xxx_imx]
[<c000e6c8>] (unwind_backtrace+0x0/0xf0) from [<c0015c70>] (warn_slowpath_common+0x4c/0x64)
[<c0015c70>] (warn_slowpath_common+0x4c/0x64) from [<c0015d1c>] (warn_slowpath_fmt+0x30/0x40)
[<c0015d1c>] (warn_slowpath_fmt+0x30/0x40) from [<c00dbbbc>] (sysfs_add_one+0x8c/0xbc)
[<c00dbbbc>] (sysfs_add_one+0x8c/0xbc) from [<c00dbd2c>] (create_dir+0x60/0xc0)
[<c00dbd2c>] (create_dir+0x60/0xc0) from [<c00dc08c>] (sysfs_create_dir+0x64/0xa8)
[<c00dc08c>] (sysfs_create_dir+0x64/0xa8) from [<c0151f28>] (kobject_add_internal+0xa4/0x1e8)
[<c0151f28>] (kobject_add_internal+0xa4/0x1e8) from [<c0152434>] (kobject_add+0x50/0x98)
[<c0152434>] (kobject_add+0x50/0x98) from [<c0187fe4>] (device_add+0xb8/0x358)
[<c0187fe4>] (device_add+0xb8/0x358) from [<c018b76c>] (platform_device_add+0xf8/0x1a0)
[<c018b76c>] (platform_device_add+0xf8/0x1a0) from [<bf006250>] (ci13xxx_add_device+0xd4/0x114 [ci_hdrc])
[<bf006250>] (ci13xxx_add_device+0xd4/0x114 [ci_hdrc]) from [<bf022264>] (ci13xxx_imx_probe+0x1e0/0x288 [ci13xxx_imx])
[<bf022264>] (ci13xxx_imx_probe+0x1e0/0x288 [ci13xxx_imx]) from [<c018b378>] (platform_drv_probe+0x14/0x18)
[<c018b378>] (platform_drv_probe+0x14/0x18) from [<c018a230>] (really_probe+0x68/0x1e0)
[<c018a230>] (really_probe+0x68/0x1e0) from [<c018a530>] (__driver_attach+0x8c/0x90)
[<c018a530>] (__driver_attach+0x8c/0x90) from [<c0188c0c>] (bus_for_each_dev+0x54/0x7c)
[<c0188c0c>] (bus_for_each_dev+0x54/0x7c) from [<c0189b74>] (bus_add_driver+0x17c/0x248)
[<c0189b74>] (bus_add_driver+0x17c/0x248) from [<c018a7e4>] (driver_register+0x78/0x12c)
[<c018a7e4>] (driver_register+0x78/0x12c) from [<c00086c4>] (do_one_initcall+0x30/0x168)
[<c00086c4>] (do_one_initcall+0x30/0x168) from [<c004c824>] (sys_init_module+0x74/0x198)
[<c004c824>] (sys_init_module+0x74/0x198) from [<c0009260>] (ret_fast_syscall+0x0/0x2c)
---[ end trace e152599aa12f31d8 ]---
------------[ cut here ]------------
WARNING: at lib/kobject.c:196 kobject_add_internal+0x1cc/0x1e8()
kobject_add_internal failed for ci_hdrc.0 with -EEXIST, don't try to register things with the same name in the same directory.
Modules linked in: ci13xxx_imx(+) ci_hdrc udc_core [last unloaded: ci13xxx_imx]
[<c000e6c8>] (unwind_backtrace+0x0/0xf0) from [<c0015c70>] (warn_slowpath_common+0x4c/0x64)
[<c0015c70>] (warn_slowpath_common+0x4c/0x64) from [<c0015d1c>] (warn_slowpath_fmt+0x30/0x40)
[<c0015d1c>] (warn_slowpath_fmt+0x30/0x40) from [<c0152050>] (kobject_add_internal+0x1cc/0x1e8)
[<c0152050>] (kobject_add_internal+0x1cc/0x1e8) from [<c0152434>] (kobject_add+0x50/0x98)
[<c0152434>] (kobject_add+0x50/0x98) from [<c0187fe4>] (device_add+0xb8/0x358)
[<c0187fe4>] (device_add+0xb8/0x358) from [<c018b76c>] (platform_device_add+0xf8/0x1a0)
[<c018b76c>] (platform_device_add+0xf8/0x1a0) from [<bf006250>] (ci13xxx_add_device+0xd4/0x114 [ci_hdrc])
[<bf006250>] (ci13xxx_add_device+0xd4/0x114 [ci_hdrc]) from [<bf022264>] (ci13xxx_imx_probe+0x1e0/0x288 [ci13xxx_imx])
[<bf022264>] (ci13xxx_imx_probe+0x1e0/0x288 [ci13xxx_imx]) from [<c018b378>] (platform_drv_probe+0x14/0x18)
[<c018b378>] (platform_drv_probe+0x14/0x18) from [<c018a230>] (really_probe+0x68/0x1e0)
[<c018a230>] (really_probe+0x68/0x1e0) from [<c018a530>] (__driver_attach+0x8c/0x90)
[<c018a530>] (__driver_attach+0x8c/0x90) from [<c0188c0c>] (bus_for_each_dev+0x54/0x7c)
[<c0188c0c>] (bus_for_each_dev+0x54/0x7c) from [<c0189b74>] (bus_add_driver+0x17c/0x248)
[<c0189b74>] (bus_add_driver+0x17c/0x248) from [<c018a7e4>] (driver_register+0x78/0x12c)
[<c018a7e4>] (driver_register+0x78/0x12c) from [<c00086c4>] (do_one_initcall+0x30/0x168)
[<c00086c4>] (do_one_initcall+0x30/0x168) from [<c004c824>] (sys_init_module+0x74/0x198)
[<c004c824>] (sys_init_module+0x74/0x198) from [<c0009260>] (ret_fast_syscall+0x0/0x2c)
---[ end trace e152599aa12f31d9 ]---
Quoted 2 lines

imx_usb 80080000.usb: Can't register ci_hdrc platform device, err=-17
imx_usb: probe of 80080000.usb failed with error -17

It's caused by Patch #7 .
Thanks very much.

Richard

Quoted 9 lines

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
#19 lore raw

PATCH v6 13/14 usb: otg: add basic mxs phy driver support

In reply to Richard Zhao

mxs phy is used in Freescale i.MX SoCs, for example imx23, imx28, imx6Q. This patch adds the basic host support.

---
 Documentation/devicetree/bindings/usb/mxs-phy.txt |   13 ++
 drivers/usb/otg/Kconfig                           |    9 +
 drivers/usb/otg/Makefile                          |    1 +
 drivers/usb/otg/mxs-phy.c                         |  197 +++++++++++++++++++++
 4 files changed, 220 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/mxs-phy.txt
 create mode 100644 drivers/usb/otg/mxs-phy.c
Documentation/devicetree/bindings/usb/mxs-phy.txt new file +13 -0
new file mode 100644
index 0000000..5835b27
@@ -0,0 +1,13 @@
+* Freescale MXS USB Phy Device
+
+Required properties:
+- compatible: Should be "fsl,imx23-usbphy"
+- reg: Should contain registers location and length
+- interrupts: Should contain phy interrupt
+
+Example:
+usbphy1: usbphy at 020c9000 {
+	compatible = "fsl,imx6q-usbphy", "fsl,imx23-usbphy";
+	reg = <0x020c9000 0x1000>;
+	interrupts = <0 44 0x04>;
+};
drivers/usb/otg/Kconfig +9 -0
index 5c87db0..669eb32 100644
@@ -116,6 +116,15 @@ config FSL_USB2_OTG
 	help
 	  Enable this to support Freescale USB OTG transceiver.
 
+config USB_MXS_PHY
+	tristate "Freescale MXS USB PHY support"
+	select STMP_DEVICE
+	select USB_OTG_UTILS
+	help
+	  Enable this to support the Freescale MXS USB PHY.
+
+	  MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x.
+
 config USB_MV_OTG
 	tristate "Marvell USB OTG support"
 	depends on USB_EHCI_MV && USB_MV_UDC && USB_SUSPEND
drivers/usb/otg/Makefile +1 -0
index 41aa509..a844b8d 100644
@@ -20,4 +20,5 @@ obj-$(CONFIG_USB_MSM_OTG)	+= msm_otg.o
 obj-$(CONFIG_AB8500_USB)	+= ab8500-usb.o
 fsl_usb2_otg-objs		:= fsl_otg.o otg_fsm.o
 obj-$(CONFIG_FSL_USB2_OTG)	+= fsl_usb2_otg.o
+obj-$(CONFIG_USB_MXS_PHY)	+= mxs-phy.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
drivers/usb/otg/mxs-phy.c new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#20 lore raw

PATCH v6 13/14 usb: otg: add basic mxs phy driver support

drivers/usb/otg/Kconfig config FSL_USB2_OTG · line 122

Quoted 4 lines · Richard Zhao
drivers/usb/otg/Kconfig +4 -0
+config USB_MXS_PHY
+	tristate "Freescale MXS USB PHY support"
+	select STMP_DEVICE
+	select USB_OTG_UTILS

There should also be a dependency on ARM (or maybe even ARCH_MXS), because you're using writel_relaxed() here, which only exists on arm and sh4 and enabling it on other architectures breaks compilation.

Regards,
--
Alex

#21 lore raw

PATCH v6 13/14 usb: otg: add basic mxs phy driver support

Quoted 10 lines · Alexander Shishkin

drivers/usb/otg/Kconfig config FSL_USB2_OTG · line 122

Quoted 4 lines · Richard Zhao
drivers/usb/otg/Kconfig +4 -0
+config USB_MXS_PHY
+	tristate "Freescale MXS USB PHY support"
+	select STMP_DEVICE
+	select USB_OTG_UTILS

There should also be a dependency on ARM (or maybe even ARCH_MXS), because you're using writel_relaxed() here, which only exists on arm and sh4 and enabling it on other architectures breaks compilation.

Thanks for your view. I'll add

	depends on ARCH_MXC || ARCH_MXS

Richard

Quoted 5 lines

Regards,
--
Alex

#22 lore raw

PATCH v6 14/14 usb: chipidea: add imx platform driver

In reply to Richard Zhao

This patch supports only the host-mode functionality so far.

Cc Peter Chen <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt        |   20 ++
 drivers/usb/chipidea/Makefile                      |    3 +
 drivers/usb/chipidea/ci13xxx_imx.c                 |  197 ++++++++++++++++++++
 3 files changed, 220 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
 create mode 100644 drivers/usb/chipidea/ci13xxx_imx.c
Documentation/devicetree/bindings/usb/ci13xxx-imx.txt new file +20 -0
new file mode 100644
index 0000000..8bcd071
@@ -0,0 +1,20 @@
+* Freescale i.MX ci13xxx usb controllers
+
+Required properties:
+- compatible: Should be "fsl,imx27-usb"
+- reg: Should contain registers location and length
+- interrupts: Should contain controller interrupt
+
+Optional properties:
+- fsl,usbphy: phandler of usb phy that connects to the only one port
+- fsl,hub-reset-gpios: gpio used to reset on-board usb hub
+- fsl,vbus-power-gpios: gpio used to set vbus power of the only one port
+
+Examples:
+usb at 02184000 { /* USB OTG */
+	compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
+	reg = <0x02184000 0x200>;
+	interrupts = <0 43 0x04>;
+	fsl,usbphy = <&usbphy1>;
+	fsl,vbus-power-gpios = <&gpio3 22 0>;
+};
drivers/usb/chipidea/Makefile +3 -0
index b69900a..5c66d9c 100644
@@ -14,3 +14,6 @@ ifneq ($(CONFIG_PCI),)
 	obj-$(CONFIG_USB_CHIPIDEA)	+= ci13xxx_pci.o
 endif
 
+ifneq ($(CONFIG_OF_DEVICE),)
+	obj-$(CONFIG_USB_CHIPIDEA)	+= ci13xxx_imx.o
+endif
drivers/usb/chipidea/ci13xxx_imx.c new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#23 lore raw

PATCH v6 14/14 usb: chipidea: add imx platform driver

Hi Alex,

Could you Ack the patch if everything is ok?

Thanks
Richard

#24 lore raw

v6 cover add imx usb driver based on Greg next tree

In reply to Richard Zhao
Quoted 6 lines · Richard Zhao

The work is based on ci13xxx rework done by Alexander Shishkin.

To let Greg pick up, I also added patches Alex queued that I depends on. Patch #1 - #9 : It can also be found at
http://github.com/virtuoso/linux-ci.git ci

Quoted 6 lines

This patch series can also be found at:
https://github.com/riczhao/kernel-imx/commits/topics/usb-driver

Status:
- this version only support host
- usbotg controler works at host role

I'm interested in usb device support on mx28, what has to be implemented to get it working?

Regards, Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120621/c88f15db/attachment.sig>
#25 lore raw

v6 cover add imx usb driver based on Greg next tree

Quoted 10 lines · Marc Kleine-Budde
Quoted 9 lines · Richard Zhao

The work is based on ci13xxx rework done by Alexander Shishkin.

To let Greg pick up, I also added patches Alex queued that I depends on. Patch #1 - #9 : It can also be found at
http://github.com/virtuoso/linux-ci.git ci

This patch series can also be found at:
https://github.com/riczhao/kernel-imx/commits/topics/usb-driver

Quoted 6 lines
Quoted 3 lines

Status:
- this version only support host
- usbotg controler works at host role

I'm interested in usb device support on mx28, what has to be implemented to get it working?

I don't have patch yet, but on the plan.

Thanks
Richard

#26 lore raw

v6 cover add imx usb driver based on Greg next tree

Quoted 11 lines · Richard Zhao
Quoted 10 lines · Marc Kleine-Budde
Quoted 9 lines · Richard Zhao

The work is based on ci13xxx rework done by Alexander Shishkin.

To let Greg pick up, I also added patches Alex queued that I depends on. Patch #1 - #9 : It can also be found at
http://github.com/virtuoso/linux-ci.git ci

This patch series can also be found at:
https://github.com/riczhao/kernel-imx/commits/topics/usb-driver

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

Status:
- this version only support host
- usbotg controler works at host role

I'm interested in usb device support on mx28, what has to be implemented to get it working?

I don't have patch yet, but on the plan.

What needs to be done? I want to help/implement it.

Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120621/b4d3e8b3/attachment.sig>
#27 lore raw

v6 cover add imx usb driver based on Greg next tree

Quoted 16 lines · Marc Kleine-Budde
Quoted 15 lines · Richard Zhao
Quoted 14 lines · Marc Kleine-Budde
Quoted 12 lines · Richard Zhao

The work is based on ci13xxx rework done by Alexander Shishkin.

To let Greg pick up, I also added patches Alex queued that I depends on. Patch #1 - #9 : It can also be found at
http://github.com/virtuoso/linux-ci.git ci

This patch series can also be found at:
https://github.com/riczhao/kernel-imx/commits/topics/usb-driver

Status:
- this version only support host
- usbotg controler works at host role

Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

I'm interested in usb device support on mx28, what has to be implemented to get it working?

I don't have patch yet, but on the plan.

What needs to be done? I want to help/implement it.

I didn't have time to look at details yet. Things in FSL kernel may find a way to implement.

Thanks
Richard

Quoted 8 lines

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
reviewer
#28 lore raw

v6 cover add imx usb driver based on Greg next tree

In reply to Richard Zhao

Hi Richard/Shawn,

Quoted 6 lines · Richard Zhao

The work is based on ?ci13xxx rework done by Alexander Shishkin.

To let Greg pick up, I also added patches Alex queued that I depends on. Patch #1 - #9 : It can also be found at
http://github.com/virtuoso/linux-ci.git ci

Quoted 6 lines

This patch series can also be found at:
https://github.com/riczhao/kernel-imx/commits/topics/usb-driver

Status:
?- this version only support host
?- usbotg controler works at host role

I am testing this series on a mx23 board and I am getting:

LLLLLLLFCLJUncompressing Linux... done, booting the kernel.

[    0.000000] Booting Linux on physical CPU 0
[    0.000000] Linux version 3.5.0-rc3-00370-g4c6d617-dirty (fabio at fabio-Latitu2
[    0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] Machine: Freescale i.MX23 (Device Tree), model: i.MX23 Olinuxinod
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pa6
[    0.000000] Kernel command line: noinitrd console=ttyAMA0,115200 root=/dev/me
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 64MB = 64MB total
[    0.000000] Memory: 54584k/54584k available, 10952k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc046506c   (4469 kB)
[    0.000000]       .init : 0xc0466000 - 0xc0487000   ( 132 kB)
[    0.000000]       .data : 0xc0488000 - 0xc04c85c0   ( 258 kB)
[    0.000000]        .bss : 0xc04c85e4 - 0xc0a149e0   (5425 kB)
[    0.000000] SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, 1
[    0.000000] NR_IRQS:304
[    0.000000] sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps eves
[    0.000000] Console: colour dummy device 80x30
[    0.000000] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingr
[    0.000000] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.000000] ... MAX_LOCK_DEPTH:          48
[    0.000000] ... MAX_LOCKDEP_KEYS:        8191
[    0.000000] ... CLASSHASH_SIZE:          4096
[    0.000000] ... MAX_LOCKDEP_ENTRIES:     16384
[    0.000000] ... MAX_LOCKDEP_CHAINS:      32768
[    0.000000] ... CHAINHASH_SIZE:          16384
[    0.000000]  memory used by lock dependency info: 3695 kB
[    0.000000]  per task-struct memory footprint: 1152 bytes
[    0.070000] Calibrating delay loop... 226.09 BogoMIPS (lpj=1130496)
[    0.070000] pid_max: default: 32768 minimum: 301
[    0.070000] Mount-cache hash table entries: 512
[    0.080000] CPU: Testing write buffer coherency: ok
[    0.080000] Setting up static identity map for 0x4032adc8 - 0x4032ae20
[    0.090000] devtmpfs: initialized
[    0.110000] pinctrl core: initialized pinctrl subsystem
[    0.110000] dummy:
[    0.120000] NET: Registered protocol family 16
[    0.150000] Serial: AMBA PL011 UART driver
[    0.150000] 80070000.serial: ttyAMA0 at MMIO 0x80070000 (irq = 0) is a PL0112
[    0.320000] console [ttyAMA0] enabled
[    0.360000] bio: create slab <bio-0> at 0
[    0.370000] mxs-dma 80004000.dma-apbh: initialized
[    0.380000] mxs-dma 80024000.dma-apbx: initialized
[    0.390000] usb0_vbus: 5000 mV
[    0.390000] SCSI subsystem initialized
[    0.400000] usbcore: registered new interface driver usbfs
[    0.400000] usbcore: registered new interface driver hub
[    0.410000] usbcore: registered new device driver usb
[    0.410000] Advanced Linux Sound Architecture Driver Version 1.0.25.
[    0.420000] Switching to clocksource mxs_timer
[    0.630000] NET: Registered protocol family 2
[    0.640000] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.650000] TCP established hash table entries: 2048 (order: 2, 16384 bytes)
[    0.660000] TCP bind hash table entries: 2048 (order: 4, 73728 bytes)
[    0.660000] TCP: Hash tables configured (established 2048 bind 2048)
[    0.670000] TCP: reno registered
[    0.680000] UDP hash table entries: 256 (order: 2, 20480 bytes)
[    0.680000] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes)
[    0.690000] NET: Registered protocol family 1
[    0.700000] RPC: Registered named UNIX socket transport module.
[    0.700000] RPC: Registered udp transport module.
[    0.710000] RPC: Registered tcp transport module.
[    0.710000] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.720000] NetWinder Floating Point Emulator V0.97 (double precision)
[    0.800000] NFS: Registering the id_resolver key type
[    0.810000] Key type id_resolver registered
[    0.820000] msgmni has been set to 106
[    0.820000] Block layer SCSI generic (bsg) driver version 0.4 loaded (major )
[    0.830000] io scheduler noop registered (default)
[    0.840000] uart-pl011 80070000.serial: no DMA platform data
[    0.850000] Initializing USB Mass Storage driver...
[    0.850000] usbcore: registered new interface driver usb-storage
[    0.860000] USB Mass Storage support registered.
[    0.870000] ci_hdrc ci_hdrc.0: doesn't support gadget
[    0.870000] ci_hdrc ci_hdrc.0: ChipIdea HDRC EHCI
[    0.880000] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[    0.940000] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[    0.950000] hub 1-0:1.0: USB hub found
[    0.960000] hub 1-0:1.0: 1 port detected
[    0.970000] mousedev: PS/2 mouse device common for all mice
[    0.970000] i2c /dev entries driver
[    1.020000] mxs-mmc 80010000.ssp: initialized
[    1.030000] usbcore: registered new interface driver usbhid
[    1.040000] usbhid: USB HID core driver
[    1.050000] TCP: cubic registered
[    1.060000] NET: Registered protocol family 17
[    1.070000] Key type dns_resolver registered
[    1.080000] registered taskstats version 1
[    1.080000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    1.090000] ALSA device list:
[    1.090000]   No soundcards found.
[    1.100000] Waiting for root device /dev/mmcblk0p2...
[    1.120000] mmc0: host does not support reading read-only switch. assuming w.
[    1.130000] mmc0: new high speed SDHC card at address 1234
[    1.140000] mmcblk0: mmc0:1234 SA08G 7.41 GiB
[    1.160000]  mmcblk0: p1 p2
[    1.220000] hub 1-0:1.0: unable to enumerate USB device on port 1

.....

[    2.800000] hub 1-0:1.0: unable to enumerate USB device on port 1
[    3.020000] hub 1-0:1.0: unable to enumerate USB device on port 1
[    3.240000] hub 1-0:1.0: unable to enumerate USB device on port 1
[    3.460000] hub 1-0:1.0: unable to enumerate USB device on port 1
[    3.680000] hub 1-0:1.0: unable to enumerate USB device on port 1
[    3.900000] hub 1-0:1.0: unable to enumerate USB device on port 1
[    4.120000] hub 1-0:1.0: unable to enumerate USB device on port 1

... (continues forever)

Any suggestions as to how to make the driver work on mx23?

Thanks,

Fabio Estevam

#29 lore raw

v6 cover add imx usb driver based on Greg next tree

Quoted 2 lines · Fabio Estevam

Any suggestions as to how to make the driver work on mx23?

I won't be able to test it on my imx23-evk board, because the board design is somehow odd on vbus supply, which probably requires a board rework.

Signature · 2 lines
Regards,
Shawn
#30 lore raw

v6 cover add imx usb driver based on Greg next tree

Dear Shawn Guo,

Quoted 6 lines · Fabio Estevam
Quoted 1 line

Any suggestions as to how to make the driver work on mx23?

I won't be able to test it on my imx23-evk board, because the board design is somehow odd on vbus supply, which probably requires a board rework.

We should be able to hack around the olinuxino. I just got the card image from Tsvetan.

Best regards,
Marek Vasut

reviewer
#31 lore raw

v6 cover add imx usb driver based on Greg next tree

In reply to Shawn Guo
Quoted 6 lines · Shawn Guo
Quoted 2 lines · Fabio Estevam

Any suggestions as to how to make the driver work on mx23?

I won't be able to test it on my imx23-evk board, because the board design is somehow odd on vbus supply, which probably requires a board rework.

Which board rework?

It looks like the 2.6.35 FSL kernel supports USB host on mx23evk without the need of hardware rework.

Can we try getting USB to work on mx23 too?

Regards,

Fabio Estevam