This splits the gadget zero "loopback" configuration into a standalone
"configuration driver", building on the composite gadget framework code.
It doesn't yet pull the original code out of gadget zero or update how
that driver is built.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This splits the gadget zero "source/sink" configuration into a standalone
"configuration driver", building on the composite gadget framework code.
It doesn't yet pull the original code out of gadget zero or update how
that driver is built.
Neither this, nor its sibling "loopback" configuration, is a function
driver that can be combined with other functions. (The host "usbtest"
driver wouldn't know how to deal with that!) However the code becomes
simpler because of this conversion, so it's a net win.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Add <linux/usb/composite.h> interfaces for composite gadget drivers, and
basic implementation support behind it:
- struct usb_function ... groups one or more interfaces into a function
managed as one unit within a configuration, to which it's added by
usb_add_function().
- struct usb_configuration ... groups one or more such functions into
a configuration managed as one unit by a driver, to which it's added
by usb_add_config(). These operate at either high or full/low speeds
and at a given bMaxPower.
- struct usb_composite_driver ... groups one or more such configurations
into a gadget driver, which may be registered or unregistered.
- struct usb_composite_dev ... a usb_composite_driver manages this; it
wraps the usb_gadget exposed by the controller driver.
This also includes some basic kerneldoc.
How to use it (the short version): provide a usb_composite_driver with a
bind() that calls usb_add_config() for each of the needed configurations.
The configurations in turn have bind() calls, which will usb_add_function()
for each function required. Each function's bind() allocates resources
needed to perform its tasks, like endpoints; sometimes configurations will
allocate resources too.
Separate patches will convert most gadget drivers to this infrastructure.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Define three new descriptor manipulation utilities, for use when
setting up functions that may have multiple instances:
usb_copy_descriptors() to copy a vector of descriptors
usb_free_descriptors() to free the copy
usb_find_endpoint() to find a copied version
These will be used as follows. Functions will continue to have static
tables of descriptors they update, now used as __initdata templates.
When a function creates a new instance, it patches those tables with
relevant interface and string IDs, plus endpoint assignments. Then it
copies those morphed descriptors, associates the copies with the new
function instance, and records the endpoint descriptors to use when
activating the endpoints. When initialization is done, only the copies
remain in memory. The copies are freed on driver removal.
This ensures that each instance has descriptors which hold the right
instance-specific data. Two instances in the same configuration will
obviously never share the same interface IDs or use the same endpoints.
Instances in different configurations won't do so either, which means
this is slightly less memory-efficient in some cases.
This also includes a bugfix to the epautoconf code that shows up with
this usage model. It must replace the previous endpoint number when
updating the template descriptors, not just mask in a few more bits.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Teach "gadget serial" to use the new abstracted (and bugfixed) TTY glue,
and remove all the orignal tangled-up code. Update the documentation
accordingly. This is a net object code shrink and cleanup; it should
make it a lot easier to see how the TTY glue should accomodate updates
to the TTY layer, be bugfixed, etc.
Notable behavior changes include: it can now support getty even when
there's no USB connection; it fits properly into the mdev/udev world;
and RX handling is better (throttling works, and low latency).
Configurations with scripts setting up the /dev/ttygserial device node
(with "experimental" major number) may want to change that to be a
symlink pointing to the /dev/ttyGS0 file, as a migration aid; else,
just switch entirely over to mdev/udev.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This abstracts the "gadget serial" driver TTY glue into a separate
component, cleaning it up and disentangling it from connection state.
It also changed some behaviors for the better:
- Stops using "experimental" major #127, and switches over to
having the TTY layer allocate the dev_t numbers.
- Provides /sys/class/tty/ttyGS* nodes, thus mdev/udev support.
(Note "mdev" hotplug bug in Busybox v1.7.2: /dev/ttyGS0 will
be a *block* device without CONFIG_SYSFS_DEPRECATED_V2.)
- The tty nodes no longer reject opens when there's no host.
Now they can support normal getty configs in /etc/inttab...
- Now implements RX throttling. When the line discipline says
it doesn't want any more data, only packets in flight will be
delivered (currently, max 1K/8K at full/high speeds) until it
unthrottles the data.
- Supports low_latency. This is a good policy for all USB serial
adapters, since it eliminates scheduler overhead on RX paths.
This also includes much cleanup including better comments, fixing
memory leaks and other bugs (including some locking fixes), messaging
cleanup, and an interface audit and tightening. This added up to a
significant object code shrinkage, on the order of 20% (!) depending
on CPU and compiler.
A separate patch actually kicks in this new code, using the functions
declared in this new header, and removes the previous glue.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
It turns out newer versions of the AT91 UDC hardware have increased
sizes of some of the FIFOs. Reporting that is a Good Thing.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This patch removes CVS keywords that weren't updated for a long time
from comments.
Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
The bus_id field is going away, use the dev_set_name() function
to set it properly.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
The bus_id field is going away, use the dev_name() function instead.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (241 commits)
[ARM] 5171/1: ep93xx: fix compilation of modules using clocks
[ARM] 5133/2: at91sam9g20 defconfig file
[ARM] 5130/4: Support for the at91sam9g20
[ARM] 5160/1: IOP3XX: gpio/gpiolib support
[ARM] at91: Fix NAND FLASH timings for at91sam9x evaluation kits.
[ARM] 5084/1: zylonite: Register AC97 device
[ARM] 5085/2: PXA: Move AC97 over to the new central device declaration model
[ARM] 5120/1: pxa: correct platform driver names for PXA25x and PXA27x UDC drivers
[ARM] 5147/1: pxaficp_ir: drop pxa_gpio_mode calls, as pin setting
[ARM] 5145/1: PXA2xx: provide api to control IrDA pins state
[ARM] 5144/1: pxaficp_ir: cleanup includes
[ARM] pxa: remove pxa_set_cken()
[ARM] pxa: allow clk aliases
[ARM] Feroceon: don't disable BPU on boot
[ARM] Orion: LED support for HP mv2120
[ARM] Orion: add RD88F5181L-FXO support
[ARM] Orion: add RD88F5181L-GE support
[ARM] Orion: add Netgear WNR854T support
[ARM] s3c2410_defconfig: update for current build
[ARM] Acer n30: Minor style and indentation fixes.
...
This includes PXA work up to the SPI changes for the initial merge,
since e172274ccc depends on the SPI
tree being merged.
Conflicts:
arch/arm/configs/em_x270_defconfig
arch/arm/configs/xm_x270_defconfig
Support for the at91sam9g20 : Atmel 400Mhz ARM 926ej-s SOC.
AT91sam9g20 is an evolution of the at91sam9260 with a faster clock
speed.
We created a new board for this device but based the chip support
directly on 9260 files with little updates.
Here is the chip page on Atmel wabsite:
http://atmel.com/dyn/products/product_card.asp?part_id=4337
Signed-off-by: Sedji Gaouaou <sedji.gaouaou@atmel.com>
Signed-off-by: Justin Waters <justin.waters@timesys.com>
Acked-by: Andrew Victor <linux@maxim.org.za>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
The pxa2xx_udc.c driver is renamed to pxa25x_udc.c (the platform
driver name changes from pxa2xx-udc to pxa25x-udc) and the
platform driver name of pxa27x_udc.c is fixed to pxa27x-udc.
pxa_device_udc in devices.c is split into pxa25x and pxa27x flavors
and the pxa27x_device_udc is enabled in pxa27x.c.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Acked-by: Nicolas Pitre <nico@cam.org>
Acked-by: Eric Miao <eric.miao@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Including from Ian Molton:
Fixes for mistakes left over from the PXA2{5,7}X UDC split.
Signed-off-by: Ian Molton <spyro@f2s.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Change omap USB code to use omap_read/write instead of __REG for multi-omap
Cc: David Brownell <david-b@pacbell.net>
Cc: linux-usb@vger.kernel.org
Cc: i2c@lm-sensors.org
Signed-off-by: Tony Lindgren <tony@atomide.com>
Remove __REG access in DMA code, use dma_read/write instead:
- dynamically set the omap_dma_base based on the omap type
- omap_read/write becomes dma_read/write
- dma channel registers are read with dma_ch_read/write
Cc: David Brownell <david-b@pacbell.net>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Tony Lindgren <tony@atomide.com>
and include pxa2xx-regs.h as build fix since PSSR definitions
moved from pxa-regs.h into pxa2xx-regs.h.
Note: This change is temporary as pxa27x processor specific
code will be finally moved elsewhere (both drivers should
support pxa3xx, too).
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Acked-by: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Adds support for the USB High Speed Device Port on the AT91SAM9RL
system on chip. The AT91SAM9RL uses the same UDPHS IP as the AVR32 and
the AT91CAP9 (atmel_usba_udc driver).
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Andrew Victor <linux@maxim.org.za>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
The PXA25x and PXA27x USB device controller register definitions are
different. Currently, they live side by side in pxa-regs.h, but only
one set is available depending on the setting of PXA25x or PXA27x.
This means that if we build to support both PXA25x and PXA27x, the
PXA27x definitions are unavailable, even to PXA27x specific code.
Remove these definitions from pxa-regs.h, and place them in separate
files. Include these files where appropriate.
Note: according to the dependencies in drivers/usb/gadget/Kconfig,
we do not support the UDC on PXA27x nor PXA3xx CPUs, so remove the
platform devices from pxa27x.c and pxa3xx.c.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Various fixes to Atmel's high speed UDC driver.
* Issue some missing disconnect() calls. Currently they are only made
when VBUS power goes away (on boards where the driver can sense such
changes), but that's not enough for gadget drivers to clean out all
the state that's needed. Missing calls were:
- After USB reset, before starting enumeration.
- When unregistering a gadget driver, before unbind().
* Don't assume gadget drivers provide disconnect callbacks; make sure
to not call through a null pointer!
* When the driver doesn't provide an unbind() callback, refuse to
unregister it.
Also remove two bogus "error" messages:
* Related to mis-handling of disconnect() ... don't emit error messages
for disconnect() handlers that disable endpoints. All of them should
be doing that; the problem is (unfixed) oddness in atmel_usba_udc.
* Don't emit a diagnostic for a curious and transient nonfatal error
that shows up sometimes with EP0.
Those messages spammed syslog, for no good reason.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Minor fixes to pxa27x udc driver :
- don't clobber driver model bus_id field
- wrong endianess fix (no functional change; cpu is little-endian)
- double udc disable fix
- resume/suspend fix (OTG hold bit)
- make driver pxa27x dependant (check cpu at runtime)
Signed-off-by: Robert Jarzmik <rjarzmik@free.fr>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Bugfix some serial gadget descriptors:
- Stop mangling the low bits (controller type ID) of bcdDevice;
just use the high bits for a driver revision code.
- Serial numbers that aren't specific to individual devices
are useless; stop reporting "0" for this.
- Since it's not part of a CDC-conformant function, the "bulk only"
configuration shouldn't be using "CDC Data" as its interface class.
Switch over to using CLASS_VENDOR_SPEC (different value, 0xff).
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Al Borchers <alborchers@steinerpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Switch serial gadget away from a *very* old idiom: just remember
the endpoints we'll be using, instead of looking them up by name
each time. This is a net code and data (globals) shrink.
Also fix a small memory leak in the rmmod path, by working the
same as the disconnect code.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Al Borchers <alborchers@steinerpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This removes a needless data structure from the serial gadget code;
it's a small code shrink, and a larger data shrink.
Since "struct usb_request" already has a "struct list_head" reserved
for use by gadget drivers, the serial gadget code doesn't need to
allocate wrapper structs to hold that list ... it can (and should!)
just use the list_head provided for that exact use.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Al Borchers <alborchers@steinerpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Some cleanup/reorg of g_serial ... simplifying it, and disentangling
its structure so morphing it into a "function" driver (combinable with
other interfaces) should be less painful.
- Remove most forward declarations
* put tty and gadget driver structs after their contents
* snug module init/exit decls next to their functions
* reordered some functions
- Other cleanup:
* convert a funky macro to an inline function
* snug up module params next to their declarations
* add missing driver.owner
* add separator lines between major driver sections
- Add comments re potential parameter/#define changes:
* only supports one port (shrank GS_NUM_PORTS)
* changing from 9600-8-N-1 affects multiple sites
- Remove net2280-specific optimization ... it was being done
way too late, can be done by net2280 module options, and in
any case doesn't matter at any sane serial data rates.
There are no behavioral changes, but the macro thing saves I-space.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Al Borchers <alborchers@steinerpoint.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/host/ohci-sm501.c:93:24: warning: Using plain integer as NULL pointer
drivers/usb/gadget/amd5536udc.c:3254:9: warning: Using plain integer as NULL pointer
drivers/usb/gadget/amd5536udc.c:3267:9: warning: Using plain integer as NULL pointer
drivers/usb/gadget/amd5536udc.c:3277:9: warning: Using plain integer as NULL pointer
drivers/usb/gadget/amd5536udc.c:3285:9: warning: Using plain integer as NULL pointer
drivers/usb/gadget/amd5536udc.c:3293:9: warning: Using plain integer as NULL pointer
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Gadget tells controller driver to ignore Clear-Feature(HALT_ENDPOINT)
Signed-off-by: David Lopo <lopo.david@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Initialize timer earlier so if an error occurs allocating USB request
or buffer request (zero_bind) Gadget Zero will not hang trying to
delete an uninitialized timer (zero_unbind).
Signed-off-by: David Lopo <lopo.david@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Minor updates to "Gadget Zero".
- Primarily these are whitespace updates to address the fact that since
this was written, Documentation/CodingStyle was changed to disapprove
of parts of the original coding style.
- Update a few comments that weren't quite correct, notably mentioning
the "autoresume" module parameter.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Based on a patch from <Aurel.Thomi@ruag.com>, this makes the
CDC-ACM support in the serial gadget handle the SET_LINE_CODING
and SET_CONTROL_LINE_STATE requests ... which should improve
interop with at least MS-Windows "usbser.sys" if not some other
ACM host drivers.
It also adds a few REVISIT comments where this code plays a bit
loose with the CDC ACM spec. If this were used to hook up to a
real RS232 or modem link, those places would need a bit of work.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Adds pxa27x udc driver to support USB peripherals on pxa27x chips.
The driver is compatible with: Gadget Zero, the File Storage
gadget, and the Ethernet gadget (only in CDC subset mode).
The driver can't properly support multiple interfaces, because
of hardware bugs without possible workaround. That means no
RNDIS support from g_ether, and no CDC ACM support in g_serial.
Signed-off-by: Robert Jarzmik <rjarzmik@free.fr>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* endianness annotations
* endianness fixes
* missing get_unaligned/put_unaligned
It's pretty much all over the place, changes to different files are independent.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Serial-parts-Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
__FUNCTION__ is gcc-specific, use __func__
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This patch (as1061) makes g_file_storage more compliant with the
Bulk-Only Transport specification. After an invalid CBW is received,
the gadget must ignore any further bulk-OUT data until it is reset.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
The at91sam9 chip are ARMv5 so they support preload instructions.
Use preloading to load the FIFO a bit faster.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This patch (as1075) changes dummy-hcd to dynamically allocate its
platform_device structures, using the core platform_device_alloc()
interface. This is what it should have done all along, because the
dynamically-allocated structures have a release method in the driver
core and are therefore immune to being released after the module has
been unloaded.
Thanks to Richard Purdie for pointing out the need for this change.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Restore some section annotations: they were switched to "__devinit"
while they should have been "__init", because of bogus warnings. The
warnings are now fixed, so the runtime footprint of various drivers
can now shrink a bit. On ARMv5, it's about 600 bytes except for the
Ethernet gadget, where it can save a bit more.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Fix a messed up combination of two nested switch statements in
drivers/usb/gadget/dummy_hcd.c.
According to the USB spec (section 5.8.3) the maximum packet size for bulk
endpoints can be 512 for high-speed devices and 8, 16, 32 or 64 for full-speed
devices. Low-speed devices must not have bulk endpoints.
Signed-off-by: Ingo van Lil <inguin@gmx.de>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
In drivers/usb/gadget/amd5536udc.c::udc_pci_probe(), sizeof(struct udc)
storage is allocated for 'dev'.
There are many exit points from the function where 'dev' is not free'd but has
also not yet been used for anything. The following patch free's 'dev' at the
return points where it has not yet been used.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
G_PRINTER: Bug fix for blocking reads and a fix for a memory leak.
This fixes bugs in blocking IO calls. When the poll() entry point
is called receive transfers will be setup if they have not already
been. Another bug fix is that the poll() entry point now checks the
current receive buffer for data when reporting if any data had been
received. A memory leak was fixed that could have occurred when a
USB reset happened.
Signed-off-by: Craig W. Nadler <craig@nadler.us>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Based on a recent discussion on the Linux USB mailing list, remove the
designation of EXPERIMENTAL from some USB gadget entries, and tag some
of them as DEVELOPMENT.
just for fun, i added a bit of help for gadgetfs, explaining the
race condition.
Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>