Re: extcon: sm5502: USB-HOST (OTG) detection not working

From: Stephan Gerhold
Date: Fri Feb 14 2020 - 08:11:08 EST


Hi Chanwoo,

On Fri, Oct 11, 2019 at 04:50:21PM +0200, Stephan Gerhold wrote:
> Hi Chanwoo,
>
> after getting interrupts working on my Samsung Galaxy A5 (2015),
> I am now trying to make the extcon device detect USB-HOST=1
> when I plug in an USB OTG adapter.
>
> At the moment, the driver can sucessfully detect:
> - USB=1 + SDP=1 when I detect the phone to a PC
> - DCP=1 when I connect it to an AC charger
> but it does not set USB-HOST=1 when I connect the USB OTG adapter.
>
> It seems to be a problem in the sm5502 driver, since I do get an
> SM5502_IRQ_INT1_ATTACH interrupt when I plug in the USB OTG adapter.
>
> In this case, SM5502 reports:
> SM5502_REG_ADC = 0x00 (SM5502_MUIC_ADC_GROUND)
> SM5502_REG_DEV_TYPE1 = 0x80 (SM5502_REG_DEV_TYPE1_USB_OTG_MASK)
>
> However, at the moment the sm5502 driver ignores all attach events with
> SM5502_REG_ADC == SM5502_MUIC_ADC_GROUND:
>
> /*
> * If ADC is SM5502_MUIC_ADC_GROUND(0x0), external cable hasn't
> * connected with to MUIC device.
> */
> cable_type = adc & SM5502_REG_ADC_MASK;
> if (cable_type == SM5502_MUIC_ADC_GROUND)
> return SM5502_MUIC_ADC_GROUND;
>
> However, I definitely have a cable attached in this case...
>
> The sm5502 driver seems to expect SM5502_REG_ADC == SM5502_MUIC_ADC_OPEN.
> Any idea why my hardware reports ADC_GROUND for the USB OTG adapter
> instead of ADC_OPEN?
>
> Confusingly, the driver used in the original downstream kernel of
> the Samsung Galaxy A5 [1] calls ADC = 0x00 "ADC_OTG" instead of
> "ADC_GROUND".
> So getting ADC = 0x00 may not be entirely unexpected here...
>
> Thanks in advance,
> Stephan
>
> [1]: https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/SM-A500FU/drivers/misc/sm5502.c#L195

This mail is quite old now but I am still confused by this.
Any idea what could be wrong here?

I was not able to find any datasheet for SM5502 unfortunately...

Thanks,
Stephan