[JiaYu S3 Questions & Answers] sniffer:
I've browsed some more through the Mediatek sources in https://github.com/Vgdn1942/kernel-3.10.72 but I'm not a day-to-day android/linux kernel dev so I'm probably going a bit off road here, nevertheless...

MT6752 should theoretically support USB Battery Charging Specification v1.1. from what I gathered from sources and some tech/spec docs from Mediatek.

MT6752 works with a PMIC module MT6325/MT6311 or similar, which is responsible, among many other, for charging and USB connection (if I'm not mistaken).

Now these are the BC1.1 functions available in the sources:

drivers/misc/mediatek/mach/mt6752/include/mach/upmu_common.h

drivers/misc/mediatek/power/mt6752/upmu_common.c

If these are available (if Jiayu S3 kernel uses these), we can detect any USB mode that conforms to BC v1.1. Mediatek already provided an algo that detects the available ACA (Accessory Charger Adapter) modes in:

drivers/misc/mediatek/power/mt6752/pmic_otg_type_dec.c

This in not complete as it does not check for ID_FLOAT (peripherial) and ID_GR (plain OTG/Host mode) but these are already supported in the drivers. As for the other modes available here is the description for the MSM kernel driver I've found on the Internet:

The file above gives us ID_A, ID_B, ID_C detection. Mediatek folks recognized also ACA_DOCK mode. This ACA mode detection mechanism will give us three (four if we count ACA_DOCK) additional possible operation modes controlled by the ID_PIN's resistance value (specified in the BC 1.1+ spec).

Along with USB mode we must properly detect the USB power source (charger). Proper Downstream Port detection between: Standard Downstream Port and Charging Downstream Port (one of DCP, CDP, ACA-Dock or ACA) must be in place.

pmic_chr_type_det.c can give us charger type detection (mainly STANDARD_HOST vs CHARGING_HOST) - as a side note (full list of supported chargers in charging.h).

All of the above should be hooked into mt_usb.c somehow IMHO (There is also the usb20 driver subdirectory, which contains similar usb handling code as mu3d driver).

I think there are most pieces of the puzzle solved. Just a matter to hook it up in the proper place and test. There rather won't be support for as many modes as on Samsung devices (ex. Audio Dock, without digging deeper), but host+charging (ID_A ?) is on the list..

---

battery drivers' kal_uint32 is_chr_det(void) is used throught the code to detect if charger is present. It calls mt6325_upmu_get_rgs_chrdet() so it seems that mt6325 is present after all in Jiayu.

I've found a quick hack for a MSM driver to force ID_A mode: https://github.com/ziddey/mako/commit/a78f59835568ffde6f1242f36be9a8b8c8d99da4

Couple of questions though - maybe someone can answer:

- what is DISO mode - seems to be triggered by CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT, is that dual input charging a mode where all four (D+/D- also) USB cables are used for charging? This should be the case IMHO

- what is PMIC AUXADC?

- is battery driver bq24261 used for Jiayu S3? should be enabled by MTK_BQ242621_SUPPORT configure option

- are any of these:

CONFIG_USB_MTK_HDRC

CONFIG_USB_MU3D_DRV

CONFIG_POWER_EXT

CONFIG_MTK_POWER_EXT_DETECT

CONFIG_MTK_PUMP_EXPRESS_SUPPORT

CONFIG_MTK_PUMP_EXPRESS_PLUS_SUPPORT

enabled?

Can any of the devs have a looksie?