[Android General] tal.aloni:
I was interested in getting USB OTG + Charging to work, and discovered that an "Accessory charging adaptor" was designed to serve such a purpose, the adapter is described in "Battery Charging Specification" Revision 1.2.

Here is a simple diagram of such an adapter (this design does not fully comply to the specifications):

[IMG="USB ACA Cable"]http://vm1.duckdns.org/public/USB_ACA/USB_ACA_CABLE.png[/IMG]

The code in 'drivers\usb\otg\msm_otg.c' suggests that the device can operate in the following 3 modes:

ID_FLOAT: Configure device to act as peripheral and allow charging if VBUS is present, else move it to LPM (low power mode).

ID_GROUND: Configure device to act as host and supply VBUS.

ID_A: Configure device to act as host and don't supply VBUS. In this state the device can charge as well.

So I built the adapter, and compiled my XT1032 kernel with CONFIG_USB_MSM_ACA,

unfortunately, (as far as I can tell) the hardware cannot detect the 124K resistor (so it does not automatically switch to ID_A).

Plan B:

It is possible however to modify 'msm_otg.c' and force ID_A (OTG + Charging mode), I was able to find an automatic method that works for me:

If you connect the ACA cable to a power source and a peripheral device and THEN connect your phone, the adapter will be detected as USB_PROPRIETARY_CHARGER (a dedicated charging port shorts the D+ and D- pins, and a flash drive does not),

so I simply assumed that USB_PROPRIETARY_CHARGER should activate ID_A.

I tested the patch (attached) using two Moto G XT1032 phones:

One manufactured in 2013-12-19 and have BOOTLOADER = 0x3 (with fastboot 41.13)

The other was manufactured in 2015-02-13 and have BOOTLOADER = 0x2 (with fastboot 41.18).

(the latest BOOTLOADER version is 0x4 with fastboot 41.1A, you can read the BOOTLOADER fuse using 'fastboot oem read_sv')

Other than the bootloader and MF date, the phones are Identical, same kernel, same system.

oddly, each behaved differently with the modified kernel and ACA cable:

With both phones, most USB peripheral devices were able to work when connected through a cheap (unpowered) USB 2.0 hub, this is the only hub out of the 3 tested that worked properly with the ACA cable.

The newer phone (but not the older one) had connectivity issues when devices were connected directly to the ACA cable.

To sum it up: I was able to use USB devices and charge at the same time using this patch.

maybe using two power adapters would have solved some of the minor issues I encountered (e.g. I could see the USB hub LED brightness fluctuate in some cases - it's not supposed to happen)

p.s. Using this patch, the phone exits ID_A mode once the charger is disconnected, and will provide power to OTG devices, so the patch does not interfere with the regular operation of the phone (unless you happen to have a real "USB_PROPRIETARY_CHARGER").

[IMG="Charging Moto G and OTG at the same time"]http://vm1.duckdns.org/public/USB_ACA/OTG_Charge-Picture.jpg[/IMG]

Components for the adapter:

USB 2.0 Male To Female Extension Cable

124K Ohm resistor (optional)

Micro USB Male to Female Extension Cable

Update:

I have bought the Acasis H027 and together with my patch I can use USB peripheral devices (connected to the hub) + charge at the same time.

p.s. USB Device Info shows the connected USB devices