EmbLogic's Blog

USB device driver

USB Device Driver

 

Introduction to USB:

These days we are using USB(Universal Serial Bus) devices like pen drive

,mouse,printer etc instead of using serial or parallel port devices. One of the original intentions of USB was to reduce the amount of cabling at the back of your PC. USB port can connect up to 127 peripheral devices by using hub. Averagely it gives us 12Mbps data transfer speed.

Basically host controller keep checking at the USB port to detect device. Whenever device came due to voltage difference it generate interrupt and inform to the system about the device.

 

Now to make USB communication between the host and the device there is need of the drivers on the both side.In our system there is core usb driver which load the appropriate interfacing driver (that is of our concern )for the usb device (mouse ,keyboard etc.) for service. In our system there are different different drivers for different type of devices to make core driver less bulky.

 

USB device basic:

USB device may have one or more configurations and each configuration consist of one or more interfaces and each interfaces consist of one or more endpoints. Generally there is only one configuration in more devices if more, then it will be select able by hardware switch. In our GSM modem there is facility of attaching storage device also so it has two interfaces.

Now for communication we have to send or receive data from the endpoints which is inside the interface ,these may be input endpoint or output endpoint for receiving and sending respectively.

 

Type of data transfer from endpoint:

Control :

Control endpoint is used to retrieve the device information at the time of enumeration of device

Enumeration is the process in which core driver take the information about the hardware from the device firmware to check the vendor id,product id ,serial number etc to load appropriate interfacing driver to serve.

Interrupt:

Interrupt endpoint is used to send the small data of in asynchronous manner like in keyboard. This endpoint is not used to transfer large amount of data.

Isochronous:

Isochronous endpoint is used to send large amount of data but it is generally used where we can accept some data loss like in video streaming where continuous stream of data is required.

Bulk:

Bulk endpoint is also used to send large amount of data and there is no loss in the data. It is used for the mass storage devices to copy the data to and from t he system. It split the data into small chunks if there is large amount of data according to the block size.

 

Now it is clear from above discussion that data is transferred from the endpoint. Data is generally transferred in URBs i.e USB request blocks.

 

Interfacing Driver:

Interfacing driver means that driver which is loaded by usb core driver for specific device to server. It communicate between the application layer and the usb core driver to serve the device request. If we want to use our interfacing driver in the system to provide service then we have to register our driver with USB subsystem first using usb_register() system call and then in our driver we also have to specify that our driver is made for which device (vendor id, product id etc.). All these information is provided in the linux/usb.h header file.

Now one important thing is that you have to remove the usbhid named driver from the system using rmmod usbhid if it is moduler otherwise recompile raw kernel by making hid(human interface device) driver moduler from static.

 

Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>