Commit Graph

29 Commits

Author SHA1 Message Date
Dima Zavin
f85cf4f97d usb: gadget: android: always update the sw_connected state
If we go through connected->configured->disconnected cycle very quickly,
it is possible that we may not generate a disconnect uevent to userspace.
Connected+configured could have happened before the work item got
executed, and thus would not have updated the sw_connected state. On
the disconnect, it would have noticed that a config is no longer there
but since sw_connected was still 0, it would not have sent the
disconnect event.

Change-Id: Id71175f784e3e1cf3f828bd8b24fceea1078a06b
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-14 15:21:36 -07:00
Dima Zavin
fc7534906a usb: gadget: android: dump the uevents sent when changing states
Change-Id: If5011e39f400b3aca036a890b8b932a7606a7ac2
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-14 13:43:22 -07:00
Dima Zavin
21bad758ae usb: gadget: android: follow proper order on disconnect
We should composite_disconnect *before* updating our internal
state and sending uevent to userspace.
Also, hold cdev->lock while updating internal state.

Change-Id: If66a5a4f7d4a102a44aefc3ce4a154a5a1517dcf
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-14 13:43:19 -07:00
Mike Lockwood
686d33a258 USB: gadget: android: pass ctrl requests to accessory function when disabled
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-09-07 11:07:02 -07:00
Mike Lockwood
6c7dd4ba33 usb: gadget: android: Only call ctrlrequest callback on enabled functions
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-08-12 15:57:43 -07:00
Mike Lockwood
394bf63a79 USB: gadget: android: Use "rndis%d" for RNDIS device name instead of "usb%d"
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-08-12 15:12:08 -07:00
Mike Lockwood
cf7addf29b USB: gadget: f_mtp: Add PTP variant of MTP USB function
This is the same as MTP but with PTP interface descriptor.
Also removed obsolete ioctl for switching between MTP and PTP mode

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-17 22:27:20 -04:00
Benoit Goby
aab96815ae usb: gadget: android: Update android gadget driver
* Functions and the device descriptor are configured from user space:
echo 0       > /sys/class/android_usb/android0/enable
echo adb,acm > /sys/class/android_usb/android0/functions
echo 2       > /sys/class/android_usb/android0/f_acm/instances
echo 1       > /sys/class/android_usb/android0/enable

* Driver does not require platform data anymore

* Moved function initialization to android.c instead of each
function file

* Replaced switches by uevents

Signed-off-by: Benoit Goby <benoit@android.com>
Signed-off-by: Mike Lockwood <lockwood@android.com>
Change-Id: If5ad9267c111ad0a442f0d87a0d31082dc5381b6
2011-06-17 16:02:37 -07:00
Mike Lockwood
9902e0b5c5 USB: gadget: f_accessory: New gadget driver for android USB accesories
Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_accessory: Misc improvements and cleanup:

- Add URI string

- Replace type string with a description string

- Add a control call to retrieve accessory protocol version (currently 1)

- Driver read() and write() calls now fail after USB disconnect until
  driver file is closed and reopened.

- Misc cleanup work

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_accessory: Clear accessory strings when USB is disconnected

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_accessory: Clear previous strings on ACCESSORY_GET_PROTOCOL

Clearing strings on disconnect does not work since we may receive
a disconnect on some devices when transitioning into accessory mode.
We require an accessory to send ACCESSORY_GET_PROTOCOL before
sending any strings, so any strings from a previous session will be cleared.

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_accessory: Clear disconnected flag when driver file is opened

Fixes a race condition that can occur when entering accessory mode.

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_accessory: Add string for accessory's unique serial number

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_accessory: Set bNumEndpoints to correct value of 2

Change-Id: I24f4e36f196d45436e0573301500c3b93215953d
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-17 16:02:31 -07:00
Mike Lockwood
1adbbfbe99 USB: gadget: android: Fix problem switching vendor IDs
We need to update the vendor ID in the composite driver as well

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:55 -07:00
Mike Lockwood
aecca43f09 USB: gadget: android: Support switching vendor ID when configuration changes
Based on the list of enabled USB functions, we can now switch the vendor ID
as well as the product ID.

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:53 -07:00
Dima Zavin
8da0417ce4 usb: gadget: android: fix compilation on 2.6.37
Change-Id: I9a99f007415c5be1bd1a86b138486eac51784e0d
Signed-off-by: Dima Zavin <dima@android.com>
2011-06-14 09:09:12 -07:00
John Michelau
d5d2de6539 USB: gadget: android Fix gadget descriptor compliance for IAD's
USB-IF core team mandates that composite devices containing
IAD's must use bDeviceClass=0xEF, bDeviceSubClass=0x02, &
bDeviceProtocol=0x01 instead of the usual 0x00 in all fields.
This is not a problem currently on Linux hosts, but it is a
problem when connecting to Windows hosts. Without this change
the default Microsoft composite driver will not group
interfaces properly, which is what allows child function
drivers with IAD's to load correctly.

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:11 -07:00
John Michelau
51d5755259 usb: gadget: Fixed Android gadget function discovery & product matching
- Don't bind until all required functions have registered
- Consider multi-instance functions when matching products

Change-Id: I6fa10567db71d49cd81968c01d75e326ff9a17c8
Signed-off-by: John Michelau <john.michelau@motorola.com>
2011-06-14 09:09:11 -07:00
Benoit Goby
ffab952c86 usb: gadget: android: Remove WAKEUP flag from bmAttributes
Remove USB_CONFIG_ATT_WAKEUP from bmAttributes as we don't
support remote wakeup. This fixes an issue with the USB 2.0
compliance test tool.

Change-Id: Ic15e44710069f3f05ace6a82bbfa2b85a3649027
Signed-off-by: Benoit Goby <benoit@android.com>
2011-06-14 09:09:09 -07:00
Mike Lockwood
d6b1d7348a USB: gadget: android: Disable MTP when RNDIS function is enabled.
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:09 -07:00
Dmitry Shmidt
577e37a65b drivers: usb: gadget: Fix section mismatch warning
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2011-06-14 09:09:08 -07:00
Mike Lockwood
28acc1a88c USB: composite: Add usb_composite_force_reset utility to force enumeration
Use this rather than calling usb_gadget_disconnect and usb_gadget_connect
directly to avoid sending USB disconnect events to userspace when resetting
the bus.

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:08 -07:00
Mike Lockwood
4a4414416d USB: gadget: android: Remove unused function android_usb_set_connected()
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:08 -07:00
Mike Lockwood
e2dc503c42 USB: gadget: composite: Add userspace notifications for USB state changes
Add switch to notify current USB configuration.  This can be used to detect
USB connect and disconnect events.

Broadcast a change via the usb_composite class when a USB function is
enabled or disabled.

Rename usb_function.hidden to usb_function.disabled.

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:07 -07:00
Mike Lockwood
0a4c12d4fa USB: gadget: android: check for null _android_dev in android_register_function()
This fixes a load ordering issue that occurred if a function driver loads before
the android gadget driver is initialized.

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:06 -07:00
Mike Lockwood
352208629f USB: gadget: android: Disable UMS when RNDIS ethernet is active.
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:05 -07:00
Steve Kondik
8f5f391403 Add USB_ANDROID_RNDIS_WCEIS option.
Change-Id: I85973ebfcbfae6b401fb8b402842309c72655149
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:09:02 -07:00
Mike Lockwood
da574e2e1f USB: gadget: android: Fix special case for RNDIS ethernet function
Only set device descriptor bDeviceClass field to USB_CLASS_COMM when
the RNDIS function is actually enabled.

Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:08:59 -07:00
Mike Lockwood
573cea55c7 USB: gadget: android: Specify USB_CLASS_COMM in device descriptor if using RNDIS
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:08:56 -07:00
Mike Lockwood
053297308f USB: android: Use composite class driver for enabling and disabling functions
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:08:55 -07:00
Mike Lockwood
789ef237b3 USB: gadget: android: android USB gadget improvements:
usb: gadget: f_mass_storage: use dev_set_name()

Replacing strcpy() to device->bus_id which no longer exists in 2.6.32

Change-Id: Id978c881f457044c750bfd62f4c5bcc35bcd4fc5
Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_adb: Claim endpoints so they are not reused by another function.

Change-Id: Ic9536cca800162e701c81cab36054f51ea759b72
Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_acm: Fix crashes in acm_set_alt()

Change-Id: I91b761d392f8b1ca8784c69069b43e402b90d6a4
Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: f_acm: Include android code only if CONFIG_USB_ANDROID_ACM is set.

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: Android support for RNDIS serial ethernet function.

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: android: Add function name to android_register_function printk.

Change-Id: I38bf79d9b544cdeaec9385f7482a131417fc4b23
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:08:55 -07:00
Krishna, Vamsi
83814ea997 USB: gadget: android: android USB gadget improvements:
USB: android gadget: add remote wakeup attribute to android function

Add remote wakeup attribute to configuration descriptor of android
function to advertise remote wakeup capability to host

Acked-by: Allam, Suresh Reddy <sallam@qualcomm.com>

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: android: Allow functions to handle setup requests.

Signed-off-by: Mike Lockwood <lockwood@android.com>

Support for specifying the list of USB functions from platform data.

The main android.c gadget driver no longer has hard coded references
to the mass_storage and adb functions.

Support for computing the product ID based on tables in platform data
and the currently enabled functions.

Moved the adb enable/disable logic from android.c to f_adb.c.

Change-Id: I6259d3fb1473ed973f700e55d17744956f3527bb
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:08:54 -07:00
Mike Lockwood
7f0d7bd310 android_usb: Composite USB gadget driver for android.
Change-Id: I4101540916b73a5f4e48684727ff782f98b969c7
Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: android gadget: add remote wakeup attribute to android function

Add remote wakeup attribute to configuration descriptor of android
function to advertise remote wakeup capability to host

Acked-by: Allam, Suresh Reddy <sallam@qualcomm.com>

Signed-off-by: Mike Lockwood <lockwood@android.com>

usb gadget: link fixes for android composite gadget

Signed-off-by: Mike Lockwood <lockwood@android.com>

usb gadget: Fix null pointer errors in android composite driver

Signed-off-by: Mike Lockwood <lockwood@android.com>

usb: gadget: android: Allow usb charging to draw up to 500mA instead of 250.

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>

usb gadget: android: Add helper function for usb_gadget_connect and disconnect.

Signed-off-by: Mike Lockwood <lockwood@android.com>

drivers: usb: gadget: call switch_dev_unregister in mass storage unbind callback

This fixes a problem unloading the android gadget driver when built as a module

Signed-off-by: Mike Lockwood <lockwood@android.com>

usb: gadget: android: Add dependency on switch driver.

Signed-off-by: Mike Lockwood <lockwood@android.com>

USB: gadget: android: Fix USB WHQL Certification Issues

Submitted on behalf of RaviKumar Vembu <ravi.v@motorola.com>
Signed-off-by: Jared Suttles <jared.suttles@motorola.com>
Signed-off-by: Mike Lockwood <lockwood@android.com>

drivers: usb: gadget: Add "usb_mass_storage" platform driver.

This will be used for configuring vendor, product and release from board file.

Submitted on behalf of RaviKumar Vembu <ravi.v@motorola.com>
Signed-off-by: Jared Suttles <jared.suttles@motorola.com>
Signed-off-by: Mike Lockwood <lockwood@android.com>

drivers: usb: gadget: Use usb_mass_storage platform device as parent for lun

If a platform device is specified for the f_mass_storage function, use it as the
parent driver for the lun files in sysfs.
This allows a platform independent file path for controlling USB mass storage
from user space.

Signed-off-by: Mike Lockwood <lockwood@android.com>

drivers: usb: gadget: Add platform data struct for usb_mass_storage device

Signed-off-by: Mike Lockwood <lockwood@android.com>

usb: gadget: mass_storage: Fix Mass Storage Panic during PC reboot

Submitted on behalf of RaviKumar Vembu <ravi.v@motorola.com>
Signed-off-by: Jared Suttles <jared.suttles@motorola.com>
Signed-off-by: Mike Lockwood <lockwood@android.com>

usb: gadget: f_mass_storage: Handle setup request correctly

Signed-off-by: Mike Lockwood <lockwood@android.com>

usb: gadget: f_mass_storage: Clean up wakelocks on error paths

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-14 09:08:53 -07:00