1 <!-- Copyright (C) 2001 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 substantively modified versions of this -->
7 <!-- document is prohibited without the explicit permission of the -->
8 <!-- copyright holder. -->
9 <!-- Distribution of the work or derivative of the work in any -->
10 <!-- standard (paper) book form is prohibited unless prior -->
11 <!-- permission is obtained from the copyright holder. -->
15 >NEC uPD985xx USB Device Driver</TITLE
16 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
19 CONTENT="Modular DocBook HTML Stylesheet Version 1.64
30 NAME="DEVS-USB-NEC-UPD985XX"
31 >NEC uPD985xx USB Device Driver</A
40 >NEC uPD985xx USB Support -- Device driver for the on-chip NEC uPD985xx USB device</DIV
47 >NEC uPD985xx USB Hardware</H2
49 >The NEC uPD985xx family of processors is supplied with an on-chip USB
50 slave device, the UDC (USB Device Controller). This supports seven
51 endpoints. Endpoint 0 can only be used for control messages. Endpoints
52 1 and 2 are for isochronous transmits and receives respectively.
53 Endpoints 3 and 4 support bulk transmits and receives. Endpoints 5 and
54 6 normally support interrupt transmits and receives,but endpoint 5 can
55 also be configured to support bulk transmits. At this time only the
56 control endpoint 0, the bulk endpoints 3 and 4, and the interrupt
57 endpoint 5 are supported.</P
65 >Endpoint Data Structures</H2
67 >The uPD985xx USB device driver can provide up to four data structures
68 corresponding to the four supported endpoints: a
71 >usbs_control_endpoint</SPAN
75 >usbs_upd985xx_ep0</TT
79 >usbs_tx_endpoint</SPAN
83 >usbs_upd985xx_ep3</TT
87 >usbs_upd985xx_ep5</TT
91 >usbs_rx_endpoint</SPAN
95 >usbs_upd985xx_ep4</TT
99 >cyg/io/usb/usbs_nec_upd985xx.h</TT
101 provides declarations for these.</P
103 >Not all applications will require support for all the endpoints. For
104 example, if the intended use of the UDC only involves peripheral to
105 host transfers then <TT
107 >usbs_upd985xx_ep4</TT
109 The device driver provides configuration options to control the
110 presence of each endpoint:</P
117 >Endpoint 0 is controlled by
120 >CYGFUN_DEVS_USB_UPD985XX_EP0</TT
122 enabled if there are any higher-level packages that require USB
123 hardware or if the global preference
126 >CYGGLO_IO_USB_SLAVE_APPLICATION</TT
128 otherwise it is disabled. Usually this has the desired effect. It may
129 be necessary to override this in special circumstances, for example if
130 the target board uses an external USB chip in preference to the UDC
131 and it is that external chip's device driver that should be used
132 rather than the on-chip UDC. It is not possible to disable endpoint 0
133 and at the same time enable one or both of the other endpoints, since
134 a USB device is only usable if it can process the standard control
139 >Endpoint 3 is controlled by
142 >CYGPKG_DEVS_USB_UPD985XX_EP3</TT
144 endpoint is disabled: according to NEC erratum U3 there may be
145 problems when attempting bulk transfers of 192 bytes or greater. As an
146 alternative the device driver provides endpoint 5 configured to
147 support bulk transfers. Endpoint 3 can be enabled if the application
148 only requires bulk transfers of less than 192 bytes, or if this
149 erratum is not applicable to the system being developed for other
154 >Similarly endpoint 4 is controlled by
157 >CYGPKG_DEVS_USB_UPD985XX_EP4</TT
158 >. This is enabled by
159 default whenever endpoint 0 is enabled, but it can be disabled
164 >Endpoint 5 is controlled by
167 >CYGPKG_DEVS_USB_UPD985XX_EP5</TT
168 >. This is enabled by
169 default whenever endpoint 0 is enabled, but it can be disabled
170 manually. There is also a configuration option
173 >CYGIMP_DEVS_USB_UPD985XX_EP5_BULK</TT
175 default. This option allows the endpoint to be used for bulk
176 transfers rather than interrupt transfers.</P
180 >The uPD985xx USB device driver implements the interface specified by the
181 common eCos USB Slave Support package. The documentation for that
182 package should be consulted for further details. </P
184 >The device driver assumes a bulk packet size of 64 bytes, so this
185 value should be used in the endpoint descriptors in the enumeration
186 data provided by application code. The device driver also assumes
187 a control packet size of eight bytes, and again this should be
188 reflected in the enumeration data. If endpoint 5 is configured for
189 interrupt rather than bulk transfers then the maximum packet size is
190 limited to 64 bytes by the USB standard.</P
200 >In addition to the endpoint data structures the uPD985xx USB device
201 driver can also provide devtab entries for each endpoint. This allows
202 higher-level code to use traditional I/O operations such as
213 rather than the USB-specific non-blocking functions like
216 >usbs_start_rx_buffer</TT
217 >. These devtab entries are
218 optional since they are not always required. The relevant
219 configuration options are
222 >CYGVAR_DEVS_USB_UPD985XX_EP0_DEVTAB_ENTRY</TT
226 >CYGVAR_DEVS_USB_UPD985XX_EP3_DEVTAB_ENTRY</TT
230 >CYGVAR_DEVS_USB_UPD985XX_EP4_DEVTAB_ENTRY</TT
234 >CYGVAR_DEVS_USB_UPD985XX_EP5_DEVTAB_ENTRY</TT
236 default these devtab entries are provided if the global preference
239 >CYGGLO_USB_SLAVE_PROVIDE_DEVTAB_ENTRIES</TT
241 which is usually the case. Obviously a devtab entry for a given
242 endpoint will only be provided if the underlying endpoint is enabled.
243 For example, there will not be a devtab entry for endpoint 4 if
246 >CYGPKG_DEVS_USB_UPD985XX_EP4</TT
249 >The names for the devtab entries are determined by using a
250 configurable base name and appending <TT
264 The base name is determined by the configuration option
267 >CYGDAT_DEVS_USB_UPD985XX_DEVTAB_BASENAME</TT
272 >, so the devtab entry for
273 endpoint 4 would default to <TT
277 target hardware involves multiple USB devices then application
278 developers may have to change the base name to prevent a name clash
279 with other USB device drivers.</P
289 >The current device driver imposes a restriction on certain bulk
290 receives on endpoint 4. If the protocol being used involves
291 variable-length transfers, in other words if the host is allowed to
292 send less data than a maximum-sized transfer, then the buffer passed
293 to the device driver for receives must be aligned to a 16-byte
294 cacheline boundary and it must be a multiple of this 16-byte cacheline
295 size. This restriction does not apply if the protocol only involves
296 fixed-size transfers.</P
304 >Optional Hardware Workarounds</H2
306 >The NEC errata list a number of other problems that affect the
307 USB device driver. The device driver contains workarounds for these,
308 which are enabled by default but can be disabled if the application
309 developer knows that the relevant errata are not relevant to the
310 system being developed.</P
312 >Erratum S1 lists a possible problem if the device driver attempts
313 multiple writes to the USB hardware. This is circumvented by a
314 dummy read operation after every write. If this workaround is not
315 required then the configuration option
318 >CYGIMP_DEVS_USB_UPD985XX_IBUS_WRITE_LIMIT</TT
319 > can be disabled.</P
321 >Errata U3 and U4 describe various problems related to concurrent
322 transmissions on different endpoints. By default the device driver
323 works around this by serializing all transmit operations. For example
324 if the device driver needs to send a response to a control message on
325 endpoint 0 while there is an ongoing bulk transfer on endpoint 5, the
326 response is delayed until the bulk transfer has completed. Under
327 typical operating conditions this does not cause any problems:
328 endpoint 0 traffic usually happens only during initialization, when
329 the target is connected to the host, while endpoint 5 traffic only
330 happens after initialization. However if transmit serialization is
331 inappropriate for the system being developed then it can be disabled
332 using the configuration option
335 >CYGIMP_DEVS_USB_UPD985XX_SERIALIZE_TRANSMITS</TT
344 >Platform Dependencies</H2
346 >On some platforms it is necessary for the low-level USB device driver
347 to perform some additional operations during start-up. For example it
348 may be necessary to manipulate one of the processor's GPIO lines
349 before the host can detect a new USB peripheral and attempt to
350 communicate with it. This avoids problems if the target involves a
351 significant amount of work prior to device driver initialization, for
352 example a power-on self-test sequence. If the USB host attempted to
353 contact the target before the USB device driver had been initialized,
354 it would fail to get the expected responses and conclude that the
355 target was not a functional USB peripheral.</P
357 >Platform-specific initialization code can be provided via a macro
360 >UPD985XX_USB_PLATFORM_INIT</TT
361 >. Typically this macro
362 would be defined in the platform HAL's header file
365 >cyg/hal/plf_io.h</TT
367 current platform defines such a macro, the USB device driver will
368 invoke it during the endpoint 0 start-up operation.</P