All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix
@ 2012-08-28  7:03 Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 01/11] USB: chipidea: imx: add pinctrl support Richard Zhao
                   ` (12 more replies)
  0 siblings, 13 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

The patch set is tested on imx6q_sabrelite board.

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

For test which merged platform patches:
https://github.com/riczhao/kernel-imx/commits/topics/usb-test

Changes since v1:
 - move usbmisc as the other patch series.
 - remove regulater_disable and old comments in ci13xxx_imx.

Richard Zhao (11):
  USB: chipidea: imx: add pinctrl support
  USB: chipidea: delay 2ms before read ID status at probe time
  USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq
    handler
  USB: chipidea: clear gadget struct at udc_start fail path
  USB: chipidea: don't let probe fail if otg controller start one role
    failed
  USB: mxs-phy: add basic otg support
  USB: chipidea: add vbus detect for udc
  USB: chipidea: convert to use devm_request_irq
  USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG
  USB: chipidea: add set_vbus_power support
  USB: chipidea: re-order irq handling to avoid unhandled irq

 drivers/usb/chipidea/Makefile      |    2 ++
 drivers/usb/chipidea/ci.h          |    1 +
 drivers/usb/chipidea/ci13xxx_imx.c |   51 +++++++++++++++++++++++-------------
 drivers/usb/chipidea/core.c        |   36 +++++++++++++++----------
 drivers/usb/chipidea/host.c        |    8 ++++++
 drivers/usb/chipidea/udc.c         |   40 +++++++++++++++++++++++++++-
 drivers/usb/otg/mxs-phy.c          |   21 +++++++++++++++
 include/linux/usb/chipidea.h       |    2 ++
 8 files changed, 128 insertions(+), 33 deletions(-)

-- 
1.7.9.5

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

* [PATCH v2 01/11] USB: chipidea: imx: add pinctrl support
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 02/11] USB: chipidea: delay 2ms before read ID status at probe time Richard Zhao
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

Some controllers may not need to setup pinctrl, so we don't fail the
probe if pinctrl get/select failed.

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/ci13xxx_imx.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 96ac67b..0f5ca4b 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -20,6 +20,7 @@
 #include <linux/usb/chipidea.h>
 #include <linux/clk.h>
 #include <linux/regulator/consumer.h>
+#include <linux/pinctrl/consumer.h>
 
 #include "ci.h"
 #include "ci13xxx_imx.h"
@@ -99,6 +100,7 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
 	struct device_node *phy_np;
 	struct resource *res;
 	struct regulator *reg_vbus;
+	struct pinctrl *pinctrl;
 	int ret;
 
 	if (of_find_property(pdev->dev.of_node, "fsl,usbmisc", NULL)
@@ -117,6 +119,11 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
+	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
+	if (IS_ERR(pinctrl))
+		dev_warn(&pdev->dev, "pinctrl get/select failed, err=%ld\n",
+			PTR_ERR(pinctrl));
+
 	data->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(data->clk)) {
 		dev_err(&pdev->dev,
-- 
1.7.9.5

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

* [PATCH v2 02/11] USB: chipidea: delay 2ms before read ID status at probe time
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 01/11] USB: chipidea: imx: add pinctrl support Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 03/11] USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq handler Richard Zhao
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

The ID pin needs 1ms debounce time, event at probe time. We delay 2ms
for safe.

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/core.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 1083585..3c3ed77 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -462,6 +462,8 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
 
 	if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) {
 		ci->is_otg = true;
+		/* ID pin needs 1ms debouce time, we delay 2ms for safe */
+		mdelay(2);
 		ci->role = ci_otg_role(ci);
 	} else {
 		ci->role = ci->roles[CI_ROLE_HOST]
-- 
1.7.9.5

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

* [PATCH v2 03/11] USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq handler
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 01/11] USB: chipidea: imx: add pinctrl support Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 02/11] USB: chipidea: delay 2ms before read ID status at probe time Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path Richard Zhao
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

OTGSC_IDIS must be cleared in irq handler to avoid re-queue the work.

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/core.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 3c3ed77..19ef324 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -273,8 +273,6 @@ static void ci_role_work(struct work_struct *work)
 	struct ci13xxx *ci = container_of(work, struct ci13xxx, work);
 	enum ci_role role = ci_otg_role(ci);
 
-	hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS);
-
 	if (role != ci->role) {
 		dev_dbg(ci->dev, "switching from %s to %s\n",
 			ci_role(ci)->name, ci->roles[role]->name);
@@ -325,6 +323,7 @@ static irqreturn_t ci_irq(int irq, void *data)
 		u32 sts = hw_read(ci, OP_OTGSC, ~0);
 
 		if (sts & OTGSC_IDIS) {
+			hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS);
 			queue_work(ci->wq, &ci->work);
 			ret = IRQ_HANDLED;
 		}
-- 
1.7.9.5

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

* [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (2 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 03/11] USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq handler Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-08-28  8:29   ` Alexander Shishkin
  2012-08-28  7:03 ` [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed Richard Zhao
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

States in gadget are not needed any more, set it to zero.

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/udc.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c7a032a..9fb6394 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1746,6 +1746,7 @@ free_pools:
 	dma_pool_destroy(ci->td_pool);
 free_qh_pool:
 	dma_pool_destroy(ci->qh_pool);
+	memset(&ci->gadget, 0, sizeof(ci->gadget));
 	return retval;
 }
 
-- 
1.7.9.5

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (3 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-08-28  8:38   ` Alexander Shishkin
  2012-08-28  7:03 ` [PATCH v2 06/11] USB: mxs-phy: add basic otg support Richard Zhao
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

One role failed, but the other role will possiblly still work.
For example, when udc start failed, if plug in a host device,
it works.

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/core.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 19ef324..8fd390a 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
 	ret = ci_role_start(ci, ci->role);
 	if (ret) {
 		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
-		ret = -ENODEV;
-		goto rm_wq;
+		ci->role = CI_ROLE_END;
+		if (!ci->is_otg) {
+			ret = -ENODEV;
+			goto rm_wq;
+		}
 	}
 
 	platform_set_drvdata(pdev, ci);
-- 
1.7.9.5

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

* [PATCH v2 06/11] USB: mxs-phy: add basic otg support
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (4 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-09-11  9:05   ` Felipe Balbi
                     ` (2 more replies)
  2012-08-28  7:03 ` [PATCH v2 07/11] USB: chipidea: add vbus detect for udc Richard Zhao
                   ` (6 subsequent siblings)
  12 siblings, 3 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/otg/mxs-phy.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
index c1a67cb..6a03e97 100644
--- a/drivers/usb/otg/mxs-phy.c
+++ b/drivers/usb/otg/mxs-phy.c
@@ -97,12 +97,24 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy, int port)
 	return 0;
 }
 
+static int mxs_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
+{
+	return 0;
+}
+
+static int mxs_phy_set_peripheral(struct usb_otg *otg,
+					struct usb_gadget *gadget)
+{
+	return 0;
+}
+
 static int mxs_phy_probe(struct platform_device *pdev)
 {
 	struct resource *res;
 	void __iomem *base;
 	struct clk *clk;
 	struct mxs_phy *mxs_phy;
+	struct usb_otg *otg;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -139,6 +151,15 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
 	mxs_phy->clk = clk;
 
+	otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), GFP_KERNEL);
+	if (!otg)
+		return -ENOMEM;
+	otg->phy = &mxs_phy->phy;
+	otg->set_host = mxs_phy_set_host;
+	otg->set_peripheral = mxs_phy_set_peripheral;
+
+	mxs_phy->phy.otg = otg;
+
 	platform_set_drvdata(pdev, &mxs_phy->phy);
 
 	return 0;
-- 
1.7.9.5

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

* [PATCH v2 07/11] USB: chipidea: add vbus detect for udc
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (5 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 06/11] USB: mxs-phy: add basic otg support Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 08/11] USB: chipidea: convert to use devm_request_irq Richard Zhao
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

Using vbus valid interrupt to detect vbus.

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/ci.h  |    1 +
 drivers/usb/chipidea/udc.c |   39 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index d738603..e25d126 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -139,6 +139,7 @@ struct ci13xxx {
 	enum ci_role			role;
 	bool				is_otg;
 	struct work_struct		work;
+	struct work_struct		vbus_work;
 	struct workqueue_struct		*wq;
 
 	struct dma_pool			*qh_pool;
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 9fb6394..2cb4498 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -308,6 +308,18 @@ static u32 hw_test_and_clear_intr_active(struct ci13xxx *ci)
 	return reg;
 }
 
+static void hw_enable_vbus_intr(struct ci13xxx *ci)
+{
+	hw_write(ci, OP_OTGSC, OTGSC_AVVIS, OTGSC_AVVIS);
+	hw_write(ci, OP_OTGSC, OTGSC_AVVIE, OTGSC_AVVIE);
+	queue_work(ci->wq, &ci->vbus_work);
+}
+
+static void hw_disable_vbus_intr(struct ci13xxx *ci)
+{
+	hw_write(ci, OP_OTGSC, OTGSC_AVVIE, 0);
+}
+
 /**
  * hw_test_and_clear_setup_guard: test & clear setup guard (execute without
  *                                interruption)
@@ -374,6 +386,16 @@ static int hw_usb_reset(struct ci13xxx *ci)
 	return 0;
 }
 
+static void vbus_work(struct work_struct *work)
+{
+	struct ci13xxx *ci = container_of(work, struct ci13xxx, vbus_work);
+
+	if (hw_read(ci, OP_OTGSC, OTGSC_AVV))
+		usb_gadget_vbus_connect(&ci->gadget);
+	else
+		usb_gadget_vbus_disconnect(&ci->gadget);
+}
+
 /******************************************************************************
  * UTIL block
  *****************************************************************************/
@@ -1376,6 +1398,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
 		if (is_active) {
 			pm_runtime_get_sync(&_gadget->dev);
 			hw_device_reset(ci, USBMODE_CM_DC);
+			hw_enable_vbus_intr(ci);
 			hw_device_state(ci, ci->ep0out->qh.dma);
 		} else {
 			hw_device_state(ci, 0);
@@ -1517,8 +1540,10 @@ static int ci13xxx_start(struct usb_gadget *gadget,
 	pm_runtime_get_sync(&ci->gadget.dev);
 	if (ci->platdata->flags & CI13XXX_PULLUP_ON_VBUS) {
 		if (ci->vbus_active) {
-			if (ci->platdata->flags & CI13XXX_REGS_SHARED)
+			if (ci->platdata->flags & CI13XXX_REGS_SHARED) {
 				hw_device_reset(ci, USBMODE_CM_DC);
+				hw_enable_vbus_intr(ci);
+			}
 		} else {
 			pm_runtime_put_sync(&ci->gadget.dev);
 			goto done;
@@ -1624,6 +1649,13 @@ static irqreturn_t udc_irq(struct ci13xxx *ci)
 	} else {
 		retval = IRQ_NONE;
 	}
+
+	intr = hw_read(ci, OP_OTGSC, ~0);
+	hw_write(ci, OP_OTGSC, ~0, intr);
+
+	if (intr & (OTGSC_AVVIE & OTGSC_AVVIS))
+		queue_work(ci->wq, &ci->vbus_work);
+
 	spin_unlock(&ci->lock);
 
 	return retval;
@@ -1699,6 +1731,7 @@ static int udc_start(struct ci13xxx *ci)
 		retval = hw_device_reset(ci, USBMODE_CM_DC);
 		if (retval)
 			goto put_transceiver;
+		hw_enable_vbus_intr(ci);
 	}
 
 	retval = device_register(&ci->gadget.dev);
@@ -1762,6 +1795,9 @@ static void udc_stop(struct ci13xxx *ci)
 	if (ci == NULL)
 		return;
 
+	hw_disable_vbus_intr(ci);
+	cancel_work_sync(&ci->vbus_work);
+
 	usb_del_gadget_udc(&ci->gadget);
 
 	for (i = 0; i < ci->hw_ep_max; i++) {
@@ -1806,6 +1842,7 @@ int ci_hdrc_gadget_init(struct ci13xxx *ci)
 	rdrv->irq	= udc_irq;
 	rdrv->name	= "gadget";
 	ci->roles[CI_ROLE_GADGET] = rdrv;
+	INIT_WORK(&ci->vbus_work, vbus_work);
 
 	return 0;
 }
-- 
1.7.9.5

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

* [PATCH v2 08/11] USB: chipidea: convert to use devm_request_irq
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (6 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 07/11] USB: chipidea: add vbus detect for udc Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 09/11] USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG Richard Zhao
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/core.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 8fd390a..7485c84 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -481,8 +481,8 @@ 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->platdata->name,
-			  ci);
+	ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED,
+				ci->platdata->name, ci);
 	if (ret)
 		goto stop;
 
@@ -513,7 +513,6 @@ static int __devexit ci_hdrc_remove(struct platform_device *pdev)
 	flush_workqueue(ci->wq);
 	destroy_workqueue(ci->wq);
 	device_remove_file(ci->dev, &dev_attr_role);
-	free_irq(ci->irq, ci);
 	ci_role_stop(ci);
 
 	return 0;
-- 
1.7.9.5

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

* [PATCH v2 09/11] USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (7 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 08/11] USB: chipidea: convert to use devm_request_irq Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 10/11] USB: chipidea: add set_vbus_power support Richard Zhao
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/Makefile |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 57e510f..d92ca32 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -1,3 +1,5 @@
+ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG
+
 obj-$(CONFIG_USB_CHIPIDEA)		+= ci_hdrc.o
 
 ci_hdrc-y				:= core.o
-- 
1.7.9.5

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

* [PATCH v2 10/11] USB: chipidea: add set_vbus_power support
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (8 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 09/11] USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-09-19  1:25   ` Richard Zhao
  2012-08-28  7:03 ` [PATCH v2 11/11] USB: chipidea: re-order irq handling to avoid unhandled irq Richard Zhao
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

set_vbus_power is used to enable or disable vbus power for usb host.

[Marc Kleine-Budde <mkl@pengutronix.de>: fix regulator unbalance disable]

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/ci13xxx_imx.c |   44 +++++++++++++++++++++---------------
 drivers/usb/chipidea/host.c        |    8 +++++++
 include/linux/usb/chipidea.h       |    2 ++
 3 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
index 0f5ca4b..5c0be08 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -27,6 +27,8 @@
 
 #define pdev_to_phy(pdev) \
 	((struct usb_phy *)platform_get_drvdata(pdev))
+#define ci_to_imx_data(ci) \
+	((struct ci13xxx_imx_data *)dev_get_drvdata(ci->dev->parent))
 
 struct ci13xxx_imx_data {
 	struct device_node *phy_np;
@@ -85,12 +87,32 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
 
 /* End of common functions shared by usbmisc drivers*/
 
+static int ci13xxx_imx_vbus(struct ci13xxx *ci, int enable)
+{
+	struct ci13xxx_imx_data *data = ci_to_imx_data(ci);
+	int ret;
+
+	if (!data->reg_vbus)
+		return 0;
+
+	if (enable)
+		ret = regulator_enable(data->reg_vbus);
+	else
+		ret = regulator_disable(data->reg_vbus);
+	if (ret)
+		dev_err(ci->dev, "ci13xxx_imx_vbus failed, enable:%d err:%d\n",
+			enable, ret);
+
+	return ret;
+}
+
 static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata  = {
 	.name			= "ci13xxx_imx",
 	.flags			= CI13XXX_REQUIRE_TRANSCEIVER |
 				  CI13XXX_PULLUP_ON_VBUS |
 				  CI13XXX_DISABLE_STREAMING,
 	.capoffset		= DEF_CAPOFFSET,
+	.set_vbus_power		= ci13xxx_imx_vbus,
 };
 
 static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
@@ -153,20 +175,11 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
 		}
 	}
 
-	/* we only support host now, so enable vbus here */
 	reg_vbus = devm_regulator_get(&pdev->dev, "vbus");
-	if (!IS_ERR(reg_vbus)) {
-		ret = regulator_enable(reg_vbus);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"Failed to enable vbus regulator, err=%d\n",
-				ret);
-			goto put_np;
-		}
+	if (!IS_ERR(reg_vbus))
 		data->reg_vbus = reg_vbus;
-	} else {
+	else
 		reg_vbus = NULL;
-	}
 
 	ci13xxx_imx_platdata.phy = data->phy;
 
@@ -191,6 +204,8 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
 		}
 	}
 
+	platform_set_drvdata(pdev, data);
+
 	plat_ci = ci13xxx_add_device(&pdev->dev,
 				pdev->resource, pdev->num_resources,
 				&ci13xxx_imx_platdata);
@@ -203,7 +218,6 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
 	}
 
 	data->ci_pdev = plat_ci;
-	platform_set_drvdata(pdev, data);
 
 	pm_runtime_no_callbacks(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
@@ -211,9 +225,6 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
 	return 0;
 
 err:
-	if (reg_vbus)
-		regulator_disable(reg_vbus);
-put_np:
 	if (phy_np)
 		of_node_put(phy_np);
 	clk_disable_unprepare(data->clk);
@@ -227,9 +238,6 @@ static int __devexit ci13xxx_imx_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 	ci13xxx_remove_device(data->ci_pdev);
 
-	if (data->reg_vbus)
-		regulator_disable(data->reg_vbus);
-
 	if (data->phy) {
 		usb_phy_shutdown(data->phy);
 		module_put(data->phy->dev->driver->owner);
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index ebff9f4..e091147 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -106,6 +106,12 @@ static int host_start(struct ci13xxx *ci)
 	if (usb_disabled())
 		return -ENODEV;
 
+	if (ci->platdata->set_vbus_power) {
+		ret = ci->platdata->set_vbus_power(ci, 1);
+		if (ret)
+			return ret;
+	}
+
 	hcd = usb_create_hcd(&ci_ehci_hc_driver, ci->dev, dev_name(ci->dev));
 	if (!hcd)
 		return -ENOMEM;
@@ -138,6 +144,8 @@ static void host_stop(struct ci13xxx *ci)
 
 	usb_remove_hcd(hcd);
 	usb_put_hcd(hcd);
+	if (ci->platdata->set_vbus_power)
+		ci->platdata->set_vbus_power(ci, 0);
 }
 
 int ci_hdrc_host_init(struct ci13xxx *ci)
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 544825d..080f479 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -23,6 +23,8 @@ struct ci13xxx_platform_data {
 #define CI13XXX_CONTROLLER_RESET_EVENT		0
 #define CI13XXX_CONTROLLER_STOPPED_EVENT	1
 	void	(*notify_event) (struct ci13xxx *ci, unsigned event);
+	/* set vbus power, it must be called in non-atomic context */
+	int	(*set_vbus_power) (struct ci13xxx *ci, int enable);
 };
 
 /* Default offset of capability registers */
-- 
1.7.9.5

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

* [PATCH v2 11/11] USB: chipidea: re-order irq handling to avoid unhandled irq
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (9 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 10/11] USB: chipidea: add set_vbus_power support Richard Zhao
@ 2012-08-28  7:03 ` Richard Zhao
  2012-09-05 14:27 ` [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Marc Kleine-Budde
  2012-09-05 15:01 ` Michael Grzeschik
  12 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  7:03 UTC (permalink / raw)
  To: linux-arm-kernel

- let role driver handle irq before ID change check. It give the
  role driver a chance to handle disconnect.
- disable irq during switch role. No role driver to handle irq in
  the period.

Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
---
 drivers/usb/chipidea/core.c |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 7485c84..0942b9b 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -279,6 +279,7 @@ static void ci_role_work(struct work_struct *work)
 
 		ci_role_stop(ci);
 		ci_role_start(ci, role);
+		enable_irq(ci->irq);
 	}
 }
 
@@ -318,18 +319,22 @@ static irqreturn_t ci_irq(int irq, void *data)
 {
 	struct ci13xxx *ci = data;
 	irqreturn_t ret = IRQ_NONE;
+	u32 otgsc = 0;
 
-	if (ci->is_otg) {
-		u32 sts = hw_read(ci, OP_OTGSC, ~0);
+	if (ci->is_otg)
+		otgsc = hw_read(ci, OP_OTGSC, ~0);
 
-		if (sts & OTGSC_IDIS) {
-			hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS);
-			queue_work(ci->wq, &ci->work);
-			ret = IRQ_HANDLED;
-		}
+	if (ci->role != CI_ROLE_END)
+		ret = ci_role(ci)->irq(ci);
+
+	if (ci->is_otg && (otgsc & OTGSC_IDIS)) {
+		hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS);
+		disable_irq_nosync(ci->irq);
+		queue_work(ci->wq, &ci->work);
+		ret = IRQ_HANDLED;
 	}
 
-	return ci->role == CI_ROLE_END ? ret : ci_role(ci)->irq(ci);
+	return ret;
 }
 
 static DEFINE_IDA(ci_ida);
-- 
1.7.9.5

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

* [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path
  2012-08-28  7:03 ` [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path Richard Zhao
@ 2012-08-28  8:29   ` Alexander Shishkin
  2012-08-28  9:09     ` Richard Zhao
  0 siblings, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-08-28  8:29 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> States in gadget are not needed any more, set it to zero.

It's generally a good practice to mention in the commit message what is
it that you are fixing with this patch.

> Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> ---
>  drivers/usb/chipidea/udc.c |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index c7a032a..9fb6394 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -1746,6 +1746,7 @@ free_pools:
>  	dma_pool_destroy(ci->td_pool);
>  free_qh_pool:
>  	dma_pool_destroy(ci->qh_pool);
> +	memset(&ci->gadget, 0, sizeof(ci->gadget));

I understand that you're probably hitting "kobject already initialized"
warning here, but I think the real problem is that this function gets
called twice and fails the first time. Why does that happen?

In any case, please elaborate on the problem.

Regards,
--
Alex

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-28  7:03 ` [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed Richard Zhao
@ 2012-08-28  8:38   ` Alexander Shishkin
  2012-08-28  9:27     ` Richard Zhao
  0 siblings, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-08-28  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> One role failed, but the other role will possiblly still work.
> For example, when udc start failed, if plug in a host device,
> it works.

If you're a host device, ci->role should be HOST at this point and
ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
role detection must be fixed. If ci_role_start() fails for host, but it
still works when it's called again after the id pin change is detected,
again, the problem is elsewhere.

>
> Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> ---
>  drivers/usb/chipidea/core.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 19ef324..8fd390a 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
>  	ret = ci_role_start(ci, ci->role);
>  	if (ret) {
>  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
> -		ret = -ENODEV;
> -		goto rm_wq;
> +		ci->role = CI_ROLE_END;

So are you relying on id pin interrupt for initializing the role after
this? Can you provide more details?

Regards,
--
Alex

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

* [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path
  2012-08-28  8:29   ` Alexander Shishkin
@ 2012-08-28  9:09     ` Richard Zhao
  2012-08-29  8:03       ` Alexander Shishkin
  0 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 28, 2012 at 11:29:35AM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > States in gadget are not needed any more, set it to zero.
> 
> It's generally a good practice to mention in the commit message what is
> it that you are fixing with this patch.
It fixes the following dump if udc_start register gadget->dev but fail
the start process:
kobject (bf8330a0): tried to init an initialized object, something is seriously wrong.
[<80011d90>] (dump_backtrace+0x0/0x10c) from [<804b65ac>] (dump_stack+0x18/0x1c)
[<804b6594>] (dump_stack+0x0/0x1c) from [<80247d98>] (kobject_init+0x7c/0x9c)
[<80247d1c>] (kobject_init+0x0/0x9c) from [<802a3870>] (device_initialize+0x28/0x70)
[<802a3848>] (device_initialize+0x0/0x70) from [<802a4798>] (device_register+0x14/0x20)
[<802a4784>] (device_register+0x0/0x20) from [<80359a70>] (udc_start+0x180/0x2c8)
[<803598f0>] (udc_start+0x0/0x2c8) from [<80356e9c>] (ci_role_work+0xc8/0xec)
[<80356dd4>] (ci_role_work+0x0/0xec) from [<8003a8a0>] (process_one_work+0x158/0x474)
[<8003a748>] (process_one_work+0x0/0x474) from [<8003af6c>] (worker_thread+0x140/0x3b4)
[<8003ae2c>] (worker_thread+0x0/0x3b4) from [<8003fe60>] (kthread+0x90/0x9c)
[<8003fdd0>] (kthread+0x0/0x9c) from [<8002774c>] (do_exit+0x0/0x350)
> 
> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> > ---
> >  drivers/usb/chipidea/udc.c |    1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> > index c7a032a..9fb6394 100644
> > --- a/drivers/usb/chipidea/udc.c
> > +++ b/drivers/usb/chipidea/udc.c
> > @@ -1746,6 +1746,7 @@ free_pools:
> >  	dma_pool_destroy(ci->td_pool);
> >  free_qh_pool:
> >  	dma_pool_destroy(ci->qh_pool);
> > +	memset(&ci->gadget, 0, sizeof(ci->gadget));
> 
> I understand that you're probably hitting "kobject already initialized"
> warning here, but I think the real problem is that this function gets
> called twice and fails the first time. Why does that happen?
I saw the dump at early stage of adding imx otg support, when there's
things not ready. I think it's less important why udc_start fail,
because no one enable imx otg before.  It's important when it fails,
the dump shows up.

Thanks
Richard
> 
> In any case, please elaborate on the problem.
> 
> Regards,
> --
> Alex
> 

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-28  8:38   ` Alexander Shishkin
@ 2012-08-28  9:27     ` Richard Zhao
  2012-08-29  8:10       ` Alexander Shishkin
  0 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-08-28  9:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > One role failed, but the other role will possiblly still work.
> > For example, when udc start failed, if plug in a host device,
> > it works.
> 
> If you're a host device, ci->role should be HOST at this point and
> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
> role detection must be fixed. If ci_role_start() fails for host, but it
> still works when it's called again after the id pin change is detected,
> again, the problem is elsewhere.
The check is only for OTG device. For single role device, it just fail
if it start the role failed.
> 
> >
> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> > ---
> >  drivers/usb/chipidea/core.c |    7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index 19ef324..8fd390a 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
> >  	ret = ci_role_start(ci, ci->role);
> >  	if (ret) {
> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
> > -		ret = -ENODEV;
> > -		goto rm_wq;
> > +		ci->role = CI_ROLE_END;
> 
> So are you relying on id pin interrupt for initializing the role after
> this? Can you provide more details?
Yes. The ID pin detect still works. My case is, gadget role failed,
host role works. I was trying not to ruin host function.

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

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

* [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path
  2012-08-28  9:09     ` Richard Zhao
@ 2012-08-29  8:03       ` Alexander Shishkin
  2012-08-29  8:22         ` Richard Zhao
  0 siblings, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-08-29  8:03 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> On Tue, Aug 28, 2012 at 11:29:35AM +0300, Alexander Shishkin wrote:
>> Richard Zhao <richard.zhao@freescale.com> writes:
>> 
>> > States in gadget are not needed any more, set it to zero.
>> 
>> It's generally a good practice to mention in the commit message what is
>> it that you are fixing with this patch.
> It fixes the following dump if udc_start register gadget->dev but fail
> the start process:
> kobject (bf8330a0): tried to init an initialized object, something is seriously wrong.
> [<80011d90>] (dump_backtrace+0x0/0x10c) from [<804b65ac>] (dump_stack+0x18/0x1c)
> [<804b6594>] (dump_stack+0x0/0x1c) from [<80247d98>] (kobject_init+0x7c/0x9c)
> [<80247d1c>] (kobject_init+0x0/0x9c) from [<802a3870>] (device_initialize+0x28/0x70)
> [<802a3848>] (device_initialize+0x0/0x70) from [<802a4798>] (device_register+0x14/0x20)
> [<802a4784>] (device_register+0x0/0x20) from [<80359a70>] (udc_start+0x180/0x2c8)
> [<803598f0>] (udc_start+0x0/0x2c8) from [<80356e9c>] (ci_role_work+0xc8/0xec)
> [<80356dd4>] (ci_role_work+0x0/0xec) from [<8003a8a0>] (process_one_work+0x158/0x474)
> [<8003a748>] (process_one_work+0x0/0x474) from [<8003af6c>] (worker_thread+0x140/0x3b4)
> [<8003ae2c>] (worker_thread+0x0/0x3b4) from [<8003fe60>] (kthread+0x90/0x9c)
> [<8003fdd0>] (kthread+0x0/0x9c) from [<8002774c>] (do_exit+0x0/0x350)
>> 
>> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
>> > ---
>> >  drivers/usb/chipidea/udc.c |    1 +
>> >  1 file changed, 1 insertion(+)
>> >
>> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
>> > index c7a032a..9fb6394 100644
>> > --- a/drivers/usb/chipidea/udc.c
>> > +++ b/drivers/usb/chipidea/udc.c
>> > @@ -1746,6 +1746,7 @@ free_pools:
>> >  	dma_pool_destroy(ci->td_pool);
>> >  free_qh_pool:
>> >  	dma_pool_destroy(ci->qh_pool);
>> > +	memset(&ci->gadget, 0, sizeof(ci->gadget));
>> 
>> I understand that you're probably hitting "kobject already initialized"
>> warning here, but I think the real problem is that this function gets
>> called twice and fails the first time. Why does that happen?
> I saw the dump at early stage of adding imx otg support, when there's
> things not ready. I think it's less important why udc_start fail,
> because no one enable imx otg before.  It's important when it fails,
> the dump shows up.

I'd prefer that whenever udc_start() fails it doesn't go unnoticed,
except probably for the cases when it fails due to transceiver not being
ready at the probe time, which needs to be handled separately.

Regards,
--
Alex

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-28  9:27     ` Richard Zhao
@ 2012-08-29  8:10       ` Alexander Shishkin
  2012-08-29  8:33         ` Richard Zhao
  0 siblings, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-08-29  8:10 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
>> Richard Zhao <richard.zhao@freescale.com> writes:
>> 
>> > One role failed, but the other role will possiblly still work.
>> > For example, when udc start failed, if plug in a host device,
>> > it works.
>> 
>> If you're a host device, ci->role should be HOST at this point and
>> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
>> role detection must be fixed. If ci_role_start() fails for host, but it
>> still works when it's called again after the id pin change is detected,
>> again, the problem is elsewhere.
> The check is only for OTG device. For single role device, it just fail
> if it start the role failed.

Sorry, can you rephrase?

>> 
>> >
>> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
>> > ---
>> >  drivers/usb/chipidea/core.c |    7 +++++--
>> >  1 file changed, 5 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>> > index 19ef324..8fd390a 100644
>> > --- a/drivers/usb/chipidea/core.c
>> > +++ b/drivers/usb/chipidea/core.c
>> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
>> >  	ret = ci_role_start(ci, ci->role);
>> >  	if (ret) {
>> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
>> > -		ret = -ENODEV;
>> > -		goto rm_wq;
>> > +		ci->role = CI_ROLE_END;
>> 
>> So are you relying on id pin interrupt for initializing the role after
>> this? Can you provide more details?
> Yes. The ID pin detect still works. My case is, gadget role failed,
> host role works. I was trying not to ruin host function.

But it shouldn't even try to start the gadget, because ci_otg_role()
should set ci->role to HOST before ci_role_start() happens.

Another question is, why does gadget start fail?

Regards,
--
Alex

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

* [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path
  2012-08-29  8:03       ` Alexander Shishkin
@ 2012-08-29  8:22         ` Richard Zhao
  2012-08-29  9:44           ` Alexander Shishkin
  0 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-08-29  8:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 29, 2012 at 11:03:48AM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > On Tue, Aug 28, 2012 at 11:29:35AM +0300, Alexander Shishkin wrote:
> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> 
> >> > States in gadget are not needed any more, set it to zero.
> >> 
> >> It's generally a good practice to mention in the commit message what is
> >> it that you are fixing with this patch.
> > It fixes the following dump if udc_start register gadget->dev but fail
> > the start process:
> > kobject (bf8330a0): tried to init an initialized object, something is seriously wrong.
> > [<80011d90>] (dump_backtrace+0x0/0x10c) from [<804b65ac>] (dump_stack+0x18/0x1c)
> > [<804b6594>] (dump_stack+0x0/0x1c) from [<80247d98>] (kobject_init+0x7c/0x9c)
> > [<80247d1c>] (kobject_init+0x0/0x9c) from [<802a3870>] (device_initialize+0x28/0x70)
> > [<802a3848>] (device_initialize+0x0/0x70) from [<802a4798>] (device_register+0x14/0x20)
> > [<802a4784>] (device_register+0x0/0x20) from [<80359a70>] (udc_start+0x180/0x2c8)
> > [<803598f0>] (udc_start+0x0/0x2c8) from [<80356e9c>] (ci_role_work+0xc8/0xec)
> > [<80356dd4>] (ci_role_work+0x0/0xec) from [<8003a8a0>] (process_one_work+0x158/0x474)
> > [<8003a748>] (process_one_work+0x0/0x474) from [<8003af6c>] (worker_thread+0x140/0x3b4)
> > [<8003ae2c>] (worker_thread+0x0/0x3b4) from [<8003fe60>] (kthread+0x90/0x9c)
> > [<8003fdd0>] (kthread+0x0/0x9c) from [<8002774c>] (do_exit+0x0/0x350)
> >> 
> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> >> > ---
> >> >  drivers/usb/chipidea/udc.c |    1 +
> >> >  1 file changed, 1 insertion(+)
> >> >
> >> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> >> > index c7a032a..9fb6394 100644
> >> > --- a/drivers/usb/chipidea/udc.c
> >> > +++ b/drivers/usb/chipidea/udc.c
> >> > @@ -1746,6 +1746,7 @@ free_pools:
> >> >  	dma_pool_destroy(ci->td_pool);
> >> >  free_qh_pool:
> >> >  	dma_pool_destroy(ci->qh_pool);
> >> > +	memset(&ci->gadget, 0, sizeof(ci->gadget));
> >> 
> >> I understand that you're probably hitting "kobject already initialized"
> >> warning here, but I think the real problem is that this function gets
> >> called twice and fails the first time. Why does that happen?
> > I saw the dump at early stage of adding imx otg support, when there's
> > things not ready. I think it's less important why udc_start fail,
> > because no one enable imx otg before.  It's important when it fails,
> > the dump shows up.
> 
> I'd prefer that whenever udc_start() fails it doesn't go unnoticed,
> except probably for the cases when it fails due to transceiver not being
> ready at the probe time, which needs to be handled separately.
Is it related to the patch? The patch is logically right that reset the
status, agree?

Thanks
Richard
> 
> Regards,
> --
> Alex
> 

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-29  8:10       ` Alexander Shishkin
@ 2012-08-29  8:33         ` Richard Zhao
  2012-08-29  9:48           ` Alexander Shishkin
  0 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-08-29  8:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> 
> >> > One role failed, but the other role will possiblly still work.
> >> > For example, when udc start failed, if plug in a host device,
> >> > it works.
> >> 
> >> If you're a host device, ci->role should be HOST at this point and
> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
> >> role detection must be fixed. If ci_role_start() fails for host, but it
> >> still works when it's called again after the id pin change is detected,
> >> again, the problem is elsewhere.
> > The check is only for OTG device. For single role device, it just fail
> > if it start the role failed.
> 
> Sorry, can you rephrase?
> 
> >> 
> >> >
> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> >> > ---
> >> >  drivers/usb/chipidea/core.c |    7 +++++--
> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> >> > index 19ef324..8fd390a 100644
> >> > --- a/drivers/usb/chipidea/core.c
> >> > +++ b/drivers/usb/chipidea/core.c
> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
> >> >  	ret = ci_role_start(ci, ci->role);
> >> >  	if (ret) {
> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
> >> > -		ret = -ENODEV;
> >> > -		goto rm_wq;
> >> > +		ci->role = CI_ROLE_END;
> >> 
> >> So are you relying on id pin interrupt for initializing the role after
> >> this? Can you provide more details?
> > Yes. The ID pin detect still works. My case is, gadget role failed,
> > host role works. I was trying not to ruin host function.
> 
> But it shouldn't even try to start the gadget, because ci_otg_role()
> should set ci->role to HOST before ci_role_start() happens.
It depends on ID pin. If ID pin is gadget and gadget is not support well,
ci_role_start will fail. See below example.
> 
> Another question is, why does gadget start fail?
There's one example:
If usb phy don't support otg yet, otg_set_peripheral will fail, and
then cause udc_start fail.

Thanks
Richard
> 
> Regards,
> --
> Alex
> 

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

* [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path
  2012-08-29  8:22         ` Richard Zhao
@ 2012-08-29  9:44           ` Alexander Shishkin
  2012-08-29 10:37             ` Richard Zhao
  0 siblings, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-08-29  9:44 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> On Wed, Aug 29, 2012 at 11:03:48AM +0300, Alexander Shishkin wrote:
>> Richard Zhao <richard.zhao@freescale.com> writes:
>> 
>> > On Tue, Aug 28, 2012 at 11:29:35AM +0300, Alexander Shishkin wrote:
>> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> 
>> >> > States in gadget are not needed any more, set it to zero.
>> >> 
>> >> It's generally a good practice to mention in the commit message what is
>> >> it that you are fixing with this patch.
>> > It fixes the following dump if udc_start register gadget->dev but fail
>> > the start process:
>> > kobject (bf8330a0): tried to init an initialized object, something is seriously wrong.
>> > [<80011d90>] (dump_backtrace+0x0/0x10c) from [<804b65ac>] (dump_stack+0x18/0x1c)
>> > [<804b6594>] (dump_stack+0x0/0x1c) from [<80247d98>] (kobject_init+0x7c/0x9c)
>> > [<80247d1c>] (kobject_init+0x0/0x9c) from [<802a3870>] (device_initialize+0x28/0x70)
>> > [<802a3848>] (device_initialize+0x0/0x70) from [<802a4798>] (device_register+0x14/0x20)
>> > [<802a4784>] (device_register+0x0/0x20) from [<80359a70>] (udc_start+0x180/0x2c8)
>> > [<803598f0>] (udc_start+0x0/0x2c8) from [<80356e9c>] (ci_role_work+0xc8/0xec)
>> > [<80356dd4>] (ci_role_work+0x0/0xec) from [<8003a8a0>] (process_one_work+0x158/0x474)
>> > [<8003a748>] (process_one_work+0x0/0x474) from [<8003af6c>] (worker_thread+0x140/0x3b4)
>> > [<8003ae2c>] (worker_thread+0x0/0x3b4) from [<8003fe60>] (kthread+0x90/0x9c)
>> > [<8003fdd0>] (kthread+0x0/0x9c) from [<8002774c>] (do_exit+0x0/0x350)
>> >> 
>> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
>> >> > ---
>> >> >  drivers/usb/chipidea/udc.c |    1 +
>> >> >  1 file changed, 1 insertion(+)
>> >> >
>> >> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
>> >> > index c7a032a..9fb6394 100644
>> >> > --- a/drivers/usb/chipidea/udc.c
>> >> > +++ b/drivers/usb/chipidea/udc.c
>> >> > @@ -1746,6 +1746,7 @@ free_pools:
>> >> >  	dma_pool_destroy(ci->td_pool);
>> >> >  free_qh_pool:
>> >> >  	dma_pool_destroy(ci->qh_pool);
>> >> > +	memset(&ci->gadget, 0, sizeof(ci->gadget));
>> >> 
>> >> I understand that you're probably hitting "kobject already initialized"
>> >> warning here, but I think the real problem is that this function gets
>> >> called twice and fails the first time. Why does that happen?
>> > I saw the dump at early stage of adding imx otg support, when there's
>> > things not ready. I think it's less important why udc_start fail,
>> > because no one enable imx otg before.  It's important when it fails,
>> > the dump shows up.
>> 
>> I'd prefer that whenever udc_start() fails it doesn't go unnoticed,
>> except probably for the cases when it fails due to transceiver not being
>> ready at the probe time, which needs to be handled separately.
> Is it related to the patch? The patch is logically right that reset the
> status, agree?

No. This warning means that we have called udc_start() once, failed
(thus didn't call udc_stop()) due to some unknown reason, and called it
again at a later point in time. This -- failing for unknown reason --
should not happen. If it does, we should fix the reason, not paper over
the warning that is telling us that something is wrong.

If we decide that we want to allow udc_start to fail for *certain*
reasons, we should do it explicitly, not by shutting up all warnings for
good.

Regards,
--
Alex

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-29  8:33         ` Richard Zhao
@ 2012-08-29  9:48           ` Alexander Shishkin
  2012-08-29 10:46             ` Richard Zhao
  0 siblings, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-08-29  9:48 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
>> Richard Zhao <richard.zhao@freescale.com> writes:
>> 
>> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
>> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> 
>> >> > One role failed, but the other role will possiblly still work.
>> >> > For example, when udc start failed, if plug in a host device,
>> >> > it works.
>> >> 
>> >> If you're a host device, ci->role should be HOST at this point and
>> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
>> >> role detection must be fixed. If ci_role_start() fails for host, but it
>> >> still works when it's called again after the id pin change is detected,
>> >> again, the problem is elsewhere.
>> > The check is only for OTG device. For single role device, it just fail
>> > if it start the role failed.
>> 
>> Sorry, can you rephrase?
>> 
>> >> 
>> >> >
>> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
>> >> > ---
>> >> >  drivers/usb/chipidea/core.c |    7 +++++--
>> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
>> >> >
>> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>> >> > index 19ef324..8fd390a 100644
>> >> > --- a/drivers/usb/chipidea/core.c
>> >> > +++ b/drivers/usb/chipidea/core.c
>> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
>> >> >  	ret = ci_role_start(ci, ci->role);
>> >> >  	if (ret) {
>> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
>> >> > -		ret = -ENODEV;
>> >> > -		goto rm_wq;
>> >> > +		ci->role = CI_ROLE_END;
>> >> 
>> >> So are you relying on id pin interrupt for initializing the role after
>> >> this? Can you provide more details?
>> > Yes. The ID pin detect still works. My case is, gadget role failed,
>> > host role works. I was trying not to ruin host function.
>> 
>> But it shouldn't even try to start the gadget, because ci_otg_role()
>> should set ci->role to HOST before ci_role_start() happens.
> It depends on ID pin. If ID pin is gadget and gadget is not support well,
> ci_role_start will fail. See below example.
>> 
>> Another question is, why does gadget start fail?
> There's one example:
> If usb phy don't support otg yet, otg_set_peripheral will fail, and
> then cause udc_start fail.

So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
platform data till the phy is fully implemented.

Regards,
--
Alex

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

* [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path
  2012-08-29  9:44           ` Alexander Shishkin
@ 2012-08-29 10:37             ` Richard Zhao
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-29 10:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 29, 2012 at 12:44:40PM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > On Wed, Aug 29, 2012 at 11:03:48AM +0300, Alexander Shishkin wrote:
> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> 
> >> > On Tue, Aug 28, 2012 at 11:29:35AM +0300, Alexander Shishkin wrote:
> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> 
> >> >> > States in gadget are not needed any more, set it to zero.
> >> >> 
> >> >> It's generally a good practice to mention in the commit message what is
> >> >> it that you are fixing with this patch.
> >> > It fixes the following dump if udc_start register gadget->dev but fail
> >> > the start process:
> >> > kobject (bf8330a0): tried to init an initialized object, something is seriously wrong.
> >> > [<80011d90>] (dump_backtrace+0x0/0x10c) from [<804b65ac>] (dump_stack+0x18/0x1c)
> >> > [<804b6594>] (dump_stack+0x0/0x1c) from [<80247d98>] (kobject_init+0x7c/0x9c)
> >> > [<80247d1c>] (kobject_init+0x0/0x9c) from [<802a3870>] (device_initialize+0x28/0x70)
> >> > [<802a3848>] (device_initialize+0x0/0x70) from [<802a4798>] (device_register+0x14/0x20)
> >> > [<802a4784>] (device_register+0x0/0x20) from [<80359a70>] (udc_start+0x180/0x2c8)
> >> > [<803598f0>] (udc_start+0x0/0x2c8) from [<80356e9c>] (ci_role_work+0xc8/0xec)
> >> > [<80356dd4>] (ci_role_work+0x0/0xec) from [<8003a8a0>] (process_one_work+0x158/0x474)
> >> > [<8003a748>] (process_one_work+0x0/0x474) from [<8003af6c>] (worker_thread+0x140/0x3b4)
> >> > [<8003ae2c>] (worker_thread+0x0/0x3b4) from [<8003fe60>] (kthread+0x90/0x9c)
> >> > [<8003fdd0>] (kthread+0x0/0x9c) from [<8002774c>] (do_exit+0x0/0x350)
> >> >> 
> >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> >> >> > ---
> >> >> >  drivers/usb/chipidea/udc.c |    1 +
> >> >> >  1 file changed, 1 insertion(+)
> >> >> >
> >> >> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> >> >> > index c7a032a..9fb6394 100644
> >> >> > --- a/drivers/usb/chipidea/udc.c
> >> >> > +++ b/drivers/usb/chipidea/udc.c
> >> >> > @@ -1746,6 +1746,7 @@ free_pools:
> >> >> >  	dma_pool_destroy(ci->td_pool);
> >> >> >  free_qh_pool:
> >> >> >  	dma_pool_destroy(ci->qh_pool);
> >> >> > +	memset(&ci->gadget, 0, sizeof(ci->gadget));
> >> >> 
> >> >> I understand that you're probably hitting "kobject already initialized"
> >> >> warning here, but I think the real problem is that this function gets
> >> >> called twice and fails the first time. Why does that happen?
> >> > I saw the dump at early stage of adding imx otg support, when there's
> >> > things not ready. I think it's less important why udc_start fail,
> >> > because no one enable imx otg before.  It's important when it fails,
> >> > the dump shows up.
> >> 
> >> I'd prefer that whenever udc_start() fails it doesn't go unnoticed,
> >> except probably for the cases when it fails due to transceiver not being
> >> ready at the probe time, which needs to be handled separately.
> > Is it related to the patch? The patch is logically right that reset the
> > status, agree?
> 
> No. This warning means that we have called udc_start() once, failed
> (thus didn't call udc_stop()) due to some unknown reason, and called it
> again at a later point in time.
If role start failed, it may have its own error message. Why do we use
such dump message to tell something wrong? And once the role start failed,
it also prevent re-trying if ID pin switch to the role again. If you
think we don't need the retrying, it's ok to drop this patch.

Thanks
Richard
> This -- failing for unknown reason --
> should not happen. If it does, we should fix the reason, not paper over
> the warning that is telling us that something is wrong.
> 
> If we decide that we want to allow udc_start to fail for *certain*
> reasons, we should do it explicitly, not by shutting up all warnings for
> good.
> 
> Regards,
> --
> Alex
> 

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-29  9:48           ` Alexander Shishkin
@ 2012-08-29 10:46             ` Richard Zhao
  2012-09-04 14:17               ` Richard Zhao
  2012-09-11  7:23               ` Alexander Shishkin
  0 siblings, 2 replies; 39+ messages in thread
From: Richard Zhao @ 2012-08-29 10:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> 
> >> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> 
> >> >> > One role failed, but the other role will possiblly still work.
> >> >> > For example, when udc start failed, if plug in a host device,
> >> >> > it works.
> >> >> 
> >> >> If you're a host device, ci->role should be HOST at this point and
> >> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
> >> >> role detection must be fixed. If ci_role_start() fails for host, but it
> >> >> still works when it's called again after the id pin change is detected,
> >> >> again, the problem is elsewhere.
> >> > The check is only for OTG device. For single role device, it just fail
> >> > if it start the role failed.
> >> 
> >> Sorry, can you rephrase?
> >> 
> >> >> 
> >> >> >
> >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> >> >> > ---
> >> >> >  drivers/usb/chipidea/core.c |    7 +++++--
> >> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >> >> >
> >> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> >> >> > index 19ef324..8fd390a 100644
> >> >> > --- a/drivers/usb/chipidea/core.c
> >> >> > +++ b/drivers/usb/chipidea/core.c
> >> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
> >> >> >  	ret = ci_role_start(ci, ci->role);
> >> >> >  	if (ret) {
> >> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
> >> >> > -		ret = -ENODEV;
> >> >> > -		goto rm_wq;
> >> >> > +		ci->role = CI_ROLE_END;
> >> >> 
> >> >> So are you relying on id pin interrupt for initializing the role after
> >> >> this? Can you provide more details?
> >> > Yes. The ID pin detect still works. My case is, gadget role failed,
> >> > host role works. I was trying not to ruin host function.
> >> 
> >> But it shouldn't even try to start the gadget, because ci_otg_role()
> >> should set ci->role to HOST before ci_role_start() happens.
> > It depends on ID pin. If ID pin is gadget and gadget is not support well,
> > ci_role_start will fail. See below example.
> >> 
> >> Another question is, why does gadget start fail?
> > There's one example:
> > If usb phy don't support otg yet, otg_set_peripheral will fail, and
> > then cause udc_start fail.
> 
> So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
> platform data till the phy is fully implemented.
It's just an example. We can not assume udc_start always success. If it
fails, isn't it better to continue support of host than say game over?

Thanks
Richard
> 
> Regards,
> --
> Alex
> 

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-29 10:46             ` Richard Zhao
@ 2012-09-04 14:17               ` Richard Zhao
  2012-09-11  7:23               ` Alexander Shishkin
  1 sibling, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-09-04 14:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 29, 2012 at 06:46:00PM +0800, Richard Zhao wrote:
> On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
> > Richard Zhao <richard.zhao@freescale.com> writes:
> > 
> > > On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
> > >> Richard Zhao <richard.zhao@freescale.com> writes:
> > >> 
> > >> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
> > >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> > >> >> 
> > >> >> > One role failed, but the other role will possiblly still work.
> > >> >> > For example, when udc start failed, if plug in a host device,
> > >> >> > it works.
> > >> >> 
> > >> >> If you're a host device, ci->role should be HOST at this point and
> > >> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
> > >> >> role detection must be fixed. If ci_role_start() fails for host, but it
> > >> >> still works when it's called again after the id pin change is detected,
> > >> >> again, the problem is elsewhere.
> > >> > The check is only for OTG device. For single role device, it just fail
> > >> > if it start the role failed.
> > >> 
> > >> Sorry, can you rephrase?
> > >> 
> > >> >> 
> > >> >> >
> > >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> > >> >> > ---
> > >> >> >  drivers/usb/chipidea/core.c |    7 +++++--
> > >> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > >> >> >
> > >> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > >> >> > index 19ef324..8fd390a 100644
> > >> >> > --- a/drivers/usb/chipidea/core.c
> > >> >> > +++ b/drivers/usb/chipidea/core.c
> > >> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
> > >> >> >  	ret = ci_role_start(ci, ci->role);
> > >> >> >  	if (ret) {
> > >> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
> > >> >> > -		ret = -ENODEV;
> > >> >> > -		goto rm_wq;
> > >> >> > +		ci->role = CI_ROLE_END;
> > >> >> 
> > >> >> So are you relying on id pin interrupt for initializing the role after
> > >> >> this? Can you provide more details?
> > >> > Yes. The ID pin detect still works. My case is, gadget role failed,
> > >> > host role works. I was trying not to ruin host function.
> > >> 
> > >> But it shouldn't even try to start the gadget, because ci_otg_role()
> > >> should set ci->role to HOST before ci_role_start() happens.
> > > It depends on ID pin. If ID pin is gadget and gadget is not support well,
> > > ci_role_start will fail. See below example.
> > >> 
> > >> Another question is, why does gadget start fail?
> > > There's one example:
> > > If usb phy don't support otg yet, otg_set_peripheral will fail, and
> > > then cause udc_start fail.
> > 
> > So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
> > platform data till the phy is fully implemented.
> It's just an example. We can not assume udc_start always success. If it
> fails, isn't it better to continue support of host than say game over?
Hi Alex,

Is it persuadable? Could you please give comments of other patches too?

Thanks
Richard
> 
> Thanks
> Richard
> > 
> > Regards,
> > --
> > Alex
> > 
> 

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

* [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (10 preceding siblings ...)
  2012-08-28  7:03 ` [PATCH v2 11/11] USB: chipidea: re-order irq handling to avoid unhandled irq Richard Zhao
@ 2012-09-05 14:27 ` Marc Kleine-Budde
  2012-09-05 15:01 ` Michael Grzeschik
  12 siblings, 0 replies; 39+ messages in thread
From: Marc Kleine-Budde @ 2012-09-05 14:27 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/28/2012 09:03 AM, Richard Zhao wrote:
> The patch set is tested on imx6q_sabrelite board.
> 
> The patch can also be found at
> https://github.com/riczhao/kernel-imx/commits/topics/usb-driver
> 
> For test which merged platform patches:
> https://github.com/riczhao/kernel-imx/commits/topics/usb-test
> 
> Changes since v1:
>  - move usbmisc as the other patch series.
>  - remove regulater_disable and old comments in ci13xxx_imx.
> 
> Richard Zhao (11):
>   USB: chipidea: imx: add pinctrl support
>   USB: chipidea: delay 2ms before read ID status at probe time
>   USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq
>     handler
>   USB: chipidea: clear gadget struct at udc_start fail path
>   USB: chipidea: don't let probe fail if otg controller start one role
>     failed
>   USB: mxs-phy: add basic otg support
>   USB: chipidea: add vbus detect for udc
>   USB: chipidea: convert to use devm_request_irq
>   USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG
>   USB: chipidea: add set_vbus_power support
>   USB: chipidea: re-order irq handling to avoid unhandled irq
> 
>  drivers/usb/chipidea/Makefile      |    2 ++
>  drivers/usb/chipidea/ci.h          |    1 +
>  drivers/usb/chipidea/ci13xxx_imx.c |   51 +++++++++++++++++++++++-------------
>  drivers/usb/chipidea/core.c        |   36 +++++++++++++++----------
>  drivers/usb/chipidea/host.c        |    8 ++++++
>  drivers/usb/chipidea/udc.c         |   40 +++++++++++++++++++++++++++-
>  drivers/usb/otg/mxs-phy.c          |   21 +++++++++++++++
>  include/linux/usb/chipidea.h       |    2 ++
>  8 files changed, 128 insertions(+), 33 deletions(-)

Tested-by: Marc Kleine-Budde <mkl@pengutronix.de>

Can this series be applied?

Marc
-- 
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: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120905/d49d5c65/attachment-0001.sig>

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

* [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix
  2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
                   ` (11 preceding siblings ...)
  2012-09-05 14:27 ` [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Marc Kleine-Budde
@ 2012-09-05 15:01 ` Michael Grzeschik
  12 siblings, 0 replies; 39+ messages in thread
From: Michael Grzeschik @ 2012-09-05 15:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 28, 2012 at 03:03:06PM +0800, Richard Zhao wrote:
> The patch set is tested on imx6q_sabrelite board.
> 
> The patch can also be found at
> https://github.com/riczhao/kernel-imx/commits/topics/usb-driver
> 
> For test which merged platform patches:
> https://github.com/riczhao/kernel-imx/commits/topics/usb-test
> 
> Changes since v1:
>  - move usbmisc as the other patch series.
>  - remove regulater_disable and old comments in ci13xxx_imx.
> 
> Richard Zhao (11):
>   USB: chipidea: imx: add pinctrl support
>   USB: chipidea: delay 2ms before read ID status at probe time
>   USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq
>     handler
>   USB: chipidea: clear gadget struct at udc_start fail path
>   USB: chipidea: don't let probe fail if otg controller start one role
>     failed
>   USB: mxs-phy: add basic otg support
>   USB: chipidea: add vbus detect for udc
>   USB: chipidea: convert to use devm_request_irq
>   USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG
>   USB: chipidea: add set_vbus_power support
>   USB: chipidea: re-order irq handling to avoid unhandled irq
> 
>  drivers/usb/chipidea/Makefile      |    2 ++
>  drivers/usb/chipidea/ci.h          |    1 +
>  drivers/usb/chipidea/ci13xxx_imx.c |   51 +++++++++++++++++++++++-------------
>  drivers/usb/chipidea/core.c        |   36 +++++++++++++++----------
>  drivers/usb/chipidea/host.c        |    8 ++++++
>  drivers/usb/chipidea/udc.c         |   40 +++++++++++++++++++++++++++-
>  drivers/usb/otg/mxs-phy.c          |   21 +++++++++++++++
>  include/linux/usb/chipidea.h       |    2 ++
>  8 files changed, 128 insertions(+), 33 deletions(-)

Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

To get this series applied, probably patch 04/11 and 05/11 should just
be dropped for now.

Michael

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-08-29 10:46             ` Richard Zhao
  2012-09-04 14:17               ` Richard Zhao
@ 2012-09-11  7:23               ` Alexander Shishkin
  2012-09-11  8:18                 ` Richard Zhao
  1 sibling, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-09-11  7:23 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
>> Richard Zhao <richard.zhao@freescale.com> writes:
>> 
>> > On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
>> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> 
>> >> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
>> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> >> 
>> >> >> > One role failed, but the other role will possiblly still work.
>> >> >> > For example, when udc start failed, if plug in a host device,
>> >> >> > it works.
>> >> >> 
>> >> >> If you're a host device, ci->role should be HOST at this point and
>> >> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
>> >> >> role detection must be fixed. If ci_role_start() fails for host, but it
>> >> >> still works when it's called again after the id pin change is detected,
>> >> >> again, the problem is elsewhere.
>> >> > The check is only for OTG device. For single role device, it just fail
>> >> > if it start the role failed.
>> >> 
>> >> Sorry, can you rephrase?
>> >> 
>> >> >> 
>> >> >> >
>> >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
>> >> >> > ---
>> >> >> >  drivers/usb/chipidea/core.c |    7 +++++--
>> >> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
>> >> >> >
>> >> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>> >> >> > index 19ef324..8fd390a 100644
>> >> >> > --- a/drivers/usb/chipidea/core.c
>> >> >> > +++ b/drivers/usb/chipidea/core.c
>> >> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
>> >> >> >  	ret = ci_role_start(ci, ci->role);
>> >> >> >  	if (ret) {
>> >> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
>> >> >> > -		ret = -ENODEV;
>> >> >> > -		goto rm_wq;
>> >> >> > +		ci->role = CI_ROLE_END;
>> >> >> 
>> >> >> So are you relying on id pin interrupt for initializing the role after
>> >> >> this? Can you provide more details?
>> >> > Yes. The ID pin detect still works. My case is, gadget role failed,
>> >> > host role works. I was trying not to ruin host function.
>> >> 
>> >> But it shouldn't even try to start the gadget, because ci_otg_role()
>> >> should set ci->role to HOST before ci_role_start() happens.
>> > It depends on ID pin. If ID pin is gadget and gadget is not support well,
>> > ci_role_start will fail. See below example.
>> >> 
>> >> Another question is, why does gadget start fail?
>> > There's one example:
>> > If usb phy don't support otg yet, otg_set_peripheral will fail, and
>> > then cause udc_start fail.
>> 
>> So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
>> platform data till the phy is fully implemented.
> It's just an example. We can not assume udc_start always success. If it
> fails, isn't it better to continue support of host than say game over?

Ok, I think what we need here is to rework error handling around role
switching, so that we can allow certain things to fail and retry at a
later point (say at id pin change), while being careful about the other
failures.

If this patch is not crucial for imx right now, I'd prefer to leave it
out.

Regards,
--
Alex

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-09-11  7:23               ` Alexander Shishkin
@ 2012-09-11  8:18                 ` Richard Zhao
  2012-09-12 10:47                   ` Alexander Shishkin
  0 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-09-11  8:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Sep 11, 2012 at 10:23:55AM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> 
> >> > On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> 
> >> >> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> >> 
> >> >> >> > One role failed, but the other role will possiblly still work.
> >> >> >> > For example, when udc start failed, if plug in a host device,
> >> >> >> > it works.
> >> >> >> 
> >> >> >> If you're a host device, ci->role should be HOST at this point and
> >> >> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
> >> >> >> role detection must be fixed. If ci_role_start() fails for host, but it
> >> >> >> still works when it's called again after the id pin change is detected,
> >> >> >> again, the problem is elsewhere.
> >> >> > The check is only for OTG device. For single role device, it just fail
> >> >> > if it start the role failed.
> >> >> 
> >> >> Sorry, can you rephrase?
> >> >> 
> >> >> >> 
> >> >> >> >
> >> >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> >> >> >> > ---
> >> >> >> >  drivers/usb/chipidea/core.c |    7 +++++--
> >> >> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >> >> >> >
> >> >> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> >> >> >> > index 19ef324..8fd390a 100644
> >> >> >> > --- a/drivers/usb/chipidea/core.c
> >> >> >> > +++ b/drivers/usb/chipidea/core.c
> >> >> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
> >> >> >> >  	ret = ci_role_start(ci, ci->role);
> >> >> >> >  	if (ret) {
> >> >> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
> >> >> >> > -		ret = -ENODEV;
> >> >> >> > -		goto rm_wq;
> >> >> >> > +		ci->role = CI_ROLE_END;
> >> >> >> 
> >> >> >> So are you relying on id pin interrupt for initializing the role after
> >> >> >> this? Can you provide more details?
> >> >> > Yes. The ID pin detect still works. My case is, gadget role failed,
> >> >> > host role works. I was trying not to ruin host function.
> >> >> 
> >> >> But it shouldn't even try to start the gadget, because ci_otg_role()
> >> >> should set ci->role to HOST before ci_role_start() happens.
> >> > It depends on ID pin. If ID pin is gadget and gadget is not support well,
> >> > ci_role_start will fail. See below example.
> >> >> 
> >> >> Another question is, why does gadget start fail?
> >> > There's one example:
> >> > If usb phy don't support otg yet, otg_set_peripheral will fail, and
> >> > then cause udc_start fail.
> >> 
> >> So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
> >> platform data till the phy is fully implemented.
> > It's just an example. We can not assume udc_start always success. If it
> > fails, isn't it better to continue support of host than say game over?
> 
> Ok, I think what we need here is to rework error handling around role
> switching, so that we can allow certain things to fail and retry at a
> later point (say at id pin change), while being careful about the other
> failures.
> 
> If this patch is not crucial for imx right now, I'd prefer to leave it
> out.
That's OK. but I hope other function related patch can be merged for
3.7 :)

Thanks
Richard
> 
> Regards,
> --
> Alex
> 

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

* [PATCH v2 06/11] USB: mxs-phy: add basic otg support
  2012-08-28  7:03 ` [PATCH v2 06/11] USB: mxs-phy: add basic otg support Richard Zhao
@ 2012-09-11  9:05   ` Felipe Balbi
  2012-09-12 10:39   ` Heikki Krogerus
  2012-09-14  8:56   ` Chen Peter-B29397
  2 siblings, 0 replies; 39+ messages in thread
From: Felipe Balbi @ 2012-09-11  9:05 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Tue, Aug 28, 2012 at 03:03:12PM +0800, Richard Zhao wrote:
> Signed-off-by: Richard Zhao <richard.zhao@freescale.com>

if you add a commit log you can add my:

Acked-by: Felipe Balbi <balbi@ti.com>

> ---
>  drivers/usb/otg/mxs-phy.c |   21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
> index c1a67cb..6a03e97 100644
> --- a/drivers/usb/otg/mxs-phy.c
> +++ b/drivers/usb/otg/mxs-phy.c
> @@ -97,12 +97,24 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy, int port)
>  	return 0;
>  }
>  
> +static int mxs_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
> +{
> +	return 0;
> +}
> +
> +static int mxs_phy_set_peripheral(struct usb_otg *otg,
> +					struct usb_gadget *gadget)
> +{
> +	return 0;
> +}
> +
>  static int mxs_phy_probe(struct platform_device *pdev)
>  {
>  	struct resource *res;
>  	void __iomem *base;
>  	struct clk *clk;
>  	struct mxs_phy *mxs_phy;
> +	struct usb_otg *otg;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!res) {
> @@ -139,6 +151,15 @@ static int mxs_phy_probe(struct platform_device *pdev)
>  
>  	mxs_phy->clk = clk;
>  
> +	otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), GFP_KERNEL);
> +	if (!otg)
> +		return -ENOMEM;
> +	otg->phy = &mxs_phy->phy;
> +	otg->set_host = mxs_phy_set_host;
> +	otg->set_peripheral = mxs_phy_set_peripheral;
> +
> +	mxs_phy->phy.otg = otg;
> +
>  	platform_set_drvdata(pdev, &mxs_phy->phy);
>  
>  	return 0;
> -- 
> 1.7.9.5
> 
> 

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

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

* [PATCH v2 06/11] USB: mxs-phy: add basic otg support
  2012-08-28  7:03 ` [PATCH v2 06/11] USB: mxs-phy: add basic otg support Richard Zhao
  2012-09-11  9:05   ` Felipe Balbi
@ 2012-09-12 10:39   ` Heikki Krogerus
  2012-09-14  8:30     ` Richard Zhao
  2012-09-14  8:56   ` Chen Peter-B29397
  2 siblings, 1 reply; 39+ messages in thread
From: Heikki Krogerus @ 2012-09-12 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Tue, Aug 28, 2012 at 03:03:12PM +0800, Richard Zhao wrote:
> +static int mxs_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
> +{

Shouldn't you at least save the host pointer?

otg->host = host;

> +	return 0;
> +}
> +
> +static int mxs_phy_set_peripheral(struct usb_otg *otg,
> +					struct usb_gadget *gadget)
> +{

And the same with the gadget?

> +	return 0;
> +}

-- 
heikki

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-09-11  8:18                 ` Richard Zhao
@ 2012-09-12 10:47                   ` Alexander Shishkin
  2012-09-14  8:35                     ` Richard Zhao
  0 siblings, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-09-12 10:47 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> On Tue, Sep 11, 2012 at 10:23:55AM +0300, Alexander Shishkin wrote:
>> Richard Zhao <richard.zhao@freescale.com> writes:
>> 
>> > On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
>> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> 
>> >> > On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
>> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> >> 
>> >> >> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
>> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> >> >> 
>> >> >> >> > One role failed, but the other role will possiblly still work.
>> >> >> >> > For example, when udc start failed, if plug in a host device,
>> >> >> >> > it works.
>> >> >> >> 
>> >> >> >> If you're a host device, ci->role should be HOST at this point and
>> >> >> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
>> >> >> >> role detection must be fixed. If ci_role_start() fails for host, but it
>> >> >> >> still works when it's called again after the id pin change is detected,
>> >> >> >> again, the problem is elsewhere.
>> >> >> > The check is only for OTG device. For single role device, it just fail
>> >> >> > if it start the role failed.
>> >> >> 
>> >> >> Sorry, can you rephrase?
>> >> >> 
>> >> >> >> 
>> >> >> >> >
>> >> >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
>> >> >> >> > ---
>> >> >> >> >  drivers/usb/chipidea/core.c |    7 +++++--
>> >> >> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
>> >> >> >> >
>> >> >> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>> >> >> >> > index 19ef324..8fd390a 100644
>> >> >> >> > --- a/drivers/usb/chipidea/core.c
>> >> >> >> > +++ b/drivers/usb/chipidea/core.c
>> >> >> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
>> >> >> >> >  	ret = ci_role_start(ci, ci->role);
>> >> >> >> >  	if (ret) {
>> >> >> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
>> >> >> >> > -		ret = -ENODEV;
>> >> >> >> > -		goto rm_wq;
>> >> >> >> > +		ci->role = CI_ROLE_END;
>> >> >> >> 
>> >> >> >> So are you relying on id pin interrupt for initializing the role after
>> >> >> >> this? Can you provide more details?
>> >> >> > Yes. The ID pin detect still works. My case is, gadget role failed,
>> >> >> > host role works. I was trying not to ruin host function.
>> >> >> 
>> >> >> But it shouldn't even try to start the gadget, because ci_otg_role()
>> >> >> should set ci->role to HOST before ci_role_start() happens.
>> >> > It depends on ID pin. If ID pin is gadget and gadget is not support well,
>> >> > ci_role_start will fail. See below example.
>> >> >> 
>> >> >> Another question is, why does gadget start fail?
>> >> > There's one example:
>> >> > If usb phy don't support otg yet, otg_set_peripheral will fail, and
>> >> > then cause udc_start fail.
>> >> 
>> >> So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
>> >> platform data till the phy is fully implemented.
>> > It's just an example. We can not assume udc_start always success. If it
>> > fails, isn't it better to continue support of host than say game over?
>> 
>> Ok, I think what we need here is to rework error handling around role
>> switching, so that we can allow certain things to fail and retry at a
>> later point (say at id pin change), while being careful about the other
>> failures.
>> 
>> If this patch is not crucial for imx right now, I'd prefer to leave it
>> out.
> That's OK. but I hope other function related patch can be merged for
> 3.7 :)

Also 6/11 seems quite pointless to me. Otherwise, I'll send them to Greg
today.

Regards,
--
Alex

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

* [PATCH v2 06/11] USB: mxs-phy: add basic otg support
  2012-09-12 10:39   ` Heikki Krogerus
@ 2012-09-14  8:30     ` Richard Zhao
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-09-14  8:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 12, 2012 at 01:39:01PM +0300, Heikki Krogerus wrote:
> Hi,
> 
> On Tue, Aug 28, 2012 at 03:03:12PM +0800, Richard Zhao wrote:
> > +static int mxs_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
> > +{
> 
> Shouldn't you at least save the host pointer?
> 
> otg->host = host;
It looks making sense, though it's not called by chipidea driver.

> 
> > +	return 0;
> > +}
> > +
> > +static int mxs_phy_set_peripheral(struct usb_otg *otg,
> > +					struct usb_gadget *gadget)
> > +{
> 
> And the same with the gadget?

Thanks
Richard
> 
> > +	return 0;
> > +}
> 
> -- 
> heikki
> 

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-09-12 10:47                   ` Alexander Shishkin
@ 2012-09-14  8:35                     ` Richard Zhao
  2012-09-14 10:25                       ` Alexander Shishkin
  0 siblings, 1 reply; 39+ messages in thread
From: Richard Zhao @ 2012-09-14  8:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Sep 12, 2012 at 01:47:54PM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > On Tue, Sep 11, 2012 at 10:23:55AM +0300, Alexander Shishkin wrote:
> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> 
> >> > On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> 
> >> >> > On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> >> 
> >> >> >> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
> >> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> >> >> 
> >> >> >> >> > One role failed, but the other role will possiblly still work.
> >> >> >> >> > For example, when udc start failed, if plug in a host device,
> >> >> >> >> > it works.
> >> >> >> >> 
> >> >> >> >> If you're a host device, ci->role should be HOST at this point and
> >> >> >> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
> >> >> >> >> role detection must be fixed. If ci_role_start() fails for host, but it
> >> >> >> >> still works when it's called again after the id pin change is detected,
> >> >> >> >> again, the problem is elsewhere.
> >> >> >> > The check is only for OTG device. For single role device, it just fail
> >> >> >> > if it start the role failed.
> >> >> >> 
> >> >> >> Sorry, can you rephrase?
> >> >> >> 
> >> >> >> >> 
> >> >> >> >> >
> >> >> >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> >> >> >> >> > ---
> >> >> >> >> >  drivers/usb/chipidea/core.c |    7 +++++--
> >> >> >> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >> >> >> >> >
> >> >> >> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> >> >> >> >> > index 19ef324..8fd390a 100644
> >> >> >> >> > --- a/drivers/usb/chipidea/core.c
> >> >> >> >> > +++ b/drivers/usb/chipidea/core.c
> >> >> >> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
> >> >> >> >> >  	ret = ci_role_start(ci, ci->role);
> >> >> >> >> >  	if (ret) {
> >> >> >> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
> >> >> >> >> > -		ret = -ENODEV;
> >> >> >> >> > -		goto rm_wq;
> >> >> >> >> > +		ci->role = CI_ROLE_END;
> >> >> >> >> 
> >> >> >> >> So are you relying on id pin interrupt for initializing the role after
> >> >> >> >> this? Can you provide more details?
> >> >> >> > Yes. The ID pin detect still works. My case is, gadget role failed,
> >> >> >> > host role works. I was trying not to ruin host function.
> >> >> >> 
> >> >> >> But it shouldn't even try to start the gadget, because ci_otg_role()
> >> >> >> should set ci->role to HOST before ci_role_start() happens.
> >> >> > It depends on ID pin. If ID pin is gadget and gadget is not support well,
> >> >> > ci_role_start will fail. See below example.
> >> >> >> 
> >> >> >> Another question is, why does gadget start fail?
> >> >> > There's one example:
> >> >> > If usb phy don't support otg yet, otg_set_peripheral will fail, and
> >> >> > then cause udc_start fail.
> >> >> 
> >> >> So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
> >> >> platform data till the phy is fully implemented.
> >> > It's just an example. We can not assume udc_start always success. If it
> >> > fails, isn't it better to continue support of host than say game over?
> >> 
> >> Ok, I think what we need here is to rework error handling around role
> >> switching, so that we can allow certain things to fail and retry at a
> >> later point (say at id pin change), while being careful about the other
> >> failures.
> >> 
> >> If this patch is not crucial for imx right now, I'd prefer to leave it
> >> out.
> > That's OK. but I hope other function related patch can be merged for
> > 3.7 :)
> 
> Also 6/11 seems quite pointless to me. Otherwise, I'll send them to Greg
> today.
If set_peripheral is null, udc_start will fail. Or you prefer removing
checking of otg_set_peripheral returned value?

Thanks
Richard
> 
> Regards,
> --
> Alex
> 

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

* [PATCH v2 06/11] USB: mxs-phy: add basic otg support
  2012-08-28  7:03 ` [PATCH v2 06/11] USB: mxs-phy: add basic otg support Richard Zhao
  2012-09-11  9:05   ` Felipe Balbi
  2012-09-12 10:39   ` Heikki Krogerus
@ 2012-09-14  8:56   ` Chen Peter-B29397
  2012-09-14 10:53     ` Richard Zhao
  2 siblings, 1 reply; 39+ messages in thread
From: Chen Peter-B29397 @ 2012-09-14  8:56 UTC (permalink / raw)
  To: linux-arm-kernel

 
> diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
> index c1a67cb..6a03e97 100644
> --- a/drivers/usb/otg/mxs-phy.c
> +++ b/drivers/usb/otg/mxs-phy.c
> @@ -97,12 +97,24 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy,
> int port)
>  	return 0;
>  }
> 
> +static int mxs_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
> +{
> +	return 0;
> +}
> +
> +static int mxs_phy_set_peripheral(struct usb_otg *otg,
> +					struct usb_gadget *gadget)
> +{
> +	return 0;
> +}
> +
>  static int mxs_phy_probe(struct platform_device *pdev)
>  {
>  	struct resource *res;
>  	void __iomem *base;
>  	struct clk *clk;
>  	struct mxs_phy *mxs_phy;
> +	struct usb_otg *otg;
> 
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!res) {
> @@ -139,6 +151,15 @@ static int mxs_phy_probe(struct platform_device
> *pdev)
> 
>  	mxs_phy->clk = clk;
> 
> +	otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), GFP_KERNEL);
> +	if (!otg)
> +		return -ENOMEM;
> +	otg->phy = &mxs_phy->phy;
> +	otg->set_host = mxs_phy_set_host;
> +	otg->set_peripheral = mxs_phy_set_peripheral;
> +
> +	mxs_phy->phy.otg = otg;
> +

Put otg struct at PHY driver is not a good practice.
Only OTG driver who handles ID interrupt cases about host and gadget struct.
PHY is a transceiver, it not cares otg, host and device at all.

>  	platform_set_drvdata(pdev, &mxs_phy->phy);
> 
>  	return 0;
> --
> 1.7.9.5

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-09-14  8:35                     ` Richard Zhao
@ 2012-09-14 10:25                       ` Alexander Shishkin
  2012-09-17  8:59                         ` Richard Zhao
  0 siblings, 1 reply; 39+ messages in thread
From: Alexander Shishkin @ 2012-09-14 10:25 UTC (permalink / raw)
  To: linux-arm-kernel

Richard Zhao <richard.zhao@freescale.com> writes:

> On Wed, Sep 12, 2012 at 01:47:54PM +0300, Alexander Shishkin wrote:
>> Richard Zhao <richard.zhao@freescale.com> writes:
>> 
>> > On Tue, Sep 11, 2012 at 10:23:55AM +0300, Alexander Shishkin wrote:
>> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> 
>> >> > On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
>> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> >> 
>> >> >> > On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
>> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> >> >> 
>> >> >> >> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
>> >> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
>> >> >> >> >> 
>> >> >> >> >> > One role failed, but the other role will possiblly still work.
>> >> >> >> >> > For example, when udc start failed, if plug in a host device,
>> >> >> >> >> > it works.
>> >> >> >> >> 
>> >> >> >> >> If you're a host device, ci->role should be HOST at this point and
>> >> >> >> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
>> >> >> >> >> role detection must be fixed. If ci_role_start() fails for host, but it
>> >> >> >> >> still works when it's called again after the id pin change is detected,
>> >> >> >> >> again, the problem is elsewhere.
>> >> >> >> > The check is only for OTG device. For single role device, it just fail
>> >> >> >> > if it start the role failed.
>> >> >> >> 
>> >> >> >> Sorry, can you rephrase?
>> >> >> >> 
>> >> >> >> >> 
>> >> >> >> >> >
>> >> >> >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
>> >> >> >> >> > ---
>> >> >> >> >> >  drivers/usb/chipidea/core.c |    7 +++++--
>> >> >> >> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
>> >> >> >> >> >
>> >> >> >> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>> >> >> >> >> > index 19ef324..8fd390a 100644
>> >> >> >> >> > --- a/drivers/usb/chipidea/core.c
>> >> >> >> >> > +++ b/drivers/usb/chipidea/core.c
>> >> >> >> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
>> >> >> >> >> >  	ret = ci_role_start(ci, ci->role);
>> >> >> >> >> >  	if (ret) {
>> >> >> >> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
>> >> >> >> >> > -		ret = -ENODEV;
>> >> >> >> >> > -		goto rm_wq;
>> >> >> >> >> > +		ci->role = CI_ROLE_END;
>> >> >> >> >> 
>> >> >> >> >> So are you relying on id pin interrupt for initializing the role after
>> >> >> >> >> this? Can you provide more details?
>> >> >> >> > Yes. The ID pin detect still works. My case is, gadget role failed,
>> >> >> >> > host role works. I was trying not to ruin host function.
>> >> >> >> 
>> >> >> >> But it shouldn't even try to start the gadget, because ci_otg_role()
>> >> >> >> should set ci->role to HOST before ci_role_start() happens.
>> >> >> > It depends on ID pin. If ID pin is gadget and gadget is not support well,
>> >> >> > ci_role_start will fail. See below example.
>> >> >> >> 
>> >> >> >> Another question is, why does gadget start fail?
>> >> >> > There's one example:
>> >> >> > If usb phy don't support otg yet, otg_set_peripheral will fail, and
>> >> >> > then cause udc_start fail.
>> >> >> 
>> >> >> So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
>> >> >> platform data till the phy is fully implemented.
>> >> > It's just an example. We can not assume udc_start always success. If it
>> >> > fails, isn't it better to continue support of host than say game over?
>> >> 
>> >> Ok, I think what we need here is to rework error handling around role
>> >> switching, so that we can allow certain things to fail and retry at a
>> >> later point (say at id pin change), while being careful about the other
>> >> failures.
>> >> 
>> >> If this patch is not crucial for imx right now, I'd prefer to leave it
>> >> out.
>> > That's OK. but I hope other function related patch can be merged for
>> > 3.7 :)
>> 
>> Also 6/11 seems quite pointless to me. Otherwise, I'll send them to Greg
>> today.
> If set_peripheral is null, udc_start will fail. Or you prefer removing
> checking of otg_set_peripheral returned value?

I guess for now we could do something like

        if (retval &&
            !(ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER))
                goto remove_dbg;

... or implement an otg driver. :)

Regards,
--
Alex

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

* [PATCH v2 06/11] USB: mxs-phy: add basic otg support
  2012-09-14  8:56   ` Chen Peter-B29397
@ 2012-09-14 10:53     ` Richard Zhao
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-09-14 10:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 14, 2012 at 04:56:13PM +0800, Chen Peter-B29397 wrote:
>  
> > diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
> > index c1a67cb..6a03e97 100644
> > --- a/drivers/usb/otg/mxs-phy.c
> > +++ b/drivers/usb/otg/mxs-phy.c
> > @@ -97,12 +97,24 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy,
> > int port)
> >  	return 0;
> >  }
> > 
> > +static int mxs_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
> > +{
> > +	return 0;
> > +}
> > +
> > +static int mxs_phy_set_peripheral(struct usb_otg *otg,
> > +					struct usb_gadget *gadget)
> > +{
> > +	return 0;
> > +}
> > +
> >  static int mxs_phy_probe(struct platform_device *pdev)
> >  {
> >  	struct resource *res;
> >  	void __iomem *base;
> >  	struct clk *clk;
> >  	struct mxs_phy *mxs_phy;
> > +	struct usb_otg *otg;
> > 
> >  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >  	if (!res) {
> > @@ -139,6 +151,15 @@ static int mxs_phy_probe(struct platform_device
> > *pdev)
> > 
> >  	mxs_phy->clk = clk;
> > 
> > +	otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), GFP_KERNEL);
> > +	if (!otg)
> > +		return -ENOMEM;
> > +	otg->phy = &mxs_phy->phy;
> > +	otg->set_host = mxs_phy_set_host;
> > +	otg->set_peripheral = mxs_phy_set_peripheral;
> > +
> > +	mxs_phy->phy.otg = otg;
> > +
> 
> Put otg struct at PHY driver is not a good practice.
> Only OTG driver who handles ID interrupt cases about host and gadget struct.
> PHY is a transceiver, it not cares otg, host and device at all.
I understand your concern, but this patch don't mean to restructure
common code.

Thanks
Richard
> 
> >  	platform_set_drvdata(pdev, &mxs_phy->phy);
> > 
> >  	return 0;
> > --
> > 1.7.9.5
> 

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

* [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed
  2012-09-14 10:25                       ` Alexander Shishkin
@ 2012-09-17  8:59                         ` Richard Zhao
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-09-17  8:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Sep 14, 2012 at 01:25:25PM +0300, Alexander Shishkin wrote:
> Richard Zhao <richard.zhao@freescale.com> writes:
> 
> > On Wed, Sep 12, 2012 at 01:47:54PM +0300, Alexander Shishkin wrote:
> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> 
> >> > On Tue, Sep 11, 2012 at 10:23:55AM +0300, Alexander Shishkin wrote:
> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> 
> >> >> > On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> >> 
> >> >> >> > On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
> >> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> >> >> 
> >> >> >> >> > On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
> >> >> >> >> >> Richard Zhao <richard.zhao@freescale.com> writes:
> >> >> >> >> >> 
> >> >> >> >> >> > One role failed, but the other role will possiblly still work.
> >> >> >> >> >> > For example, when udc start failed, if plug in a host device,
> >> >> >> >> >> > it works.
> >> >> >> >> >> 
> >> >> >> >> >> If you're a host device, ci->role should be HOST at this point and
> >> >> >> >> >> ci_role_start() shouldn't fail. If ci->role is detected wrongly, the
> >> >> >> >> >> role detection must be fixed. If ci_role_start() fails for host, but it
> >> >> >> >> >> still works when it's called again after the id pin change is detected,
> >> >> >> >> >> again, the problem is elsewhere.
> >> >> >> >> > The check is only for OTG device. For single role device, it just fail
> >> >> >> >> > if it start the role failed.
> >> >> >> >> 
> >> >> >> >> Sorry, can you rephrase?
> >> >> >> >> 
> >> >> >> >> >> 
> >> >> >> >> >> >
> >> >> >> >> >> > Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> >> >> >> >> >> > ---
> >> >> >> >> >> >  drivers/usb/chipidea/core.c |    7 +++++--
> >> >> >> >> >> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >> >> >> >> >> >
> >> >> >> >> >> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> >> >> >> >> >> > index 19ef324..8fd390a 100644
> >> >> >> >> >> > --- a/drivers/usb/chipidea/core.c
> >> >> >> >> >> > +++ b/drivers/usb/chipidea/core.c
> >> >> >> >> >> > @@ -473,8 +473,11 @@ static int __devinit ci_hdrc_probe(struct platform_device *pdev)
> >> >> >> >> >> >  	ret = ci_role_start(ci, ci->role);
> >> >> >> >> >> >  	if (ret) {
> >> >> >> >> >> >  		dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
> >> >> >> >> >> > -		ret = -ENODEV;
> >> >> >> >> >> > -		goto rm_wq;
> >> >> >> >> >> > +		ci->role = CI_ROLE_END;
> >> >> >> >> >> 
> >> >> >> >> >> So are you relying on id pin interrupt for initializing the role after
> >> >> >> >> >> this? Can you provide more details?
> >> >> >> >> > Yes. The ID pin detect still works. My case is, gadget role failed,
> >> >> >> >> > host role works. I was trying not to ruin host function.
> >> >> >> >> 
> >> >> >> >> But it shouldn't even try to start the gadget, because ci_otg_role()
> >> >> >> >> should set ci->role to HOST before ci_role_start() happens.
> >> >> >> > It depends on ID pin. If ID pin is gadget and gadget is not support well,
> >> >> >> > ci_role_start will fail. See below example.
> >> >> >> >> 
> >> >> >> >> Another question is, why does gadget start fail?
> >> >> >> > There's one example:
> >> >> >> > If usb phy don't support otg yet, otg_set_peripheral will fail, and
> >> >> >> > then cause udc_start fail.
> >> >> >> 
> >> >> >> So you should drop the CI13XXX_REQUIRE_TRANSCEIVER flag from imx
> >> >> >> platform data till the phy is fully implemented.
> >> >> > It's just an example. We can not assume udc_start always success. If it
> >> >> > fails, isn't it better to continue support of host than say game over?
> >> >> 
> >> >> Ok, I think what we need here is to rework error handling around role
> >> >> switching, so that we can allow certain things to fail and retry at a
> >> >> later point (say at id pin change), while being careful about the other
> >> >> failures.
> >> >> 
> >> >> If this patch is not crucial for imx right now, I'd prefer to leave it
> >> >> out.
> >> > That's OK. but I hope other function related patch can be merged for
> >> > 3.7 :)
> >> 
> >> Also 6/11 seems quite pointless to me. Otherwise, I'll send them to Greg
> >> today.
> > If set_peripheral is null, udc_start will fail. Or you prefer removing
> > checking of otg_set_peripheral returned value?
> 
> I guess for now we could do something like
> 
>         if (retval &&
>             !(ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER))
>                 goto remove_dbg;
> 
> ... or implement an otg driver. :)
Yes, a fake otg driver sounds more simple :)

Thanks
Richard
> 
> Regards,
> --
> Alex
> 

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

* [PATCH v2 10/11] USB: chipidea: add set_vbus_power support
  2012-08-28  7:03 ` [PATCH v2 10/11] USB: chipidea: add set_vbus_power support Richard Zhao
@ 2012-09-19  1:25   ` Richard Zhao
  0 siblings, 0 replies; 39+ messages in thread
From: Richard Zhao @ 2012-09-19  1:25 UTC (permalink / raw)
  To: linux-arm-kernel

Alex,

I find you dropped this too. Did you mean to add it after otg driver or
any other reason?

Thanks
Richard 

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

end of thread, other threads:[~2012-09-19  1:25 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-28  7:03 [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Richard Zhao
2012-08-28  7:03 ` [PATCH v2 01/11] USB: chipidea: imx: add pinctrl support Richard Zhao
2012-08-28  7:03 ` [PATCH v2 02/11] USB: chipidea: delay 2ms before read ID status at probe time Richard Zhao
2012-08-28  7:03 ` [PATCH v2 03/11] USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq handler Richard Zhao
2012-08-28  7:03 ` [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path Richard Zhao
2012-08-28  8:29   ` Alexander Shishkin
2012-08-28  9:09     ` Richard Zhao
2012-08-29  8:03       ` Alexander Shishkin
2012-08-29  8:22         ` Richard Zhao
2012-08-29  9:44           ` Alexander Shishkin
2012-08-29 10:37             ` Richard Zhao
2012-08-28  7:03 ` [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed Richard Zhao
2012-08-28  8:38   ` Alexander Shishkin
2012-08-28  9:27     ` Richard Zhao
2012-08-29  8:10       ` Alexander Shishkin
2012-08-29  8:33         ` Richard Zhao
2012-08-29  9:48           ` Alexander Shishkin
2012-08-29 10:46             ` Richard Zhao
2012-09-04 14:17               ` Richard Zhao
2012-09-11  7:23               ` Alexander Shishkin
2012-09-11  8:18                 ` Richard Zhao
2012-09-12 10:47                   ` Alexander Shishkin
2012-09-14  8:35                     ` Richard Zhao
2012-09-14 10:25                       ` Alexander Shishkin
2012-09-17  8:59                         ` Richard Zhao
2012-08-28  7:03 ` [PATCH v2 06/11] USB: mxs-phy: add basic otg support Richard Zhao
2012-09-11  9:05   ` Felipe Balbi
2012-09-12 10:39   ` Heikki Krogerus
2012-09-14  8:30     ` Richard Zhao
2012-09-14  8:56   ` Chen Peter-B29397
2012-09-14 10:53     ` Richard Zhao
2012-08-28  7:03 ` [PATCH v2 07/11] USB: chipidea: add vbus detect for udc Richard Zhao
2012-08-28  7:03 ` [PATCH v2 08/11] USB: chipidea: convert to use devm_request_irq Richard Zhao
2012-08-28  7:03 ` [PATCH v2 09/11] USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG Richard Zhao
2012-08-28  7:03 ` [PATCH v2 10/11] USB: chipidea: add set_vbus_power support Richard Zhao
2012-09-19  1:25   ` Richard Zhao
2012-08-28  7:03 ` [PATCH v2 11/11] USB: chipidea: re-order irq handling to avoid unhandled irq Richard Zhao
2012-09-05 14:27 ` [PATCH v2 00/11] chipidea/imx: add otg support and some bug fix Marc Kleine-Budde
2012-09-05 15:01 ` Michael Grzeschik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.