s3c2440 USB Host

Source: Internet
Author: User
Tags volatile

http://www.arm8.net/forum.php?mod=viewthread&tid=255

Then you must familiarize yourself with the USB v1.1 protocol first. Therefore, it is not easy to use the USB host interface provided by s3c2440 to correct the content of this part. Here, I mainly introduce the USB device enumeration process involved in some knowledge, and give a specific implementation program.
OHCI (Open HCI) is one of the more widely used three kinds of USB host controller specifications. The USB architecture consists of four main components: client software/USB driver, host controller driver (HCD), host controller (HC) and USB drive. The first two are implemented by software, and the latter two are implemented by hardware. The OHCI is the specification of the interface between host controller driver and host controller, and their basic operation. Between the host controller driver and the host controller, there are two communication channels, the first is to apply a set of operational registers located in HC, which include control registers, status registers and list pointer registers, and another channel is to apply shared memory called Host controller Communication domain (HCCA).

USB defines four types of data transfer: control transmission, bulk transmission, interrupt transmission and synchronous transmission. In the OHCI specification, data transmission types are divided into two categories: periodic transmission and aperiodic transmission. Synchronous transmission and interrupt transmission belong to periodic transmission, control transmission and bulk transmission belong to aperiodic transmission. USB defines a period of 1.0 milliseconds per frame, in order to ensure that each frame can occur both periodic and aperiodic transmissions, generally, OHCI divides the bandwidth of each frame into four parts, first sending the SOF, then the aperiodic transmission, followed by the periodic transmission, and if there is time after the transmission of the cycle, the remaining time is still left for aperiodic transmission.

The endpoint descriptor (ED) and the transport descriptor (TD) are the two most basic communication modules. Ed contains information about an endpoint that is used by HC to manage the use of endpoints. The typical parameters of Ed include endpoint address, transmission speed, maximum packet size, and Ed also provides a docking place (anchor Point) for the TD list. TD is a memory cache that relies on ED for data transfer to and from endpoints. When HC accesses an ED and finds a valid TD address, HC completes a simple transport task between the endpoints, which is determined by Ed, and the memory address of the data being accessed is specified by TD. When all the data that is defined by TD is completed, TD is linked from Ed and linked to the completion list. This completion list can be processed by HCD to provide some completion information.

Ed's data structure is 16 bytes long, and its fields are:
FA:USB's functional address;
The endpoint address within the EN:USB function;
D: Data flow transmission direction, is in,out, or have TD to determine the transmission direction;
S: speed, full speed or low speed;
K: For setting skip current Ed;
F: Link in the form of Ed TD, is the general TD format or synchronous TD format;
MPS: Maximum byte size for data transmission;
TAILP:TD the tail pointer of the list;
H: To stop the current TD list processing;
C: Data flip carry bit;
HEADP:TD the head pointer of the list;
Nexted: The next ed pointer to be processed.

Based on the above instructions, we can define ED as the following data type:
typedef struct _ED {
volatile unsigned int control;
volatile unsigned int tailp;
volatile unsigned int headp;
volatile unsigned int nexted;
ED, *p_ed;

Since Ed must be a 16-byte address alignment, we must declare its variables in the following form:
__align Ed Ed;

We can use the following function to create an ED:
__inline void Createed (
unsigned int edaddr,//ed address pointer
unsigned int maxpacket,//mps
unsigned int tdformat,//f
unsigned int Skip,//k
unsigned int Speed,//s
unsigned int Direction,//d
unsigned int endpt,//en
unsigned int funcaddress,//FA
unsigned int tdqtailpntr,//TAILP
unsigned int tdqheadpntr,//HEADP
unsigned int togglecarry,//c
unsigned int nexted)//nexted
{
p_ed PED = (p_ed) edaddr;
Ped->control = (maxpacket << 16) | (Tdformat << 15) | (Skip << 14) | (Speed << 13)
| Direction << 11) | (ENDPT << 7) | funcaddress;
Ped->tailp = (Tdqtailpntr & 0xfffffff0);
PED-&GT;HEADP = (tdqheadpntr & 0xfffffff0) | (Togglecarry << 1);
ped->nexted = (nexted & 0xfffffff0);
}

TD has a total of two types: general TD and synchronous TD. Universal TD is used for interrupt, control, and batch endpoints, and synchronous TD is used for synchronous transmissions. Here, we only give the general TD's data structure and definition.

The general TD's data structure is 16 bytes long, and its fields are:
R: Cache rounding to set whether the length of the last packet required is consistent with the defined length;
DP: Direction, is in,out, or setup;
DI: Delay interruption;
T: Data flip;
EC: Transmission error count;
CC: Condition code, the state of the last attempt to transmit;
CBP: The physical address of the data memory that will be transmitted;
NEXTTD: Next TD;
Be: The physical last byte address of the data memory to be transmitted;

Based on the above instructions, we can define general TD for the following data types:
typedef struct _TD {
volatile unsigned int control;
volatile unsigned int CBP;
volatile unsigned int nexttd;
volatile unsigned int be;
TD, *P_TD;

Since universal TD must be a 16-byte address alignment, we must declare its variables in the following form:
__align () TD td[4];

We can use the following function to create a generic TD:
__inline void Creategentd (
unsigned int gentdaddr,//TD address pointer
unsigned int datatoggle,//t
unsigned int delayinterrupt,//di
unsigned int Direction,//DP
unsigned int bufrnding,//r
unsigned int curbufptr,//CBP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.