Re: [PATCH v2] usb: host: Faraday fotg210-hcd driver

2013-07-25 Thread Yuan-Hsin Chen
Hi,


On Thu, Jul 25, 2013 at 7:10 AM, Greg KH gre...@linuxfoundation.org wrote:

 On Wed, Jun 19, 2013 at 07:53:04PM +, Yuan-Hsin Chen wrote:
  FOTG210 is an OTG controller which can be configured as an
  USB2.0 host. FOTG210 host is an ehci-like controller with
  some differences. First, register layout of FOTG210 is
  incompatible with EHCI. Furthermore, FOTG210 is lack of
  siTDs which means iTDs are used for both HS and FS ISO
  transfer.
 
  Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com

 As your email now is bouncing, I'm going to revert this patch, I can't
 take a patch for a driver with no active maintainer, sorry.

 If someone else from Faraday will step up and maintain this, that would
 be great, please resend it with your email information.

I see. My ex-colleague who takes over the driver will resend the patch later.

Thanks.

Yuan-Hsin


 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] usb: gadget: fotg210-udc: Use module_platform_driver_probe macro

2013-06-21 Thread Yuan-Hsin Chen
Hi,


On Thu, Jun 20, 2013 at 8:16 PM, Felipe Balbi ba...@ti.com wrote:

 Hi,

 On Thu, Jun 20, 2013 at 01:53:13PM +, Yuan-Hsin Chen wrote:
  Because fotg210-udc is configured as a non-hotpluggable device,
  that makes sense to use module_platform_driver_probe() instead of
  module_platform_driver(). This also fixes the section mismatch issue.
 
  Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com

 I would rather see you remove __init annotation from your probe()
 function. The reason being that it will users to bind/unbind the driver
 through sysfs, which is pretty good for testing, at least.

I see and will send a patch later. Thanks.

Yuan-Hsin



 --
 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] usb: host: Faraday fotg210-hcd driver

2013-06-17 Thread Yuan-Hsin Chen
Hi,

On Tue, Jun 18, 2013 at 4:39 AM, Greg KH gre...@linuxfoundation.org wrote:
 On Wed, Jun 05, 2013 at 05:15:43PM +, Yuan-Hsin Chen wrote:
 FOTG210 is an OTG controller which can be configured as an
 USB2.0 host. FOTG210 host is an ehci-like controller with
 some differences. First, register layout of FOTG210 is
 incompatible with EHCI. Furthermore, FOTG210 is lack of
 siTDs which means iTDs are used for both HS and FS ISO
 transfer.

 Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com
 ---
  drivers/usb/Makefile   |1 +
  drivers/usb/host/Kconfig   |   12 +
  drivers/usb/host/Makefile  |1 +
  drivers/usb/host/fotg210-hcd.c | 5967 
 
  drivers/usb/host/fotg210.h |  746 +
  5 files changed, 6727 insertions(+), 0 deletions(-)
  create mode 100644 drivers/usb/host/fotg210-hcd.c
  create mode 100644 drivers/usb/host/fotg210.h

 You obviously didn't even run this through checkpatch.pl, did you?

 $ ./scripts/checkpatch.pl --terse ../usb.mbox | tail -n 1
 total: 138 errors, 618 warnings, 6742 lines checked

 Please fix all of these if you wish us to at least start reviewing the
 patch.  Your internal Q/A should have caught this first, please be more
 careful in the future.


Actually I did run checkpatch.pl and found that almost all errors and
warnings are from ehci core (ehci-hcd.c, ehci-hub.c and so on) where
my driver borrowed most of code.

$ ./scripts/checkpatch.pl --terse -f drivers/usb/host/ehci-hub.c | tail -n 1
total: 18 errors, 69 warnings, 1138 lines checked

$ ./scripts/checkpatch.pl --terse -f drivers/usb/host/ehci-hcd.c | tail -n 1
total: 17 errors, 78 warnings, 1403 lines checked

So you're saying that I should fix them, is that right?

thanks,

Yuan-Hsin

 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] usb: host: Faraday fotg210-hcd driver

2013-06-17 Thread Yuan-Hsin Chen
Hi,

On Tue, Jun 18, 2013 at 11:07 AM, Sarah Sharp
sarah.a.sh...@linux.intel.com wrote:
 On Tue, Jun 18, 2013 at 10:42:09AM +0800, Yuan-Hsin Chen wrote:
 Hi,

 On Tue, Jun 18, 2013 at 4:39 AM, Greg KH gre...@linuxfoundation.org wrote:
  On Wed, Jun 05, 2013 at 05:15:43PM +, Yuan-Hsin Chen wrote:
  FOTG210 is an OTG controller which can be configured as an
  USB2.0 host. FOTG210 host is an ehci-like controller with
  some differences. First, register layout of FOTG210 is
  incompatible with EHCI. Furthermore, FOTG210 is lack of
  siTDs which means iTDs are used for both HS and FS ISO
  transfer.
 
  Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com
  ---
   drivers/usb/Makefile   |1 +
   drivers/usb/host/Kconfig   |   12 +
   drivers/usb/host/Makefile  |1 +
   drivers/usb/host/fotg210-hcd.c | 5967 
  
   drivers/usb/host/fotg210.h |  746 +
   5 files changed, 6727 insertions(+), 0 deletions(-)
   create mode 100644 drivers/usb/host/fotg210-hcd.c
   create mode 100644 drivers/usb/host/fotg210.h
 
  You obviously didn't even run this through checkpatch.pl, did you?
 
  $ ./scripts/checkpatch.pl --terse ../usb.mbox | tail -n 1
  total: 138 errors, 618 warnings, 6742 lines checked
 
  Please fix all of these if you wish us to at least start reviewing the
  patch.  Your internal Q/A should have caught this first, please be more
  careful in the future.
 

 Actually I did run checkpatch.pl and found that almost all errors and
 warnings are from ehci core (ehci-hcd.c, ehci-hub.c and so on) where
 my driver borrowed most of code.

 $ ./scripts/checkpatch.pl --terse -f drivers/usb/host/ehci-hub.c | tail -n 1
 total: 18 errors, 69 warnings, 1138 lines checked

 $ ./scripts/checkpatch.pl --terse -f drivers/usb/host/ehci-hcd.c | tail -n 1
 total: 17 errors, 78 warnings, 1403 lines checked

 So you're saying that I should fix them, is that right?

 In that case, no, you should be figuring out how to refactor and reuse
 the EHCI code instead of copying it straight into your driver.

I was trying to use ehci-platform.c, anonymous union/struct, and quirk
flags to avoid copying EHCI code.
But there are too big incompatibilities between fotg210/fusbh200
controller and EHCI.
That's why Alan agreed that I could create a stand-alone driver for
fusbh200 host controller.
Since fotg210 and fusbh200 have the same issue,  fotg210 hcd is
supposed to be stand-alone.
More details please refer to mail sequence
http://www.spinics.net/lists/linux-usb/msg83812.html

Thanks,

Yuan-Hsin


 Sarah Sharp
--
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: gadget: add Faraday fotg210_udc driver

2013-05-29 Thread Yuan-Hsin Chen
Hi,

On Thu, May 30, 2013 at 7:55 AM, Felipe Balbi ba...@ti.com wrote:
 Hi,

 On Wed, May 29, 2013 at 06:31:50PM +, Yuan-Hsin Chen wrote:
 Faraday fotg210 udc driver supports only Bulk transfer so far.
 fotg210 could be configured as an USB2.0 peripheral.

 This driver is tested with mass storage gadget driver on Faraday
 EVB a369.

 Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com

 Run through checkpatch.pl --strict and fix all errors, warnings and all
 checks which make sense.

 WARNING: please write a paragraph that describes the config symbol fully
 #81: FILE: drivers/usb/gadget/Kconfig:196:
 +config USB_FOTG210_UDC

 CHECK: braces {} should be used on all arms of this statement
 #183: FILE: drivers/usb/gadget/fotg210-udc.c:76:
 +   if (ep-epnum) {
 [...]
 +   } else
 [...]

 WARNING: line over 80 characters
 #190: FILE: drivers/usb/gadget/fotg210-udc.c:83:
 +static void fotg210_fifo_ep_mapping(struct fotg210_ep *ep, u32 epnum, u32 
 dir_in)

 WARNING: line over 80 characters
 #237: FILE: drivers/usb/gadget/fotg210-udc.c:130:
 +static void fotg210_set_mps(struct fotg210_ep *ep, u32 epnum, u32 mps, u32 
 dir_in)

 WARNING: line over 80 characters
 #241: FILE: drivers/usb/gadget/fotg210-udc.c:134:
 +   u32 offset = dir_in ? FOTG210_INEPMPSR(epnum) : 
 FOTG210_OUTEPMPSR(epnum);

 WARNING: line over 80 characters
 #349: FILE: drivers/usb/gadget/fotg210-udc.c:242:
 +static void fotg210_ep_free_request(struct usb_ep *_ep, struct usb_request 
 *_req)

 WARNING: Avoid CamelCase: DMATFNR_ACC_Fn
 #372: FILE: drivers/usb/gadget/fotg210-udc.c:265:
 +   value |= DMATFNR_ACC_Fn(ep-epnum - 1);

 WARNING: line over 80 characters
 #418: FILE: drivers/usb/gadget/fotg210-udc.c:311:
 +   value = ioread32(ep-fotg210-reg + FOTG210_FIBCR(ep-epnum - 
 1));

 WARNING: line over 80 characters
 #420: FILE: drivers/usb/gadget/fotg210-udc.c:313:
 +   iowrite32(value, ep-fotg210-reg + FOTG210_FIBCR(ep-epnum - 
 1));

 WARNING: line over 80 characters
 #441: FILE: drivers/usb/gadget/fotg210-udc.c:334:
 +   length = ioread32(ep-fotg210-reg + 
 FOTG210_FIBCR(ep-epnum - 1));

 WARNING: Avoid CamelCase: FIBCR_BCFx
 #442: FILE: drivers/usb/gadget/fotg210-udc.c:335:
 +   length = FIBCR_BCFx;

 WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then 
 pr_debug(...  to printk(KERN_DEBUG ...
 #456: FILE: drivers/usb/gadget/fotg210-udc.c:349:
 +   printk(KERN_DEBUG dma_mapping_error\n);

 CHECK: Alignment should match open parenthesis
 #461: FILE: drivers/usb/gadget/fotg210-udc.c:354:
 +   dma_sync_single_for_device(NULL, d, length,
 +   ep-dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);

 WARNING: line over 80 characters
 #476: FILE: drivers/usb/gadget/fotg210-udc.c:369:
 +static void fotg210_ep0_queue(struct fotg210_ep *ep, struct fotg210_request 
 *req)

 CHECK: braces {} should be used on all arms of this statement
 #483: FILE: drivers/usb/gadget/fotg210-udc.c:376:
 +   if (req-req.length) {
 [...]
 +   } else
 [...]

 WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then 
 pr_debug(...  to printk(KERN_DEBUG ...
 #486: FILE: drivers/usb/gadget/fotg210-udc.c:379:
 +   printk(KERN_DEBUG %s : req-req.length = 0x%x\n,

 CHECK: Alignment should match open parenthesis
 #487: FILE: drivers/usb/gadget/fotg210-udc.c:380:
 +   printk(KERN_DEBUG %s : req-req.length = 0x%x\n,
 +   __func__, req-req.length);

 CHECK: braces {} should be used on all arms of this statement
 #492: FILE: drivers/usb/gadget/fotg210-udc.c:385:
 +   if (!req-req.length)
 [...]
 +   else {
 [...]

 WARNING: line over 80 characters
 #495: FILE: drivers/usb/gadget/fotg210-udc.c:388:
 +   u32 value = ioread32(ep-fotg210-reg + 
 FOTG210_DMISGR0);

 WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then 
 pr_debug(...  to printk(KERN_DEBUG ...
 #680: FILE: drivers/usb/gadget/fotg210-udc.c:573:
 +   printk(KERN_DEBUG 0x%x\n, data);

 WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then 
 pr_debug(...  to printk(KERN_DEBUG ...
 #691: FILE: drivers/usb/gadget/fotg210-udc.c:584:
 +   printk(KERN_DEBUG 0x%x\n, data);

 WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then 
 pr_debug(...  to printk(KERN_DEBUG ...
 #696: FILE: drivers/usb/gadget/fotg210-udc.c:589:
 +   printk(KERN_DEBUG 0x%x\n, data);

 WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then 
 pr_debug(...  to printk(KERN_DEBUG ...
 #702: FILE: drivers/usb/gadget/fotg210-udc.c:595:
 +   printk(KERN_DEBUG 0x%x\n, data);

 WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then 
 pr_debug(...  to printk(KERN_DEBUG ...
 #741: FILE: drivers/usb/gadget/fotg210-udc.c:634:
 +   printk(KERN_DEBUG request error!!\n

Re: [PATCH 2/2] usb: host: fusbh200-hcd: Staticize local symbols

2013-05-20 Thread Yuan-Hsin Chen
Hi,

On Mon, May 20, 2013 at 1:51 PM, Sachin Kamat sachin.ka...@linaro.org wrote:
 Local symbols referenced only in this file are made static.

 Signed-off-by: Sachin Kamat sachin.ka...@linaro.org

Thank you.

 ---
  drivers/usb/host/fusbh200-hcd.c |6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

 diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
 index b17dd3f..0855ca4 100644
 --- a/drivers/usb/host/fusbh200-hcd.c
 +++ b/drivers/usb/host/fusbh200-hcd.c
 @@ -5769,7 +5769,7 @@ static const struct hc_driver 
 fusbh200_fusbh200_hc_driver = {
 .clear_tt_buffer_complete = fusbh200_clear_tt_buffer_complete,
  };

 -void fusbh200_init(struct fusbh200_hcd *fusbh200)
 +static void fusbh200_init(struct fusbh200_hcd *fusbh200)
  {
 u32 reg;

 @@ -5895,7 +5895,7 @@ fail_create_hcd:
   * the HCD's stop() method.  It is always called from a thread
   * context, normally rmmod, apmd, or something similar.
   */
 -int fusbh200_hcd_fusbh200_remove(struct platform_device *pdev)
 +static int fusbh200_hcd_fusbh200_remove(struct platform_device *pdev)
  {
 struct device *dev  = pdev-dev;
 struct usb_hcd *hcd = dev_get_drvdata(dev);
 @@ -5911,7 +5911,7 @@ int fusbh200_hcd_fusbh200_remove(struct platform_device 
 *pdev)
 return 0;
  }

 -struct platform_driver fusbh200_hcd_fusbh200_driver = {
 +static struct platform_driver fusbh200_hcd_fusbh200_driver = {
 .driver = {
 .name   = fusbh200,
 },
 --
 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
--
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: host: fusbh200-hcd: Staticize local symbols

2013-05-20 Thread Yuan-Hsin Chen
On Mon, May 20, 2013 at 1:51 PM, Sachin Kamat sachin.ka...@linaro.org wrote:
 Local symbols referenced only in this file are made static.

 Signed-off-by: Sachin Kamat sachin.ka...@linaro.org

Acked-by: Yuan-Hsin Chen yhc...@faraday-tech.com

 ---
  drivers/usb/host/fusbh200-hcd.c |6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

 diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
 index b17dd3f..0855ca4 100644
 --- a/drivers/usb/host/fusbh200-hcd.c
 +++ b/drivers/usb/host/fusbh200-hcd.c
 @@ -5769,7 +5769,7 @@ static const struct hc_driver 
 fusbh200_fusbh200_hc_driver = {
 .clear_tt_buffer_complete = fusbh200_clear_tt_buffer_complete,
  };

 -void fusbh200_init(struct fusbh200_hcd *fusbh200)
 +static void fusbh200_init(struct fusbh200_hcd *fusbh200)
  {
 u32 reg;

 @@ -5895,7 +5895,7 @@ fail_create_hcd:
   * the HCD's stop() method.  It is always called from a thread
   * context, normally rmmod, apmd, or something similar.
   */
 -int fusbh200_hcd_fusbh200_remove(struct platform_device *pdev)
 +static int fusbh200_hcd_fusbh200_remove(struct platform_device *pdev)
  {
 struct device *dev  = pdev-dev;
 struct usb_hcd *hcd = dev_get_drvdata(dev);
 @@ -5911,7 +5911,7 @@ int fusbh200_hcd_fusbh200_remove(struct platform_device 
 *pdev)
 return 0;
  }

 -struct platform_driver fusbh200_hcd_fusbh200_driver = {
 +static struct platform_driver fusbh200_hcd_fusbh200_driver = {
 .driver = {
 .name   = fusbh200,
 },
 --
 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
--
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 host: Faraday USB2.0 FUSBH200-HCD driver

2013-05-08 Thread Yuan-Hsin Chen
Hi,

On Wed, May 8, 2013 at 10:40 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Wed, 8 May 2013, Yuan-Hsin Chen wrote:

 Hi,

 Are there any advice?
 Thanks.

 On Fri, Apr 26, 2013 at 5:37 PM, Yuan-Hsin Chen yuan...@gmail.com wrote:
  FUSBH200-HCD is an USB2.0 hcd for Faraday FUSBH200.
  FUSBH200 is an ehci-like controller with some differences.
  First, register layout of FUSBH200 is incompatible with EHCI.
  Furthermore, FUSBH200 is lack of siTDs which means iTDs
  are used for both HS and FS ISO transfer.

 As far as I'm concerned, this can be merged.

Thanks for your great help.


 Alan Stern


Yuan-Hsin
--
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: gadget: fusb300_udc: add FUSB300_EPSET0_STL_CLR for clearing EP0 stall

2013-04-02 Thread Yuan-Hsin Chen
The final version of fusb300 controller adds EPSET0_STL_CLR
for clearing EP0 stall and also removes EPSET0_EPn_TX0BYTE.

fusb300_udc driver is tested on FARADAY platform a369 with
FUSB300 FPGA v1.8

Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com
---

v2:
split patch

 drivers/usb/gadget/fusb300_udc.c |2 +-
 drivers/usb/gadget/fusb300_udc.h |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c
index 72cd5e6..c20cc58 100644
--- a/drivers/usb/gadget/fusb300_udc.c
+++ b/drivers/usb/gadget/fusb300_udc.c
@@ -394,7 +394,7 @@ static void fusb300_clear_epnstall(struct fusb300 *fusb300, 
u8 ep)
 
if (reg  FUSB300_EPSET0_STL) {
printk(KERN_DEBUG EP%d stall... Clear!!\n, ep);
-   reg = ~FUSB300_EPSET0_STL;
+   reg |= FUSB300_EPSET0_STL_CLR;
iowrite32(reg, fusb300-reg + FUSB300_OFFSET_EPSET0(ep));
}
 }
diff --git a/drivers/usb/gadget/fusb300_udc.h b/drivers/usb/gadget/fusb300_udc.h
index 542cd83..ccae1b5 100644
--- a/drivers/usb/gadget/fusb300_udc.h
+++ b/drivers/usb/gadget/fusb300_udc.h
@@ -111,8 +111,8 @@
 /*
  * * EPn Setting 0 (EPn_SET0, offset = 020H+(n-1)*30H, n=1~15 )
  * */
+#define FUSB300_EPSET0_STL_CLR (1  3)
 #define FUSB300_EPSET0_CLRSEQNUM   (1  2)
-#define FUSB300_EPSET0_EPn_TX0BYTE (1  1)
 #define FUSB300_EPSET0_STL (1  0)
 
 /*
-- 
1.7.4.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/2] usb: gadget: fusb300_udc: bug fix of not doing idma reset for each time

2013-04-02 Thread Yuan-Hsin Chen
Enter IDMA_RESET only when the controller has been reset or
the device has been plugged in to or out from a host. In
IDMA_RESET, we should disable the corresponding PRD interrupt.
Also there is a redundant space eliminated.

fusb300_udc driver is tested on FARADAY platform a369 with
FUSB300 FPGA v1.8

Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com
---

v2:
split patch

 drivers/usb/gadget/fusb300_udc.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c
index c20cc58..c4dc906 100644
--- a/drivers/usb/gadget/fusb300_udc.c
+++ b/drivers/usb/gadget/fusb300_udc.c
@@ -930,12 +930,15 @@ static void fusb300_wait_idma_finished(struct fusb300_ep 
*ep)
 
fusb300_clear_int(ep-fusb300, FUSB300_OFFSET_IGR0,
FUSB300_IGR0_EPn_PRD_INT(ep-epnum));
+   return;
+
 IDMA_RESET:
-   fusb300_clear_int(ep-fusb300, FUSB300_OFFSET_IGER0,
-   FUSB300_IGER0_EEPn_PRD_INT(ep-epnum));
+   reg = ioread32(ep-fusb300-reg + FUSB300_OFFSET_IGER0);
+   reg = ~FUSB300_IGER0_EEPn_PRD_INT(ep-epnum);
+   iowrite32(reg, ep-fusb300-reg + FUSB300_OFFSET_IGER0);
 }
 
-static void  fusb300_set_idma(struct fusb300_ep *ep,
+static void fusb300_set_idma(struct fusb300_ep *ep,
struct fusb300_request *req)
 {
dma_addr_t d;
-- 
1.7.4.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] usb host: Faraday FUSBH200 HCD driver

2013-04-01 Thread Yuan-Hsin Chen
FUSBH200 is an ehci-like controller with some differences.
First, register layout of FUSBH200 is incompatible with EHCI.
We use a quirk flag and modify struct ehci_regs with anonymous
union and struct to make sure driver of FUSBH200 and EHCI could
coexist. Furthermore, FUSBH200 is lack of siTDs which means iTDs
are used for both HS and FS ISO transfer.

Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com
---

Note that anonymous union and struct might not be supported
in earlier version of gcc

v2:
use ehci-platform.c
use anonymous union and struct
add is_fusbh200 to struct ehci_hcd

 drivers/usb/host/Kconfig |9 ++
 drivers/usb/host/ehci-fusbh200.c |  223 ++
 drivers/usb/host/ehci-hcd.c  |   18 +++-
 drivers/usb/host/ehci-hub.c  |   30 +++---
 drivers/usb/host/ehci-mem.c  |3 +-
 drivers/usb/host/ehci-sched.c|   33 --
 drivers/usb/host/ehci.h  |   27 +-
 include/linux/usb/ehci_def.h |   58 +++---
 8 files changed, 351 insertions(+), 50 deletions(-)
 create mode 100644 drivers/usb/host/ehci-fusbh200.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3f1431d..42b8768 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -157,6 +157,15 @@ config USB_EHCI_HCD_OMAP
  Enables support for the on-chip EHCI controller on
  OMAP3 and later chips.
 
+config USB_EHCI_HCD_FUSBH200
+   bool Faraday FUSBH200 HCD support
+   depends on USB_EHCI_HCD  ARCH_FARADAY
+   select USB_EHCI_ROOT_HUB_TT
+   default y
+   ---help---
+ The USB HCD Driver of Faraday FUSBH200 is designed to
+ meet USB2.0 EHCI specification with minor modification
+
 config USB_EHCI_MSM
bool Support for MSM on-chip EHCI USB controller
depends on USB_EHCI_HCD  ARCH_MSM
diff --git a/drivers/usb/host/ehci-fusbh200.c b/drivers/usb/host/ehci-fusbh200.c
new file mode 100644
index 000..1d5fd14
--- /dev/null
+++ b/drivers/usb/host/ehci-fusbh200.c
@@ -0,0 +1,223 @@
+/*
+ * ehci-fusbh200.c - driver for Faraday USB2.0 Host FUSBH200
+ *
+ * Copyright (c) 2013 Yuan-Hsin Chen yhchen@faraday-tech
+ * Copyright (c) 2013 Po-Yu Chuang ratbert.chu...@gmail.com
+ * Copyright (c) 2010-2012 Feng-Hsin Chiang john453@faraday-tech
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include linux/platform_device.h
+
+static const struct hc_driver ehci_fusbh200_hc_driver = {
+   .description= hcd_name,
+   .product_desc   = Faraday USB2.0 Host Controller,
+   .hcd_priv_size  = sizeof(struct ehci_hcd),
+
+   /*
+* generic hardware linkage
+*/
+   .irq= ehci_irq,
+   .flags  = HCD_MEMORY | HCD_USB2,
+
+   /*
+* basic lifecycle operations
+*/
+   .reset  = ehci_init,
+   .start  = ehci_run,
+   .stop   = ehci_stop,
+   .shutdown   = ehci_shutdown,
+
+   /*
+* managing i/o requests and associated device resources
+*/
+   .urb_enqueue= ehci_urb_enqueue,
+   .urb_dequeue= ehci_urb_dequeue,
+   .endpoint_disable   = ehci_endpoint_disable,
+   .endpoint_reset = ehci_endpoint_reset,
+
+   /*
+* scheduling support
+*/
+   .get_frame_number   = ehci_get_frame,
+
+   /*
+* root hub support
+*/
+   .hub_status_data= ehci_hub_status_data,
+   .hub_control= ehci_hub_control,
+   .bus_suspend= ehci_bus_suspend,
+   .bus_resume = ehci_bus_resume,
+
+   .relinquish_port= ehci_relinquish_port,
+   .port_handed_over   = ehci_port_handed_over,
+
+   .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
+};
+
+void fusbh200_init(struct ehci_hcd *ehci)
+{
+   u32 reg;
+
+   reg = ehci_readl(ehci, ehci-regs-bmcsr);
+   reg |= BMCSR_INT_POLARITY;
+   reg = ~BMCSR_VBUS_OFF;
+   ehci_writel(ehci, reg, ehci-regs-bmcsr);
+
+   reg = ehci_readl(ehci, ehci-regs-bmier);
+   ehci_writel(ehci, reg | BMIER_OVC_EN | BMIER_VBUS_ERR_EN,
+   ehci-regs-bmier);
+}
+
+/**
+ * ehci_hcd_fusbh200_probe - initialize faraday

Re: [PATCH] usb host: Faraday FUSBH200 HCD driver.

2013-03-21 Thread Yuan-Hsin Chen
Hi,

On Wed, Mar 20, 2013 at 10:26 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Wed, 20 Mar 2013, Yuan-Hsin Chen wrote:

 Hi,

 On Tue, Mar 19, 2013 at 11:48 PM, Alan Stern st...@rowland.harvard.edu 
 wrote:
  On Tue, 19 Mar 2013, Yuan-Hsin Chen wrote:
 
   What about the port_status registers?  They're not between command and
   async_next.  If they aren't consistent with EHCI, it makes things a lot
   more complicated.
 
  fusbh200 has only one port_status register with different offset,
  0x30, and the position of some bits are different from EHCI.

 How about adding kernel configuration to adjust offset for FUSBH200 in
 ehci_def.h? So port_status would be in offset 0x20 from ehci_regs.

 For example,

 /* ASYNCLISTADDR: offset 0x18 */
 u32 async_next; /* address of next async queue head 
 */

 #ifndef CONFIG_USB_EHCI_HCD_FUSBH200
 u32 reserved1[2];

 /* TXFILLTUNING: offset 0x24 */
 u32 txfill_tuning;  /* TX FIFO Tuning register */
 #define TXFIFO_DEFAULT  (816) /* FIFO burst threshold 8 */

 u32 reserved2[6];

 /* CONFIGFLAG: offset 0x40 */
 u32 configured_flag;
 #define FLAG_CF (10)  /* true: we'll support high speed 
 */

 #else
 u32 reserved1;
 #endif
 /* PORTSC: offset 0x44 */
 u32 port_status[0]; /* up to N_PORTS */

 This is acceptable _only_ if it is not possible to use an FUSBH200
 controller in the same computer as a normal EHCI controller.

 Furthermore, there are PORT_POWER, PORT_OWNER, PORT_LED_XXX,
 PORT_TEST, PORT_WKCONN_E, PORT_WKDISC_E, PORT_WKOC_E absent in
 port_status of FUSBH200. Also PORT_OC and PORT_OCC are in another
 register. Is it ok to use quirk flag also?

 Yes, those can be handled by a quirk flag.  Does the FUSBH200 have a
 built-in Transaction Translator?

Yes, the FUSBH200 has built-in Transaction Translator.

I will modify the driver based on what we discussed before and re-submit it.
Thank you for your time.


 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] usb host: Faraday FUSBH200 HCD driver.

2013-03-20 Thread Yuan-Hsin Chen
Hi,

On Tue, Mar 19, 2013 at 11:48 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Tue, 19 Mar 2013, Yuan-Hsin Chen wrote:

  What about the port_status registers?  They're not between command and
  async_next.  If they aren't consistent with EHCI, it makes things a lot
  more complicated.

 fusbh200 has only one port_status register with different offset,
 0x30, and the position of some bits are different from EHCI.

How about adding kernel configuration to adjust offset for FUSBH200 in
ehci_def.h? So port_status would be in offset 0x20 from ehci_regs.

For example,

/* ASYNCLISTADDR: offset 0x18 */
u32 async_next; /* address of next async queue head */

#ifndef CONFIG_USB_EHCI_HCD_FUSBH200
u32 reserved1[2];

/* TXFILLTUNING: offset 0x24 */
u32 txfill_tuning;  /* TX FIFO Tuning register */
#define TXFIFO_DEFAULT  (816) /* FIFO burst threshold 8 */

u32 reserved2[6];

/* CONFIGFLAG: offset 0x40 */
u32 configured_flag;
#define FLAG_CF (10)  /* true: we'll support high speed */

#else
u32 reserved1;
#endif
/* PORTSC: offset 0x44 */
u32 port_status[0]; /* up to N_PORTS */


Furthermore, there are PORT_POWER, PORT_OWNER, PORT_LED_XXX,
PORT_TEST, PORT_WKCONN_E, PORT_WKDISC_E, PORT_WKOC_E absent in
port_status of FUSBH200. Also PORT_OC and PORT_OCC are in another
register. Is it ok to use quirk flag also?


 That's pretty nasty.  Integrating that with the standard EHCI driver
 would be considerably more difficult.

 Why was the FUSBH200 designed in this strange way?  Why doesn't it use
 the standard EHCI register layout?  Were the engineers at Faraday
 deliberately trying to make life harder for driver writers?

 Also, usbmode_ex, hostpc, and txfill_tuning other than configured_flag
 are non-existent in fusbh200. They are used in both ehci-hcd.c and
 ehci-hub.c for several times.

 They are used only if the hardware supports them, that is, only if the
 ehci-has_hostpc flag is set.

 Alan Stern


Thank you for your help.

Yuan-Hsin
--
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 host: Faraday FUSBH200 HCD driver.

2013-03-19 Thread Yuan-Hsin Chen
Hi,

On Mon, Mar 18, 2013 at 10:16 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Mon, 18 Mar 2013, Felipe Balbi wrote:

 On Mon, Mar 18, 2013 at 06:06:18PM +0800, Yuan-Hsin Chen wrote:
  Hi,
 
  I tried to modify fusbh200 hcd driver following ehci-platform.c.
  However, the register definition of fusbh200 is partially incompatible
  to ehci. For fusbh200, only the elements between command and
  async_next in struct ehci_regs are consistent with ehci which means

 What about the port_status registers?  They're not between command and
 async_next.  If they aren't consistent with EHCI, it makes things a lot
 more complicated.

fusbh200 has only one port_status register with different offset,
0x30, and the position of some bits are different from EHCI.


  it would cause copious modification and duplication of ehci hcd
  driver. For example, there is no configured_flag register in
  fusbh200 controller, yet, ehci hcd driver accesses configured_flag
  in function ehci_run which would cause compile errors. Therefore,
  maybe my first patch which refers to oxu210hp-hcd is a better
  solution?

 why don't you just add a quirk flag to ehci struct so that it knows it
 shouldn't access CONFIGFLAG register when that's non-existent ?

Also, usbmode_ex, hostpc, and txfill_tuning other than configured_flag
are non-existent in fusbh200. They are used in both ehci-hcd.c and
ehci-hub.c for several times.


 There are only 5 uses of configured_flag in ehci-hcd.c, so it should be
 easy to wrap that around a flag check.

 Two of those uses turn configured_flag on and two of them turn it off.
 However, one of the uses tests its value (the first one in
 ehci_resume).  How would that be handled if configured_flag doesn't
 exist?

 Alan, would you have a better idea ? Looks like this is a non-standard
 EHCI implementation.

 Yes, it does.  If all we need is to protect four or five accesses with
 a quirk flag, that's okay with me.

Thanks for your time.


 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] usb host: Faraday FUSBH200 HCD driver.

2013-03-19 Thread Yuan-Hsin Chen
On Tue, Mar 19, 2013 at 11:48 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Tue, 19 Mar 2013, Yuan-Hsin Chen wrote:

  What about the port_status registers?  They're not between command and
  async_next.  If they aren't consistent with EHCI, it makes things a lot
  more complicated.

 fusbh200 has only one port_status register with different offset,
 0x30, and the position of some bits are different from EHCI.

 That's pretty nasty.  Integrating that with the standard EHCI driver
 would be considerably more difficult.

 Why was the FUSBH200 designed in this strange way?  Why doesn't it use
 the standard EHCI register layout?  Were the engineers at Faraday
 deliberately trying to make life harder for driver writers?

Since FUSBH200 was designed more than eight years ago, the engineers
responsible for FUSBH200 are no longer working for Faraday. I have the
same question as you, but no one here could answer it. The strange
register layout and other implementation incompatible with EHCI are
the reasons why the FUSBH200 driver was not tried to submit to
mainline in the past.


 Also, usbmode_ex, hostpc, and txfill_tuning other than configured_flag
 are non-existent in fusbh200. They are used in both ehci-hcd.c and
 ehci-hub.c for several times.

 They are used only if the hardware supports them, that is, only if the
 ehci-has_hostpc flag is set.

 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] usb host: Faraday FUSBH200 HCD driver.

2013-03-18 Thread Yuan-Hsin Chen
Hi,

I tried to modify fusbh200 hcd driver following ehci-platform.c.
However, the register definition of fusbh200 is partially incompatible
to ehci. For fusbh200, only the elements between command and
async_next in struct ehci_regs are consistent with ehci which means
it would cause copious modification and duplication of ehci hcd
driver. For example, there is no configured_flag register in
fusbh200 controller, yet, ehci hcd driver accesses configured_flag
in function ehci_run which would cause compile errors. Therefore,
maybe my first patch which refers to oxu210hp-hcd is a better
solution?

Thanks for your time.

Yuan-Hsin


On Thu, Feb 7, 2013 at 11:03 AM, Yuan-Hsin Chen yuan...@gmail.com wrote:
 On Thu, Feb 7, 2013 at 12:38 AM, Felipe Balbi ba...@ti.com wrote:
 On Wed, Feb 06, 2013 at 07:24:01PM +0800, Yuan-Hsin Chen wrote:
 From: Yuan-Hsin Chen yhc...@faraday-tech.com

 USB2.0 HCD driver for Faraday FUSBH200

 Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com

 just use ehci-platform.c and avoid the duplication

 --
 balbi

 Thanks for your advice. I will modify and re-submit it later.

 Yuan-Hsin
--
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] fusb300_udc: modify stall clear and idma reset procedure

2013-03-04 Thread Yuan-Hsin Chen
Hi,

On Wed, Feb 27, 2013 at 1:59 AM, Felipe Balbi ba...@ti.com wrote:
 Hi,

 On Fri, Feb 22, 2013 at 07:09:39AM +, Yuan-Hsin Chen wrote:
 From: Yuan-Hsin Chen yuan...@gmail.com

 Due to fusb300 controller modification, stall clear procedure should be
 modified consistantly. This patch also fixes software bugs: only
 enter IDMA_RESET when the condition matched and disable corresponding
 PRD interrupt in IDMA_RESET.


 Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com

 I have been trying to understand if this is a bug fix or if it can wait
 until v3.10.

There are a software bug fix and two corresponding fixes to hw register
 modification in the patch. Should it wait until v3.10?

 Also, according to your commit log, it seems like this patch is doing
 more than one thing, which is really frowned upon. Please split it up
 into separate logically self-contained changes. While doing that, make
 sure that your commit log explains the problem and the solution very
 well. Saying that because of a controller modification you need to
 change stall clear consistently isn't enough.

I will split it up and explain more clearly.
Thanks.

 Don't forget to mention how and with which platforms you tested.

 --
 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] fusb300_udc: modify stall clear and idma reset procedure

2013-02-21 Thread Yuan-Hsin Chen
From: Yuan-Hsin Chen yuan...@gmail.com

Due to fusb300 controller modification, stall clear procedure should be
modified consistantly. This patch also fixes software bugs: only
enter IDMA_RESET when the condition matched and disable corresponding
PRD interrupt in IDMA_RESET.


Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com
---
 drivers/usb/gadget/fusb300_udc.c |9 ++---
 drivers/usb/gadget/fusb300_udc.h |2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c
index 72cd5e6..109cab1 100644
--- a/drivers/usb/gadget/fusb300_udc.c
+++ b/drivers/usb/gadget/fusb300_udc.c
@@ -394,7 +394,7 @@ static void fusb300_clear_epnstall(struct fusb300 *fusb300, 
u8 ep)
 
if (reg  FUSB300_EPSET0_STL) {
printk(KERN_DEBUG EP%d stall... Clear!!\n, ep);
-   reg = ~FUSB300_EPSET0_STL;
+   reg |= FUSB300_EPSET0_STL_CLR;
iowrite32(reg, fusb300-reg + FUSB300_OFFSET_EPSET0(ep));
}
 }
@@ -930,9 +930,12 @@ static void fusb300_wait_idma_finished(struct fusb300_ep 
*ep)
 
fusb300_clear_int(ep-fusb300, FUSB300_OFFSET_IGR0,
FUSB300_IGR0_EPn_PRD_INT(ep-epnum));
+   return;
+
 IDMA_RESET:
-   fusb300_clear_int(ep-fusb300, FUSB300_OFFSET_IGER0,
-   FUSB300_IGER0_EEPn_PRD_INT(ep-epnum));
+   reg = ioread32(ep-fusb300-reg + FUSB300_OFFSET_IGER0);
+   reg = ~FUSB300_IGER0_EEPn_PRD_INT(ep-epnum);
+   iowrite32(reg, ep-fusb300-reg + FUSB300_OFFSET_IGER0);
 }
 
 static void  fusb300_set_idma(struct fusb300_ep *ep,
diff --git a/drivers/usb/gadget/fusb300_udc.h b/drivers/usb/gadget/fusb300_udc.h
index 542cd83..ccae1b5 100644
--- a/drivers/usb/gadget/fusb300_udc.h
+++ b/drivers/usb/gadget/fusb300_udc.h
@@ -111,8 +111,8 @@
 /*
  * * EPn Setting 0 (EPn_SET0, offset = 020H+(n-1)*30H, n=1~15 )
  * */
+#define FUSB300_EPSET0_STL_CLR (1  3)
 #define FUSB300_EPSET0_CLRSEQNUM   (1  2)
-#define FUSB300_EPSET0_EPn_TX0BYTE (1  1)
 #define FUSB300_EPSET0_STL (1  0)
 
 /*
-- 
1.7.4.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] usb host: Faraday FUSBH200 HCD driver.

2013-02-06 Thread Yuan-Hsin Chen
On Thu, Feb 7, 2013 at 12:38 AM, Felipe Balbi ba...@ti.com wrote:
 On Wed, Feb 06, 2013 at 07:24:01PM +0800, Yuan-Hsin Chen wrote:
 From: Yuan-Hsin Chen yhc...@faraday-tech.com

 USB2.0 HCD driver for Faraday FUSBH200

 Signed-off-by: Yuan-Hsin Chen yhc...@faraday-tech.com

 just use ehci-platform.c and avoid the duplication

 --
 balbi

Thanks for your advice. I will modify and re-submit it later.

Yuan-Hsin
--
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