We have a custom board with i.MX6DualLite running android which seems to work well. We are having problems finding out how much current we are allowed to draw from the USB port during USB charging. We plan to use an external circuit for the actual charging, but the device driver for the charging circuit needs input regarding which type of port the USB cable is connected to and how much current we are allowed to draw from this port.
The i.MX6 reference manual describes USB port detection in chapter 65 (Universal Serial Bus 2.0 Integrated PHY) and the actual algorithm for finding which type of port is connected is described in chapter 188.8.131.52 (charger detection software flow). This algorithm is implemented in the file kernel/drivers/usb/gadget/imx_usb_charger.c and we have found this algorithm to work well when testing USB port detection.
The algorithm decides that the connected USB port is one of the following:
* Standard Downstream Port (SDP)
* Charging Downstream Port (CDP)
* Dedicated Charging Port (DCP)
The following is a bit simplified, but the Battery Charging Specification (http://www.usb.org/developers/devclass_docs/BCv1.2_070312.zip) states how much current a device is allowed to draw from a specific type of port:
* SDP: 100mA when not configured and 500mA when configured.
* CDP/DCP: 1500mA without having to be configured or follow the rules of suspend.
We plan to draw at most 900mA which should be ok for both CDP and DCP, but for the SDP we need to draw either 100mA or 500mA depending on if the port is configured or not. The port gets configured after a negotiation between the connected USB port and the i.MX6 USB controller. The actual negotiation is (somewhat simplified) described at http://www.lvr.com/usbcenum.htm
From what I can see there is no way to get this information from the available i.MX6 registers so we don't know whether we are allowed to draw 100mA or 500mA.
Any input on how to get the amount of current being allowed to draw from a connected USB port would be greatly appreciated?