Re: [PATCH v3] USB: mxs-phy: add basic otg support

2012-09-18 Thread Richard Zhao
On Mon, Sep 17, 2012 at 01:06:21PM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@freescale.com writes:
 
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  Acked-by: Felipe Balbi ba...@ti.com
 
 Felipe said, 
 
  if you add a commit log you can add my:
  
  Acked-by: Felipe Balbi ba...@ti.com
 
 but the commit message is still totally missing. I would like to ask you
 to pay attention to the commit messages in the patches that you
 submit. They should explain the problem that your patch is solving, how
 you are solving it and why, so that anyone immediately knows what the
 patch is about without digging up mailing list conversations. There's
 also a nice blog entry [1] on how to write good commit messages.
 
 [1] http://who-t.blogspot.com/2009/12/on-commit-messages.html
Will you agree to give ack if commit message changed to below?

USB: mxs-phy: add fake otg support

It has nothing to do with phy driver, but for now chipidea driver calls
struct usb_otg callbacks. So we implement a fake one.

When chipidea implement its own otg driver, this commit can be reverted.

Signed-off-by: Richard Zhao richard.z...@freescale.com
Acked-by: Felipe Balbi ba...@ti.com

Thanks
Richard
 
  ---
  Changes from v2:
   - assign host/gadget in mxs_phy_set_host/mxs_phy_set_peripheral
 
   drivers/usb/otg/mxs-phy.c |   25 +
   1 file changed, 25 insertions(+)
 
  diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
  index 88db976..3255112 100644
  --- a/drivers/usb/otg/mxs-phy.c
  +++ b/drivers/usb/otg/mxs-phy.c
  @@ -129,12 +129,28 @@ 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)
  +{
  +   otg-host = host;
  +
  +   return 0;
  +}
  +
  +static int mxs_phy_set_peripheral(struct usb_otg *otg,
  +   struct usb_gadget *gadget)
  +{
  +   otg-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) {
  @@ -171,6 +187,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
 

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


[PATCH v2 RESEND] USB: chipidea: convert to use devm_request_irq

2012-09-18 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@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 307651b..0942b9b 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -486,8 +486,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;
 
@@ -518,7 +518,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


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


Re: [PATCH v2 10/11] USB: chipidea: add set_vbus_power support

2012-09-18 Thread Richard Zhao
Alex,

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

Thanks
Richard 

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


Re: [PATCH v2 RESEND] USB: chipidea: convert to use devm_request_irq

2012-09-18 Thread Richard Zhao
On Wed, Sep 19, 2012 at 03:30:41AM +0200, Marek Vasut wrote:
 Dear Richard Zhao,
 
 You know, commit message would be nice to have.
Yes, but for this one, the title shows obviously what it changed,
doesn't it?

Thanks
Richard
 
  Signed-off-by: Richard Zhao richard.z...@freescale.com
 
 Otherwise
 
 Reviewed-by: Marek Vasut ma...@denx.de
 
  ---
   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 307651b..0942b9b 100644
  --- a/drivers/usb/chipidea/core.c
  +++ b/drivers/usb/chipidea/core.c
  @@ -486,8 +486,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;
  
  @@ -518,7 +518,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;
 
 Best regards,
 Marek Vasut
 

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


[PATCH] USB: chipidea: use OTGSC_BSV to detect vbus valid

2012-09-17 Thread Richard Zhao
OTGSC_AVVIS cannot be set when vbus voltage goes valid or invalid on
imx, so convert to use OTGSC_BSV.

OTGSC_BSVIE and OTGSC_BSVIS is not cleared when hw_device_reset, so we
don't need to call hw_enable_vbus_intr after hw_device_reset.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 drivers/usb/chipidea/udc.c |   17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 2f45bba..b158a04 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -307,14 +307,13 @@ static u32 hw_test_and_clear_intr_active(struct ci13xxx 
*ci)
 
 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);
+   hw_write(ci, OP_OTGSC, OTGSC_BSVIS, OTGSC_BSVIS);
+   hw_write(ci, OP_OTGSC, OTGSC_BSVIE, OTGSC_BSVIE);
 }
 
 static void hw_disable_vbus_intr(struct ci13xxx *ci)
 {
-   hw_write(ci, OP_OTGSC, OTGSC_AVVIE, 0);
+   hw_write(ci, OP_OTGSC, OTGSC_BSVIE, 0);
 }
 
 /**
@@ -387,7 +386,7 @@ 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))
+   if (hw_read(ci, OP_OTGSC, OTGSC_BSV))
usb_gadget_vbus_connect(ci-gadget);
else
usb_gadget_vbus_disconnect(ci-gadget);
@@ -1392,7 +1391,6 @@ 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);
@@ -1569,7 +1567,6 @@ static int ci13xxx_start(struct usb_gadget *gadget,
if (ci-vbus_active) {
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);
@@ -1680,7 +1677,7 @@ static irqreturn_t udc_irq(struct ci13xxx *ci)
intr = hw_read(ci, OP_OTGSC, ~0);
hw_write(ci, OP_OTGSC, ~0, intr);
 
-   if (intr  (OTGSC_AVVIE  OTGSC_AVVIS))
+   if ((intr  OTGSC_BSVIE)  (intr  OTGSC_BSVIS))
queue_work(ci-wq, ci-vbus_work);
 
spin_unlock(ci-lock);
@@ -1758,7 +1755,6 @@ 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);
@@ -1782,6 +1778,9 @@ static int udc_start(struct ci13xxx *ci)
if (retval)
goto remove_trans;
 
+   queue_work(ci-wq, ci-vbus_work);
+   hw_enable_vbus_intr(ci);
+
pm_runtime_no_callbacks(ci-gadget.dev);
pm_runtime_enable(ci-gadget.dev);
 
-- 
1.7.9.5


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


[PATCH v3] USB: mxs-phy: add basic otg support

2012-09-17 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
Acked-by: Felipe Balbi ba...@ti.com
---
Changes from v2:
 - assign host/gadget in mxs_phy_set_host/mxs_phy_set_peripheral

 drivers/usb/otg/mxs-phy.c |   25 +
 1 file changed, 25 insertions(+)

diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
index 88db976..3255112 100644
--- a/drivers/usb/otg/mxs-phy.c
+++ b/drivers/usb/otg/mxs-phy.c
@@ -129,12 +129,28 @@ 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)
+{
+   otg-host = host;
+
+   return 0;
+}
+
+static int mxs_phy_set_peripheral(struct usb_otg *otg,
+   struct usb_gadget *gadget)
+{
+   otg-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) {
@@ -171,6 +187,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


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


Re: [patch] USB: chipidea: fix vs | bug

2012-09-14 Thread Richard Zhao
On Fri, Sep 14, 2012 at 09:50:56AM +0300, Dan Carpenter wrote:
 There is a '' vs '|' typo in the original code so the condition is
 never true and we don't queue the work.
 
 Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
 ---
 
 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index 2f45bba..5294f81 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -1680,7 +1680,7 @@ static irqreturn_t udc_irq(struct ci13xxx *ci)
   intr = hw_read(ci, OP_OTGSC, ~0);
   hw_write(ci, OP_OTGSC, ~0, intr);
  
 - if (intr  (OTGSC_AVVIE  OTGSC_AVVIS))
 + if (intr  (OTGSC_AVVIE | OTGSC_AVVIS))
It's not what I meant. Should be
if ((intr  OTGSC_AVVIE)  (intr  OTGSC_AVVIS))
I'm still testing it.

Thanks
Richard
   queue_work(ci-wq, ci-vbus_work);
  
   spin_unlock(ci-lock);
 

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


Re: [PATCH v2 06/11] USB: mxs-phy: add basic otg support

2012-09-14 Thread Richard Zhao
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
 

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


Re: [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed

2012-09-14 Thread Richard Zhao
On Wed, Sep 12, 2012 at 01:47:54PM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@freescale.com writes:
 
  On Tue, Sep 11, 2012 at 10:23:55AM +0300, Alexander Shishkin wrote:
  Richard Zhao richard.z...@freescale.com writes:
  
   On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
   Richard Zhao richard.z...@freescale.com writes:
   
On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
Richard Zhao richard.z...@freescale.com writes:

 On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@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.z...@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
 

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


Re: [PATCH v2 06/11] USB: mxs-phy: add basic otg support

2012-09-14 Thread Richard Zhao
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
 

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


Re: [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed

2012-09-11 Thread Richard Zhao
On Tue, Sep 11, 2012 at 10:23:55AM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@freescale.com writes:
 
  On Wed, Aug 29, 2012 at 12:48:15PM +0300, Alexander Shishkin wrote:
  Richard Zhao richard.z...@freescale.com writes:
  
   On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
   Richard Zhao richard.z...@freescale.com writes:
   
On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
Richard Zhao richard.z...@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.z...@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
 

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


Re: [PATCH 2/2] usb: chipidea: usbmisc: prepare driver to handle more than one soc

2012-09-07 Thread Richard Zhao
On Thu, Sep 06, 2012 at 05:18:29PM +0200, Marc Kleine-Budde wrote:
 On 09/06/2012 05:15 PM, Richard Zhao wrote:
  Hi Marc,
  
  usbmisc_imx6q.c is only for imx6x. And for a certain running kernel,
  there will be always one driver instance.
 
 It's currently only for imx6q, but I've patches[1] in queue for mx53.
 And mx35 is about to be written.
It's per-SoC file. mx53 and mx35 should have their specific driver,
because the register layout is SoC specific.

Thanks
Richard
 
 Marc
 
 [1]
 http://git.pengutronix.de/?p=mkl/linux.git;a=commit;h=bdeff138ba8bb40856c9946b67df2604fdb4416b
 
 -- 
 Pengutronix e.K.  | Marc Kleine-Budde   |
 Industrial Linux Solutions| Phone: +49-231-2826-924 |
 Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
 Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
 



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


Re: [PATCH v3 4/5] usb: chipidea: cleanup dma_pool if udc_start() fails

2012-09-06 Thread Richard Zhao
On Wed, Sep 05, 2012 at 10:11:52AM +0200, Marc Kleine-Budde wrote:
 If udc_start() fails the qh_pool dma-pool cannot be closed because
 it's still in use. This patch factors out the dma_pool_free() loop
 into destroy_eps() and calls it in the error path of udc_start(),
 too.
 
 Cc: Richard Zhao richard.z...@freescale.com
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
Reviewed-by: Richard Zhao richard.z...@freescale.com

 ---
  drivers/usb/chipidea/udc.c |   23 +++
  1 file changed, 15 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index 3a755e5..2d8b609 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -1503,6 +1503,17 @@ static int init_eps(struct ci13xxx *ci)
   return retval;
  }
  
 +static void destroy_eps(struct ci13xxx *ci)
 +{
 + int i;
 +
 + for (i = 0; i  ci-hw_ep_max; i++) {
 + struct ci13xxx_ep *mEp = ci-ci13xxx_ep[i];
 +
 + dma_pool_free(ci-qh_pool, mEp-qh.ptr, mEp-qh.dma);
 + }
 +}
 +
  /**
   * ci13xxx_start: register a gadget driver
   * @gadget: our gadget
 @@ -1710,7 +1721,7 @@ static int udc_start(struct ci13xxx *ci)
   if (ci-platdata-flags  CI13XXX_REQUIRE_TRANSCEIVER) {
   if (ci-transceiver == NULL) {
   retval = -ENODEV;
 - goto free_pools;
 + goto destroy_eps;
   }
   }
  
 @@ -1761,6 +1772,8 @@ unreg_device:
  put_transceiver:
   if (!IS_ERR_OR_NULL(ci-transceiver)  ci-global_phy)
   usb_put_phy(ci-transceiver);
 +destroy_eps:
 + destroy_eps(ci);
  free_pools:
   dma_pool_destroy(ci-td_pool);
  free_qh_pool:
 @@ -1775,18 +1788,12 @@ free_qh_pool:
   */
  static void udc_stop(struct ci13xxx *ci)
  {
 - int i;
 -
   if (ci == NULL)
   return;
  
   usb_del_gadget_udc(ci-gadget);
  
 - for (i = 0; i  ci-hw_ep_max; i++) {
 - struct ci13xxx_ep *mEp = ci-ci13xxx_ep[i];
 -
 - dma_pool_free(ci-qh_pool, mEp-qh.ptr, mEp-qh.dma);
 - }
 + destroy_eps(ci);
  
   dma_pool_destroy(ci-td_pool);
   dma_pool_destroy(ci-qh_pool);
 -- 
 1.7.10.4
 
 

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


Re: [PATCH 2/3] usb: otg: add device tree support to otg library

2012-09-06 Thread Richard Zhao
On Thu, Sep 06, 2012 at 05:30:02PM +0300, Felipe Balbi wrote:
 On Tue, Sep 04, 2012 at 09:32:06PM +0200, Marc Kleine-Budde wrote:
  On 09/04/2012 07:51 PM, ABRAHAM, KISHON VIJAY wrote:
   Since it's already a common function, we may give phandler 
   property
   a common name too. So we will not need phandle argument.
   Please also don't forget to document the devm_xxx and dt 
   binding.
  
   I don't think this is a good idea. If we hardcode the phandle 
   name, we
   introduce a limit of one phy per usb device. The usb3 controllers
   alreadyt use two phys (one for usb2, the othere for usb3) for one
   controller. So I think we should not make the same mistake again.
   That only means current binding is not good enough. Rather not, 
   means
   it should not be in common code.
   Maybe something like:
   usbport0-phys = phy0;
   usbport1-phys = phy1 phy2; /* usb2  usb3 */
  
   Granted. Do we need strings that describe the phys, like in pinctrl 
   or
   is a index enough? What about this?
  
   struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
 int index)
  
  
   Comments? The phandle_name string will be usbphy.
  
   I don't think phandle_name should be usbphy. Eventually we want to 
   turn
   this into a kernel-wide phy subsystem and if we use usbphy, we will 
   just
   have to patch a bunch of dts files once we make the move.
   Coud you please give a link of kernel-wide phy subsystem discussion?
  
   Is just phy better?
   If the property name don't include port number, how do we know what
   port the phy is attached to?
   
   We can use something like -phy as the phandle name. And the
   users can get the phy by using
   devm_usb_get_phy_by_phandle(dev, ).
   (So the frwrk appends *-phy* to the name and searches). Or we don't
   have any  restriction on the phandle naming conventions and search for
   the phandle by the name the user passes in devm_usb_get_phy_by_phandle
   directly.
  
  Maintainer, I need a Maintainer. Can someone please decide what we want
  to have here. I can code all that, but please someone has to make a
  decision. Now, please.
 
 Like I said on another reply:
 
 phyN (phy1, phy2, ... phyN) is better since eventually we want to turn
 this into a kernel-wide PHY layer.
I think Marc is wondering how to handle the below two case in such way.
 - how to get the port number the phy is attached to
 - how to describe it if a port has two phys.

Thanks
Richard
 
 -- 
 balbi


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


Re: [PATCH 1/2] usb: chipidea: usbmisc: unset global varibale usbmisc on driver remove

2012-09-06 Thread Richard Zhao
Hi Marc,

Thanks for your patch. It's good.

Richard

On Thu, Sep 06, 2012 at 02:37:58PM +0200, Marc Kleine-Budde wrote:
 While there fix a potential race condition, first set usbmisc, then call
 usbmisc_set_ops().
 
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 ---
  drivers/usb/chipidea/usbmisc_imx6q.c |5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/chipidea/usbmisc_imx6q.c 
 b/drivers/usb/chipidea/usbmisc_imx6q.c
 index 416e3fc..edc0edd7 100644
 --- a/drivers/usb/chipidea/usbmisc_imx6q.c
 +++ b/drivers/usb/chipidea/usbmisc_imx6q.c
 @@ -116,14 +116,14 @@ static int __devinit usbmisc_imx6q_probe(struct 
 platform_device *pdev)
   return ret;
   }
  
 + usbmisc = data;
   ret = usbmisc_set_ops(imx6q_usbmisc_ops);
   if (ret) {
 + usbmisc = NULL;
   clk_disable_unprepare(data-clk);
   return ret;
   }
  
 - usbmisc = data;
 -
   return 0;
  }
  
 @@ -131,6 +131,7 @@ static int __devexit usbmisc_imx6q_remove(struct 
 platform_device *pdev)
  {
   usbmisc_unset_ops(imx6q_usbmisc_ops);
 + usbmisc = NULL;
   clk_disable_unprepare(usbmisc-clk);
 + usbmisc = NULL;
   return 0;
  }
  
 -- 
 1.7.10.4
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-usb in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] usb: chipidea: usbmisc: prepare driver to handle more than one soc

2012-09-06 Thread Richard Zhao
Hi Marc,

usbmisc_imx6q.c is only for imx6x. And for a certain running kernel,
there will be always one driver instance.

Thanks
Richard

On Thu, Sep 06, 2012 at 02:37:59PM +0200, Marc Kleine-Budde wrote:
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 ---
  drivers/usb/chipidea/usbmisc_imx6q.c |9 ++---
  1 file changed, 6 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/chipidea/usbmisc_imx6q.c 
 b/drivers/usb/chipidea/usbmisc_imx6q.c
 index edc0edd7..5989a80 100644
 --- a/drivers/usb/chipidea/usbmisc_imx6q.c
 +++ b/drivers/usb/chipidea/usbmisc_imx6q.c
 @@ -26,6 +26,7 @@ struct imx6q_usbmisc {
   spinlock_t lock;
   struct clk *clk;
   struct usbmisc_usb_device usbdev[USB_DEV_MAX];
 + const struct usbmisc_ops *ops;
  };
  
  static struct imx6q_usbmisc *usbmisc;
 @@ -78,7 +79,7 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = {
  };
  
  static const struct of_device_id usbmisc_imx6q_dt_ids[] = {
 - { .compatible = fsl,imx6q-usbmisc},
 + { .compatible = fsl,imx6q-usbmisc, .data = (void *)imx6q_usbmisc_ops 
 },
   { /* sentinel */ }
  };
  
 @@ -116,8 +117,10 @@ static int __devinit usbmisc_imx6q_probe(struct 
 platform_device *pdev)
   return ret;
   }
  
 + data-ops = (const struct usbmisc_ops *)
 + of_match_device(usbmisc_imx6q_dt_ids, pdev-dev);
   usbmisc = data;
 - ret = usbmisc_set_ops(imx6q_usbmisc_ops);
 + ret = usbmisc_set_ops(data-ops);
   if (ret) {
   usbmisc = NULL;
   clk_disable_unprepare(data-clk);
 @@ -129,7 +132,7 @@ static int __devinit usbmisc_imx6q_probe(struct 
 platform_device *pdev)
  
  static int __devexit usbmisc_imx6q_remove(struct platform_device *pdev)
  {
 - usbmisc_unset_ops(imx6q_usbmisc_ops);
 + usbmisc_unset_ops(usbmisc-ops);
   clk_disable_unprepare(usbmisc-clk);
   usbmisc = NULL;
   return 0;
 -- 
 1.7.10.4
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-usb in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] usb: otg: add device tree support to otg library

2012-09-04 Thread Richard Zhao
On Tue, Sep 04, 2012 at 03:58:50PM +0200, Marc Kleine-Budde wrote:
 On 09/04/2012 03:45 PM, Felipe Balbi wrote:
  On Tue, Sep 04, 2012 at 12:31:14PM +0200, Marc Kleine-Budde wrote:
  On 08/29/2012 10:11 PM, Marc Kleine-Budde wrote:
  [...]
 
  +struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
  +const char *phandle)
 
  Since it's already a common function, we may give phandler property
  a common name too. So we will not need phandle argument.
  Please also don't forget to document the devm_xxx and dt binding.
 
  I don't think this is a good idea. If we hardcode the phandle name, we
  introduce a limit of one phy per usb device. The usb3 controllers
  alreadyt use two phys (one for usb2, the othere for usb3) for one
  controller. So I think we should not make the same mistake again.
  That only means current binding is not good enough. Rather not, means
  it should not be in common code.
  Maybe something like:
  usbport0-phys = phy0;
  usbport1-phys = phy1 phy2; /* usb2  usb3 */
 
  Granted. Do we need strings that describe the phys, like in pinctrl or
  is a index enough? What about this?
 
  struct usb_phy *devm_usb_get_phy_by_phandle(struct device *dev,
int index)
 
 
  Comments? The phandle_name string will be usbphy.
  
  I don't think phandle_name should be usbphy. Eventually we want to turn
  this into a kernel-wide phy subsystem and if we use usbphy, we will just
  have to patch a bunch of dts files once we make the move.
Coud you please give a link of kernel-wide phy subsystem discussion?
 
 Is just phy better?
If the property name don't include port number, how do we know what
port the phy is attached to?

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


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


Re: [PATCH v6 1/3] USB: chipidea: add imx usbmisc support

2012-09-04 Thread Richard Zhao
On Wed, Aug 29, 2012 at 10:00:32PM +0200, Marc Kleine-Budde wrote:
 On 08/29/2012 01:01 PM, Sascha Hauer wrote:
  On Wed, Aug 29, 2012 at 01:18:10PM +0300, Alexander Shishkin wrote:
  Sascha Hauer s.ha...@pengutronix.de writes:
 
  On Wed, Aug 29, 2012 at 10:50:08AM +0300, Alexander Shishkin wrote:
  Richard Zhao richard.z...@freescale.com writes:
 
  i.MX usb controllers shares non-core registers, which may include
  SoC specific controls. We take it as a usbmisc device and usbmisc
  driver set operations needed by ci13xxx_imx driver.
 
  For example, Sabrelite board has bad over-current design, we can
  usbmisc to disable over-current detect.
 
  Why does this have to be part of the usb driver instead of SoC specific
  code? It looks like you've created a whole new device/driver
  infrastructure just to disable overcurrent for a specific board.
 
  Richards code indeed only handles overcurrent for a specific board, but
  there are more bits to configure in the longer run: power pin
  polarities, ULPI/serial mode select and some more.
 
 We already have a patch adding a usbmisc_imx53_init() function to that
 driver.
 
  Sounds to me like these things that should be taken care of by the phy
  driver, which will likely be simpler from both driver's and devicetree's
  perspective.
  
  Most i.MX SoCs have three instances of the chipidea core. These cores
  share a single register space for controlling the mentioned bits (the
  usbmisc register space). The usbmisc looks different on the different
  SoCs.
  Indeed they control some phy specific aspects, but the phy itself may
  also be an external ULPI or UTMI phy with a separate driver. So if we
  integrate the usbmisc into the phy wouldn't that mean that it has to
  be integrated into all possible phy drivers?
  
  From a devicetrees perspective it makes sense to integrate the flags
  into the chipidea nodes, because there is one node per chipidea core,
  but only one usbmisc unit for all ports on the SoC. So we can do a:
  
  chipidea@ofs {
  disable-overcurrent = 1;
  };
  
  instead of
  
  usbmisc@ofs {
  disable-overcurrent-port0 = 1;
  disable-overcurrent-port1 = 0;
  ...
  };
 
 +1
 
 IMHO looks much cleaner.
So, Marc agree on the patch too. Maybe you can give a reviewed-by? :)

Hi Alex,

What do you think?

Thanks
Richard
 
  And the infrastructure boils down to a complex way of passing a callback
  from imx driver to another imx driver, that only works if they are
  probed in the right order. I don't see any point in doing it like this
  other than inflating the device tree tables even further.
 
  Why can't this be part of the SoC code like it is done, for example in
  arch/arm/mach-omap2/control.c?
 
  The settings are board specific, so there must be some way to configure
  them in the devicetree.
 
  But I'm sure there's a way to control board-specific settings/kludges
  from devicetree?
  
  Hm, yes. That's what Richard does, right? I may be misunderstanding you
  here.
  
  Sascha
 
 Marc
 
 
 -- 
 Pengutronix e.K.  | Marc Kleine-Budde   |
 Industrial Linux Solutions| Phone: +49-231-2826-924 |
 Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
 Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
 


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


Re: [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed

2012-09-04 Thread Richard Zhao
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.z...@freescale.com writes:
  
   On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
   Richard Zhao richard.z...@freescale.com writes:
   
On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
Richard Zhao richard.z...@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.z...@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
  
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 1/3] USB: chipidea: add imx usbmisc support

2012-08-29 Thread Richard Zhao
On Wed, Aug 29, 2012 at 10:50:08AM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@freescale.com writes:
 
  i.MX usb controllers shares non-core registers, which may include
  SoC specific controls. We take it as a usbmisc device and usbmisc
  driver set operations needed by ci13xxx_imx driver.
 
  For example, Sabrelite board has bad over-current design, we can
  usbmisc to disable over-current detect.
 
 Why does this have to be part of the usb driver instead of SoC specific
 code? It looks like you've created a whole new device/driver
 infrastructure just to disable overcurrent for a specific board.
 
 And the infrastructure boils down to a complex way of passing a callback
 from imx driver to another imx driver, that only works if they are
 probed in the right order. I don't see any point in doing it like this
 other than inflating the device tree tables even further.
The goal is to let ci13xxx_imx can call usbmisc function at runtime.
The disable over current can be set once at boot time, but there's other
callbacks which is not yet in the mainline have to be called dynamically.

Thanks
Richard
 
 Why can't this be part of the SoC code like it is done, for example in
 arch/arm/mach-omap2/control.c?
 
 Regards,
 --
 Alex
 
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  Acked-by: Sascha Hauer s.ha...@pengutronix.de
  ---
   .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +
   .../devicetree/bindings/usb/usbmisc-imx.txt|   14 ++
   drivers/usb/chipidea/Makefile  |2 +-
   drivers/usb/chipidea/ci13xxx_imx.c |   64 
   drivers/usb/chipidea/ci13xxx_imx.h |   28 
   drivers/usb/chipidea/usbmisc_imx6q.c   |  162 
  
   6 files changed, 274 insertions(+), 1 deletion(-)
   create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
   create mode 100644 drivers/usb/chipidea/ci13xxx_imx.h
   create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c
 
  diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
  b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
  index 2c29041..5778b9c 100644
  --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
  +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
  @@ -7,7 +7,10 @@ Required properties:
   
   Optional properties:
   - fsl,usbphy: phandler of usb phy that connects to the only one port
  +- fsl,usbmisc: phandler of non-core register device, with one argument
  +  that indicate usb controller index
   - vbus-supply: regulator for vbus
  +- disable-over-current: disable over current detect
   
   Examples:
   usb@02184000 { /* USB OTG */
  @@ -15,4 +18,6 @@ usb@02184000 { /* USB OTG */
  reg = 0x02184000 0x200;
  interrupts = 0 43 0x04;
  fsl,usbphy = usbphy1;
  +   fsl,usbmisc = usbmisc 0;
  +   disable-over-current;
   };
  diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
  b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
  new file mode 100644
  index 000..97ce94e
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
  @@ -0,0 +1,14 @@
  +* Freescale i.MX non-core registers
  +
  +Required properties:
  +- #index-cells: Cells used to descibe usb controller index. Should be 1
  +- compatible: Should be one of below:
  +   fsl,imx6q-usbmisc for imx6q
  +- reg: Should contain registers location and length
  +
  +Examples:
  +usbmisc@02184800 {
  +   #index-cells = 1;
  +   compatible = fsl,imx6q-usbmisc;
  +   reg = 0x02184800 0x200;
  +};
  diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
  index 5c66d9c..57e510f 100644
  --- a/drivers/usb/chipidea/Makefile
  +++ b/drivers/usb/chipidea/Makefile
  @@ -15,5 +15,5 @@ ifneq ($(CONFIG_PCI),)
   endif
   
   ifneq ($(CONFIG_OF_DEVICE),)
  -   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
  +   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o usbmisc_imx6q.o
   endif
  diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
  b/drivers/usb/chipidea/ci13xxx_imx.c
  index ef60d06..96ac67b 100644
  --- a/drivers/usb/chipidea/ci13xxx_imx.c
  +++ b/drivers/usb/chipidea/ci13xxx_imx.c
  @@ -22,6 +22,7 @@
   #include linux/regulator/consumer.h
   
   #include ci.h
  +#include ci13xxx_imx.h
   
   #define pdev_to_phy(pdev) \
  ((struct usb_phy *)platform_get_drvdata(pdev))
  @@ -34,6 +35,55 @@ struct ci13xxx_imx_data {
  struct regulator *reg_vbus;
   };
   
  +static const struct usbmisc_ops *usbmisc_ops;
  +
  +/* Common functions shared by usbmisc drivers */
  +
  +int usbmisc_set_ops(const struct usbmisc_ops *ops)
  +{
  +   if (usbmisc_ops)
  +   return -EBUSY;
  +
  +   usbmisc_ops = ops;
  +
  +   return 0;
  +}
  +EXPORT_SYMBOL_GPL(usbmisc_set_ops);
  +
  +void usbmisc_unset_ops(const struct usbmisc_ops *ops)
  +{
  +   usbmisc_ops = NULL;
  +}
  +EXPORT_SYMBOL_GPL(usbmisc_unset_ops);
  +
  +int usbmisc_get_init_data(struct device *dev

Re: [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path

2012-08-29 Thread Richard Zhao
On Wed, Aug 29, 2012 at 11:03:48AM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@freescale.com writes:
 
  On Tue, Aug 28, 2012 at 11:29:35AM +0300, Alexander Shishkin wrote:
  Richard Zhao richard.z...@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.z...@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
 

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


Re: [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed

2012-08-29 Thread Richard Zhao
On Wed, Aug 29, 2012 at 11:10:33AM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@freescale.com writes:
 
  On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
  Richard Zhao richard.z...@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.z...@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
 

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


[PATCH v6 0/3] imx: add usbmisc support

2012-08-28 Thread Richard Zhao
usbmisc driver handles the SoC specific non-core usb registers.

Changes since last version:
 goto err when usbmisc_ops-init failed rather than return directly.

Richard Zhao (3):
  USB: chipidea: add imx usbmisc support
  ARM: imx6q: clk_register_clkdev usbmisc clock
  ARM: dts: imx6q-sabrelite: add usbmisc device

 .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   14 ++
 arch/arm/boot/dts/imx6q-sabrelite.dts  |1 +
 arch/arm/boot/dts/imx6q.dtsi   |   10 ++
 arch/arm/mach-imx/clk-imx6q.c  |1 +
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   64 
 drivers/usb/chipidea/ci13xxx_imx.h |   28 
 drivers/usb/chipidea/usbmisc_imx6q.c   |  162 
 9 files changed, 286 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/ci13xxx_imx.h
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

-- 
1.7.9.5


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


[PATCH v6 1/3] USB: chipidea: add imx usbmisc support

2012-08-28 Thread Richard Zhao
i.MX usb controllers shares non-core registers, which may include
SoC specific controls. We take it as a usbmisc device and usbmisc
driver set operations needed by ci13xxx_imx driver.

For example, Sabrelite board has bad over-current design, we can
usbmisc to disable over-current detect.

Signed-off-by: Richard Zhao richard.z...@freescale.com
Acked-by: Sascha Hauer s.ha...@pengutronix.de
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   14 ++
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   64 
 drivers/usb/chipidea/ci13xxx_imx.h |   28 
 drivers/usb/chipidea/usbmisc_imx6q.c   |  162 
 6 files changed, 274 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/ci13xxx_imx.h
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 2c29041..5778b9c 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -7,7 +7,10 @@ Required properties:
 
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
+- fsl,usbmisc: phandler of non-core register device, with one argument
+  that indicate usb controller index
 - vbus-supply: regulator for vbus
+- disable-over-current: disable over current detect
 
 Examples:
 usb@02184000 { /* USB OTG */
@@ -15,4 +18,6 @@ usb@02184000 { /* USB OTG */
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
+   fsl,usbmisc = usbmisc 0;
+   disable-over-current;
 };
diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
new file mode 100644
index 000..97ce94e
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
@@ -0,0 +1,14 @@
+* Freescale i.MX non-core registers
+
+Required properties:
+- #index-cells: Cells used to descibe usb controller index. Should be 1
+- compatible: Should be one of below:
+   fsl,imx6q-usbmisc for imx6q
+- reg: Should contain registers location and length
+
+Examples:
+usbmisc@02184800 {
+   #index-cells = 1;
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+};
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 5c66d9c..57e510f 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -15,5 +15,5 @@ ifneq ($(CONFIG_PCI),)
 endif
 
 ifneq ($(CONFIG_OF_DEVICE),)
-   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
+   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o usbmisc_imx6q.o
 endif
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index ef60d06..96ac67b 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -22,6 +22,7 @@
 #include linux/regulator/consumer.h
 
 #include ci.h
+#include ci13xxx_imx.h
 
 #define pdev_to_phy(pdev) \
((struct usb_phy *)platform_get_drvdata(pdev))
@@ -34,6 +35,55 @@ struct ci13xxx_imx_data {
struct regulator *reg_vbus;
 };
 
+static const struct usbmisc_ops *usbmisc_ops;
+
+/* Common functions shared by usbmisc drivers */
+
+int usbmisc_set_ops(const struct usbmisc_ops *ops)
+{
+   if (usbmisc_ops)
+   return -EBUSY;
+
+   usbmisc_ops = ops;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usbmisc_set_ops);
+
+void usbmisc_unset_ops(const struct usbmisc_ops *ops)
+{
+   usbmisc_ops = NULL;
+}
+EXPORT_SYMBOL_GPL(usbmisc_unset_ops);
+
+int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device 
*usbdev)
+{
+   struct device_node *np = dev-of_node;
+   struct of_phandle_args args;
+   int ret;
+
+   usbdev-dev = dev;
+
+   ret = of_parse_phandle_with_args(np, fsl,usbmisc, #index-cells,
+   0, args);
+   if (ret) {
+   dev_err(dev, Failed to parse property fsl,usbmisc, errno %d\n,
+   ret);
+   memset(usbdev, 0, sizeof(*usbdev));
+   return ret;
+   }
+   usbdev-index = args.args[0];
+   of_node_put(args.np);
+
+   if (of_find_property(np, disable-over-current, NULL))
+   usbdev-disable_oc = 1;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
+
+/* End of common functions shared by usbmisc drivers*/
+
 static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata  = {
.name   = ci13xxx_imx,
.flags  = CI13XXX_REQUIRE_TRANSCEIVER |
@@ -51,6 +101,10 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
struct regulator

[PATCH v6 3/3] ARM: dts: imx6q-sabrelite: add usbmisc device

2012-08-28 Thread Richard Zhao
- add usbmisc device
- set property fsl,usbmisc for usb controllers
- set disable-over-current for imx6q-sabrelite usb otg

Signed-off-by: Richard Zhao richard.z...@freescale.com
Acked-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |1 +
 arch/arm/boot/dts/imx6q.dtsi  |   10 ++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 72f30f3..aee0568 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -63,6 +63,7 @@
aips-bus@0210 { /* AIPS2 */
usb@02184000 { /* USB OTG */
vbus-supply = reg_usb_otg_vbus;
+   disable-over-current;
status = okay;
};
 
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index fd57079..7c27267 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -636,6 +636,7 @@
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
+   fsl,usbmisc = usbmisc 0;
status = disabled;
};
 
@@ -644,6 +645,7 @@
reg = 0x02184200 0x200;
interrupts = 0 40 0x04;
fsl,usbphy = usbphy2;
+   fsl,usbmisc = usbmisc 1;
status = disabled;
};
 
@@ -651,6 +653,7 @@
compatible = fsl,imx6q-usb, fsl,imx27-usb;
reg = 0x02184400 0x200;
interrupts = 0 41 0x04;
+   fsl,usbmisc = usbmisc 2;
status = disabled;
};
 
@@ -658,9 +661,16 @@
compatible = fsl,imx6q-usb, fsl,imx27-usb;
reg = 0x02184600 0x200;
interrupts = 0 42 0x04;
+   fsl,usbmisc = usbmisc 3;
status = disabled;
};
 
+   usbmisc: usbmisc@02184800 {
+   #index-cells = 1;
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+   };
+
ethernet@02188000 {
compatible = fsl,imx6q-fec;
reg = 0x02188000 0x4000;
-- 
1.7.9.5


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


[PATCH v6 2/3] ARM: imx6q: clk_register_clkdev usbmisc clock

2012-08-28 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
Acked-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/mach-imx/clk-imx6q.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index ea89520..660fcbb 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -405,6 +405,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[usboh3], NULL, 2184200.usb);
clk_register_clkdev(clk[usboh3], NULL, 2184400.usb);
clk_register_clkdev(clk[usboh3], NULL, 2184600.usb);
+   clk_register_clkdev(clk[usboh3], NULL, 2184800.usbmisc);
clk_register_clkdev(clk[usbphy1], NULL, 20c9000.usbphy);
clk_register_clkdev(clk[usbphy2], NULL, 20ca000.usbphy);
clk_register_clkdev(clk[uart_serial], per, 202.serial);
-- 
1.7.9.5


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


[PATCH v2 00/11] chipidea/imx: add otg support and some bug fix

2012-08-28 Thread Richard Zhao
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


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


[PATCH v2 01/11] USB: chipidea: imx: add pinctrl support

2012-08-28 Thread Richard Zhao
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.z...@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


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


[PATCH v2 02/11] USB: chipidea: delay 2ms before read ID status at probe time

2012-08-28 Thread Richard Zhao
The ID pin needs 1ms debounce time, event at probe time. We delay 2ms
for safe.

Signed-off-by: Richard Zhao richard.z...@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


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


[PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path

2012-08-28 Thread Richard Zhao
States in gadget are not needed any more, set it to zero.

Signed-off-by: Richard Zhao richard.z...@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


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


[PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed

2012-08-28 Thread Richard Zhao
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.z...@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


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


[PATCH v2 06/11] USB: mxs-phy: add basic otg support

2012-08-28 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@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


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


[PATCH v2 08/11] USB: chipidea: convert to use devm_request_irq

2012-08-28 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@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


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


[PATCH v2 09/11] USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG

2012-08-28 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@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


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


Re: [PATCH v2 04/11] USB: chipidea: clear gadget struct at udc_start fail path

2012-08-28 Thread Richard Zhao
On Tue, Aug 28, 2012 at 11:29:35AM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@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.z...@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
 

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


Re: [PATCH v2 05/11] USB: chipidea: don't let probe fail if otg controller start one role failed

2012-08-28 Thread Richard Zhao
On Tue, Aug 28, 2012 at 11:38:23AM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@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.z...@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 majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 

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


Re: [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails

2012-08-28 Thread Richard Zhao
On Tue, Aug 28, 2012 at 12:52:19PM +0200, Marc Kleine-Budde wrote:
 On 08/28/2012 12:46 PM, Richard Zhao wrote:
  On Tue, Aug 28, 2012 at 12:31:25PM +0200, Marc Kleine-Budde wrote:
  If udc_start() fails the qh_pool dma-pool cannot be closed because
  it's still in use. This patch factors out the dma_pool_free() loop
  into destroy_eps() and calls it in the error path of udc_start(),
  too.
 
  Cc: Richard Zhao richard.z...@freescale.com
  Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
  ---
  Hello,
 
  Richard, can you please include this patch in your stack. IIRC I think it 
  once
  was, but now it's not anymore.
  Sorry for that. I just push it to my topics/usb-driver branch.
  Of course, it's better, if Alex can give a ACK and Greg could pick up.
 
 I'm not sure, if this [1] is the latest thread on this patch, but Greg
 asked to queue this patch into your tree.
It does not depends on my tree any more. It can be applied directly on
Greg's tree.

Thanks
Richard
 
 Marc
 
 [1] http://comments.gmane.org/gmane.linux.usb.general/66440
 -- 
 Pengutronix e.K.  | Marc Kleine-Budde   |
 Industrial Linux Solutions| Phone: +49-231-2826-924 |
 Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
 Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
 



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


Re: [PATCH 3/3] usb: mxs-phy: register phy as USB_PHY_TYPE_USB2

2012-08-28 Thread Richard Zhao
On Tue, Aug 28, 2012 at 03:42:07PM +0200, Marc Kleine-Budde wrote:
 On 08/27/2012 12:36 PM, Marc Kleine-Budde wrote:
 [...]
 
  +return usb_add_phy(mxs_phy-phy, USB_PHY_TYPE_USB2);
  Why is it usb2? It's kind of USB_PHY_TYPE_DT.
 
  For now there is USB_PHY_TYPE_USB2, USB_PHY_TYPE_USB3 and undefined. On
  the one hand it's an USB2 type phy on the other the type is not 
  relevant
  if you get the phy by a phandle. I think it should be USB2. Kishon, 
  what
  do you think?
 
  IMHO, USB_PHY_TYPE_DT does not qualify to be a phy type.
  USB_PHY_TYPE_USB2 makes more sense to me.
  Why is USB_PHY_TYPE_USB2 better? It might not be attached to usb2.
  undefined may be better, if it's not used to check re-initialization.
 
  What I meant is, the type should be something that qualifies the phy
  ip. For example, USB_PHY_TYPE_USB2 specifies a phy that connects to a
  usb2/usb3 controller to provide usb2 functionality. If a specific type
  of phy can't be qualified with a type (which ideally shouldn't be the
  case), UNDEFINED can be used.
  Ah, I though usb2 means the index of usb controller is 2. So, if usb2
  is usb version 2, how can usb_get_phy identify a unique controller. A
  SoC may have several usb2 controllers.
  
  Via the get by phandle the previous patch adds.
 
 Problem solved?
If it use DT, yes. If don't, no.

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



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


Re: [PATCH 3/3] usb: mxs-phy: register phy as USB_PHY_TYPE_USB2

2012-08-27 Thread Richard Zhao
On Mon, Aug 27, 2012 at 11:04:58AM +0530, ABRAHAM, KISHON VIJAY wrote:
 Hi,
 
 On Sat, Aug 25, 2012 at 3:33 PM, Marc Kleine-Budde m...@pengutronix.de 
 wrote:
  On 08/24/2012 08:51 AM, Richard Zhao wrote:
  On Thu, Aug 23, 2012 at 07:22:54PM +0200, Marc Kleine-Budde wrote:
  This patch registers the msx-phy as an USB_PHY_TYPE_USB2. This is needed 
  to get
  reference to the phy with devm_usb_get_phy_by_phandle(), which will be 
  added in
  a later patch.
 
  Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
  ---
   drivers/usb/otg/mxs-phy.c |5 -
   1 file changed, 4 insertions(+), 1 deletion(-)
 
  diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
  index c1a67cb..240b945 100644
  --- a/drivers/usb/otg/mxs-phy.c
  +++ b/drivers/usb/otg/mxs-phy.c
  @@ -141,11 +141,14 @@ static int mxs_phy_probe(struct platform_device 
  *pdev)
 
   platform_set_drvdata(pdev, mxs_phy-phy);
 
  -return 0;
  +return usb_add_phy(mxs_phy-phy, USB_PHY_TYPE_USB2);
  Why is it usb2? It's kind of USB_PHY_TYPE_DT.
 
  For now there is USB_PHY_TYPE_USB2, USB_PHY_TYPE_USB3 and undefined. On
  the one hand it's an USB2 type phy on the other the type is not relevant
  if you get the phy by a phandle. I think it should be USB2. Kishon, what
  do you think?
 
 IMHO, USB_PHY_TYPE_DT does not qualify to be a phy type.
 USB_PHY_TYPE_USB2 makes more sense to me.
Why is USB_PHY_TYPE_USB2 better? It might not be attached to usb2.
undefined may be better, if it's not used to check re-initialization.

Thanks
Richard
 
 Thanks
 Kishon
 

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


Re: chipidea driver

2012-08-27 Thread Richard Zhao
On Fri, Aug 24, 2012 at 10:34:37AM +0300, Alexander Shishkin wrote:
 Richard Zhao richard.z...@freescale.com writes:
 
  On Thu, Aug 23, 2012 at 06:57:03PM +0200, Marc Kleine-Budde wrote:
  Hello,
 
 Hi,
 
  Michael and I have a bunch of updates and improvement for the chipidea
  driver. They apply to Richard's tree:
  
  https://github.com/riczhao/kernel-imx/commits/topics/usb-driver
  
  What's the status of these patches? It would be fine if someone queues
  them for upstream.
  My patches is pending on Alex to review. The otg patch series was sent
  on Jul 12. I don't know whether Alex has been back from vacation, or
  what else I can do.
 
  otg patch: 
  http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/109020.html
  usbmisc: 
  http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/111945.html
 
 Thanks for the ping, will have a look soon.
Thanks. The above usbmisc link has got ack from imx maintainer Sascha.
So could you look at it first and ack?

Thanks
Richard
 
 Regards,
 --
 Alex
 

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


Re: [PATCH] usb: chipidea: ci13xxx_imx: fix regulator unbalance disable

2012-08-27 Thread Richard Zhao
Hi Marc,

Thanks. I'll merge the fix when I send out my v4 patch.

Thanks
Richard
On Mon, Aug 27, 2012 at 09:56:06PM +0200, Marc Kleine-Budde wrote:
 This patch applies to Richard's tree at
 https://github.com/riczhao/kernel-imx/commits/topics/usb-driver. It fixes an
 issue introduced with commit:
 
 acfc0b8 USB: chipidea: add set_vbus_power support
 
 That commit switches form a permanent vbus enable to set_vbus_power(), the
 permanent regulator_enable() is removed but the corresponding
 regulator_disable() are forgotten. This patch removes the leftover
 regulator_disable().
 
 Cc: Richard Zhao richard.z...@freescale.com
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 ---
  drivers/usb/chipidea/ci13xxx_imx.c |6 --
  1 file changed, 6 deletions(-)
 
 diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
 b/drivers/usb/chipidea/ci13xxx_imx.c
 index dd7f3a3..32e3e68 100644
 --- a/drivers/usb/chipidea/ci13xxx_imx.c
 +++ b/drivers/usb/chipidea/ci13xxx_imx.c
 @@ -123,7 +123,6 @@ 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))
   data-reg_vbus = reg_vbus;
 @@ -167,8 +166,6 @@ static int __devinit ci13xxx_imx_probe(struct 
 platform_device *pdev)
   return 0;
  
  err:
 - if (reg_vbus)
 - regulator_disable(reg_vbus);
   if (phy_np)
   of_node_put(phy_np);
   clk_disable_unprepare(data-clk);
 @@ -182,9 +179,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);
 -- 
 1.7.10.4
 
 

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


Re: [PATCH 3/3] usb: mxs-phy: register phy as USB_PHY_TYPE_USB2

2012-08-24 Thread Richard Zhao
On Thu, Aug 23, 2012 at 07:22:54PM +0200, Marc Kleine-Budde wrote:
 This patch registers the msx-phy as an USB_PHY_TYPE_USB2. This is needed to 
 get
 reference to the phy with devm_usb_get_phy_by_phandle(), which will be added 
 in
 a later patch.
 
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 ---
  drivers/usb/otg/mxs-phy.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
 index c1a67cb..240b945 100644
 --- a/drivers/usb/otg/mxs-phy.c
 +++ b/drivers/usb/otg/mxs-phy.c
 @@ -141,11 +141,14 @@ static int mxs_phy_probe(struct platform_device *pdev)
  
   platform_set_drvdata(pdev, mxs_phy-phy);
  
 - return 0;
 + return usb_add_phy(mxs_phy-phy, USB_PHY_TYPE_USB2);
Why is it usb2? It's kind of USB_PHY_TYPE_DT.
  }
  
  static int __devexit mxs_phy_remove(struct platform_device *pdev)
  {
 + struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
drvdata is usb_phy.

Thanks
Richard
 +
 + usb_remove_phy(mxs_phy-phy);
   platform_set_drvdata(pdev, NULL);
  
   return 0;
 -- 
 1.7.10.4
 
 

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


Re: [PATCH 1/4] usb: chipidea: udc: fix error path in udc_start()

2012-08-24 Thread Richard Zhao
On Thu, Aug 23, 2012 at 07:30:44PM +0200, Marc Kleine-Budde wrote:
 This patch fixes the error path of udc_start(). Now NULL is used to
 unset the peripheral with otg_set_peripheral().
 
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
Reviewed-by: Richard Zhao richard.z...@freescale.com
 ---
  drivers/usb/chipidea/udc.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index c7a032a..e4db7af 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -1729,7 +1729,7 @@ static int udc_start(struct ci13xxx *ci)
  
  remove_trans:
   if (!IS_ERR_OR_NULL(ci-transceiver)) {
 - otg_set_peripheral(ci-transceiver-otg, ci-gadget);
 + otg_set_peripheral(ci-transceiver-otg, NULL);
   if (ci-global_phy)
   usb_put_phy(ci-transceiver);
   }
 -- 
 1.7.10.4
 
 

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


Re: [PATCH 1/3] usb: otg: Improve phy handling

2012-08-23 Thread Richard Zhao
On Thu, Aug 23, 2012 at 07:22:51PM +0200, Marc Kleine-Budde wrote:
 This patch series improves the phy handling.
 
 The first patch fixes the problem that the phy driver, when build as module,
 can be unloaded when the phy is in use.
ci13xxx_imx also have a try_module_get.

Thanks
Richard
 The second patch takes up Kishon's work
 and adds device tree support to the otg library. New in this patch is that
 devm_usb_get_phy_by_phandle() will return with -EPROBE_DEFER, if the requested
 phy has not registered itself yet. The third patch registers the mxs-phy as a
 USB_PHY_TYPE_USB2 phy, so that the ci13xxx_imx driver can reqeust it via the
 devm_usb_get_phy_by_phandle() function.
 
 These patches apply to v3.6-rc3 and have ben successfully tested on mx28 and
 mx53 (with an improved version of the chipidea driver though).
 
 regards, Marc
 
 

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


Re: chipidea driver

2012-08-23 Thread Richard Zhao
On Thu, Aug 23, 2012 at 06:57:03PM +0200, Marc Kleine-Budde wrote:
 Hello,
 
 Michael and I have a bunch of updates and improvement for the chipidea
 driver. They apply to Richard's tree:
 
 https://github.com/riczhao/kernel-imx/commits/topics/usb-driver
 
 What's the status of these patches? It would be fine if someone queues
 them for upstream.
My patches is pending on Alex to review. The otg patch series was sent
on Jul 12. I don't know whether Alex has been back from vacation, or
what else I can do.

otg patch: 
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/109020.html
usbmisc: 
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/111945.html

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

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


Re: mxs-phy on i.MX233 not enumerating

2012-08-13 Thread Richard Zhao
On Tue, Aug 14, 2012 at 10:40:21AM +0800, Chen Peter-B29397 wrote:
  
  
   According to IC guys, the logic of handling HOSTDISCONDETECT is the
  same
   between i.mx28 and i.mx23.
  
  As pointed out by Sean, on mx23 reference manual we have the following
  text describing HOSTDISCONDETECT:
  
  Due to a on chip issue (Errata #2791), software must
  pay attention to when to assert the HOSTDISCONDETECT bit description
  has the following:
  
  ENHOSTDISCONDETECT bit in HW_USBPHY_CTRL register:
  1. Only set HW_USBPHY_CTRL.ENHOSTDISCONDETECT
  during high speed host mode.
  2. Do not set HW_USBPHY_CTRL.ENHOSTDISCONDETECT
  during the reset and speed negotiation period.
  3. Do not set HW_USBPHY_CTRL.ENHOSTDISCONDETECT
  during host suspend/resume sequence.
  
  and the same is not present on mx28 reference manual.
  
  How can we make sure we are not violating the point 2 above?
  
 It is the same with i.mx28.
If they're same, imx23 should be ok. The mxs_phy driver pass test
on mx28.
 I think Richard's patch should not
 violate point 2. Richard, can you confirm it?
You mean I should not set the bit in mxs_phy_on_connect?
or mxs_phy_on_connect is called in wrong place?

Thanks
Richard
 
  Thanks,
  
  Fabio Estevam
 

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


Re: [PATCH v4 1/3] USB: chipidea: add imx usbmisc support

2012-08-01 Thread Richard Zhao
 Could it be that something is missing in this patch? I don't see struct
 usbmisc_usb_device defined anywhere in this patch.
ah, Sorry I missed the header file. I'll send a new version.

Thanks
Richard
 
 Sascha
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 --
 To unsubscribe from this list: send the line unsubscribe linux-usb in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 

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


[PATCH v5 0/3] imx: add usbmisc support

2012-08-01 Thread Richard Zhao
usbmisc driver handles the SoC specific non-core usb registers.

Changes since last version:
 - add missing ci13xxx_imx.h

Changes v3 - v4:
 - rebase onto torvalds latest git tree
 - use phandle linke usb controllers and usbmisc device.
   It also make usbmisc driver possible to be kernel modules.

Richard Zhao (3):
  USB: chipidea: add imx usbmisc support
  ARM: imx6q: clk_register_clkdev usbmisc clock
  ARM: dts: imx6q-sabrelite: add usbmisc device

 .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   14 ++
 arch/arm/boot/dts/imx6q-sabrelite.dts  |1 +
 arch/arm/boot/dts/imx6q.dtsi   |   10 ++
 arch/arm/mach-imx/clk-imx6q.c  |1 +
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   64 
 drivers/usb/chipidea/ci13xxx_imx.h |   28 
 drivers/usb/chipidea/usbmisc_imx6q.c   |  162 
 9 files changed, 286 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/ci13xxx_imx.h
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

-- 
1.7.9.5


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


[PATCH v5 2/3] ARM: imx6q: clk_register_clkdev usbmisc clock

2012-08-01 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index ea89520..660fcbb 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -405,6 +405,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[usboh3], NULL, 2184200.usb);
clk_register_clkdev(clk[usboh3], NULL, 2184400.usb);
clk_register_clkdev(clk[usboh3], NULL, 2184600.usb);
+   clk_register_clkdev(clk[usboh3], NULL, 2184800.usbmisc);
clk_register_clkdev(clk[usbphy1], NULL, 20c9000.usbphy);
clk_register_clkdev(clk[usbphy2], NULL, 20ca000.usbphy);
clk_register_clkdev(clk[uart_serial], per, 202.serial);
-- 
1.7.9.5


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


[PATCH v5 3/3] ARM: dts: imx6q-sabrelite: add usbmisc device

2012-08-01 Thread Richard Zhao
- add usbmisc device
- set property fsl,usbmisc for usb controllers
- set disable-over-current for imx6q-sabrelite usb otg

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |1 +
 arch/arm/boot/dts/imx6q.dtsi  |   10 ++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index d42e851..b32ebfc 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -62,6 +62,7 @@
aips-bus@0210 { /* AIPS2 */
usb@02184000 { /* USB OTG */
vbus-supply = reg_usb_otg_vbus;
+   disable-over-current;
status = okay;
};
 
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 3d3c64b..a6e1816 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -629,6 +629,7 @@
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
+   fsl,usbmisc = usbmisc 0;
status = disabled;
};
 
@@ -637,6 +638,7 @@
reg = 0x02184200 0x200;
interrupts = 0 40 0x04;
fsl,usbphy = usbphy2;
+   fsl,usbmisc = usbmisc 1;
status = disabled;
};
 
@@ -644,6 +646,7 @@
compatible = fsl,imx6q-usb, fsl,imx27-usb;
reg = 0x02184400 0x200;
interrupts = 0 41 0x04;
+   fsl,usbmisc = usbmisc 2;
status = disabled;
};
 
@@ -651,9 +654,16 @@
compatible = fsl,imx6q-usb, fsl,imx27-usb;
reg = 0x02184600 0x200;
interrupts = 0 42 0x04;
+   fsl,usbmisc = usbmisc 3;
status = disabled;
};
 
+   usbmisc: usbmisc@02184800 {
+   #index-cells = 1;
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+   };
+
ethernet@02188000 {
compatible = fsl,imx6q-fec;
reg = 0x02188000 0x4000;
-- 
1.7.9.5


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


[PATCH v5 1/3] USB: chipidea: add imx usbmisc support

2012-08-01 Thread Richard Zhao
i.MX usb controllers shares non-core registers, which may include
SoC specific controls. We take it as a usbmisc device and usbmisc
driver set operations needed by ci13xxx_imx driver.

For example, Sabrelite board has bad over-current design, we can
usbmisc to disable over-current detect.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   14 ++
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   64 
 drivers/usb/chipidea/ci13xxx_imx.h |   28 
 drivers/usb/chipidea/usbmisc_imx6q.c   |  162 
 6 files changed, 274 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/ci13xxx_imx.h
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 2c29041..5778b9c 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -7,7 +7,10 @@ Required properties:
 
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
+- fsl,usbmisc: phandler of non-core register device, with one argument
+  that indicate usb controller index
 - vbus-supply: regulator for vbus
+- disable-over-current: disable over current detect
 
 Examples:
 usb@02184000 { /* USB OTG */
@@ -15,4 +18,6 @@ usb@02184000 { /* USB OTG */
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
+   fsl,usbmisc = usbmisc 0;
+   disable-over-current;
 };
diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
new file mode 100644
index 000..97ce94e
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
@@ -0,0 +1,14 @@
+* Freescale i.MX non-core registers
+
+Required properties:
+- #index-cells: Cells used to descibe usb controller index. Should be 1
+- compatible: Should be one of below:
+   fsl,imx6q-usbmisc for imx6q
+- reg: Should contain registers location and length
+
+Examples:
+usbmisc@02184800 {
+   #index-cells = 1;
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+};
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 5c66d9c..57e510f 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -15,5 +15,5 @@ ifneq ($(CONFIG_PCI),)
 endif
 
 ifneq ($(CONFIG_OF_DEVICE),)
-   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
+   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o usbmisc_imx6q.o
 endif
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index ef60d06..05cd0ae 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -22,6 +22,7 @@
 #include linux/regulator/consumer.h
 
 #include ci.h
+#include ci13xxx_imx.h
 
 #define pdev_to_phy(pdev) \
((struct usb_phy *)platform_get_drvdata(pdev))
@@ -34,6 +35,55 @@ struct ci13xxx_imx_data {
struct regulator *reg_vbus;
 };
 
+static const struct usbmisc_ops *usbmisc_ops;
+
+/* Common functions shared by usbmisc drivers */
+
+int usbmisc_set_ops(const struct usbmisc_ops *ops)
+{
+   if (usbmisc_ops)
+   return -EBUSY;
+
+   usbmisc_ops = ops;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usbmisc_set_ops);
+
+void usbmisc_unset_ops(const struct usbmisc_ops *ops)
+{
+   usbmisc_ops = NULL;
+}
+EXPORT_SYMBOL_GPL(usbmisc_unset_ops);
+
+int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device 
*usbdev)
+{
+   struct device_node *np = dev-of_node;
+   struct of_phandle_args args;
+   int ret;
+
+   usbdev-dev = dev;
+
+   ret = of_parse_phandle_with_args(np, fsl,usbmisc, #index-cells,
+   0, args);
+   if (ret) {
+   dev_err(dev, Failed to parse property fsl,usbmisc, errno %d\n,
+   ret);
+   memset(usbdev, 0, sizeof(*usbdev));
+   return ret;
+   }
+   usbdev-index = args.args[0];
+   of_node_put(args.np);
+
+   if (of_find_property(np, disable-over-current, NULL))
+   usbdev-disable_oc = 1;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
+
+/* End of common functions shared by usbmisc drivers*/
+
 static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata  = {
.name   = ci13xxx_imx,
.flags  = CI13XXX_REQUIRE_TRANSCEIVER |
@@ -51,6 +101,10 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
struct regulator *reg_vbus;
int ret

Re: [PATCH v3 1/3] USB: chipidea: add imx usbmisc support

2012-07-31 Thread Richard Zhao
On Tue, Jul 31, 2012 at 09:06:33AM +0800, Chen Peter-B29397 wrote:
  
  
   usbmisc 0 would then mean port 0 of the usbmisc device.
  I didn't add the restriction that a usbmisc driver must have a usbmisc
  device. I'm not sure whether all SoC and future SoC can be look as
  a device.
  
  Peter, do you have any idea?
  
 I have not followed this usbmisc design, I just list some facts at i.mx
 USB controller:
 
 Sigmatel-derived SoCs (i.mx23, i.mx28) have no this register region, all phy 
 controls
 are through PHY register.
 Other freescale SoCs have this usbmisc register region to control phy and 
 tune some
 signal quality. This register region is from another 0x800 or (last 
 controller base address + 0x200) 
Looks good. I'll take Sascha's suggestion.

Thanks
Richard
 
  Thanks
  Richard
  
   If the usbmisc property exists, you can return -EPROBE_DEFER until it
  is
   available. If it doesn't exist, you just continue without usbmisc
   support (i.MX28)
  
   Sascha
  
  
   --
   Pengutronix e.K.   |
  |
   Industrial Linux Solutions | http://www.pengutronix.de/
  |
   Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0
  |
   Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917-
   |
  

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


[PATCH v4 0/3] imx: add usbmisc support

2012-07-31 Thread Richard Zhao
usbmisc driver handles the SoC specific non-core usb registers.

Changes since last version:
 - rebase onto torvalds latest git tree
 - use phandle linke usb controllers and usbmisc device.
   It also make usbmisc driver possible to be kernel modules.

Richard Zhao (3):
  USB: chipidea: add imx usbmisc support
  ARM: imx6q: clk_register_clkdev usbmisc clock
  ARM: dts: imx6q-sabrelite: add usbmisc device

 .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   14 ++
 arch/arm/boot/dts/imx6q-sabrelite.dts  |1 +
 arch/arm/boot/dts/imx6q.dtsi   |   10 ++
 arch/arm/mach-imx/clk-imx6q.c  |1 +
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   64 
 drivers/usb/chipidea/usbmisc_imx6q.c   |  162 
 8 files changed, 258 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

-- 
1.7.9.5


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


[PATCH v4 1/3] USB: chipidea: add imx usbmisc support

2012-07-31 Thread Richard Zhao
i.MX usb controllers shares non-core registers, which may include
SoC specific controls. We take it as a usbmisc device and usbmisc
driver set operations needed by ci13xxx_imx driver.

For example, Sabrelite board has bad over-current design, we can
usbmisc to disable over-current detect.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|5 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   14 ++
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   64 
 drivers/usb/chipidea/usbmisc_imx6q.c   |  162 
 5 files changed, 246 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 2c29041..5778b9c 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -7,7 +7,10 @@ Required properties:
 
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
+- fsl,usbmisc: phandler of non-core register device, with one argument
+  that indicate usb controller index
 - vbus-supply: regulator for vbus
+- disable-over-current: disable over current detect
 
 Examples:
 usb@02184000 { /* USB OTG */
@@ -15,4 +18,6 @@ usb@02184000 { /* USB OTG */
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
+   fsl,usbmisc = usbmisc 0;
+   disable-over-current;
 };
diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
new file mode 100644
index 000..97ce94e
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
@@ -0,0 +1,14 @@
+* Freescale i.MX non-core registers
+
+Required properties:
+- #index-cells: Cells used to descibe usb controller index. Should be 1
+- compatible: Should be one of below:
+   fsl,imx6q-usbmisc for imx6q
+- reg: Should contain registers location and length
+
+Examples:
+usbmisc@02184800 {
+   #index-cells = 1;
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+};
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 5c66d9c..57e510f 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -15,5 +15,5 @@ ifneq ($(CONFIG_PCI),)
 endif
 
 ifneq ($(CONFIG_OF_DEVICE),)
-   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
+   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o usbmisc_imx6q.o
 endif
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index ef60d06..05cd0ae 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -22,6 +22,7 @@
 #include linux/regulator/consumer.h
 
 #include ci.h
+#include ci13xxx_imx.h
 
 #define pdev_to_phy(pdev) \
((struct usb_phy *)platform_get_drvdata(pdev))
@@ -34,6 +35,55 @@ struct ci13xxx_imx_data {
struct regulator *reg_vbus;
 };
 
+static const struct usbmisc_ops *usbmisc_ops;
+
+/* Common functions shared by usbmisc drivers */
+
+int usbmisc_set_ops(const struct usbmisc_ops *ops)
+{
+   if (usbmisc_ops)
+   return -EBUSY;
+
+   usbmisc_ops = ops;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usbmisc_set_ops);
+
+void usbmisc_unset_ops(const struct usbmisc_ops *ops)
+{
+   usbmisc_ops = NULL;
+}
+EXPORT_SYMBOL_GPL(usbmisc_unset_ops);
+
+int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device 
*usbdev)
+{
+   struct device_node *np = dev-of_node;
+   struct of_phandle_args args;
+   int ret;
+
+   usbdev-dev = dev;
+
+   ret = of_parse_phandle_with_args(np, fsl,usbmisc, #index-cells,
+   0, args);
+   if (ret) {
+   dev_err(dev, Failed to parse property fsl,usbmisc, errno %d\n,
+   ret);
+   memset(usbdev, 0, sizeof(*usbdev));
+   return ret;
+   }
+   usbdev-index = args.args[0];
+   of_node_put(args.np);
+
+   if (of_find_property(np, disable-over-current, NULL))
+   usbdev-disable_oc = 1;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
+
+/* End of common functions shared by usbmisc drivers*/
+
 static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata  = {
.name   = ci13xxx_imx,
.flags  = CI13XXX_REQUIRE_TRANSCEIVER |
@@ -51,6 +101,10 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
struct regulator *reg_vbus;
int ret;
 
+   if (of_find_property(pdev-dev.of_node, fsl,usbmisc, NULL)
+!usbmisc_ops)
+   return -EPROBE_DEFER

[PATCH v4 3/3] ARM: dts: imx6q-sabrelite: add usbmisc device

2012-07-31 Thread Richard Zhao
- add usbmisc device
- set property fsl,usbmisc for usb controllers

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |1 +
 arch/arm/boot/dts/imx6q.dtsi  |   10 ++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index d42e851..b32ebfc 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -62,6 +62,7 @@
aips-bus@0210 { /* AIPS2 */
usb@02184000 { /* USB OTG */
vbus-supply = reg_usb_otg_vbus;
+   disable-over-current;
status = okay;
};
 
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 3d3c64b..a6e1816 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -629,6 +629,7 @@
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
+   fsl,usbmisc = usbmisc 0;
status = disabled;
};
 
@@ -637,6 +638,7 @@
reg = 0x02184200 0x200;
interrupts = 0 40 0x04;
fsl,usbphy = usbphy2;
+   fsl,usbmisc = usbmisc 1;
status = disabled;
};
 
@@ -644,6 +646,7 @@
compatible = fsl,imx6q-usb, fsl,imx27-usb;
reg = 0x02184400 0x200;
interrupts = 0 41 0x04;
+   fsl,usbmisc = usbmisc 2;
status = disabled;
};
 
@@ -651,9 +654,16 @@
compatible = fsl,imx6q-usb, fsl,imx27-usb;
reg = 0x02184600 0x200;
interrupts = 0 42 0x04;
+   fsl,usbmisc = usbmisc 3;
status = disabled;
};
 
+   usbmisc: usbmisc@02184800 {
+   #index-cells = 1;
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+   };
+
ethernet@02188000 {
compatible = fsl,imx6q-fec;
reg = 0x02188000 0x4000;
-- 
1.7.9.5


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


Re: [PATCH 00/12] chipidea/imx: add otg support and some bug fix

2012-07-30 Thread Richard Zhao
On Thu, Jul 26, 2012 at 06:59:48PM +0800, Richard Zhao wrote:
 On Thu, Jul 19, 2012 at 10:05:54AM +0800, Richard Zhao wrote:
  On Mon, Jul 16, 2012 at 05:40:57PM -0700, Greg KH wrote:
   On Thu, Jul 12, 2012 at 03:01:40PM +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

It's better apply after patch I sent out:
usb: chipidea: cleanup dma_pool if udc_start() fails
   
   I need acks from Alexander before I can accept any of these.
  ping Alexander ...
 ping Alexander again ...
Hi Greg,

Is there a better way but keeping waiting?

Hi Felipe,

Could you help review the patch series?

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

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


Re: [PATCH v3 1/3] USB: chipidea: add imx usbmisc support

2012-07-30 Thread Richard Zhao
On Mon, Jul 30, 2012 at 11:32:44AM +0200, Sascha Hauer wrote:
 On Thu, Jul 26, 2012 at 06:35:14PM +0800, Richard Zhao wrote:
  i.MX usb controllers shares non-core registers, which may include
  SoC specific controls. We take it as a usbmisc device and usbmisc
  driver set operations needed by ci13xxx_imx driver.
  
  For example, Sabrelite board has bad over-current design, we can
  usbmisc to disable over-current detect.
  
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   .../devicetree/bindings/usb/ci13xxx-imx.txt|2 +
   .../devicetree/bindings/usb/usbmisc-imx.txt|   12 ++
   drivers/usb/chipidea/Makefile  |3 +-
   drivers/usb/chipidea/ci13xxx_imx.c |   72 -
   drivers/usb/chipidea/usbmisc_imx6q.c   |  155 
  
   5 files changed, 242 insertions(+), 2 deletions(-)
   create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
   create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c
  
  diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
  b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
  index 2c29041..06105ce 100644
  --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
  +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
  @@ -8,6 +8,7 @@ Required properties:
   Optional properties:
   - fsl,usbphy: phandler of usb phy that connects to the only one port
   - vbus-supply: regulator for vbus
  +- disable-over-current: disable over current detect
   
   Examples:
   usb@02184000 { /* USB OTG */
  @@ -15,4 +16,5 @@ usb@02184000 { /* USB OTG */
  reg = 0x02184000 0x200;
  interrupts = 0 43 0x04;
  fsl,usbphy = usbphy1;
  +   disable-over-current;
   };
  diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
  b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
  new file mode 100644
  index 000..4fa500d
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
  @@ -0,0 +1,12 @@
  +* Freescale i.MX non-core registers
  +
  +Required properties:
  +- compatible: Should be one of below:
  +   fsl,imx6q-usbmisc for imx6q
  +- reg: Should contain registers location and length
  +
  +Examples:
  +usbmisc@02184800 {
  +   compatible = fsl,imx6q-usbmisc;
  +   reg = 0x02184800 0x200;
  +};
  diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
  index 5c66d9c..36f94c9d 100644
  --- a/drivers/usb/chipidea/Makefile
  +++ b/drivers/usb/chipidea/Makefile
  @@ -15,5 +15,6 @@ ifneq ($(CONFIG_PCI),)
   endif
   
   ifneq ($(CONFIG_OF_DEVICE),)
  -   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
  +   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx-imx.o
  +   ci13xxx-imx-y   := ci13xxx_imx.o usbmisc_imx6q.o
   endif
  diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
  b/drivers/usb/chipidea/ci13xxx_imx.c
  index ef60d06..d178889 100644
  --- a/drivers/usb/chipidea/ci13xxx_imx.c
  +++ b/drivers/usb/chipidea/ci13xxx_imx.c
  @@ -22,6 +22,7 @@
   #include linux/regulator/consumer.h
   
   #include ci.h
  +#include ci13xxx_imx.h
   
   #define pdev_to_phy(pdev) \
  ((struct usb_phy *)platform_get_drvdata(pdev))
  @@ -34,6 +35,48 @@ struct ci13xxx_imx_data {
  struct regulator *reg_vbus;
   };
   
  +static const struct usbmisc_ops *usbmisc_ops;
  +
  +/* Common functions shared by usbmisc drivers */
  +
  +int usbmisc_set_ops(const struct usbmisc_ops *ops)
  +{
  +   if (usbmisc_ops)
  +   return -EBUSY;
  +
  +   usbmisc_ops = ops;
  +
  +   return 0;
  +}
  +
  +void usbmisc_unset_ops(const struct usbmisc_ops *ops)
  +{
  +   usbmisc_ops = NULL;
  +}
  +
  +int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device 
  *usbdev)
  +{
  +   struct device_node *np = dev-of_node;
  +   int id;
  +
  +   usbdev-dev = dev;
  +
  +   id = of_alias_get_id(np, usb);
  +   if (id  0) {
  +   dev_err(dev, Failed to get alias id, errno %d\n, id);
  +   memset(usbdev, 0, sizeof(*usbdev));
  +   return id;
  +   }
  +   usbdev-index = id;
  +
  +   if (of_find_property(np, disable-over-current, NULL))
  +   usbdev-disable_oc = 1;
  +
  +   return 0;
  +}
  +
  +/* End of common functions shared by usbmisc drivers*/
  +
   static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata  = {
  .name   = ci13xxx_imx,
  .flags  = CI13XXX_REQUIRE_TRANSCEIVER |
  @@ -120,6 +163,16 @@ static int __devinit ci13xxx_imx_probe(struct 
  platform_device *pdev)
  *pdev-dev.dma_mask = DMA_BIT_MASK(32);
  dma_set_coherent_mask(pdev-dev, *pdev-dev.dma_mask);
  }
  +
  +   if (usbmisc_ops  usbmisc_ops-init) {
  +   ret = usbmisc_ops-init(pdev-dev);
  +   if (ret) {
  +   dev_err(pdev-dev,
  +   usbmisc init failed, ret=%d\n, ret);
  +   return ret;
  +   }
  +   }
  +
  plat_ci

[PATCH v3 0/3] imx: add usbmisc support

2012-07-26 Thread Richard Zhao
usbmisc driver handles the SoC specific non-core usb registers.

Changes since last version:
 - build usbmisc drivers into ci13xxx-imx module if it's chosen.
 - interprete properties in common code
 - check wether usbmisc_ops is null
 - dts: enable usbmisc device by default
 - take clk changes as a seperate patch

Richard Zhao (3):
  USB: chipidea: add imx usbmisc support
  ARM: dts: imx6q-sabrelite: add usbmisc device
  ARM: imx6q: clk_register_clkdev usbmisc clock

 .../devicetree/bindings/usb/ci13xxx-imx.txt|2 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   12 ++
 arch/arm/boot/dts/imx6q-sabrelite.dts  |1 +
 arch/arm/boot/dts/imx6q.dtsi   |   18 ++-
 arch/arm/mach-imx/clk-imx6q.c  |1 +
 drivers/usb/chipidea/Makefile  |3 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   72 -
 drivers/usb/chipidea/usbmisc_imx6q.c   |  155 
 8 files changed, 258 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

-- 
1.7.9.5


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


[PATCH v3 1/3] USB: chipidea: add imx usbmisc support

2012-07-26 Thread Richard Zhao
i.MX usb controllers shares non-core registers, which may include
SoC specific controls. We take it as a usbmisc device and usbmisc
driver set operations needed by ci13xxx_imx driver.

For example, Sabrelite board has bad over-current design, we can
usbmisc to disable over-current detect.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|2 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   12 ++
 drivers/usb/chipidea/Makefile  |3 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   72 -
 drivers/usb/chipidea/usbmisc_imx6q.c   |  155 
 5 files changed, 242 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 2c29041..06105ce 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -8,6 +8,7 @@ Required properties:
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
 - vbus-supply: regulator for vbus
+- disable-over-current: disable over current detect
 
 Examples:
 usb@02184000 { /* USB OTG */
@@ -15,4 +16,5 @@ usb@02184000 { /* USB OTG */
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
+   disable-over-current;
 };
diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
new file mode 100644
index 000..4fa500d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
@@ -0,0 +1,12 @@
+* Freescale i.MX non-core registers
+
+Required properties:
+- compatible: Should be one of below:
+   fsl,imx6q-usbmisc for imx6q
+- reg: Should contain registers location and length
+
+Examples:
+usbmisc@02184800 {
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+};
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 5c66d9c..36f94c9d 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -15,5 +15,6 @@ ifneq ($(CONFIG_PCI),)
 endif
 
 ifneq ($(CONFIG_OF_DEVICE),)
-   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
+   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx-imx.o
+   ci13xxx-imx-y   := ci13xxx_imx.o usbmisc_imx6q.o
 endif
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index ef60d06..d178889 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -22,6 +22,7 @@
 #include linux/regulator/consumer.h
 
 #include ci.h
+#include ci13xxx_imx.h
 
 #define pdev_to_phy(pdev) \
((struct usb_phy *)platform_get_drvdata(pdev))
@@ -34,6 +35,48 @@ struct ci13xxx_imx_data {
struct regulator *reg_vbus;
 };
 
+static const struct usbmisc_ops *usbmisc_ops;
+
+/* Common functions shared by usbmisc drivers */
+
+int usbmisc_set_ops(const struct usbmisc_ops *ops)
+{
+   if (usbmisc_ops)
+   return -EBUSY;
+
+   usbmisc_ops = ops;
+
+   return 0;
+}
+
+void usbmisc_unset_ops(const struct usbmisc_ops *ops)
+{
+   usbmisc_ops = NULL;
+}
+
+int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device 
*usbdev)
+{
+   struct device_node *np = dev-of_node;
+   int id;
+
+   usbdev-dev = dev;
+
+   id = of_alias_get_id(np, usb);
+   if (id  0) {
+   dev_err(dev, Failed to get alias id, errno %d\n, id);
+   memset(usbdev, 0, sizeof(*usbdev));
+   return id;
+   }
+   usbdev-index = id;
+
+   if (of_find_property(np, disable-over-current, NULL))
+   usbdev-disable_oc = 1;
+
+   return 0;
+}
+
+/* End of common functions shared by usbmisc drivers*/
+
 static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata  = {
.name   = ci13xxx_imx,
.flags  = CI13XXX_REQUIRE_TRANSCEIVER |
@@ -120,6 +163,16 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
*pdev-dev.dma_mask = DMA_BIT_MASK(32);
dma_set_coherent_mask(pdev-dev, *pdev-dev.dma_mask);
}
+
+   if (usbmisc_ops  usbmisc_ops-init) {
+   ret = usbmisc_ops-init(pdev-dev);
+   if (ret) {
+   dev_err(pdev-dev,
+   usbmisc init failed, ret=%d\n, ret);
+   return ret;
+   }
+   }
+
plat_ci = ci13xxx_add_device(pdev-dev,
pdev-resource, pdev-num_resources,
ci13xxx_imx_platdata);
@@ -189,7 +242,24 @@ static struct platform_driver ci13xxx_imx_driver

Re: [PATCH v2 1/2] USB: chipidea: add imx usbmisc support

2012-07-23 Thread Richard Zhao
On Mon, Jul 23, 2012 at 02:21:06PM +0300, Felipe Balbi wrote:
 On Mon, Jul 23, 2012 at 07:13:52PM +0800, Richard Zhao wrote:
  On Mon, Jul 23, 2012 at 01:51:55PM +0300, Felipe Balbi wrote:
   On Mon, Jul 23, 2012 at 11:30:18AM +0200, Marc Kleine-Budde wrote:
On 07/23/2012 11:27 AM, Richard Zhao wrote:
 This patch looks like a recipe for disaster IMHO, but it's Alex's 
 call.
 Well, if there's any better place to hold it, I'd like to move there.
 Another place is arch/arm/mach-imx. Sascha/Shawn who are maintainers 
 of
 imx are also in cc list.

IMHO it's not about the place where the driver is located, it's about
the shortcomings Michael and Sascha mentioned.
  Thanks, Marc.
   
   exactly. It's not about where a file is placed or how it's called. It's
   how you decided to implement it. This will prevent a platform with
   multiple instances of the IP to be used, at least.
  To me, usbmisc on imx6 is just a set of non-core registers which is
  companion of Chipidea IP cores. All cores share the same usbmisc.
  From design perspective, ci13xxx_imx knows nothing about usbmisc. It
  just call the ops in proper occasion. usbmisc driver wrappers all
  SoC specific things.
 
 but if all you need is to call and initialization function, why don't
 you just do it on probe() of that usbmisc stuff ? Is this usbmisc used
 only for this USB IP ?
If it only need to init once, it may follow that way. But it also have
remote wakeup enable/disable bits, which in Freescale internal driver,
are set enabled or disabled at runtime.

Thanks
Richard
 
 -- 
 balbi



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


[PATCH v2 1/2] USB: chipidea: add imx usbmisc support

2012-07-18 Thread Richard Zhao
i.MX usb controllers shares non-core registers, which may include
SoC specific controls. We take it as a usbmisc device and usbmisc
driver set operations needed by ci13xxx_imx driver.

For example, Sabrelite board has bad over-current design, we can
usbmisc to disable over-current detect.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|2 +
 .../devicetree/bindings/usb/usbmisc-imx.txt|   12 ++
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci13xxx_imx.c |   23 +++
 drivers/usb/chipidea/usbmisc_imx6q.c   |  161 
 5 files changed, 199 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/usbmisc_imx6q.c

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
index 2c29041..06105ce 100644
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
@@ -8,6 +8,7 @@ Required properties:
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
 - vbus-supply: regulator for vbus
+- disable-over-current: disable over current detect
 
 Examples:
 usb@02184000 { /* USB OTG */
@@ -15,4 +16,5 @@ usb@02184000 { /* USB OTG */
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
+   disable-over-current;
 };
diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
new file mode 100644
index 000..4fa500d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
@@ -0,0 +1,12 @@
+* Freescale i.MX non-core registers
+
+Required properties:
+- compatible: Should be one of below:
+   fsl,imx6q-usbmisc for imx6q
+- reg: Should contain registers location and length
+
+Examples:
+usbmisc@02184800 {
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+};
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 5c66d9c..57e510f 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -15,5 +15,5 @@ ifneq ($(CONFIG_PCI),)
 endif
 
 ifneq ($(CONFIG_OF_DEVICE),)
-   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
+   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o usbmisc_imx6q.o
 endif
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index ef60d06..e790c0e 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -22,6 +22,7 @@
 #include linux/regulator/consumer.h
 
 #include ci.h
+#include ci13xxx_imx.h
 
 #define pdev_to_phy(pdev) \
((struct usb_phy *)platform_get_drvdata(pdev))
@@ -34,6 +35,25 @@ struct ci13xxx_imx_data {
struct regulator *reg_vbus;
 };
 
+static const struct usbmisc_ops *usbmisc_ops;
+
+int usbmisc_set_ops(const struct usbmisc_ops *ops)
+{
+   if (usbmisc_ops)
+   return -EBUSY;
+
+   usbmisc_ops = ops;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usbmisc_set_ops);
+
+void usbmisc_unset_ops(const struct usbmisc_ops *ops)
+{
+   usbmisc_ops = NULL;
+}
+EXPORT_SYMBOL_GPL(usbmisc_unset_ops);
+
 static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata  = {
.name   = ci13xxx_imx,
.flags  = CI13XXX_REQUIRE_TRANSCEIVER |
@@ -120,6 +140,9 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
*pdev-dev.dma_mask = DMA_BIT_MASK(32);
dma_set_coherent_mask(pdev-dev, *pdev-dev.dma_mask);
}
+
+   usbmisc_ops-init(pdev-dev);
+
plat_ci = ci13xxx_add_device(pdev-dev,
pdev-resource, pdev-num_resources,
ci13xxx_imx_platdata);
diff --git a/drivers/usb/chipidea/usbmisc_imx6q.c 
b/drivers/usb/chipidea/usbmisc_imx6q.c
new file mode 100644
index 000..9f69a8c
--- /dev/null
+++ b/drivers/usb/chipidea/usbmisc_imx6q.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include linux/module.h
+#include linux/of_platform.h
+#include linux/clk.h
+#include linux/err.h
+#include linux/io.h
+
+#include ci13xxx_imx.h
+
+#define USB_DEV_MAX 4
+
+#define BM_OVER_CUR_DISBIT(7)
+
+struct imx6q_usbmisc {
+   void __iomem *base;
+   struct clk *clk;
+   struct device *usb_dev[USB_DEV_MAX];
+   spinlock_t lock;
+
+   int disable_oc:USB_DEV_MAX;
+};
+
+static struct imx6q_usbmisc

Re: [PATCH v2 1/2] USB: chipidea: add imx usbmisc support

2012-07-18 Thread Richard Zhao
[snip]
static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata  
   = {
 .name   = ci13xxx_imx,
 .flags  = CI13XXX_REQUIRE_TRANSCEIVER |
   @@ -120,6 +140,9 @@ static int __devinit ci13xxx_imx_probe(struct 
   platform_device *pdev)
 *pdev-dev.dma_mask = DMA_BIT_MASK(32);
 dma_set_coherent_mask(pdev-dev, *pdev-dev.dma_mask);
 }
   +
   + usbmisc_ops-init(pdev-dev);
  
  usbmisc_ops can be NULL and also can return an error.
 Yes. And I find it can not work when usbmisc is module.
It's hard to resolve module dependency. How about build all imx related
things into a single module? ci13xxx_imx module init will call
usbmisc_imx6q_drv_init, usbmisc_imx53_drv_init etc.

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


Re: [PATCH 00/12] chipidea/imx: add otg support and some bug fix

2012-07-18 Thread Richard Zhao
On Mon, Jul 16, 2012 at 05:40:57PM -0700, Greg KH wrote:
 On Thu, Jul 12, 2012 at 03:01:40PM +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
  
  It's better apply after patch I sent out:
  usb: chipidea: cleanup dma_pool if udc_start() fails
 
 I need acks from Alexander before I can accept any of these.
ping Alexander ...
 
 thanks,
 
 greg k-h
 

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


Re: [Patch v5 08/13] ARM: imx6q: add config-on-boot gpios

2012-07-18 Thread Richard Zhao
On Tue, Jul 17, 2012 at 02:30:17PM +0200, Dirk Behme wrote:
 On 13.06.2012 14:34, Richard Zhao wrote:
 Sometimes, boards have gpios that don't own by any driver or owner
 by a generic driver that don't like hacks. Such gpios is normally
 output and need setup once on boot. So I introduce the config-on-boot
 gpios.
 
 Signed-off-by: Richard Zhao richard.z...@freescale.com
 Cc: Shawn Guo shawn@linaro.org
 Cc: Rob Herring rob.herr...@calxeda.com
 Cc: Grant Likely grant.lik...@secretlab.ca
 ---
  .../devicetree/bindings/arm/config-on-boot.txt |   12 +++
  arch/arm/boot/dts/imx6q-sabrelite.dts  |7 
  arch/arm/mach-imx/mach-imx6q.c |   35 
  
  3 files changed, 54 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/arm/config-on-boot.txt
 
 diff --git a/Documentation/devicetree/bindings/arm/config-on-boot.txt 
 b/Documentation/devicetree/bindings/arm/config-on-boot.txt
 new file mode 100644
 index 000..f98ed74
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/arm/config-on-boot.txt
 @@ -0,0 +1,12 @@
 +* Configure on Boot
 +
 +Node name: config-on-boot
 +  It must be in root node. config-on-boot means to describe settings that 
 needs
 +  to be set one time on boot but aren't owned by any driver, or the owned 
 driver
 +  is too generic to handle such settings. For example, usb hub uses generic
 +  driver in usb core code, a on-board usb may need deassert reset pin.
 +
 +Optional properties:
 +- output-gpios: Output gpio array that needs to set.
 +- output-gpio-values: This property is required if output-gpios is set.
 +  The value is a array of 0 or 1. Total count eaquals the number of gpios.
 diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
 b/arch/arm/boot/dts/imx6q-sabrelite.dts
 index e0ec929..1dd2261 100644
 --- a/arch/arm/boot/dts/imx6q-sabrelite.dts
 +++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
 @@ -17,6 +17,13 @@
  model = Freescale i.MX6 Quad SABRE Lite Board;
  compatible = fsl,imx6q-sabrelite, fsl,imx6q;
 +config-on-boot {
 +output-gpios = 
 +gpio3 22 0;   /* vbus reset */
 +output-gpio-values = 
 +1; /* vbus reset */
 +};
 +
  memory {
  reg = 0x1000 0x4000;
  };
 diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
 index b47e98b..577cf19 100644
 --- a/arch/arm/mach-imx/mach-imx6q.c
 +++ b/arch/arm/mach-imx/mach-imx6q.c
 @@ -19,6 +19,7 @@
  #include linux/irqdomain.h
  #include linux/of.h
  #include linux/of_address.h
 +#include linux/of_gpio.h
  #include linux/of_irq.h
  #include linux/of_platform.h
  #include linux/pinctrl/machine.h
 @@ -113,6 +114,38 @@ static void __init imx6q_sabrelite_init(void)
  imx6q_sabrelite_cko1_setup();
  }
 +static void __init imx6q_config_on_boot(void)
 +{
 +struct device_node *np;
 +struct property *pp;
 +int cnt, len, i;
 +int gpio;
 +
 +np = of_find_node_by_path(/config-on-boot);
 +if (!np)
 +return;
 +cnt = of_gpio_named_count(np, output-gpios);
 +pp = of_find_property(np, output-gpio-values, len);
 +if (!pp || cnt != len / sizeof(u32)) {
 +pr_err(Invalid config-on-boot gpios!\n);
 +of_node_put(np);
 +return;
 +}
 +for (i = 0; i  cnt; i++) {
 +gpio = of_get_named_gpio(np, output-gpios, i);
 +if (gpio_is_valid(gpio))
 +gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH,
 +config-on-boot);
 
 While trying to use this code: Is there a special reason why all
 pins are set to HIGH here? The contents of 'output-gpio-values' seem
 to be ignored?
It may be bug here. The patch is rejected. imx6_sabrelite happens work
by default value. So I won't follow it any more.

Thanks
Richard
 
 Best regards
 
 Dirk
 

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


Re: [PATCH 12/12] USB: chipidea: add imx usbmisc support

2012-07-16 Thread Richard Zhao
On Mon, Jul 16, 2012 at 10:25:20AM +0200, Sascha Hauer wrote:
 On Thu, Jul 12, 2012 at 03:01:52PM +0800, Richard Zhao wrote:
  i.MX usb controllers shares non-core registers, which may include
  SoC specific controls. We take it as a usbmisc device and usbmisc
  driver export functions needed by ci13xxx_imx driver.
  
  For example, Sabrelite board has bad over-current design, we can
  usbmisc to disable over-current detect.
  
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   .../devicetree/bindings/usb/imx-usbmisc.txt|   15 ++
   drivers/usb/chipidea/Makefile  |2 +-
   drivers/usb/chipidea/ci13xxx_imx.c |4 +
   drivers/usb/chipidea/imx_usbmisc.c |  144 
  
   4 files changed, 164 insertions(+), 1 deletion(-)
   create mode 100644 Documentation/devicetree/bindings/usb/imx-usbmisc.txt
   create mode 100644 drivers/usb/chipidea/imx_usbmisc.c
  
  diff --git a/Documentation/devicetree/bindings/usb/imx-usbmisc.txt 
  b/Documentation/devicetree/bindings/usb/imx-usbmisc.txt
  new file mode 100644
  index 000..09f01ca
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/usb/imx-usbmisc.txt
  @@ -0,0 +1,15 @@
  +* Freescale i.MX non-core registers
  +
  +Required properties:
  +- compatible: Should be fsl,imx6q-usbmisc
  +- reg: Should contain registers location and length
  +
  +Optional properties:
  +- fsl,disable-over-current: disable over current detect
  +
  +Examples:
  +usbmisc@02184800 {
  +   compatible = fsl,imx6q-usbmisc;
  +   reg = 0x02184800 0x200;
  +   fsl,disable-over-current;
  +};
  diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
  index 3f56b76..46fc31c 100644
  --- a/drivers/usb/chipidea/Makefile
  +++ b/drivers/usb/chipidea/Makefile
  @@ -17,5 +17,5 @@ ifneq ($(CONFIG_PCI),)
   endif
   
   ifneq ($(CONFIG_OF_DEVICE),)
  -   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
  +   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o imx_usbmisc.o
   endif
  diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
  b/drivers/usb/chipidea/ci13xxx_imx.c
  index b3173d8..dd7f3a3 100644
  --- a/drivers/usb/chipidea/ci13xxx_imx.c
  +++ b/drivers/usb/chipidea/ci13xxx_imx.c
  @@ -24,6 +24,8 @@
   
   #include ci.h
   
  +int imx_usbmisc_init(struct device *usbdev);
  +
   #define pdev_to_phy(pdev) \
  ((struct usb_phy *)platform_get_drvdata(pdev))
   #define ci_to_imx_data(ci) \
  @@ -142,6 +144,8 @@ static int __devinit ci13xxx_imx_probe(struct 
  platform_device *pdev)
  dma_set_coherent_mask(pdev-dev, *pdev-dev.dma_mask);
  }
   
  +   imx_usbmisc_init(pdev-dev);
  +
  platform_set_drvdata(pdev, data);
   
  plat_ci = ci13xxx_add_device(pdev-dev,
  diff --git a/drivers/usb/chipidea/imx_usbmisc.c 
  b/drivers/usb/chipidea/imx_usbmisc.c
  new file mode 100644
  index 000..33a8ec0
  --- /dev/null
  +++ b/drivers/usb/chipidea/imx_usbmisc.c
  @@ -0,0 +1,144 @@
  +/*
  + * Copyright 2012 Freescale Semiconductor, Inc.
  + *
  + * The code contained herein is licensed under the GNU General Public
  + * License. You may obtain a copy of the GNU General Public License
  + * Version 2 or later at the following locations:
  + *
  + * http://www.opensource.org/licenses/gpl-license.html
  + * http://www.gnu.org/copyleft/gpl.html
  + */
  +
  +#include linux/module.h
  +#include linux/of_platform.h
  +#include linux/clk.h
  +#include linux/err.h
  +#include asm/io.h
 
 linux/io.h
 
  +
  +struct usbmisc;
  +
  +struct soc_data {
  +   int (*init) (struct usbmisc *usbmisc, int id);
  +   void (*exit) (struct usbmisc *usbmisc, int id);
  +};
  +
  +struct usbmisc {
  +   struct soc_data *soc_data;
  +   void __iomem *base;
  +   struct clk *clk;
  +
  +   int dis_oc:1;
  +};
  +
  +/* Since we only have one usbmisc device at runtime, we global variables */
  +static struct usbmisc *usbmisc;
 
 NACK
Right, it's a bad design. I'm considering change it too. Maybe I will
move it out this patch series. As I asked you in another mail in this
thread, do you think it's good to put it here or in mach-imx/ ?
 
 What you've done here exactly matches your current usecase but is not
 enough for any of the other usecases I can think of. Even the i.MX6 has
 three USB ports, each of them has a overcurrent disable bit. Also, there
 are more flags, like:
Yes, I'll change it to support different usb with different properties.
 
 - use internal phy
 - power pin polarity
 - ttl enabled
I focus on imx6 now. So I think the property can be added when it's
needed. Now I only use disable oc.
 
 I think the best you can do here is to add the flags to the
 fsl,imx6q-usb device nodes:
 
   usb@02184000 { /* USB OTG */
   compatible = fsl,imx6q-usb, fsl,imx27-usb;
   reg = 0x02184000 0x200;
   interrupts = 0 43 0x04;
   fsl,usbphy = usbphy1;
   status = disabled;
   fsl,disable-over-current

Re: [PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails

2012-07-16 Thread Richard Zhao
Hi Alex,

Could you please also review  ack this patch?

Thanks
Richard 

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


Re: [PATCH 12/12] USB: chipidea: add imx usbmisc support

2012-07-13 Thread Richard Zhao
On Fri, Jul 13, 2012 at 02:25:45PM +0200, Michael Grzeschik wrote:
 On Thu, Jul 12, 2012 at 03:01:52PM +0800, Richard Zhao wrote:
  i.MX usb controllers shares non-core registers, which may include
  SoC specific controls. We take it as a usbmisc device and usbmisc
  driver export functions needed by ci13xxx_imx driver.
 
 So this is SoC and not chipidea specific and should not be sorted into
 this subdir.
Yes, but it's usb specific and serve chipidea usb IP.
 
  For example, Sabrelite board has bad over-current design, we can
  usbmisc to disable over-current detect.
 
 This driver layout is also reflected in:
 
 arch/arm/mach-imx/ehci-imx*.c
It sounds sensible, but I'm not quite sure. I saw drivers are moving
out of there, event it's SoC specific, for example, clk, pinmux. And
the non-core registers might not only be setup onetime on boot, but
be called at runtime by usb driver. For now, it's set once.
 
 You should use these existing mx*_initialize_usb_hw functions to avoid
 code duplication
I can not see what duplication it can avoid.
 and add your mx6_initialize_usb_hw routine for mx6 there.
Maybe.
 
 This devicetree based glue code in this file can be reused to
 call the right mx*_initialize_usb_hw by the compatible.
The glue code makes it more like a normal driver. Doesn't it?
 
 We already have common flags available like i.e. MXC_EHCI_POWER_PINS_ENABLED
 which is currently used to disable overcurrent detection.
The flags may be replace with properties in DT bindings.
 
 
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   .../devicetree/bindings/usb/imx-usbmisc.txt|   15 ++
   drivers/usb/chipidea/Makefile  |2 +-
   drivers/usb/chipidea/ci13xxx_imx.c |4 +
   drivers/usb/chipidea/imx_usbmisc.c |  144 
  
   4 files changed, 164 insertions(+), 1 deletion(-)
   create mode 100644 Documentation/devicetree/bindings/usb/imx-usbmisc.txt
   create mode 100644 drivers/usb/chipidea/imx_usbmisc.c
  
  diff --git a/Documentation/devicetree/bindings/usb/imx-usbmisc.txt 
  b/Documentation/devicetree/bindings/usb/imx-usbmisc.txt
  new file mode 100644
  index 000..09f01ca
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/usb/imx-usbmisc.txt
  @@ -0,0 +1,15 @@
  +* Freescale i.MX non-core registers
  +
  +Required properties:
  +- compatible: Should be fsl,imx6q-usbmisc
  +- reg: Should contain registers location and length
  +
  +Optional properties:
  +- fsl,disable-over-current: disable over current detect
  +
  +Examples:
  +usbmisc@02184800 {
  +   compatible = fsl,imx6q-usbmisc;
  +   reg = 0x02184800 0x200;
  +   fsl,disable-over-current;
  +};
  diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
  index 3f56b76..46fc31c 100644
  --- a/drivers/usb/chipidea/Makefile
  +++ b/drivers/usb/chipidea/Makefile
  @@ -17,5 +17,5 @@ ifneq ($(CONFIG_PCI),)
   endif
   
   ifneq ($(CONFIG_OF_DEVICE),)
  -   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
  +   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o imx_usbmisc.o
   endif
  diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
  b/drivers/usb/chipidea/ci13xxx_imx.c
  index b3173d8..dd7f3a3 100644
  --- a/drivers/usb/chipidea/ci13xxx_imx.c
  +++ b/drivers/usb/chipidea/ci13xxx_imx.c
  @@ -24,6 +24,8 @@
   
   #include ci.h
   
  +int imx_usbmisc_init(struct device *usbdev);
  +
   #define pdev_to_phy(pdev) \
  ((struct usb_phy *)platform_get_drvdata(pdev))
   #define ci_to_imx_data(ci) \
  @@ -142,6 +144,8 @@ static int __devinit ci13xxx_imx_probe(struct 
  platform_device *pdev)
  dma_set_coherent_mask(pdev-dev, *pdev-dev.dma_mask);
  }
   
  +   imx_usbmisc_init(pdev-dev);
  +
  platform_set_drvdata(pdev, data);
   
  plat_ci = ci13xxx_add_device(pdev-dev,
  diff --git a/drivers/usb/chipidea/imx_usbmisc.c 
  b/drivers/usb/chipidea/imx_usbmisc.c
  new file mode 100644
  index 000..33a8ec0
  --- /dev/null
  +++ b/drivers/usb/chipidea/imx_usbmisc.c
  @@ -0,0 +1,144 @@
  +/*
  + * Copyright 2012 Freescale Semiconductor, Inc.
  + *
  + * The code contained herein is licensed under the GNU General Public
  + * License. You may obtain a copy of the GNU General Public License
  + * Version 2 or later at the following locations:
  + *
  + * http://www.opensource.org/licenses/gpl-license.html
  + * http://www.gnu.org/copyleft/gpl.html
  + */
  +
  +#include linux/module.h
  +#include linux/of_platform.h
  +#include linux/clk.h
  +#include linux/err.h
  +#include asm/io.h
  +
  +struct usbmisc;
  +
  +struct soc_data {
  +   int (*init) (struct usbmisc *usbmisc, int id);
  +   void (*exit) (struct usbmisc *usbmisc, int id);
  +};
  +
  +struct usbmisc {
  +   struct soc_data *soc_data;
  +   void __iomem *base;
  +   struct clk *clk;
  +
  +   int dis_oc:1;
  +};
  +
  +/* Since we only have one usbmisc device at runtime, we global variables */
  +static struct usbmisc *usbmisc;
 
 Global variable?
Yes. we

[PATCH 01/12] USB: chipidea: imx: add pinctrl support

2012-07-12 Thread Richard Zhao
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.z...@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 ef60d06..c94e30f 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
 
@@ -49,6 +50,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;
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
@@ -63,6 +65,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


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


[PATCH 03/12] USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq handler

2012-07-12 Thread Richard Zhao
OTGSC_IDIS must be cleared in irq handler to avoid re-queue the work.

Signed-off-by: Richard Zhao richard.z...@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


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


[PATCH 04/12] USB: chipidea: clear gadget struct at udc_start fail path

2012-07-12 Thread Richard Zhao
States in gadget are not needed any more, set it to zero.

Signed-off-by: Richard Zhao richard.z...@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 9029985..fd27f4d 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1759,6 +1759,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


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


[PATCH 05/12] USB: chipidea: don't let probe fail if otg controller start one role failed

2012-07-12 Thread Richard Zhao
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.z...@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


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


[PATCH 07/12] USB: chipidea: add vbus detect for udc

2012-07-12 Thread Richard Zhao
Using vbus valid interrupt to detect vbus.

Signed-off-by: Richard Zhao richard.z...@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_rolerole;
boolis_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 fd27f4d..0b18191 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);
@@ -1528,8 +1551,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;
@@ -1635,6 +1660,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;
@@ -1710,6 +1742,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);
@@ -1773,6 +1806,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);
 
destroy_eps(ci);
@@ -1813,6 +1849,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


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


[PATCH 02/12] USB: chipidea: delay 2ms before read ID status at probe time

2012-07-12 Thread Richard Zhao
The ID pin needs 1ms debounce time, event at probe time. We delay 2ms
for safe.

Signed-off-by: Richard Zhao richard.z...@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


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


[PATCH 08/12] USB: chipidea: convert to use devm_request_irq

2012-07-12 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@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


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


[PATCH 09/12] USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG

2012-07-12 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@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 5c66d9c..3f56b76 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


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


[PATCH 10/12] USB: chipidea: add set_vbus_power support

2012-07-12 Thread Richard Zhao
set_vbus_power is used to enable or disable vbus power for usb host.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 drivers/usb/chipidea/ci13xxx_imx.c |   39 +---
 drivers/usb/chipidea/host.c|8 
 include/linux/usb/chipidea.h   |2 ++
 3 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index c94e30f..b3173d8 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -26,6 +26,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;
@@ -35,12 +37,32 @@ struct ci13xxx_imx_data {
struct regulator *reg_vbus;
 };
 
+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)
@@ -101,18 +123,10 @@ 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;
 
@@ -127,6 +141,9 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
*pdev-dev.dma_mask = DMA_BIT_MASK(32);
dma_set_coherent_mask(pdev-dev, *pdev-dev.dma_mask);
}
+
+   platform_set_drvdata(pdev, data);
+
plat_ci = ci13xxx_add_device(pdev-dev,
pdev-resource, pdev-num_resources,
ci13xxx_imx_platdata);
@@ -139,7 +156,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);
@@ -149,7 +165,6 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
 err:
if (reg_vbus)
regulator_disable(reg_vbus);
-put_np:
if (phy_np)
of_node_put(phy_np);
clk_disable_unprepare(data-clk);
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

[PATCH 12/12] USB: chipidea: add imx usbmisc support

2012-07-12 Thread Richard Zhao
i.MX usb controllers shares non-core registers, which may include
SoC specific controls. We take it as a usbmisc device and usbmisc
driver export functions needed by ci13xxx_imx driver.

For example, Sabrelite board has bad over-current design, we can
usbmisc to disable over-current detect.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 .../devicetree/bindings/usb/imx-usbmisc.txt|   15 ++
 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/ci13xxx_imx.c |4 +
 drivers/usb/chipidea/imx_usbmisc.c |  144 
 4 files changed, 164 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/imx-usbmisc.txt
 create mode 100644 drivers/usb/chipidea/imx_usbmisc.c

diff --git a/Documentation/devicetree/bindings/usb/imx-usbmisc.txt 
b/Documentation/devicetree/bindings/usb/imx-usbmisc.txt
new file mode 100644
index 000..09f01ca
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/imx-usbmisc.txt
@@ -0,0 +1,15 @@
+* Freescale i.MX non-core registers
+
+Required properties:
+- compatible: Should be fsl,imx6q-usbmisc
+- reg: Should contain registers location and length
+
+Optional properties:
+- fsl,disable-over-current: disable over current detect
+
+Examples:
+usbmisc@02184800 {
+   compatible = fsl,imx6q-usbmisc;
+   reg = 0x02184800 0x200;
+   fsl,disable-over-current;
+};
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 3f56b76..46fc31c 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -17,5 +17,5 @@ ifneq ($(CONFIG_PCI),)
 endif
 
 ifneq ($(CONFIG_OF_DEVICE),)
-   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o
+   obj-$(CONFIG_USB_CHIPIDEA)  += ci13xxx_imx.o imx_usbmisc.o
 endif
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index b3173d8..dd7f3a3 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -24,6 +24,8 @@
 
 #include ci.h
 
+int imx_usbmisc_init(struct device *usbdev);
+
 #define pdev_to_phy(pdev) \
((struct usb_phy *)platform_get_drvdata(pdev))
 #define ci_to_imx_data(ci) \
@@ -142,6 +144,8 @@ static int __devinit ci13xxx_imx_probe(struct 
platform_device *pdev)
dma_set_coherent_mask(pdev-dev, *pdev-dev.dma_mask);
}
 
+   imx_usbmisc_init(pdev-dev);
+
platform_set_drvdata(pdev, data);
 
plat_ci = ci13xxx_add_device(pdev-dev,
diff --git a/drivers/usb/chipidea/imx_usbmisc.c 
b/drivers/usb/chipidea/imx_usbmisc.c
new file mode 100644
index 000..33a8ec0
--- /dev/null
+++ b/drivers/usb/chipidea/imx_usbmisc.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include linux/module.h
+#include linux/of_platform.h
+#include linux/clk.h
+#include linux/err.h
+#include asm/io.h
+
+struct usbmisc;
+
+struct soc_data {
+   int (*init) (struct usbmisc *usbmisc, int id);
+   void (*exit) (struct usbmisc *usbmisc, int id);
+};
+
+struct usbmisc {
+   struct soc_data *soc_data;
+   void __iomem *base;
+   struct clk *clk;
+
+   int dis_oc:1;
+};
+
+/* Since we only have one usbmisc device at runtime, we global variables */
+static struct usbmisc *usbmisc;
+
+static int imx6q_usbmisc_init(struct usbmisc *usbmisc, int id)
+{
+   u32 reg;
+
+   if (usbmisc-dis_oc) {
+   reg = readl_relaxed(usbmisc-base + id * 4);
+   writel_relaxed(reg | (1  7), usbmisc-base + id * 4);
+   }
+
+   return 0;
+}
+
+static struct soc_data imx6q_data = {
+   .init = imx6q_usbmisc_init,
+};
+
+
+static const struct of_device_id imx_usbmisc_dt_ids[] = {
+   { .compatible = fsl,imx6q-usbmisc, .data = imx6q_data },
+   { /* sentinel */ }
+};
+
+static int __devinit imx_usbmisc_probe(struct platform_device *pdev)
+{
+   struct resource *res;
+   struct usbmisc *data;
+   const struct of_device_id *of_id =
+   of_match_device(imx_usbmisc_dt_ids, pdev-dev);
+
+   int ret;
+
+   if (usbmisc)
+   return -EBUSY;
+
+   data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
+   if (!data)
+   return -ENOMEM;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   data-base = devm_request_and_ioremap(pdev-dev, res);
+   if (!data-base)
+   return -EADDRNOTAVAIL;
+
+   data-clk = devm_clk_get(pdev-dev, NULL);
+   if (IS_ERR(data-clk)) {
+   dev_err(pdev-dev,
+   failed to get clock, err=%ld\n, PTR_ERR(data-clk));
+   return PTR_ERR(data-clk

Re: [PATCH 12/12] USB: chipidea: add imx usbmisc support

2012-07-12 Thread Richard Zhao
[snip]
 --- /dev/null
 +++ b/drivers/usb/chipidea/imx_usbmisc.c
 @@ -0,0 +1,144 @@
 +/*
 + * Copyright 2012 Freescale Semiconductor, Inc.
 + *
 + * The code contained herein is licensed under the GNU General Public
 + * License. You may obtain a copy of the GNU General Public License
 + * Version 2 or later at the following locations:
 + *
 + * http://www.opensource.org/licenses/gpl-license.html
 + * http://www.gnu.org/copyleft/gpl.html
 + */
 +
 +#include linux/module.h
 +#include linux/of_platform.h
 +#include linux/clk.h
 +#include linux/err.h
 +#include asm/io.h
It should be linux/io.h
 
Thanks
Richard

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


[PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails

2012-07-11 Thread Richard Zhao
From: Marc Kleine-Budde m...@pengutronix.de

If udc_start() fails the qh_pool dma-pool cannot be closed because
it's still in use. This patch factors out the dma_pool_free() loop
into destroy_eps() and calls it in the error path of udc_start(),
too.

Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 drivers/usb/chipidea/udc.c |   23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c7a032a..9029985 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1484,6 +1484,17 @@ static int init_eps(struct ci13xxx *ci)
return retval;
 }
 
+static void destroy_eps(struct ci13xxx *ci)
+{
+   int i;
+
+   for (i = 0; i  ci-hw_ep_max; i++) {
+   struct ci13xxx_ep *mEp = ci-ci13xxx_ep[i];
+
+   dma_pool_free(ci-qh_pool, mEp-qh.ptr, mEp-qh.dma);
+   }
+}
+
 /**
  * ci13xxx_start: register a gadget driver
  * @gadget: our gadget
@@ -1691,7 +1702,7 @@ static int udc_start(struct ci13xxx *ci)
if (ci-platdata-flags  CI13XXX_REQUIRE_TRANSCEIVER) {
if (ci-transceiver == NULL) {
retval = -ENODEV;
-   goto free_pools;
+   goto destroy_eps;
}
}
 
@@ -1742,6 +1753,8 @@ unreg_device:
 put_transceiver:
if (!IS_ERR_OR_NULL(ci-transceiver)  ci-global_phy)
usb_put_phy(ci-transceiver);
+destroy_eps:
+   destroy_eps(ci);
 free_pools:
dma_pool_destroy(ci-td_pool);
 free_qh_pool:
@@ -1756,18 +1769,12 @@ free_qh_pool:
  */
 static void udc_stop(struct ci13xxx *ci)
 {
-   int i;
-
if (ci == NULL)
return;
 
usb_del_gadget_udc(ci-gadget);
 
-   for (i = 0; i  ci-hw_ep_max; i++) {
-   struct ci13xxx_ep *mEp = ci-ci13xxx_ep[i];
-
-   dma_pool_free(ci-qh_pool, mEp-qh.ptr, mEp-qh.dma);
-   }
+   destroy_eps(ci);
 
dma_pool_destroy(ci-td_pool);
dma_pool_destroy(ci-qh_pool);
-- 
1.7.9.5


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


Re: [PATCH v9 REBASE 6/9] USB: notify phy when root hub port connect change

2012-07-10 Thread Richard Zhao
On Tue, Jul 10, 2012 at 05:22:20AM +0200, Marek Vasut wrote:
 Dear Richard Zhao,
 
  On Sat, Jul 07, 2012 at 10:56:45PM +0800, Richard Zhao wrote:
   Phy may need to change settings when port connect change.
   
   Signed-off-by: Richard Zhao richard.z...@freescale.com
   Tested-by: Subodh Nijsure snijs...@grid-net.com
   ---
   
drivers/usb/core/hub.c |8 
1 file changed, 8 insertions(+)
   
   diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
   index 4cc8dc9..2ba9d84 100644
   --- a/drivers/usb/core/hub.c
   +++ b/drivers/usb/core/hub.c
   @@ -20,6 +20,7 @@
   
#include linux/usb.h
#include linux/usbdevice_fs.h
#include linux/usb/hcd.h
   
   +#include linux/usb/otg.h
   
#include linux/usb/quirks.h
#include linux/kthread.h
#include linux/mutex.h
   
   @@ -4037,6 +4038,13 @@ static void hub_port_connect_change(struct usb_hub
   *hub, int port1,
   
 }
 
 }
   
   + if (unlikely(hcd-phy  !hdev-parent)) {
   + if (portstatus  USB_PORT_STAT_CONNECTION)
   + usb_phy_notify_connect(hcd-phy, port1);
   + else
   + usb_phy_notify_disconnect(hcd-phy, port1);
  
  There's another issue. When hcd is removed, notify disconnect is not
  called. Is it ok, if I remove the above two line and add below patch:
  
  --- a/drivers/usb/core/hub.c
  +++ b/drivers/usb/core/hub.c
  @@ -1924,6 +1924,11 @@ void usb_disconnect(struct usb_device **pdev)
   */
  device_del(udev-dev);
  
  +   if (udev-parent  !udev-parent-parent) {
  +   struct usb_hcd *hcd = bus_to_hcd(udev-bus);
  +   usb_phy_notify_disconnect(hcd-phy, udev-portnum);
  +   }
 
 Shouldn't that go before device_del() ?
Any difference?

Thanks
Richard
 
  +
  /* Free the device number and delete the parent's children[]
   * (or root_hub) pointer.
   */
  
  
  Thanks
  Richard
 
 Best regards,
 Marek Vasut
 

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


Re: [PATCH v9 REBASE 6/9] USB: notify phy when root hub port connect change

2012-07-10 Thread Richard Zhao
On Tue, Jul 10, 2012 at 10:24:07AM -0400, Alan Stern wrote:
 On Tue, 10 Jul 2012, Richard Zhao wrote:
 
@@ -4037,6 +4038,13 @@ static void hub_port_connect_change(struct 
usb_hub *hub, int port1,
}
}
 
+   if (unlikely(hcd-phy  !hdev-parent)) {
   
   Why is this unlikely?  And why mark it as such, is this a fast path
   that needs the compiler to know this hint to optimize things here?
   
   Please don't use likely() or unlikely() except in places it really is
   needed, _and_ you have measured the difference.  Have you done so in
   this place?
  It's from a comment by Alan Stern.
  http://www.spinics.net/lists/linux-usb/msg64987.html
 
 That comment was made in a somewhat different context.  At the time 
 the code was part of an interrupt handler; now it isn't.
 
  Actually, for my board, it's not unlikely. But for others which don't
  have notify_connect/disconnect, it's unlikely.
  
  Because it's not unlikely for all boards, I prefer remove unlikely.
 
 It's no longer a big deal one way or another.  I don't care about the 
 unlikely because it's on a cold path running in process context.  Go 
 ahead and remove it.
Ok. I'll remove it. 

Thanks
Richard
 
 Alan Stern
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 REBASE 6/9] USB: notify phy when root hub port connect change

2012-07-09 Thread Richard Zhao
On Mon, Jul 09, 2012 at 09:57:57AM -0700, Greg KH wrote:
 On Sat, Jul 07, 2012 at 10:56:45PM +0800, Richard Zhao wrote:
  Phy may need to change settings when port connect change.
  
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  Tested-by: Subodh Nijsure snijs...@grid-net.com
  ---
   drivers/usb/core/hub.c |8 
   1 file changed, 8 insertions(+)
  
  diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
  index 4cc8dc9..2ba9d84 100644
  --- a/drivers/usb/core/hub.c
  +++ b/drivers/usb/core/hub.c
  @@ -20,6 +20,7 @@
   #include linux/usb.h
   #include linux/usbdevice_fs.h
   #include linux/usb/hcd.h
  +#include linux/usb/otg.h
   #include linux/usb/quirks.h
   #include linux/kthread.h
   #include linux/mutex.h
  @@ -4037,6 +4038,13 @@ static void hub_port_connect_change(struct usb_hub 
  *hub, int port1,
  }
  }
   
  +   if (unlikely(hcd-phy  !hdev-parent)) {
 
 Why is this unlikely?  And why mark it as such, is this a fast path
 that needs the compiler to know this hint to optimize things here?
 
 Please don't use likely() or unlikely() except in places it really is
 needed, _and_ you have measured the difference.  Have you done so in
 this place?
It's from a comment by Alan Stern.
http://www.spinics.net/lists/linux-usb/msg64987.html

Actually, for my board, it's not unlikely. But for others which don't
have notify_connect/disconnect, it's unlikely.

Because it's not unlikely for all boards, I prefer remove unlikely.

Thanks
Richard
 
 thanks,
 
 greg k-h
 

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


Re: [PATCH v8 06/14] USB: Chipidea: rename struct ci13xxx variables from udc to ci

2012-07-07 Thread Richard Zhao
On Fri, Jul 06, 2012 at 11:07:21AM -0700, Greg KH wrote:
 On Fri, Jun 29, 2012 at 05:48:54PM +0800, Richard Zhao wrote:
  struct ci13xxx represent the controller, which may be device or host,
  so name its variables as ci.
  
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  Reviewed-by: Felipe Balbi ba...@ti.com
  Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
  Reviewed-by: Marek Vasut ma...@denx.de
 
 This patch fails to apply (the 5/14 had some fuzz, but I fixed that by
 hand.
#5 is good. Thanks.
 )  Odds are it's due to Felipe's other changes now in my tree.
 Care to rediff this, and the rest of the series against the usb-next
 branch and resend them so that I can apply them?
I'll send out v9 REBASE.

Thanks
Richard
 
 I've applied the first 5 in this series already, so you don't have to
 resend them.
 
 thanks,
 
 greg k-h
 

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


[PATCH v9 REBASE 2/9] USB: Chipidea: add unified ci13xxx_{add,remove}_device for platform drivers

2012-07-07 Thread Richard Zhao
Platform drivers do the similar things to add/remove ci13xxx device, so
create a unified one.

Signed-off-by: Richard Zhao richard.z...@freescale.com
Reviewed-by: Felipe Balbi ba...@ti.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci13xxx_msm.c |   34 ++--
 drivers/usb/chipidea/ci13xxx_pci.c |   34 +---
 drivers/usb/chipidea/core.c|   43 
 include/linux/usb/chipidea.h   |7 ++
 4 files changed, 63 insertions(+), 55 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_msm.c 
b/drivers/usb/chipidea/ci13xxx_msm.c
index 5a2fe5f..b01feb3 100644
--- a/drivers/usb/chipidea/ci13xxx_msm.c
+++ b/drivers/usb/chipidea/ci13xxx_msm.c
@@ -58,43 +58,23 @@ static struct ci13xxx_platform_data ci13xxx_msm_platdata = {
 static int __devinit ci13xxx_msm_probe(struct platform_device *pdev)
 {
struct platform_device *plat_ci;
-   int ret;
 
dev_dbg(pdev-dev, ci13xxx_msm_probe\n);
 
-   plat_ci = platform_device_alloc(ci_hdrc, -1);
-   if (!plat_ci) {
-   dev_err(pdev-dev, can't allocate ci_hdrc platform device\n);
-   return -ENOMEM;
+   plat_ci = ci13xxx_add_device(pdev-dev,
+   pdev-resource, pdev-num_resources,
+   ci13xxx_msm_platdata);
+   if (IS_ERR(plat_ci)) {
+   dev_err(pdev-dev, ci13xxx_add_device failed!\n);
+   return PTR_ERR(plat_ci);
}
 
-   ret = platform_device_add_resources(plat_ci, pdev-resource,
-   pdev-num_resources);
-   if (ret) {
-   dev_err(pdev-dev, can't add resources to platform device\n);
-   goto put_platform;
-   }
-
-   ret = platform_device_add_data(plat_ci, ci13xxx_msm_platdata,
-  sizeof(ci13xxx_msm_platdata));
-   if (ret)
-   goto put_platform;
-
-   ret = platform_device_add(plat_ci);
-   if (ret)
-   goto put_platform;
-
platform_set_drvdata(pdev, plat_ci);
 
pm_runtime_no_callbacks(pdev-dev);
pm_runtime_enable(pdev-dev);
 
return 0;
-
-put_platform:
-   platform_device_put(plat_ci);
-
-   return ret;
 }
 
 static int __devexit ci13xxx_msm_remove(struct platform_device *pdev)
@@ -102,7 +82,7 @@ static int __devexit ci13xxx_msm_remove(struct 
platform_device *pdev)
struct platform_device *plat_ci = platform_get_drvdata(pdev);
 
pm_runtime_disable(pdev-dev);
-   platform_device_unregister(plat_ci);
+   ci13xxx_remove_device(plat_ci);
 
return 0;
 }
diff --git a/drivers/usb/chipidea/ci13xxx_pci.c 
b/drivers/usb/chipidea/ci13xxx_pci.c
index cdcac3a..918e149 100644
--- a/drivers/usb/chipidea/ci13xxx_pci.c
+++ b/drivers/usb/chipidea/ci13xxx_pci.c
@@ -75,13 +75,6 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
pci_set_master(pdev);
pci_try_set_mwi(pdev);
 
-   plat_ci = platform_device_alloc(ci_hdrc, -1);
-   if (!plat_ci) {
-   dev_err(pdev-dev, can't allocate ci_hdrc platform device\n);
-   retval = -ENOMEM;
-   goto disable_device;
-   }
-
memset(res, 0, sizeof(res));
res[0].start= pci_resource_start(pdev, 0);
res[0].end  = pci_resource_end(pdev, 0);
@@ -89,32 +82,17 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
res[1].start= pdev-irq;
res[1].flags= IORESOURCE_IRQ;
 
-   retval = platform_device_add_resources(plat_ci, res, nres);
-   if (retval) {
-   dev_err(pdev-dev, can't add resources to platform device\n);
-   goto put_platform;
+   plat_ci = ci13xxx_add_device(pdev-dev, res, nres, platdata);
+   if (IS_ERR(plat_ci)) {
+   dev_err(pdev-dev, ci13xxx_add_device failed!\n);
+   retval = PTR_ERR(plat_ci);
+   goto disable_device;
}
 
-   retval = platform_device_add_data(plat_ci, platdata, sizeof(*platdata));
-   if (retval)
-   goto put_platform;
-
-   dma_set_coherent_mask(plat_ci-dev, pdev-dev.coherent_dma_mask);
-   plat_ci-dev.dma_mask = pdev-dev.dma_mask;
-   plat_ci-dev.dma_parms = pdev-dev.dma_parms;
-   plat_ci-dev.parent = pdev-dev;
-
pci_set_drvdata(pdev, plat_ci);
 
-   retval = platform_device_add(plat_ci);
-   if (retval)
-   goto put_platform;
-
return 0;
 
- put_platform:
-   pci_set_drvdata(pdev, NULL);
-   platform_device_put(plat_ci);
  disable_device:
pci_disable_device(pdev);
  done:
@@ -133,7 +111,7 @@ static void __devexit ci13xxx_pci_remove(struct pci_dev 
*pdev)
 {
struct platform_device *plat_ci = pci_get_drvdata(pdev);
 
-   platform_device_unregister(plat_ci);
+   ci13xxx_remove_device(plat_ci

[PATCH v9 REBASE 3/9] USB: Chipidea: add ci13xxx device id management

2012-07-07 Thread Richard Zhao
We use ida_simple_get and ida_simple_remove to manage the ids.

Signed-off-by: Richard Zhao richard.z...@freescale.com
Reviewed-by: Felipe Balbi ba...@ti.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/core.c |   21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 8b9d06f..39603d7 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -56,6 +56,7 @@
 #include linux/init.h
 #include linux/platform_device.h
 #include linux/module.h
+#include linux/idr.h
 #include linux/interrupt.h
 #include linux/io.h
 #include linux/irq.h
@@ -332,17 +333,24 @@ static irqreturn_t ci_irq(int irq, void *data)
return ci-role == CI_ROLE_END ? ret : ci_role(ci)-irq(ci);
 }
 
+static DEFINE_IDA(ci_ida);
+
 struct platform_device *ci13xxx_add_device(struct device *dev,
struct resource *res, int nres,
struct ci13xxx_platform_data *platdata)
 {
struct platform_device *pdev;
-   int ret;
+   int id, ret;
 
-   /* FIXME: find a way to choose id */
-   pdev = platform_device_alloc(ci_hdrc, -1);
-   if (!pdev)
-   return ERR_PTR(-ENOMEM);
+   id = ida_simple_get(ci_ida, 0, 0, GFP_KERNEL);
+   if (id  0)
+   return ERR_PTR(id);
+
+   pdev = platform_device_alloc(ci_hdrc, id);
+   if (!pdev) {
+   ret = -ENOMEM;
+   goto put_id;
+   }
 
pdev-dev.parent = dev;
pdev-dev.dma_mask = dev-dma_mask;
@@ -365,6 +373,8 @@ struct platform_device *ci13xxx_add_device(struct device 
*dev,
 
 err:
platform_device_put(pdev);
+put_id:
+   ida_simple_remove(ci_ida, id);
return ERR_PTR(ret);
 }
 EXPORT_SYMBOL_GPL(ci13xxx_add_device);
@@ -372,6 +382,7 @@ EXPORT_SYMBOL_GPL(ci13xxx_add_device);
 void ci13xxx_remove_device(struct platform_device *pdev)
 {
platform_device_unregister(pdev);
+   ida_simple_remove(ci_ida, pdev-id);
 }
 EXPORT_SYMBOL_GPL(ci13xxx_remove_device);
 
-- 
1.7.9.5


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


[PATCH v9 REBASE 4/9] usb: chipidea: select USB_EHCI_ROOT_HUB_TT in USB_CHIPIDEA_HOST of Kconfig

2012-07-07 Thread Richard Zhao
ci13xxx host needs Root Hub Transaction Translators.

Reported-by: Shawn Guo shawn@freescale.com
Signed-off-by: Richard Zhao richard.z...@freescale.com
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
Acked-by: Marek Vasut ma...@denx.de
---
 drivers/usb/chipidea/Kconfig |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig
index fd36dc8..8337fb5 100644
--- a/drivers/usb/chipidea/Kconfig
+++ b/drivers/usb/chipidea/Kconfig
@@ -20,6 +20,7 @@ config USB_CHIPIDEA_UDC
 
 config USB_CHIPIDEA_HOST
bool ChipIdea host controller
+   select USB_EHCI_ROOT_HUB_TT
help
  Say Y here to enable host controller functionality of the
  ChipIdea driver.
-- 
1.7.9.5


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


[PATCH v9 REBASE 5/9] usb: otg: add notify_connect/notify_disconnect callback

2012-07-07 Thread Richard Zhao
This let usb phy driver has a chance to change hw settings when connect
status change.

Signed-off-by: Richard Zhao richard.z...@freescale.com
Acked-by: Felipe Balbi ba...@ti.com
Tested-by: Subodh Nijsure snijs...@grid-net.com
---
 include/linux/usb/otg.h |   21 +
 1 file changed, 21 insertions(+)

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 0cb2ec2..45824be 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -128,6 +128,9 @@ struct usb_phy {
int (*set_suspend)(struct usb_phy *x,
int suspend);
 
+   /* notify phy connect status change */
+   int (*notify_connect)(struct usb_phy *x, int port);
+   int (*notify_disconnect)(struct usb_phy *x, int port);
 };
 
 
@@ -277,6 +280,24 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend)
 }
 
 static inline int
+usb_phy_notify_connect(struct usb_phy *x, int port)
+{
+   if (x-notify_connect)
+   return x-notify_connect(x, port);
+   else
+   return 0;
+}
+
+static inline int
+usb_phy_notify_disconnect(struct usb_phy *x, int port)
+{
+   if (x-notify_disconnect)
+   return x-notify_disconnect(x, port);
+   else
+   return 0;
+}
+
+static inline int
 otg_start_srp(struct usb_otg *otg)
 {
if (otg  otg-start_srp)
-- 
1.7.9.5


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


[PATCH v9 REBASE 7/9] usb: chipidea: permit driver bindings pass phy pointer

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

Signed-off-by: Richard Zhao richard.z...@freescale.com
Reviewed-by: Marek Vasut ma...@denx.de
Acked-by: Felipe Balbi ba...@ti.com
Tested-by: Subodh Nijsure snijs...@grid-net.com
---
 drivers/usb/chipidea/ci.h|2 ++
 drivers/usb/chipidea/core.c  |4 
 drivers/usb/chipidea/host.c  |1 +
 drivers/usb/chipidea/udc.c   |   11 +++
 include/linux/usb/chipidea.h |3 +++
 5 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 9655e35..d738603 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -160,6 +160,8 @@ struct ci13xxx {
 
struct ci13xxx_platform_data*platdata;
int vbus_active;
+   /* FIXME: some day, we'll not use global phy */
+   boolglobal_phy;
struct usb_phy  *transceiver;
struct usb_hcd  *hcd;
 };
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 39603d7..1083585 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -419,6 +419,10 @@ static int __devinit ci_hdrc_probe(struct platform_device 
*pdev)
 
ci-dev = dev;
ci-platdata = dev-platform_data;
+   if (ci-platdata-phy)
+   ci-transceiver = ci-platdata-phy;
+   else
+   ci-global_phy = true;
 
ret = hw_device_init(ci, base);
if (ret  0) {
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 4a4fdb8..ebff9f4 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -117,6 +117,7 @@ static int host_start(struct ci13xxx *ci)
hcd-has_tt = 1;
 
hcd-power_budget = ci-platdata-power_budget;
+   hcd-phy = ci-transceiver;
 
ehci = hcd_to_ehci(hcd);
ehci-caps = ci-hw_bank.cap;
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index ba8284e..c7a032a 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1685,7 +1685,8 @@ static int udc_start(struct ci13xxx *ci)
 
ci-gadget.ep0 = ci-ep0in-ep;
 
-   ci-transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+   if (ci-global_phy)
+   ci-transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
 
if (ci-platdata-flags  CI13XXX_REQUIRE_TRANSCEIVER) {
if (ci-transceiver == NULL) {
@@ -1729,7 +1730,8 @@ static int udc_start(struct ci13xxx *ci)
 remove_trans:
if (!IS_ERR_OR_NULL(ci-transceiver)) {
otg_set_peripheral(ci-transceiver-otg, ci-gadget);
-   usb_put_phy(ci-transceiver);
+   if (ci-global_phy)
+   usb_put_phy(ci-transceiver);
}
 
dev_err(dev, error = %i\n, retval);
@@ -1738,7 +1740,7 @@ remove_dbg:
 unreg_device:
device_unregister(ci-gadget.dev);
 put_transceiver:
-   if (!IS_ERR_OR_NULL(ci-transceiver))
+   if (!IS_ERR_OR_NULL(ci-transceiver)  ci-global_phy)
usb_put_phy(ci-transceiver);
 free_pools:
dma_pool_destroy(ci-td_pool);
@@ -1772,7 +1774,8 @@ static void udc_stop(struct ci13xxx *ci)
 
if (!IS_ERR_OR_NULL(ci-transceiver)) {
otg_set_peripheral(ci-transceiver-otg, NULL);
-   usb_put_phy(ci-transceiver);
+   if (ci-global_phy)
+   usb_put_phy(ci-transceiver);
}
dbg_remove_files(ci-gadget.dev);
device_unregister(ci-gadget.dev);
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index be078f0..544825d 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -5,12 +5,15 @@
 #ifndef __LINUX_USB_CHIPIDEA_H
 #define __LINUX_USB_CHIPIDEA_H
 
+#include linux/usb/otg.h
+
 struct ci13xxx;
 struct ci13xxx_platform_data {
const char  *name;
/* offset of the capability registers */
uintptr_tcapoffset;
unsigned power_budget;
+   struct usb_phy  *phy;
unsigned longflags;
 #define CI13XXX_REGS_SHAREDBIT(0)
 #define CI13XXX_REQUIRE_TRANSCEIVERBIT(1)
-- 
1.7.9.5


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


[PATCH v9 REBASE 6/9] USB: notify phy when root hub port connect change

2012-07-07 Thread Richard Zhao
Phy may need to change settings when port connect change.

Signed-off-by: Richard Zhao richard.z...@freescale.com
Tested-by: Subodh Nijsure snijs...@grid-net.com
---
 drivers/usb/core/hub.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4cc8dc9..2ba9d84 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -20,6 +20,7 @@
 #include linux/usb.h
 #include linux/usbdevice_fs.h
 #include linux/usb/hcd.h
+#include linux/usb/otg.h
 #include linux/usb/quirks.h
 #include linux/kthread.h
 #include linux/mutex.h
@@ -4037,6 +4038,13 @@ static void hub_port_connect_change(struct usb_hub *hub, 
int port1,
}
}
 
+   if (unlikely(hcd-phy  !hdev-parent)) {
+   if (portstatus  USB_PORT_STAT_CONNECTION)
+   usb_phy_notify_connect(hcd-phy, port1);
+   else
+   usb_phy_notify_disconnect(hcd-phy, port1);
+   }
+
/* Return now if debouncing failed or nothing is connected or
 * the device was removed.
 */
-- 
1.7.9.5


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


[PATCH v9 REBASE 8/9] usb: otg: add basic mxs phy driver support

2012-07-07 Thread Richard Zhao
mxs phy is used in Freescale i.MX SoCs, for example
imx23, imx28, imx6Q. This patch adds the basic host
support.

Signed-off-by: Richard Zhao richard.z...@freescale.com
Signed-off-by: Marek Vasut ma...@denx.de
Cc: Peter Chen peter.c...@freescale.com
Acked-by: Felipe Balbi ba...@ti.com
Tested-by: Subodh Nijsure snijs...@grid-net.com
---
 Documentation/devicetree/bindings/usb/mxs-phy.txt |   13 ++
 drivers/usb/otg/Kconfig   |   10 ++
 drivers/usb/otg/Makefile  |1 +
 drivers/usb/otg/mxs-phy.c |  186 +
 4 files changed, 210 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/mxs-phy.txt
 create mode 100644 drivers/usb/otg/mxs-phy.c

diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt 
b/Documentation/devicetree/bindings/usb/mxs-phy.txt
new file mode 100644
index 000..5835b27
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
@@ -0,0 +1,13 @@
+* Freescale MXS USB Phy Device
+
+Required properties:
+- compatible: Should be fsl,imx23-usbphy
+- reg: Should contain registers location and length
+- interrupts: Should contain phy interrupt
+
+Example:
+usbphy1: usbphy@020c9000 {
+   compatible = fsl,imx6q-usbphy, fsl,imx23-usbphy;
+   reg = 0x020c9000 0x1000;
+   interrupts = 0 44 0x04;
+};
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 5c87db0..13fd1ddf 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -116,6 +116,16 @@ config FSL_USB2_OTG
help
  Enable this to support Freescale USB OTG transceiver.
 
+config USB_MXS_PHY
+   tristate Freescale MXS USB PHY support
+   depends on ARCH_MXC || ARCH_MXS
+   select STMP_DEVICE
+   select USB_OTG_UTILS
+   help
+ Enable this to support the Freescale MXS USB PHY.
+
+ MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x.
+
 config USB_MV_OTG
tristate Marvell USB OTG support
depends on USB_EHCI_MV  USB_MV_UDC  USB_SUSPEND
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index 41aa509..a844b8d 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -20,4 +20,5 @@ obj-$(CONFIG_USB_MSM_OTG) += msm_otg.o
 obj-$(CONFIG_AB8500_USB)   += ab8500-usb.o
 fsl_usb2_otg-objs  := fsl_otg.o otg_fsm.o
 obj-$(CONFIG_FSL_USB2_OTG) += fsl_usb2_otg.o
+obj-$(CONFIG_USB_MXS_PHY)  += mxs-phy.o
 obj-$(CONFIG_USB_MV_OTG)   += mv_otg.o
diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
new file mode 100644
index 000..c1a67cb
--- /dev/null
+++ b/drivers/usb/otg/mxs-phy.c
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright (C) 2012 Marek Vasut ma...@denx.de
+ * on behalf of DENX Software Engineering GmbH
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/platform_device.h
+#include linux/clk.h
+#include linux/usb/otg.h
+#include linux/stmp_device.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/io.h
+
+#define DRIVER_NAME mxs_phy
+
+#define HW_USBPHY_PWD  0x00
+#define HW_USBPHY_CTRL 0x30
+#define HW_USBPHY_CTRL_SET 0x34
+#define HW_USBPHY_CTRL_CLR 0x38
+
+#define BM_USBPHY_CTRL_SFTRST  BIT(31)
+#define BM_USBPHY_CTRL_CLKGATE BIT(30)
+#define BM_USBPHY_CTRL_ENUTMILEVEL3BIT(15)
+#define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14)
+#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT  BIT(1)
+
+struct mxs_phy {
+   struct usb_phy phy;
+   struct clk *clk;
+};
+
+#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
+
+static void mxs_phy_hw_init(struct mxs_phy *mxs_phy)
+{
+   void __iomem *base = mxs_phy-phy.io_priv;
+
+   stmp_reset_block(base + HW_USBPHY_CTRL);
+
+   /* Power up the PHY */
+   writel_relaxed(0, base + HW_USBPHY_PWD);
+
+   /* enable FS/LS device */
+   writel_relaxed(BM_USBPHY_CTRL_ENUTMILEVEL2 |
+   BM_USBPHY_CTRL_ENUTMILEVEL3,
+   base + HW_USBPHY_CTRL_SET);
+}
+
+static int mxs_phy_init(struct usb_phy *phy)
+{
+   struct mxs_phy *mxs_phy = to_mxs_phy(phy);
+
+   clk_prepare_enable(mxs_phy-clk);
+   mxs_phy_hw_init(mxs_phy);
+
+   return 0;
+}
+
+static void mxs_phy_shutdown(struct usb_phy *phy)
+{
+   struct mxs_phy *mxs_phy = to_mxs_phy(phy);
+
+   writel_relaxed(BM_USBPHY_CTRL_CLKGATE,
+   phy-io_priv + HW_USBPHY_CTRL_SET);
+
+   clk_disable_unprepare(mxs_phy-clk);
+}
+
+static int mxs_phy_on_connect(struct