Hello, I am writing a driver for USB to Serial converter /bridge having 4 serial ports . I was going through the existing USB to Serial driver . I have a few questions related to those . I would be glad to receive responses to my queries . 1. "num_interrupt_in" field in the usb_serial_device_type structure is for the device and not for the port . I mean if there is a device which has INTERRUPT IN and BULK OUT endpoints per port and has 4 such ports I would decalare usb_serial_device_type with the fields poplulated as follows .num_interrupt_in = 4, .num_bulk_in = 0, .num_bulk_out = 4, .num_ports = 4,
2. what are the tx Credits for the edgeport adapter ? I really didnt get a feel of what it means . 3. Do I need to maintain a buffer at the driver level . What governs the desicion of having a buffer at the driver level. In many sample drivers I found a separate buffer - e.g pl2303.c , kobil_sct.c . I guess it should be a good since we can only transmit 64 bytes ( maxPacketSize of endpoint ) in an URB and the applications talking to serial device may send more bytes than these . 4. What should be the criteria used to select the size of the buffer . 5. What is the significance of this step in "kobil_write()" and "kobil_read_int_callback" // someone sets the dev to 0 if the close method has been called port->interrupt_in_urb->dev = port->serial->dev; Thanks , Monali. > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of [EMAIL PROTECTED] > Sent: Friday, March 18, 2005 7:32 AM > To: linux-usb-devel@lists.sourceforge.net > Subject: linux-usb-devel digest, Vol 1 #4491 - 24 msgs > > > Send linux-usb-devel mailing list submissions to > linux-usb-devel@lists.sourceforge.net > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/linux-usb-devel > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more > specific than "Re: Contents of linux-usb-devel digest..." > > > Today's Topics: > > 1. Re: Re: driver core fix proposal (was [PATCH] 1/3 > cdc acm errors) (Alan Stern) > 2. Re: FWD: get devices change event in sysfs? (Christopher Li) > 3. Re: FWD: get devices change event in sysfs? (Christopher Li) > 4. Re: [2.6 patch] USB: possible cleanups (Greg KH) > 5. Re: [2.6 patch] drivers/usb/serial/: make some > functions static (Greg KH) > 6. Re: [2.6 patch] drivers/usb/storage/: cleanups (Greg KH) > 7. Re: [2.6 patch] drivers/usb/net/pegasus.c: make some > code static (Greg KH) > 8. Re: [2.6 patch] remove drivers/usb/image/hpusbscsi.c (Greg KH) > 9. What's wrong with iso-IN split transactions? (Antti Andreimann) > 10. Re: [patch 2.6.11-usb] usbnet gets status polling, uses > for CDC Ethernet (Greg KH) > 11. Re: [patch 2.6.11] ohci zero length control IN > transfers (Greg KH) > 12. Re: [patch 2.6.11] ehci and short in-bulk transfers > with 20KB+ urbs (Greg KH) > 13. Re: [patch 2.6.11-usb] net2280 reports correct dequeue > status (Greg KH) > 14. Re: [patch 2.6.11-usb] usbnet fix for Zaurus C-860 (Greg KH) > 15. Re: [patch 2.6.11-usb] ethernet/rndis gadget driver > updates (Greg KH) > 16. Re: [patch 2.6] add at91_udc recognition (Greg KH) > 17. Re: [patch 2.6] usb gadget kconfig tweaks (Greg KH) > 18. Re: Patch for ub to fix oops after disconnect (Greg KH) > 19. Re: [PATCH as481] g_file_storage: add configuration and > interface strings (Greg KH) > 20. Re: [PATCH]removal of obsolete error code from kaweth (Greg KH) > 21. Re: [PATCH as482] usb-midi: fix arguments to > usb_maxpacket() (Greg KH) > 22. Re: [PATCH as483] Prevent hub driver interference > during port reset (Greg KH) > 23. [patch 2.6.11] pxa25x udc updates, mostly PM (David Brownell) > > --__--__-- > > Message: 1 > Date: Thu, 17 Mar 2005 16:08:24 -0500 (EST) > From: Alan Stern <[EMAIL PROTECTED]> > To: Brian Murphy <[EMAIL PROTECTED]> > cc: David Brownell <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>, > <linux-usb-devel@lists.sourceforge.net>, <[EMAIL PROTECTED]> > Subject: Re: [linux-usb-devel] Re: driver core fix proposal > (was [PATCH] 1/3 cdc acm errors) > > On Thu, 17 Mar 2005, Brian Murphy wrote: > > > Yes, that is correct. This is a design error (mine or the device > > core). > > > > So how about the patch then, any comments? > > Actually it looked good to me. > > Alan Stern > > > > --__--__-- > > Message: 2 > Date: Thu, 17 Mar 2005 13:53:14 -0500 > From: Christopher Li <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: linux-usb-devel@lists.sourceforge.net > Subject: Re: [linux-usb-devel] FWD: get devices change event in sysfs? > > That is good to know. > > Chris > > On Wed, Mar 16, 2005 at 07:36:09PM -0800, David Brownell wrote: > > On Wednesday 16 March 2005 3:26 pm, Christopher Li wrote: > > > > In come to my attention that the later SuSE kernel has > change the > > > > /proc/bus/usb/devices to > > > > /proc/bus/usb/devices_please-use-sysfs-instead. > > > > I think SuSE 9.1 does, but 9.2 reverted that bogosity. > > > > > --__--__-- > > Message: 3 > Date: Thu, 17 Mar 2005 13:52:25 -0500 > From: Christopher Li <[EMAIL PROTECTED]> > To: Alan Stern <[EMAIL PROTECTED]> > Cc: linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: FWD: get devices change event in sysfs? > > Hi Alan, > > Thanks for your reply. > > On Wed, Mar 16, 2005 at 10:17:13PM -0500, Alan Stern wrote: > > > > I have to wonder why they did that? How do they think > people can use > > sysfs instead of /proc/bus/usb/devices? There's lots of > information in > > /proc/bus/usb/devices that isn't in sysfs at all. > > I am wondering about the same thing. > > > > > > > Of course, that breaks the VMWare and I add some option to use > > > > this wired file name. > > > > > > > > I am wondering how to get the devices change event from > sysfs in > > > > the user space if VMware want to use sysfs instead? > > > > Device change events have nothing to do with either sysfs or > > /proc/bus/usb/devices. Use hotplug. > > Right now VMware select() on the /proc/bus/usb/devices for > the device change event arrived. Maybe this topic belong to > the hotplug mailing list. > > > > > > Short of rmmod'ing a driver, there is no way to prevent the kernel > > from > > binding it to a device. However, VMware can tell the > kernel to _unbind_ a > > driver by using the USBDEVFS_DISCONNECT ioctl in usbfs. > > I add the USBDEVFS_DISCONNECT to VMware recently. But that > doesn't solved all the problems. > > Let the device bind to a kernel driver then disconnect it > again will disturb some (broken) USB devices. Some PDA > syncing tend to have this problem. I guess the firmware in > the PDA has some pretty straight forward initialing > sequence in mind, anything beyond that is likely goto an > untested code path. > > In that case, it would be best not to let the kernel driver > touch the device at all. I am thinking an option that kernel > will aways pass the event to hotplug and let the hotplug > decide what to do next. > > > > > > It might be possible to change the hotplug manager so that VMware > > could > > tell it to ignore USB events. > > I will look into that. As I mention above, the kernel needs > the ability to the skip the binding in the first place. > > Thanks again. > > Chris > > > --__--__-- > > Message: 4 > Date: Thu, 17 Mar 2005 17:02:28 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Adrian Bunk <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED], linux-usb-devel@lists.sourceforge.net, > linux-kernel@vger.kernel.org > Subject: [linux-usb-devel] Re: [2.6 patch] USB: possible cleanups > > On Tue, Mar 01, 2005 at 01:43:52AM +0100, Adrian Bunk wrote: > > Before I'm getting flamed to death: > > This patch contains possible cleanups. If parts of this > patch conflict > > with pending changes these parts of my patch have to be dropped. > > > > This patch contains the following possible cleanups: > > - make needlessly global code static > > - #if 0 the following unused global functions: > > - core/usb.c: usb_buffer_map > > - core/usb.c: usb_buffer_unmap > > - remove the following unneeded EXPORT_SYMBOL's: > > - core/hcd.c: usb_bus_init > > - core/hcd.c: usb_alloc_bus > > - core/hcd.c: usb_register_bus > > - core/hcd.c: usb_deregister_bus > > - core/hcd.c: usb_hcd_irq > > - core/usb.c: usb_buffer_map > > - core/usb.c: usb_buffer_unmap > > - core/buffer.c: hcd_buffer_create > > - core/buffer.c: hcd_buffer_destroy > > > > Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]> > > Looks good to me, thanks for the patch. Applied. > > greg k-h > > > --__--__-- > > Message: 5 > Date: Thu, 17 Mar 2005 17:17:41 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Adrian Bunk <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED], linux-usb-devel@lists.sourceforge.net, > linux-kernel@vger.kernel.org > Subject: [linux-usb-devel] Re: [2.6 patch] > drivers/usb/serial/: make some functions static > > On Tue, Mar 01, 2005 at 01:39:35AM +0100, Adrian Bunk wrote: > > This patch makes some needlessly global functions static. > > > > Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]> > > Applied, thanks. > > greg k-h > > > --__--__-- > > Message: 6 > Date: Thu, 17 Mar 2005 17:17:46 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Adrian Bunk <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED], > linux-usb-devel@lists.sourceforge.net, > linux-kernel@vger.kernel.org > Subject: [linux-usb-devel] Re: [2.6 patch] > drivers/usb/storage/: cleanups > > On Tue, Mar 01, 2005 at 01:37:58AM +0100, Adrian Bunk wrote: > > This patch contains the following cleanups: > > - make needlessly global code static > > - scsiglue.c: remove the unused usb_stor_sense_notready > > > > Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]> > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 7 > Date: Thu, 17 Mar 2005 17:17:51 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Adrian Bunk <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED], > linux-usb-devel@lists.sourceforge.net, > linux-kernel@vger.kernel.org > Subject: [linux-usb-devel] Re: [2.6 patch] > drivers/usb/net/pegasus.c: make some code static > > On Tue, Mar 01, 2005 at 01:35:41AM +0100, Adrian Bunk wrote: > > This patch makes some needlessly global code static. > > > > Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]> > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 8 > Date: Thu, 17 Mar 2005 17:17:56 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Adrian Bunk <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED], linux-usb-devel@lists.sourceforge.net, > linux-kernel@vger.kernel.org > Subject: [linux-usb-devel] Re: [2.6 patch] remove > drivers/usb/image/hpusbscsi.c > > On Thu, Mar 03, 2005 at 02:38:56PM +0100, Adrian Bunk wrote: > > USB_HPUSBSCSI was marked as BROKEN in 2.6.11 since libsane is the > > preferred way to access these devices. > > > > Unless someone plans to resurrect this driver, I'm > therefore proposing > > this patch to completely remove it. > > > > Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]> > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 9 > From: Antti Andreimann <[EMAIL PROTECTED]> > To: linux-usb-devel@lists.sourceforge.net > Date: Fri, 18 Mar 2005 03:27:11 +0200 > Subject: [linux-usb-devel] What's wrong with iso-IN split > transactions? > > Hi! > > I see from the drivers/usb/host/ehci-sched.c that those are > not supported. I also found a year-old post in this list by > David Brownell which states: > > > It's essentially all coded, but microframe scheduling needs > tweaks for > > the IN cases. I decided to force ENOMEM until that code is > ready ... > > someone willing to play with the code could turn it on and > shouldn't > > find it needs many changes. > > What is the status of this stuff now? Has anyone done any > work on this and what exactly is the problem with current > code? I did try to turn it on for my USB soundcard (so it > would work through a USB 2.0 hub) and experienced a NULL > pointer dereference plus some spinlock errors. I haven't > tried it without pre-emption yet. I am willing to spend some > time to tweak and test it if I'd know what exactly needs tweaking ;) > > -- > Antti Andreimann - Security Expert > Using Linux since 1993 > Member of ELUG since 29.01.2000 > > > --__--__-- > > Message: 10 > Date: Thu, 17 Mar 2005 17:33:18 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: [patch 2.6.11-usb] usbnet gets > status polling, uses for CDC Ethernet > > On Sun, Mar 06, 2005 at 08:50:11PM -0800, David Brownell wrote: > > This patch applies with minor offsets against the latest USB BK, > > adding status/interrupt transfer support to the infrastructure and > > using it for CDC Ethernet for link status notifications. > Please merge. > > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 11 > Date: Thu, 17 Mar 2005 17:33:08 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: [patch 2.6.11] ohci zero > length control IN transfers > > On Wed, Mar 02, 2005 at 09:18:18AM -0800, David Brownell wrote: > > This fixes a rare protocol bug that's been with us since at > least 2.4 > > days; please merge. > > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 12 > Date: Thu, 17 Mar 2005 17:33:13 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: [patch 2.6.11] ehci and short > in-bulk transfers with 20KB+ urbs > > On Thu, Mar 03, 2005 at 11:18:08AM -0800, David Brownell wrote: > > This addresses the problem Steve Hosgood was seeing, which > seems to be > > a chip-specific misbehavior with certain sizes for urb buffers. > > Please merge. > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 13 > Date: Thu, 17 Mar 2005 17:33:29 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: [patch 2.6.11-usb] net2280 > reports correct dequeue status > > On Sun, Mar 06, 2005 at 10:55:58PM -0800, David Brownell wrote: > > Driver was wrongly reporting failure in some cases; please merge. > > > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 14 > Date: Thu, 17 Mar 2005 17:33:23 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: linux-usb-devel@lists.sourceforge.net, > Holger Klawitter <[EMAIL PROTECTED]> > Subject: [linux-usb-devel] Re: [patch 2.6.11-usb] usbnet fix > for Zaurus C-860 > > On Sun, Mar 06, 2005 at 08:50:18PM -0800, David Brownell wrote: > > This fixes the problem Holger had with his Zaurus, and adds > some more > > class declarations to the <linux/usb_cdc.h> headers. Please merge. > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 15 > Date: Thu, 17 Mar 2005 17:33:34 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: [patch 2.6.11-usb] > ethernet/rndis gadget driver updates > > On Sun, Mar 06, 2005 at 10:56:01PM -0800, David Brownell wrote: > > This has several small updates; please merge. > > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 16 > Date: Thu, 17 Mar 2005 17:32:53 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: Greg KH <[EMAIL PROTECTED]>, linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: [patch 2.6] add at91_udc recognition > > On Mon, Feb 28, 2005 at 06:45:21PM -0800, David Brownell wrote: > > This just adds recognition for the Atmel AT91 USB peripheral > > controller. (And a missing check for the Samsung S3C2410.) This > > PIO-only hardware is used in a variety of chips, including the > > at91rm9200. (That one has an MMU and runs "regular Linux".) > > > > Please merge; the patch is against your current BK. > > Applied, thanks. > > greg k-h > > > --__--__-- > > Message: 17 > Date: Thu, 17 Mar 2005 17:33:03 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: David Brownell <[EMAIL PROTECTED]> > Cc: Greg KH <[EMAIL PROTECTED]>, linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: [patch 2.6] usb gadget kconfig tweaks > > On Mon, Feb 28, 2005 at 07:05:55PM -0800, David Brownell wrote: > > Removes sa-1100 support until someone finishes that driver; > and moves > > dummy_hcd to the end so that Kconfig will preferentially configure > > real hardware. > > Applied, thanks. > > greg k-h > > > > --__--__-- > > Message: 18 > Date: Thu, 17 Mar 2005 17:49:55 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Pete Zaitcev <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED], linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: Patch for ub to fix oops after > disconnect > > On Mon, Feb 21, 2005 at 02:22:15PM -0800, Pete Zaitcev wrote: > > Please pass this to Linus as soon as practical, because this is a > > bugfix. > > > > This patch was developed by Glenn Maynard for his oops back in > > December, but for some reason I forgot about it and had it > > reimplemented when I stepped on this problem myself. In my > case, there > > was no oops, but a warning about slab corruption. > > Applied, thanks. > > greg k-h > > > --__--__-- > > Message: 19 > Date: Thu, 17 Mar 2005 17:56:39 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Alan Stern <[EMAIL PROTECTED]> > Cc: USB development list <linux-usb-devel@lists.sourceforge.net> > Subject: [linux-usb-devel] Re: [PATCH as481] g_file_storage: > add configuration and interface strings > > On Fri, Mar 04, 2005 at 04:15:40PM -0500, Alan Stern wrote: > > Greg: > > > > This patch adds iConfiguration and iInterface strings to the > > g_file_storage driver (just to spiff it up and help in testing > > software that looks at those strings). It also enlarges the space > > reserved for the Manufacturer string, since combinations of long > > kernel names and long UDC driver names were sometimes getting > > truncated. > > Applied, thanks. > > greg k-h > > > --__--__-- > > Message: 20 > Date: Thu, 17 Mar 2005 17:56:27 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Oliver Neukum <[EMAIL PROTECTED]> > Cc: David Brownell <[EMAIL PROTECTED]>, > linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] Re: [PATCH]removal of obsolete > error code from kaweth > > On Sat, Mar 05, 2005 at 09:01:04AM +0100, Oliver Neukum wrote: > > Hi, > > > > this patch from David removes an obsolete error code from kaweth. > > Applied, thanks. > > greg k-h > > > --__--__-- > > Message: 21 > Date: Thu, 17 Mar 2005 17:57:11 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Alan Stern <[EMAIL PROTECTED]> > Cc: USB development list <linux-usb-devel@lists.sourceforge.net> > Subject: [linux-usb-devel] Re: [PATCH as482] usb-midi: fix > arguments to usb_maxpacket() > > On Mon, Feb 28, 2005 at 12:09:12PM -0500, Alan Stern wrote: > > Greg: > > > > The usb-midi driver uses an incorrect value for the is_out > argument to > > usb_maxpacket(), triggering a WARN_ON. This patch fixes > the mistake. > > Applied, thanks. > > greg k-h > > > --__--__-- > > Message: 22 > Date: Thu, 17 Mar 2005 17:56:32 -0800 > From: Greg KH <[EMAIL PROTECTED]> > To: Alan Stern <[EMAIL PROTECTED]> > Cc: USB development list <linux-usb-devel@lists.sourceforge.net> > Subject: [linux-usb-devel] Re: [PATCH as483] Prevent hub > driver interference during port reset > > On Fri, Mar 04, 2005 at 04:21:36PM -0500, Alan Stern wrote: > > Greg: > > > > This patch causes the hub driver to ignore ports that are > being reset > > by another driver. Without this protection khubd will sometimes > > notice that the port is behaving funny while the reset is > taking place > > and will unilaterally disconnect it, which is not what we want. > > Applied, thanks. > > greg k-h > > > --__--__-- > > Message: 23 > From: David Brownell <[EMAIL PROTECTED]> > To: Greg KH <[EMAIL PROTECTED]> > Date: Thu, 17 Mar 2005 17:59:48 -0800 > Cc: linux-usb-devel@lists.sourceforge.net > Subject: [linux-usb-devel] [patch 2.6.11] pxa25x udc updates, > mostly PM > > --Boundary-00=_UYjOCdbIEsNn6c6 > Content-Type: text/plain; > charset="us-ascii" > Content-Transfer-Encoding: 7bit > Content-Disposition: inline > > This supports the newish (as of last summer) pullup and vbus > session calls, using them to support PM. Also sparse fixes. > Tested on multiple boards; please merge. > > - Dvae > > --Boundary-00=_UYjOCdbIEsNn6c6 > Content-Type: text/x-diff; > charset="us-ascii"; > name="pxa2xx-0312.patch" > Content-Transfer-Encoding: 7bit > Content-Disposition: attachment; > filename="pxa2xx-0312.patch" > > This has various updates to the PXA 21x/25x/26x UDC driver. > > - Implement the "new" pullup() and vbus_session() methods, and > use them to keep the UDC 48 MHz clock off much of the time. > > * Reworked that ugly Lubbock VBUS IRQ code. Claim both IRQs, > enable only one at a time; clock the UDC only when VBUS is > present. (And get rid of rude runtime messages.) > > * Implement driver model suspend() and resume() calls. When > this device suspends, it clocks off the UDC. On boards that > support it (including Zaurus clamshells, but not Lubbock) > the D+ pullup is disabled, so the host won't see the device. > > - Hmm, the "latest" errata defined some "Must Be One" bits. OK. > > - Change the LED support for debugging. It stopped compiling for > Lubbock a while back. This switches to the standard LED calls > (so it can work on non-Lubbock hardware), removes the EP0 calls > (not very useful any more), and for Lubbock now initializes the > hex leds (U-Boot doesn't enable them, BLOB did). > > - "sparse" updates, and get rid of a warning that's pointless > unless someone's working on DMA support; > > Tested on Lubbock (VBUS sensing but no pullup) and some > Zaurus clamshells (pullup but no VBUS). > > Signed-off-by: David Brownell <[EMAIL PROTECTED]> > > --- a/drivers/usb/gadget/pxa2xx_udc.c 2005-03-12 16:35:52 -08:00 > +++ b/drivers/usb/gadget/pxa2xx_udc.c 2005-03-12 16:35:52 -08:00 > @@ -310,7 +311,7 @@ > /* flush fifo (mostly for IN buffers) */ > pxa2xx_ep_fifo_flush (_ep); > > - ep->desc = 0; > + ep->desc = NULL; > ep->stopped = 1; > > DBG(DBG_VERBOSE, "%s disabled\n", _ep->name); > @@ -334,7 +335,7 @@ > > req = kmalloc (sizeof *req, gfp_flags); > if (!req) > - return 0; > + return NULL; > > memset (req, 0, sizeof *req); > INIT_LIST_HEAD (&req->queue); > @@ -369,7 +370,11 @@ > > retval = kmalloc (bytes, gfp_flags & > ~(__GFP_DMA|__GFP_HIGHMEM)); > if (retval) > +#ifdef USE_DMA > *dma = virt_to_bus (retval); > +#else > + *dma = (dma_addr_t)~0; > +#endif > return retval; > } > > @@ -411,7 +416,6 @@ > static inline void ep0_idle (struct pxa2xx_udc *dev) > { > dev->ep0state = EP0_IDLE; > - LED_EP0_OFF; > } > > static int > @@ -930,7 +934,7 @@ > case EP0_IN_DATA_PHASE: > dev->stats.write.ops++; > if (write_ep0_fifo(ep, req)) > - req = 0; > + req = NULL; > break; > > case EP0_OUT_DATA_PHASE: > @@ -940,7 +944,8 @@ > DBG(DBG_VERBOSE, "ep0 > config ack%s\n", > dev->has_cfr ? > "" : " raced"); > if (dev->has_cfr) > - UDCCFR = > UDCCFR_AREN|UDCCFR_ACM; > + UDCCFR = > UDCCFR_AREN|UDCCFR_ACM > + |UDCCFR_MB1; > done(ep, req, 0); > dev->ep0state = EP0_END_XFER; > local_irq_restore (flags); > @@ -952,7 +957,7 @@ > && > read_ep0_fifo(ep, req))) { > ep0_idle(dev); > done(ep, req, 0); > - req = 0; > + req = NULL; > } > break; > > @@ -970,10 +975,10 @@ > } else if ((ep->bEndpointAddress & USB_DIR_IN) != 0 > && (*ep->reg_udccs & UDCCS_BI_TFS) != 0 > && write_fifo(ep, req)) { > - req = 0; > + req = NULL; > } else if ((*ep->reg_udccs & UDCCS_BO_RFS) != 0 > && read_fifo(ep, req)) { > - req = 0; > + req = NULL; > } > > if (likely (req && ep->desc) && ep->dma < 0) > @@ -1094,7 +1099,6 @@ > start_watchdog(ep->dev); > ep->dev->req_pending = 0; > ep->dev->ep0state = EP0_STALL; > - LED_EP0_OFF; > > /* and bulk/intr endpoints like dropping stalls too */ > } else { > @@ -1194,13 +1198,71 @@ > return 0; > } > > +static void stop_activity(struct pxa2xx_udc *, struct > usb_gadget_driver > +*); static void udc_enable (struct pxa2xx_udc *); static void > +udc_disable(struct pxa2xx_udc *); > + > +/* We disable the UDC -- and its 48 MHz clock -- whenever it's not > + * in active use. > + */ > +static int pullup(struct pxa2xx_udc *udc, int is_active) > +{ > + is_active = is_active && udc->vbus && udc->pullup; > + DMSG("%s\n", is_active ? "active" : "inactive"); > + if (is_active) > + udc_enable(udc); > + else { > + if (udc->gadget.speed != USB_SPEED_UNKNOWN) { > + DMSG("disconnect %s\n", udc->driver > + ? udc->driver->driver.name > + : "(no driver)"); > + stop_activity(udc, udc->driver); > + } > + udc_disable(udc); > + } > + return 0; > +} > + > +/* VBUS reporting logically comes from a transceiver */ > +static int pxa2xx_udc_vbus_session(struct usb_gadget *_gadget, int > +is_active) { > + struct pxa2xx_udc *udc; > + > + udc = container_of(_gadget, struct pxa2xx_udc, gadget); > + udc->vbus = is_active = (is_active != 0); > + DMSG("vbus %s\n", is_active ? "supplied" : "inactive"); > + pullup(udc, is_active); > + return 0; > +} > + > +/* drivers may have software control over D+ pullup */ > +static int pxa2xx_udc_pullup(struct usb_gadget *_gadget, int > is_active) > +{ > + struct pxa2xx_udc *udc; > + > + udc = container_of(_gadget, struct pxa2xx_udc, gadget); > + > + /* not all boards support pullup control */ > + if (!udc->mach->udc_command) > + return -EOPNOTSUPP; > + > + is_active = (is_active != 0); > + udc->pullup = is_active; > + pullup(udc, is_active); > + return 0; > +} > + > static const struct usb_gadget_ops pxa2xx_udc_ops = { > - .get_frame = pxa2xx_udc_get_frame, > - .wakeup = pxa2xx_udc_wakeup, > - // current versions must always be self-powered > + .get_frame = pxa2xx_udc_get_frame, > + .wakeup = pxa2xx_udc_wakeup, > + .vbus_session = pxa2xx_udc_vbus_session, > + .pullup = pxa2xx_udc_pullup, > + > + // .vbus_draw ... boards may consume current from VBUS, up to > + // 100-500mA based on config. the 500uA suspend ceiling means > + // that exclusively vbus-powered PXA designs violate USB specs. > }; > > - > /*------------------------------------------------------------ > -------------*/ > > #ifdef CONFIG_USB_GADGET_DEBUG_FILES > @@ -1427,7 +1489,7 @@ > if (i != 0) > list_add_tail (&ep->ep.ep_list, > &dev->gadget.ep_list); > > - ep->desc = 0; > + ep->desc = NULL; > ep->stopped = 0; > INIT_LIST_HEAD (&ep->queue); > ep->pio_irqs = ep->dma_irqs = 0; > @@ -1446,6 +1508,7 @@ > #ifdef CONFIG_ARCH_PXA > /* Enable clock for USB device */ > pxa_set_cken(CKEN11_USB, 1); > + udelay(5); > #endif > > /* try to clear these bits before we enable the udc */ > @@ -1469,7 +1532,7 @@ > /* pxa255 (a0+) can avoid a set_config race that could > * prevent gadget drivers from configuring correctly > */ > - UDCCFR = UDCCFR_ACM; > + UDCCFR = UDCCFR_ACM | UDCCFR_MB1; > } else { > /* "USB test mode" for pxa250 errata 40-42 > (stepping a0, a1) > * which could result in missing packets and interrupts. > @@ -1498,18 +1561,13 @@ > } > #endif > > - /* caller must be able to sleep in order to cope > - * with startup transients. > - */ > - msleep(100); > - > /* enable suspend/resume and reset irqs */ > udc_clear_mask_UDCCR(UDCCR_SRM | UDCCR_REM); > > /* enable ep0 irqs */ > UICR0 &= ~UICR0_IM0; > > - /* if hardware supports it, connect to usb and wait for host */ > + /* if hardware supports it, pullup D+ and wait for reset */ > let_usb_appear(); > } > > @@ -1540,6 +1598,7 @@ > /* first hook up the driver ... */ > dev->driver = driver; > dev->gadget.dev.driver = &driver->driver; > + dev->pullup = 1; > > device_add (&dev->gadget.dev); > retval = driver->bind(&dev->gadget); > @@ -1548,18 +1607,17 @@ > driver->driver.name, retval); > device_del (&dev->gadget.dev); > > - dev->driver = 0; > - dev->gadget.dev.driver = 0; > + dev->driver = NULL; > + dev->gadget.dev.driver = NULL; > return retval; > } > device_create_file(dev->dev, &dev_attr_function); > > /* ... then enable host detection and ep0; and we're ready > * for set_configuration as well as eventual disconnect. > - * NOTE: this shouldn't power up until later. > */ > DMSG("registered gadget driver '%s'\n", driver->driver.name); > - udc_enable(dev); > + pullup(dev, 1); > dump_state(dev); > return 0; > } > @@ -1572,7 +1630,7 @@ > > /* don't disconnect drivers more than once */ > if (dev->gadget.speed == USB_SPEED_UNKNOWN) > - driver = 0; > + driver = NULL; > dev->gadget.speed = USB_SPEED_UNKNOWN; > > /* prevent new request submissions, kill any > outstanding requests */ @@ -1603,12 +1661,12 @@ > return -EINVAL; > > local_irq_disable(); > - udc_disable(dev); > + pullup(dev, 0); > stop_activity(dev, driver); > local_irq_enable(); > > driver->unbind(&dev->gadget); > - dev->driver = 0; > + dev->driver = NULL; > > device_del (&dev->gadget.dev); > device_remove_file(dev->dev, &dev_attr_function); > @@ -1624,61 +1682,41 @@ > > #ifdef CONFIG_ARCH_LUBBOCK > > -/* Lubbock can report connect or disconnect irqs. Likely > more hardware > - * could support it as a timer callback. > - * > - * FIXME for better power management, keep the hardware powered down > - * until a host is powering the link. means scheduling work later > - * in some task that can udc_enable(). > +/* Lubbock has separate connect and disconnect irqs. More typical > +designs > + * use one GPIO as the VBUS IRQ, and another to control the > D+ pullup. > */ > > -#define enable_disconnect_irq() \ > - if (machine_is_lubbock()) { enable_irq(LUBBOCK_USB_DISC_IRQ); } > -#define disable_disconnect_irq() \ > - if (machine_is_lubbock()) { disable_irq(LUBBOCK_USB_DISC_IRQ); } > - > static irqreturn_t > -usb_connection_irq(int irq, void *_dev, struct pt_regs *r) > +lubbock_vbus_irq(int irq, void *_dev, struct pt_regs *r) > { > struct pxa2xx_udc *dev = _dev; > + int vbus; > > dev->stats.irqs++; > HEX_DISPLAY(dev->stats.irqs); > - > - if (!is_usb_connected()) { > - LED_CONNECTED_OFF; > - disable_disconnect_irq(); > - /* report disconnect just once */ > - if (dev->gadget.speed != USB_SPEED_UNKNOWN) { > - DMSG("disconnect %s\n", > - dev->driver ? > dev->driver->driver.name : 0); > - stop_activity(dev, dev->driver); > - > - // udc_disable (dev); > - // no more udc irqs > - // maybe "ACTION=disconnect > /sbin/hotplug gadget". > - } > - } else if (dev->gadget.speed == USB_SPEED_UNKNOWN) { > + switch (irq) { > + case LUBBOCK_USB_IRQ: > LED_CONNECTED_ON; > - > - DMSG("?? connect irq ??\n"); > - > - // if there's no driver bound, ignore; else > - // udc_enable (dev); > - // UDC irqs drive the rest. > - // maybe "ACTION=connect /sbin/hotplug gadget". > + vbus = 1; > + disable_irq(LUBBOCK_USB_IRQ); > + enable_irq(LUBBOCK_USB_DISC_IRQ); > + break; > + case LUBBOCK_USB_DISC_IRQ: > + LED_CONNECTED_OFF; > + vbus = 0; > + disable_irq(LUBBOCK_USB_DISC_IRQ); > + enable_irq(LUBBOCK_USB_IRQ); > + break; > + default: > + return IRQ_NONE; > } > + > + pxa2xx_udc_vbus_session(&dev->gadget, vbus); > return IRQ_HANDLED; > } > > #endif > > -#ifndef enable_disconnect_irq > -#warning USB disconnect() is not yet reported. > -#define enable_disconnect_irq() do {} while (0) > -#define disable_disconnect_irq() do {} while (0) > -#endif > - > > > /*------------------------------------------------------------ > -------------*/ > > @@ -1720,7 +1758,7 @@ > } u; > > if (list_empty(&ep->queue)) > - req = 0; > + req = NULL; > else > req = list_entry(ep->queue.next, struct > pxa2xx_request, queue); > > @@ -1764,14 +1802,11 @@ > goto bad_setup; > > got_setup: > - le16_to_cpus (&u.r.wValue); > - le16_to_cpus (&u.r.wIndex); > - le16_to_cpus (&u.r.wLength); > - > - LED_EP0_ON; > DBG(DBG_VERBOSE, "SETUP %02x.%02x v%04x > i%04x l%04x\n", > u.r.bRequestType, u.r.bRequest, > - u.r.wValue, u.r.wIndex, u.r.wLength); > + le16_to_cpu(u.r.wValue), > + le16_to_cpu(u.r.wIndex), > + le16_to_cpu(u.r.wLength)); > > /* cope with automagic for some > standard requests. */ > dev->req_std = (u.r.bRequestType & > USB_TYPE_MASK) > @@ -1803,7 +1838,8 @@ > * - ep reset doesn't > include halt(?). > */ > DMSG("broken > set_interface (%d/%d)\n", > - u.r.wIndex, u.r.wValue); > + le16_to_cpu(u.r.wIndex), > + > le16_to_cpu(u.r.wValue)); > goto config_change; > } > break; > @@ -1847,7 +1883,6 @@ > ep0start(dev, > UDCCS0_FST|UDCCS0_FTF, "stall"); > start_watchdog(dev); > dev->ep0state = EP0_STALL; > - LED_EP0_OFF; > > /* deferred i/o == no response yet */ > } else if (dev->req_pending) { > @@ -1948,7 +1983,7 @@ > req = list_entry(ep->queue.next, > struct pxa2xx_request, queue); > else > - req = 0; > + req = NULL; > > // TODO check FST handling > > @@ -2050,8 +2085,6 @@ > > if ((UDCCR & UDCCR_UDA) == 0) { > DBG(DBG_VERBOSE, "USB reset start\n"); > - if (dev->gadget.speed != > USB_SPEED_UNKNOWN) > - disable_disconnect_irq(); > > /* reset driver and endpoints, > * in case that's not yet done > @@ -2059,12 +2092,11 @@ > stop_activity (dev, dev->driver); > > } else { > - INFO("USB reset\n"); > + DBG(DBG_VERBOSE, "USB reset end\n"); > dev->gadget.speed = USB_SPEED_FULL; > LED_CONNECTED_ON; > memset(&dev->stats, 0, sizeof > dev->stats); > /* driver and endpoints are > still reset */ > - enable_disconnect_irq(); > } > > } else { > @@ -2478,6 +2548,8 @@ > udc_disable(dev); > udc_reinit(dev); > > + dev->vbus = is_usb_connected(); > + > /* irq setup after old hardware state is cleaned up */ > retval = request_irq(IRQ_USB, pxa2xx_udc_irq, > SA_INTERRUPT, driver_name, dev); > @@ -2490,18 +2562,32 @@ > > #ifdef CONFIG_ARCH_LUBBOCK > if (machine_is_lubbock()) { > - disable_irq(LUBBOCK_USB_DISC_IRQ); > retval = request_irq(LUBBOCK_USB_DISC_IRQ, > - usb_connection_irq, > - SA_INTERRUPT /* OOPSING | > SA_SAMPLE_RANDOM */, > + lubbock_vbus_irq, > + SA_INTERRUPT | SA_SAMPLE_RANDOM, > driver_name, dev); > if (retval != 0) { > - enable_irq(LUBBOCK_USB_DISC_IRQ); > printk(KERN_ERR "%s: can't get irq %i, > err %d\n", > driver_name, > LUBBOCK_USB_DISC_IRQ, retval); > +lubbock_fail0: > + free_irq(IRQ_USB, dev); > return -EBUSY; > } > - dev->got_disc = 1; > + retval = request_irq(LUBBOCK_USB_IRQ, > + lubbock_vbus_irq, > + SA_INTERRUPT | SA_SAMPLE_RANDOM, > + driver_name, dev); > + if (retval != 0) { > + printk(KERN_ERR "%s: can't get irq %i, > err %d\n", > + driver_name, LUBBOCK_USB_IRQ, retval); > + free_irq(LUBBOCK_USB_DISC_IRQ, dev); > + goto lubbock_fail0; > + } > +#ifdef DEBUG > + /* with U-Boot (but not BLOB), hex is off by default */ > + HEX_DISPLAY(dev->stats.irqs); > + LUB_DISC_BLNK_LED &= 0xff; > +#endif > } > #endif > create_proc_files(); > @@ -2510,7 +2596,7 @@ > } > static int __exit pxa2xx_udc_remove(struct device *_dev) > { > - struct pxa2xx_udc *dev = _dev->driver_data; > + struct pxa2xx_udc *dev = dev_get_drvdata(_dev); > > udc_disable(dev); > remove_proc_files(); > @@ -2520,15 +2606,57 @@ > free_irq(IRQ_USB, dev); > dev->got_irq = 0; > } > - if (machine_is_lubbock() && dev->got_disc) { > + if (machine_is_lubbock()) { > free_irq(LUBBOCK_USB_DISC_IRQ, dev); > - dev->got_disc = 0; > + free_irq(LUBBOCK_USB_IRQ, dev); > + } > + dev_set_drvdata(_dev, NULL); > + the_controller = NULL; > + return 0; > +} > + > +/*----------------------------------------------------------- > ---------- > +----*/ > + > +#ifdef CONFIG_PM > + > +/* USB suspend (controlled by the host) and system suspend > (controlled > + * by the PXA) don't necessarily work well together. If USB > is active, > + * the 48 MHz clock is required; so the system can't enter > 33 MHz idle > + * mode, or any deeper PM saving state. > + * > + * For now, we punt and forcibly disconnect from the USB > host when PXA > + * enters any suspend state. While we're disconnected, we always > +disable > + * the 48MHz USB clock ... allowing PXA sleep and/or 33 MHz > idle states. > + * Boards without software pullup control shouldn't use those states. > + * VBUS IRQs should probably be ignored so that the PXA > device just acts > + * "dead" to USB hosts until system resume. > + */ > +static int pxa2xx_udc_suspend(struct device *dev, u32 state, > u32 level) > +{ > + struct pxa2xx_udc *udc = dev_get_drvdata(dev); > + > + if (level == SUSPEND_POWER_DOWN) { > + if (!udc->mach->udc_command) > + WARN("USB host won't detect disconnect!\n"); > + pullup(udc, 0); > } > - dev_set_drvdata(_dev, 0); > - the_controller = 0; > return 0; > } > > +static int pxa2xx_udc_resume(struct device *dev, u32 level) > +{ > + struct pxa2xx_udc *udc = dev_get_drvdata(dev); > + > + if (level == RESUME_POWER_ON) > + pullup(udc, 1); > + return 0; > +} > + > +#else > +#define pxa2xx_udc_suspend NULL > +#define pxa2xx_udc_resume NULL > +#endif > + > > /*------------------------------------------------------------ > -------------*/ > > static struct device_driver udc_driver = { > @@ -2536,10 +2664,8 @@ > .bus = &platform_bus_type, > .probe = pxa2xx_udc_probe, > .remove = __exit_p(pxa2xx_udc_remove), > - > - // FIXME power management support > - // .suspend = ... disable UDC > - // .resume = ... re-enable UDC > + .suspend = pxa2xx_udc_suspend, > + .resume = pxa2xx_udc_resume, > }; > > static int __init udc_init(void) > --- a/drivers/usb/gadget/pxa2xx_udc.h 2005-03-12 16:35:52 -08:00 > +++ b/drivers/usb/gadget/pxa2xx_udc.h 2005-03-12 16:35:52 -08:00 > @@ -40,6 +40,9 @@ > #define UDCCFR_AREN (1 << 7) /* ACK response enable (now) */ > #define UDCCFR_ACM (1 << 2) /* ACK control mode > (wait for AREN) */ > > +/* latest pxa255 errata define new "must be one" bits in UDCCFR */ > +#define UDCCFR_MB1 (0xff & ~(UDCCFR_AREN|UDCCFR_ACM)) > + > > /*------------------------------------------------------------ > -------------*/ > > struct pxa2xx_udc; > @@ -120,7 +123,8 @@ > enum ep0_state ep0state; > struct udc_stats stats; > unsigned got_irq : 1, > - got_disc : 1, > + vbus : 1, > + pullup : 1, > has_cfr : 1, > req_pending : 1, > req_std : 1, > @@ -143,14 +147,7 @@ > > #ifdef DEBUG > #define HEX_DISPLAY(n) if (machine_is_lubbock()) { > LUB_HEXLED = (n); } > - > -#define LED_CONNECTED_ON if (machine_is_lubbock()) { \ > - DISCRETE_LED_ON(D26); } > -#define LED_CONNECTED_OFF if(machine_is_lubbock()) { \ > - DISCRETE_LED_OFF(D26); LUB_HEXLED = 0; } > -#define LED_EP0_ON if (machine_is_lubbock()) { > DISCRETE_LED_ON(D25); } > -#define LED_EP0_OFF if (machine_is_lubbock()) { > DISCRETE_LED_OFF(D25); } > -#endif /* DEBUG */ > +#endif > > #endif > > @@ -161,13 +158,19 @@ > #define HEX_DISPLAY(n) do {} while(0) > #endif > > +#ifdef DEBUG > +#include <asm/leds.h> > + > +#define LED_CONNECTED_ON leds_event(led_green_on) > +#define LED_CONNECTED_OFF do { \ > + leds_event(led_green_off); \ > + HEX_DISPLAY(0); \ > + } while(0) > +#endif > + > #ifndef LED_CONNECTED_ON > #define LED_CONNECTED_ON do {} while(0) > #define LED_CONNECTED_OFF do {} while(0) > -#endif > -#ifndef LED_EP0_ON > -#define LED_EP0_ON do {} while (0) > -#define LED_EP0_OFF do {} while (0) > #endif > > > /*------------------------------------------------------------ > -------------*/ > > --Boundary-00=_UYjOCdbIEsNn6c6-- > > > > --__--__-- > > _______________________________________________ > linux-usb-devel@lists.sourceforge.net > To unsubscribe, use the last form field at: > https://lists.sourceforge.net/lists/listinfo/linux-usb-devel > > > End of linux-usb-devel Digest > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel