Re: [PATCH 1/3] dm9601: enable EP3 interrupt

2016-03-10 Thread Peter Korsgaard
>>>>> "Joseph" == Joseph CHANG  writes:

 > Enable chip's EP3 interrupt to get the link-up notify soon
 > immediately.

Sorry, what do you mean about 'soon immediately'?

 > +
 > +/* Always return 8-bytes data to host per interrupt-interval */
 > +dm_write_reg(dev, DM_USB_CTRL, USB_CTRL_EP3ACK);

Why would we want to do that instead of the current setup that afaik
only returns data when the link status changes?

-- 
Bye, Peter Korsgaard
--
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] dm9601: manage eeprom to assure the chip for correct operation

2016-03-10 Thread Peter Korsgaard
>>>>> "Joseph" == Joseph CHANG  writes:

 > Add to maintain variant eeprom adapters which may have not right
 > dm962x's format.

 > Signed-off-by: Joseph CHANG 

> +static void dm_render_begin(struct usbnet *dev)
 > +{
 > +/* Render eeprom if need, WORD3 render, set D[15:14] 01b */
 > +dm_eeprom_render(dev, 3, 0x4000, 0xc000);
 > +/* Render eeprom if need, WORD7 render, clear D[10] */
 > +dm_eeprom_render(dev, 7, 0x, 0x0400);
 > +/* Render eeprom if need, WORD11 render, need 0x005a */
 > +dm_eeprom_render(dev, 11, 0x005a, 0x);
 > +/* Render eeprom if need, WORD12 render, need 0x0007 */
 > +dm_eeprom_render(dev, 12, DM_EP3I_VAL, 0x);

With render I guess you mean something like fixup? I'm not sure we want
to do this automatically without an explicit action from the user.

How common are these adapters without valid eeprom? What happens if the
eeprom content isn't fixed?

Do we need to reset the device once the eeprom is updated?

-- 
Bye, Peter Korsgaard
--
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/1] dm9601: enable EP3 interrupt and enhance eeprom functions

2016-03-09 Thread Peter Korsgaard
>>>>> "Joseph" == Joseph CHANG  writes:

Hi Joseph,

 > Enable chip's EP3 interrupt to get the link-up notify soon
 > immediately.

 > Add to maintain variant eeprom adapters which may have not right
 > dm9620x's format.

 > Add function dm9601_set_eeprom which tested good with ethtool
 > utility.

Thanks for the patch. This sounds like 3 seperate changes, could you
please restructure it as 3 patches each doing one of the changes?

-- 
Bye, Peter Korsgaard
--
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/23] Use USB_CHAR_* in the host drivers

2015-01-25 Thread Peter Korsgaard
>>>>> "Sergei" == Sergei Shtylyov  writes:

Hi,

 >I've just discovered that I missed c67x00 in this patchset,
 > probably due to the value and the comments there differing...
 >From the code it follows that most probably both are wrong: no
 > power switching is supported (the value claims the common power
 > switching) and nothing happens with the hardware about the
 > over-current (the value claims common protection, while the comment
 > says it's per port). Peter, any comments?

Sorry, I don't really remember. I haven't had access to any hw with
c67x00 USB since 2009 or so.

It could very well be that the numbers are wrong.

-- 
Bye, Peter Korsgaard
--
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: c67x00: add proper delays to HPI read/write

2013-12-25 Thread Peter Korsgaard
>>>>> "Max" == Max Filippov  writes:

 > According to CY7C67300 specification HPI read and write cycle duration
 > Tcyc must be at least 6T long, where T is 1/48MHz, which is 125ns.
 > Without this delay fast host processor cannot write to chip registers.
 > Add proper ndelay to hpi_{read,write}_reg.

It would be good to add a sensible named define (with the above
description) as a comment and use that instead of the magic 125 constant
in the code.

With that fixed:

Acked-by: Peter Korsgaard 

-- 
Bye, Peter Korsgaard
--
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: c67x00: move URB private data allocation from under spinlock

2013-12-25 Thread Peter Korsgaard
>>>>> "Max" == Max Filippov  writes:

 > This fixes the following warning:
 >   BUG: sleeping function called from invalid context at mm/slub.c:940
 >   in_atomic(): 1, irqs_disabled(): 1, pid: 17, name: khubd
 >   CPU: 0 PID: 17 Comm: khubd Not tainted 3.12.0-4-g938dd60-dirty #1

 >__might_sleep+0xbe/0xc0
 >kmem_cache_alloc_trace+0x36/0x170
 >c67x00_urb_enqueue+0x5c/0x254
 >usb_hcd_submit_urb+0x66e/0x724
 >usb_submit_urb+0x2ac/0x308
 >usb_start_wait_urb+0x2c/0xb8
 >usb_control_msg+0x8c/0xa8
 >hub_port_init+0x191/0x718
 >hub_thread+0x804/0xe14
 >kthread+0x72/0x78
 >ret_from_kernel_thread+0x8/0xc

 > Signed-off-by: Max Filippov 

Acked-by: Peter Korsgaard 

-- 
Bye, Peter Korsgaard
--
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: c67x00: remove CONFIG_USB_DEBUG dependancy

2013-12-19 Thread Peter Korsgaard
>>>>> "Greg" == Greg Kroah-Hartman  writes:

 > From: Greg Kroah-Hartman 
 > This removes the usage of CONFIG_USB_DEBUG in the c67x00 driver.  There
 > was only one place, where the TD was dumped to the kernel log, and that
 > was using the dynamic debug infrastructure already, with the exception
 > of the call to print_hex_dump().  So move everything to the dynamic
 > debug infrastructure, including one odd printk(KERN_DEBUG...) line that
 > looks like it was forgotten about a long time ago.

 > Cc: Peter Korsgaard 
 > Signed-off-by: Greg Kroah-Hartman 

Acked-by: Peter Korsgaard 

-- 
Bye, Peter Korsgaard
--
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/1] net: add dm9620 net usb driver

2013-07-05 Thread Peter Korsgaard
>>>>> "Joseph" == Joseph Chang  writes:

Hi,

 Joseph>   This is Joseph CHANG, I am glade to contact and work with
 Joseph>   you.  I am busy in some affairs else these days, and will
 Joseph>   like to be back soon.

 Joseph>   For the begin, We copy the source code 'dm9601.c' which was
 Joseph>   by you, In order to work for our new chips (DM9620, DM9621,
 Joseph>   DM9621A... series), We did modify to get 'dm9620.c' base on
 Joseph>   'dm0601.c', Since you are the author and also the owner, so
 Joseph>   keep MODULE_AUTHOR() as you.

Yes, that's what I learned from a number of bug reports. It would have
been good if you would have worked with me to get your modifications
integrated instead.


 Joseph>   To generate DM9620.c is a way to distinguish the different
 Joseph>   generation chips: (as below)

 Joseph>DM9601: old revision: USB1.1, Ethernet 10/100, Phase out
 Joseph>DM9620: current revision:  USB2.0, Ethernet 10/100, Mass production 
state
 Joseph>DM9633: next revision: USB3.0, Ethernet 10/100/1000, Will to
 Joseph> release on 2013/E

dm9620 is basically backwards compatible with dm9601, so I added dm9620
support to the dm9601 driver earlier this year:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6642f91c92da0736

Is there anything missing from that?

I don't see any dm9633 datasheet on the davicom website, so I cannot say
if it makes sense to add support for it in the existing driver. Is the
datasheet available somewhere?


 Joseph>   So want to make it from the configuration by "make
 Joseph>   menuconfig".

 Joseph>   Can you help give further advices, we hope you can go ahead
 Joseph> be the owner (author) of the 'dm9620.c', And then we make patch
 Joseph> to it. Would you agree this idea? If so we will be happy
 Joseph> because we did not ever create such a code.

 Joseph>   * Think about DM9633 driver to be, It will be is total
 Joseph> different compare to DM9601 & DM9620. And will get the same
 Joseph> issue.

If you can provide me with a dm9633 datasheet and a sample device then I
can look into writing a driver for it / extending dm9601.c. Please
contact me off list for that.

Thanks!

-- 
Bye, Peter Korsgaard
--
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/1] net: add dm9620 net usb driver

2013-06-23 Thread Peter Korsgaard
>>>>> "Joseph" == Joseph CHANG  writes:

 Joseph> DM9620 is an USB2.0 network adapter rather than DM9601 USB1.1. This
 Joseph> driver processed the RX data 4 bytes header, TX data 2 bytes header,
 Joseph> make the control bit exactly right in PHY write function, and optional
 Joseph> IFF_ALLMUTLI bit for RX control.

But dm9601.c already supports the dm9620 based devices. Why another
driver for the same hardware?

Please CC me on dm9601 related patches.

 Joseph> Tested good for many platforms, include X86 desktop and ARM embedded.

 Joseph> +static struct usb_driver dm9620_driver = {
 Joseph> +  .name = "dm9620",
 Joseph> +  .id_table = products,
 Joseph> +  .probe = usbnet_probe,
 Joseph> +  .disconnect = usbnet_disconnect,
 Joseph> +  .suspend = usbnet_suspend,
 Joseph> +  .resume = usbnet_resume,
 Joseph> +  .disable_hub_initiated_lpm = 1,
 Joseph> +};
 Joseph> +
 Joseph> +module_usb_driver(dm9620_driver);
 Joseph> +
 Joseph> +MODULE_AUTHOR("Peter Korsgaard ");

I'm not the author of this file.


-- 
Bye, Peter Korsgaard
--
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 08/11] usbnet: dm9601: apply usbnet_link_change

2013-04-11 Thread Peter Korsgaard
>>>>> "Ming" == Ming Lei  writes:

 Ming> Use usbnet_link_change to handle link change centrally.

Acked-by: Peter Korsgaard 

 Ming> Cc: Peter Korsgaard 
 Ming> Signed-off-by: Ming Lei 
 Ming> ---
 Ming>  drivers/net/usb/dm9601.c |7 +--
 Ming>  1 file changed, 1 insertion(+), 6 deletions(-)

 Ming> diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
 Ming> index 174e5ec..2dbb946 100644
 Ming> --- a/drivers/net/usb/dm9601.c
 Ming> +++ b/drivers/net/usb/dm9601.c
 Ming> @@ -524,12 +524,7 @@ static void dm9601_status(struct usbnet *dev, 
struct urb *urb)
 
 Ming>  link = !!(buf[0] & 0x40);
 Ming>  if (netif_carrier_ok(dev->net) != link) {
 Ming> -if (link) {
 Ming> -netif_carrier_on(dev->net);
 Ming> -usbnet_defer_kevent (dev, EVENT_LINK_RESET);
 Ming> -}
 Ming> -else
 Ming> -netif_carrier_off(dev->net);
 Ming> +usbnet_link_change(dev, link, 1);
 Ming>  netdev_dbg(dev->net, "Link Status is: %d\n", link);
 Ming>  }
 Ming>  }
 Ming> -- 
 Ming> 1.7.9.5



-- 
Bye, Peter Korsgaard
--
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 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

Hi,

 >> Just that it's an unneeded extra level of indirection.

 Daniel> Ok, alright. Sent v4 right now.

Thanks!

 Daniel> Thanks for your feedback! Much appreciated. Btw - did you try
 Daniel> that on your board yet? Does it work for you as well?

Sorry, not yet. I'm temporarily working on a dm8168 based board (which
unfortunately doesn't have mainline support), and I'm afraid I won't be
able to test it on our am335x based board until a few weeks.

I will need USB host support though, so I am interested in getting it
fixed. Thanks for doing this work!

-- 
Bye, Peter Korsgaard
--
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 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

Hi,

 Daniel> +struct musb_hcd_link {
 Daniel> +  struct musb *musb;
 Daniel> +};
 Daniel> +
 Daniel> +struct musb *hcd_to_musb(struct usb_hcd *hcd)
 Daniel> +{
 Daniel> +  struct musb_hcd_link *link = (struct musb_hcd_link *) 
hcd->hcd_priv;
 Daniel> +  return link->musb;
 Daniel> +}
 Daniel> +
 >> 
 >> Sorry, I missed this first time around - But why the indirection with
 >> musb_hcd_link? Why not simply directly store a pointer to struct musb in
 >> hcd_priv?

 Daniel> Well, that's also possible. I just thought it's nicer (more readable)
 Daniel> that way. But I can as well rework it so the struct isn't needed. It
 Daniel> won't safe us any binary size or anything though. So I'm not sure.

Well, it will save one level of indirection (hcd_priv->link->musb vs
hcd_priv->musb).

 Daniel> Any particular reason why you don't like the struct? :)

Just that it's an unneeded extra level of indirection.

-- 
Bye, Peter Korsgaard
--
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 06/11] usb: musb: factor out hcd initalization

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> The musb struct is currently allocated along with the hcd, which makes
 Daniel> it difficult to build a driver that only acts as gadget device.

 Daniel> Fix this by allocating musb directly, and keep the hcd around as
 Daniel> a pointer in the musb struct.

 Daniel> struct hc_driver musb_hc_driver can now also be static to musb_host.c,
 Daniel> and the macro musb_to_hcd() is just a pointer dereferencer for now, and
 Daniel> will be eliminated later.

 Daniel> Signed-off-by: Daniel Mack 
 Daniel> Acked-by: Peter Korsgaard 
 Daniel> ---
 Daniel>  drivers/usb/musb/musb_core.c | 40 
 Daniel>  drivers/usb/musb/musb_core.h |  1 +
 Daniel>  drivers/usb/musb/musb_host.c | 54 
++--
 Daniel>  drivers/usb/musb/musb_host.h | 19 +++-
 Daniel>  4 files changed, 75 insertions(+), 39 deletions(-)

 
 Daniel> +struct musb_hcd_link {
 Daniel> +  struct musb *musb;
 Daniel> +};
 Daniel> +
 Daniel> +struct musb *hcd_to_musb(struct usb_hcd *hcd)
 Daniel> +{
 Daniel> +  struct musb_hcd_link *link = (struct musb_hcd_link *) 
hcd->hcd_priv;
 Daniel> +  return link->musb;
 Daniel> +}
 Daniel> +

Sorry, I missed this first time around - But why the indirection with
musb_hcd_link? Why not simply directly store a pointer to struct musb in
hcd_priv?

-- 
Bye, Peter Korsgaard
--
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 10/11] usb: musb: use musb->port_mode

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> Initialize the host and gagdet subsystems of the musb driver
 Daniel> only when

Sorry, I missed this before - s/gagdet/gadget/


 Daniel> the appropriate mode is selected from platform data, or device-tree
 Daniel> information, respectively.

 Daniel> Signed-off-by: Daniel Mack 
 Daniel> Acked-by: Peter Korsgaard 
 Daniel> ---
 Daniel>  drivers/usb/musb/musb_core.c| 22 +-
 Daniel>  drivers/usb/musb/musb_virthub.c |  3 ++-
 Daniel>  2 files changed, 19 insertions(+), 6 deletions(-)

 Daniel> diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel> index 2640d25..b3b9873 100644
 Daniel> --- a/drivers/usb/musb/musb_core.c
 Daniel> +++ b/drivers/usb/musb/musb_core.c
 Daniel> @@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int 
nIrq, void __iomem *ctrl)
 musb-> xceiv->state = OTG_STATE_B_IDLE;
 Daniel>}
 
 Daniel> -  status = musb_host_setup(musb, plat->power);
 Daniel> -  if (status < 0)
 Daniel> -  goto fail3;
 Daniel> -
 Daniel> -  status = musb_gadget_setup(musb);
 Daniel> +  switch (musb->port_mode) {
 Daniel> +  case MUSB_PORT_MODE_HOST:
 Daniel> +  status = musb_host_setup(musb, plat->power);
 Daniel> +  break;
 Daniel> +  case MUSB_PORT_MODE_GADGET:
 Daniel> +  status = musb_gadget_setup(musb);
 Daniel> +  break;
 Daniel> +  case MUSB_PORT_MODE_DUAL_ROLE:
 Daniel> +  status = musb_host_setup(musb, plat->power);
 Daniel> +  if (status < 0)
 Daniel> +  goto fail3;
 Daniel> +  status = musb_gadget_setup(musb);
 Daniel> +  break;
 Daniel> +  default:
 Daniel> +  dev_err(dev, "unsupported port mode %d\n", 
musb->port_mode);
 Daniel> +  break;
 Daniel> +  }
 
 Daniel>if (status < 0)
 Daniel>goto fail3;
 Daniel> diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel> index 1e17c20..8d92ba2 100644
 Daniel> --- a/drivers/usb/musb/musb_virthub.c
 Daniel> +++ b/drivers/usb/musb/musb_virthub.c
 Daniel> @@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 Daniel> * (b) vbus present/connect IRQ, peripheral mode;
 Daniel> * (c) peripheral initiates, using SRP
 Daniel> */
 Daniel> -  if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 Daniel> +  if (musb->port_mode != MUSB_PORT_MODE_HOST &&
 Daniel> +  (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 musb-> is_active = 1;
 Daniel>} else {
 Daniel>devctl |= MUSB_DEVCTL_SESSION;
 Daniel> -- 
 Daniel> 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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: musb: move musb_start to musb_virthub.c

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> This function has its only user in musb_virthub.c, so let's move it
 Daniel> there and make it static.

 Daniel> Signed-off-by: Daniel Mack 

Acked-by: Peter Korsgaard 

 Daniel> ---
 Daniel>  drivers/usb/musb/musb_core.c| 45 
-
 Daniel>  drivers/usb/musb/musb_core.h|  1 -
 Daniel>  drivers/usb/musb/musb_virthub.c | 44 

 Daniel>  3 files changed, 44 insertions(+), 46 deletions(-)

 Daniel> diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel> index 13341c6..adf069d 100644
 Daniel> --- a/drivers/usb/musb/musb_core.c
 Daniel> +++ b/drivers/usb/musb/musb_core.c
 Daniel> @@ -905,51 +905,6 @@ b_host:
 
 Daniel>  
/*-*/
 
 Daniel> -/*
 Daniel> -* Program the HDRC to start (enable interrupts, dma, etc.).
 Daniel> -*/
 Daniel> -void musb_start(struct musb *musb)
 Daniel> -{
 Daniel> -  void __iomem*regs = musb->mregs;
 Daniel> -  u8  devctl = musb_readb(regs, MUSB_DEVCTL);
 Daniel> -
 Daniel> -  dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
 Daniel> -
 Daniel> -  /*  Set INT enable registers, enable interrupts */
 Daniel> -  musb->intrtxe = musb->epmask;
 Daniel> -  musb_writew(regs, MUSB_INTRTXE, musb->intrtxe);
 Daniel> -  musb->intrrxe = musb->epmask & 0xfffe;
 Daniel> -  musb_writew(regs, MUSB_INTRRXE, musb->intrrxe);
 Daniel> -  musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
 Daniel> -
 Daniel> -  musb_writeb(regs, MUSB_TESTMODE, 0);
 Daniel> -
 Daniel> -  /* put into basic highspeed mode and start session */
 Daniel> -  musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
 Daniel> -  | MUSB_POWER_HSENAB
 Daniel> -  /* ENSUSPEND wedges 
tusb */
 Daniel> -  /* | 
MUSB_POWER_ENSUSPEND */
 Daniel> -  );
 Daniel> -
 Daniel> -  musb->is_active = 0;
 Daniel> -  devctl = musb_readb(regs, MUSB_DEVCTL);
 Daniel> -  devctl &= ~MUSB_DEVCTL_SESSION;
 Daniel> -
 Daniel> -  /* session started after:
 Daniel> -   * (a) ID-grounded irq, host mode;
 Daniel> -   * (b) vbus present/connect IRQ, peripheral mode;
 Daniel> -   * (c) peripheral initiates, using SRP
 Daniel> -   */
 Daniel> -  if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
 Daniel> -  musb->is_active = 1;
 Daniel> -  else
 Daniel> -  devctl |= MUSB_DEVCTL_SESSION;
 Daniel> -
 Daniel> -  musb_platform_enable(musb);
 Daniel> -  musb_writeb(regs, MUSB_DEVCTL, devctl);
 Daniel> -}
 Daniel> -
 Daniel> -
 Daniel>  static void musb_generic_disable(struct musb *musb)
 Daniel>  {
 Daniel>void __iomem*mbase = musb->mregs;
 Daniel> diff --git a/drivers/usb/musb/musb_core.h 
b/drivers/usb/musb/musb_core.h
 Daniel> index 04d8974..87da041 100644
 Daniel> --- a/drivers/usb/musb/musb_core.h
 Daniel> +++ b/drivers/usb/musb/musb_core.h
 Daniel> @@ -503,7 +503,6 @@ static inline void musb_configure_ep0(struct musb 
*musb)
 
 Daniel>  extern const char musb_driver_name[];
 
 Daniel> -extern void musb_start(struct musb *musb);
 Daniel>  extern void musb_stop(struct musb *musb);
 
 Daniel>  extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 
*src);
 Daniel> diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel> index ef7d110..1e17c20 100644
 Daniel> --- a/drivers/usb/musb/musb_virthub.c
 Daniel> +++ b/drivers/usb/musb/musb_virthub.c
 Daniel> @@ -44,6 +44,50 @@
 
 Daniel>  #include "musb_core.h"
 
 Daniel> +/*
 Daniel> +* Program the HDRC to start (enable interrupts, dma, etc.).
 Daniel> +*/
 Daniel> +static void musb_start(struct musb *musb)
 Daniel> +{
 Daniel> +  void __iomem*regs = musb->mregs;
 Daniel> +  u8  devctl = musb_readb(regs, MUSB_DEVCTL);
 Daniel> +
 Daniel> +  dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
 Daniel> +
 Daniel> +  /*  Set INT enable registers, enable interrupts */
 Daniel> +  musb->intrtxe = musb->epmask;
 Daniel> +  musb_writew(regs, MUSB_INTRTXE, musb->intrtxe);
 Daniel> +  musb->intrrxe = musb->epmask & 0xfffe;
 Daniel> +  musb_writew(regs, MUSB_INTRRXE, musb->intrrxe);
 Daniel> +  musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
 Daniel> +
 Daniel> +  musb_writeb(reg

Re: [PATCH v2 11/11] usb: musb: eliminate musb_to_hcd

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> With the hcd is now a direct member of struct musb, we can now simply
 Daniel> eliminate the musb_to_hcd() macro. There aren't that many users left
 Daniel> anyway, as some where already fixed up when parts were factored out to
 Daniel> musb_host.c

 Daniel> Signed-off-by: Daniel Mack 

You seem to have forgotten to remove the musb_to_hcd() implementation.

With that fixed:

Acked-by: Peter Korsgaard 

 Daniel> ---
 Daniel>  drivers/usb/musb/musb_core.c| 4 ++--
 Daniel>  drivers/usb/musb/musb_host.c| 8 
 Daniel>  drivers/usb/musb/musb_virthub.c | 6 +++---
 Daniel>  3 files changed, 9 insertions(+), 9 deletions(-)

 Daniel> diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel> index b3b9873..57b7a17 100644
 Daniel> --- a/drivers/usb/musb/musb_core.c
 Daniel> +++ b/drivers/usb/musb/musb_core.c
 Daniel> @@ -389,7 +389,7 @@ static void musb_otg_timer_func(unsigned long data)
 Daniel>   */
 Daniel>  void musb_hnp_stop(struct musb *musb)
 Daniel>  {
 Daniel> -  struct usb_hcd  *hcd = musb_to_hcd(musb);
 Daniel> +  struct usb_hcd  *hcd = musb->hcd;
 Daniel>void __iomem*mbase = musb->mregs;
 Daniel>u8  reg;
 
 Daniel> @@ -686,7 +686,7 @@ static irqreturn_t musb_stage0_irq(struct musb 
*musb, u8 int_usb,
 Daniel>}
 
 Daniel>if (int_usb & MUSB_INTR_CONNECT) {
 Daniel> -  struct usb_hcd *hcd = musb_to_hcd(musb);
 Daniel> +  struct usb_hcd *hcd = musb->hcd;
 
 Daniel>handled = IRQ_HANDLED;
 musb-> is_active = 1;
 Daniel> diff --git a/drivers/usb/musb/musb_host.c 
b/drivers/usb/musb/musb_host.c
 Daniel> index b6a840e..d3cbaa3 100644
 Daniel> --- a/drivers/usb/musb/musb_host.c
 Daniel> +++ b/drivers/usb/musb/musb_host.c
 Daniel> @@ -320,9 +320,9 @@ __acquires(musb->lock)
 urb-> actual_length, urb->transfer_buffer_length
 Daniel>);
 
 Daniel> -  usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb);
 Daniel> +  usb_hcd_unlink_urb_from_ep(musb->hcd, urb);
 Daniel>spin_unlock(&musb->lock);
 Daniel> -  usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status);
 Daniel> +  usb_hcd_giveback_urb(musb->hcd, urb, status);
 Daniel>spin_lock(&musb->lock);
 Daniel>  }
 
 Daniel> @@ -1465,7 +1465,7 @@ done:
 Daniel>if (length > qh->maxpacket)
 Daniel>length = qh->maxpacket;
 Daniel>/* Unmap the buffer so that CPU can use it */
 Daniel> -  usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb);
 Daniel> +  usb_hcd_unmap_urb_for_dma(musb->hcd, urb);
 
 Daniel>/*
 Daniel> * We need to map sg if the transfer_buffer is
 Daniel> @@ -1880,7 +1880,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
 Daniel>unsigned int received_len;
 
 Daniel>/* Unmap the buffer so that CPU can use it */
 Daniel> -  usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), 
urb);
 Daniel> +  usb_hcd_unmap_urb_for_dma(musb->hcd, urb);
 
 Daniel>/*
 Daniel> * We need to map sg if the transfer_buffer is
 Daniel> diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel> index 8d92ba2..5a101fe 100644
 Daniel> --- a/drivers/usb/musb/musb_virthub.c
 Daniel> +++ b/drivers/usb/musb/musb_virthub.c
 Daniel> @@ -215,7 +215,7 @@ static void musb_port_reset(struct musb *musb, 
bool do_reset)
 musb-> port1_status |= USB_PORT_STAT_ENABLE
 Daniel>| (USB_PORT_STAT_C_RESET << 16)
 Daniel>| (USB_PORT_STAT_C_ENABLE << 
16);
 Daniel> -  usb_hcd_poll_rh_status(musb_to_hcd(musb));
 Daniel> +  usb_hcd_poll_rh_status(musb->hcd);
 
 musb-> vbuserr_retry = VBUSERR_RETRY_COUNT;
 Daniel>}
 Daniel> @@ -228,7 +228,7 @@ void musb_root_disconnect(struct musb *musb)
 musb-> port1_status = USB_PORT_STAT_POWER
 Daniel>| (USB_PORT_STAT_C_CONNECTION << 16);
 
 Daniel> -  usb_hcd_poll_rh_status(musb_to_hcd(musb));
 Daniel> +  usb_hcd_poll_rh_status(musb->hcd);
 musb-> is_active = 0;
 
 Daniel>switch (musb->xceiv->state) {
 Daniel> @@ -382,7 +382,7 @@ int musb_hub_control(
 musb-> port1_status &= ~(USB_PORT_STAT_SUSPEND
 Daniel>| MUSB_PORT_STAT_RESUME);
 musb-> port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
 Daniel> -  usb_hcd_poll_rh_status(musb_to_hcd(musb));
 Daniel> +  

Re: [PATCH v2 10/11] usb: musb: use musb->port_mode

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> Initialize the host and gagdet subsystems of the musb driver only when
 Daniel> the appropriate mode is selected from platform data, or device-tree
 Daniel> information, respectively.

 Daniel> Signed-off-by: Daniel Mack 

Acked-by: Peter Korsgaard 


 Daniel> ---
 Daniel>  drivers/usb/musb/musb_core.c| 22 +-
 Daniel>  drivers/usb/musb/musb_virthub.c |  3 ++-
 Daniel>  2 files changed, 19 insertions(+), 6 deletions(-)

 Daniel> diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel> index 2640d25..b3b9873 100644
 Daniel> --- a/drivers/usb/musb/musb_core.c
 Daniel> +++ b/drivers/usb/musb/musb_core.c
 Daniel> @@ -1912,11 +1912,23 @@ musb_init_controller(struct device *dev, int 
nIrq, void __iomem *ctrl)
 musb-> xceiv->state = OTG_STATE_B_IDLE;
 Daniel>}
 
 Daniel> -  status = musb_host_setup(musb, plat->power);
 Daniel> -  if (status < 0)
 Daniel> -  goto fail3;
 Daniel> -
 Daniel> -  status = musb_gadget_setup(musb);
 Daniel> +  switch (musb->port_mode) {
 Daniel> +  case MUSB_PORT_MODE_HOST:
 Daniel> +  status = musb_host_setup(musb, plat->power);
 Daniel> +  break;
 Daniel> +  case MUSB_PORT_MODE_GADGET:
 Daniel> +  status = musb_gadget_setup(musb);
 Daniel> +  break;
 Daniel> +  case MUSB_PORT_MODE_DUAL_ROLE:
 Daniel> +  status = musb_host_setup(musb, plat->power);
 Daniel> +  if (status < 0)
 Daniel> +  goto fail3;
 Daniel> +  status = musb_gadget_setup(musb);
 Daniel> +  break;
 Daniel> +  default:
 Daniel> +  dev_err(dev, "unsupported port mode %d\n", 
musb->port_mode);
 Daniel> +  break;
 Daniel> +  }
 
 Daniel>if (status < 0)
 Daniel>goto fail3;
 Daniel> diff --git a/drivers/usb/musb/musb_virthub.c 
b/drivers/usb/musb/musb_virthub.c
 Daniel> index 1e17c20..8d92ba2 100644
 Daniel> --- a/drivers/usb/musb/musb_virthub.c
 Daniel> +++ b/drivers/usb/musb/musb_virthub.c
 Daniel> @@ -79,7 +79,8 @@ static void musb_start(struct musb *musb)
 Daniel> * (b) vbus present/connect IRQ, peripheral mode;
 Daniel> * (c) peripheral initiates, using SRP
 Daniel> */
 Daniel> -  if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 Daniel> +  if (musb->port_mode != MUSB_PORT_MODE_HOST &&
 Daniel> +  (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
 musb-> is_active = 1;
 Daniel>} else {
 Daniel>devctl |= MUSB_DEVCTL_SESSION;
 Daniel> -- 
 Daniel> 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 09/11] usb: musb: re-introduce musb->port_mode

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> Define MUSB_PORT_MODE_{HOST,GADGET,DUAL_ROLE} and store the
 Daniel> platform-specified value in struct musb.

 Daniel> Note that MUSB_PORT_MODE_HOST has to be set to 1 in order to
 Daniel> match existing device tree bindings which are already
 Daniel> documented but in fact unusued.

 Daniel> Signed-off-by: Daniel Mack 

It would have been nice to add an explicit reference to am33xx-usb.txt /
omap-usb.txt for the bindings, but that's minor (should those files be
combined?)

Acked-by: Peter Korsgaard 

 Daniel> ---
 Daniel>  drivers/usb/musb/musb_core.c | 1 +
 Daniel>  drivers/usb/musb/musb_core.h | 7 +++
 Daniel>  2 files changed, 8 insertions(+)

 Daniel> diff --git a/drivers/usb/musb/musb_core.c 
b/drivers/usb/musb/musb_core.c
 Daniel> index fbcf5cb..2640d25 100644
 Daniel> --- a/drivers/usb/musb/musb_core.c
 Daniel> +++ b/drivers/usb/musb/musb_core.c
 Daniel> @@ -1821,6 +1821,7 @@ musb_init_controller(struct device *dev, int 
nIrq, void __iomem *ctrl)
 musb-> board_set_power = plat->set_power;
 musb-> min_power = plat->min_power;
 musb-> ops = plat->platform_ops;
 Daniel> +  musb->port_mode = plat->mode;
 
 Daniel>/* The musb_platform_init() call:
 Daniel> *   - adjusts musb->mregs
 Daniel> diff --git a/drivers/usb/musb/musb_core.h 
b/drivers/usb/musb/musb_core.h
 Daniel> index 6b65847..174c097 100644
 Daniel> --- a/drivers/usb/musb/musb_core.h
 Daniel> +++ b/drivers/usb/musb/musb_core.h
 Daniel> @@ -77,6 +77,12 @@ struct musb_ep;
 Daniel>  #define is_peripheral_active(m)   (!(m)->is_host)
 Daniel>  #define is_host_active(m) ((m)->is_host)
 
 Daniel> +enum {
 Daniel> +  MUSB_PORT_MODE_HOST = 1,
 Daniel> +  MUSB_PORT_MODE_GADGET,
 Daniel> +  MUSB_PORT_MODE_DUAL_ROLE,
 Daniel> +};
 Daniel> +
 Daniel>  #ifdef CONFIG_PROC_FS
 Daniel>  #include 
 Daniel>  #define MUSB_CONFIG_PROC_FS
 Daniel> @@ -356,6 +362,7 @@ struct musb {
 
 Daniel>u8  min_power;  /* vbus for periph, in 
mA/2 */
 
 Daniel> +  int port_mode;  /* MUSB_PORT_MODE_* */
 Daniel>boolis_host;
 
 Daniel>int a_wait_bcon;/* VBUS timeout in 
msecs */
 Daniel> -- 
 Daniel> 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 08/11] usb: musb: add musb_host_setup() and musb_host_cleanup()

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> This patch re-introduces the bits that are necessary to use the musb
 Daniel> controller in host mode.

Acked-by: Peter Korsgaard 

-- 
Bye, Peter Korsgaard
--
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 07/11] usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> This makes building the actual object files optional to the selected
 Daniel> mode, which saves users who know which kind of USB mode support they
 Daniel> need some binary size.

 Daniel> Unimplemented functions are stubbed out with static inline functions.

 Daniel> Signed-off-by: Daniel Mack 
 Daniel> ---
 Daniel>  drivers/usb/musb/Kconfig   | 29 +
 Daniel>  drivers/usb/musb/Makefile  | 10 --
 Daniel>  drivers/usb/musb/musb_gadget.h | 21 +
 Daniel>  drivers/usb/musb/musb_host.h   | 29 +++--
 Daniel>  4 files changed, 85 insertions(+), 4 deletions(-)

 Daniel> diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
 Daniel> index 47442d3..aab1568 100644
 Daniel> --- a/drivers/usb/musb/Kconfig
 Daniel> +++ b/drivers/usb/musb/Kconfig
 Daniel> @@ -28,6 +28,35 @@ config USB_MUSB_HDRC
 Daniel>  if USB_MUSB_HDRC
 
 Daniel>  choice
 Daniel> +  bool "MUSB Mode Selection"
 Daniel> +  default USB_MUSB_DUAL_ROLE if (USB && USB_GADGET)
 Daniel> +  default USB_MUSB_HOST if (USB && !USB_GADGET)
 Daniel> +  default USB_MUSB_GADGET if (!USB && USB_GADGET)
 Daniel> +
 Daniel> +config USB_MUSB_HOST
 Daniel> +  bool "Host only mode"
 Daniel> +  depends on USB
 Daniel> +  help
 Daniel> +Select this when you want to use MUSB in host mode only,
 Daniel> +thereby the gadget feature will be regressed.
 Daniel> +
 Daniel> +config USB_MUSB_GADGET
 Daniel> +  bool "Gadget only mode"
 Daniel> +  depends on USB_GADGET
 Daniel> +  help
 Daniel> +Select this when you want to use MUSB in gadget mode only,
 Daniel> +thereby the host feature will be regressed.
 Daniel> +
 Daniel> +config USB_MUSB_DUAL_ROLE
 Daniel> +  bool "Dual Role mode"
 Daniel> +  depends on (USB && USB_GADGET)
 Daniel> +  help
 Daniel> +This is the default mode of working of MUSB controller where
 Daniel> +both host and gadget features are enabled.
 Daniel> +
 Daniel> +endchoice
 Daniel> +
 Daniel> +choice
 Daniel>prompt "Platform Glue Layer"
 
 Daniel>  config USB_MUSB_DAVINCI
 Daniel> diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
 Daniel> index 3b85871..6b13a53 100644
 Daniel> --- a/drivers/usb/musb/Makefile
 Daniel> +++ b/drivers/usb/musb/Makefile
 Daniel> @@ -6,10 +6,16 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
 
 Daniel>  musb_hdrc-y := musb_core.o
 
 Daniel> -musb_hdrc-y   += musb_gadget_ep0.o 
musb_gadget.o
 Daniel> -musb_hdrc-y   += musb_virthub.o 
musb_host.o
 Daniel>  musb_hdrc-$(CONFIG_DEBUG_FS)  += musb_debugfs.o
 
 Daniel> +ifneq ($(filter y,$(CONFIG_USB_MUSB_HOST) 
$(CONFIG_USB_MUSB_DUAL_ROLE)),)
 Daniel> +  musb_hdrc-y += musb_virthub.o 
musb_host.o
 Daniel> +endif
 Daniel> +
 Daniel> +ifneq ($(filter y,$(CONFIG_USB_MUSB_GADGET) 
$(CONFIG_USB_MUSB_DUAL_ROLE)),)
 Daniel> +  musb_hdrc-y += musb_gadget_ep0.o 
musb_gadget.o
 Daniel> +endif

I believe unselected option values simply expand to the empty strings,
so these can just be:

musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_virthub.o 
musb_host.o

musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += 
musb_gadget_ep0.o musb_gadget.o

Other than that, it looks good:

Acked-by: Peter Korsgaard 

-- 
Bye, Peter Korsgaard
--
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: musb: factor out hcd initalization

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> The musb struct is currently allocated along with the hcd,
 Daniel> which makes it difficult to build a driver that only acts as
 Daniel> gadget device.

 Daniel> Fix this by allocating musb directly, and keep the hcd around as
 Daniel> a pointer in the musb struct.

 Daniel> struct hc_driver musb_hc_driver can now also be static to
 Daniel> musb_host.c, and the macro musb_to_hcd() is just a pointer
 Daniel> dereferencer for now, and will be elminiated later.

s/elminiated/eliminated/

 Daniel> Signed-off-by: Daniel Mack 

 Daniel> +++ b/drivers/usb/musb/musb_host.h
 Daniel> @@ -37,15 +37,9 @@
 
 Daniel>  #include 
 
 Daniel> -static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
 Daniel> -{
 Daniel> -  return container_of((void *) musb, struct usb_hcd, hcd_priv);
 Daniel> -}
 Daniel> +#define musb_to_hcd(MUSB) ((MUSB)->hcd)

I dislike the capitals, but as it's going away later:

Acked-by: Peter Korsgaard 

-- 
Bye, Peter Korsgaard
--
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: musb: gadget: remove hcd initialization

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> This will be done from a more appropriate location and as it doesn't
 Daniel> work anyway, it can safely be removed before the other changes.

 Daniel> Signed-off-by: Daniel Mack 

Acked-by: Peter Korsgaard 

 Daniel> ---
 Daniel>  drivers/usb/musb/musb_gadget.c | 10 --
 Daniel>  1 file changed, 10 deletions(-)

 Daniel> diff --git a/drivers/usb/musb/musb_gadget.c 
b/drivers/usb/musb/musb_gadget.c
 Daniel> index ba70923..0414bc1 100644
 Daniel> --- a/drivers/usb/musb/musb_gadget.c
 Daniel> +++ b/drivers/usb/musb/musb_gadget.c
 Daniel> @@ -1820,7 +1820,6 @@ static int musb_gadget_start(struct usb_gadget 
*g,
 Daniel>  {
 Daniel>struct musb *musb = gadget_to_musb(g);
 Daniel>struct usb_otg  *otg = musb->xceiv->otg;
 Daniel> -  struct usb_hcd  *hcd = musb_to_hcd(musb);
 Daniel>unsigned long   flags;
 Daniel>int retval = 0;
 
 Daniel> @@ -1847,17 +1846,9 @@ static int musb_gadget_start(struct usb_gadget 
*g,
 Daniel> * handles power budgeting ... this way also
 Daniel> * ensures HdrcStart is indirectly called.
 Daniel> */
 Daniel> -  retval = usb_add_hcd(hcd, 0, 0);
 Daniel> -  if (retval < 0) {
 Daniel> -  dev_dbg(musb->controller, "add_hcd failed, %d\n", 
retval);
 Daniel> -  goto err;
 Daniel> -  }
 Daniel> -
 Daniel>if (musb->xceiv->last_event == USB_EVENT_ID)
 Daniel>musb_platform_set_vbus(musb, 1);
 
 Daniel> -  hcd->self.uses_pio_for_control = 1;
 Daniel> -
 Daniel>if (musb->xceiv->last_event == USB_EVENT_NONE)
 Daniel>pm_runtime_put(musb->controller);
 
 Daniel> @@ -1942,7 +1933,6 @@ static int musb_gadget_stop(struct usb_gadget *g,
 Daniel>musb_platform_try_idle(musb, 0);
 Daniel>spin_unlock_irqrestore(&musb->lock, flags);
 
 Daniel> -  usb_remove_hcd(musb_to_hcd(musb));
 Daniel>    /*
 Daniel> * FIXME we need to be able to register another
 Daniel> * gadget driver here and have everything work;
 Daniel> -- 
 Daniel> 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 03/11] usb: musb: factor some host-specific functions

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> In particular, this introduces musb_host_resume_root_hub()and
 Daniel> musb_host_poke_root_hub() which will be stubbed out later.

 Daniel> Signed-off-by: Daniel Mack 

Acked-by: Peter Korsgaard 

-- 
Bye, Peter Korsgaard
--
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 02/11] usb: musb: move function declarations to musb_{host,gadget}.h

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> Let the function declarations live in the header files they belong to,
 Daniel> which makes it easier to stub them out later.

 Daniel> Signed-off-by: Daniel Mack 

Acked-by: Peter Korsgaard 

 Daniel> ---
 Daniel>  drivers/usb/musb/musb_core.h   | 17 -
 Daniel>  drivers/usb/musb/musb_gadget.h | 17 +++--
 Daniel>  drivers/usb/musb/musb_host.h   |  4 +++-
 Daniel>  3 files changed, 14 insertions(+), 24 deletions(-)

 Daniel> diff --git a/drivers/usb/musb/musb_core.h 
b/drivers/usb/musb/musb_core.h
 Daniel> index 7fb4819..04d8974 100644
 Daniel> --- a/drivers/usb/musb/musb_core.h
 Daniel> +++ b/drivers/usb/musb/musb_core.h
 Daniel> @@ -82,23 +82,6 @@ struct musb_ep;
 Daniel>  #define MUSB_CONFIG_PROC_FS
 Daniel>  #endif
 
 Daniel> -/** PERIPHERAL ROLE 
*/
 Daniel> -
 Daniel> -extern irqreturn_t musb_g_ep0_irq(struct musb *);
 Daniel> -extern void musb_g_tx(struct musb *, u8);
 Daniel> -extern void musb_g_rx(struct musb *, u8);
 Daniel> -extern void musb_g_reset(struct musb *);
 Daniel> -extern void musb_g_suspend(struct musb *);
 Daniel> -extern void musb_g_resume(struct musb *);
 Daniel> -extern void musb_g_wakeup(struct musb *);
 Daniel> -extern void musb_g_disconnect(struct musb *);
 Daniel> -
 Daniel> -/** HOST ROLE 
***/
 Daniel> -
 Daniel> -extern irqreturn_t musb_h_ep0_irq(struct musb *);
 Daniel> -extern void musb_host_tx(struct musb *, u8);
 Daniel> -extern void musb_host_rx(struct musb *, u8);
 Daniel> -
 Daniel>  /** CONSTANTS 
/
 
 Daniel>  #ifndef MUSB_C_NUM_EPS
 Daniel> diff --git a/drivers/usb/musb/musb_gadget.h 
b/drivers/usb/musb/musb_gadget.h
 Daniel> index 66b7c5e..75f821c 100644
 Daniel> --- a/drivers/usb/musb/musb_gadget.h
 Daniel> +++ b/drivers/usb/musb/musb_gadget.h
 Daniel> @@ -37,6 +37,17 @@
 
 Daniel>  #include 
 
 Daniel> +extern irqreturn_t musb_g_ep0_irq(struct musb *);
 Daniel> +extern void musb_g_tx(struct musb *, u8);
 Daniel> +extern void musb_g_rx(struct musb *, u8);
 Daniel> +extern void musb_g_reset(struct musb *);
 Daniel> +extern void musb_g_suspend(struct musb *);
 Daniel> +extern void musb_g_resume(struct musb *);
 Daniel> +extern void musb_g_wakeup(struct musb *);
 Daniel> +extern void musb_g_disconnect(struct musb *);
 Daniel> +extern void musb_gadget_cleanup(struct musb *);
 Daniel> +extern int musb_gadget_setup(struct musb *);
 Daniel> +
 Daniel>  enum buffer_map_state {
 Daniel>UN_MAPPED = 0,
 Daniel>PRE_MAPPED,
 Daniel> @@ -106,14 +117,8 @@ static inline struct musb_request 
*next_request(struct musb_ep *ep)
 Daniel>return container_of(queue->next, struct musb_request, list);
 Daniel>  }
 
 Daniel> -extern void musb_g_tx(struct musb *musb, u8 epnum);
 Daniel> -extern void musb_g_rx(struct musb *musb, u8 epnum);
 Daniel> -
 Daniel>  extern const struct usb_ep_ops musb_g_ep0_ops;
 
 Daniel> -extern int musb_gadget_setup(struct musb *);
 Daniel> -extern void musb_gadget_cleanup(struct musb *);
 Daniel> -
 Daniel>  extern void musb_g_giveback(struct musb_ep *, struct usb_request *, 
int);
 
 Daniel>  extern void musb_ep_restart(struct musb *, struct musb_request *);
 Daniel> diff --git a/drivers/usb/musb/musb_host.h 
b/drivers/usb/musb/musb_host.h
 Daniel> index 5a9c8fe..9670269 100644
 Daniel> --- a/drivers/usb/musb/musb_host.h
 Daniel> +++ b/drivers/usb/musb/musb_host.h
 Daniel> @@ -84,7 +84,9 @@ static inline struct musb_qh *first_qh(struct 
list_head *q)
 Daniel>return list_entry(q->next, struct musb_qh, ring);
 Daniel>  }
 
 Daniel> -
 Daniel> +extern irqreturn_t musb_h_ep0_irq(struct musb *);
 Daniel> +extern void musb_host_tx(struct musb *, u8);
 Daniel> +extern void musb_host_rx(struct musb *, u8);
 Daniel>  extern void musb_root_disconnect(struct musb *musb);
 
 Daniel>  struct usb_hcd;
 Daniel> -- 
 Daniel> 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 01/11] usb: gadget: drop unused USB_GADGET_MUSB_HDRC

2013-04-10 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

 Daniel> The functionality meant to be represented by this symbol will be
 Daniel> re-added later, but for now, USB_GADGET_MUSB_HDRC is in fact unused and
 Daniel> can be dropped.

 Daniel> Signed-off-by: Daniel Mack 

Acked-by: Peter Korsgaard 

 Daniel> ---
 Daniel>  drivers/usb/gadget/Kconfig | 8 
 Daniel>  1 file changed, 8 deletions(-)

 Daniel> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
 Daniel> index a61d981..0702fa0 100644
 Daniel> --- a/drivers/usb/gadget/Kconfig
 Daniel> +++ b/drivers/usb/gadget/Kconfig
 Daniel> @@ -333,14 +333,6 @@ config USB_MV_U3D
 Daniel>  # Controllers available in both integrated and discrete versions
 Daniel>  #
 
 Daniel> -# musb builds in ../musb along with host support
 Daniel> -config USB_GADGET_MUSB_HDRC
 Daniel> -  tristate "Inventra HDRC USB Peripheral (TI, ADI, ...)"
 Daniel> -  depends on USB_MUSB_HDRC
 Daniel> -  help
 Daniel> -This OTG-capable silicon IP is used in dual designs including
 Daniel> -the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI 
Blackfin
 Daniel> -
 Daniel>  config USB_M66592
 Daniel>tristate "Renesas M66592 USB Peripheral Controller"
 Daniel>help
 Daniel> -- 
 Daniel> 1.8.1.4



-- 
Bye, Peter Korsgaard
--
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 0/5] usb: musb: am335x support

2013-03-19 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

Hi,

 >> I know this patch reintroduces bits that have been intentionally
 >> removed before, in particular by 032ec49f53 ("usb: musb: drop
 >> useless board_mode usage"), but I don't know how this usb driver is
 >> supposed to work in host mode without taking the configured port
 >> mode into account. If anyone can explain to me which information I'm
 >> missing here, I can happily test a patch. For now, this works for
 >> me.

 Daniel> Hmm, nobody, really? Am I the only one who's running the musb
 Daniel> driver in host-only mode?

Sorry, I'll be needing host mode as well, but am currently stuck working
on non-am335x stuff - So I'm definately interested in getting it to
work, but don't have free cycles to look into it right now.

-- 
Bye, Peter Korsgaard
--
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: Make sure each c67x00 TD has been executed

2013-03-03 Thread Peter Korsgaard
>>>>> "Dave" == Dave Tubbs  writes:

 Dave> From: Dave Tubbs 
 Dave> Make sure each c67x00 TD has been executed or retry using the existing
 Dave> retry mechanism. Reference Cypress Semiconductor BIOS User's Manual 1.2,
 Dave> page 3-16

 Dave> Signed-off-by: Dave Tubbs 

Acked-by: Peter Korsgaard 

 Dave> ---
 Dave>  drivers/usb/c67x00/c67x00-sched.c |6 ++
 Dave>  1 files changed, 6 insertions(+), 0 deletions(-)

 Dave> diff --git a/drivers/usb/c67x00/c67x00-sched.c 
b/drivers/usb/c67x00/c67x00-sched.c
 Dave> index aa49162..dd5bdb4 100644
 Dave> --- a/drivers/usb/c67x00/c67x00-sched.c
 Dave> +++ b/drivers/usb/c67x00/c67x00-sched.c
 Dave> @@ -1033,6 +1033,12 @@ static inline void c67x00_check_td_list(struct 
c67x00_hcd *c67x00)
 Dave>  !td_acked(td))
 Dave>  goto cont;

 Dave> +/*
 Dave> + * at this point, there are no errors, but it's still 
possible
 Dave> + * that the td wasn't executed by the c67x00. Confirm 
it was
 Dave> + * executed or force a retry
 Dave> + */
 Dave> +if ((td->retry_cnt & TD_RETRYCNTMASK_ACT_FLG) &&
 Dave> +td->status == 0)
 Dave> +goto cont;
 Dave> +
 Dave>  /* Sequence ok and acked, don't need to fix toggle */
 Dave>  ack_ok = 1;
 
 Dave> -- 
 Dave> 1.7.1




-- 
Bye, Peter Korsgaard
--
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 0/5] usb: musb: am335x support

2013-03-03 Thread Peter Korsgaard
>>>>> "Daniel" == Daniel Mack  writes:

Hi,

 Daniel> On my board, the USB is purely used as host interface, with a
 Daniel> type B plug soldered. In the DT, I'm using the following
 Daniel> sniplet in accordance to the documentation of the bindings:

 Daniel>usb_otg_hs: usb@4740 {
 Daniel>compatible = "ti,musb-am33xx";
 Daniel>reg = <0x4740 0x1000/* usbss */
 Daniel>   0x47401000 0x800 /* musb instance 0 */
 Daniel>   0x47401800 0x800>;   /* musb instance 1 */
 Daniel>interrupt-parent = <&intc>;
 Daniel>interrupts = <17/* usbss */
 Daniel>  18/* musb instance 0 */
 19> ;  /* musb instance 1 */
 Daniel>multipoint = <1>;
 Daniel>num-eps = <16>;
 Daniel>ram-bits = <12>;
 Daniel>port0-mode = <3>;
 Daniel>port1-mode = <3>;
 Daniel>power = <250>;
 Daniel>ti,hwmods = "usb_otg_hs";
 Daniel>};

 Daniel> The relevant config options are

 Daniel> CONFIG_USB_MUSB_HDRC=y
 Daniel> # CONFIG_USB_MUSB_TUSB6010 is not set
 Daniel> # CONFIG_USB_MUSB_OMAP2PLUS is not set
 Daniel> # CONFIG_USB_MUSB_AM35X is not set
 Daniel> CONFIG_USB_MUSB_DSPS=y
 Daniel> CONFIG_MUSB_PIO_ONLY=y
 Daniel> CONFIG_USB_GADGET=y
 Daniel> CONFIG_USB_GADGET_DEBUG=y
 Daniel> CONFIG_USB_GADGET_DEBUG_FILES=y
 Daniel> CONFIG_USB_GADGET_DEBUG_FS=y
 Daniel> CONFIG_USB_GADGET_VBUS_DRAW=2
 Daniel> CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
 Daniel> CONFIG_USB_GADGET_MUSB_HDRC=y

Ehh, I'm confused here. You talk about host mode, a single 'B' (gadget)
connector and your device tree mentions 2 OTG ports.

What is the configuration exactly?

-- 
Bye, Peter Korsgaard
--
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: Make sure each c67x00 TD has been executed

2013-02-28 Thread Peter Korsgaard
>>>>> "Dave" == Dave Tubbs  writes:

 Dave> From: Dave Tubbs 
 Dave> Make sure each c67x00 TD has been executed or retry using the existing
 Dave> retry mechanism. Reference Cypress Semiconductor BIOS User's Manual 1.2,
 Dave> page 3-16

 Dave> Signed-off-by: Dave Tubbs 
 Dave> ---
 Dave>  drivers/usb/c67x00/c67x00-sched.c |6 ++
 Dave>  1 files changed, 6 insertions(+), 0 deletions(-)

 Dave> diff --git a/drivers/usb/c67x00/c67x00-sched.c 
b/drivers/usb/c67x00/c67x00-sched.c
 Dave> index aa49162..dd5bdb4 100644
 Dave> --- a/drivers/usb/c67x00/c67x00-sched.c
 Dave> +++ b/drivers/usb/c67x00/c67x00-sched.c
 Dave> @@ -1033,6 +1033,12 @@ static inline void c67x00_check_td_list(struct 
c67x00_hcd *c67x00)
 Dave>  !td_acked(td))
 Dave>  goto cont;

 Dave> +/* at this point, there are no errors, but it's still possible 
that the
 Dave> +* td wasn't executed by the c67x00. Confirm it was executed or 
force a
 Dave> +* retry */
 Dave> +if(((td->retry_cnt) & TD_RETRYCNTMASK_ACT_FLG) && (td->status 
== 0))
 Dave> +goto cont;
 Dave> +
 Dave>  /* Sequence ok and acked, don't need to fix toggle */
 Dave>  ack_ok = 1;

This is still not aligned with the ack_ok below?

-- 
Bye, Peter Korsgaard
--
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: Make sure each c67x00 TD has been executed

2013-02-28 Thread Peter Korsgaard
>>>>> "Dave" == Dave Tubbs  writes:

 Dave> From: Dave Tubbs 
 Dave> Make sure each c67x00 TD has been executed or retry using the existing
 Dave> retry mechanism. Reference Cypress Semiconductor BIOS User's Manual 1.2,
 Dave> page 3-16

 Dave> Signed-off-by: Dave Tubbs 
 Dave> ---
 Dave>  drivers/usb/c67x00/c67x00-sched.c |6 ++
 Dave>  1 files changed, 6 insertions(+), 0 deletions(-)

 Dave> diff --git a/drivers/usb/c67x00/c67x00-sched.c 
b/drivers/usb/c67x00/c67x00-sched.c
 Dave> index aa49162..dd5bdb4 100644
 Dave> --- a/drivers/usb/c67x00/c67x00-sched.c
 Dave> +++ b/drivers/usb/c67x00/c67x00-sched.c
 Dave> @@ -1033,6 +1033,12 @@ static inline void c67x00_check_td_list(struct 
c67x00_hcd *c67x00)
 Dave>  !td_acked(td))
 Dave>  goto cont;
 
 Dave> +/* at this point, there are no errors, but it's still possible that 
the
 Dave> + * td wasn't executed by the c67x00. Confirm it was executed or 
force a
 Dave> + * retry */
 Dave> +if(((td->retry_cnt) & TD_RETRYCNTMASK_ACT_FLG) && (td->status == 0))
 Dave> +  goto cont;
 Dave> +

Alignment seems off and you have trailing spaces on the last line.

 Dave>  /* Sequence ok and acked, don't need to fix toggle */
 Dave>  ack_ok = 1;
 
 Dave> -- 
 Dave> 1.7.1




-- 
Bye, Peter Korsgaard
--
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: c67x00 RetryCnt value in c67x00 TD should be 3

2013-02-28 Thread Peter Korsgaard
>>>>> "Dave" == Dave Tubbs  writes:

 Dave> From: Dave Tubbs 
 Dave> RetryCnt value in c67x00 TD should be 3 (both bits set to 1). Reference
 Dave> Cypress Semiconductor BIOS User's Manual 1.2, page 3-14

Acked-by: Peter Korsgaard 

 Dave> Signed-off-by: Dave Tubbs 
 Dave> ---
 Dave>  drivers/usb/c67x00/c67x00-sched.c |2 +-
 Dave>  1 files changed, 1 insertions(+), 1 deletions(-)

 Dave> diff --git a/drivers/usb/c67x00/c67x00-sched.c 
b/drivers/usb/c67x00/c67x00-sched.c
 Dave> index aa2262f..aa49162 100644
 Dave> --- a/drivers/usb/c67x00/c67x00-sched.c
 Dave> +++ b/drivers/usb/c67x00/c67x00-sched.c
 Dave> @@ -590,7 +590,7 @@ static int c67x00_create_td(struct c67x00_hcd 
*c67x00, struct urb *urb,
 Dave>  {
 Dave>  struct c67x00_td *td;
 Dave>  struct c67x00_urb_priv *urbp = urb->hcpriv;
 Dave> -const __u8 active_flag = 1, retry_cnt = 1;
 Dave> +const __u8 active_flag = 1, retry_cnt = 3;
 Dave>  __u8 cmd = 0;
 Dave>  int tt = 0;
 
 Dave> -- 
 Dave> 1.7.1




-- 
Bye, Peter Korsgaard
--
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: Correction to c67x00 TD data length mask

2013-02-28 Thread Peter Korsgaard
>>>>> "Dave" == Dave Tubbs  writes:

 Dave> From: Dave Tubbs 
 Dave> TD data length is 10 bits, correct TD_PORTLENMASK_DL. Reference
 Dave> Cypress Semiconductor BIOS User's Manual 1.2, page 3-10

 Dave> Signed-off-by: Dave Tubbs 

Acked-by: Peter Korsgaard 

 Dave> ---
 Dave>  drivers/usb/c67x00/c67x00-sched.c |2 +-
 Dave>  1 files changed, 1 insertions(+), 1 deletions(-)

 Dave> diff --git a/drivers/usb/c67x00/c67x00-sched.c 
b/drivers/usb/c67x00/c67x00-sched.c
 Dave> index a03fbc1..aa2262f 100644
 Dave> --- a/drivers/usb/c67x00/c67x00-sched.c
 Dave> +++ b/drivers/usb/c67x00/c67x00-sched.c
 Dave> @@ -100,7 +100,7 @@ struct c67x00_urb_priv {
 Dave>  #define TD_PIDEP_OFFSET 0x04
 Dave>  #define TD_PIDEPMASK_PID0xF0
 Dave>  #define TD_PIDEPMASK_EP 0x0F
 Dave> -#define TD_PORTLENMASK_DL   0x02FF
 Dave> +#define TD_PORTLENMASK_DL   0x03FF
 Dave>  #define TD_PORTLENMASK_PN   0xC000
 
 Dave>  #define TD_STATUS_OFFSET0x07
 Dave> -- 
 Dave> 1.7.1




-- 
Bye, Peter Korsgaard
--
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: c67x00 TD data length is 10 bits, correct TD_PORTLENMASK_DL.

2013-02-27 Thread Peter Korsgaard
>>>>> "Dave" == Dave Tubbs  writes:

 Dave> From: Dave Tubbs 
 Dave> TD data length is 10 bits, correct TD_PORTLENMASK_DL. Reference

 Dave> Cypress Semiconductor BIOS User's Manual 1.2, page 3-10

Thanks, content looks good.

Acked-by: Peter Korsgaard 

But your mailer (Outlook) has again corrupted the patch so Greg cannot
apply it. Please have a look at Documentation/email-clients.txt and
consider using git send-email.

-- 
Bye, Peter Korsgaard
--
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/1] usb: Corrections to c67x00 scheduler to handle un-executed TD's

2013-02-21 Thread Peter Korsgaard
>>>>> "Dave" == Dave Tubbs  writes:

Hi,

 Dave> From: Dave Tubbs

 Dave> Below is a patch that handles situations where TD's submitted to
 Dave> a c67x00 USB Host Controller may not be executed before being
 Dave> "handled" by the driver and given back to the URB. This can cause
 Dave> situations where data read from the c67x00 may be incorrect, and
 Dave> data written to the c67x00 may never be delivered to the
 Dave> device. In the case of mass storage devices, this can also mean
 Dave> file system corruption.

I no longer have access to any c67x00 hardware, but the fixes looks
sensible. The fixes are independent of eachother, so they should be
submitted as 3 seperate patches.

Could you resend as 3 seperate git formatted patches please?

-- 
Bye, Peter Korsgaard
--
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: c67x00-ll-hpi.c: signedness bug in ll_recv_msg()

2013-01-18 Thread Peter Korsgaard
>>>>> "Dan" == Dan Carpenter  writes:

 Dan> The callers expect this function to return zero on success or -EIO if it
 Dan> times out.  The type should be int instead of unsigned short.

 Dan> Signed-off-by: Dan Carpenter 

Acked-by: Peter Korsgaard 


 Dan> diff --git a/drivers/usb/c67x00/c67x00-ll-hpi.c 
b/drivers/usb/c67x00/c67x00-ll-hpi.c
 Dan> index a9636f4..3a1ca4d 100644
 Dan> --- a/drivers/usb/c67x00/c67x00-ll-hpi.c
 Dan> +++ b/drivers/usb/c67x00/c67x00-ll-hpi.c
 Dan> @@ -237,7 +237,7 @@ void c67x00_ll_hpi_disable_sofeop(struct c67x00_sie 
*sie)
 Dan>  /* 
-- */
 Dan>  /* Transactions */
 
 Dan> -static inline u16 ll_recv_msg(struct c67x00_device *dev)
 Dan> +static inline int ll_recv_msg(struct c67x00_device *dev)
 Dan>  {
 Dan>   u16 res;
 


-- 
Bye, Peter Korsgaard
--
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: ftdi_sio: fixup BeagleBone A5+ quirk

2012-11-22 Thread Peter Korsgaard
BeagleBone A5+ devices ended up getting shipped with the
'BeagleBone/XDS100V2' product string, and not XDS100 like it
was agreed, so adjust the quirk to match.

For details, see the thread on the beagle list:

https://groups.google.com/forum/#!msg/beagleboard/zrFPew9_Wvo/ibWr1-eE8JwJ

Signed-off-by: Peter Korsgaard 
---
 drivers/usb/serial/ftdi_sio.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 8c3379b..e1203bd 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1783,7 +1783,7 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
struct usb_device *udev = serial->dev;
 
if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO 
Systems")) ||
-   (udev->product && !strcmp(udev->product, "BeagleBone/XDS100")))
+   (udev->product && !strcmp(udev->product, "BeagleBone/XDS100V2")))
return ftdi_jtag_probe(serial);
 
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 119/493] usb: remove use of __devexit_p

2012-11-20 Thread Peter Korsgaard
>>>>> "Nicolas" == Nicolas Ferre  writes:

 Nicolas> On 11/19/2012 07:21 PM, Bill Pemberton :
 >> CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
 >> needed.
 >> 
 >> Signed-off-by: Bill Pemberton 
 >> Cc: Peter Korsgaard  
 >> Cc: Alexander Shishkin  
 >> Cc: Felipe Balbi  
 >> Cc: Li Yang  
 >> Cc: Alan Stern  
 >> Cc: Wan ZongShun  
 >> Cc: Ben Dooks  
 >> Cc: Kukjin Kim  
 >> Cc: linux-usb@vger.kernel.org 
 >> Cc: linux-o...@vger.kernel.org 
 >> Cc: linuxppc-...@lists.ozlabs.org 
 >> Cc: linux-arm-ker...@lists.infradead.org 
 >> Cc: linux-samsung-...@vger.kernel.org 

 Nicolas> [..]

 >> drivers/usb/host/ehci-atmel.c| 2 +-

 >> drivers/usb/host/ohci-at91.c | 2 +-

 Nicolas> For Atmel:

 Nicolas> Acked-by: Nicolas Ferre 

For c67x00 and g_hid:

Acked-by: Peter Korsgaard 

-- 
Bye, Peter Korsgaard
--
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 POWERPC] ehci-fsl: add PPC_MPC837x to default y

2008-02-21 Thread Peter Korsgaard
On Fri, Feb 22, 2008 at 2:36 AM, Peter Korsgaard <[EMAIL PROTECTED]> wrote:

>  Notice that I have a patch in the USB queue which fixes up the MPC834x
>  symbol (PPC_MPC834x instead of MPC834x) so this patch won't apply.

Never mind, Greg fixed it.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [USB POWERPC] ehci-fsl: add PPC_MPC837x to default y

2008-02-21 Thread Peter Korsgaard
>>>>> "Anton" == Anton Vorontsov <[EMAIL PROTECTED]> writes:

Hi,

 Anton>  config USB_EHCI_FSL
 Anton> -   bool
 Anton> -   depends on USB_EHCI_HCD
 Anton> +   bool "Support for Freescale on-chip EHCI USB controller"
 Anton> +   depends on USB_EHCI_HCD && FSL_SOC
 Anton> select USB_EHCI_ROOT_HUB_TT
 Anton> -   default y if MPC834x || PPC_MPC831x

Notice that I have a patch in the USB queue which fixes up the MPC834x
symbol (PPC_MPC834x instead of MPC834x) so this patch won't apply.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v10 4/4] USB: add Cypress c67x00 OTG controller gadget driver

2008-02-21 Thread Peter Korsgaard
00_HCD)+= c67x00-hcd.o c67x00-sched.o
+c67x00-$(CONFIG_USB_GADGET_C67X00) += c67x00-udc.o
Index: linux-2.6/drivers/usb/gadget/Kconfig
===
--- linux-2.6.orig/drivers/usb/gadget/Kconfig
+++ linux-2.6/drivers/usb/gadget/Kconfig
@@ -335,6 +335,13 @@
depends on USB_GADGET_AT91
default USB_GADGET
 
+config USB_GADGET_C67X00
+   boolean "Cypress C67X00 Gadget support"
+   depends on USB_C67X00_DRV
+   select USB_GADGET_SELECTED
+   help
+ This enables the gadget functionality of the Cypress C67X00.
+
 config USB_GADGET_DUMMY_HCD
boolean "Dummy HCD (DEVELOPMENT)"
depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL
Index: linux-2.6/drivers/usb/gadget/gadget_chips.h
===
--- linux-2.6.orig/drivers/usb/gadget/gadget_chips.h
+++ linux-2.6/drivers/usb/gadget/gadget_chips.h
@@ -147,6 +147,12 @@
 #definegadget_is_m66592(g) 0
 #endif
 
+#ifdef CONFIG_USB_GADGET_C67X00
+#definegadget_is_c67x00(g) !strcmp("c67x00_udc", (g)->name)
+#else
+#definegadget_is_c67x00(g) 0
+#endif
+
 
 // CONFIG_USB_GADGET_SX2
 // CONFIG_USB_GADGET_AU1X00
@@ -212,5 +218,7 @@
return 0x20;
else if (gadget_is_m66592(gadget))
return 0x21;
+   else if (gadget_is_c67x00(gadget))
+   return 0x22;
return -ENOENT;
 }
Index: linux-2.6/drivers/usb/host/Kconfig
===
--- linux-2.6.orig/drivers/usb/host/Kconfig
+++ linux-2.6/drivers/usb/host/Kconfig
@@ -4,19 +4,6 @@
 comment "USB Host Controller Drivers"
depends on USB
 
-config USB_C67X00_HCD
-   tristate "Cypress C67x00 HCD support"
-   depends on USB
-   help
- The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
- host/peripheral/OTG USB controllers.
-
- Enable this option to support this chip in host controller mode.
- If unsure, say N.
-
- To compile this driver as a module, choose M here: the
- module will be called c67x00.
-
 config USB_EHCI_HCD
tristate "EHCI HCD (USB 2.0) support"
depends on USB && USB_ARCH_HAS_EHCI
Index: linux-2.6/drivers/usb/Makefile
===
--- linux-2.6.orig/drivers/usb/Makefile
+++ linux-2.6/drivers/usb/Makefile
@@ -17,7 +17,7 @@
 obj-$(CONFIG_USB_U132_HCD) += host/
 obj-$(CONFIG_USB_R8A66597_HCD) += host/
 
-obj-$(CONFIG_USB_C67X00_HCD)   += c67x00/
+obj-$(CONFIG_USB_C67X00_DRV)   += c67x00/
 
 obj-$(CONFIG_USB_ACM)  += class/
 obj-$(CONFIG_USB_PRINTER)  += class/
Index: linux-2.6/drivers/usb/Kconfig
===
--- linux-2.6.orig/drivers/usb/Kconfig
+++ linux-2.6/drivers/usb/Kconfig
@@ -97,6 +97,8 @@
 
 source "drivers/usb/host/Kconfig"
 
+source "drivers/usb/c67x00/Kconfig"
+
 source "drivers/usb/class/Kconfig"
 
 source "drivers/usb/storage/Kconfig"
Index: linux-2.6/drivers/usb/c67x00/Kconfig
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/Kconfig
@@ -0,0 +1,21 @@
+#
+# Cypress C67x00 USB controller
+#
+config USB_C67X00_DRV
+   tristate "Cypress C67x00 support"
+   # only allowed to be =y if both USB!=m and USB_GADGET!=m
+   depends on (!USB && USB_GADGET) || (!USB_GADGET && USB) || (USB && 
USB_GADGET)
+   help
+ The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
+ host/peripheral USB controllers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called c67x00.
+
+config USB_C67X00_HCD
+   bool "Cypress C67X00 HCD support"
+   depends on USB && USB_C67X00_DRV
+   default y
+   help
+ Enable this option to support the Cypress C67x00 in host
+ controller mode.
Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.h
===
--- linux-2.6.orig/drivers/usb/c67x00/c67x00-hcd.h
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.h
@@ -112,8 +112,21 @@
  * Functions used by c67x00-drv
  */
 
+#ifdef CONFIG_USB_C67X00_HCD
 int c67x00_hcd_probe(struct c67x00_sie *sie);
 void c67x00_hcd_remove(struct c67x00_sie *sie);
+#else
+static inline int c67x00_hcd_probe(struct c67x00_sie *sie)
+{
+   printk(KERN_ERR "hcd requested but CONFIG_USB_C67X00_HCD "
+  "not enabled!\n");
+   return -ENODEV;
+}
+
+static inline void c67x00_hcd_remove(struct c67x00_sie *sie)
+{
+}
+#endif /* CONFIG_USB_C67X00_HCD */
 
 /* -
  * Transfer Descriptor scheduling functions

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v10 2/4] USB: add Cypress c67x00 OTG controller core driver

2008-02-21 Thread Peter Korsgaard
This patch add the core driver for the c67x00 USB OTG controller.  The core
driver is responsible for the platform bus binding and creating either
USB HCD or USB Gadget instances for each of the serial interface engines
on the chip.

This driver does not directly implement the HCD or gadget behaviours; it
just controls access to the chip.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
Acked-by: David Brownell <[EMAIL PROTECTED]>
---
 MAINTAINERS |6 +
 drivers/usb/c67x00/c67x00-drv.c |  229 
 include/linux/usb/c67x00.h  |   48 
 3 files changed, 283 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-drv.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-drv.c
@@ -0,0 +1,229 @@
+/*
+ * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+/*
+ * This file implements the common infrastructure for using the c67x00.
+ * It is both the link between the platform configuration and subdrivers and
+ * the link between the common hardware parts and the subdrivers (e.g.
+ * interrupt handling).
+ *
+ * The c67x00 has 2 SIE's (serial interface engine) wich can be configured
+ * to be host, device or OTG (with some limitations, E.G. only SIE1 can be 
OTG).
+ *
+ * Depending on the platform configuration, the SIE's are created and
+ * the corresponding subdriver is initialized (c67x00_probe_sie).
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+
+static void c67x00_probe_sie(struct c67x00_sie *sie,
+struct c67x00_device *dev, int sie_num)
+{
+   spin_lock_init(&sie->lock);
+   sie->dev = dev;
+   sie->sie_num = sie_num;
+   sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num);
+
+   switch (sie->mode) {
+   case C67X00_SIE_UNUSED:
+   dev_info(sie_dev(sie),
+"Not using SIE %d as requested\n", sie->sie_num);
+   break;
+
+   default:
+   dev_err(sie_dev(sie),
+   "Unsupported configuration: 0x%x for SIE %d\n",
+   sie->mode, sie->sie_num);
+   break;
+   }
+}
+
+static void c67x00_remove_sie(struct c67x00_sie *sie)
+{
+}
+
+static irqreturn_t c67x00_irq(int irq, void *__dev)
+{
+   struct c67x00_device *c67x00 = __dev;
+   struct c67x00_sie *sie;
+   u16 msg, int_status;
+   int i, count = 8;
+
+   int_status = c67x00_ll_hpi_status(c67x00);
+   if (!int_status)
+   return IRQ_NONE;
+
+   while (int_status != 0 && (count-- >= 0)) {
+   c67x00_ll_irq(c67x00, int_status);
+   for (i = 0; i < C67X00_SIES; i++) {
+   sie = &c67x00->sie[i];
+   msg = 0;
+   if (int_status & SIEMSG_FLG(i))
+   msg = c67x00_ll_fetch_siemsg(c67x00, i);
+   if (sie->irq)
+   sie->irq(sie, int_status, msg);
+   }
+   int_status = c67x00_ll_hpi_status(c67x00);
+   }
+
+   if (int_status)
+   dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! "
+"status = 0x%04x\n", int_status);
+
+   return IRQ_HANDLED;
+}
+
+/* - */
+
+static int __devinit c67x00_drv_probe(struct platform_device *pdev)
+{
+   struct c67x00_device *c67x00;
+   struct c67x00_platform_data *pdata;
+   struct resource *res, *res2;
+   int ret, i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENODEV;
+
+   res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!res2)
+   return -ENODEV;
+
+   pdata

[patch v10 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-02-21 Thread Peter Korsgaard
This patch adds HCD support for the Cypress c67x00 family of devices.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/Makefile   |2 
 drivers/usb/c67x00/Makefile|9 
 drivers/usb/c67x00/c67x00-drv.c|   13 
 drivers/usb/c67x00/c67x00-hcd.c|  412 +
 drivers/usb/c67x00/c67x00-hcd.h|  133 
 drivers/usb/c67x00/c67x00-ll-hpi.c |   75 ++
 drivers/usb/c67x00/c67x00-sched.c  | 1170 +
 drivers/usb/c67x00/c67x00.h|9 
 drivers/usb/host/Kconfig   |   13 
 9 files changed, 1836 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
@@ -0,0 +1,412 @@
+/*
+ * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+#include "c67x00-hcd.h"
+
+/* --
+ * Root Hub Support
+ */
+
+static __u8 c67x00_hub_des[] = {
+   0x09,   /*  __u8  bLength; */
+   0x29,   /*  __u8  bDescriptorType; Hub-descriptor */
+   0x02,   /*  __u8  bNbrPorts; */
+   0x00,   /* __u16  wHubCharacteristics; */
+   0x00,   /*   (per-port OC, no power switching) */
+   0x32,   /*  __u8  bPwrOn2pwrGood; 2ms */
+   0x00,   /*  __u8  bHubContrCurrent; 0 mA */
+   0x00,   /*  __u8  DeviceRemovable; ** 7 Ports max ** */
+   0xff,   /*  __u8  PortPwrCtrlMask; ** 7 ports max ** */
+};
+
+static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port)
+{
+   struct c67x00_hcd *c67x00 = sie->private_data;
+   unsigned long flags;
+
+   c67x00_ll_husb_reset(sie, port);
+
+   spin_lock_irqsave(&c67x00->lock, flags);
+   c67x00_ll_husb_reset_port(sie, port);
+   spin_unlock_irqrestore(&c67x00->lock, flags);
+
+   c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT);
+}
+
+static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status;
+   int i;
+
+   *buf = 0;
+   status = c67x00_ll_usb_get_status(sie);
+   for (i = 0; i < C67X00_PORTS; i++)
+   if (status & PORT_CONNECT_CHANGE(i))
+   *buf |= (1 << i);
+
+   /* bit 0 denotes hub change, b1..n port change */
+   *buf <<= 1;
+
+   return !!*buf;
+}
+
+static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 wIndex, char *buf, u16 wLength)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status, usb_status;
+   int len = 0;
+   unsigned int port = wIndex-1;
+   u16 wPortChange, wPortStatus;
+
+   switch (typeReq) {
+
+   case GetHubStatus:
+   *(__le32 *) buf = cpu_to_le32(0);
+   len = 4;/* hub power */
+   break;
+
+   case GetPortStatus:
+   if (wIndex > C67X00_PORTS)
+   return -EPIPE;
+
+   status = c67x00_ll_usb_get_status(sie);
+   usb_status = c67x00_ll_get_usb_ctl(sie);
+
+   wPortChange = 0;
+   if (status & PORT_CONNECT_CHANGE(port))
+   wPortChange |= USB_PORT_STAT_C_CONNECTION;
+
+   wPortStatus = USB_PORT_STAT_POWER;
+   if (!(status & PORT_SE0_STATUS(port)))
+   wPortStatus |= USB_PORT_STAT_CONNECTION;
+   if (usb_status & LOW_SPEED_PORT(port)) {
+   wPortStatus |= USB_PORT_STAT_LOW_SPEED;
+   c67x00->low_speed_ports |= (1 <&l

[patch v10 1/4] USB: add Cypress c67x00 low level interface code

2008-02-21 Thread Peter Korsgaard
This patch adds the low level support code for the Cypress c67x00 family of
OTG controllers.  The low level code is responsible for register access and
implements the software protocol for communicating with the 16bit
microcontroller inside the c67x00 device.

Communication is done over the HPI interface (16bit SRAM-like parallel bus).

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
Acked-by: David Brownell <[EMAIL PROTECTED]>
---
 drivers/usb/c67x00/c67x00-ll-hpi.c |  405 +
 drivers/usb/c67x00/c67x00.h|  285 ++
 2 files changed, 690 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00.h
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00.h
@@ -0,0 +1,285 @@
+/*
+ * c67x00.h: Cypress C67X00 USB register and field definitions
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#ifndef _USB_C67X00_H
+#define _USB_C67X00_H
+
+#include 
+#include 
+#include 
+#include 
+
+/* -
+ * Cypress C67x00 register definitions
+ */
+
+/* Hardware Revision Register */
+#define HW_REV_REG 0xC004
+
+/* General USB registers */
+/* = */
+
+/* USB Control Register */
+#define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A)
+
+#define LOW_SPEED_PORT(x)  ((x) ? 0x0800 : 0x0400)
+#define HOST_MODE  0x0200
+#define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080)
+#define SOF_EOP_EN(x)  ((x) ? 0x0002 : 0x0001)
+
+/* USB status register - Notice it has different content in hcd/udc mode */
+#define USB_STAT_REG(x)((x) ? 0xC0B0 : 0xC090)
+
+#define EP0_IRQ_FLG0x0001
+#define EP1_IRQ_FLG0x0002
+#define EP2_IRQ_FLG0x0004
+#define EP3_IRQ_FLG0x0008
+#define EP4_IRQ_FLG0x0010
+#define EP5_IRQ_FLG0x0020
+#define EP6_IRQ_FLG0x0040
+#define EP7_IRQ_FLG0x0080
+#define RESET_IRQ_FLG  0x0100
+#define SOF_EOP_IRQ_FLG0x0200
+#define ID_IRQ_FLG 0x4000
+#define VBUS_IRQ_FLG   0x8000
+
+/* USB Host only registers */
+/* === */
+
+/* Host n Control Register */
+#define HOST_CTL_REG(x)((x) ? 0xC0A0 : 0xC080)
+
+#define PREAMBLE_EN0x0080  /* Preamble enable */
+#define SEQ_SEL0x0040  /* Data Toggle Sequence Bit 
Select */
+#define ISO_EN 0x0010  /* Isochronous enable  */
+#define ARM_EN 0x0001  /* Arm operation */
+
+/* Host n Interrupt Enable Register */
+#define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define SOF_EOP_IRQ_EN 0x0200  /* SOF/EOP Interrupt Enable  */
+#define SOF_EOP_TMOUT_IRQ_EN   0x0800  /* SOF/EOP Timeout Interrupt Enable  */
+#define ID_IRQ_EN  0x4000  /* ID interrupt enable */
+#define VBUS_IRQ_EN0x8000  /* VBUS interrupt enable */
+#define DONE_IRQ_EN0x0001  /* Done Interrupt Enable  */
+
+/* USB status register */
+#define HOST_STAT_MASK 0x02FD
+#define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010)
+#define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004)
+
+/* Host Frame Register */
+#define HOST_FRAME_REG(x)  ((x) ? 0xC0B6 : 0xC096)
+
+#define HOST_FRAME_MASK0x07FF
+
+/* USB Peripheral only registers */
+/* = */
+
+/* Device n Port Sel reg */
+#define DEVICE_N_PORT_SEL(x)   ((x) ? 0xC0A4 : 0xC084)
+
+/* Device n Interrupt Enable Register */
+#define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep)   ((dev)  \
+? (0x0280 + (ep << 4)) \
+: (0x0200 + (ep << 4)))
+#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep)  ((dev)  \
+? (0x0286 + (ep << 4)) \
+  

[patch v10 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-02-21 Thread Peter Korsgaard
The Cypress c67x00 (EZ-Host/EZ-OTG) controllers are multi-role low/fullspeed
USB controllers. This patch series implements a HCD driver and shows the
work-in-progress status of a gadget driver.

I believe patch 1..3 are ready, and I would like to see them queued up for
mainline.

Changes since v9:
 - Put Kconfig in alphabetical order, use ccflags-$(CONFIG_USB_DEBUG)
   (feedback from David)

Changes since v8:
 - checkpatch.pl fixes (__FUNCTION__ -> __func__, indent)

Changes since v7:
 - Moved dummy hcd probe/remove functions for conditional hcd support into
   udc patch.
 - Moved usb_disabled() check into c67x00_hcd_probe().
 - Moved c67x00_get_comm_reg() to udc patch as it is only needed for gadget
   support.

Changes since v6:
 - Addressed David and Alan's comments (removed done list + tasklet)

Changes since v5:
 - Merged c67x00_ll_{get,set}_siemsg() into c67x00_ll_fetch_siemsg().
 - Fix for interrupt race condition at probe time (reported by Grant)

Changes since v4:
 - Addressed Grant's comments (c67x00_dev->c67x00_hcd_dev, label indent)
 - Moved c67x00_ll_set_ep_{ctrl,packet_size}_reg() to patch 4 as they are
   only needed for gadget support.

Changes since v3:
- Lots of cleanups: checkpatch, interrupt handling, c67x00_ prefixes, ..
- The dummy platform_device's created per serial engine are gone.
- Gadget driver (WIP)

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v8 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-02-20 Thread Peter Korsgaard
>>>>> "David" == David Brownell <[EMAIL PROTECTED]> writes:

Hi,

 David>   +ccflags-$(CONFIG_USB_DEBUG)+= -DDEBUG

 David> It's a newish idiom, most easily applied to new code before
 David> it merges ...  :)

Ok. I'll fix that.

 David> And I realize that some of the drivers there have violated the
 David> normal "alphabetical order" convention, so maybe one big
 David> cleanup patch would be in order ... but still, I'd rather see
 David> such new options added in the right place, rather than need
 David> to see them fixed up later.

And this as well.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v9 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-02-20 Thread Peter Korsgaard
This patch adds HCD support for the Cypress c67x00 family of devices.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/Makefile   |2 
 drivers/usb/c67x00/Makefile|   11 
 drivers/usb/c67x00/c67x00-drv.c|   13 
 drivers/usb/c67x00/c67x00-hcd.c|  412 +
 drivers/usb/c67x00/c67x00-hcd.h|  133 
 drivers/usb/c67x00/c67x00-ll-hpi.c |   75 ++
 drivers/usb/c67x00/c67x00-sched.c  | 1170 +
 drivers/usb/c67x00/c67x00.h|9 
 drivers/usb/host/Kconfig   |   12 
 9 files changed, 1837 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
@@ -0,0 +1,412 @@
+/*
+ * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+#include "c67x00-hcd.h"
+
+/* --
+ * Root Hub Support
+ */
+
+static __u8 c67x00_hub_des[] = {
+   0x09,   /*  __u8  bLength; */
+   0x29,   /*  __u8  bDescriptorType; Hub-descriptor */
+   0x02,   /*  __u8  bNbrPorts; */
+   0x00,   /* __u16  wHubCharacteristics; */
+   0x00,   /*   (per-port OC, no power switching) */
+   0x32,   /*  __u8  bPwrOn2pwrGood; 2ms */
+   0x00,   /*  __u8  bHubContrCurrent; 0 mA */
+   0x00,   /*  __u8  DeviceRemovable; ** 7 Ports max ** */
+   0xff,   /*  __u8  PortPwrCtrlMask; ** 7 ports max ** */
+};
+
+static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port)
+{
+   struct c67x00_hcd *c67x00 = sie->private_data;
+   unsigned long flags;
+
+   c67x00_ll_husb_reset(sie, port);
+
+   spin_lock_irqsave(&c67x00->lock, flags);
+   c67x00_ll_husb_reset_port(sie, port);
+   spin_unlock_irqrestore(&c67x00->lock, flags);
+
+   c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT);
+}
+
+static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status;
+   int i;
+
+   *buf = 0;
+   status = c67x00_ll_usb_get_status(sie);
+   for (i = 0; i < C67X00_PORTS; i++)
+   if (status & PORT_CONNECT_CHANGE(i))
+   *buf |= (1 << i);
+
+   /* bit 0 denotes hub change, b1..n port change */
+   *buf <<= 1;
+
+   return !!*buf;
+}
+
+static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 wIndex, char *buf, u16 wLength)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status, usb_status;
+   int len = 0;
+   unsigned int port = wIndex-1;
+   u16 wPortChange, wPortStatus;
+
+   switch (typeReq) {
+
+   case GetHubStatus:
+   *(__le32 *) buf = cpu_to_le32(0);
+   len = 4;/* hub power */
+   break;
+
+   case GetPortStatus:
+   if (wIndex > C67X00_PORTS)
+   return -EPIPE;
+
+   status = c67x00_ll_usb_get_status(sie);
+   usb_status = c67x00_ll_get_usb_ctl(sie);
+
+   wPortChange = 0;
+   if (status & PORT_CONNECT_CHANGE(port))
+   wPortChange |= USB_PORT_STAT_C_CONNECTION;
+
+   wPortStatus = USB_PORT_STAT_POWER;
+   if (!(status & PORT_SE0_STATUS(port)))
+   wPortStatus |= USB_PORT_STAT_CONNECTION;
+   if (usb_status & LOW_SPEED_PORT(port)) {
+   wPortStatus |= USB_PORT_STAT_LOW_SPEED;
+   c67x00->low_speed_ports |= (1 <&l

[patch v9 4/4] USB: add Cypress c67x00 OTG controller gadget driver

2008-02-20 Thread Peter Korsgaard
7x00-sched.o
+c67x00-$(CONFIG_USB_GADGET_C67X00) += c67x00-udc.o
Index: linux-2.6/drivers/usb/gadget/Kconfig
===
--- linux-2.6.orig/drivers/usb/gadget/Kconfig
+++ linux-2.6/drivers/usb/gadget/Kconfig
@@ -335,6 +335,13 @@
depends on USB_GADGET_AT91
default USB_GADGET
 
+config USB_GADGET_C67X00
+   boolean "Cypress C67X00 Gadget support"
+   depends on USB_C67X00_DRV
+   select USB_GADGET_SELECTED
+   help
+ This enables the gadget functionality of the Cypress C67X00.
+
 config USB_GADGET_DUMMY_HCD
boolean "Dummy HCD (DEVELOPMENT)"
depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL
Index: linux-2.6/drivers/usb/gadget/gadget_chips.h
===
--- linux-2.6.orig/drivers/usb/gadget/gadget_chips.h
+++ linux-2.6/drivers/usb/gadget/gadget_chips.h
@@ -147,6 +147,12 @@
 #definegadget_is_m66592(g) 0
 #endif
 
+#ifdef CONFIG_USB_GADGET_C67X00
+#definegadget_is_c67x00(g) !strcmp("c67x00_udc", (g)->name)
+#else
+#definegadget_is_c67x00(g) 0
+#endif
+
 
 // CONFIG_USB_GADGET_SX2
 // CONFIG_USB_GADGET_AU1X00
@@ -212,5 +218,7 @@
return 0x20;
else if (gadget_is_m66592(gadget))
return 0x21;
+   else if (gadget_is_c67x00(gadget))
+   return 0x22;
return -ENOENT;
 }
Index: linux-2.6/drivers/usb/host/Kconfig
===
--- linux-2.6.orig/drivers/usb/host/Kconfig
+++ linux-2.6/drivers/usb/host/Kconfig
@@ -261,15 +261,3 @@
  To compile this driver as a module, choose M here: the
  module will be called r8a66597-hcd.
 
-config USB_C67X00_HCD
-   tristate "Cypress C67x00 HCD support"
-   depends on USB
-   help
- The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
- host/peripheral/OTG USB controllers.
-
- Enable this option to support this chip in host controller mode.
- If unsure, say N.
-
- To compile this driver as a module, choose M here: the
- module will be called c67x00.
Index: linux-2.6/drivers/usb/Makefile
===
--- linux-2.6.orig/drivers/usb/Makefile
+++ linux-2.6/drivers/usb/Makefile
@@ -17,7 +17,7 @@
 obj-$(CONFIG_USB_U132_HCD) += host/
 obj-$(CONFIG_USB_R8A66597_HCD) += host/
 
-obj-$(CONFIG_USB_C67X00_HCD)   += c67x00/
+obj-$(CONFIG_USB_C67X00_DRV)   += c67x00/
 
 obj-$(CONFIG_USB_ACM)  += class/
 obj-$(CONFIG_USB_PRINTER)  += class/
Index: linux-2.6/drivers/usb/Kconfig
=======
--- linux-2.6.orig/drivers/usb/Kconfig
+++ linux-2.6/drivers/usb/Kconfig
@@ -97,6 +97,8 @@
 
 source "drivers/usb/host/Kconfig"
 
+source "drivers/usb/c67x00/Kconfig"
+
 source "drivers/usb/class/Kconfig"
 
 source "drivers/usb/storage/Kconfig"
Index: linux-2.6/drivers/usb/c67x00/Kconfig
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/Kconfig
@@ -0,0 +1,21 @@
+#
+# Cypress C67x00 USB controller
+#
+config USB_C67X00_DRV
+   tristate "Cypress C67x00 support"
+   # only allowed to be =y if both USB!=m and USB_GADGET!=m
+   depends on (!USB && USB_GADGET) || (!USB_GADGET && USB) || (USB && 
USB_GADGET)
+   help
+ The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
+ host/peripheral USB controllers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called c67x00.
+
+config USB_C67X00_HCD
+   bool "Cypress C67X00 HCD support"
+   depends on USB && USB_C67X00_DRV
+   default y
+   help
+ Enable this option to support the Cypress C67x00 in host
+ controller mode.
Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.h
===
--- linux-2.6.orig/drivers/usb/c67x00/c67x00-hcd.h
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.h
@@ -112,8 +112,21 @@
  * Functions used by c67x00-drv
  */
 
+#ifdef CONFIG_USB_C67X00_HCD
 int c67x00_hcd_probe(struct c67x00_sie *sie);
 void c67x00_hcd_remove(struct c67x00_sie *sie);
+#else
+static inline int c67x00_hcd_probe(struct c67x00_sie *sie)
+{
+   printk(KERN_ERR "hcd requested but CONFIG_USB_C67X00_HCD "
+  "not enabled!\n");
+   return -ENODEV;
+}
+
+static inline void c67x00_hcd_remove(struct c67x00_sie *sie)
+{
+}
+#endif /* CONFIG_USB_C67X00_HCD */
 
 /* -
  * Transfer Descriptor scheduling functions

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v9 1/4] USB: add Cypress c67x00 low level interface code

2008-02-20 Thread Peter Korsgaard
This patch adds the low level support code for the Cypress c67x00 family of
OTG controllers.  The low level code is responsible for register access and
implements the software protocol for communicating with the 16bit
microcontroller inside the c67x00 device.

Communication is done over the HPI interface (16bit SRAM-like parallel bus).

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
Acked-by: David Brownell <[EMAIL PROTECTED]>
---
 drivers/usb/c67x00/c67x00-ll-hpi.c |  405 +
 drivers/usb/c67x00/c67x00.h|  285 ++
 2 files changed, 690 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00.h
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00.h
@@ -0,0 +1,285 @@
+/*
+ * c67x00.h: Cypress C67X00 USB register and field definitions
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#ifndef _USB_C67X00_H
+#define _USB_C67X00_H
+
+#include 
+#include 
+#include 
+#include 
+
+/* -
+ * Cypress C67x00 register definitions
+ */
+
+/* Hardware Revision Register */
+#define HW_REV_REG 0xC004
+
+/* General USB registers */
+/* = */
+
+/* USB Control Register */
+#define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A)
+
+#define LOW_SPEED_PORT(x)  ((x) ? 0x0800 : 0x0400)
+#define HOST_MODE  0x0200
+#define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080)
+#define SOF_EOP_EN(x)  ((x) ? 0x0002 : 0x0001)
+
+/* USB status register - Notice it has different content in hcd/udc mode */
+#define USB_STAT_REG(x)((x) ? 0xC0B0 : 0xC090)
+
+#define EP0_IRQ_FLG0x0001
+#define EP1_IRQ_FLG0x0002
+#define EP2_IRQ_FLG0x0004
+#define EP3_IRQ_FLG0x0008
+#define EP4_IRQ_FLG0x0010
+#define EP5_IRQ_FLG0x0020
+#define EP6_IRQ_FLG0x0040
+#define EP7_IRQ_FLG0x0080
+#define RESET_IRQ_FLG  0x0100
+#define SOF_EOP_IRQ_FLG0x0200
+#define ID_IRQ_FLG 0x4000
+#define VBUS_IRQ_FLG   0x8000
+
+/* USB Host only registers */
+/* === */
+
+/* Host n Control Register */
+#define HOST_CTL_REG(x)((x) ? 0xC0A0 : 0xC080)
+
+#define PREAMBLE_EN0x0080  /* Preamble enable */
+#define SEQ_SEL0x0040  /* Data Toggle Sequence Bit 
Select */
+#define ISO_EN 0x0010  /* Isochronous enable  */
+#define ARM_EN 0x0001  /* Arm operation */
+
+/* Host n Interrupt Enable Register */
+#define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define SOF_EOP_IRQ_EN 0x0200  /* SOF/EOP Interrupt Enable  */
+#define SOF_EOP_TMOUT_IRQ_EN   0x0800  /* SOF/EOP Timeout Interrupt Enable  */
+#define ID_IRQ_EN  0x4000  /* ID interrupt enable */
+#define VBUS_IRQ_EN0x8000  /* VBUS interrupt enable */
+#define DONE_IRQ_EN0x0001  /* Done Interrupt Enable  */
+
+/* USB status register */
+#define HOST_STAT_MASK 0x02FD
+#define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010)
+#define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004)
+
+/* Host Frame Register */
+#define HOST_FRAME_REG(x)  ((x) ? 0xC0B6 : 0xC096)
+
+#define HOST_FRAME_MASK0x07FF
+
+/* USB Peripheral only registers */
+/* = */
+
+/* Device n Port Sel reg */
+#define DEVICE_N_PORT_SEL(x)   ((x) ? 0xC0A4 : 0xC084)
+
+/* Device n Interrupt Enable Register */
+#define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep)   ((dev)  \
+? (0x0280 + (ep << 4)) \
+: (0x0200 + (ep << 4)))
+#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep)  ((dev)  \
+? (0x0286 + (ep << 4)) \
+  

[patch v9 2/4] USB: add Cypress c67x00 OTG controller core driver

2008-02-20 Thread Peter Korsgaard
This patch add the core driver for the c67x00 USB OTG controller.  The core
driver is responsible for the platform bus binding and creating either
USB HCD or USB Gadget instances for each of the serial interface engines
on the chip.

This driver does not directly implement the HCD or gadget behaviours; it
just controls access to the chip.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
Acked-by: David Brownell <[EMAIL PROTECTED]>
---
 MAINTAINERS |6 +
 drivers/usb/c67x00/c67x00-drv.c |  229 
 include/linux/usb/c67x00.h  |   48 
 3 files changed, 283 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-drv.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-drv.c
@@ -0,0 +1,229 @@
+/*
+ * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+/*
+ * This file implements the common infrastructure for using the c67x00.
+ * It is both the link between the platform configuration and subdrivers and
+ * the link between the common hardware parts and the subdrivers (e.g.
+ * interrupt handling).
+ *
+ * The c67x00 has 2 SIE's (serial interface engine) wich can be configured
+ * to be host, device or OTG (with some limitations, E.G. only SIE1 can be 
OTG).
+ *
+ * Depending on the platform configuration, the SIE's are created and
+ * the corresponding subdriver is initialized (c67x00_probe_sie).
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+
+static void c67x00_probe_sie(struct c67x00_sie *sie,
+struct c67x00_device *dev, int sie_num)
+{
+   spin_lock_init(&sie->lock);
+   sie->dev = dev;
+   sie->sie_num = sie_num;
+   sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num);
+
+   switch (sie->mode) {
+   case C67X00_SIE_UNUSED:
+   dev_info(sie_dev(sie),
+"Not using SIE %d as requested\n", sie->sie_num);
+   break;
+
+   default:
+   dev_err(sie_dev(sie),
+   "Unsupported configuration: 0x%x for SIE %d\n",
+   sie->mode, sie->sie_num);
+   break;
+   }
+}
+
+static void c67x00_remove_sie(struct c67x00_sie *sie)
+{
+}
+
+static irqreturn_t c67x00_irq(int irq, void *__dev)
+{
+   struct c67x00_device *c67x00 = __dev;
+   struct c67x00_sie *sie;
+   u16 msg, int_status;
+   int i, count = 8;
+
+   int_status = c67x00_ll_hpi_status(c67x00);
+   if (!int_status)
+   return IRQ_NONE;
+
+   while (int_status != 0 && (count-- >= 0)) {
+   c67x00_ll_irq(c67x00, int_status);
+   for (i = 0; i < C67X00_SIES; i++) {
+   sie = &c67x00->sie[i];
+   msg = 0;
+   if (int_status & SIEMSG_FLG(i))
+   msg = c67x00_ll_fetch_siemsg(c67x00, i);
+   if (sie->irq)
+   sie->irq(sie, int_status, msg);
+   }
+   int_status = c67x00_ll_hpi_status(c67x00);
+   }
+
+   if (int_status)
+   dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! "
+"status = 0x%04x\n", int_status);
+
+   return IRQ_HANDLED;
+}
+
+/* - */
+
+static int __devinit c67x00_drv_probe(struct platform_device *pdev)
+{
+   struct c67x00_device *c67x00;
+   struct c67x00_platform_data *pdata;
+   struct resource *res, *res2;
+   int ret, i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENODEV;
+
+   res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!res2)
+   return -ENODEV;
+
+   pdata

[patch v9 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-02-20 Thread Peter Korsgaard
The Cypress c67x00 (EZ-Host/EZ-OTG) controllers are multi-role low/fullspeed
USB controllers. This patch series implements a HCD driver and shows the
work-in-progress status of a gadget driver.

I believe patch 1..3 are ready, and I would like to see them queued up for
mainline.

Changes since v8:
 - checkpatch.pl fixes (__FUNCTION__ -> __func__, indent)

Changes since v7:
 - Moved dummy hcd probe/remove functions for conditional hcd support into
   udc patch.
 - Moved usb_disabled() check into c67x00_hcd_probe().
 - Moved c67x00_get_comm_reg() to udc patch as it is only needed for gadget
   support.

Changes since v6:
 - Addressed David and Alan's comments (removed done list + tasklet)

Changes since v5:
 - Merged c67x00_ll_{get,set}_siemsg() into c67x00_ll_fetch_siemsg().
 - Fix for interrupt race condition at probe time (reported by Grant)

Changes since v4:
 - Addressed Grant's comments (c67x00_dev->c67x00_hcd_dev, label indent)
 - Moved c67x00_ll_set_ep_{ctrl,packet_size}_reg() to patch 4 as they are
   only needed for gadget support.

Changes since v3:
- Lots of cleanups: checkpatch, interrupt handling, c67x00_ prefixes, ..
- The dummy platform_device's created per serial engine are gone.
- Gadget driver (WIP)

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v7 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-02-20 Thread Peter Korsgaard
>>>>> "Greg" == Greg KH <[EMAIL PROTECTED]> writes:

 >> Sorry, I cannot reproduce that here. Could you try again?

 Greg> I will on the next round :)

Ok.

 Greg> Can you move the files under the hcd/ subdir

 Greg> Oops, I ment "host/" not, "hcd/".

Yeah, I guessed ;)

 >> Sorry, I don't think that's a good idea as the hardware can do
 >> peripheral as well, and as you can see in patch 4, a gadget driver is
 >> on it's way.

 Greg> Ok, that's fine, why can't the gadget stuff go into the gadget/
 Greg> directory then also?  As this device is a host controller, it makes
 Greg> sense to me to keep it in the host-controller subdirectory.

Because of the way the driver (and hardware) is structured. There is a
single c67x00.ko which can contain both hcd and gadget support
depending on Kconfig.

 Greg> run it through checkpatch.pl and fix up the __FUNCTION__
 Greg> warnings, and then I'll be willing to test it again :)
 >> 
 >> Ahh, that seems to be a pretty new warning in checkpatch - I atleast
 >> haven't seen it before. The other things it complains about seems to
 >> be rubbish though (except for the single indented label).

 Greg> What other things do you think are rubbish?

It misdetected a #define as a functions and complained, E.G.:

WARNING: no space between function name and open parenthesis '('
#298: FILE: include/linux/usb/c67x00.h:41:
+ #define C67X00_SIE2_PERIPHERAL_B  (C67X00_SIE_PERIPHERAL_B<< 4)

But ok, the space before the #define shouldn't have been there.

 Greg> And yes, it's a new warning with the advent of 2.6.25-rc1, but
 Greg> that's no reason to ignore it :)

Sure. it's fixed in the v9 series.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v8 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-02-20 Thread Peter Korsgaard
>>>>> "Greg" == Greg KH <[EMAIL PROTECTED]> writes:

 Greg> On Wed, Feb 20, 2008 at 10:07:27AM +0100, Peter Korsgaard wrote:
 >> The Cypress c67x00 (EZ-Host/EZ-OTG) controllers are multi-role low/fullspeed
 >> USB controllers. This patch series implements a HCD driver and shows the
 >> work-in-progress status of a gadget driver.
 >> 
 >> I believe patch 1..3 are ready, and I would like to see them queued up for
 >> mainline.
 >> 
 >> Changes since v7:
 >> - Moved dummy hcd probe/remove functions for conditional hcd support into
 >> udc patch.
 >> - Moved usb_disabled() check into c67x00_hcd_probe().
 >> - Moved c67x00_get_comm_reg() to udc patch as it is only needed for gadget
 >> support.

 Greg> So this fixes the build errors/warnings I sent you?

Well, I cannot reproduce the errors you showed (with Linus -git), but
it does fix a warning about c67x00_get_comm_reg being unused.

 Greg> Can you run them through scripts/checkpatch.pl to ensure that those
 Greg> warnings are also fixed?

Yes, I'll send a new series shortly.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v8 1/4] USB: add Cypress c67x00 low level interface code

2008-02-20 Thread Peter Korsgaard
>>>>> "Greg" == Greg KH <[EMAIL PROTECTED]> writes:

Hi,

 >> drivers/usb/c67x00/c67x00.h|  285 ++

 Greg> Why not drivers/usb/hcd/c67x00/ instead?

Because the device can do both host and peripheral (E.G. see patch 4
in the series).

We could put it under hcd for now and then move it once the gadget
driver gets finished/merged, but that seems silly to me..

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v7 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-02-20 Thread Peter Korsgaard
>>>>> "Greg" == Greg KH <[EMAIL PROTECTED]> writes:

Hi,
 Greg> I don't know, I selected the config option, and yet, it built
 Greg> as if it wasn't set.

Sorry, I cannot reproduce that here. Could you try again?

 Greg> Can you move the files under the hcd/ subdir

Sorry, I don't think that's a good idea as the hardware can do
peripheral as well, and as you can see in patch 4, a gadget driver is
on it's way.

 Greg> run it through checkpatch.pl and fix up the __FUNCTION__
 Greg> warnings, and then I'll be willing to test it again :)

Ahh, that seems to be a pretty new warning in checkpatch - I atleast
haven't seen it before. The other things it complains about seems to
be rubbish though (except for the single indented label).

I'll send a v9 series shortly.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v8 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-02-20 Thread Peter Korsgaard
This patch adds HCD support for the Cypress c67x00 family of devices.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/Makefile   |2 
 drivers/usb/c67x00/Makefile|   11 
 drivers/usb/c67x00/c67x00-drv.c|   13 
 drivers/usb/c67x00/c67x00-hcd.c|  412 +
 drivers/usb/c67x00/c67x00-hcd.h|  133 
 drivers/usb/c67x00/c67x00-ll-hpi.c |   75 ++
 drivers/usb/c67x00/c67x00-sched.c  | 1170 +
 drivers/usb/c67x00/c67x00.h|9 
 drivers/usb/host/Kconfig   |   12 
 9 files changed, 1837 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
@@ -0,0 +1,412 @@
+/*
+ * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+#include "c67x00-hcd.h"
+
+/* --
+ * Root Hub Support
+ */
+
+static __u8 c67x00_hub_des[] = {
+   0x09,   /*  __u8  bLength; */
+   0x29,   /*  __u8  bDescriptorType; Hub-descriptor */
+   0x02,   /*  __u8  bNbrPorts; */
+   0x00,   /* __u16  wHubCharacteristics; */
+   0x00,   /*   (per-port OC, no power switching) */
+   0x32,   /*  __u8  bPwrOn2pwrGood; 2ms */
+   0x00,   /*  __u8  bHubContrCurrent; 0 mA */
+   0x00,   /*  __u8  DeviceRemovable; ** 7 Ports max ** */
+   0xff,   /*  __u8  PortPwrCtrlMask; ** 7 ports max ** */
+};
+
+static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port)
+{
+   struct c67x00_hcd *c67x00 = sie->private_data;
+   unsigned long flags;
+
+   c67x00_ll_husb_reset(sie, port);
+
+   spin_lock_irqsave(&c67x00->lock, flags);
+   c67x00_ll_husb_reset_port(sie, port);
+   spin_unlock_irqrestore(&c67x00->lock, flags);
+
+   c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT);
+}
+
+static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status;
+   int i;
+
+   *buf = 0;
+   status = c67x00_ll_usb_get_status(sie);
+   for (i = 0; i < C67X00_PORTS; i++)
+   if (status & PORT_CONNECT_CHANGE(i))
+   *buf |= (1 << i);
+
+   /* bit 0 denotes hub change, b1..n port change */
+   *buf <<= 1;
+
+   return !!*buf;
+}
+
+static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 wIndex, char *buf, u16 wLength)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status, usb_status;
+   int len = 0;
+   unsigned int port = wIndex-1;
+   u16 wPortChange, wPortStatus;
+
+   switch (typeReq) {
+
+   case GetHubStatus:
+   *(__le32 *) buf = cpu_to_le32(0);
+   len = 4;/* hub power */
+   break;
+
+   case GetPortStatus:
+   if (wIndex > C67X00_PORTS)
+   return -EPIPE;
+
+   status = c67x00_ll_usb_get_status(sie);
+   usb_status = c67x00_ll_get_usb_ctl(sie);
+
+   wPortChange = 0;
+   if (status & PORT_CONNECT_CHANGE(port))
+   wPortChange |= USB_PORT_STAT_C_CONNECTION;
+
+   wPortStatus = USB_PORT_STAT_POWER;
+   if (!(status & PORT_SE0_STATUS(port)))
+   wPortStatus |= USB_PORT_STAT_CONNECTION;
+   if (usb_status & LOW_SPEED_PORT(port)) {
+   wPortStatus |= USB_PORT_STAT_LOW_SPEED;
+   c67x00->low_speed_ports |= (1 <&l

[patch v8 4/4] USB: add Cypress c67x00 OTG controller gadget driver

2008-02-20 Thread Peter Korsgaard
7x00-sched.o
+c67x00-$(CONFIG_USB_GADGET_C67X00) += c67x00-udc.o
Index: linux-2.6/drivers/usb/gadget/Kconfig
===
--- linux-2.6.orig/drivers/usb/gadget/Kconfig
+++ linux-2.6/drivers/usb/gadget/Kconfig
@@ -335,6 +335,13 @@
depends on USB_GADGET_AT91
default USB_GADGET
 
+config USB_GADGET_C67X00
+   boolean "Cypress C67X00 Gadget support"
+   depends on USB_C67X00_DRV
+   select USB_GADGET_SELECTED
+   help
+ This enables the gadget functionality of the Cypress C67X00.
+
 config USB_GADGET_DUMMY_HCD
boolean "Dummy HCD (DEVELOPMENT)"
depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL
Index: linux-2.6/drivers/usb/gadget/gadget_chips.h
===
--- linux-2.6.orig/drivers/usb/gadget/gadget_chips.h
+++ linux-2.6/drivers/usb/gadget/gadget_chips.h
@@ -147,6 +147,12 @@
 #definegadget_is_m66592(g) 0
 #endif
 
+#ifdef CONFIG_USB_GADGET_C67X00
+#definegadget_is_c67x00(g) !strcmp("c67x00_udc", (g)->name)
+#else
+#definegadget_is_c67x00(g) 0
+#endif
+
 
 // CONFIG_USB_GADGET_SX2
 // CONFIG_USB_GADGET_AU1X00
@@ -212,5 +218,7 @@
return 0x20;
else if (gadget_is_m66592(gadget))
return 0x21;
+   else if (gadget_is_c67x00(gadget))
+   return 0x22;
return -ENOENT;
 }
Index: linux-2.6/drivers/usb/host/Kconfig
===
--- linux-2.6.orig/drivers/usb/host/Kconfig
+++ linux-2.6/drivers/usb/host/Kconfig
@@ -261,15 +261,3 @@
  To compile this driver as a module, choose M here: the
  module will be called r8a66597-hcd.
 
-config USB_C67X00_HCD
-   tristate "Cypress C67x00 HCD support"
-   depends on USB
-   help
- The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
- host/peripheral/OTG USB controllers.
-
- Enable this option to support this chip in host controller mode.
- If unsure, say N.
-
- To compile this driver as a module, choose M here: the
- module will be called c67x00.
Index: linux-2.6/drivers/usb/Makefile
===
--- linux-2.6.orig/drivers/usb/Makefile
+++ linux-2.6/drivers/usb/Makefile
@@ -17,7 +17,7 @@
 obj-$(CONFIG_USB_U132_HCD) += host/
 obj-$(CONFIG_USB_R8A66597_HCD) += host/
 
-obj-$(CONFIG_USB_C67X00_HCD)   += c67x00/
+obj-$(CONFIG_USB_C67X00_DRV)   += c67x00/
 
 obj-$(CONFIG_USB_ACM)  += class/
 obj-$(CONFIG_USB_PRINTER)  += class/
Index: linux-2.6/drivers/usb/Kconfig
=======
--- linux-2.6.orig/drivers/usb/Kconfig
+++ linux-2.6/drivers/usb/Kconfig
@@ -97,6 +97,8 @@
 
 source "drivers/usb/host/Kconfig"
 
+source "drivers/usb/c67x00/Kconfig"
+
 source "drivers/usb/class/Kconfig"
 
 source "drivers/usb/storage/Kconfig"
Index: linux-2.6/drivers/usb/c67x00/Kconfig
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/Kconfig
@@ -0,0 +1,21 @@
+#
+# Cypress C67x00 USB controller
+#
+config USB_C67X00_DRV
+   tristate "Cypress C67x00 support"
+   # only allowed to be =y if both USB!=m and USB_GADGET!=m
+   depends on (!USB && USB_GADGET) || (!USB_GADGET && USB) || (USB && 
USB_GADGET)
+   help
+ The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
+ host/peripheral USB controllers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called c67x00.
+
+config USB_C67X00_HCD
+   bool "Cypress C67X00 HCD support"
+   depends on USB && USB_C67X00_DRV
+   default y
+   help
+ Enable this option to support the Cypress C67x00 in host
+ controller mode.
Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.h
===
--- linux-2.6.orig/drivers/usb/c67x00/c67x00-hcd.h
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.h
@@ -112,8 +112,21 @@
  * Functions used by c67x00-drv
  */
 
+#ifdef CONFIG_USB_C67X00_HCD
 int c67x00_hcd_probe(struct c67x00_sie *sie);
 void c67x00_hcd_remove(struct c67x00_sie *sie);
+#else
+static inline int c67x00_hcd_probe(struct c67x00_sie *sie)
+{
+   printk(KERN_ERR "hcd requested but CONFIG_USB_C67X00_HCD "
+  "not enabled!\n");
+   return -ENODEV;
+}
+
+static inline void c67x00_hcd_remove(struct c67x00_sie *sie)
+{
+}
+#endif /* CONFIG_USB_C67X00_HCD */
 
 /* -
  * Transfer Descriptor scheduling functions

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v8 1/4] USB: add Cypress c67x00 low level interface code

2008-02-20 Thread Peter Korsgaard
This patch adds the low level support code for the Cypress c67x00 family of
OTG controllers.  The low level code is responsible for register access and
implements the software protocol for communicating with the 16bit
microcontroller inside the c67x00 device.

Communication is done over the HPI interface (16bit SRAM-like parallel bus).

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
Acked-by: David Brownell <[EMAIL PROTECTED]>
---
 drivers/usb/c67x00/c67x00-ll-hpi.c |  405 +
 drivers/usb/c67x00/c67x00.h|  285 ++
 2 files changed, 690 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00.h
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00.h
@@ -0,0 +1,285 @@
+/*
+ * c67x00.h: Cypress C67X00 USB register and field definitions
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#ifndef _USB_C67X00_H
+#define _USB_C67X00_H
+
+#include 
+#include 
+#include 
+#include 
+
+/* -
+ * Cypress C67x00 register definitions
+ */
+
+/* Hardware Revision Register */
+#define HW_REV_REG 0xC004
+
+/* General USB registers */
+/* = */
+
+/* USB Control Register */
+#define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A)
+
+#define LOW_SPEED_PORT(x)  ((x) ? 0x0800 : 0x0400)
+#define HOST_MODE  0x0200
+#define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080)
+#define SOF_EOP_EN(x)  ((x) ? 0x0002 : 0x0001)
+
+/* USB status register - Notice it has different content in hcd/udc mode */
+#define USB_STAT_REG(x)((x) ? 0xC0B0 : 0xC090)
+
+#define EP0_IRQ_FLG0x0001
+#define EP1_IRQ_FLG0x0002
+#define EP2_IRQ_FLG0x0004
+#define EP3_IRQ_FLG0x0008
+#define EP4_IRQ_FLG0x0010
+#define EP5_IRQ_FLG0x0020
+#define EP6_IRQ_FLG0x0040
+#define EP7_IRQ_FLG0x0080
+#define RESET_IRQ_FLG  0x0100
+#define SOF_EOP_IRQ_FLG0x0200
+#define ID_IRQ_FLG 0x4000
+#define VBUS_IRQ_FLG   0x8000
+
+/* USB Host only registers */
+/* === */
+
+/* Host n Control Register */
+#define HOST_CTL_REG(x)((x) ? 0xC0A0 : 0xC080)
+
+#define PREAMBLE_EN0x0080  /* Preamble enable */
+#define SEQ_SEL0x0040  /* Data Toggle Sequence Bit 
Select */
+#define ISO_EN 0x0010  /* Isochronous enable  */
+#define ARM_EN 0x0001  /* Arm operation */
+
+/* Host n Interrupt Enable Register */
+#define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define SOF_EOP_IRQ_EN 0x0200  /* SOF/EOP Interrupt Enable  */
+#define SOF_EOP_TMOUT_IRQ_EN   0x0800  /* SOF/EOP Timeout Interrupt Enable  */
+#define ID_IRQ_EN  0x4000  /* ID interrupt enable */
+#define VBUS_IRQ_EN0x8000  /* VBUS interrupt enable */
+#define DONE_IRQ_EN0x0001  /* Done Interrupt Enable  */
+
+/* USB status register */
+#define HOST_STAT_MASK 0x02FD
+#define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010)
+#define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004)
+
+/* Host Frame Register */
+#define HOST_FRAME_REG(x)  ((x) ? 0xC0B6 : 0xC096)
+
+#define HOST_FRAME_MASK0x07FF
+
+/* USB Peripheral only registers */
+/* = */
+
+/* Device n Port Sel reg */
+#define DEVICE_N_PORT_SEL(x)   ((x) ? 0xC0A4 : 0xC084)
+
+/* Device n Interrupt Enable Register */
+#define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep)   ((dev)  \
+? (0x0280 + (ep << 4)) \
+: (0x0200 + (ep << 4)))
+#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep)  ((dev)  \
+? (0x0286 + (ep << 4)) \
+  

[patch v8 2/4] USB: add Cypress c67x00 OTG controller core driver

2008-02-20 Thread Peter Korsgaard
This patch add the core driver for the c67x00 USB OTG controller.  The core
driver is responsible for the platform bus binding and creating either
USB HCD or USB Gadget instances for each of the serial interface engines
on the chip.

This driver does not directly implement the HCD or gadget behaviours; it
just controls access to the chip.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
Acked-by: David Brownell <[EMAIL PROTECTED]>
---
 MAINTAINERS |6 +
 drivers/usb/c67x00/c67x00-drv.c |  229 
 include/linux/usb/c67x00.h  |   48 
 3 files changed, 283 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-drv.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-drv.c
@@ -0,0 +1,229 @@
+/*
+ * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+/*
+ * This file implements the common infrastructure for using the c67x00.
+ * It is both the link between the platform configuration and subdrivers and
+ * the link between the common hardware parts and the subdrivers (e.g.
+ * interrupt handling).
+ *
+ * The c67x00 has 2 SIE's (serial interface engine) wich can be configured
+ * to be host, device or OTG (with some limitations, E.G. only SIE1 can be 
OTG).
+ *
+ * Depending on the platform configuration, the SIE's are created and
+ * the corresponding subdriver is initialized (c67x00_probe_sie).
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+
+static void c67x00_probe_sie(struct c67x00_sie *sie,
+struct c67x00_device *dev, int sie_num)
+{
+   spin_lock_init(&sie->lock);
+   sie->dev = dev;
+   sie->sie_num = sie_num;
+   sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num);
+
+   switch (sie->mode) {
+   case C67X00_SIE_UNUSED:
+   dev_info(sie_dev(sie),
+"Not using SIE %d as requested\n", sie->sie_num);
+   break;
+
+   default:
+   dev_err(sie_dev(sie),
+   "Unsupported configuration: 0x%x for SIE %d\n",
+   sie->mode, sie->sie_num);
+   break;
+   }
+}
+
+static void c67x00_remove_sie(struct c67x00_sie *sie)
+{
+}
+
+static irqreturn_t c67x00_irq(int irq, void *__dev)
+{
+   struct c67x00_device *c67x00 = __dev;
+   struct c67x00_sie *sie;
+   u16 msg, int_status;
+   int i, count = 8;
+
+   int_status = c67x00_ll_hpi_status(c67x00);
+   if (!int_status)
+   return IRQ_NONE;
+
+   while (int_status != 0 && (count-- >= 0)) {
+   c67x00_ll_irq(c67x00, int_status);
+   for (i = 0; i < C67X00_SIES; i++) {
+   sie = &c67x00->sie[i];
+   msg = 0;
+   if (int_status & SIEMSG_FLG(i))
+   msg = c67x00_ll_fetch_siemsg(c67x00, i);
+   if (sie->irq)
+   sie->irq(sie, int_status, msg);
+   }
+   int_status = c67x00_ll_hpi_status(c67x00);
+   }
+
+   if (int_status)
+   dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! "
+"status = 0x%04x\n", int_status);
+
+   return IRQ_HANDLED;
+}
+
+/* - */
+
+static int __devinit c67x00_drv_probe(struct platform_device *pdev)
+{
+   struct c67x00_device *c67x00;
+   struct c67x00_platform_data *pdata;
+   struct resource *res, *res2;
+   int ret, i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENODEV;
+
+   res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!res2)
+   return -ENODEV;
+
+   pdata

[patch v8 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-02-20 Thread Peter Korsgaard
The Cypress c67x00 (EZ-Host/EZ-OTG) controllers are multi-role low/fullspeed
USB controllers. This patch series implements a HCD driver and shows the
work-in-progress status of a gadget driver.

I believe patch 1..3 are ready, and I would like to see them queued up for
mainline.

Changes since v7:
 - Moved dummy hcd probe/remove functions for conditional hcd support into
   udc patch.
 - Moved usb_disabled() check into c67x00_hcd_probe().
 - Moved c67x00_get_comm_reg() to udc patch as it is only needed for gadget
   support.

Changes since v6:
 - Addressed David and Alan's comments (removed done list + tasklet)

Changes since v5:
 - Merged c67x00_ll_{get,set}_siemsg() into c67x00_ll_fetch_siemsg().
 - Fix for interrupt race condition at probe time (reported by Grant)

Changes since v4:
 - Addressed Grant's comments (c67x00_dev->c67x00_hcd_dev, label indent)
 - Moved c67x00_ll_set_ep_{ctrl,packet_size}_reg() to patch 4 as they are
   only needed for gadget support.

Changes since v3:
- Lots of cleanups: checkpatch, interrupt handling, c67x00_ prefixes, ..
- The dummy platform_device's created per serial engine are gone.
- Gadget driver (WIP)

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v7 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-02-20 Thread Peter Korsgaard
>>>>> "Greg" == Greg KH <[EMAIL PROTECTED]> writes:

 Greg> On Tue, Feb 19, 2008 at 04:09:19PM +0100, Peter Korsgaard wrote:
 >> This patch adds HCD support for the Cypress c67x00 family of devices.
 >> 
 >> Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>

 Greg> And it doesn't build:

 Greg>   CC [M]  drivers/usb/c67x00/c67x00-hcd.o
 Greg> distcc[2413] ERROR: compile 
/home/gregkh/.ccache/c67x00-hcd.tmp.mini.2409.i on localhost failed
 Greg> drivers/usb/c67x00/c67x00-hcd.c:345: error: redefinition of 
'c67x00_hcd_probe'
 Greg> drivers/usb/c67x00/c67x00-hcd.h:119: error: previous definition of 
'c67x00_hcd_probe' was here
 Greg> drivers/usb/c67x00/c67x00-hcd.c:402: error: redefinition of 
'c67x00_hcd_remove'
 Greg> drivers/usb/c67x00/c67x00-hcd.h:126: error: previous definition of 
'c67x00_hcd_remove' was here
 Greg> make[2]: *** [drivers/usb/c67x00/c67x00-hcd.o] Error 1
 Greg> make[1]: *** [drivers/usb/c67x00] Error 2
 Greg> make: *** [_module_drivers/usb] Error 2

Huh, that doesn't make any sense to me. The dumy definitions of
c67x00_hcd_{probe,remove} are protected by an ifndef
CONFIG_USB_C67X00_HCD, and c67x00-hcd.c which contains the real
definitions only gets compiled if CONFIG_USB_C67X00_HCD is
enabled. Could you perhaps provide some more details?

Anyway, the conditional hcd stuff isn't really needed at this point in
the patch series, so I have moved it into patch 4 in the v8 series
I'll post in a minute.

 Greg> This is _after_ removing the obviously incorrect usb_disabled()
 Greg> function that you included in your .h file.

That was again for conditional hcd/udc support. I have now moved the
check into _hcd_probe() instead.

 Greg> I'm going to hold off applying any of these for now, as it
 Greg> doesn't look like something is configured properly here.

Could you give the v8 series a try please?

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v7 1/4] USB: add Cypress c67x00 low level interface code

2008-02-19 Thread Peter Korsgaard
This patch adds the low level support code for the Cypress c67x00 family of
OTG controllers.  The low level code is responsible for register access and
implements the software protocol for communicating with the 16bit
microcontroller inside the c67x00 device.

Communication is done over the HPI interface (16bit SRAM-like parallel bus).

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
Acked-by: David Brownell <[EMAIL PROTECTED]>
---
 drivers/usb/c67x00/c67x00-ll-hpi.c |  410 +
 drivers/usb/c67x00/c67x00.h|  285 +
 2 files changed, 695 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00.h
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00.h
@@ -0,0 +1,285 @@
+/*
+ * c67x00.h: Cypress C67X00 USB register and field definitions
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#ifndef _USB_C67X00_H
+#define _USB_C67X00_H
+
+#include 
+#include 
+#include 
+#include 
+
+/* -
+ * Cypress C67x00 register definitions
+ */
+
+/* Hardware Revision Register */
+#define HW_REV_REG 0xC004
+
+/* General USB registers */
+/* = */
+
+/* USB Control Register */
+#define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A)
+
+#define LOW_SPEED_PORT(x)  ((x) ? 0x0800 : 0x0400)
+#define HOST_MODE  0x0200
+#define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080)
+#define SOF_EOP_EN(x)  ((x) ? 0x0002 : 0x0001)
+
+/* USB status register - Notice it has different content in hcd/udc mode */
+#define USB_STAT_REG(x)((x) ? 0xC0B0 : 0xC090)
+
+#define EP0_IRQ_FLG0x0001
+#define EP1_IRQ_FLG0x0002
+#define EP2_IRQ_FLG0x0004
+#define EP3_IRQ_FLG0x0008
+#define EP4_IRQ_FLG0x0010
+#define EP5_IRQ_FLG0x0020
+#define EP6_IRQ_FLG0x0040
+#define EP7_IRQ_FLG0x0080
+#define RESET_IRQ_FLG  0x0100
+#define SOF_EOP_IRQ_FLG0x0200
+#define ID_IRQ_FLG 0x4000
+#define VBUS_IRQ_FLG   0x8000
+
+/* USB Host only registers */
+/* === */
+
+/* Host n Control Register */
+#define HOST_CTL_REG(x)((x) ? 0xC0A0 : 0xC080)
+
+#define PREAMBLE_EN0x0080  /* Preamble enable */
+#define SEQ_SEL0x0040  /* Data Toggle Sequence Bit 
Select */
+#define ISO_EN 0x0010  /* Isochronous enable  */
+#define ARM_EN 0x0001  /* Arm operation */
+
+/* Host n Interrupt Enable Register */
+#define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define SOF_EOP_IRQ_EN 0x0200  /* SOF/EOP Interrupt Enable  */
+#define SOF_EOP_TMOUT_IRQ_EN   0x0800  /* SOF/EOP Timeout Interrupt Enable  */
+#define ID_IRQ_EN  0x4000  /* ID interrupt enable */
+#define VBUS_IRQ_EN0x8000  /* VBUS interrupt enable */
+#define DONE_IRQ_EN0x0001  /* Done Interrupt Enable  */
+
+/* USB status register */
+#define HOST_STAT_MASK 0x02FD
+#define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010)
+#define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004)
+
+/* Host Frame Register */
+#define HOST_FRAME_REG(x)  ((x) ? 0xC0B6 : 0xC096)
+
+#define HOST_FRAME_MASK0x07FF
+
+/* USB Peripheral only registers */
+/* = */
+
+/* Device n Port Sel reg */
+#define DEVICE_N_PORT_SEL(x)   ((x) ? 0xC0A4 : 0xC084)
+
+/* Device n Interrupt Enable Register */
+#define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep)   ((dev)  \
+? (0x0280 + (ep << 4)) \
+: (0x0200 + (ep << 4)))
+#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep)  ((dev)  \
+? (0x0286 + (ep << 4)) \
+  

[patch v7 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-02-19 Thread Peter Korsgaard
This patch adds HCD support for the Cypress c67x00 family of devices.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/Makefile   |2 
 drivers/usb/c67x00/Makefile|   11 
 drivers/usb/c67x00/c67x00-drv.c|   13 
 drivers/usb/c67x00/c67x00-hcd.c|  409 
 drivers/usb/c67x00/c67x00-hcd.h|  150 
 drivers/usb/c67x00/c67x00-ll-hpi.c |   75 ++
 drivers/usb/c67x00/c67x00-sched.c  | 1170 +
 drivers/usb/c67x00/c67x00.h|9 
 drivers/usb/host/Kconfig   |   12 
 9 files changed, 1851 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
@@ -0,0 +1,409 @@
+/*
+ * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+#include "c67x00-hcd.h"
+
+/* --
+ * Root Hub Support
+ */
+
+static __u8 c67x00_hub_des[] = {
+   0x09,   /*  __u8  bLength; */
+   0x29,   /*  __u8  bDescriptorType; Hub-descriptor */
+   0x02,   /*  __u8  bNbrPorts; */
+   0x00,   /* __u16  wHubCharacteristics; */
+   0x00,   /*   (per-port OC, no power switching) */
+   0x32,   /*  __u8  bPwrOn2pwrGood; 2ms */
+   0x00,   /*  __u8  bHubContrCurrent; 0 mA */
+   0x00,   /*  __u8  DeviceRemovable; ** 7 Ports max ** */
+   0xff,   /*  __u8  PortPwrCtrlMask; ** 7 ports max ** */
+};
+
+static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port)
+{
+   struct c67x00_hcd *c67x00 = sie->private_data;
+   unsigned long flags;
+
+   c67x00_ll_husb_reset(sie, port);
+
+   spin_lock_irqsave(&c67x00->lock, flags);
+   c67x00_ll_husb_reset_port(sie, port);
+   spin_unlock_irqrestore(&c67x00->lock, flags);
+
+   c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT);
+}
+
+static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status;
+   int i;
+
+   *buf = 0;
+   status = c67x00_ll_usb_get_status(sie);
+   for (i = 0; i < C67X00_PORTS; i++)
+   if (status & PORT_CONNECT_CHANGE(i))
+   *buf |= (1 << i);
+
+   /* bit 0 denotes hub change, b1..n port change */
+   *buf <<= 1;
+
+   return !!*buf;
+}
+
+static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 wIndex, char *buf, u16 wLength)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status, usb_status;
+   int len = 0;
+   unsigned int port = wIndex-1;
+   u16 wPortChange, wPortStatus;
+
+   switch (typeReq) {
+
+   case GetHubStatus:
+   *(__le32 *) buf = cpu_to_le32(0);
+   len = 4;/* hub power */
+   break;
+
+   case GetPortStatus:
+   if (wIndex > C67X00_PORTS)
+   return -EPIPE;
+
+   status = c67x00_ll_usb_get_status(sie);
+   usb_status = c67x00_ll_get_usb_ctl(sie);
+
+   wPortChange = 0;
+   if (status & PORT_CONNECT_CHANGE(port))
+   wPortChange |= USB_PORT_STAT_C_CONNECTION;
+
+   wPortStatus = USB_PORT_STAT_POWER;
+   if (!(status & PORT_SE0_STATUS(port)))
+   wPortStatus |= USB_PORT_STAT_CONNECTION;
+   if (usb_status & LOW_SPEED_PORT(port)) {
+   wPortStatus |= USB_PORT_STAT_LOW_SPEED;
+   c67x00->low_speed_ports |= (1 <&l

[patch v7 2/4] USB: add Cypress c67x00 OTG controller core driver

2008-02-19 Thread Peter Korsgaard
This patch add the core driver for the c67x00 USB OTG controller.  The core
driver is responsible for the platform bus binding and creating either
USB HCD or USB Gadget instances for each of the serial interface engines
on the chip.

This driver does not directly implement the HCD or gadget behaviours; it
just controls access to the chip.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
Acked-by: David Brownell <[EMAIL PROTECTED]>
---
 MAINTAINERS |6 +
 drivers/usb/c67x00/c67x00-drv.c |  232 
 include/linux/usb/c67x00.h  |   48 
 3 files changed, 286 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-drv.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-drv.c
@@ -0,0 +1,232 @@
+/*
+ * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+/*
+ * This file implements the common infrastructure for using the c67x00.
+ * It is both the link between the platform configuration and subdrivers and
+ * the link between the common hardware parts and the subdrivers (e.g.
+ * interrupt handling).
+ *
+ * The c67x00 has 2 SIE's (serial interface engine) wich can be configured
+ * to be host, device or OTG (with some limitations, E.G. only SIE1 can be 
OTG).
+ *
+ * Depending on the platform configuration, the SIE's are created and
+ * the corresponding subdriver is initialized (c67x00_probe_sie).
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+
+static void c67x00_probe_sie(struct c67x00_sie *sie,
+struct c67x00_device *dev, int sie_num)
+{
+   spin_lock_init(&sie->lock);
+   sie->dev = dev;
+   sie->sie_num = sie_num;
+   sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num);
+
+   switch (sie->mode) {
+   case C67X00_SIE_UNUSED:
+   dev_info(sie_dev(sie),
+"Not using SIE %d as requested\n", sie->sie_num);
+   break;
+
+   default:
+   dev_err(sie_dev(sie),
+   "Unsupported configuration: 0x%x for SIE %d\n",
+   sie->mode, sie->sie_num);
+   break;
+   }
+}
+
+static void c67x00_remove_sie(struct c67x00_sie *sie)
+{
+}
+
+static irqreturn_t c67x00_irq(int irq, void *__dev)
+{
+   struct c67x00_device *c67x00 = __dev;
+   struct c67x00_sie *sie;
+   u16 msg, int_status;
+   int i, count = 8;
+
+   int_status = c67x00_ll_hpi_status(c67x00);
+   if (!int_status)
+   return IRQ_NONE;
+
+   while (int_status != 0 && (count-- >= 0)) {
+   c67x00_ll_irq(c67x00, int_status);
+   for (i = 0; i < C67X00_SIES; i++) {
+   sie = &c67x00->sie[i];
+   msg = 0;
+   if (int_status & SIEMSG_FLG(i))
+   msg = c67x00_ll_fetch_siemsg(c67x00, i);
+   if (sie->irq)
+   sie->irq(sie, int_status, msg);
+   }
+   int_status = c67x00_ll_hpi_status(c67x00);
+   }
+
+   if (int_status)
+   dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! "
+"status = 0x%04x\n", int_status);
+
+   return IRQ_HANDLED;
+}
+
+/* - */
+
+static int __devinit c67x00_drv_probe(struct platform_device *pdev)
+{
+   struct c67x00_device *c67x00;
+   struct c67x00_platform_data *pdata;
+   struct resource *res, *res2;
+   int ret, i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENODEV;
+
+   res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!res2)
+   return -ENODEV;
+

[patch v7 4/4] USB: add Cypress c67x00 OTG controller gadget driver

2008-02-19 Thread Peter Korsgaard
nfig
@@ -335,6 +335,13 @@
depends on USB_GADGET_AT91
default USB_GADGET
 
+config USB_GADGET_C67X00
+   boolean "Cypress C67X00 Gadget support"
+   depends on USB_C67X00_DRV
+   select USB_GADGET_SELECTED
+   help
+ This enables the gadget functionality of the Cypress C67X00.
+
 config USB_GADGET_DUMMY_HCD
boolean "Dummy HCD (DEVELOPMENT)"
depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL
Index: linux-2.6/drivers/usb/gadget/gadget_chips.h
===
--- linux-2.6.orig/drivers/usb/gadget/gadget_chips.h
+++ linux-2.6/drivers/usb/gadget/gadget_chips.h
@@ -147,6 +147,12 @@
 #definegadget_is_m66592(g) 0
 #endif
 
+#ifdef CONFIG_USB_GADGET_C67X00
+#definegadget_is_c67x00(g) !strcmp("c67x00_udc", (g)->name)
+#else
+#definegadget_is_c67x00(g) 0
+#endif
+
 
 // CONFIG_USB_GADGET_SX2
 // CONFIG_USB_GADGET_AU1X00
@@ -212,5 +218,7 @@
return 0x20;
else if (gadget_is_m66592(gadget))
return 0x21;
+   else if (gadget_is_c67x00(gadget))
+   return 0x22;
return -ENOENT;
 }
Index: linux-2.6/drivers/usb/host/Kconfig
===
--- linux-2.6.orig/drivers/usb/host/Kconfig
+++ linux-2.6/drivers/usb/host/Kconfig
@@ -261,15 +261,3 @@
  To compile this driver as a module, choose M here: the
  module will be called r8a66597-hcd.
 
-config USB_C67X00_HCD
-   tristate "Cypress C67x00 HCD support"
-   depends on USB
-   help
- The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
- host/peripheral/OTG USB controllers.
-
- Enable this option to support this chip in host controller mode.
- If unsure, say N.
-
- To compile this driver as a module, choose M here: the
- module will be called c67x00.
Index: linux-2.6/drivers/usb/Makefile
===
--- linux-2.6.orig/drivers/usb/Makefile
+++ linux-2.6/drivers/usb/Makefile
@@ -17,7 +17,7 @@
 obj-$(CONFIG_USB_U132_HCD) += host/
 obj-$(CONFIG_USB_R8A66597_HCD) += host/
 
-obj-$(CONFIG_USB_C67X00_HCD)   += c67x00/
+obj-$(CONFIG_USB_C67X00_DRV)   += c67x00/
 
 obj-$(CONFIG_USB_ACM)  += class/
 obj-$(CONFIG_USB_PRINTER)  += class/
Index: linux-2.6/drivers/usb/Kconfig
===
--- linux-2.6.orig/drivers/usb/Kconfig
+++ linux-2.6/drivers/usb/Kconfig
@@ -97,6 +97,8 @@
 
 source "drivers/usb/host/Kconfig"
 
+source "drivers/usb/c67x00/Kconfig"
+
 source "drivers/usb/class/Kconfig"
 
 source "drivers/usb/storage/Kconfig"
Index: linux-2.6/drivers/usb/c67x00/Kconfig
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/Kconfig
@@ -0,0 +1,21 @@
+#
+# Cypress C67x00 USB controller
+#
+config USB_C67X00_DRV
+   tristate "Cypress C67x00 support"
+   # only allowed to be =y if both USB!=m and USB_GADGET!=m
+   depends on (!USB && USB_GADGET) || (!USB_GADGET && USB) || (USB && 
USB_GADGET)
+   help
+ The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
+ host/peripheral USB controllers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called c67x00.
+
+config USB_C67X00_HCD
+   bool "Cypress C67X00 HCD support"
+   depends on USB && USB_C67X00_DRV
+   default y
+   help
+ Enable this option to support the Cypress C67x00 in host
+ controller mode.

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v7 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-02-19 Thread Peter Korsgaard
The Cypress c67x00 (EZ-Host/EZ-OTG) controllers are multi-role low/fullspeed
USB controllers. This patch series implements a HCD driver and shows the
work-in-progress status of a gadget driver.

I believe patch 1..3 are ready, and I would like to see them queued up for
mainline.

Changes since v6:
 - Addressed David and Alan's comments (removed done list + tasklet)

Changes since v5:
 - Merged c67x00_ll_{get,set}_siemsg() into c67x00_ll_fetch_siemsg().
 - Fix for interrupt race condition at probe time (reported by Grant)

Changes since v4:
 - Addressed Grant's comments (c67x00_dev->c67x00_hcd_dev, label indent)
 - Moved c67x00_ll_set_ep_{ctrl,packet_size}_reg() to patch 4 as they are
   only needed for gadget support.
 - Added c67x00_ prefix to struct lcp_int_data

Changes since v3:
- Lots of cleanups: checkpatch, interrupt handling, c67x00_ prefixes, ..
- The dummy platform_device's created per serial engine are gone.
- Gadget driver (WIP)

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ehci-fsl: mpc834x config symbol is PPC_MPC834x, not MPC834x

2008-02-11 Thread Peter Korsgaard
The config symbol for mpc834x processors is CONFIG_PPC_MPC834x,
not CONFIG_MPC834x.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index d97b16b..2dd0544 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -72,7 +72,7 @@ config USB_EHCI_FSL
bool
depends on USB_EHCI_HCD
select USB_EHCI_ROOT_HUB_TT
-   default y if MPC834x || PPC_MPC831x
+   default y if PPC_MPC834x || PPC_MPC831x
---help---
  Variation of ARC USB block used in some Freescale chips.
 
-- 
debian.1.5.3.7.1-dirty

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


Re: [patch v6 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-02-04 Thread Peter Korsgaard
>>>>> "alf" == alf scherer <[EMAIL PROTECTED]> writes:

 alf> Actually, the LEON3-soft CPU vendor only supports 2.6.21, so for
 alf> that reason I'm kind stuck. I could try to add LEON3
 alf> hardware-specific support to the latest linux release, but that
 alf> would actually be more work than just porting the c67x00 back to
 alf> 2.6.21. I've already adopted the code to 2.6.21 kernel HCD.

Ok.

 alf> I see, thanks for the hint! BTW, do you plan to add
 alf> peripheral-mode support to the driver? If so, I'd be eager to
 alf> help you with development and testing.

Yes, see patch 4 in the patch series you are replying to.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v6 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-02-04 Thread Peter Korsgaard
>>>>> "alf" == alf scherer <[EMAIL PROTECTED]> writes:

 alf> Hello Peter,
 alf> Hello Alan,

 alf> I have got the HPE-mini FPGA embedded development board running
 alf> a LEON3-SPARC Snapgear-linux with a 2.6.21 kernel. The Cypress
 alf> cy7c67300 is directly connected to an Altera Cylcone II FPGA in
 alf> HPI mode.

Ok. Any particular reason why you're stuck with 2.6.21? The kernel HCD
interface has changed a bit since then, so you'l have to fix that up.

 alf>  First, I was very glad to find a c67x00 driver for 2.6, but I
 alf> need to do some porting stuff back to 2.6.21/SPARC, that
 alf> should'nt be a big deal. However, while reading the code back
 alf> and forth , I was just wondering how and where the
 alf> "pdev->dev.platform_data" gets allocated as it is referenced in
 alf> function c67x00_drv_probe() without the
 alf> platform_device_add_data() beeing called anywhere before. I've
 alf> browsed through the drivers/base-code where all platform-driver
 alf> specific stuff is done, but I really wasn't able to see where
 alf> this allocation happens.  Can you give me a hint where to look
 alf> at?

In your platform code like for other platform devices, E.G.:

static struct resource c67x00_resources[] = {
[0] = {
.start  = 0x8400,
.end= 0x840f,
.flags  = IORESOURCE_MEM,
},
[1] = {
.start  = 3,
.end= 3,
.flags  = IORESOURCE_IRQ,
},
};

static struct c67x00_platform_data c67x00_data = {
.sie_config = C67X00_SIE1_HOST | C67X00_SIE2_PERIPHERAL_B,
.hpi_regstep= 0x02, /* A0 not connected on 16bit bus */
};

static struct platform_device c67x00_dev = {
.name   = "c67x00",
.id = 0,
.num_resources  = ARRAY_SIZE(c67x00_resources),
.resource   = c67x00_resources,
.dev.platform_data  = &c67x00_data,
};

And the c67x00_dev structure is then registerred with the platform bus
with platform_add_devices() or similar.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v6 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-01-30 Thread Peter Korsgaard
>>>>> "Alan" == Alan Stern <[EMAIL PROTECTED]> writes:

 Alan> On Tue, 29 Jan 2008, Peter Korsgaard wrote:
 >> This patch adds HCD support for the Cypress c67x00 family of devices.

 >> --- /dev/null
 >> +++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.c

 >> +int c67x00_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 >> +{
 >> +   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
 >> +   unsigned long flags;
 >> +   int rc;
 >> +
 >> +   spin_lock_irqsave(&c67x00->lock, flags);
 >> +   rc = usb_hcd_check_unlink_urb(hcd, urb, status);
 >> +   if (rc)
 >> +   goto done;
 >> +
 >> +   c67x00_release_urb(c67x00, urb);
 >> +   usb_hcd_unlink_urb_from_ep(hcd, urb);
 >> +   spin_unlock_irqrestore(&c67x00->lock, flags);
 >> +
 >> +   usb_hcd_giveback_urb(hcd, urb, status);

 Alan> This is wrong.  usb_hcd_giveback_urb() must be called with local
 Alan> interrupts disabled.

Ups, good catch. I've put a spin_unlock() / spin_lock() around it and
moved the _irqrestore down below now.

 >> +/*
 >> + * pre: urb != NULL and c67x00 locked, urb unlocked
 >> + */
 >> +static inline void
 >> +c67x00_giveback_urb(struct c67x00_hcd *c67x00, struct urb *urb, int status)
 >> +{
 >> +   struct c67x00_urb_priv *urbp;
 >> +
 >> +   if (!urb)
 >> +   return;

 Alan> Since you have the documented precondition that urb != NULL, and since
 Alan> this routine is never called in a context where urb could be NULL,
 Alan> there's no need for this test.  Also, I doubt that this routine really
 Alan> needs to be inline (and besides, the compiler is better at making such
 Alan> decisions than we are).

It can be null in c67x00_check_td_list, so it's actually the comment
that's wrong. I've fixed that.

 >> +static void c67x00_sched_done(unsigned long __c67x00)
 >> +{
 >> +   struct c67x00_hcd *c67x00 = (struct c67x00_hcd *)__c67x00;
 >> +   struct c67x00_urb_priv *urbp, *tmp;
 >> +   struct urb *urb;
 >> +
 >> +   spin_lock(&c67x00->lock);
 >> +
 >> +   /* Loop over the done list and give back all the urbs */
 >> +   list_for_each_entry_safe(urbp, tmp, &c67x00->done_list, hep_node) {
 >> +   urb = urbp->urb;
 >> +   c67x00_release_urb(c67x00, urb);
 >> +   if (!usb_hcd_check_unlink_urb(c67x00_hcd_to_hcd(c67x00),
 >> + urb, urbp->status)) {

 Alan> The function call above is completely wrong.  It is meant to be used only
 Alan> from within the dequeue method.

Ahh, so should I just unconditionally do the unlink_urb_from_ep and
giveback_urb?

 >> +   usb_hcd_unlink_urb_from_ep(c67x00_hcd_to_hcd(c67x00),
 >> +  urb);
 >> +   spin_unlock(&c67x00->lock);
 >> +   usb_hcd_giveback_urb(c67x00_hcd_to_hcd(c67x00), urb,
 >> +urbp->status);
 >> +   spin_lock(&c67x00->lock);
 >> +   }
 >> +   }
 >> +   spin_unlock(&c67x00->lock);
 >> +}

 Alan> Is there some reason this routine needs to run in a tasklet?  Why not
 Alan> just call it directly?

Hmm, I don't actually remember anymore. It's was written back in
Spring 2006 by Jan. I'll try moving it out of the tasklet and see what
it gives.

 Alan> Also, the fact that it is in a tasklet means that it runs with
 Alan> interrupts enabled.  Hence your spin_lock() and spin_unlock() calls
 Alan> will not do the right thing.

Ahh, ofcause.

Thanks for the feedback!

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v6 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-01-29 Thread Peter Korsgaard
This patch adds HCD support for the Cypress c67x00 family of devices.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/Makefile   |2 
 drivers/usb/c67x00/Makefile|   11 
 drivers/usb/c67x00/c67x00-drv.c|   13 
 drivers/usb/c67x00/c67x00-hcd.c|  410 
 drivers/usb/c67x00/c67x00-hcd.h|  152 
 drivers/usb/c67x00/c67x00-ll-hpi.c |   75 ++
 drivers/usb/c67x00/c67x00-sched.c  | 1194 +
 drivers/usb/c67x00/c67x00.h|9 
 drivers/usb/host/Kconfig   |   12 
 9 files changed, 1878 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
@@ -0,0 +1,410 @@
+/*
+ * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+#include "c67x00-hcd.h"
+
+/* --
+ * Root Hub Support
+ */
+
+static __u8 c67x00_hub_des[] = {
+   0x09,   /*  __u8  bLength; */
+   0x29,   /*  __u8  bDescriptorType; Hub-descriptor */
+   0x02,   /*  __u8  bNbrPorts; */
+   0x00,   /* __u16  wHubCharacteristics; */
+   0x00,   /*   (per-port OC, no power switching) */
+   0x32,   /*  __u8  bPwrOn2pwrGood; 2ms */
+   0x00,   /*  __u8  bHubContrCurrent; 0 mA */
+   0x00,   /*  __u8  DeviceRemovable; ** 7 Ports max ** */
+   0xff,   /*  __u8  PortPwrCtrlMask; ** 7 ports max ** */
+};
+
+static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port)
+{
+   struct c67x00_hcd *c67x00 = sie->private_data;
+   unsigned long flags;
+
+   c67x00_ll_husb_reset(sie, port);
+
+   spin_lock_irqsave(&c67x00->lock, flags);
+   c67x00_ll_husb_reset_port(sie, port);
+   spin_unlock_irqrestore(&c67x00->lock, flags);
+
+   c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT);
+}
+
+static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status;
+   int i;
+
+   *buf = 0;
+   status = c67x00_ll_usb_get_status(sie);
+   for (i = 0; i < C67X00_PORTS; i++)
+   if (status & PORT_CONNECT_CHANGE(i))
+   *buf |= (1 << i);
+
+   /* bit 0 denotes hub change, b1..n port change */
+   *buf <<= 1;
+
+   return !!*buf;
+}
+
+static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 wIndex, char *buf, u16 wLength)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status, usb_status;
+   int len = 0;
+   unsigned int port = wIndex-1;
+   u16 wPortChange, wPortStatus;
+
+   switch (typeReq) {
+
+   case GetHubStatus:
+   *(__le32 *) buf = cpu_to_le32(0);
+   len = 4;/* hub power */
+   break;
+
+   case GetPortStatus:
+   if (wIndex > C67X00_PORTS)
+   return -EPIPE;
+
+   status = c67x00_ll_usb_get_status(sie);
+   usb_status = c67x00_ll_get_usb_ctl(sie);
+
+   wPortChange = 0;
+   if (status & PORT_CONNECT_CHANGE(port))
+   wPortChange |= USB_PORT_STAT_C_CONNECTION;
+
+   wPortStatus = USB_PORT_STAT_POWER;
+   if (!(status & PORT_SE0_STATUS(port)))
+   wPortStatus |= USB_PORT_STAT_CONNECTION;
+   if (usb_status & LOW_SPEED_PORT(port)) {
+   wPortStatus |= USB_PORT_STAT_LOW_SPEED;
+   c67x00->low_speed_ports |= (1 <&l

[patch v6 4/4] USB: add Cypress c67x00 OTG controller gadget driver

2008-01-29 Thread Peter Korsgaard
nfig
@@ -324,6 +324,13 @@
depends on USB_GADGET_AT91
default USB_GADGET
 
+config USB_GADGET_C67X00
+   boolean "Cypress C67X00 Gadget support"
+   depends on USB_C67X00_DRV
+   select USB_GADGET_SELECTED
+   help
+ This enables the gadget functionality of the Cypress C67X00.
+
 config USB_GADGET_DUMMY_HCD
boolean "Dummy HCD (DEVELOPMENT)"
depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL
Index: linux-2.6/drivers/usb/gadget/gadget_chips.h
===
--- linux-2.6.orig/drivers/usb/gadget/gadget_chips.h
+++ linux-2.6/drivers/usb/gadget/gadget_chips.h
@@ -147,6 +147,12 @@
 #definegadget_is_m66592(g) 0
 #endif
 
+#ifdef CONFIG_USB_GADGET_C67X00
+#definegadget_is_c67x00(g) !strcmp("c67x00_udc", (g)->name)
+#else
+#definegadget_is_c67x00(g) 0
+#endif
+
 
 // CONFIG_USB_GADGET_SX2
 // CONFIG_USB_GADGET_AU1X00
@@ -212,5 +218,7 @@
return 0x20;
else if (gadget_is_m66592(gadget))
return 0x21;
+   else if (gadget_is_c67x00(gadget))
+   return 0x22;
return -ENOENT;
 }
Index: linux-2.6/drivers/usb/host/Kconfig
===
--- linux-2.6.orig/drivers/usb/host/Kconfig
+++ linux-2.6/drivers/usb/host/Kconfig
@@ -261,15 +261,3 @@
  To compile this driver as a module, choose M here: the
  module will be called r8a66597-hcd.
 
-config USB_C67X00_HCD
-   tristate "Cypress C67x00 HCD support"
-   depends on USB
-   help
- The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
- host/peripheral/OTG USB controllers.
-
- Enable this option to support this chip in host controller mode.
- If unsure, say N.
-
- To compile this driver as a module, choose M here: the
- module will be called c67x00.
Index: linux-2.6/drivers/usb/Makefile
===
--- linux-2.6.orig/drivers/usb/Makefile
+++ linux-2.6/drivers/usb/Makefile
@@ -17,7 +17,7 @@
 obj-$(CONFIG_USB_U132_HCD) += host/
 obj-$(CONFIG_USB_R8A66597_HCD) += host/
 
-obj-$(CONFIG_USB_C67X00_HCD)   += c67x00/
+obj-$(CONFIG_USB_C67X00_DRV)   += c67x00/
 
 obj-$(CONFIG_USB_ACM)  += class/
 obj-$(CONFIG_USB_PRINTER)  += class/
Index: linux-2.6/drivers/usb/Kconfig
===
--- linux-2.6.orig/drivers/usb/Kconfig
+++ linux-2.6/drivers/usb/Kconfig
@@ -92,6 +92,8 @@
 
 source "drivers/usb/host/Kconfig"
 
+source "drivers/usb/c67x00/Kconfig"
+
 source "drivers/usb/class/Kconfig"
 
 source "drivers/usb/storage/Kconfig"
Index: linux-2.6/drivers/usb/c67x00/Kconfig
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/Kconfig
@@ -0,0 +1,21 @@
+#
+# Cypress C67x00 USB controller
+#
+config USB_C67X00_DRV
+   tristate "Cypress C67x00 support"
+   # only allowed to be =y if both USB!=m and USB_GADGET!=m
+   depends on (!USB && USB_GADGET) || (!USB_GADGET && USB) || (USB && 
USB_GADGET)
+   help
+ The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
+ host/peripheral USB controllers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called c67x00.
+
+config USB_C67X00_HCD
+   bool "Cypress C67X00 HCD support"
+   depends on USB && USB_C67X00_DRV
+   default y
+   help
+ Enable this option to support the Cypress C67x00 in host
+ controller mode.

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v6 1/4] USB: add Cypress c67x00 low level interface code

2008-01-29 Thread Peter Korsgaard
This patch adds the low level support code for the Cypress c67x00 family of
OTG controllers.  The low level code is responsible for register access and
implements the software protocol for communicating with the 16bit
microcontroller inside the c67x00 device.

Communication is done over the HPI interface (16bit SRAM-like parallel bus).

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/c67x00/c67x00-ll-hpi.c |  410 +
 drivers/usb/c67x00/c67x00.h|  285 +
 2 files changed, 695 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00.h
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00.h
@@ -0,0 +1,285 @@
+/*
+ * c67x00.h: Cypress C67X00 USB register and field definitions
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#ifndef _USB_C67X00_H
+#define _USB_C67X00_H
+
+#include 
+#include 
+#include 
+#include 
+
+/* -
+ * Cypress C67x00 register definitions
+ */
+
+/* Hardware Revision Register */
+#define HW_REV_REG 0xC004
+
+/* General USB registers */
+/* = */
+
+/* USB Control Register */
+#define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A)
+
+#define LOW_SPEED_PORT(x)  ((x) ? 0x0800 : 0x0400)
+#define HOST_MODE  0x0200
+#define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080)
+#define SOF_EOP_EN(x)  ((x) ? 0x0002 : 0x0001)
+
+/* USB status register - Notice it has different content in hcd/udc mode */
+#define USB_STAT_REG(x)((x) ? 0xC0B0 : 0xC090)
+
+#define EP0_IRQ_FLG0x0001
+#define EP1_IRQ_FLG0x0002
+#define EP2_IRQ_FLG0x0004
+#define EP3_IRQ_FLG0x0008
+#define EP4_IRQ_FLG0x0010
+#define EP5_IRQ_FLG0x0020
+#define EP6_IRQ_FLG0x0040
+#define EP7_IRQ_FLG0x0080
+#define RESET_IRQ_FLG  0x0100
+#define SOF_EOP_IRQ_FLG0x0200
+#define ID_IRQ_FLG 0x4000
+#define VBUS_IRQ_FLG   0x8000
+
+/* USB Host only registers */
+/* === */
+
+/* Host n Control Register */
+#define HOST_CTL_REG(x)((x) ? 0xC0A0 : 0xC080)
+
+#define PREAMBLE_EN0x0080  /* Preamble enable */
+#define SEQ_SEL0x0040  /* Data Toggle Sequence Bit 
Select */
+#define ISO_EN 0x0010  /* Isochronous enable  */
+#define ARM_EN 0x0001  /* Arm operation */
+
+/* Host n Interrupt Enable Register */
+#define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define SOF_EOP_IRQ_EN 0x0200  /* SOF/EOP Interrupt Enable  */
+#define SOF_EOP_TMOUT_IRQ_EN   0x0800  /* SOF/EOP Timeout Interrupt Enable  */
+#define ID_IRQ_EN  0x4000  /* ID interrupt enable */
+#define VBUS_IRQ_EN0x8000  /* VBUS interrupt enable */
+#define DONE_IRQ_EN0x0001  /* Done Interrupt Enable  */
+
+/* USB status register */
+#define HOST_STAT_MASK 0x02FD
+#define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010)
+#define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004)
+
+/* Host Frame Register */
+#define HOST_FRAME_REG(x)  ((x) ? 0xC0B6 : 0xC096)
+
+#define HOST_FRAME_MASK0x07FF
+
+/* USB Peripheral only registers */
+/* = */
+
+/* Device n Port Sel reg */
+#define DEVICE_N_PORT_SEL(x)   ((x) ? 0xC0A4 : 0xC084)
+
+/* Device n Interrupt Enable Register */
+#define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep)   ((dev)  \
+? (0x0280 + (ep << 4)) \
+: (0x0200 + (ep << 4)))
+#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep)  ((dev)  \
+? (0x0286 + (ep << 4)) \
+: (0x0206 + (ep << 4)))
+
+#defin

[patch v6 2/4] USB: add Cypress c67x00 OTG controller core driver

2008-01-29 Thread Peter Korsgaard
This patch add the core driver for the c67x00 USB OTG controller.  The core
driver is responsible for the platform bus binding and creating either
USB HCD or USB Gadget instances for each of the serial interface engines
on the chip.

This driver does not directly implement the HCD or gadget behaviours; it
just controls access to the chip.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 MAINTAINERS |6 +
 drivers/usb/c67x00/c67x00-drv.c |  232 
 include/linux/usb/c67x00.h  |   48 
 3 files changed, 286 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-drv.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-drv.c
@@ -0,0 +1,232 @@
+/*
+ * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+/*
+ * This file implements the common infrastructure for using the c67x00.
+ * It is both the link between the platform configuration and subdrivers and
+ * the link between the common hardware parts and the subdrivers (e.g.
+ * interrupt handling).
+ *
+ * The c67x00 has 2 SIE's (serial interface engine) wich can be configured
+ * to be host, device or OTG (with some limitations, E.G. only SIE1 can be 
OTG).
+ *
+ * Depending on the platform configuration, the SIE's are created and
+ * the corresponding subdriver is initialized (c67x00_probe_sie).
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+
+static void c67x00_probe_sie(struct c67x00_sie *sie,
+struct c67x00_device *dev, int sie_num)
+{
+   spin_lock_init(&sie->lock);
+   sie->dev = dev;
+   sie->sie_num = sie_num;
+   sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num);
+
+   switch (sie->mode) {
+   case C67X00_SIE_UNUSED:
+   dev_info(sie_dev(sie),
+"Not using SIE %d as requested\n", sie->sie_num);
+   break;
+
+   default:
+   dev_err(sie_dev(sie),
+   "Unsupported configuration: 0x%x for SIE %d\n",
+   sie->mode, sie->sie_num);
+   break;
+   }
+}
+
+static void c67x00_remove_sie(struct c67x00_sie *sie)
+{
+}
+
+static irqreturn_t c67x00_irq(int irq, void *__dev)
+{
+   struct c67x00_device *c67x00 = __dev;
+   struct c67x00_sie *sie;
+   u16 msg, int_status;
+   int i, count = 8;
+
+   int_status = c67x00_ll_hpi_status(c67x00);
+   if (!int_status)
+   return IRQ_NONE;
+
+   while (int_status != 0 && (count-- >= 0)) {
+   c67x00_ll_irq(c67x00, int_status);
+   for (i = 0; i < C67X00_SIES; i++) {
+   sie = &c67x00->sie[i];
+   msg = 0;
+   if (int_status & SIEMSG_FLG(i))
+   msg = c67x00_ll_fetch_siemsg(c67x00, i);
+   if (sie->irq)
+   sie->irq(sie, int_status, msg);
+   }
+   int_status = c67x00_ll_hpi_status(c67x00);
+   }
+
+   if (int_status)
+   dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! "
+"status = 0x%04x\n", int_status);
+
+   return IRQ_HANDLED;
+}
+
+/* - */
+
+static int __devinit c67x00_drv_probe(struct platform_device *pdev)
+{
+   struct c67x00_device *c67x00;
+   struct c67x00_platform_data *pdata;
+   struct resource *res, *res2;
+   int ret, i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENODEV;
+
+   res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!res2)
+   return -ENODEV;
+
+   pdata = pdev->dev.platform_data;
+   if (!pda

[patch v6 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-29 Thread Peter Korsgaard
The Cypress c67x00 (EZ-Host/EZ-OTG) controllers are multi-role low/fullspeed
USB controllers. This patch series implements a HCD driver and shows the
work-in-progress status of a gadget driver.

I believe patch 1..3 are ready, and I would like to see them queued up for
2.6.25.

Changes since v5:
 - Merged c67x00_ll_{get,set}_siemsg() into c67x00_ll_fetch_siemsg().
 - Fix for interrupt race condition at probe time (reported by Grant)

Changes since v4:
 - Addressed Grant's comments (c67x00_dev->c67x00_hcd_dev, label indent)
 - Moved c67x00_ll_set_ep_{ctrl,packet_size}_reg() to patch 4 as they are
   only needed for gadget support.
 - Added c67x00_ prefix to struct lcp_int_data

Changes since v3:
- Lots of cleanups: checkpatch, interrupt handling, c67x00_ prefixes, ..
- The dummy platform_device's created per serial engine are gone.
- Gadget driver (WIP)

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v4 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-28 Thread Peter Korsgaard
>>>>> "Grant" == Grant Likely <[EMAIL PROTECTED]> writes:

Hi,

 Grant> I've now merged the driver into my tree and tested it.

 Grant> The good news is that using only one device node is absolutely
 Grant> no problem.  It works without error or complaint and sysfs
 Grant> looks sane.

Great.

 Grant> The bad news is that I discovered a race condition on
 Grant> initialization.  The problem is that IRQs are enabled before
 Grant> the SIEs are configured.  The interrupt handler is firing
 Grant> immediately and tries to get the status of each SIE.  Since
 Grant> the SIE probe has not yet occured, sie->dev is NULL and we get
 Grant> a kernel oops when c67x00_ll_get_siemsg() tries to dereference
 Grant> it.

Not so great. I unfortunately don't see it here.

 Grant> However, register_irq() cannot be easily moved to after the
 Grant> SIE probe because the current probe code depends on interrupts
 Grant> being enabled.  Below is an ugly workaround that solves the
 Grant> problem to me, but there is probably a better solution.

Wouldn't it be simpler to just add a if (sie->dev) check to
_ll_get_siemsg()? Or doesn't the hcd init properly reinitialize the
device?

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v5 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-01-24 Thread Peter Korsgaard
This patch adds HCD support for the Cypress c67x00 family of devices.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/Makefile   |2 
 drivers/usb/c67x00/Makefile|   11 
 drivers/usb/c67x00/c67x00-drv.c|   13 
 drivers/usb/c67x00/c67x00-hcd.c|  410 
 drivers/usb/c67x00/c67x00-hcd.h|  152 
 drivers/usb/c67x00/c67x00-ll-hpi.c |   75 ++
 drivers/usb/c67x00/c67x00-sched.c  | 1194 +
 drivers/usb/c67x00/c67x00.h|9 
 drivers/usb/host/Kconfig   |   12 
 9 files changed, 1878 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
@@ -0,0 +1,410 @@
+/*
+ * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+#include "c67x00-hcd.h"
+
+/* --
+ * Root Hub Support
+ */
+
+static __u8 c67x00_hub_des[] = {
+   0x09,   /*  __u8  bLength; */
+   0x29,   /*  __u8  bDescriptorType; Hub-descriptor */
+   0x02,   /*  __u8  bNbrPorts; */
+   0x00,   /* __u16  wHubCharacteristics; */
+   0x00,   /*   (per-port OC, no power switching) */
+   0x32,   /*  __u8  bPwrOn2pwrGood; 2ms */
+   0x00,   /*  __u8  bHubContrCurrent; 0 mA */
+   0x00,   /*  __u8  DeviceRemovable; ** 7 Ports max ** */
+   0xff,   /*  __u8  PortPwrCtrlMask; ** 7 ports max ** */
+};
+
+static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port)
+{
+   struct c67x00_hcd *c67x00 = sie->private_data;
+   unsigned long flags;
+
+   c67x00_ll_husb_reset(sie, port);
+
+   spin_lock_irqsave(&c67x00->lock, flags);
+   c67x00_ll_husb_reset_port(sie, port);
+   spin_unlock_irqrestore(&c67x00->lock, flags);
+
+   c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT);
+}
+
+static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status;
+   int i;
+
+   *buf = 0;
+   status = c67x00_ll_usb_get_status(sie);
+   for (i = 0; i < C67X00_PORTS; i++)
+   if (status & PORT_CONNECT_CHANGE(i))
+   *buf |= (1 << i);
+
+   /* bit 0 denotes hub change, b1..n port change */
+   *buf <<= 1;
+
+   return !!*buf;
+}
+
+static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 wIndex, char *buf, u16 wLength)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status, usb_status;
+   int len = 0;
+   unsigned int port = wIndex-1;
+   u16 wPortChange, wPortStatus;
+
+   switch (typeReq) {
+
+   case GetHubStatus:
+   *(__le32 *) buf = cpu_to_le32(0);
+   len = 4;/* hub power */
+   break;
+
+   case GetPortStatus:
+   if (wIndex > C67X00_PORTS)
+   return -EPIPE;
+
+   status = c67x00_ll_usb_get_status(sie);
+   usb_status = c67x00_ll_get_usb_ctl(sie);
+
+   wPortChange = 0;
+   if (status & PORT_CONNECT_CHANGE(port))
+   wPortChange |= USB_PORT_STAT_C_CONNECTION;
+
+   wPortStatus = USB_PORT_STAT_POWER;
+   if (!(status & PORT_SE0_STATUS(port)))
+   wPortStatus |= USB_PORT_STAT_CONNECTION;
+   if (usb_status & LOW_SPEED_PORT(port)) {
+   wPortStatus |= USB_PORT_STAT_LOW_SPEED;
+   c67x00->low_speed_ports |= (1 <&l

[patch v5 4/4] USB: add Cypress c67x00 OTG controller gadget driver

2008-01-24 Thread Peter Korsgaard
nfig
@@ -324,6 +324,13 @@
depends on USB_GADGET_AT91
default USB_GADGET
 
+config USB_GADGET_C67X00
+   boolean "Cypress C67X00 Gadget support"
+   depends on USB_C67X00_DRV
+   select USB_GADGET_SELECTED
+   help
+ This enables the gadget functionality of the Cypress C67X00.
+
 config USB_GADGET_DUMMY_HCD
boolean "Dummy HCD (DEVELOPMENT)"
depends on (USB=y || (USB=m && USB_GADGET=m)) && EXPERIMENTAL
Index: linux-2.6/drivers/usb/gadget/gadget_chips.h
===
--- linux-2.6.orig/drivers/usb/gadget/gadget_chips.h
+++ linux-2.6/drivers/usb/gadget/gadget_chips.h
@@ -147,6 +147,12 @@
 #definegadget_is_m66592(g) 0
 #endif
 
+#ifdef CONFIG_USB_GADGET_C67X00
+#definegadget_is_c67x00(g) !strcmp("c67x00_udc", (g)->name)
+#else
+#definegadget_is_c67x00(g) 0
+#endif
+
 
 // CONFIG_USB_GADGET_SX2
 // CONFIG_USB_GADGET_AU1X00
@@ -212,5 +218,7 @@
return 0x20;
else if (gadget_is_m66592(gadget))
return 0x21;
+   else if (gadget_is_c67x00(gadget))
+   return 0x22;
return -ENOENT;
 }
Index: linux-2.6/drivers/usb/host/Kconfig
===
--- linux-2.6.orig/drivers/usb/host/Kconfig
+++ linux-2.6/drivers/usb/host/Kconfig
@@ -261,15 +261,3 @@
  To compile this driver as a module, choose M here: the
  module will be called r8a66597-hcd.
 
-config USB_C67X00_HCD
-   tristate "Cypress C67x00 HCD support"
-   depends on USB
-   help
- The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
- host/peripheral/OTG USB controllers.
-
- Enable this option to support this chip in host controller mode.
- If unsure, say N.
-
- To compile this driver as a module, choose M here: the
- module will be called c67x00.
Index: linux-2.6/drivers/usb/Makefile
===
--- linux-2.6.orig/drivers/usb/Makefile
+++ linux-2.6/drivers/usb/Makefile
@@ -17,7 +17,7 @@
 obj-$(CONFIG_USB_U132_HCD) += host/
 obj-$(CONFIG_USB_R8A66597_HCD) += host/
 
-obj-$(CONFIG_USB_C67X00_HCD)   += c67x00/
+obj-$(CONFIG_USB_C67X00_DRV)   += c67x00/
 
 obj-$(CONFIG_USB_ACM)  += class/
 obj-$(CONFIG_USB_PRINTER)  += class/
Index: linux-2.6/drivers/usb/Kconfig
===
--- linux-2.6.orig/drivers/usb/Kconfig
+++ linux-2.6/drivers/usb/Kconfig
@@ -91,6 +91,8 @@
 
 source "drivers/usb/host/Kconfig"
 
+source "drivers/usb/c67x00/Kconfig"
+
 source "drivers/usb/class/Kconfig"
 
 source "drivers/usb/storage/Kconfig"
Index: linux-2.6/drivers/usb/c67x00/Kconfig
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/Kconfig
@@ -0,0 +1,21 @@
+#
+# Cypress C67x00 USB controller
+#
+config USB_C67X00_DRV
+   tristate "Cypress C67x00 support"
+   # only allowed to be =y if both USB!=m and USB_GADGET!=m
+   depends on (!USB && USB_GADGET) || (!USB_GADGET && USB) || (USB && 
USB_GADGET)
+   help
+ The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
+ host/peripheral USB controllers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called c67x00.
+
+config USB_C67X00_HCD
+   bool "Cypress C67X00 HCD support"
+   depends on USB && USB_C67X00_DRV
+   default y
+   help
+ Enable this option to support the Cypress C67x00 in host
+ controller mode.

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v5 2/4] USB: add Cypress c67x00 OTG controller core driver

2008-01-24 Thread Peter Korsgaard
This patch add the core driver for the c67x00 USB OTG controller.  The core
driver is responsible for the platform bus binding and creating either
USB HCD or USB Gadget instances for each of the serial interface engines
on the chip.

This driver does not directly implement the HCD or gadget behaviours; it
just controls access to the chip.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 MAINTAINERS |6 +
 drivers/usb/c67x00/c67x00-drv.c |  236 
 include/linux/usb/c67x00.h  |   48 
 3 files changed, 290 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-drv.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-drv.c
@@ -0,0 +1,236 @@
+/*
+ * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+/*
+ * This file implements the common infrastructure for using the c67x00.
+ * It is both the link between the platform configuration and subdrivers and
+ * the link between the common hardware parts and the subdrivers (e.g.
+ * interrupt handling).
+ *
+ * The c67x00 has 2 SIE's (serial interface engine) wich can be configured
+ * to be host, device or OTG (with some limitations, E.G. only SIE1 can be 
OTG).
+ *
+ * Depending on the platform configuration, the SIE's are created and
+ * the corresponding subdriver is initialized (c67x00_probe_sie).
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+
+static void c67x00_probe_sie(struct c67x00_sie *sie,
+struct c67x00_device *dev, int sie_num)
+{
+   spin_lock_init(&sie->lock);
+   sie->dev = dev;
+   sie->sie_num = sie_num;
+   sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num);
+
+   switch (sie->mode) {
+   case C67X00_SIE_UNUSED:
+   dev_info(sie_dev(sie),
+"Not using SIE %d as requested\n", sie->sie_num);
+   break;
+
+   default:
+   dev_err(sie_dev(sie),
+   "Unsupported configuration: 0x%x for SIE %d\n",
+   sie->mode, sie->sie_num);
+   break;
+   }
+}
+
+static void c67x00_remove_sie(struct c67x00_sie *sie)
+{
+}
+
+
+static irqreturn_t c67x00_irq(int irq, void *__dev)
+{
+   struct c67x00_device *c67x00 = __dev;
+   struct c67x00_sie *sie;
+   u16 msg, int_status;
+   int i, count = 8;
+
+   int_status = c67x00_ll_hpi_status(c67x00);
+   if (!int_status)
+   return IRQ_NONE;
+
+   while (int_status != 0 && (count-- >= 0)) {
+   c67x00_ll_irq(c67x00, int_status);
+   for (i = 0; i < C67X00_SIES; i++) {
+   sie = &c67x00->sie[i];
+   msg = 0;
+   if (int_status & SIEMSG_FLG(i)) {
+   msg = c67x00_ll_get_siemsg(sie);
+   /* clear register to allow next message */
+   c67x00_ll_set_siemsg(sie, 0);
+   }
+   if (sie->irq)
+   sie->irq(sie, int_status, msg);
+   }
+   int_status = c67x00_ll_hpi_status(c67x00);
+   }
+
+   if (int_status)
+   dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! "
+"status = 0x%04x\n", int_status);
+
+   return IRQ_HANDLED;
+}
+
+/* - */
+
+static int __devinit c67x00_drv_probe(struct platform_device *pdev)
+{
+   struct c67x00_device *c67x00;
+   struct c67x00_platform_data *pdata;
+   struct resource *res, *res2;
+   int ret, i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENODEV;
+
+   res2 =

[patch v5 1/4] USB: add Cypress c67x00 low level interface code

2008-01-24 Thread Peter Korsgaard
This patch adds the low level support code for the Cypress c67x00 family of
OTG controllers.  The low level code is responsible for register access and
implements the software protocol for communicating with the 16bit
microcontroller inside the c67x00 device.

Communication is done over the HPI interface (16bit SRAM-like parallel bus).

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/c67x00/c67x00-ll-hpi.c |  409 +
 drivers/usb/c67x00/c67x00.h|  286 +
 2 files changed, 695 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00.h
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00.h
@@ -0,0 +1,286 @@
+/*
+ * c67x00.h: Cypress C67X00 USB register and field definitions
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#ifndef _USB_C67X00_H
+#define _USB_C67X00_H
+
+#include 
+#include 
+#include 
+#include 
+
+/* -
+ * Cypress C67x00 register definitions
+ */
+
+/* Hardware Revision Register */
+#define HW_REV_REG 0xC004
+
+/* General USB registers */
+/* = */
+
+/* USB Control Register */
+#define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A)
+
+#define LOW_SPEED_PORT(x)  ((x) ? 0x0800 : 0x0400)
+#define HOST_MODE  0x0200
+#define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080)
+#define SOF_EOP_EN(x)  ((x) ? 0x0002 : 0x0001)
+
+/* USB status register - Notice it has different content in hcd/udc mode */
+#define USB_STAT_REG(x)((x) ? 0xC0B0 : 0xC090)
+
+#define EP0_IRQ_FLG0x0001
+#define EP1_IRQ_FLG0x0002
+#define EP2_IRQ_FLG0x0004
+#define EP3_IRQ_FLG0x0008
+#define EP4_IRQ_FLG0x0010
+#define EP5_IRQ_FLG0x0020
+#define EP6_IRQ_FLG0x0040
+#define EP7_IRQ_FLG0x0080
+#define RESET_IRQ_FLG  0x0100
+#define SOF_EOP_IRQ_FLG0x0200
+#define ID_IRQ_FLG 0x4000
+#define VBUS_IRQ_FLG   0x8000
+
+/* USB Host only registers */
+/* === */
+
+/* Host n Control Register */
+#define HOST_CTL_REG(x)((x) ? 0xC0A0 : 0xC080)
+
+#define PREAMBLE_EN0x0080  /* Preamble enable */
+#define SEQ_SEL0x0040  /* Data Toggle Sequence Bit 
Select */
+#define ISO_EN 0x0010  /* Isochronous enable  */
+#define ARM_EN 0x0001  /* Arm operation */
+
+/* Host n Interrupt Enable Register */
+#define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define SOF_EOP_IRQ_EN 0x0200  /* SOF/EOP Interrupt Enable  */
+#define SOF_EOP_TMOUT_IRQ_EN   0x0800  /* SOF/EOP Timeout Interrupt Enable  */
+#define ID_IRQ_EN  0x4000  /* ID interrupt enable */
+#define VBUS_IRQ_EN0x8000  /* VBUS interrupt enable */
+#define DONE_IRQ_EN0x0001  /* Done Interrupt Enable  */
+
+/* USB status register */
+#define HOST_STAT_MASK 0x02FD
+#define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010)
+#define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004)
+
+/* Host Frame Register */
+#define HOST_FRAME_REG(x)  ((x) ? 0xC0B6 : 0xC096)
+
+#define HOST_FRAME_MASK0x07FF
+
+/* USB Peripheral only registers */
+/* = */
+
+/* Device n Port Sel reg */
+#define DEVICE_N_PORT_SEL(x)   ((x) ? 0xC0A4 : 0xC084)
+
+/* Device n Interrupt Enable Register */
+#define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep)   ((dev)  \
+? (0x0280 + (ep << 4)) \
+: (0x0200 + (ep << 4)))
+#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep)  ((dev)  \
+? (0x0286 + (ep << 4)) \
+: (0x0206 + (ep << 4)))
+
+#defin

[patch v5 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-24 Thread Peter Korsgaard
The Cypress c67x00 (EZ-Host/EZ-OTG) controllers are multi-role low/fullspeed
USB controllers. This patch series implements a HCD driver and shows the
work-in-progress status of a gadget driver.

I believe patch 1..3 are ready, and I would like to see them queued up for
2.6.25.

Changes since v4:
 - Addressed Grant's comments (c67x00_dev->c67x00_hcd_dev, label indent)
 - Moved c67x00_ll_set_ep_{ctrl,packet_size}_reg() to patch 4 as they are
   only needed for gadget support.
 - Added c67x00_ prefix to struct lcp_int_data

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v4 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-23 Thread Peter Korsgaard
>>>>> "David" == David Brownell <[EMAIL PROTECTED]> writes:

 David> On Wednesday 23 January 2008, Grant Likely wrote:
 >> The question is about the device structure which used to be provided
 >> by the platform device instances and now there just uses the c67x00's
 >> device struct.  I was under the impression that each USB HCD needs to
 >> have it's own struct device.  I take it that's not true?

 David> Each root hub necessarily is a unique device, representing a set
 David> of downstream links.  Unless Peter didn't test something relevant,
 David> it would seem we have observational proof that two root hubs can
 David> share the same device node for an upstream link.

I haven't actually tested a setup with HCDs on both SIEs as I don't
have a board with host connectors on both, but I've done the change
based on your feedback:

http://article.gmane.org/gmane.linux.usb.devel/53496

 David> I can't think of a reason to demand multiple upstream links, though
 David> sharing them between root hubs like that isn't a common structure.  

 David> - Dave


-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v4 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-23 Thread Peter Korsgaard
>>>>> "Grant" == Grant Likely <[EMAIL PROTECTED]> writes:

 Grant> Okay, I've had a chance to read through this.  I haven't
 Grant> tested it, but I don't see anything I strongly disagree with.
 Grant> I've just got a few editorial comments below and a question.

Ok, great.

 Grant> The question is about the device structure which used to be provided
 Grant> by the platform device instances and now there just uses the c67x00's
 Grant> device struct.  I was under the impression that each USB HCD needs to
 Grant> have it's own struct device.  I take it that's not true?

Not afaik. In fact, I changed this based on feedback from David back
when I first time posted the patch series:

http://article.gmane.org/gmane.linux.usb.devel/53496

But I don't have a board with host connectors on both SIEs, so I
haven't actually been able to test it.

 Grant> Otherwise:

 Grant> Acked-by: Grant Likely <[EMAIL PROTECTED]>

 Grant> Cheers,
 Grant> g.
 >> 
 >> diff --git a/drivers/usb/c67x00/c67x00-drv.c 
 >> b/drivers/usb/c67x00/c67x00-drv.c
 >> index 0f0720a..c2ea3b6 100644
 >> --- a/drivers/usb/c67x00/c67x00-drv.c
 >> +++ b/drivers/usb/c67x00/c67x00-drv.c
 >> @@ -203,19 +175,19 @@ static int __devinit c67x00_drv_probe(struct 
 >> platform_device *pdev)
 >> }
 >> 
 >> for (i = 0; i < C67X00_SIES; i++)
 >> -   c67x00_probe_sie(&c67x00->sie[i]);
 >> +   c67x00_probe_sie(&c67x00->sie[i], c67x00, i);
 >> 
 >> platform_set_drvdata(pdev, c67x00);
 >> 
 >> return 0;
 >> 
 >> - reset_failed:
 >> +reset_failed:
 >> free_irq(res2->start, c67x00);
 >> - request_irq_failed:
 >> +request_irq_failed:
 >> iounmap(c67x00->hpi.base);
 >> - map_failed:
 >> +map_failed:
 >> release_mem_region(res->start, res->end - res->start + 1);
 >> - request_mem_failed:
 >> +request_mem_failed:

 Grant> A single space should be preserved in front of the labels.  Doing so
 Grant> means that git-diff picks up the function name instead of the label
 Grant> when generating output.

Ok. Emacs doesn't seem to do this by default.

 >> diff --git a/drivers/usb/c67x00/c67x00-hcd.c 
 >> b/drivers/usb/c67x00/c67x00-hcd.c
 >> index 3d0b77e..4afb291 100644
 >> --- a/drivers/usb/c67x00/c67x00-hcd.c
 >> +++ b/drivers/usb/c67x00/c67x00-hcd.c
 >> @@ -368,23 +383,26 @@ int c67x00_hcd_probe(struct c67x00_sie *sie)
 >> goto err2;
 >> }
 >> 
 >> +   spin_lock_irqsave(&sie->lock, flags);
 >> +   sie->private_data = c67x00;
 >> +   sie->irq = c67x00_hcd_irq;
 >> +   spin_unlock_irqrestore(&sie->lock, flags);
 >> +
 >> return retval;
 >> - err2:
 >> +err2:
 >> c67x00_sched_stop_scheduler(c67x00);
 >> - err1:
 >> +err1:
 >> usb_put_hcd(hcd);
 >> - err0:
 >> +err0:

 Grant> Ditto on the labels

 >> diff --git a/drivers/usb/c67x00/c67x00-hcd.h 
 >> b/drivers/usb/c67x00/c67x00-hcd.h
 >> index 5b35f01..daee4cd 100644
 >> --- a/drivers/usb/c67x00/c67x00-hcd.h
 >> +++ b/drivers/usb/c67x00/c67x00-hcd.h
 >> @@ -132,6 +147,6 @@ void c67x00_sched_kick(struct c67x00_hcd *c67x00);
 >> int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00);
 >> void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00);
 >> 
 >> -#define c67x00_hcd_dev(x)  (c67x00_hcd_to_hcd(x)->self.controller)
 >> +#define c67x00_dev(x)  (c67x00_hcd_to_hcd(x)->self.controller)

 Grant> Can the name c67x00_hcd_dev() be used instead?  This macro is used
 Grant> with 'struct c67x00_hcd', not 'struct c67x00' and I find the code less
 Grant> confusing if the macro name reflects that.

Well, we can. I didn't copy your name change over as the hcds don't
have their own struct device in my series, but I don't feel strongly
about the issue.

 >> 
 >> #endif /* _USB_C67X00_HCD_H */
 >> diff --git a/drivers/usb/c67x00/c67x00-sched.c 
 >> b/drivers/usb/c67x00/c67x00-sched.c
 >> index 35d7318..3140d89 100644
 >> --- a/drivers/usb/c67x00/c67x00-sched.c
 >> +++ b/drivers/usb/c67x00/c67x00-sched.c
 >> -   /* Something went wrong; unwind the allocations */
 >> - err_epdata:
 >> +err_epdata:
 >> kfree(urbp);
 >> - err_urbp:
 >> +err_urbp:
 >> usb_hcd_unlink_urb_from_ep(hcd, urb);
 >> - err_not_linked:
 >> +err_not_linked:

 Grant> ditto

 Grant> Cheers,
 Grant> g.

Thanks for the feedback, I'll post an updated series.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v4 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-21 Thread Peter Korsgaard
>>>>> "Grant" == Grant Likely <[EMAIL PROTECTED]> writes:

Hi,

 Grant> My v1, v2 and v3 postings were based on Peter's work from about a year
 Grant> ago.  I picked up the driver because Peter didn't have any time to
 Grant> work on it.

Ack.

 Grant> Peter told me last week that this series merges the v3 patches with
 Grant> work that he's done recently now that he has some time to do so again.
 Grant>  However, I don't know what the diff is between v3 and this new
 Grant> series.  I've also not done a full review, so I cannot make any
 Grant> comment at this time.

I would be grateful if you would find a bit of time to skim over it -
I'll post a diff between v3 and v4-without-the-gadget-part in a
moment.

 Grant> Personally, I'd prefer to see the v3 series picked up now (as I
 Grant> believe all outstanding comments from the list have been addressed)
 Grant> and have new patches build on top of that, but that's just my
 Grant> preference.

That's understandable; I would ofcause prefer to see v4 selected instead
to get the cleanups and fixes and because the in-progress gadget work
is based on it.

But anyway, that's details - Most of all I would like to see c67x00
support in mainline, one way or another. Most of the work has been
sitting on my hard drive gathering dust since spring 2006.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v4 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-21 Thread Peter Korsgaard
>>>>> "David" == David Brownell <[EMAIL PROTECTED]> writes:

Hi,

 David> How does this relate to the "v3" patches posted 8-Jan by Grant Likely?
 David> Is that the "v3" you were referring to?

Yes - Sorry, I should have been more clear about that.

 David> It's confusing to see two different people submit two sets of
 David> patches for the same driver, without any evident
 David> coordination...

True. The story behind it is that I posted the original patch series
back in Spring '06, but real life got in way of me following up on
pushing it to mainline (some development was still done on it, and
we've shipped it in products).

Then Grant picked it up (which I'm grateful for) and posted his v1..v3
series. I have now taken his v3 series and merged it with my
development.

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch v4 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-21 Thread Peter Korsgaard
>>>>> "Grant" == Grant Likely <[EMAIL PROTECTED]> writes:

Hi,

 >> Changes since v3:
 >> - Lots of cleanups: checkpatch, interrupt handling, c67x00_ prefixes, ..
 >> - The dummy platform_device's created per serial engine are gone.
 >> - Gadget driver (WIP)

 Grant> Can you please post/publish the diff between v3 and this series?

Sure, http://peter.korsgaard.com/c67x00-v3-v4.patch (not posting as
it's more than 100k)

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v4 4/4] USB: add Cypress c67x00 OTG controller gadget driver

2008-01-21 Thread Peter Korsgaard
ndif
+
 
 // CONFIG_USB_GADGET_SX2
 // CONFIG_USB_GADGET_AU1X00
@@ -212,5 +218,7 @@
return 0x20;
else if (gadget_is_m66592(gadget))
return 0x21;
+   else if (gadget_is_c67x00(gadget))
+   return 0x22;
return -ENOENT;
 }
Index: linux-2.6/drivers/usb/host/Kconfig
===
--- linux-2.6.orig/drivers/usb/host/Kconfig
+++ linux-2.6/drivers/usb/host/Kconfig
@@ -261,15 +261,3 @@
  To compile this driver as a module, choose M here: the
  module will be called r8a66597-hcd.
 
-config USB_C67X00_HCD
-   tristate "Cypress C67x00 HCD support"
-   depends on USB
-   help
- The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
- host/peripheral/OTG USB controllers.
-
- Enable this option to support this chip in host controller mode.
- If unsure, say N.
-
- To compile this driver as a module, choose M here: the
- module will be called c67x00.
Index: linux-2.6/drivers/usb/Makefile
===
--- linux-2.6.orig/drivers/usb/Makefile
+++ linux-2.6/drivers/usb/Makefile
@@ -17,7 +17,7 @@
 obj-$(CONFIG_USB_U132_HCD) += host/
 obj-$(CONFIG_USB_R8A66597_HCD) += host/
 
-obj-$(CONFIG_USB_C67X00_HCD)   += c67x00/
+obj-$(CONFIG_USB_C67X00_DRV)   += c67x00/
 
 obj-$(CONFIG_USB_ACM)  += class/
 obj-$(CONFIG_USB_PRINTER)  += class/
Index: linux-2.6/drivers/usb/Kconfig
===
--- linux-2.6.orig/drivers/usb/Kconfig
+++ linux-2.6/drivers/usb/Kconfig
@@ -91,6 +91,8 @@
 
 source "drivers/usb/host/Kconfig"
 
+source "drivers/usb/c67x00/Kconfig"
+
 source "drivers/usb/class/Kconfig"
 
 source "drivers/usb/storage/Kconfig"
Index: linux-2.6/drivers/usb/c67x00/Kconfig
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/Kconfig
@@ -0,0 +1,21 @@
+#
+# Cypress C67x00 USB controller
+#
+config USB_C67X00_DRV
+   tristate "Cypress C67x00 support"
+   # only allowed to be =y if both USB!=m and USB_GADGET!=m
+   depends on (!USB && USB_GADGET) || (!USB_GADGET && USB) || (USB && 
USB_GADGET)
+   help
+ The Cypress C67x00 (EZ-Host/EZ-OTG) chips are dual-role
+ host/peripheral USB controllers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called c67x00.
+
+config USB_C67X00_HCD
+   bool "Cypress C67X00 HCD support"
+   depends on USB && USB_C67X00_DRV
+   default y
+   help
+ Enable this option to support the Cypress C67x00 in host
+ controller mode.

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v4 2/4] USB: add Cypress c67x00 OTG controller core driver

2008-01-21 Thread Peter Korsgaard
This patch add the core driver for the c67x00 USB OTG controller.  The core
driver is responsible for the platform bus binding and creating either
USB HCD or USB Gadget instances for each of the serial interface engines
on the chip.

This driver does not directly implement the HCD or gadget behaviours; it
just controls access to the chip.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 MAINTAINERS |6 +
 drivers/usb/c67x00/c67x00-drv.c |  236 
 include/linux/usb/c67x00.h  |   48 
 3 files changed, 290 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-drv.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-drv.c
@@ -0,0 +1,236 @@
+/*
+ * c67x00-drv.c: Cypress C67X00 USB Common infrastructure
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+/*
+ * This file implements the common infrastructure for using the c67x00.
+ * It is both the link between the platform configuration and subdrivers and
+ * the link between the common hardware parts and the subdrivers (e.g.
+ * interrupt handling).
+ *
+ * The c67x00 has 2 SIE's (serial interface engine) wich can be configured
+ * to be host, device or OTG (with some limitations, E.G. only SIE1 can be 
OTG).
+ *
+ * Depending on the platform configuration, the SIE's are created and
+ * the corresponding subdriver is initialized (c67x00_probe_sie).
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+
+static void c67x00_probe_sie(struct c67x00_sie *sie,
+struct c67x00_device *dev, int sie_num)
+{
+   spin_lock_init(&sie->lock);
+   sie->dev = dev;
+   sie->sie_num = sie_num;
+   sie->mode = c67x00_sie_config(dev->pdata->sie_config, sie_num);
+
+   switch (sie->mode) {
+   case C67X00_SIE_UNUSED:
+   dev_info(sie_dev(sie),
+"Not using SIE %d as requested\n", sie->sie_num);
+   break;
+
+   default:
+   dev_err(sie_dev(sie),
+   "Unsupported configuration: 0x%x for SIE %d\n",
+   sie->mode, sie->sie_num);
+   break;
+   }
+}
+
+static void c67x00_remove_sie(struct c67x00_sie *sie)
+{
+}
+
+
+static irqreturn_t c67x00_irq(int irq, void *__dev)
+{
+   struct c67x00_device *c67x00 = __dev;
+   struct c67x00_sie *sie;
+   u16 msg, int_status;
+   int i, count = 8;
+
+   int_status = c67x00_ll_hpi_status(c67x00);
+   if (!int_status)
+   return IRQ_NONE;
+
+   while (int_status != 0 && (count-- >= 0)) {
+   c67x00_ll_irq(c67x00, int_status);
+   for (i = 0; i < C67X00_SIES; i++) {
+   sie = &c67x00->sie[i];
+   msg = 0;
+   if (int_status & SIEMSG_FLG(i)) {
+   msg = c67x00_ll_get_siemsg(sie);
+   /* clear register to allow next message */
+   c67x00_ll_set_siemsg(sie, 0);
+   }
+   if (sie->irq)
+   sie->irq(sie, int_status, msg);
+   }
+   int_status = c67x00_ll_hpi_status(c67x00);
+   }
+
+   if (int_status)
+   dev_warn(&c67x00->pdev->dev, "Not all interrupts handled! "
+"status = 0x%04x\n", int_status);
+
+   return IRQ_HANDLED;
+}
+
+/* - */
+
+static int __devinit c67x00_drv_probe(struct platform_device *pdev)
+{
+   struct c67x00_device *c67x00;
+   struct c67x00_platform_data *pdata;
+   struct resource *res, *res2;
+   int ret, i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -ENODEV;
+
+   res2 =

[patch v4 0/4] Cypress c67x00 (EZ-Host/EZ-OTG) support

2008-01-21 Thread Peter Korsgaard
The Cypress c67x00 (EZ-Host/EZ-OTG) controllers are multi-role low/fullspeed
USB controllers. This patch series implements a HCD driver and shows the
work-in-progress status of a gadget driver.

I believe patch 1..3 are ready, and I would like to see queued up for 2.6.25.

Changes since v3:
- Lots of cleanups: checkpatch, interrupt handling, c67x00_ prefixes, ..
- The dummy platform_device's created per serial engine are gone.
- Gadget driver (WIP)

Comments are very much appreciated.

--
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v4 1/4] USB: add Cypress c67x00 low level interface code

2008-01-21 Thread Peter Korsgaard
This patch adds the low level support code for the Cypress c67x00 family of
OTG controllers.  The low level code is responsible for register access and
implements the software protocol for communicating with the 16bit
microcontroller inside the c67x00 device.

Communication is done over the HPI interface (16bit SRAM-like parallel bus).

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/c67x00/c67x00-ll-hpi.c |  426 +
 drivers/usb/c67x00/c67x00.h|  289 +
 2 files changed, 715 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00.h
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00.h
@@ -0,0 +1,289 @@
+/*
+ * c67x00.h: Cypress C67X00 USB register and field definitions
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#ifndef _USB_C67X00_H
+#define _USB_C67X00_H
+
+#include 
+#include 
+#include 
+#include 
+
+/* -
+ * Cypress C67x00 register definitions
+ */
+
+/* Hardware Revision Register */
+#define HW_REV_REG 0xC004
+
+/* General USB registers */
+/* = */
+
+/* USB Control Register */
+#define USB_CTL_REG(x) ((x) ? 0xC0AA : 0xC08A)
+
+#define LOW_SPEED_PORT(x)  ((x) ? 0x0800 : 0x0400)
+#define HOST_MODE  0x0200
+#define PORT_RES_EN(x) ((x) ? 0x0100 : 0x0080)
+#define SOF_EOP_EN(x)  ((x) ? 0x0002 : 0x0001)
+
+/* USB status register - Notice it has different content in hcd/udc mode */
+#define USB_STAT_REG(x)((x) ? 0xC0B0 : 0xC090)
+
+#define EP0_IRQ_FLG0x0001
+#define EP1_IRQ_FLG0x0002
+#define EP2_IRQ_FLG0x0004
+#define EP3_IRQ_FLG0x0008
+#define EP4_IRQ_FLG0x0010
+#define EP5_IRQ_FLG0x0020
+#define EP6_IRQ_FLG0x0040
+#define EP7_IRQ_FLG0x0080
+#define RESET_IRQ_FLG  0x0100
+#define SOF_EOP_IRQ_FLG0x0200
+#define ID_IRQ_FLG 0x4000
+#define VBUS_IRQ_FLG   0x8000
+
+/* USB Host only registers */
+/* === */
+
+/* Host n Control Register */
+#define HOST_CTL_REG(x)((x) ? 0xC0A0 : 0xC080)
+
+#define PREAMBLE_EN0x0080  /* Preamble enable */
+#define SEQ_SEL0x0040  /* Data Toggle Sequence Bit 
Select */
+#define ISO_EN 0x0010  /* Isochronous enable  */
+#define ARM_EN 0x0001  /* Arm operation */
+
+/* Host n Interrupt Enable Register */
+#define HOST_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define SOF_EOP_IRQ_EN 0x0200  /* SOF/EOP Interrupt Enable  */
+#define SOF_EOP_TMOUT_IRQ_EN   0x0800  /* SOF/EOP Timeout Interrupt Enable  */
+#define ID_IRQ_EN  0x4000  /* ID interrupt enable */
+#define VBUS_IRQ_EN0x8000  /* VBUS interrupt enable */
+#define DONE_IRQ_EN0x0001  /* Done Interrupt Enable  */
+
+/* USB status register */
+#define HOST_STAT_MASK 0x02FD
+#define PORT_CONNECT_CHANGE(x) ((x) ? 0x0020 : 0x0010)
+#define PORT_SE0_STATUS(x) ((x) ? 0x0008 : 0x0004)
+
+/* Host Frame Register */
+#define HOST_FRAME_REG(x)  ((x) ? 0xC0B6 : 0xC096)
+
+#define HOST_FRAME_MASK0x07FF
+
+/* USB Peripheral only registers */
+/* = */
+
+/* Device n Port Sel reg */
+#define DEVICE_N_PORT_SEL(x)   ((x) ? 0xC0A4 : 0xC084)
+
+/* Device n Interrupt Enable Register */
+#define DEVICE_N_IRQ_EN_REG(x) ((x) ? 0xC0AC : 0xC08C)
+
+#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep)   ((dev)  \
+? (0x0280 + (ep << 4)) \
+: (0x0200 + (ep << 4)))
+#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep)  ((dev)  \
+? (0x0286 + (ep << 4)) \
+: (0x0206 + (ep << 4)))
+
+#defin

[patch v4 3/4] USB: add Cypress c67x00 OTG controller HCD driver

2008-01-21 Thread Peter Korsgaard
This patch adds HCD support for the Cypress c67x00 family of devices.

Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
---
 drivers/usb/Makefile   |2 
 drivers/usb/c67x00/Makefile|   11 
 drivers/usb/c67x00/c67x00-drv.c|   13 
 drivers/usb/c67x00/c67x00-hcd.c|  409 
 drivers/usb/c67x00/c67x00-hcd.h|  152 
 drivers/usb/c67x00/c67x00-ll-hpi.c |   75 ++
 drivers/usb/c67x00/c67x00-sched.c  | 1193 +
 drivers/usb/c67x00/c67x00.h|9 
 drivers/usb/host/Kconfig   |   12 
 9 files changed, 1876 insertions(+)

Index: linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
===
--- /dev/null
+++ linux-2.6/drivers/usb/c67x00/c67x00-hcd.c
@@ -0,0 +1,409 @@
+/*
+ * c67x00-hcd.c: Cypress C67X00 USB Host Controller Driver
+ *
+ * Copyright (C) 2006-2008 Barco N.V.
+ *Derived from the Cypress cy7c67200/300 ezusb linux driver and
+ *based on multiple host controller drivers inside the linux kernel.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301  USA.
+ */
+
+#include 
+#include 
+#include 
+
+#include "c67x00.h"
+#include "c67x00-hcd.h"
+
+/* --
+ * Root Hub Support
+ */
+
+static __u8 c67x00_hub_des[] = {
+   0x09,   /*  __u8  bLength; */
+   0x29,   /*  __u8  bDescriptorType; Hub-descriptor */
+   0x02,   /*  __u8  bNbrPorts; */
+   0x00,   /* __u16  wHubCharacteristics; */
+   0x00,   /*   (per-port OC, no power switching) */
+   0x32,   /*  __u8  bPwrOn2pwrGood; 2ms */
+   0x00,   /*  __u8  bHubContrCurrent; 0 mA */
+   0x00,   /*  __u8  DeviceRemovable; ** 7 Ports max ** */
+   0xff,   /*  __u8  PortPwrCtrlMask; ** 7 ports max ** */
+};
+
+static void c67x00_hub_reset_host_port(struct c67x00_sie *sie, int port)
+{
+   struct c67x00_hcd *c67x00 = sie->private_data;
+   unsigned long flags;
+
+   c67x00_ll_husb_reset(sie, port);
+
+   spin_lock_irqsave(&c67x00->lock, flags);
+   c67x00_ll_husb_reset_port(sie, port);
+   spin_unlock_irqrestore(&c67x00->lock, flags);
+
+   c67x00_ll_set_husb_eot(sie->dev, DEFAULT_EOT);
+}
+
+static int c67x00_hub_status_data(struct usb_hcd *hcd, char *buf)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status;
+   int i;
+
+   *buf = 0;
+   status = c67x00_ll_usb_get_status(sie);
+   for (i = 0; i < C67X00_PORTS; i++)
+   if (status & PORT_CONNECT_CHANGE(i))
+   *buf |= (1 << i);
+
+   /* bit 0 denotes hub change, b1..n port change */
+   *buf <<= 1;
+
+   return !!*buf;
+}
+
+static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
+ u16 wIndex, char *buf, u16 wLength)
+{
+   struct c67x00_hcd *c67x00 = hcd_to_c67x00_hcd(hcd);
+   struct c67x00_sie *sie = c67x00->sie;
+   u16 status, usb_status;
+   int len = 0;
+   unsigned int port = wIndex-1;
+   u16 wPortChange, wPortStatus;
+
+   switch (typeReq) {
+
+   case GetHubStatus:
+   *(__le32 *) buf = cpu_to_le32(0);
+   len = 4;/* hub power */
+   break;
+
+   case GetPortStatus:
+   if (wIndex > C67X00_PORTS)
+   return -EPIPE;
+
+   status = c67x00_ll_usb_get_status(sie);
+   usb_status = c67x00_ll_get_usb_ctl(sie);
+
+   wPortChange = 0;
+   if (status & PORT_CONNECT_CHANGE(port))
+   wPortChange |= USB_PORT_STAT_C_CONNECTION;
+
+   wPortStatus = USB_PORT_STAT_POWER;
+   if (!(status & PORT_SE0_STATUS(port)))
+   wPortStatus |= USB_PORT_STAT_CONNECTION;
+   if (usb_status & LOW_SPEED_PORT(port)) {
+   wPortStatus |= USB_PORT_STAT_LOW_SPEED;
+   c67x00->low_speed_ports |= (1 <&l

Re: [PATCH] Unbreak fsl_usb2_udc

2007-12-21 Thread Peter Korsgaard
>>>>> "David" == David Brownell <[EMAIL PROTECTED]> writes:

Hi,

 David> On Tuesday 06 November 2007, Peter Korsgaard wrote:
 >> Commit a4e3ef5... (USB: gadget: gadget_is_{dualspeed,otg} predicates and
 >> cleanup) broke fsl_usb2_udc. udc->gadget is a struct usb_gadget, not a
 >> pointer to one.
 >> 
 >> Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>

 David> ACK.

 David> Sorry about that.  What seems to have happened is that I did the
 David> test builds against all the gadget drivers, but no peripheral
 David> controller was involved.  Patches for the two affected ones have
 David> now been submitted to Greg.  (The other was omap_udc.)

This never seems to have made it's way to Linus? (the omap one did)

-- 
Bye, Peter Korsgaard
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html