SlideShare a Scribd company logo
Submit Search
Upload
USB Drivers
Report
Share
Anil Kumar Pugalia
Linux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Follow
•
12 likes
•
42,921 views
1
of
31
USB Drivers
•
12 likes
•
42,921 views
Report
Share
Technology
USB Host & Gadget Device Drivers in Linux
Read more
Anil Kumar Pugalia
Linux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Follow
Recommended
Bootloaders (U-Boot) by
Bootloaders (U-Boot)
Omkar Rane
635 views
•
18 slides
U-Boot - An universal bootloader by
U-Boot - An universal bootloader
Emertxe Information Technologies Pvt Ltd
3K views
•
46 slides
linux device driver by
linux device driver
Rahul Batra
11.4K views
•
37 slides
U boot porting guide for SoC by
U boot porting guide for SoC
Macpaul Lin
11.9K views
•
32 slides
U-Boot presentation 2013 by
U-Boot presentation 2013
Wave Digitech
18.7K views
•
28 slides
Board Bringup by
Board Bringup
Anil Kumar Pugalia
28.7K views
•
16 slides
More Related Content
What's hot
Bootloaders by
Bootloaders
Anil Kumar Pugalia
10K views
•
19 slides
Arm device tree and linux device drivers by
Arm device tree and linux device drivers
Houcheng Lin
17.5K views
•
19 slides
Jagan Teki - U-boot from scratch by
Jagan Teki - U-boot from scratch
linuxlab_conf
709 views
•
90 slides
Linux Audio Drivers. ALSA by
Linux Audio Drivers. ALSA
GlobalLogic Ukraine
3.8K views
•
24 slides
Linux Porting to a Custom Board by
Linux Porting to a Custom Board
Patrick Bellasi
28.6K views
•
46 slides
U-Boot Porting on New Hardware by
U-Boot Porting on New Hardware
RuggedBoardGroup
2.1K views
•
31 slides
What's hot
(20)
Bootloaders by Anil Kumar Pugalia
Bootloaders
Anil Kumar Pugalia
•
10K views
Arm device tree and linux device drivers by Houcheng Lin
Arm device tree and linux device drivers
Houcheng Lin
•
17.5K views
Jagan Teki - U-boot from scratch by linuxlab_conf
Jagan Teki - U-boot from scratch
linuxlab_conf
•
709 views
Linux Audio Drivers. ALSA by GlobalLogic Ukraine
Linux Audio Drivers. ALSA
GlobalLogic Ukraine
•
3.8K views
Linux Porting to a Custom Board by Patrick Bellasi
Linux Porting to a Custom Board
Patrick Bellasi
•
28.6K views
U-Boot Porting on New Hardware by RuggedBoardGroup
U-Boot Porting on New Hardware
RuggedBoardGroup
•
2.1K views
Linux device drivers by Emertxe Information Technologies Pvt Ltd
Linux device drivers
Emertxe Information Technologies Pvt Ltd
•
41.5K views
Linux I2C by KaidenYu
Linux I2C
KaidenYu
•
797 views
I2c drivers by pradeep_tewani
I2c drivers
pradeep_tewani
•
358 views
Embedded_Linux_Booting by Rashila Rr
Embedded_Linux_Booting
Rashila Rr
•
513 views
BeagleBoard-xM Booting Process by SysPlay eLearning Academy for You
BeagleBoard-xM Booting Process
SysPlay eLearning Academy for You
•
3.8K views
U Boot or Universal Bootloader by Satpal Parmar
U Boot or Universal Bootloader
Satpal Parmar
•
21.1K views
Linux Initialization Process (2) by shimosawa
Linux Initialization Process (2)
shimosawa
•
6.8K views
Introduction Linux Device Drivers by NEEVEE Technologies
Introduction Linux Device Drivers
NEEVEE Technologies
•
938 views
Introduction to Linux Drivers by Anil Kumar Pugalia
Introduction to Linux Drivers
Anil Kumar Pugalia
•
64.7K views
I2C Drivers by SysPlay eLearning Academy for You
I2C Drivers
SysPlay eLearning Academy for You
•
28.8K views
Linux Porting by Anil Kumar Pugalia
Linux Porting
Anil Kumar Pugalia
•
17.5K views
BeagleBone Black Bootloaders by SysPlay eLearning Academy for You
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
•
4.6K views
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware by Linaro
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
Linaro
•
7.6K views
Linux device drivers by Abhishek Sagar
Linux device drivers
Abhishek Sagar
•
1.1K views
Viewers also liked
Network Drivers by
Network Drivers
Anil Kumar Pugalia
39.4K views
•
15 slides
Serial Drivers by
Serial Drivers
SysPlay eLearning Academy for You
17.1K views
•
13 slides
SPI Drivers by
SPI Drivers
SysPlay eLearning Academy for You
13.2K views
•
20 slides
Interrupts by
Interrupts
Anil Kumar Pugalia
47.7K views
•
18 slides
PCI Drivers by
PCI Drivers
Anil Kumar Pugalia
44.5K views
•
16 slides
File System Modules by
File System Modules
Anil Kumar Pugalia
25K views
•
27 slides
Viewers also liked
(17)
Network Drivers by Anil Kumar Pugalia
Network Drivers
Anil Kumar Pugalia
•
39.4K views
Serial Drivers by SysPlay eLearning Academy for You
Serial Drivers
SysPlay eLearning Academy for You
•
17.1K views
SPI Drivers by SysPlay eLearning Academy for You
SPI Drivers
SysPlay eLearning Academy for You
•
13.2K views
Interrupts by Anil Kumar Pugalia
Interrupts
Anil Kumar Pugalia
•
47.7K views
PCI Drivers by Anil Kumar Pugalia
PCI Drivers
Anil Kumar Pugalia
•
44.5K views
File System Modules by Anil Kumar Pugalia
File System Modules
Anil Kumar Pugalia
•
25K views
Block Drivers by Anil Kumar Pugalia
Block Drivers
Anil Kumar Pugalia
•
38.4K views
Video Drivers by Anil Kumar Pugalia
Video Drivers
Anil Kumar Pugalia
•
23.4K views
Low-level Accesses by Anil Kumar Pugalia
Low-level Accesses
Anil Kumar Pugalia
•
25.3K views
Audio Drivers by Anil Kumar Pugalia
Audio Drivers
Anil Kumar Pugalia
•
20.8K views
Kernel Programming by Anil Kumar Pugalia
Kernel Programming
Anil Kumar Pugalia
•
24.5K views
Kernel Debugging & Profiling by Anil Kumar Pugalia
Kernel Debugging & Profiling
Anil Kumar Pugalia
•
18.8K views
gcc and friends by Anil Kumar Pugalia
gcc and friends
Anil Kumar Pugalia
•
14.3K views
References by Anil Kumar Pugalia
References
Anil Kumar Pugalia
•
21.8K views
Embedded C by Anil Kumar Pugalia
Embedded C
Anil Kumar Pugalia
•
25.7K views
Platform Drivers by SysPlay eLearning Academy for You
Platform Drivers
SysPlay eLearning Academy for You
•
17.6K views
Character Drivers by Anil Kumar Pugalia
Character Drivers
Anil Kumar Pugalia
•
56.7K views
Similar to USB Drivers
Usb Drive Protector by
Usb Drive Protector
Aashiq Ahamed N
83 views
•
10 slides
Useful USB Gadgets on Linux by
Useful USB Gadgets on Linux
Gary Bisson
2.4K views
•
35 slides
SR-IOV Introduce by
SR-IOV Introduce
Lingfei Kong
4.2K views
•
16 slides
Embedded I/O Management by
Embedded I/O Management
Anil Kumar Pugalia
5.1K views
•
22 slides
Study on Android Emulator by
Study on Android Emulator
Samael Wang
6.7K views
•
84 slides
Cold front - bridging the web and the physical world by
Cold front - bridging the web and the physical world
Kenneth Rohde Christiansen
124 views
•
118 slides
Similar to USB Drivers
(20)
Usb Drive Protector by Aashiq Ahamed N
Usb Drive Protector
Aashiq Ahamed N
•
83 views
Useful USB Gadgets on Linux by Gary Bisson
Useful USB Gadgets on Linux
Gary Bisson
•
2.4K views
SR-IOV Introduce by Lingfei Kong
SR-IOV Introduce
Lingfei Kong
•
4.2K views
Embedded I/O Management by Anil Kumar Pugalia
Embedded I/O Management
Anil Kumar Pugalia
•
5.1K views
Study on Android Emulator by Samael Wang
Study on Android Emulator
Samael Wang
•
6.7K views
Cold front - bridging the web and the physical world by Kenneth Rohde Christiansen
Cold front - bridging the web and the physical world
Kenneth Rohde Christiansen
•
124 views
Linux Usb overview by Satyam Sharma
Linux Usb overview
Satyam Sharma
•
737 views
BeagleBone Black Bootloaders by SysPlay eLearning Academy for You
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
•
4K views
Open Source Firmware - FrOSCon 2019 by Daniel Maslowski
Open Source Firmware - FrOSCon 2019
Daniel Maslowski
•
150 views
PICDriver by John Dunbar
PICDriver
John Dunbar
•
106 views
Beagle board101 esc-boston-2009b by Michael Hallak-Stamler
Beagle board101 esc-boston-2009b
Michael Hallak-Stamler
•
8.9K views
Introduction to Embedded Systems by Anil Kumar Pugalia
Introduction to Embedded Systems
Anil Kumar Pugalia
•
18.5K views
Embedded Applications by Anil Kumar Pugalia
Embedded Applications
Anil Kumar Pugalia
•
8.1K views
Notes for LX0-101 Linux by Chris Henson, CCNP
Notes for LX0-101 Linux
Chris Henson, CCNP
•
1.7K views
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood by EmbeddedFest
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
EmbeddedFest
•
421 views
Software and its types by Waheed Iqbal Boss
Software and its types
Waheed Iqbal Boss
•
3.3K views
Slimline Open Firmware by Heiko Joerg Schick
Slimline Open Firmware
Heiko Joerg Schick
•
2.1K views
How to Hack Edison by Shotaro Uchida
How to Hack Edison
Shotaro Uchida
•
7.7K views
SESI 7 RouterTroubleshooting.pptx by FirmanAFauzi1
SESI 7 RouterTroubleshooting.pptx
FirmanAFauzi1
•
5 views
UP Board AI Core Configuration memo by Naoto MATSUMOTO
UP Board AI Core Configuration memo
Naoto MATSUMOTO
•
284 views
More from Anil Kumar Pugalia
File System Modules by
File System Modules
Anil Kumar Pugalia
21K views
•
37 slides
Kernel Debugging & Profiling by
Kernel Debugging & Profiling
Anil Kumar Pugalia
6K views
•
14 slides
Processes by
Processes
Anil Kumar Pugalia
7K views
•
33 slides
System Calls by
System Calls
Anil Kumar Pugalia
4.2K views
•
17 slides
Introduction to Linux by
Introduction to Linux
Anil Kumar Pugalia
4K views
•
33 slides
Embedded Software Design by
Embedded Software Design
Anil Kumar Pugalia
7K views
•
29 slides
More from Anil Kumar Pugalia
(20)
File System Modules by Anil Kumar Pugalia
File System Modules
Anil Kumar Pugalia
•
21K views
Kernel Debugging & Profiling by Anil Kumar Pugalia
Kernel Debugging & Profiling
Anil Kumar Pugalia
•
6K views
Processes by Anil Kumar Pugalia
Processes
Anil Kumar Pugalia
•
7K views
System Calls by Anil Kumar Pugalia
System Calls
Anil Kumar Pugalia
•
4.2K views
Introduction to Linux by Anil Kumar Pugalia
Introduction to Linux
Anil Kumar Pugalia
•
4K views
Embedded Software Design by Anil Kumar Pugalia
Embedded Software Design
Anil Kumar Pugalia
•
7K views
Playing with R L C Circuits by Anil Kumar Pugalia
Playing with R L C Circuits
Anil Kumar Pugalia
•
2.8K views
Mobile Hacking using Linux Drivers by Anil Kumar Pugalia
Mobile Hacking using Linux Drivers
Anil Kumar Pugalia
•
6K views
Shell Scripting by Anil Kumar Pugalia
Shell Scripting
Anil Kumar Pugalia
•
6.2K views
Functional Programming with LISP by Anil Kumar Pugalia
Functional Programming with LISP
Anil Kumar Pugalia
•
6.1K views
Power of vi by Anil Kumar Pugalia
Power of vi
Anil Kumar Pugalia
•
3K views
"make" system by Anil Kumar Pugalia
"make" system
Anil Kumar Pugalia
•
4.2K views
Hardware Design for Software Hackers by Anil Kumar Pugalia
Hardware Design for Software Hackers
Anil Kumar Pugalia
•
1.7K views
RPM Building by Anil Kumar Pugalia
RPM Building
Anil Kumar Pugalia
•
4K views
Linux User Space Debugging & Profiling by Anil Kumar Pugalia
Linux User Space Debugging & Profiling
Anil Kumar Pugalia
•
6.5K views
Linux Network Management by Anil Kumar Pugalia
Linux Network Management
Anil Kumar Pugalia
•
11.3K views
System Calls by Anil Kumar Pugalia
System Calls
Anil Kumar Pugalia
•
9.7K views
Timers by Anil Kumar Pugalia
Timers
Anil Kumar Pugalia
•
6.5K views
Threads by Anil Kumar Pugalia
Threads
Anil Kumar Pugalia
•
10.2K views
Synchronization by Anil Kumar Pugalia
Synchronization
Anil Kumar Pugalia
•
9K views
Recently uploaded
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue
46 views
•
28 slides
Network Source of Truth and Infrastructure as Code revisited by
Network Source of Truth and Infrastructure as Code revisited
Network Automation Forum
32 views
•
45 slides
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue
55 views
•
12 slides
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro
27 views
•
38 slides
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue
70 views
•
7 slides
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software
317 views
•
86 slides
Recently uploaded
(20)
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue
•
46 views
Network Source of Truth and Infrastructure as Code revisited by Network Automation Forum
Network Source of Truth and Infrastructure as Code revisited
Network Automation Forum
•
32 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue
•
55 views
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro
•
27 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue
•
70 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software
•
317 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue
•
44 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue
•
38 views
Uni Systems for Power Platform.pptx by Uni Systems S.M.S.A.
Uni Systems for Power Platform.pptx
Uni Systems S.M.S.A.
•
58 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10
•
42 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... by ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue
•
40 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue
•
54 views
Scaling Knowledge Graph Architectures with AI by Enterprise Knowledge
Scaling Knowledge Graph Architectures with AI
Enterprise Knowledge
•
50 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker
•
48 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Network Automation Forum
•
43 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue
•
26 views
Microsoft Power Platform.pptx by Uni Systems S.M.S.A.
Microsoft Power Platform.pptx
Uni Systems S.M.S.A.
•
61 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue
•
44 views
MVP and prioritization.pdf by rahuldharwal141
MVP and prioritization.pdf
rahuldharwal141
•
37 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
IttrainingIttraining
•
69 views
USB Drivers
1.
© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Drivers
2.
2© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? USB Evolution USB Subsystem: Host & Gadget Understanding of USB Protocol Writing USB Host Drivers Writing USB Gadget Drivers
3.
3© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Prologue What was USB designed for? A Unified Bus for Slow Devices So, design based on Master-Slave concept USB (Host) Controller is the “Single Master” UHC polls the Slave Peripherals / Devices Later Additions High Speed Specifications Bandwidth Allocation Ability But even today, the polling continues
4.
4© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Device Driver Types 2 Types: Both written for the Device USB Host (Device) Driver Runs on Host (Master) Drives the USB Device (Slave) USB Gadget (Device) Driver Runs on the USB Gadget / Device (Slave) Responds to a Host (Master) Pre-requisite: Gadget is Linux based
5.
5© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Host Subsystem View FS Layer USB Host Device Drivers ... USB Core USB Host / OTG Controller Driver(s) ... TTY Layer Char Layer Net Layer Block Layer Kernel Space User Applications USB Devices ... Hardware Space User Space usbfs User Mode Drivers USB Host / OTG Controller
6.
6© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Host Subsystem UHC Driver (uhci, ohci, ehci, otg) Hardware-specific USB Host Controller driver Hides all the hardware details from the layers above Provides a uniform interface to USB Core USB Core Module (usbcore) Provides the generic USB Protocol APIs for the kernel, in general By interfacing with the underlying UHC driver USB File System Module (usbfs) Uses USB Core to provide Kernel Windows & USB Devices as entries under /sys Enables writing User Mode USB Drivers USB Host Device Driver USB Device specific Driver Interfaces with the corresponding USB Device through the USB Core Provides interface to the User Space through the relevant Vertical(s)
7.
7© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Subsystem View USB Gadget Device Drivers ... USB Composite USB Device / OTG Controller Driver Kernel Space USB Host Hardware Space USB Device / OTG Controller Horizontal Layers Vertical Layers Peripherals User Applications User Space
8.
8© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Subsystem UDC Driver (*udc) Hardware-specific USB Device Controller driver Hides all the hardware details from the layers above Provides a uniform interface to USB Composite USB Composite Module (libcomposite) Provides the generic USB Protocol APIs for the kernel, in general By interfacing with the underlying UDC driver USB Gadget Device Driver USB Device specific Driver Interfaces with the USB Host through the USB Composite Exposes peripherals &/or (virtual) functionalities to the Host May provide (virtual) functionalities to the User Space through the relevant Layer(s) / Driver(s)
9.
9© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Host & sysfs Command: /sbin/lspci <dom>:<bus>:<dev>:<fn> for <usbhubid> Kernel Window /sys/devices/pci0000:00/<usbhubid>/usb<hub> usb_device fields roothub-hubport:config.interface usb_interface fields PCI USB HC functions -> USB buses /sys/kernel/debug/usb/devices
10.
10© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Device Overview (Protocol) Device Config Interface Endpoint ... Endpoint Endpoint ... Interface USB Driver USB Driver ...
11.
11© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Device Endpoints Also called Pipes Direction OUT (host->device) IN (device->host) Four Types Control Interrupt Bulk Isochronous
12.
12© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Host Device Driver
13.
13© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Host Driver Data Structures Header: <linux/usb.h> Data Structures struct usb_device struct usb_host_config struct usb_interface interface_to_usbdev struct usb_host_endpoint struct usb_endpoint_descriptor
14.
14© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Core Functionality USB Host Device Driver Registration USB Host Device Hot Plugability probe: Vertical Registration disconnect: Vertical Unregistration USB Transfers through URBs
15.
15© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Host Device Driver Registration Header: <linux/usb.h> Data Structure: struct usb_driver struct module *owner const char *name const struct usb_device_id *id_table int (*probe)(struct usb_interface *, struct usb_device_id *) int (*disconnect)(struct usb_interface *) APIs int usb_register(struct usb_driver *); int usb_deregister(struct usb_driver *);
16.
16© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Host Device Hot-plug-ability Callback probe int usb_register_dev(intf, class); Callback disconnect int usb_deregister_dev(intf, class); Other Useful APIs (Header: <linux/usb.h> void usb_set_intfdata(intf, void *data); void *usb_get_intfdata(intf);
17.
17© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Request Block Header: <linux/usb.h> Data Structure: struct urb struct usb_device *dev unsigned int pipe unsigned int transfer_flags void *transfer_buffer int transfer_buffer_length usb_complete_t complete int actual_length int status Pipe type specific fields
18.
18© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. URB Operations Header: <linux/usb.h> URB Storage usb_alloc_urb(int iso_pkts, gfp_t flags); usb_free_urb(struct urb *); Populating the URB usb_fill_control_urb(urb, dev, pipe, req, buf, len, fn, ctxt); usb_fill_int_urb(urb, dev, pipe, buf, len, fn, ctxt, interval); usb_fill_bulk_urb(urb, dev, pipe, buf, len, fn, ctxt); Using the URB usb_submit_urb(struct urb *, gfp_t flags); usb_unlink_urb(struct urb *) / usb_kill_urb(struct urb *);
19.
19© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. URB Operations' Wrappers Header: <linux/usb.h> APIs usb_control_msg(dev, pipe, req, req_type, value, index, data, size, timeout); usb_interrupt_msg(dev, pipe, data, len, &act_len, timeout); usb_bulk_msg(dev, pipe, data, len, &act_len, timeout);
20.
20© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Device Driver
21.
21© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Data Structures Header: <linux/usb/composite.h> Data Structures struct usb_device_descriptor struct usb_gadget_strings struct usb_string struct usb_configuration struct usb_descriptor_header struct usb_interface_descriptor struct usb_endpoint_descriptor
22.
22© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Composite Functionality USB Gadget Device Driver Registration USB Gadget Device Creation bind: Gadget Setup unbind: Gadget Cleanup USB Gadget Endpoint Interactions
23.
23© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Driver Registration Header: <linux/usb/composite.h> Data Structure: struct usb_composite_driver const char *name const struct usb_device_descriptor *dev struct usb_gadget_strings **strings enum usb_device_speed max_speed int (*bind)(struct usb_composite_dev *cdev) int (*unbind)(struct usb_composite_dev *cdev) APIs int usb_composite_probe(struct usb_composite_driver *driver); void usb_composite_unregister(struct usb_composite_driver *driver);
24.
24© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Device Creation Header: <linux/usb/composite.h> Callback bind int usb_string_ids_tab(struct usb_composite_dev *c, struct usb_string *str); int usb_add_config_only(comp_dev, usb_cfg) int usb_add_function(usb_cfg, usb_fn); Callback unbind int usb_put_function(usb_fn); // int usb_remove_function(usb_cfg, usb_fn);
25.
25© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Function Addition Header: <linux/usb/composite.h> Callbacks in struct usb_function: int (*bind)(struct usb_configuration *c, struct usb_function *f); void (*unbind)(struct usb_configuration *c, struct usb_function *f); void (*free_func)(struct usb_function *f); int (*set_alt)(struct usb_function *f, unsigned interface, unsigned alt); // Must int (*get_alt)(struct usb_function *f, unsigned interface); void (*disable)(struct usb_function *f); // Must int (*setup)(struct usb_function *f, const struct usb_ctrlrequest *ctrlreq); ...
26.
26© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Descriptors Addition Header: <linux/usb/gadget.h> Through <linux/usb/composite.h> Typical invocations through function's bind / unbind/free_func: int usb_interface_id(struct usb_configuration *c, struct usb_function *f); int usb_string_id(struct usb_composite_dev *c); struct usb_ep *usb_ep_autoconfig(struct usb_gadget *gadget, struct usb_endpoint_descriptor *usb_ep); void usb_ep_autoconfig_reset(struct usb_gadget *gadget); int usb_assign_descriptors(struct usb_function *f, struct usb_descriptor_header **fs, struct usb_descriptor_header **hs, struct usb_descriptor_header **ss); void usb_free_all_descriptors(struct usb_function *f);
27.
27© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Endpoint Interactions Header: <linux/usb/gadget.h> Through <linux/usb/composite.h> Typical (Endpoint Interaction) APIs for set_alt / disable: int usb_ep_enable(struct usb_ep *ep); int usb_ep_disable(struct usb_ep *ep); struct usb_request *usb_ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags); void usb_ep_free_request(struct usb_ep *ep, struct usb_request *req); int usb_ep_queue(struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags); int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req); ...
28.
28© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Endpoint Request Header: <linux/usb/gadget.h> Through <linux/usb/composite.h> Data Structure: struct usb_request void *buf unsigned length void (*complete)(struct usb_ep *ep, struct usb_request *req); int status unsigned actual ... APIs: As mentioned under “Endpoint Interactions”
29.
29© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. USB Gadget Function Driver Registration Header: <linux/usb/composite.h> Data Structure: struct usb_function_driver const char *name struct usb_function_instance *(*alloc_inst)(void); struct usb_function *(*alloc_func)(struct usb_function_instance *inst); DECLARE_USB_FUNCTION(fn_name, fn_alloc_instance, fn_alloc); APIs int usb_function_register(struct usb_function_driver *); int usb_function_unregister(struct usb_function_driver *); Useful APIs for the function user gadget driver struct usb_function_instance *usb_get_function_instance(char *fn); struct usb_function *usb_get_function(struct usb_function_instance *);
30.
30© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? Evolution of USB USB Subsystem Host: The Four Components Gadget: The Three Components Understanding of USB Protocol USB Device Overview Writing USB Host Device Drivers Registration Hot Plug-ability Transfers Writing USB Gadget Device Drivers Registration Gadget Device Creation Function & Descriptors Addition Endpoint Interactions Writing USB Gadget Function Drivers
31.
31© 2010-15 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?