1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >SA11X0 USB Device Driver</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="SA11X0 USB Device Driver"
23 HREF="devs-usb-sa11x0-ref.html"><LINK
25 TITLE="SA11X0 USB Device Driver"
26 HREF="devs-usb-sa11x0-ref.html"><LINK
28 TITLE="NEC uPD985xx USB Device Driver"
29 HREF="devs-usb-nec-upd985xx-ref.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="devs-usb-sa11x0-ref.html"
71 HREF="devs-usb-nec-upd985xx-ref.html"
82 NAME="DEVS-USB-SA11X0">SA11X0 USB Device Driver</H1
90 >SA11X0 USB Support -- Device driver for the on-chip SA11X0 USB device</DIV
97 >SA11X0 USB Hardware</H2
99 >The Intel StrongARM SA11x0 family of processors is supplied with an
100 on-chip USB slave device, the UDC (USB Device Controller). This
101 supports three endpoints. Endpoint 0 can only be used for control
102 messages. Endpoint 1 can only be used for bulk transfers from host to
103 peripheral. Endpoint 2 can only be used for bulk transfers from
104 peripheral to host. Isochronous and interrupt transfers are not
125 >Different revisions of the SA11x0 silicon have had various problems
126 with the USB support. The device driver has been tested primarily
127 against stepping B4 of the SA1110 processor, and may not function as
128 expected with other revisions. Application developers should obtain
129 the manufacturer's current errata sheets and specification updates.
130 The B4 stepping still has a number of problems, but the device driver
131 can work around these. However there is a penalty in terms of extra
132 code, extra cpu cycles, and increased dispatch latency because extra
133 processing is needed at DSR level. Interrupt latency should not be
136 >There is one specific problem inherent in the UDC design of which
137 application developers should be aware: the hardware cannot fully
138 implement the USB standard for bulk transfers. A bulk transfer
139 typically consists of some number of full-size 64-byte packets and is
140 terminated by a packet less than the full size. If the amount of data
141 transferred is an exact multiple of 64 bytes then this requires a
142 terminating packet of 0 bytes of data (plus header and checksum). The
143 SA11x0 USB hardware does not allow a 0-byte packet to be transmitted,
144 so the device driver is forced to substitute a 1-byte packet and the
145 host receives more data than expected. Protocol support is needed so
146 that the appropriate host-side device driver can allow buffer space
147 for the extra byte, detect when it gets sent, and discard it.
148 Consequently certain standard USB class protocols cannot be
149 implemented using the SA11x0, and therefore custom host-side device
150 drivers will generally have to be provided, rather than re-using
151 existing ones that understand the standard protocol.</P
163 >Endpoint Data Structures</H2
165 >The SA11x0 USB device driver can provide up to three data structures
166 corresponding to the three endpoints: a
169 >usbs_control_endpoint</SPAN
177 >usbs_rx_endpoint</SPAN
185 >usbs_tx_endpoint</SPAN
193 >cyg/io/usb/usbs_sa11x0.h</TT
195 provides declarations for these.</P
197 >Not all applications will require support for all the endpoints. For
198 example, if the intended use of the UDC only involves peripheral to
199 host transfers then <TT
203 The device driver provides configuration options to control the
204 presence of each endpoint:</P
211 >Endpoint 0 is controlled by
214 >CYGFUN_DEVS_USB_SA11X0_EP0</TT
216 enabled if there are any higher-level packages that require USB
217 hardware or if the global preference
220 >CYGGLO_IO_USB_SLAVE_APPLICATION</TT
222 otherwise it is disabled. Usually this has the desired effect. It may
223 be necessary to override this in special circumstances, for example if
224 the target board uses an external USB chip in preference to the UDC
225 and it is that external chip's device driver that should be used
226 rather than the on-chip UDC. It is not possible to disable endpoint 0
227 and at the same time enable one or both of the other endpoints, since
228 a USB device is only usable if it can process the standard control
233 >Endpoint 1 is controlled by
236 >CYGPKG_DEVS_USB_SA11X0_EP1</TT
238 enabled whenever endpoint 0 is enabled, but it can be disabled
239 manually when not required.</P
243 >Similarly endpoint 2 is controlled by
246 >CYGPKG_DEVS_USB_SA11X0_EP2</TT
247 >. This is also enabled by
248 default whenever endpoint 0 is enabled, but it can be disabled manually.</P
252 >The SA11X0 USB device driver implements the interface specified by the
253 common eCos USB Slave Support package. The documentation for that
254 package should be consulted for further details. There is only one
255 major deviation: when there is a peripheral to host transfer on
256 endpoint 2 which is an exact multiple of the bulk transfer packet size
257 (usually 64 bytes) the device driver has to pad the transfer with one
258 extra byte. This is because of a hardware limitation: the UDC is
259 incapable of transmitting 0-byte packets as required by the USB
260 specification. Higher-level code, including the host-side device
261 driver, needs to be aware of this and adapt accordingly.</P
263 >The device driver assumes a bulk packet size of 64 bytes, so this
264 value should be used in the endpoint descriptors in the enumeration
265 data provided by application code. There is experimental code
267 HREF="devs-usb-sa11x0.html#AEN18808"
270 in which case the packet size will be 16 bytes rather than 64.</P
280 >In addition to the endpoint data structures the SA11X0 USB device
281 driver can also provide devtab entries for each endpoint. This allows
282 higher-level code to use traditional I/O operations such as
293 rather than the USB-specific non-blocking functions like
296 >usbs_start_rx_buffer</TT
297 >. These devtab entries are
298 optional since they are not always required. The relevant
299 configuration options are
302 >CYGVAR_DEVS_USB_SA11X0_EP0_DEVTAB_ENTRY</TT
306 >CYGVAR_DEVS_USB_SA11X0_EP1_DEVTAB_ENTRY</TT
310 >CYGVAR_DEVS_USB_SA11X0_EP2_DEVTAB_ENTRY</TT
312 these devtab entries are provided if the global preference
315 >CYGGLO_USB_SLAVE_PROVIDE_DEVTAB_ENTRIES</TT
317 which is usually the case. Obviously a devtab entry for a given
318 endpoint will only be provided if the underlying endpoint is enabled.
319 For example, there will not be a devtab entry for endpoint 1 if
322 >CYGPKG_DEVS_USB_SA11X0_EP1</TT
325 >The names for the three devtab entries are determined by using a
326 configurable base name and appending <TT
337 determined by the configuration option
340 >CYGDAT_DEVS_USB_SA11X0_DEVTAB_BASENAME</TT
345 >, so the devtab entry for
346 endpoint 1 would default to <TT
350 target hardware involves multiple USB devices then application
351 developers may have to change the base name to prevent a name clash.</P
361 >The SA11X0 UDC provides only limited fifos for bulk transfers on
362 endpoints 1 and 2; smaller than the normal 64-byte bulk packet size.
363 Therefore a typical transfer requires the use of DMA engines. The
364 SA11x0 provides six DMA engines that can be used for this, and the
365 endpoints require one each (assuming both endpoints are enabled). At
366 the time of writing there is no arbitration mechanism to control
367 access to the DMA engines. By default the device driver will use
368 DMA engine 4 for endpoint 1 and DMA engine 5 for endpoint 2, and it
369 assumes that no other code uses these particular engines.</P
371 >The exact DMA engines that will be used are determined by the
372 configuration options
375 >CYGNUM_DEVS_USB_SA11X0_EP1_DMA_CHANNEL</TT
379 >CYGNUM_DEVS_USB_SA11X0_EP2_DMA_CHANNEL</TT
381 options have the booldata flavor, allowing the use of DMA to be
382 disabled completely in addition to controlling which DMA engines are
383 used. If DMA is disabled then the device driver will attempt to
384 work purely using the fifos, and the packet size will be limited to
385 only 16 bytes. This limit should be reflected in the appropriate
386 endpoint descriptors in the enumeration data. The code for driving the
387 endpoints without DMA should be considered experimental. At best it
388 will be suitable only for applications where the amount of data
389 transferred is relatively small, because four times as many interrupts
390 will be raised and performance will suffer accordingly.</P
397 SUMMARY="Footer navigation table"
408 HREF="devs-usb-sa11x0-ref.html"
426 HREF="devs-usb-nec-upd985xx-ref.html"
436 >SA11X0 USB Device Driver</TD
442 HREF="devs-usb-sa11x0-ref.html"
450 >NEC uPD985xx USB Device Driver</TD