/sxr2130_Pre-CS/kernel/msm-4.19/Documentation/usb/gadget_configfs.txt
2 3 4 5 Linux USB gadget configured through configfs 6 7 8 25th April 2013 9 10 11 12 13 Overview 14 ======== 15 16 A USB Linux Gadget is a device which has a UDC (USB Device Controller) and can 17 be connected to a USB Host to extend it with additional functions like a serial 18 port or a mass storage capability. 19 20 A gadget is seen by its host as a set of configurations, each of which contains 21 a number of interfaces which, from the gadget's perspective, are known as 22 functions, each function representing e.g. a serial connection or a SCSI disk. 23 24 Linux provides a number of functions for gadgets to use. 25 26 Creating a gadget means deciding what configurations there will be 27 and which functions each configuration will provide. 28 29 Configfs (please see Documentation/filesystems/configfs/*) lends itself nicely 30 for the purpose of telling the kernel about the above mentioned decision. 31 This document is about how to do it. 32 33 It also describes how configfs integration into gadget is designed. 34 35 36 37 38 Requirements 39 ============ 40 41 In order for this to work configfs must be available, so CONFIGFS_FS must be 42 'y' or 'm' in .config. As of this writing USB_LIBCOMPOSITE selects CONFIGFS_FS. 43 44 45 46 47 Usage 48 ===== 49 50 (The original post describing the first function 51 made available through configfs can be seen here: 52 http://www.spinics.net/lists/linux-usb/msg76388.html) 53 54 $ modprobe libcomposite 55 $ mount none $CONFIGFS_HOME -t configfs 56 57 where CONFIGFS_HOME is the mount point for configfs 58 59 1. Creating the gadgets 60 ----------------------- 61 62 For each gadget to be created its corresponding directory must be created: 63 64 $ mkdir $CONFIGFS_HOME/usb_gadget/<gadget name> 65 66 e.g.: 67 68 $ mkdir $CONFIGFS_HOME/usb_gadget/g1 69 70 ... 71 ... 72 ... 73 74 $ cd $CONFIGFS_HOME/usb_gadget/g1 75 76 Each gadget needs to have its vendor id <VID> and product id <PID> specified: 77 78 $ echo <VID> > idVendor 79 $ echo <PID> > idProduct