Systems and methods for batched USB data transfers
A USB host controller for embedded systems employing batched data transfer. The system batches up to 16 individual transactions in a single batch to reduce the number and frequency of interrupts to the microprocessor and to increase USB data throughput.
This application is a continuation of U.S. patent application Ser. No. 09/754,828 filed Jan. 2, 2001 and titled “SYSTEMS AND METHODS FOR BATCHED USB DATA TRANSFERS,” which is incorporated herein by reference in its entirety. This application also claims the benefit of U.S. Provisional Application No. 60/174,395 entitled USB HOST CONTROLLER AND HOST DRIVER INTERFACE filed Jan. 3, 2000.
BACKGROUND OF THE INVENTION1. Field of the Invention
The present invention relates to the field of electronic devices and the transfer of data there between and, in particular, to providing a host controller and host controller driver interface to microprocessor based embedded systems for interconnecting devices via a serial bus. More specifically, the present invention relates to a Universal Serial Bus (USB) host controller and host controller driver interface for embedded systems that employ batched data transfer.
2. Description of the Related Art
Electronic devices are often electrically connected to one or more other electronic devices. For example, microprocessor based systems, such as personal computers, are often connected to one or more peripheral devices such as printers, scanners, graphics tablets, digital cameras and the like. The connection to peripheral devices can take place via a number of known serial or parallel interfaces.
The Universal Serial Bus (USB) is one standardized serial interface that has been developed to offer flexible, high, moderate and low-speed interconnections between a host device and external, peripheral devices. USB was developed to accomplish three main goals: connection of a microprocessor based system to a telephone system, plug-and-play of peripheral devices in a hot swappable manner, and ready expansion of a microprocessor based system's peripheral connectivity.
USB employs a four-wire connector. Two wires supply power (up to 500 mA at 5 vdc) and the other two wires form a twisted-pair, differential data line. USB employs a master-slave architecture with a tiered-star topology. One or more hubs can be connected to a host or root tier to expand the capacity of a USB system. Hubs can also be connected to other hubs to further expand the system. A single USB host can support up to 127 separate devices.
USB currently supports data transfer at a high speed of 480 Mbps, a full speed of 12 Mbps, and a low speed of 1.5 Mbps data rate. There are four types of USB transfers: isochronous, bulk, interrupt and control. Isochronous transfer is not error checked as the need for uninterrupted data transfer at a given data rate overrides the need for error-free transmission. The other three types of transfer contains error-checking mechanisms, data sequence toggle sequences and retry sequences to guarantee error-free data transfer.
A USB system has a single USB host.
However, there is a need for a USB Host Controller for embedded systems and microprocessors which do not have a bus interface with bus mastering capability such as a PCI bus. Such a USB Host Controller is referred to as an embedded USB Host Controller which can be interfaced via a standard processor bus interface to any microprocessor, microcontroller, digital signal processor, FPGA processor or any other processor (hereafter referred to as microprocessor). In the prior art, these embedded Host Controllers suffer the shortcoming of low data transfer rate and frequent interrupts to the microprocessor because the microprocessor is interrupted every transaction. Without the bus mastering capability, prior art embedded USB host controllers interrupt the microprocessor for each transaction to report the status of the transaction to the microprocessor, and for the microprocessor to process the just finished transaction, read data from and/or write data into the USB host controller, and prepare and dispatch the next transaction.
Moreover, each interrupt of the microprocessor involves an interrupt latency period. The latency period is the time during which the microprocessor stores the data and status conditions related to task at hand, before it can attends to the request of the USB host. An example timing diagram for the interaction of the microprocessor and a prior art embedded USB host controller showing the interrupt latency period is illustrated in
The interrupt latency period and the interrupt recovery period waste the microprocessor's time. The USB bus is idle during both the interrupt latency period and the period for the microprocessor to process the current transaction and prepare for the next transaction. That is, there is no data on the USB bus, which results in very low data throughput. The process also slows the microprocessor system as the microprocessor must cease operating on whatever task before the interrupt, attends to the USB host controller, and then recover its working environment to pick up again where it was before.
More specifically, the microprocessor must typically take time to store the registers and context it was working on when it received the interrupt and subsequently retrieve the registers and context and resume processing it upon completion of the task requested by the USB interrupt. The time to cease operation, store the registers and context, and then later retrieve the registers and context and resume processing contributes greatly to the increased inefficiency of the microprocessor during USB interrupts. This can significantly reduce the throughput of the USB connection, as well as the performance of the microprocessor system, below optimum.
OHCI and UHCI host controllers overcomes this problem using reverse bus mastering, such as that provided by a known PCI bus, and equip the host controller with the capability to process sequentially one-by-one a list of transactions scheduled in the microprocessor's system memory. In this method, upon each transaction, the USB host controller uses the reverse bus master mechanism to access the system memory, processes the transaction, exchanges data with the system memory, and start the next transaction, all without interrupting the microprocessor. While this method does significantly improve the throughput of the USB, it is not applicable to many embedded systems where there is no reverse bus mastering mechanism either due to cost reasons, architectural or software considerations.
From the foregoing, it will be appreciated that there is a need for a system that permits more efficient USB transfers in an embedded system. To this end, there is a need for an improved system that reduces the interrupts to microprocessor and improves the data throughput on USB for a host system having an embedded USB architecture.
SUMMARY OF THE INVENTIONThe aforementioned needs are satisfied by the present invention which in one aspect comprises a USB host controller system for interfacing between at least one USB device and a host processor. The system comprises a host controller that transfers USB transactions between at least one USB device and a host processor. The system further includes at least one memory associated with the host controller, wherein the host controller stores the information indicative of a plurality of USB transactions in the memory and executes a plurality of stored USB transactions in a single batch so as to reduce the overall resource demands on the host processor to execute the USB transactions and to increase data throughput on the USB.
In another aspect, the invention comprises a method of interfacing a plurality of USB device with a host processor. The method comprises assembling a first batch of USB transactions in a memory, sequentially executing each of the USB transactions of the first batch in the memory and sending an interrupt signal to a host processor indicating that the first batch of transactions has been completed so that the host processor is interrupted less thereby reducing the overall resource demand on the host processor during execution of the first batch.
In yet another aspect, the invention comprises a USB host controller that is adapted to receive and assemble information indicative of a plurality of USB transactions from a host processor wherein the USB host controller executes an assembled batch of a plurality of USB transactions upon meeting a certain condition and wherein the host processor is informed of the availability of the status of the plurality of transactions upon completion of the batch to thereby reduce the overall resource demand on the host processor during execution of the batch of USB transactions.
In yet another aspect, the invention comprises a USB system that comprises a host microprocessor, at least one memory associated with the host microprocessor and an embedded microprocessor bus whose bus master for memory access is the host microprocessor. In this aspects the USB system further comprises an embedded USB host controller that sends interrupt signals to the host microprocessor such that the host microprocessor in response to the interrupts manipulates data in the at least one memory such that the USB host stack associated with the USB system that is designed to be used with a bus that is controllable by the USB host controller can be mused with the embedded USB host controller.
BRIEF DESCRIPTION OF THE DRAWINGS
Reference will now be made to the drawings wherein like numerals refer to like parts throughout. As discussed above,
As will be described in greater detail below, the host controller system of the preferred embodiment, is designed so as to transfer transactions between a host system and peripheral devices in a batched format. In this way, the throughput of the system can be improved and the demands on the host microprocessor can be reduced. A batch is defined as a plurality of USB transactions executed one after another which is started after the host microprocessor sends a command or a signal to the host controller, or which is started by the microprocessor writing into the host controller information indicative of a certain number of USB transactions, or which is started by one or more internal signals in the host controller, or which is started by the microprocessor writing into the host controller certain information to a certain address. Alternatively, a batch is a plurality of USB transactions carried out one after another without requiring further intervention from the host processor, or executed after a certain condition is met. In any case, the status of the batch can be reported by the host controller with a single interrupt to the microprocessor or can be accessed by the host microprocessor at its own initiative as a group after the plurality of USB transactions are executed.
Referring now to
The host controller logic unit 22 receives data transfer requests in the format of USB transactions from the host microprocessor 24. These data transfer requests can either comprise data that is to be transferred from USB device(s) 26 to the host system for storage in the system memory 32 or requests for data from the system memory 32 of the host system to the USB device(s) 26. The host controller logic unit 22 is connected to the host microprocessor 24 via the host processor bus 31 that allows for the transfer of data between the host microprocessor 24 and the host controller system 100. In this embodiment, the host processor bus 31 is an embedded data bus that is slaved to the host microprocessor 24 and is not configurable so as to be controlled by the host controller system 100.
In the prior art, once a USB transaction between the host system and a USB device is executed, the host controller logic unit 22 sends an interrupt signal to the host microprocessor 24 to induce the host microprocessor 24 to review the transaction and prepare the next transaction in the manner that will be described in greater detail herein below. However, as discussed above, sending the interrupt results in wasted time on the host microprocessor in the form of interrupt latency and interrupt recovery as is illustrated in
The host microprocessor 24 is not engaged in processing either the USB initiated task or the original host task in the interrupt latency period as identified in
As is also illustrated in
To address these problems, the USB system of the illustrated embodiment includes a batch memory 30 in the host controller system 100 as is illustrated in
For a transaction transmitting data to a designated USB device 26 (called an OUT transaction or SETUP transaction in USB specification), the microprocessor will write the data in a segment of the batch memory 30 designated for the transaction. For a transaction receiving data from a designated device 26 (called an IN transaction in USB specification), the microprocessor will allocate a segment of the batch memory 30 as the buffer for the transaction. In this embodiment, each batch is comprised of up to 16 transactions. In this embodiment, the host controller system 100 stores each of the transaction descriptors (XDs) in a designated section of the batch memory 30 and the corresponding data or buffer in a corresponding designated section of the batch memory 30 in the manner that will be described in greater detail in reference to
Hence, the host controller system 100 and the host microprocessor 24 assemble a plurality of transactions into a batch that is stored in the batch memory 30 for subsequent transfer between the host controller 100 and the USB devices. Once the batch has been fully assembled, the microprocessor 24 induces the dispatch of the assembled batch in state 48 with a single command or signal to the host controller system 100. This results in the host controller system 100 reading each of the transaction descriptors (XDs) and executing the corresponding transaction, transmitting the data from the batch memory to the designated USB device 26, or receiving data from designated USB device and storing the received data in the buffer allocated to the transaction in the batch memory 30. The host controller system 100 thus acts on each of the transactions within the batch in state 49 until it decides in decision state 50 that it has completed the batch.
Once the host controller system 100 has completed the batch it sends a single interrupt signal to the host microprocessor 24 in state 52 indicating that the batch of transactions have been completed. The host microprocessor 24 then reviews the results of the batch of transactions in state 54 to ascertain the status of the current batch of transactions. If there are IN transactions, the microprocessor 24 reads the data from the designated buffers in the batch memory 30 and loads the data into the system memory 32.
In some circumstances, one or more of the transactions would not have been successfully transacted which may result in the microprocessor 24 determining that the transaction must be resent as part of the next batch. The microprocessor 24 then determines in decision state 56 whether it has more transactions that must be transferred between the host system and the USB devices. This determination is made based upon the information determined in state 54 as well as from client software or USB device drivers running on the microprocessor. If no additional transactions are needed to be sent, the microprocessor then proceeds to an end state 58 wherein it can be dedicated to other tasks. Alternatively, if the host microprocessor 24 determines in state 56 that additional transactions are needed, it then prepare the next batch in state 60 and then proceeds to transmit the transaction descriptors XDs and associated data in state 46.
In another embodiment, part of the preparation of the next batch in state 60 can occur concurrently with the execution of the batch of transactions in states 49 and 50. This way, the next batch can be dispatched sooner, preferably right after the microprocessor reviews the status of the current batch.
In this way, the microprocessor 24 can induce the host controller system 100 to process a batch of USB transactions in the batch memory 30 and evaluate the results in a single step before returning to the host task. This results in less demand on the host system resources which improves the performance of the host system. The manner in which the host controller system 100 acts on the batch of USB transactions is described in greater detail in
Specifically, once the host controller system 100 has received the batch of transaction descriptors XD and the associated data from the microprocessor 24 for OUT or SETUP transactions, or buffer allocation for IN transactions, the host controller system 100 then sequentially processes the USB transactions. More particularly, from a start state 61, the host controller system 100 initializes in state 62 a variable i, indicative of the particular USB transaction being processed, to zero. The host controller system 100 then determines in decision state 64 whether the particular USB transaction having the transaction descriptor XD(i) has been selected by the microprocessor 24 as to be executed with the particular batch. As will be described in greater detail below, the transaction descriptors are stored in a list in the batch memory and the microprocessor can designate some or all of the transaction descriptors to be executed as part of a batch or processed in a different manner. Particular identifiers that are described in more detail below are then read by the host controller system 100 to determine whether to execute a particular USB transaction.
If the particular USB transaction XD(i) is not to be executed as part of the batch, the host controller system 100 then increments the variable i in state 66 and then determines in decision state 68 whether all of the transaction descriptors in the batch received by the host controller in state 46 (
If all of the USB transactions in the batch has been completed the host controller system 100 sends a batch complete interrupt in state 86 to the host microprocessor 24. If the USB transactions in the batch have not been completed, the host controller then returns to decision state 64 to determine whether the next sequential transaction descriptor XD(i) is selected for the batch being processed.
If a particular transaction is selected to be executed in the batch, the host controller then determines in decision state 70 if there is enough time to dispatch the USB transaction XD(i) in the current USB frame. As is understood, USB bus time are partitioned into frames that are 1 mSec. in duration and the host controller system 100 must be able to complete a transaction before the end of frame. Otherwise, USB transaction traffic may collide with the Start of Frame (SOF) signal on the USB. If there is not enough time, the host controller system 100 then waits, in state 72, for the next frame. Alternatively, the host controller may mark the current transaction as unexecuted and move on to the next transaction selected for inclusion in the current batch. A transaction marked unexecuted in the current frame can be executed at the beginning of the next frame or can be included in the next batch.
Subsequently, the USB transaction identified by the transaction descriptor XD(i) is then dispatched in state 74 by the host controller system 100. The host controller system 100 monitors whether the USB transaction was completed and updates, in state 76, a record in the transaction descriptor for the USB transaction indicative of the status of the executed transaction. The updated record can then be evaluated by the microprocessor 24 in state 54 (
The host controller system 100 then determines in decision state 80 whether there is an accelerated interrupt condition for the USB transaction XD(i) that has been met. Such an accelerated interrupt condition is set by the microprocessor for a particular USB transaction for a number of different reasons. One example of a situation that could warrant an immediate interrupt signal being sent to the microprocessor 24 is if a particular USB transaction, that is needed for subsequent transactions, was not successfully completed in state 74. In this circumstance, it may be necessary to halt dispatching of the batch in decision state 84 and proceed to determine whether to process the next batch from the microprocessor 24 in decision state 88.
If there is no accelerated interrupt condition that has been set for XD(i) or one is set but not met, the host controller then increments the variable i in state 66 and proceeds to the next transaction in the batch in state 64. The process comprising the steps 64 through 84 is then continued for each of the transactions XD(i) until the host controller system 100 determines the batch has been completed in state 68. Once the batch has been completed, the host controller system 100 then sends the batch complete interrupt signal to the microprocessor 24 and then determines if another batch has been sent by the microprocessor in decision state 88.
As will be described in greater detail below, the batch memory 30 can be used as a double buffer such that when a batch is being executed by the host controller system 100, the microprocessor 24 can be simultaneously sending additional USB transactions to a different part of the batch memory to assemble another batch for subsequent processing and dispatch by the host controller system 100. In this way, the throughput of the USB system can be enhanced as the idle period of the USB host controller system 100 is decreased.
The improved throughput of the USB host controller system 100 and the decreased idle time on the USB is illustrated in greater detail in the timing chart of
The batch memory 30 is preferably organized so as to be able to receive USB transactions from the host microprocessor 24 for one batch while the host controller system 100 is acting on another batch. Similarly, while the host controller system 100 is executing the next batch of transactions, the microprocessor 24 is reading data for the current batch and is preparing the next batch of transactions in period 93. Thus, the idle time that the USB system experiences is limited to the interrupt latency period and the period where the microprocessor 24 is evaluating the previously executed batch. Consequently, the throughput of the system is significantly enhanced.
The foregoing description in connection with
More specifically,
The host controller system 100 of this embodiment involves a microprocessor interface 104. The microprocessor interface 104 provides the functionality of the data bus 31 of
The host controller system 100 also comprises a control memory (CM) 106 which provides some of the functionality of the batch memory 30 of
The host controller system 100 also comprises a host controller logic unit 114. The host controller logic unit 114 provides the functionality of the host logic unit 22 in
In this implementation, each batch may comprise up to 16 USB transactions. The host controller system 100 allows spill over of USB transactions to the next frame in the manner described above in connection with
The host controller system 100 also comprises data memory (DM) 116 that also provides the functionality of the batch memory 30 of
In one embodiment of this invention, there are four interrupt modes which provide a developer the flexibility to balance high data rate and demand on microprocessor 102 resources.
-
- In the Batch Complete (BC) interrupt mode, the host microprocessor 24 is only interrupted once after a batch of USB transactions are completed in the manner described above in connection with
FIGS. 3A and 3B . In one batch, the microprocessor 24 can schedule a plurality of transactions by writing XDs 110 in the CM 106, and data in the DM if needed. A batch can be scheduled within a frame to reach the maximum USB 1.1 full speed data rate. For example, five transactions can be scheduled for a total of 1,280 bytes in one ms: one isochronous transaction of 1023 bytes, and four bulk or interrupt transactions of 64 bytes each. - In the Transaction Error/NAK (XTE) interrupt mode, the batch is stopped and an interrupt is generated upon the error condition of a transaction, or NAK from a device.
- In the Transaction Successful (XTS) interrupt mode, an interrupt is generated immediately upon the successful completion of a batch transaction.
- In the Transaction Done (XTD) interrupt mode, the batch is stopped and an interrupt is generated after a USB transaction is dispatched regardless of its outcome.
- In the Batch Complete (BC) interrupt mode, the host microprocessor 24 is only interrupted once after a batch of USB transactions are completed in the manner described above in connection with
By choosing among the BC, XTE, XTS and XTD modes, a developer has the flexibility to stop the batch based on the outcome of any of the plural XDs 110.
The memory map of one embodiment of this host controller system 100 is shown in
The read/write access to the bits of each Register by both the host controller driver (HCD) software and the host controller system 100 are specified as follows.
UhcControl Register
The UhcControl Register defines the operating modes for the host controller system 100 and is used by the host controller driver software to execute commands such as sending USB reset, suspending the host controller system 100, and to move the host controller system 100 from one state to another. Bits [4..1] define the Host Controller Function States (HCFS).
This register is used by the HCD to send commands to the host controller system 100 and by the host controller system 100 to report its states to the HCD. The HCD writes to a bit of this register to change the HCFS or dispatch a batch of transactions. The HCFS may be changed by the host controller system 100 hardware only when in the USBSUSPEND state. The host controller system 100 moves from the USBSUSPEND state to the USBRESUME state after detecting the resume signaling from a downstream port 122. The HCD reads this register to find out the state of the host controller system 100. The HCFS bits are effective only when the power saving mode is off (PowerSavingOff=1). The user should read this register if confirmation of the state of the host controller system 100 is desired after a write to the HCFS bits.
The HCD may only write 1 to one bit of this register at a time. Writing 1's to more than one bits will be ignored. Writing 0's to this register has no effect. Only valid transitions as shown in
Register Address:
-
- Low byte: 000h
High byte: 001h
UhcTransactionSelect Register
Register Address:
-
- Low byte: 002h
- High byte: 003h
The HCD sets the bit to select the transaction for dispatch. When the ith bit is set and UhcControl[BatchDispatch]=1, the host controller system 100 dispatches the transaction associated with the ith XD 110 located at 400h+i×010h in ascending order from i=0 to 15d.
UhcBatchStatus Register
Register Address:
-
- Low byte: 004h
- High byte: 005h
When the UhcControl[BatchDispatch] bit is set, the host controller system 100 clears all bits of the UhcBatchStatus to zero before dispatching any transaction. UhcBatchStatus[i] is set when the transaction associated with the ith XD 110 is dispatched. After UhcControl[BatchDispatch] transitions from 1 to 0, the status of the ith XD 110 is determined by UhcTransactionSelect[i] and UhcBatchStatus[i] as follows:
UhcInterruptStatus Register
Register Address: 006h
This register provides status on various host controller system 100 level events that cause hardware interrupts. When an event occurs, the host controller system 100 sets the corresponding bit in this register. When a bit becomes set, a hardware interrupt is generated if the interrupt is enabled in the UhcInterruptEnable register and the MasterInterruptEnable bit is set. The host controller system 100 does not clear the bits in this register except bit 1, BatchIncomplete. The HCD clears the bits in this register by writing ‘1’ to bit position's to be cleared. The HCD may not set any of these bits.
UhcInterruptEnable Register
Register Address: 007h
This register enables and disables reporting of the corresponding interrupt to the HCD. When a bit is set and the corresponding interrupt is active, an interrupt is generated to the host. Interrupt sources that are disabled in this register still appear in the UhcInterruptStatus Register to allow the software to poll for events.
Each enable bit in the UhcInterruptEnable register corresponds to an associated interrupt bit in the UhcInterruptStatus Register. The UhcInterruptEnable register is used to control which events generate a hardware interrupt. When a bit is set in the UhcInterruptStatus register AND the corresponding bit in the UhcInterruptEnable register is set AND the MasterInterruptEnable bit is set, then a hardware interrupt is requested on the host bus.
UhcFmInterval Register
Register Address:
-
- Low byte: 008h
- High byte: 009h
When reading this register, the HCD must read the low byte (008h) first.
Bits [13:0] of the UhcFmInterval Register stores the length of a USB in 12-MHz bit times. The UhcFmInterval register and the UhcFmRemaining register er define frame boundaries. This register can be used to adjust out any offset from the source that generates the clock that drives the SOF counter. It can also be used to maintain real time synchronization with the rest of the system so that all devices have the same sense of real time.
UhcFmRemaining Register
Register Address:
-
- Low byte: 00Ah
- High byte: 00Bh
This register is a 14-bit frame counter. When reading this register, the HCD must read the low byte (00Ah) first.
UhcFmNumber Register
Register Address:
-
- Low byte: 00Ch
- High byte: 00Dh
This Register is an 11 bit counter. When reading this Register, the HCD must read the low byte (00Ch) first.
Transaction Descriptors 110 in the Control Memory 106
The 256 bytes of the memory space starting from 400h are reserved as Control Memory (CM) 106. The CM 106 holds 16 Transaction Descriptors (XD) 110 denoted as XD1, XD2, . . . , XDF. Each XD 110 comprises the following fields:
-
- XDControl
- XDStatus
- XDDevAddress
- XDEndpoint
- XDBufAddress
- XDBufLength
- XDXferCount
At run time, the selected XDs 110 are loaded one at a time for batch dispatching. When BatchDispatch=1, the HCD should not access any of the XDs 110 selected for dispatch.
XDControl
Memory Address: (400h+i×10h) where i=0,1,2, . . . 15d.
The HCD defines the type and parameters of a transaction using this field.
XDStatus
Memory Address: (400h+i×10h+1) where i=0,1,2, . . . 15d.
The host controller system 100 stores the status of the transaction in this is completed. After a batch is completed or stopped, the HCD may read this byte status of the corresponding transaction. When the BatchDispatch bit is 1, the this byte is meaningless. There are a total of a 16 XDStatus fields in this embodiment, referred to as XDStatus0, XDStatus1, . . . , XDStatusF.
XDDevAddress
Memory Address: (400h+i×10h+2) where i=0,1,2, . . . 15d.
XDEndpoint
Memory Address: (400h+i×10h+3) where i=0,1,2, . . . 15d.
XDBufAddress
Memory Address: (400h+i×10h+4) and (400h+i×10h+5) where i=0,1,2, . . . 15d.
XDBufLength
Memory Address: (400h+i×10h+6) and (400h+i×10h+7) where i=0,1,2, . . . 15d.
XDXferCount
Memory Address: (400h+i×10h+8h) and (400h+i×10h+9h) where i=0,1,2, . . . 15d.
The host controller system 100 writes this field after the completion of the corresponding transaction.
The host controller system 100 also comprises a root hub 120 (
USB Ports
The root hub 120 of this embodiment has four downstream ports 122. The four downstream ports of the root hub 120 support both full speed as well as low speed USB devices 112. 15 KΩ pull-down resistors are required at the inputs of the downstream ports 122. Full speed signal requirements demand controlled rise/fall times and impedance matching of the USB ports. To meet these requirements, 22 Ω resistors must be inserted in series between the USB data pins and the USB connectors.
USB devices 112 attached to the downstream ports 122 are determined to be either full speed or low speed depending which data line (DP or DM) is pulled high. If a downstream port 122 is enumerated as low speed, its output buffers operate at a slew rate of 75-300 ns, and the root hub 120 will not propagate any traffic to that port 122 unless it is prefaced with a preamble PID. Low speed data following the preamble PID is propagated to both low and full speed USB devices 112. The root hub 120 will enable low speed drivers within four full-speed bit times of the last bit of a preamble PID, and will disable them at the end of an EOP.
All the downstream ports 122 independently drive and monitor their DP and DM pins so that they are able to detect and generate the ‘J’, ‘K’, and SE0 bus signaling states. Each port 122 has single-ended and differential receivers on its DP and DM lines.
Port Power Management
Overcurrent sensing is on a per port 122 basis and is achieved through the OVCx pins. Whenever the voltage at OVCx is asserted, the root hub 120 treats it as an overcurrent condition. This could be caused by an overload, or even a short circuit, and causes the root hub 120 to set the PORT_OVER_CURRENT status bit and its C_PORT_OVER_CURRENT status change bit. At the same time, power to the offending port 122 is shut off.
An external device is needed to perform the actual switching of the port 122 power under control of the root hub 120. The signals to control the external switches are the PWRX pins that are open drain signals and require external pull-up resistors of 100 KΩ. Any type of suitable switch or device is acceptable. However, it should have a low voltage drop across it even when the port 122 absorbs full power. In its simplest form this switch can be a P-channel MOSFET. One advantage of using a MOSFET switch is its very low voltage drop and low cost.
Each one of the ports 122 has its own power control pin which is asserted only when a SetPortFeature[PORT-POWER] request is received from the HCD. PWRX is de-asserted under the following conditions:
-
- 1. Power up
- 2. Reset and initialization
- 3. Overcurrent condition
- 4. Requested by the HCD through a ClearPortFeature[PORT_POWER].
Hub Controller
The root hub 120 comprises a hub controller 124. The hub controller 124 provides the mechanism for the HCD to enumerate the root hub 120 and for the root hub 120 to provide the HCD with its configuration information. The hub controller 124 also provides a mechanism for the HCD to monitor and control the downstream ports 122. Power is applied, on a per port 122 basis, by the hub controller 124 upon receiving a command, SetPortFeature[PORT_POWER], from the HCD. The root hub 120 must be configured first by the HCD before the hub controller 124 can apply power to external devices.
The hub controller 124 contains two endpoints, Endpoint0 and Endpoint1 and maintains a status register, Controller Status Register, which reflects the root hub 120 current settings. At power up, all bits in this register will be set to 0's.
Endpoint 0
Endpoint 0 is the root hub 120 default endpoint used for enumeration of the root hub 120 and exchange of configuration information and requests between the HCD and the root hub 120. Endpoint 0 supports control transfers. Standard USB Device Requests and class-specific Hub Requests are supported through Endpoint 0. There is no endpoint descriptor for Endpoint0.
Endpoint 1
Endpoint1, an interrupt endpoint, is used by the hub controller 124 to send status change information to the HCD. The hub controller 124 samples the changes at the end of every frame at time marker EOF2 in preparation for a potential data transfer in the subsequent frame. The sampled information is stored in a byte wide register, the Status Change Register, using a bitmap scheme.
Each bit in the Status Change Register corresponds to one port 122 as indicated in the following table.
An IN Token packet from the Host to Endpoint 1 indicates a request for port change status. If the root hub 120 has not detected any change on its ports 122, or any changes in itself, then all bits in this register will be 0 and the hub controller 124 will return a NAK to requests on Endpoint1. If any of bits 0-4 is 1, the hub controller 124 will transfer the whole byte. The hub controller 124 will continue to report a status change when polled until that particular change has been removed by a ClearPortFeature request from the HCD. No status change will be reported by Endpoint 1 until the root hub 120 has been enumerated and configured by the HCD via Endpoint 0.
The host controller system 100 also comprises a phase locked loop (PLL) 126. The PLL 126 generates from a single oscillator 6 MHz, 12 MHz, and 48 MHz clocking signals for the host controller system 100. The PLL 126 generates minimal electro-magnetic interference and in this embodiment is integrated on the same chip as the host controller system 100.
The host controller system 100 also comprises a host serial interface engine (SIE) 130. The SIE 130 interconnects the host controller logic unit 114 and the root hub 120. The SIE 130 buffers USB data bits and maintains state of data toggle bits. The SIE 130 receives a 48 MHz clocking signal from the PLL 126 to synchronize clocks.
Host Controller States Valid states and state transitions of the host controller system 100 are shown in
USBOPERATIONAL
When in the USBOPERATIONAL state, the host controller system 100 will generate SOF and enable dispatch of selected XDs 110. The USBOPERATIONAL state may be entered from the USBRESUME or USBRESET states. It may be exited to the USBRESET or USBSUSPEND or POWERSAVING states. The host controller system 100 enters USBOPERATIONAL from USBRESUME automatically after satisfying the USB Resume timing (20 ms).
USBRESET
The host controller system 100 enters this state upon power up and hardware reset, and from USBOPERATIONAL and USBSUSPEND immediately upon USBRESET write. When in the USBRESET state, all downstream ports 122 of the root hub 120 in host controller system 100 will be in the SE0 state, resetting all downstream devices until the root hub 120 is configured following a USBOPERATIONAL write by the HCD. The HCD must ensure that the host controller system 100 remain in USBRESET for a minimum 50 ms (per USB Specification 1.1) once it enters this state.
USBSUSPEND
USBSUSPEND is entered following a software reset or from the USBOPERATIONAL state on a USBSUSPEND write by HCD. When the host controller system 100 is in USBOPERATIONAL, if there is a batch in progress, it enters USBSUSPEND after batch is finished. When the host controller system 100 is in USBSUSPEND, XD dispatching and SOF token generation are disabled. While in USBSUSPEND, upon detecting a Remote Wakeup from a downstream USB device 112, the host controller system 100 will send the USB Resume signal downstream for 20 ms. If the HCD writes a 1 to USBRESET while the host controller system 100 is in USBRESUME, the USBRESET write will be ignored.
Normally, the HCD must ensure that the host controller system 100 stays in this state for at least 5 ms and then exits this state to either the USBRESUME or the USBRESET state. One exception is when USBSUSPEND is entered due to a soft reset and the previous state was USBOPERATIONAL. In that case, if the host controller system 100 remains in the USBSUSPEND state for less than 1 ms, it may exit directly to USBOPERATIONAL.
While in USBSUSPEND, the host controller system 100 may force a transition to the USBRESUME state due to a remote wakeup condition. This transition may conflict with the HCD initiating a transition to the USBRESET state. If this situation occurs, the UHC will transition to USBRESET state.
USBRESUME
Upon a USBRESUME write, the host controller system 100 sends USB Resume signal downstream for 20 ms. While the host controller system 100 is in the USBRESUME state, writes to the UhcControl register by the HCD is ignored. XD dispatching and SOF Token generation are disabled while in USBRESUME. USBRESUME is only entered from USBSUSPEND. The transition to USBRESUME can be initiated by a USBRESUME write to the UhcControl register, or by a Remote Wakeup signal from downstream.
Powersaving
Upon a POWERSAVING write, the host controller system 100 enters into POWERSAVING state. In POWERSAVING, the host controller system 100 stops its clock. Thus, the host controller system 100 can not be awakened by a remote wakeup event when it is in POWERSAVING state. The only way to exit the POWERSAVING state is for the microprocessor to assert the /RESET pin of the host controller system 100 (>200 ns), upon which the host controller system 100 enters the USBRESET state.
Host controller Driver Interface
The host controller system 100 does not have a bus mastering ability as in a PCI bus in the Universal Host Controller Interface (UHCI) or the Open Host Controller Interface (OHCI). However, the USB host stack (i.e., USB Driver and Host Controller Driver) in many operating systems is designed to operate with a host controller system that does have bus mastering capabilities. For example, using UHCI or OHCI interfaces, data can be moved between the system memories in response to signals from the host controller as the system bus can be slaved to the host controller. As discussed above, however, with embedded systems, the system bus is only under the control of the host microprocessor. Hence, such host stack are often not able to be used with such embedded USB systems.
To address this problem, the present invention uses an interrupt-driven USB Engine 168 in conjunction with the host controller system 100 described above. The host controller system 1000 is programmed so as to send interrupts to host microprocessor so that the host microprocessor can use an interrupt handler to transfer data between the system memory and the host controller system 100 in response to interrupt signal generated by the host controller system 100. In this way, data transfer between the host controller system 100 and the system memory occurs without the intervention of the higher-layer of the HCD, the USB driver and the client software as if the host controller system 100 has bus mastering. USB host stacks designed for OHCI or UHCI host controllers with bus mastering can then be used with embedded USB host controller systems that do not have r bus mastering capability.
More specifically, in one embodiment shown in
In OHCI, there is a segment in shared main memory, called Host Controller Communications Area (HCCA), established by the HCD and is used for communication between the HCD and the host controller system 100. There are two communication channels between the host controller system 100 and the HCD. The first channel uses the registers located in the host controller system 100. It may also use a segment of the microprocessor 102 memory to control the functions of the host controller system 100. The USB Engine 168 shown in
In UHCI, the UHCI data structures include a Frame List, Isochronous Transfer Descriptors, Queue Heads, and queued Transfer Descriptors. These data structures are used by HCD software to construct a “schedule” in system memory for the host controller system 100 to execute. The USB Engine 168 stores the starting address of the Frame List, and makes use of the interrupt from the host controller system 100 to activate an interrupt handler routine to read from the system memory the link pointers in the Frame List, Transfer Descriptors, and Queue Heads. The USB Engine 168 uses the link pointer to determine where to find the next Transfer Descriptor to execute. Transfer descriptors point to data buffers and include information about the addressing, data, and general behavior characteristics of the transaction.
Another embodiment shown in
Although the foregoing description of the preferred embodiment of the present invention has shown, described, and pointed out the fundamental novel features of the invention, it will be understood that various omissions, substitutions, and changes in the form of the detail of the apparatus as illustrated, as well as the uses thereof, may be made by those skilled in the art without departing from the spirit of the present invention. Hence, the scope of the present invention should not be limited to the foregoing discussion, but should be defined by the appended claims.
Claims
1. A USB host controller system for interfacing between at least one USB device and a host processor, the system comprising:
- a host controller that transfers USB transactions between at least one USB device and the host processor; and
- at least one memory associated with the host controller, wherein the host controller receives a plurality of USB transactions each having an associated transaction descriptor and assembles the USB transactions in the memory as a single batch and wherein the host processor induces the dispatch of the assembled batch as a composite signal that is subsequently decoded upon arrival as discrete USB transactions processed according to the transaction descriptors in such a manner so as to reduce interrupts to the host processor thereby reducing overall latency and resource demand on the host processor during execution of the USB transactions and increasing the overall data throughput as compared to transmitting the plurality of USB transactions individually.
Type: Application
Filed: May 14, 2004
Publication Date: Feb 10, 2005
Inventors: Jing Wang (Riverside, CA), Ping Liang (Irvine, CA)
Application Number: 10/846,162