linux/drivers/staging
Andrzej Pietrasiewicz 450279822f staging: usb: gadget: Add FunctionFS support to Configurable Composite Gadget driver
Add FunctionFS support.
It allows certain USB functions to be provided from userspace, e.g. MTP,
PTP, adb.

The functions provided by the gadget itself are enumerated in
/sys/class/ccg0/functions. The functions which can be supplied
from userspace must be enumerated in /sys/class/ccg0/f_fs/user_functions.
No other userspace functions can be used than specified in the above mentioned
file, but just specifying them there is not enough to activate them.
The userspace functions in order to be activated need also be enumerated
in /sys/class/ccg0/functions.

An example sequence of operations can be as follows:

$ echo 0 > /sys/class/ccg_usb/ccg0/enable

$ echo -n 0x2d01 > /sys/module/g_ccg/parameters/idProduct
$ echo -n MyDevice > /sys/module/g_ccg/parameters/iSerialNumber
$ echo -n 0x1d6b > /sys/module/g_ccg/parameters/idVendor
$ echo -n Manufacturer > /sys/module/g_ccg/parameters/iManufacturer
$ echo -n Product > /sys/module/g_ccg/parameters/iProduct
$ echo -n bcdDevice > /sys/module/g_ccg/parameters/bcdDevice

$ echo adb,mtp,ptp > /sys/class/ccg_usb/ccg0/f_fs/user_functions
$ echo mass_storage,ptp > /sys/class/ccg_usb/ccg0/functions
$ echo /file.img > /sys/class/ccg_usb/ccg0/f_mass_storage/lun/file

$ mkdir -p /dev/usbgadget/ptp
$ mount -t functionfs ptp /dev/usbgadget/ptp
$ ./ptp &

$ echo 1 > /sys/class/ccg_usb/ccg0/enable

The above example declares that adb, mtp and ptp functions can be supplied
from userspace through FunctionFS. But of them all only ptp is actually
activated, together with mass_storage, the latter being implemented in
the gadget itself (in kernel, not in userspace). The list of functions
can be modified at runtime while the gadget is not enabled, that is,
after

$ echo 0 > /sys/class/ccg_usb/ccg0/enable

The FunctionFS function is implicitly handled by the gadget, that is,
if a userspace function name is provided in
/sys/class/ccg_usb/ccg0/functions, then the FunctionFS function
is activated.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-16 05:32:20 -07:00
..
android
asus_oled
bcm
ccg staging: usb: gadget: Add FunctionFS support to Configurable Composite Gadget driver 2012-05-16 05:32:20 -07:00
comedi USB: vmk80xx.c: remove err() usage 2012-04-20 16:53:22 -07:00
cptm1217
crystalhd
cxt1e1
echo
et131x
frontier USB: tranzport.c: remove err() usage 2012-04-20 16:53:27 -07:00
ft1000
iio
keucr
line6 USB: toneport.c: remove err() usage 2012-04-20 16:53:32 -07:00
media USB: remove CONFIG_USB_DEVICEFS 2012-04-29 22:20:03 -04:00
mei
nvec
octeon staging: octeon-ethernet: fix build errors by including interrupt.h 2012-04-24 11:57:37 -07:00
olpc_dcon
omapdrm
ozwpan staging: ozwpan: Fix bug where kfree is called twice. 2012-04-26 12:40:53 -07:00
panel
phison
quickstart
ramster
rtl8187se
rtl8192e
rtl8192u
rtl8712
rts5139
rts_pstor
sbe-2t3e3
sep
serial
serqt_usb2 USB: serqt_usb2: remove duplicate device ids 2012-05-10 14:13:17 -07:00
slicoss
sm7xx
speakup
ste_rmi4
telephony
tidspbridge staging: tidspbridge: remove usage of OMAP2_L4_IO_ADDRESS 2012-04-24 11:57:36 -07:00
usbip Revert "usb: move struct usb_device->children to struct usb_hub_port->child" 2012-05-14 09:20:37 -07:00
vme
vt6655
vt6656
winbond
wlags49_h2
wlags49_h25
wlan-ng
xgifb
zcache staging: zcache: fix Kconfig crypto dependency 2012-04-24 11:57:36 -07:00
zram
zsmalloc
Kconfig staging: usb: gadget: Add Configurable Composite Gadget driver 2012-05-16 05:31:42 -07:00
Makefile staging: usb: gadget: Add Configurable Composite Gadget driver 2012-05-16 05:31:42 -07:00
staging.c