Commit 332bb43f authored by Mike Lockwood's avatar Mike Lockwood Committed by Greg Kroah-Hartman

staging: usb: gadget: Add Configurable Composite Gadget driver

The Configurable Gadget driver is a composite driver that allows
userspace to change at runtime the list of functions enabled in
its configuration and to configure these functions. It supports
multiple functions: acm, rndis, and mass storage.

It is usually controlled by a daemon that changes the configuration
based on user settings. For example, rndis is enabled when the user
enables sharing the phone data connection.

As an example on how to use it, the following shell commands will
make the gadget disconnect from the host and make it be re-enumerated
as a composite with 1 rndis and 2 acm interfaces, and a different
product id:

echo 0       > /sys/class/ccg_usb/ccg0/enable
echo rndis,acm > /sys/class/ccg_usb/ccg0/functions
echo 2       > /sys/class/ccg_usb/ccg0/f_acm/instances
echo -n 0x2d01 > /sys/module/g_ccg/parameters/idProduct
echo 1       > /sys/class/ccg_usb/ccg0/enable

The driver requires a gadget controller that supports software
control of the D+ pullup and the controller driver must support
disabling the pullup during composite_bind.
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
Signed-off-by: default avatarBenoit Goby <benoit@android.com>
	[import from android.c, implement review comments, remove adb,mtp,ptp,accessory]
Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3a230038
......@@ -130,4 +130,6 @@ source "drivers/staging/ramster/Kconfig"
source "drivers/staging/ozwpan/Kconfig"
source "drivers/staging/ccg/Kconfig"
endif # STAGING
......@@ -56,3 +56,4 @@ obj-$(CONFIG_ANDROID) += android/
obj-$(CONFIG_PHONE) += telephony/
obj-$(CONFIG_RAMSTER) += ramster/
obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
obj-$(CONFIG_USB_G_CCG) += ccg/
if USB_GADGET
config USB_G_CCG
tristate "Configurable Composite Gadget (STAGING)"
depends on STAGING && !USB_ZERO && !USB_ZERO_HNPTEST && !USB_AUDIO && !GADGET_UAC1 && !USB_ETH && !USB_ETH_RNDIS && !USB_ETH_EEM && !USB_G_NCM && !USB_GADGETFS && !USB_FUNCTIONFS && !USB_FUNCTIONFS_ETH && !USB_FUNCTIONFS_RNDIS && !USB_FUNCTIONFS_GENERIC && !USB_FILE_STORAGE && !USB_FILE_STORAGE_TEST && !USB_MASS_STORAGE && !USB_G_SERIAL && !USB_MIDI_GADGET && !USB_G_PRINTER && !USB_CDC_COMPOSITE && !USB_G_NOKIA && !USB_G_ACM_MS && !USB_G_MULTI && !USB_G_MULTI_RNDIS && !USB_G_MULTI_CDC && !USB_G_HID && !USB_G_DBGP && !USB_G_WEBCAM
help
The Configurable Composite Gadget supports multiple USB
functions: acm, mass storage, rndis and FunctionFS.
Each function can be configured and enabled/disabled
dynamically from userspace through a sysfs interface.
In order to compile this (either as a module or built-in),
"USB Gadget Drivers" and anything under it must not be
selected compiled-in in
Device Drivers->USB Support->USB Gadget Support.
However, you can say "M" there, if you do, the
Configurable Composite Gadget can be compiled "M" only
or not at all.
endif # USB_GADGET
g_ccg-y := ccg.o
ccflags-y += -Idrivers/usb/gadget
obj-$(CONFIG_USB_G_CCG) += g_ccg.o
TODO:
- change configuration interface from sysfs to configfs
Please send patches to Greg Kroah-Hartmann <gregkh@linuxfoundation.org>,
Andrzej Pietrasiewicz <andrzej.p@samsung.com>, and
Cc: Mike Lockwood <lockwood@android.com>
This diff is collapsed.
What: /sys/class/ccg_usb
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
The ccg_usb/ class subdirectory belongs to ccg
USB gadget.
What: /sys/class/ccg_usb/ccgX
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
The /sys/class/ccg_usb/ccg{0,1,2,3...} class
subdirectories correspond to each ccg gadget device;
at the time of this writing there is only ccg0 and it
represents the ccg gadget.
What: /sys/class/ccg_usb/ccgX/functions
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
A comma-separated list of USB function names to be activated
in this ccg gadget.
What: /sys/class/ccg_usb/ccgX/enable
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
A flag activating/deactivating the ccg usb gadget.
What: /sys/class/ccg_usb/ccgX/state
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
Configurable usb gadget state:
DISCONNECTED
CONNECTED
CONFIGURED
What: /sys/class/ccg_usb/ccgX/f_acm/
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
The /sys/class/ccg_usb/ccgX/f_acm subdirectory
corresponds to the gadget's USB CDC serial (ACM) function
driver.
What: /sys/class/ccg_usb/ccgX/f_acm/instances
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
Maximum number of the /dev/ttyGS<X> interface the driver uses.
What: /sys/class/ccg_usb/ccgX/f_rndis
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
The /sys/class/ccg_usb/ccgX/f_rndis subdirectory
corresponds to the gadget's RNDIS driver.
What: /sys/class/ccg_usb/ccgX/f_rndis/manufacturer
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
RNDIS Ethernet port manufacturer string.
What: /sys/class/ccg_usb/ccgX/f_rndis/wceis
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
RNDIS Ethernet port wireless flag.
What: /sys/class/ccg_usb/ccgX/f_rndis/ethaddr
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
RNDIS Ethernet port Ethernet address.
What: /sys/class/ccg_usb/ccgX/f_rndis/vendorID
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
RNDIS Ethernet port vendor ID.
What: /sys/class/ccg_usb/ccgX/f_mass_storage
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
The /sys/class/ccg_usb/ccgX/f_mass_storage subdirectory
corresponds to the gadget's USB mass storage driver.
What: /sys/class/ccg_usb/ccgX/f_mass_storage/lun
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
The /sys/class/ccg_usb/ccgX/f_mass_storage/lun
subdirectory corresponds to the gadget's USB mass storage
driver and its underlying storage.
What: /sys/class/ccg_usb/ccgX/f_mass_storage/lun
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
The /sys/class/ccg_usb/ccgX/f_mass_storage/lun
subdirectory corresponds to the gadget's USB mass storage
driver and its underlying storage.
What: /sys/class/ccg_usb/ccgX/f_mass_storage/lun/file
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
Gadget's USB mass storage underlying file.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment