Re: Tested your workaround regarding the uas bug (posted in archlinux.org forum), seems as it failed

2014-11-16 Thread Hans de Goede
Hi,

On 11/16/2014 08:39 AM, Jonas Seibert wrote:
 Hey Hans,
 
 as I got a 2TB external harddrive and it didn't work with linux for ages 
 (works with windows though) I decided to give your fix a try.
 Said HDD says airy and by CnMemory on the front and on the back 
 Item-No.68770 (just in case that helps you with the chipset, I can't open 
 it).
 Sadly it didn't show up, but I attached you the logs it created.

Looking at the lsusb output this is not an uas device, but rather a regular
usb-storage (bulk only transport) device.

The best way to get help with this is to send an email with a detailed
bug-report to: linux-usb linux-usb@vger.kernel.org, no need to
subscribe there, if you put yourself in the CC you should get all replies.

Please also put me in the CC. As for the detailed part of the bug
report, I think the mail you send to me with a slightly different
introductionary text will do nicely.

Regards,

Hans
--
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] qcserial: Add support for HP lt4112 LTE/HSPA+ Gobi 4G Modem

2014-11-16 Thread Sergei Shtylyov

Hello.

On 11/16/2014 3:05 AM, Martin Hauke wrote:


Added new device layout DEVICE_HWI and also added the USB VID/PID for the
HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e)
---
  drivers/usb/serial/qcserial.c | 34 ++
  1 file changed, 34 insertions(+)



diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index b2aa003..522e3e5 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c

[...]

@@ -286,6 +292,34 @@ static int qcprobe(struct usb_serial *serial, const struct 
usb_device_id *id)
altsetting = -1;
break;
}
+   case QCSERIAL_HWI:
+   /*
+* Huawei layout:
+* 0: AT-capable modem port
+* 1: DM/DIAG
+* 2: AT-capable modem port
+* 3: CCID-compatible PCSC interface
+* 4: QMI/net
+* 5: NMEA
+*/
+   switch (ifnum) {
+   case 0:


   Perhaps, add *case* 2: here...


+   dev_dbg(dev, Modem port found\n);
+   break;
+   case 1:
+   dev_dbg(dev, DM/DIAG interface found\n);
+   break;
+   case 2:
+   dev_dbg(dev, Modem port found\n);
+   break;


   ... and remove the above *case*?

WBR, Sergei

--
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] qcserial: Add support for HP lt4112 LTE/HSPA+ Gobi 4G Modem

2014-11-16 Thread Martin Hauke
Added new device layout DEVICE_HWI and also added the USB VID/PID for the
HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e)

Signed-off-by: Martin Hauke mar...@gmx.de
---
 drivers/usb/serial/qcserial.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index b2aa003..3a78384 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -27,12 +27,15 @@ enum qcserial_layouts {
QCSERIAL_G2K = 0,   /* Gobi 2000 */
QCSERIAL_G1K = 1,   /* Gobi 1000 */
QCSERIAL_SWI = 2,   /* Sierra Wireless */
+   QCSERIAL_HWI = 3,   /* Huawei */
 };
 
 #define DEVICE_G1K(v, p) \
USB_DEVICE(v, p), .driver_info = QCSERIAL_G1K
 #define DEVICE_SWI(v, p) \
USB_DEVICE(v, p), .driver_info = QCSERIAL_SWI
+#define DEVICE_HWI(v, p) \
+   USB_DEVICE(v, p), .driver_info = QCSERIAL_HWI
 
 static const struct usb_device_id id_table[] = {
/* Gobi 1000 devices */
@@ -157,6 +160,9 @@ static const struct usb_device_id id_table[] = {
{DEVICE_SWI(0x413c, 0x81a8)},   /* Dell Wireless 5808 Gobi(TM) 4G LTE 
Mobile Broadband Card */
{DEVICE_SWI(0x413c, 0x81a9)},   /* Dell Wireless 5808e Gobi(TM) 4G LTE 
Mobile Broadband Card */
 
+   /* Huawei devices */
+   {DEVICE_HWI(0x03f0, 0x581d)},   /* HP lt4112 LTE/HSPA+ Gobi 4G Modem 
(Huawei me906e) */
+
{ } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, id_table);
@@ -286,6 +292,32 @@ static int qcprobe(struct usb_serial *serial, const struct 
usb_device_id *id)
altsetting = -1;
break;
}
+   case QCSERIAL_HWI:
+   /*
+* Huawei layout:
+* 0: AT-capable modem port
+* 1: DM/DIAG
+* 2: AT-capable modem port
+* 3: CCID-compatible PCSC interface
+* 4: QMI/net
+* 5: NMEA
+*/
+   switch (ifnum) {
+   case 0:
+   case 2:
+   dev_dbg(dev, Modem port found\n);
+   break;
+   case 1:
+   dev_dbg(dev, DM/DIAG interface found\n);
+   break;
+   case 5:
+   dev_dbg(dev, NMEA GPS interface found\n);
+   break;
+   default:
+   /* don't claim any unsupported interface */
+   altsetting = -1;
+   break;
+   }
break;
default:
dev_err(dev, unsupported device layout type: %lu\n,
-- 
2.1.2

--
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] qcserial: Add support for HP lt4112 LTE/HSPA+ Gobi 4G Modem

2014-11-16 Thread Sergei Shtylyov

Hello.

On 11/16/2014 09:54 PM, Martin Hauke wrote:


Added new device layout DEVICE_HWI and also added the USB VID/PID for the
HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e)



Signed-off-by: Martin Hauke mar...@gmx.de
---
  drivers/usb/serial/qcserial.c | 32 
  1 file changed, 32 insertions(+)



diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index b2aa003..3a78384 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c

[...]

@@ -286,6 +292,32 @@ static int qcprobe(struct usb_serial *serial, const struct 
usb_device_id *id)
altsetting = -1;
break;
}


   Are you sure there shouldn't be *break* here?


+   case QCSERIAL_HWI:
+   /*
+* Huawei layout:
+* 0: AT-capable modem port
+* 1: DM/DIAG
+* 2: AT-capable modem port
+* 3: CCID-compatible PCSC interface
+* 4: QMI/net
+* 5: NMEA
+*/
+   switch (ifnum) {
+   case 0:
+   case 2:
+   dev_dbg(dev, Modem port found\n);
+   break;
+   case 1:
+   dev_dbg(dev, DM/DIAG interface found\n);
+   break;
+   case 5:
+   dev_dbg(dev, NMEA GPS interface found\n);
+   break;
+   default:
+   /* don't claim any unsupported interface */
+   altsetting = -1;
+   break;
+   }
break;


WBR, Sergei

--
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] qcserial: Add support for HP lt4112 LTE/HSPA+ Gobi 4G Modem

2014-11-16 Thread Martin Hauke
Added new device layout DEVICE_HWI and also added the USB VID/PID for the
HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e)

Signed-off-by: Martin Hauke mar...@gmx.de
---
 drivers/usb/serial/qcserial.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index b2aa003..cb3e147 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -27,12 +27,15 @@ enum qcserial_layouts {
QCSERIAL_G2K = 0,   /* Gobi 2000 */
QCSERIAL_G1K = 1,   /* Gobi 1000 */
QCSERIAL_SWI = 2,   /* Sierra Wireless */
+   QCSERIAL_HWI = 3,   /* Huawei */
 };
 
 #define DEVICE_G1K(v, p) \
USB_DEVICE(v, p), .driver_info = QCSERIAL_G1K
 #define DEVICE_SWI(v, p) \
USB_DEVICE(v, p), .driver_info = QCSERIAL_SWI
+#define DEVICE_HWI(v, p) \
+   USB_DEVICE(v, p), .driver_info = QCSERIAL_HWI
 
 static const struct usb_device_id id_table[] = {
/* Gobi 1000 devices */
@@ -157,6 +160,9 @@ static const struct usb_device_id id_table[] = {
{DEVICE_SWI(0x413c, 0x81a8)},   /* Dell Wireless 5808 Gobi(TM) 4G LTE 
Mobile Broadband Card */
{DEVICE_SWI(0x413c, 0x81a9)},   /* Dell Wireless 5808e Gobi(TM) 4G LTE 
Mobile Broadband Card */
 
+   /* Huawei devices */
+   {DEVICE_HWI(0x03f0, 0x581d)},   /* HP lt4112 LTE/HSPA+ Gobi 4G Modem 
(Huawei me906e) */
+
{ } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, id_table);
@@ -287,6 +293,33 @@ static int qcprobe(struct usb_serial *serial, const struct 
usb_device_id *id)
break;
}
break;
+   case QCSERIAL_HWI:
+   /*
+* Huawei layout:
+* 0: AT-capable modem port
+* 1: DM/DIAG
+* 2: AT-capable modem port
+* 3: CCID-compatible PCSC interface
+* 4: QMI/net
+* 5: NMEA
+*/
+   switch (ifnum) {
+   case 0:
+   case 2:
+   dev_dbg(dev, Modem port found\n);
+   break;
+   case 1:
+   dev_dbg(dev, DM/DIAG interface found\n);
+   break;
+   case 5:
+   dev_dbg(dev, NMEA GPS interface found\n);
+   break;
+   default:
+   /* don't claim any unsupported interface */
+   altsetting = -1;
+   break;
+   }
+   break;
default:
dev_err(dev, unsupported device layout type: %lu\n,
id-driver_info);
-- 
2.1.2

--
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] net2280: Fix superspeed dma_done()

2014-11-16 Thread Mario Schuknecht
Parameter three in function call dma_done() is incorrect.
Move use of variable 'tmp' after if-condition.

Signed-off-by: Mario Schuknecht mario.schukne...@dresearch-fe.de
---
 drivers/usb/gadget/udc/net2280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 8d13337..1f35193 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1118,10 +1118,10 @@ static void scan_dma_completions(struct net2280_ep *ep)
break;
} else if (!ep-is_in 
(req-req.length % ep-ep.maxpacket) != 0) {
-   tmp = readl(ep-regs-ep_stat);
if (ep-dev-quirks  PLX_SUPERSPEED)
return dma_done(ep, req, tmp, 0);
 
+   tmp = readl(ep-regs-ep_stat);
/* AVOID TROUBLE HERE by not issuing short reads from
 * your gadget driver.  That helps avoids errata 0121,
 * 0122, and 0124; not all cases trigger the warning.
-- 
1.8.4.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 v1] chipidea: issue message when some calls fail in -probe()

2014-11-16 Thread Peter Chen
On Thu, Nov 13, 2014 at 05:59:47PM +0200, Andy Shevchenko wrote:
 There is no message when PHY is not enabled, IRQ line can't be acquired, or
 debugfs registration fails. This patch adds the messages.
 
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/usb/chipidea/core.c | 16 
  1 file changed, 12 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index c57448a..ffd2457 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -659,8 +659,10 @@ static int ci_hdrc_probe(struct platform_device *pdev)
  
   /* if both generic PHY and USB PHY layers aren't enabled */
   if (PTR_ERR(ci-phy) == -ENOSYS 
 - PTR_ERR(ci-usb_phy) == -ENXIO)
 + PTR_ERR(ci-usb_phy) == -ENXIO) {
 + dev_err(dev, PHY and USB PHY layers aren't enabled\n);
   return -ENXIO;
 + }
  
   if (IS_ERR(ci-phy)  IS_ERR(ci-usb_phy))
   return -EPROBE_DEFER;
 @@ -761,16 +763,22 @@ static int 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);
 - if (ret)
 + if (ret) {
 + dev_err(dev, can't acquire IRQ line %d\n, ci-irq);
   goto stop;
 + }
  
   if (ci_otg_is_fsm_mode(ci))
   ci_hdrc_otg_fsm_start(ci);
  
   ret = dbg_create_files(ci);
 - if (!ret)
 - return 0;
 + if (ret) {
 + dev_err(dev, can't register debugfs files\n);
 + goto release_irq;
 + }
 + return 0;
  
 +release_irq:
   free_irq(ci-irq, ci);
  stop:
   ci_role_destroy(ci);
 -- 
 2.1.3
 

Yes, I find the probe does not show warning for -ENODEV and -ENXIO,
I have changed request_irq to devm_request_irq at my next tree,
rebase it, and send your v2 please.

-- 

Best Regards,
Peter Chen
--
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 v1] chipidea: pci: register nop PHY

2014-11-16 Thread Peter Chen
On Fri, Nov 14, 2014 at 04:33:22PM +0200, Andy Shevchenko wrote:
 Since PHY for Chipidea is optional (not all SoCs having PHY for Chipidea 
 should
 be programmed), we register 'nop' PHY for platforms that does not have
 programmable PHY.
 
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/usb/chipidea/ci_hdrc_pci.c | 32 +---
  1 file changed, 25 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c 
 b/drivers/usb/chipidea/ci_hdrc_pci.c
 index 241ae34..7e0b701 100644
 --- a/drivers/usb/chipidea/ci_hdrc_pci.c
 +++ b/drivers/usb/chipidea/ci_hdrc_pci.c
 @@ -16,10 +16,16 @@
  #include linux/interrupt.h
  #include linux/usb/gadget.h
  #include linux/usb/chipidea.h
 +#include linux/usb/usb_phy_generic.h
  
  /* driver name */
  #define UDC_DRIVER_NAME   ci_hdrc_pci
  
 +struct ci_hdrc_pci {
 + struct platform_device  *ci;
 + struct platform_device  *phy;
 +};
 +
  
 /**
   * PCI block
   
 */
 @@ -52,7 +58,7 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
  const struct pci_device_id *id)
  {
   struct ci_hdrc_platform_data *platdata = (void *)id-driver_data;
 - struct platform_device *plat_ci;
 + struct ci_hdrc_pci *ci;
   struct resource res[3];
   int retval = 0, nres = 2;
  
 @@ -61,6 +67,10 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
   return -ENODEV;
   }
  
 + ci = devm_kzalloc(pdev-dev, sizeof(*ci), GFP_KERNEL);
 + if (!ci)
 + return -ENOMEM;
 +
   retval = pcim_enable_device(pdev);
   if (retval)
   return retval;
 @@ -73,20 +83,27 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
   pci_set_master(pdev);
   pci_try_set_mwi(pdev);
  
 + /* register a nop PHY */
 + ci-phy = usb_phy_generic_register();
 + if (!ci-phy)
 + return -ENOMEM;

Rebase my next tree where antoine's generic phy support for chipidea
driver in it, and for usb phy, the phy changes to usb_phy.

 +
   memset(res, 0, sizeof(res));
 +

Why this blank line is needed?

   res[0].start= pci_resource_start(pdev, 0);
   res[0].end  = pci_resource_end(pdev, 0);
   res[0].flags= IORESOURCE_MEM;
   res[1].start= pdev-irq;
   res[1].flags= IORESOURCE_IRQ;
  
 - plat_ci = ci_hdrc_add_device(pdev-dev, res, nres, platdata);
 - if (IS_ERR(plat_ci)) {
 + ci-ci = ci_hdrc_add_device(pdev-dev, res, nres, platdata);
 + if (IS_ERR(ci-ci)) {
   dev_err(pdev-dev, ci_hdrc_add_device failed!\n);
 - return PTR_ERR(plat_ci);
 + usb_phy_generic_unregister(ci-phy);
 + return PTR_ERR(ci-ci);
   }
  
 - pci_set_drvdata(pdev, plat_ci);
 + pci_set_drvdata(pdev, ci);
  
   return 0;
  }
 @@ -101,9 +118,10 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
   */
  static void ci_hdrc_pci_remove(struct pci_dev *pdev)
  {
 - struct platform_device *plat_ci = pci_get_drvdata(pdev);
 + struct ci_hdrc_pci *ci = pci_get_drvdata(pdev);
  
 - ci_hdrc_remove_device(plat_ci);
 + ci_hdrc_remove_device(ci-ci);
 + usb_phy_generic_unregister(ci-phy);
  }
  
  /**
 -- 
 2.1.3
 

-- 

Best Regards,
Peter Chen
--
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 1/3] usb: chipidea: add controller reset API

2014-11-16 Thread Peter Chen
On Fri, Nov 14, 2014 at 02:55:41PM +0300, Sergei Shtylyov wrote:
 Hello.
 
 On 11/14/2014 3:03 AM, Peter Chen wrote:
 
 Add controller reset API, it may be used for host/otg driver in future.
 
 Signed-off-by: Peter Chen peter.c...@freescale.com
 ---
 
 Changes for v2:
 - Add return value check for controller reset at hw_device_reset
 
   drivers/usb/chipidea/core.c | 30 +++---
   1 file changed, 27 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index bd74f27..dffd89b 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 [...]
 @@ -392,13 +412,17 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
*/
   int hw_device_reset(struct ci_hdrc *ci, u32 mode)
   {
 +int ret;
 +
  /* should flush  stop before reset */
  hw_write(ci, OP_ENDPTFLUSH, ~0, ~0);
  hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
 
 -hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST);
 -while (hw_read(ci, OP_USBCMD, USBCMD_RST))
 -udelay(10); /* not RTOS friendly */
 +ret = hw_controller_reset(ci);
 +if (ret) {
 +dev_err(ci-dev, error for reset, ret=%d\n, ret);
 
Perhaps error resetting?
 

Thanks, will change to error resetting controller.

 +return ret;
 +}
 
 WBR, Sergei
 

-- 

Best Regards,
Peter Chen
--
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: chipidea: parameter 'mode' isn't needed for hw_device_reset

2014-11-16 Thread Peter Chen
On Fri, Nov 14, 2014 at 09:05:16AM -0600, Felipe Balbi wrote:
 Hi,
 
 On Fri, Nov 14, 2014 at 03:40:55PM +0800, Peter Chen wrote:
@@ -1660,7 +1660,7 @@ static int ci_udc_start(struct usb_gadget *gadget,
pm_runtime_get_sync(ci-gadget.dev);
if (ci-vbus_active) {
spin_lock_irqsave(ci-lock, flags);
-   hw_device_reset(ci, USBMODE_CM_DC);
+   hw_device_reset(ci);
   
   wow, you guys reset this IP all the time... that's scary, could be
   hiding bugs easily.
   
  
  In current chipidea design, it indeed resets controller often, it
  resets controller when the usb cable connects to pc and the gadget
  driver is there, something like which we do for RUN/STOP bit.
 
 RUN/STOP on dwc3 is not an IP reset though. Neither it is on XHCI/EHCI.
 

Of cos, I mean the situation which the chipidea does reset controller
is not necessary sometimes, it can control RUN/STOP bit instead of it.

-- 

Best Regards,
Peter Chen
--
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 1/3] usb: chipidea: add controller reset API

2014-11-16 Thread Peter Chen
On Fri, Nov 14, 2014 at 09:06:47AM -0600, Felipe Balbi wrote:
 On Fri, Nov 14, 2014 at 03:33:44PM +0800, Peter Chen wrote:
  On Thu, Nov 13, 2014 at 09:55:34PM -0600, Felipe Balbi wrote:
   Hi,
   
   On Fri, Nov 14, 2014 at 08:03:15AM +0800, Peter Chen wrote:
Add controller reset API, it may be used for host/otg driver in future.
   
   you need a better commit log here. How would it be used ? when ? And,
   more importantly, why ?
   
  
  I will add more information
  
   Why would we need to reset the IP outside of -probe() ?
   
   I don't oppose to the refactoring, but why would we ever need to reset
   this IP ?
  
  Usually, we need to below reset controller at below situations:
  - Role switch, host-device and device-host
  - Return from hibernation, which the controller will lost its power,
and the content of the register are lost.
 
 resetting is probably not the best solution in either case, though. It
 might be the easiest, but not the best. For suspend/resume, you would be
 better off saving/restoring contenxt and for role switch, you could just
 reprogram the few registers which need to change when role swapping.
 

For safe reason, it is better to do reset controller at above two
situations. Why we need to do reset at probe, it may also work if
we program register directly.

-- 

Best Regards,
Peter Chen
--
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: chipidea: parameter 'mode' isn't needed for hw_device_reset

2014-11-16 Thread Felipe Balbi
On Mon, Nov 17, 2014 at 10:11:38AM +0800, Peter Chen wrote:
 On Fri, Nov 14, 2014 at 09:05:16AM -0600, Felipe Balbi wrote:
  Hi,
  
  On Fri, Nov 14, 2014 at 03:40:55PM +0800, Peter Chen wrote:
 @@ -1660,7 +1660,7 @@ static int ci_udc_start(struct usb_gadget 
 *gadget,
   pm_runtime_get_sync(ci-gadget.dev);
   if (ci-vbus_active) {
   spin_lock_irqsave(ci-lock, flags);
 - hw_device_reset(ci, USBMODE_CM_DC);
 + hw_device_reset(ci);

wow, you guys reset this IP all the time... that's scary, could be
hiding bugs easily.

   
   In current chipidea design, it indeed resets controller often, it
   resets controller when the usb cable connects to pc and the gadget
   driver is there, something like which we do for RUN/STOP bit.
  
  RUN/STOP on dwc3 is not an IP reset though. Neither it is on XHCI/EHCI.
  
 
 Of cos, I mean the situation which the chipidea does reset controller
 is not necessary sometimes, it can control RUN/STOP bit instead of it.

got it now, that would be a very welcome optimization.

-- 
balbi


signature.asc
Description: Digital signature


About wakeup IRQ support in USB core

2014-11-16 Thread Wang, Yu
Hi Roger,

I saw one old thread about your patch for wakeup IRQ support in USB
core. We need it for Intel platform. And it is work well on intel
platform.

May I know why this patch haven't get merged so far? I saw everything
was smooth during the discussion, and you had already fixed all comments
from Alan. But somehow the discussion is stop.

Old thread link:
http://lkml.iu.edu//hypermail/linux/kernel/1307.1/01392.html


Thanks
Yu
--
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] usb: dwc2/gadget: rework disconnect event handling

2014-11-16 Thread Marek Szyprowski

Hello,

On 2014-11-14 23:09, Paul Zimmerman wrote:

From: Paul Zimmerman
Sent: Friday, November 14, 2014 1:21 PM


From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-ow...@vger.kernel.org] 
On Behalf Of Felipe Balbi
Sent: Friday, November 14, 2014 11:05 AM

On Fri, Nov 14, 2014 at 07:01:37PM +, Paul Zimmerman wrote:

-Original Message-
From: Marek Szyprowski [mailto:m.szyprow...@samsung.com]
Sent: Friday, November 14, 2014 4:20 AM

This patch adds a call to s3c_hsotg_disconnect() from 'end session'
interrupt (GOTGINT_SES_END_DET) to correctly notify gadget subsystem
about unplugged usb cable. DISCONNINT interrupt cannot be used for this
purpose, because it is asserted only in host mode.

To avoid reporting disconnect event more than once, a disconnect call has
been moved from USB_REQ_SET_ADDRESS handling function to SESSREQINT
interrupt. This way driver ensures that disconnect event is reported
either when usb cable is unplugged or every time the host starts a new
session.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
  drivers/usb/dwc2/core.h   |  1 +
  drivers/usb/dwc2/gadget.c | 13 +++--
  2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 55c90c53f2d6..78b9090ebf71 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -210,6 +210,7 @@ struct s3c_hsotg {
u8  ctrl_buff[8];

struct usb_gadget   gadget;
+   unsigned intsession:1;
unsigned intsetup;
unsigned long   last_rst;
struct s3c_hsotg_ep *eps;
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index fcd2bb55ccca..c7f68dc1cf6b 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1029,7 +1029,6 @@ static int s3c_hsotg_process_req_feature(struct s3c_hsotg 
*hsotg,
  }

  static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg);
-static void s3c_hsotg_disconnect(struct s3c_hsotg *hsotg);

  /**
   * s3c_hsotg_stall_ep0 - stall ep0
@@ -1107,7 +1106,6 @@ static void s3c_hsotg_process_control(struct s3c_hsotg 
*hsotg,
if ((ctrl-bRequestType  USB_TYPE_MASK) == USB_TYPE_STANDARD) {
switch (ctrl-bRequest) {
case USB_REQ_SET_ADDRESS:
-   s3c_hsotg_disconnect(hsotg);
dcfg = readl(hsotg-regs + DCFG);
dcfg = ~DCFG_DEVADDR_MASK;
dcfg |= (le16_to_cpu(ctrl-wValue) 
@@ -2031,6 +2029,10 @@ static void s3c_hsotg_disconnect(struct s3c_hsotg *hsotg)
  {
unsigned ep;

+   if (!hsotg-session)
+   return;
+
+   hsotg-session = 0;
for (ep = 0; ep  hsotg-num_of_eps; ep++)
kill_all_requests(hsotg, hsotg-eps[ep], -ESHUTDOWN, true);

@@ -2290,11 +2292,18 @@ irq_retry:
dev_info(hsotg-dev, OTGInt: %08x\n, otgint);

writel(otgint, hsotg-regs + GOTGINT);
+
+   if (otgint  GOTGINT_SES_END_DET) {
+   s3c_hsotg_disconnect(hsotg);

I think you should clear hsotg-session here, shouldn't you?
Otherwise I think s3c_hsotg_disconnect() will be called twice, once
here and once when the next GINTSTS_SESSREQINT comes.

the best way to avoid that would be fiddle with hsotg-session inside
s3c_hsotg_disconnect() only.

Whoops, I just noticed that hsotg-session *is* cleared inside of
s3c_hsotg_disconnect(). So I think the patch is good as-is.

Acked-by: Paul Zimmerman pa...@synopsys.com

I'm having second thoughts about this. Currently, the
GINTSTS_SESSREQINT interrupt in the gadget does nothing except print
a debug message. So I'm not sure that all versions of the controller
actually assert this interrupt when a connection is made. If they
don't, then this patch would break the disconnect handling, since
hsotg-session would never get set.

In particular, I'm thinking that a core which is synthesized without
SRP support may not implement the GINTSTS_SESSREQINT interrupt. The
databook seems to imply that:

SessReqInt: In Device mode, this interrupt is asserted when the
utmisrp_bvalid signal goes high.

And in the section which describes the utmisrp_bvalid signal, there is
a note that says:

This interface is present only when parameter OTG_MODE specifies an
SRP-capable configuration.

So Marek, can you try moving the line which sets hsotg-session = 1
into s3c_hsotg_irq_enumdone() instead? Then we will be sure it gets set
to one after a connect. Probably it should be renamed from 'session'
to 'connect' in that case.


Well... ok, but this will work exactly the same way as v3, which you were
not keen of. I think the best way will be to keep it set both in SESSREQINT
and enumdone, I will send a patch in a few minutes.

Best regards
--
Marek Szyprowski, PhD
Samsung RD Institute Poland

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to 

[PATCH v3 1/3] usb: chipidea: add controller reset API

2014-11-16 Thread Peter Chen
Add controller reset API, currently it is used for device mode only.
It may be used for host/otg driver in future.

Ususally, we need this API for dual-role switch and back from hibernation
suspend to let the controller at default state.

Signed-off-by: Peter Chen peter.c...@freescale.com
---

Changes for v3:
- Add more description for why this API is needed
- Fix one indentation problem
- Change error message for error for reset to error resetting controller

 drivers/usb/chipidea/core.c | 32 
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index bd74f27..48b25d9 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -385,20 +385,44 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
 }
 
 /**
- * hw_device_reset: resets chip (execute without interruption)
+ * hw_controller_reset: do controller reset
  * @ci: the controller
   *
  * This function returns an error code
  */
+static int hw_controller_reset(struct ci_hdrc *ci)
+{
+   int count = 0;
+
+   hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST);
+   while (hw_read(ci, OP_USBCMD, USBCMD_RST)) {
+   udelay(10);
+   if (count++  1000)
+   return -ETIMEDOUT;
+   }
+
+   return 0;
+}
+
+/**
+ * hw_device_reset: resets chip (execute without interruption)
+ * @ci: the controller
+ *
+ * This function returns an error code
+ */
 int hw_device_reset(struct ci_hdrc *ci, u32 mode)
 {
+   int ret;
+
/* should flush  stop before reset */
hw_write(ci, OP_ENDPTFLUSH, ~0, ~0);
hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
 
-   hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST);
-   while (hw_read(ci, OP_USBCMD, USBCMD_RST))
-   udelay(10); /* not RTOS friendly */
+   ret = hw_controller_reset(ci);
+   if (ret) {
+   dev_err(ci-dev, error resetting controller, ret=%d\n, ret);
+   return ret;
+   }
 
if (ci-platdata-notify_event)
ci-platdata-notify_event(ci,
-- 
1.9.1

--
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 2/3] usb: chipidea: parameter 'mode' isn't needed for hw_device_reset

2014-11-16 Thread Peter Chen
The hw_device_reset is dedicated to be used at device mode initializaiton,
so delete the parameter 'mode'. For host driver, the ehci driver will
handle all things.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
Changes for v2:
- Add missing description at commit log.

 drivers/usb/chipidea/ci.h  | 2 +-
 drivers/usb/chipidea/core.c| 8 
 drivers/usb/chipidea/otg_fsm.c | 2 +-
 drivers/usb/chipidea/udc.c | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 5bbfcc7..65913d4 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -352,7 +352,7 @@ u32 hw_read_intr_enable(struct ci_hdrc *ci);
 
 u32 hw_read_intr_status(struct ci_hdrc *ci);
 
-int hw_device_reset(struct ci_hdrc *ci, u32 mode);
+int hw_device_reset(struct ci_hdrc *ci);
 
 int hw_port_test_set(struct ci_hdrc *ci, u8 mode);
 
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 48b25d9..e43be34 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -410,7 +410,7 @@ static int hw_controller_reset(struct ci_hdrc *ci)
  *
  * This function returns an error code
  */
-int hw_device_reset(struct ci_hdrc *ci, u32 mode)
+int hw_device_reset(struct ci_hdrc *ci)
 {
int ret;
 
@@ -440,12 +440,12 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode)
 
/* USBMODE should be configured step by step */
hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
-   hw_write(ci, OP_USBMODE, USBMODE_CM, mode);
+   hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC);
/* HW = 2.3 */
hw_write(ci, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM);
 
-   if (hw_read(ci, OP_USBMODE, USBMODE_CM) != mode) {
-   pr_err(cannot enter in %s mode, ci_role(ci)-name);
+   if (hw_read(ci, OP_USBMODE, USBMODE_CM) != USBMODE_CM_DC) {
+   pr_err(cannot enter in %s device mode, ci_role(ci)-name);
pr_err(lpm = %i, ci-hw_bank.lpm);
return -ENODEV;
}
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 21058ae..e8c936d 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -543,7 +543,7 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
ci_role_start(ci, CI_ROLE_HOST);
} else {
ci_role_stop(ci);
-   hw_device_reset(ci, USBMODE_CM_DC);
+   hw_device_reset(ci);
ci_role_start(ci, CI_ROLE_GADGET);
}
mutex_lock(fsm-lock);
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index bdaa7ba..4fe18ce 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1471,7 +1471,7 @@ static int ci_udc_vbus_session(struct usb_gadget 
*_gadget, int is_active)
if (gadget_ready) {
if (is_active) {
pm_runtime_get_sync(_gadget-dev);
-   hw_device_reset(ci, USBMODE_CM_DC);
+   hw_device_reset(ci);
hw_device_state(ci, ci-ep0out-qh.dma);
usb_gadget_set_state(_gadget, USB_STATE_POWERED);
} else {
@@ -1660,7 +1660,7 @@ static int ci_udc_start(struct usb_gadget *gadget,
pm_runtime_get_sync(ci-gadget.dev);
if (ci-vbus_active) {
spin_lock_irqsave(ci-lock, flags);
-   hw_device_reset(ci, USBMODE_CM_DC);
+   hw_device_reset(ci);
} else {
pm_runtime_put_sync(ci-gadget.dev);
return retval;
-- 
1.9.1

--
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 3/3] usb: chipidea: remove duplicate dev_set_drvdata for host_start

2014-11-16 Thread Peter Chen
The core driver has already done it, besides, move set driver data
operation just after ci has allocated successfully in case some
code (like ci_role_start) want to access this driver data.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/core.c | 2 +-
 drivers/usb/chipidea/host.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index e43be34..de1e4a8 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -669,6 +669,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (!ci)
return -ENOMEM;
 
+   platform_set_drvdata(pdev, ci);
ci-dev = dev;
ci-platdata = dev_get_platdata(dev);
ci-imx28_write_fix = !!(ci-platdata-flags 
@@ -782,7 +783,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
}
}
 
-   platform_set_drvdata(pdev, ci);
ret = devm_request_irq(dev, ci-irq, ci_irq, IRQF_SHARED,
ci-platdata-name, ci);
if (ret)
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 48731d0..c1694cf 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -91,7 +91,6 @@ static int host_start(struct ci_hdrc *ci)
if (!hcd)
return -ENOMEM;
 
-   dev_set_drvdata(ci-dev, ci);
hcd-rsrc_start = ci-hw_bank.phys;
hcd-rsrc_len = ci-hw_bank.size;
hcd-regs = ci-hw_bank.abs;
-- 
1.9.1

--
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 v7 1/2] usb: host: xhci-plat: Get PHYs for xhci's hcds

2014-11-16 Thread Vivek Gautam
Hi,


On Fri, Oct 31, 2014 at 7:21 PM, Sergei Shtylyov
sergei.shtyl...@cogentembedded.com wrote:
 Hello.

 On 10/31/2014 4:26 PM, Vivek Gautam wrote:

 The host controller by itself may sometimes need to handle PHY
 and re-initialize it to re-configure some of the PHY parameters
 to get full support out of the PHY controller.
 Therefore, facilitate getting the two possible PHYs, viz.
 USB 2.0 type (UTMI+) and USB 3.0 type (PIPE3), and initialize them.


 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 ---
   drivers/usb/host/xhci-plat.c |   74
 ++
   1 file changed, 74 insertions(+)


 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index 3d78b0c..5207d5b 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c

 [...]

 @@ -129,10 +130,41 @@ static int xhci_plat_probe(struct platform_device
 *pdev)
 goto put_hcd;
 }

 +   /* Get possile USB 2.0 type PHY (UTMI+) available with xhci */
 +   hcd-phy = devm_phy_get(pdev-dev, usb2-phy);
 +   if (IS_ERR(hcd-phy)) {
 +   ret = PTR_ERR(hcd-phy);
 +   if (ret == -EPROBE_DEFER) {
 +   goto disable_clk;
 +   } else if (ret != -ENOSYS  ret != -ENODEV) {


Asking to be a *switch* statement instead...

Sure, will change this to *switch* statement. That will improve the
readability.


 +   hcd-phy = NULL;
 +   dev_warn(pdev-dev,
 +Error retrieving usb2 phy: %d\n, ret);
 +   }
 +   }
 +

 [...]

 @@ -158,12 +190,41 @@ static int xhci_plat_probe(struct platform_device
 *pdev)
 if (HCC_MAX_PSA(xhci-hcc_params) = 4)
 xhci-shared_hcd-can_do_streams = 1;

 +   /* Get possile USB 3.0 type PHY (PIPE3) available with xhci */
 +   xhci-shared_hcd-phy = devm_phy_get(pdev-dev, usb3-phy);
 +   if (IS_ERR(xhci-shared_hcd-phy)) {
 +   ret = PTR_ERR(xhci-shared_hcd-phy);
 +   if (ret == -EPROBE_DEFER) {
 +   goto put_usb3_hcd;
 +   } else if (ret != -ENOSYS  ret != -ENODEV) {


Likewise...

ok


 +   xhci-shared_hcd-phy = NULL;
 +   dev_warn(pdev-dev,
 +Error retrieving usb3 phy: %d\n, ret);
 +   }
 +   }
 +

 [...]

 @@ -204,6 +271,8 @@ static int xhci_plat_suspend(struct device *dev)
 struct usb_hcd  *hcd = dev_get_drvdata(dev);
 struct xhci_hcd *xhci = hcd_to_xhci(hcd);

 +   phy_exit(hcd-phy);


Hm, in the suspend() method?

phy_exit() should eventually be suspending the PHY and put it to
low power state.
phy_init() in resume() will then take up the task of activating the
PHY again.

phy_power_on() and phy_power_off() are called at xhci_probe() and remove() time.

Does this makes sense ?



-- 
Best Regards
Vivek Gautam
Samsung RD Institute, Bangalore
India
--
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/6] usb: chipidea: add a core function to setup ci_hdrc_platform_data

2014-11-16 Thread Peter Chen
On Fri, Nov 14, 2014 at 04:34:55PM +0100, Antoine Tenart wrote:
 Peter,
 
 On Fri, Nov 14, 2014 at 09:16:55AM +0800, Peter Chen wrote:
  
  Ok, Antoine, I find this patch set may not have many benefits due to
  below reasons:
  - There is already function ci_get_platdata to do the similar things
  - If the PHY can't get from the DT, it will use devm_phy_get or
  devm_usb_get_phy to get, this code has already in core.
  
  I am apologized that I wanted you to do a patch for moving get PHY
  operation to core, it doesn't have many benefits currently
  - For non-dt user, the phy get function has already in core like I said
  above.
  - For dt generic phy user, it uses of_phy_get, the second parameter
  con_id may be different for platforms.
  - For dt usb phy, it uses devm_usb_get_phy_by_phandle, the second
  parameters phandle may be different for platforms.
 
 Ok.
 
  So, please rebase my next tree which your generic phy patch set has
  already in, and send your generic usb2 chipidea patch base on it.
 
 I just rebased my usb2 ci generic driver series and sent it to you and
 to the mailing lists. Since there is not reason from now to delay it, I
 expect it to be merged soon. I wouldn't want to miss yet another release.
 
 Thanks,
 

I hope soon, just your generic phy patch set changed lots of things, and
spent too much time on reviewing.

-- 

Best Regards,
Peter Chen
--
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 v7 1/2] usb: host: xhci-plat: Get PHYs for xhci's hcds

2014-11-16 Thread Vivek Gautam
Hi Felipe,



On Fri, Oct 31, 2014 at 6:56 PM, Vivek Gautam gautam.vi...@samsung.com wrote:
 The host controller by itself may sometimes need to handle PHY
 and re-initialize it to re-configure some of the PHY parameters
 to get full support out of the PHY controller.
 Therefore, facilitate getting the two possible PHYs, viz.
 USB 2.0 type (UTMI+) and USB 3.0 type (PIPE3), and initialize them.

 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 ---
  drivers/usb/host/xhci-plat.c |   74 
 ++
  1 file changed, 74 insertions(+)

 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index 3d78b0c..5207d5b 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c
 @@ -16,6 +16,7 @@
  #include linux/module.h
  #include linux/of.h
  #include linux/platform_device.h
 +#include linux/phy/phy.h
  #include linux/slab.h
  #include linux/usb/xhci_pdriver.h

 @@ -129,10 +130,41 @@ static int xhci_plat_probe(struct platform_device *pdev)
 goto put_hcd;
 }

 +   /* Get possile USB 2.0 type PHY (UTMI+) available with xhci */
 +   hcd-phy = devm_phy_get(pdev-dev, usb2-phy);
 +   if (IS_ERR(hcd-phy)) {
 +   ret = PTR_ERR(hcd-phy);
 +   if (ret == -EPROBE_DEFER) {
 +   goto disable_clk;
 +   } else if (ret != -ENOSYS  ret != -ENODEV) {
 +   hcd-phy = NULL;
 +   dev_warn(pdev-dev,
 +Error retrieving usb2 phy: %d\n, ret);
 +   }
 +   }
 +
 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
 if (ret)
 goto disable_clk;

 +   /*
 +* Initialize and power-on USB 2.0 PHY
 +* FIXME: Isn't this a hacky way of initializing the PHY again ?
 +* xhci's parent would have already initialized the PHY, but we
 +* wanna do it again.
 +*/

Does this change looks anywhere close to what you suggested to
re-initialize PHYs in XHCI even after DWC3 has initialized them once,
in order to avoid adding phy_calibration() callback ? ;-)

 +   hcd-phy-init_count = 0;
 +   ret = phy_init(hcd-phy);
 +   if (ret)
 +   goto dealloc_usb2_hcd;
 +
 +   hcd-phy-power_count = 0;
 +   ret = phy_power_on(hcd-phy);
 +   if (ret) {
 +   phy_exit(hcd-phy);
 +   goto dealloc_usb2_hcd;
 +   }
 +
 device_wakeup_enable(hcd-self.controller);

 /* USB 2.0 roothub is stored in the platform_device now. */
 @@ -158,12 +190,41 @@ static int xhci_plat_probe(struct platform_device *pdev)
 if (HCC_MAX_PSA(xhci-hcc_params) = 4)
 xhci-shared_hcd-can_do_streams = 1;

 +   /* Get possile USB 3.0 type PHY (PIPE3) available with xhci */
 +   xhci-shared_hcd-phy = devm_phy_get(pdev-dev, usb3-phy);
 +   if (IS_ERR(xhci-shared_hcd-phy)) {
 +   ret = PTR_ERR(xhci-shared_hcd-phy);
 +   if (ret == -EPROBE_DEFER) {
 +   goto put_usb3_hcd;
 +   } else if (ret != -ENOSYS  ret != -ENODEV) {
 +   xhci-shared_hcd-phy = NULL;
 +   dev_warn(pdev-dev,
 +Error retrieving usb3 phy: %d\n, ret);
 +   }
 +   }
 +
 ret = usb_add_hcd(xhci-shared_hcd, irq, IRQF_SHARED);
 if (ret)
 goto put_usb3_hcd;

 +   /* Initialize and power-on USB 3.0 PHY */
 +   xhci-shared_hcd-phy-init_count = 0;
 +   ret = phy_init(xhci-shared_hcd-phy);
 +   if (ret)
 +   goto dealloc_usb3_hcd;
 +
 +   xhci-shared_hcd-phy-power_count = 0;
 +   ret = phy_power_on(xhci-shared_hcd-phy);
 +   if (ret) {
 +   phy_exit(xhci-shared_hcd-phy);
 +   goto dealloc_usb3_hcd;
 +   }
 +
 return 0;

 +dealloc_usb3_hcd:
 +   usb_remove_hcd(xhci-shared_hcd);
 +
  put_usb3_hcd:
 usb_put_hcd(xhci-shared_hcd);

 @@ -186,9 +247,15 @@ static int xhci_plat_remove(struct platform_device *dev)
 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 struct clk *clk = xhci-clk;

 +   phy_power_off(xhci-shared_hcd-phy);
 +   phy_exit(xhci-shared_hcd-phy);
 +
 usb_remove_hcd(xhci-shared_hcd);
 usb_put_hcd(xhci-shared_hcd);

 +   phy_power_off(hcd-phy);
 +   phy_exit(hcd-phy);
 +
 usb_remove_hcd(hcd);
 if (!IS_ERR(clk))
 clk_disable_unprepare(clk);
 @@ -204,6 +271,8 @@ static int xhci_plat_suspend(struct device *dev)
 struct usb_hcd  *hcd = dev_get_drvdata(dev);
 struct xhci_hcd *xhci = hcd_to_xhci(hcd);

 +   phy_exit(hcd-phy);
 +
 return xhci_suspend(xhci);
  }

 @@ -211,6 +280,11 @@ static int xhci_plat_resume(struct device *dev)
  {
 struct usb_hcd  *hcd = dev_get_drvdata(dev);
 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 +   int ret;
 +
 +  

Re: [PATCH v7 08/13] usb: chipidea: add a usb2 driver for ci13xxx

2014-11-16 Thread Peter Chen
On Fri, Nov 14, 2014 at 04:25:58PM +0100, Antoine Tenart wrote:
 Add a USB2 ChipIdea driver for ci13xxx, with optional PHY, clock
 and DMA mask, to support USB2 ChipIdea controllers that don't need
 specific functions.
 
 Tested on the Marvell Berlin SoCs USB controllers.
 
 Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com

I remember someone tested it before, you can add his tested-by if you
can find it.

 ---
  drivers/usb/chipidea/Makefile   |   1 +
  drivers/usb/chipidea/ci_hdrc_usb2.c | 117 
 
  2 files changed, 118 insertions(+)
  create mode 100644 drivers/usb/chipidea/ci_hdrc_usb2.c
 
 diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
 index 2f099c7df7b5..1fc86a2ca22d 100644
 --- a/drivers/usb/chipidea/Makefile
 +++ b/drivers/usb/chipidea/Makefile
 @@ -10,6 +10,7 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM)   += otg_fsm.o
  
  # Glue/Bridge layers go here
  
 +obj-$(CONFIG_USB_CHIPIDEA)   += ci_hdrc_usb2.o
  obj-$(CONFIG_USB_CHIPIDEA)   += ci_hdrc_msm.o
  obj-$(CONFIG_USB_CHIPIDEA)   += ci_hdrc_zevio.o
  
 diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c 
 b/drivers/usb/chipidea/ci_hdrc_usb2.c
 new file mode 100644
 index ..15a0947483b8
 --- /dev/null
 +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
 @@ -0,0 +1,117 @@
 +/*
 + * Copyright (C) 2014 Marvell Technology Group Ltd.
 + *
 + * Antoine Tenart antoine.ten...@free-electrons.com
 + *
 + * This file is licensed under the terms of the GNU General Public
 + * License version 2. This program is licensed as is without any
 + * warranty of any kind, whether express or implied.
 + */
 +
 +#include linux/clk.h
 +#include linux/dma-mapping.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/phy/phy.h
 +#include linux/platform_device.h
 +#include linux/usb/chipidea.h
 +#include linux/usb/hcd.h
 +#include linux/usb/ulpi.h
 +
 +#include ci.h
 +
 +struct ci_hdrc_usb2_priv {
 + struct platform_device  *ci_pdev;
 + struct clk  *clk;
 +};
 +
 +static struct ci_hdrc_platform_data ci_default_pdata = {
 + .capoffset  = DEF_CAPOFFSET,
 + .flags  = CI_HDRC_REQUIRE_TRANSCEIVER |
 +   CI_HDRC_DISABLE_STREAMING,
 +};
 +

CI_HDRC_REQUIRE_TRANSCEIVER is deleted, have you rebased my next tree?

 +static int ci_hdrc_usb2_probe(struct platform_device *pdev)
 +{
 + struct device *dev = pdev-dev;
 + struct ci_hdrc_usb2_priv *priv;
 + struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(pdev-dev);

You can dev instead of pdev-dev.

 + int ret;
 +
 + if (!ci_pdata)
 + ci_pdata = ci_default_pdata;
 +
 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 + if (!priv)
 + return -ENOMEM;
 +
 + priv-clk = devm_clk_get(dev, NULL);
 + if (!IS_ERR(priv-clk)) {
 + ret = clk_prepare_enable(priv-clk);
 + if (ret) {
 + dev_err(dev, failed to enable the clock: %d\n, ret);
 + return ret;
 + }
 + }
 +
 + ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
 + if (ret)
 + goto clk_err;
 +
 + ci_pdata-name = dev_name(pdev-dev);
 +
 + priv-ci_pdev = ci_hdrc_add_device(dev, pdev-resource,
 +pdev-num_resources, ci_pdata);
 + if (IS_ERR(priv-ci_pdev)) {
 + ret = PTR_ERR(priv-ci_pdev);
 + if (ret != -EPROBE_DEFER)
 + dev_err(dev,
 + failed to register ci_hdrc platform device: 
 %d\n,
 + ret);
 + goto clk_err;
 + }
 +
 + platform_set_drvdata(pdev, priv);
 +
 + pm_runtime_no_callbacks(dev);
 + pm_runtime_enable(dev);
 +
 + return 0;
 +
 +clk_err:
 + if (!IS_ERR(priv-clk))
 + clk_disable_unprepare(priv-clk);
 + return ret;
 +}
 +
 +static int ci_hdrc_usb2_remove(struct platform_device *pdev)
 +{
 + struct ci_hdrc_usb2_priv *priv = platform_get_drvdata(pdev);
 +
 + pm_runtime_disable(pdev-dev);
 + ci_hdrc_remove_device(priv-ci_pdev);
 + clk_disable_unprepare(priv-clk);
 +
 + return 0;
 +}
 +
 +static const struct of_device_id ci_hdrc_usb2_of_match[] = {
 + { .compatible = chipidea,usb2 },
 + { }
 +};
 +MODULE_DEVICE_TABLE(of, ci_hdrc_usb2_of_match);
 +
 +static struct platform_driver ci_hdrc_usb2_driver = {
 + .probe  = ci_hdrc_usb2_probe,
 + .remove = ci_hdrc_usb2_remove,
 + .driver = {
 + .name   = chipidea-usb2,
 + .owner  = THIS_MODULE,
 + .of_match_table = of_match_ptr(ci_hdrc_usb2_of_match),
 + },
 +};
 +module_platform_driver(ci_hdrc_usb2_driver);
 +
 +MODULE_DESCRIPTION(ChipIdea HDRC USB2 binding for ci13xxx);
 +MODULE_AUTHOR(Antoine Tenart antoine.ten...@free-electrons.com);
 +MODULE_LICENSE(GPL);
 -- 
 2.1.0
 

-- 

Best Regards,
Peter Chen
--
To unsubscribe from 

Re: [PATCH v7 07/13] usb: chipidea: fix phy handling

2014-11-16 Thread Peter Chen
On Fri, Nov 14, 2014 at 04:25:57PM +0100, Antoine Tenart wrote:
 The generic platform device for CI drivers is probed by calling
 ci_hdrc_probe. This is not the same device as the one for the specific
 driver, so the of_node isn't the one we're looking into.
 
 This result in not being able to probe the phys. Since all CI driver are
 retrieving their phys in the specific code, this didn't impact any of
 them yet.
 
 Fixes it using the right of node pointer, by using dev-parent instead
 of dev in phy get functions.

It is a correct fix, but the description need to be refined, it is
not related to of_node or node, it is related child/parent device.

 
 Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
 ---
  drivers/usb/chipidea/core.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index ba0ac2723098..36318c85ad65 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -654,8 +654,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
   } else if (ci-platdata-usb_phy) {
   ci-usb_phy = ci-platdata-usb_phy;
   } else {
 - ci-phy = devm_phy_get(dev, usb-phy);
 - ci-usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 + ci-phy = devm_phy_get(dev-parent, usb-phy);
 + ci-usb_phy = devm_usb_get_phy(dev-parent, USB_PHY_TYPE_USB2);
  
   /* if both generic PHY and USB PHY layers aren't enabled */
   if (PTR_ERR(ci-phy) == -ENOSYS 
 -- 
 2.1.0
 

-- 

Best Regards,
Peter Chen
--
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 v7 09/13] Documentation: bindings: add doc for the USB2 ChipIdea USB driver

2014-11-16 Thread Peter Chen
On Fri, Nov 14, 2014 at 04:25:59PM +0100, Antoine Tenart wrote:
 Document the USB2 ChipIdea driver (ci13xxx) bindings.
 
 Signed-off-by: Antoine Tenart antoine.ten...@free-electrons.com
 ---
  .../devicetree/bindings/usb/ci-hdrc-usb2.txt   | 24 
 ++
  1 file changed, 24 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
 
 diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt 
 b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
 new file mode 100644
 index ..27f8b1e5ee46
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
 @@ -0,0 +1,24 @@
 +* USB2 ChipIdea USB controller for ci13xxx
 +
 +Required properties:
 +- compatible: should be chipidea,usb2
 +- reg: base address and length of the registers
 +- interrupts: interrupt for the USB controller
 +
 +Optional properties:
 +- clocks: reference to the USB clock
 +- phys: reference to the USB PHY
 +- phy-names: should be usb-phy
 +- vbus-supply: reference to the VBUS regulator
 +
 +Example:
 +
 + usb@f7ed {
 + compatible = chipidea,usb2;
 + reg = 0xf7ed 0x1;
 + interrupts = GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH;
 + clocks = chip CLKID_USB0;
 + phys = usb_phy0;
 + phy-names = usb-phy;
 + vbus-supply = reg_usb0_vbus;
 + };
 -- 
 2.1.0
 

Acked-by: Peter Chen peter.c...@freescale.com

-- 

Best Regards,
Peter Chen
--
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