linux-stable/drivers/staging/ccg/sysfs-class-ccg_usb
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

158 lines
4.4 KiB
Text

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. It includes both the functions provided
in-kernel by the ccg gadget and the functions provided from
userspace through FunctionFS.
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_fs
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
The /sys/class/ccg_usb/ccgX/f_fs subdirectory
corresponds to the gadget's FunctionFS driver.
What: /sys/class/ccg_usb/ccgX/f_fs/user_functions
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
A comma-separeted list of USB function names to be supported
from userspace. No other userspace FunctionFS functions can
be supported than listed here. However, the actual activation
of these functions is still done through
/sys/class/ccg_usb/ccgX/functions, where it is possible
to specify any subset (including maximum and empty) of
/sys/class/ccg_usb/ccgX/f_fs/user_functions.
What: /sys/class/ccg_usb/ccgX/f_fs/max_user_functions
Date: May 2012
KernelVersion: 3.4
Contact: linux-usb@vger.kernel.org
Description:
Maximum number of USB functions to be supported from userspace.
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.