Re: [PATCH v18 0/4] Introduce usb charger framework to deal with the usb gadget power negotation

Peter Chen
2016-11-09T01:33:26Z

On Wed, Nov 09, 2016 at 07:38:36AM +1100, NeilBrown wrote:
> On Tue, Nov 08 2016, Peter Chen wrote:
>
> > On Thu, Nov 03, 2016 at 12:25:42PM +1100, NeilBrown wrote:
> >>
> >>
> >>
> >> 2/ Change all usb phys to register an extcon and to send appropriate
> >> notifications. Many already do, but I don't think it is universal.
> >> It is probable that the extcon should be registered using common code
> >> instead of each phy driver having its own
> >> extcon_get_edev_by_phandle()
> >> or whatever.
> >> If the usb phy driver needs to look at battery charger registers to
> >> know what sort of cable was connected (which I believe is the case
> >> for the chips you are interested in), then it should do that.
> >
> > Not only USB PHY to register an extcon, but also for the drivers which
> > can detect USB charger type, it may be USB controller driver, USB type-c
> > driver, pmic driver, and these drivers may not have an extcon device
> > since the internal part can finish the vbus detect.
>
> Can you point to an example of the sort of hardware/driver you are
> referring to, preferably in the mainline kernel. Concrete examples make
> this sort of thing much easier to understand.
>

Eg, the nxp/fsl USB charger detector part, the register used to begin
the detection is in USB controller register region, and we also need to
use controller register to pull up dp to begin the secondary detect.

Since there is no USB charger framework, the code is not in mainline.
It finished an upstream version based on patch set in this thread [1]

Some SoCs uses chipidea IP doesn't need to use extcon to detect plugging
in/out, since the vbus pin connects to SoC's vbus pin.

The pmic has abilities to charger detection, eg, drivers/mfd/axp20x.c
and drivers/extcon/extcon-axp288.c.

> I think I would argue that if some piece of hardware can detect the USB
> charger type, then that piece of hardware is part of the "USB PHY", even
> if the hardware manufacturer has chosen to partition the register set in
> a way which doesn't make that obvious.

I agree with that the charger detect hardware is in the USB PHY part,
but some USB PHY's control is integrated in USB controller (eg, some
controller uses drivers/usb/phy/phy-generic.c as its PHY driver), so
we have to use controller register to finish some PHY function, eg
charger detection.

[1] https://www.spinics.net/lists/linux-usb/msg139425.html

--

Best Regards,
Peter Chen