• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0
2#
3# USB Gadget support on a system involves
4#    (a) a peripheral controller, and
5#    (b) the gadget driver using it.
6#
7# NOTE:  Gadget support ** DOES NOT ** depend on host-side CONFIG_USB !!
8#
9#  - Host systems (like PCs) need CONFIG_USB (with "A" jacks).
10#  - Peripherals (like PDAs) need CONFIG_USB_GADGET (with "B" jacks).
11#  - Some systems have both kinds of controllers.
12#
13# With help from a special transceiver and a "Mini-AB" jack, systems with
14# both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG).
15#
16
17menuconfig USB_GADGET
18	tristate "USB Gadget Support"
19	select USB_COMMON
20	select NLS
21	help
22	   USB is a host/device protocol, organized with one host (such as a
23	   PC) controlling up to 127 peripheral devices.
24	   The USB hardware is asymmetric, which makes it easier to set up:
25	   you can't connect a "to-the-host" connector to a peripheral.
26
27	   Linux can run in the host, or in the peripheral.  In both cases
28	   you need a low level bus controller driver, and some software
29	   talking to it.  Peripheral controllers are often discrete silicon,
30	   or are integrated with the CPU in a microcontroller.  The more
31	   familiar host side controllers have names like "EHCI", "OHCI",
32	   or "UHCI", and are usually integrated into southbridges on PC
33	   motherboards.
34
35	   Enable this configuration option if you want to run Linux inside
36	   a USB peripheral device.  Configure one hardware driver for your
37	   peripheral/device side bus controller, and a "gadget driver" for
38	   your peripheral protocol.  (If you use modular gadget drivers,
39	   you may configure more than one.)
40
41	   If in doubt, say "N" and don't enable these drivers; most people
42	   don't have this kind of hardware (except maybe inside Linux PDAs).
43
44	   For more information, see <http://www.linux-usb.org/gadget> and
45	   the kernel documentation for this API.
46
47if USB_GADGET
48
49config USB_GADGET_DEBUG
50	bool "Debugging messages (DEVELOPMENT)"
51	depends on DEBUG_KERNEL
52	help
53	   Many controller and gadget drivers will print some debugging
54	   messages if you use this option to ask for those messages.
55
56	   Avoid enabling these messages, even if you're actively
57	   debugging such a driver.  Many drivers will emit so many
58	   messages that the driver timings are affected, which will
59	   either create new failure modes or remove the one you're
60	   trying to track down.  Never enable these messages for a
61	   production build.
62
63config USB_GADGET_VERBOSE
64	bool "Verbose debugging Messages (DEVELOPMENT)"
65	depends on USB_GADGET_DEBUG
66	help
67	   Many controller and gadget drivers will print verbose debugging
68	   messages if you use this option to ask for those messages.
69
70	   Avoid enabling these messages, even if you're actively
71	   debugging such a driver.  Many drivers will emit so many
72	   messages that the driver timings are affected, which will
73	   either create new failure modes or remove the one you're
74	   trying to track down.  Never enable these messages for a
75	   production build.
76
77config USB_GADGET_DEBUG_FILES
78	bool "Debugging information files (DEVELOPMENT)"
79	depends on PROC_FS
80	help
81	   Some of the drivers in the "gadget" framework can expose
82	   debugging information in files such as /proc/driver/udc
83	   (for a peripheral controller).  The information in these
84	   files may help when you're troubleshooting or bringing up a
85	   driver on a new board.   Enable these files by choosing "Y"
86	   here.  If in doubt, or to conserve kernel memory, say "N".
87
88config USB_GADGET_DEBUG_FS
89	bool "Debugging information files in debugfs (DEVELOPMENT)"
90	depends on DEBUG_FS
91	help
92	   Some of the drivers in the "gadget" framework can expose
93	   debugging information in files under /sys/kernel/debug/.
94	   The information in these files may help when you're
95	   troubleshooting or bringing up a driver on a new board.
96	   Enable these files by choosing "Y" here.  If in doubt, or
97	   to conserve kernel memory, say "N".
98
99config USB_GADGET_VBUS_DRAW
100	int "Maximum VBUS Power usage (2-500 mA)"
101	range 2 500
102	default 2
103	help
104	   Some devices need to draw power from USB when they are
105	   configured, perhaps to operate circuitry or to recharge
106	   batteries.  This is in addition to any local power supply,
107	   such as an AC adapter or batteries.
108
109	   Enter the maximum power your device draws through USB, in
110	   milliAmperes.  The permitted range of values is 2 - 500 mA;
111	   0 mA would be legal, but can make some hosts misbehave.
112
113	   This value will be used except for system-specific gadget
114	   drivers that have more specific information.
115
116config USB_GADGET_STORAGE_NUM_BUFFERS
117	int "Number of storage pipeline buffers"
118	range 2 256
119	default 2
120	help
121	   Usually 2 buffers are enough to establish a good buffering
122	   pipeline. The number may be increased in order to compensate
123	   for a bursty VFS behaviour. For instance there may be CPU wake up
124	   latencies that makes the VFS to appear bursty in a system with
125	   an CPU on-demand governor. Especially if DMA is doing IO to
126	   offload the CPU. In this case the CPU will go into power
127	   save often and spin up occasionally to move data within VFS.
128	   If selecting USB_GADGET_DEBUG_FILES this value may be set by
129	   a module parameter as well.
130	   If unsure, say 2.
131
132config U_SERIAL_CONSOLE
133	bool "Serial gadget console support"
134	depends on USB_U_SERIAL
135	help
136	   It supports the serial gadget can be used as a console.
137
138source "drivers/usb/gadget/udc/Kconfig"
139
140#
141# USB Gadget Drivers
142#
143
144# composite based drivers
145config USB_LIBCOMPOSITE
146	tristate
147	select CONFIGFS_FS
148	depends on USB_GADGET
149
150config USB_F_ACM
151	tristate
152
153config USB_F_SS_LB
154	tristate
155
156config USB_U_SERIAL
157	tristate
158
159config USB_U_ETHER
160	tristate
161
162config USB_U_AUDIO
163	tristate
164
165config USB_F_SERIAL
166	tristate
167
168config USB_F_OBEX
169	tristate
170
171config USB_F_NCM
172	tristate
173
174config USB_F_ECM
175	tristate
176
177config USB_F_PHONET
178	tristate
179
180config USB_F_EEM
181	tristate
182
183config USB_F_SUBSET
184	tristate
185
186config USB_F_RNDIS
187	tristate
188
189config USB_F_MASS_STORAGE
190	tristate
191
192config USB_F_FS
193	tristate
194
195config USB_F_UAC1
196	tristate
197
198config USB_F_UAC1_LEGACY
199	tristate
200
201config USB_F_UAC2
202	tristate
203
204config USB_F_UVC
205	tristate
206	select UVC_COMMON
207
208config USB_F_MIDI
209	tristate
210
211config USB_F_MIDI2
212	tristate
213
214config USB_F_HID
215	tristate
216
217config USB_F_PRINTER
218	tristate
219
220config USB_F_TCM
221	tristate
222
223# due to coupling with composite driver, can not be built as a module.
224config ANDROID_USB_F_ACC
225	bool
226
227# this first set of drivers all depend on bulk-capable hardware.
228
229config USB_CONFIGFS
230	tristate "USB Gadget functions configurable through configfs"
231	select USB_LIBCOMPOSITE
232	help
233	  A Linux USB "gadget" can be set up through configfs.
234	  If this is the case, the USB functions (which from the host's
235	  perspective are seen as interfaces) and configurations are
236	  specified simply by creating appropriate directories in configfs.
237	  Associating functions with configurations is done by creating
238	  appropriate symbolic links.
239	  For more information see Documentation/usb/gadget_configfs.rst.
240
241config ANDROID_USB_CONFIGFS_UEVENT
242	bool "Uevent notification of Gadget State"
243	depends on USB_CONFIGFS
244	help
245	  Enable uevent notifications to userspace when gadget state changes.
246	  The gadget can be in any of the following three states:
247	  "CONNECTED", "DISCONNECTED" or "CONFIGURED".
248	  Additionally, selecting this will create the android_usb class of
249	  devices, including a "state" attribute for the android_device which
250	  shows the gadget state.
251
252config USB_CONFIGFS_SERIAL
253	bool "Generic serial bulk in/out"
254	depends on USB_CONFIGFS
255	depends on TTY
256	select USB_U_SERIAL
257	select USB_F_SERIAL
258	help
259	  The function talks to the Linux-USB generic serial driver.
260
261config USB_CONFIGFS_ACM
262	bool "Abstract Control Model (CDC ACM)"
263	depends on USB_CONFIGFS
264	depends on TTY
265	select USB_U_SERIAL
266	select USB_F_ACM
267	help
268	  ACM serial link.  This function can be used to interoperate with
269	  MS-Windows hosts or with the Linux-USB "cdc-acm" driver.
270
271config USB_CONFIGFS_OBEX
272	bool "Object Exchange Model (CDC OBEX)"
273	depends on USB_CONFIGFS
274	depends on TTY
275	select USB_U_SERIAL
276	select USB_F_OBEX
277	help
278	  You will need a user space OBEX server talking to /dev/ttyGS*,
279	  since the kernel itself doesn't implement the OBEX protocol.
280
281config USB_CONFIGFS_NCM
282	bool "Network Control Model (CDC NCM)"
283	depends on USB_CONFIGFS
284	depends on NET
285	select USB_U_ETHER
286	select USB_F_NCM
287	select CRC32
288	help
289	  NCM is an advanced protocol for Ethernet encapsulation, allows
290	  grouping of several ethernet frames into one USB transfer and
291	  different alignment possibilities.
292
293config USB_CONFIGFS_ECM
294	bool "Ethernet Control Model (CDC ECM)"
295	depends on USB_CONFIGFS
296	depends on NET
297	select USB_U_ETHER
298	select USB_F_ECM
299	help
300	  The "Communication Device Class" (CDC) Ethernet Control Model.
301	  That protocol is often avoided with pure Ethernet adapters, in
302	  favor of simpler vendor-specific hardware, but is widely
303	  supported by firmware for smart network devices.
304
305config USB_CONFIGFS_ECM_SUBSET
306	bool "Ethernet Control Model (CDC ECM) subset"
307	depends on USB_CONFIGFS
308	depends on NET
309	select USB_U_ETHER
310	select USB_F_SUBSET
311	help
312	  On hardware that can't implement the full protocol,
313	  a simple CDC subset is used, placing fewer demands on USB.
314
315config USB_CONFIGFS_RNDIS
316	bool "RNDIS"
317	depends on USB_CONFIGFS
318	depends on NET
319	select USB_U_ETHER
320	select USB_F_RNDIS
321	help
322	   Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
323	   and Microsoft provides redistributable binary RNDIS drivers for
324	   older versions of Windows.
325
326	   To make MS-Windows work with this, use Documentation/usb/linux.inf
327	   as the "driver info file".  For versions of MS-Windows older than
328	   XP, you'll need to download drivers from Microsoft's website; a URL
329	   is given in comments found in that info file.
330
331config USB_CONFIGFS_EEM
332	bool "Ethernet Emulation Model (EEM)"
333	depends on USB_CONFIGFS
334	depends on NET
335	select USB_U_ETHER
336	select USB_F_EEM
337	select CRC32
338	help
339	  CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM
340	  and therefore can be supported by more hardware.  Technically ECM and
341	  EEM are designed for different applications.  The ECM model extends
342	  the network interface to the target (e.g. a USB cable modem), and the
343	  EEM model is for mobile devices to communicate with hosts using
344	  ethernet over USB.  For Linux gadgets, however, the interface with
345	  the host is the same (a usbX device), so the differences are minimal.
346
347config USB_CONFIGFS_PHONET
348	bool "Phonet protocol"
349	depends on USB_CONFIGFS
350	depends on NET
351	depends on PHONET
352	select USB_U_ETHER
353	select USB_F_PHONET
354	help
355	  The Phonet protocol implementation for USB device.
356
357config USB_CONFIGFS_MASS_STORAGE
358	bool "Mass storage"
359	depends on USB_CONFIGFS
360	depends on BLOCK
361	select USB_F_MASS_STORAGE
362	help
363	  The Mass Storage Gadget acts as a USB Mass Storage disk drive.
364	  As its storage repository it can use a regular file or a block
365	  device (in much the same way as the "loop" device driver),
366	  specified as a module parameter or sysfs option.
367
368config USB_CONFIGFS_F_LB_SS
369	bool "Loopback and sourcesink function (for testing)"
370	depends on USB_CONFIGFS
371	select USB_F_SS_LB
372	help
373	  Loopback function loops back a configurable number of transfers.
374	  Sourcesink function either sinks and sources bulk data.
375	  It also implements control requests, for "chapter 9" conformance.
376	  Make this be the first driver you try using on top of any new
377	  USB peripheral controller driver.  Then you can use host-side
378	  test software, like the "usbtest" driver, to put your hardware
379	  and its driver through a basic set of functional tests.
380
381config USB_CONFIGFS_F_FS
382	bool "Function filesystem (FunctionFS)"
383	depends on USB_CONFIGFS
384	select USB_F_FS
385	help
386	  The Function Filesystem (FunctionFS) lets one create USB
387	  composite functions in user space in the same way GadgetFS
388	  lets one create USB gadgets in user space.  This allows creation
389	  of composite gadgets such that some of the functions are
390	  implemented in kernel space (for instance Ethernet, serial or
391	  mass storage) and other are implemented in user space.
392
393config USB_CONFIGFS_F_UAC1
394	bool "Audio Class 1.0"
395	depends on USB_CONFIGFS
396	depends on SND
397	select USB_LIBCOMPOSITE
398	select SND_PCM
399	select USB_U_AUDIO
400	select USB_F_UAC1
401	help
402	  This Audio function implements 1 AudioControl interface,
403	  1 AudioStreaming Interface each for USB-OUT and USB-IN.
404	  This driver doesn't expect any real Audio codec to be present
405	  on the device - the audio streams are simply sinked to and
406	  sourced from a virtual ALSA sound card created. The user-space
407	  application may choose to do whatever it wants with the data
408	  received from the USB Host and choose to provide whatever it
409	  wants as audio data to the USB Host.
410
411config USB_CONFIGFS_F_UAC1_LEGACY
412	bool "Audio Class 1.0 (legacy implementation)"
413	depends on USB_CONFIGFS
414	depends on SND
415	select USB_LIBCOMPOSITE
416	select SND_PCM
417	select USB_F_UAC1_LEGACY
418	help
419	  This Audio function implements 1 AudioControl interface,
420	  1 AudioStreaming Interface each for USB-OUT and USB-IN.
421	  This is a legacy driver and requires a real Audio codec
422	  to be present on the device.
423
424config USB_CONFIGFS_F_UAC2
425	bool "Audio Class 2.0"
426	depends on USB_CONFIGFS
427	depends on SND
428	select USB_LIBCOMPOSITE
429	select SND_PCM
430	select USB_U_AUDIO
431	select USB_F_UAC2
432	help
433	  This Audio function is compatible with USB Audio Class
434	  specification 2.0. It implements 1 AudioControl interface,
435	  1 AudioStreaming Interface each for USB-OUT and USB-IN.
436	  This driver doesn't expect any real Audio codec to be present
437	  on the device - the audio streams are simply sinked to and
438	  sourced from a virtual ALSA sound card created. The user-space
439	  application may choose to do whatever it wants with the data
440	  received from the USB Host and choose to provide whatever it
441	  wants as audio data to the USB Host.
442
443config USB_CONFIGFS_F_MIDI
444	bool "MIDI function"
445	depends on USB_CONFIGFS
446	depends on SND
447	select USB_LIBCOMPOSITE
448	select SND_RAWMIDI
449	select USB_F_MIDI
450	help
451	  The MIDI Function acts as a USB Audio device, with one MIDI
452	  input and one MIDI output. These MIDI jacks appear as
453	  a sound "card" in the ALSA sound system. Other MIDI
454	  connections can then be made on the gadget system, using
455	  ALSA's aconnect utility etc.
456
457config ANDROID_USB_F_MIDI_INFO
458	bool "Android MIDI function information"
459	depends on ANDROID_USB_CONFIGFS_UEVENT
460	help
461	  Creates a f_midi device in sysfs under the androidN device
462	  within the android_usb class which provides information
463	  about the PCM card and rmidi device created as part of the
464	  f_midi gadget.
465
466config USB_CONFIGFS_F_MIDI2
467	bool "MIDI 2.0 function"
468	depends on USB_CONFIGFS
469	depends on SND
470	select USB_LIBCOMPOSITE
471	select SND_UMP
472	select SND_UMP_LEGACY_RAWMIDI
473	select USB_F_MIDI2
474	help
475	  The MIDI 2.0 function driver provides the generic emulated
476	  USB MIDI 2.0 interface, looped back to ALSA UMP rawmidi
477	  device on the gadget host. It supports UMP 1.1 spec and
478	  responds UMP Stream messages for UMP Endpoint and Function
479	  Block information / configuration.
480
481config USB_CONFIGFS_F_HID
482	bool "HID function"
483	depends on USB_CONFIGFS
484	select USB_F_HID
485	help
486	  The HID function driver provides generic emulation of USB
487	  Human Interface Devices (HID).
488
489	  For more information, see Documentation/usb/gadget_hid.rst.
490
491config USB_CONFIGFS_F_UVC
492	bool "USB Webcam function"
493	depends on USB_CONFIGFS
494	depends on VIDEO_DEV
495	depends on VIDEO_DEV
496	select VIDEOBUF2_DMA_SG
497	select VIDEOBUF2_VMALLOC
498	select USB_F_UVC
499	help
500	  The Webcam function acts as a composite USB Audio and Video Class
501	  device. It provides a userspace API to process UVC control requests
502	  and stream video data to the host.
503
504config USB_CONFIGFS_F_PRINTER
505	bool "Printer function"
506	select USB_F_PRINTER
507	depends on USB_CONFIGFS
508	help
509	  The Printer function channels data between the USB host and a
510	  userspace program driving the print engine. The user space
511	  program reads and writes the device file /dev/g_printer<X> to
512	  receive or send printer data. It can use ioctl calls to
513	  the device file to get or set printer status.
514
515	  For more information, see Documentation/usb/gadget_printer.rst
516	  which includes sample code for accessing the device file.
517
518config USB_CONFIGFS_F_TCM
519	bool "USB Gadget Target Fabric"
520	depends on TARGET_CORE
521	depends on USB_CONFIGFS
522	select USB_LIBCOMPOSITE
523	select USB_F_TCM
524	help
525	  This fabric is a USB gadget component. Two USB protocols are
526	  supported that is BBB or BOT (Bulk Only Transport) and UAS
527	  (USB Attached SCSI). BOT is advertised on alternative
528	  interface 0 (primary) and UAS is on alternative interface 1.
529	  Both protocols can work on USB2.0 and USB3.0.
530	  UAS utilizes the USB 3.0 feature called streams support.
531
532config ANDROID_USB_CONFIGFS_F_ACC
533	bool "Accessory Gadget"
534	depends on USB_CONFIGFS
535	depends on HID=y
536	select ANDROID_USB_F_ACC
537	help
538	  This Accessory function adds support for the Android Open Accessory
539	  (AOA) protocol v2. Devices which support this protocol send vendor
540	  specific control_requests to describe what they are and what
541	  userspace application should handle their traffic. This function
542	  enables the data exchange with usersapce.
543
544source "drivers/usb/gadget/legacy/Kconfig"
545
546endif # USB_GADGET
547