Re: [PATCH] usb: common: usb-conn-gpio: Register charger

From: Paul Cercueil
Date: Tue Jan 14 2020 - 10:16:05 EST


Hi Chunfeng,

Le jeu., janv. 9, 2020 at 10:27, Chunfeng Yun <chunfeng.yun@xxxxxxxxxxxx> a écrit :
Hi Paul,

On Wed, 2020-01-08 at 14:26 -0300, Paul Cercueil wrote:
Hi Greg,


Le mer., janv. 8, 2020 at 17:53, Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx> a écrit :
> On Tue, Jan 07, 2020 at 01:29:01AM +0100, Paul Cercueil wrote:
>> Register a power supply charger, whose online state depends on
>> whether
>> the USB role is set to device or not.
>
> That says _what_ you are doing, but I have no idea _why_ you want to
> do
> this.
>
> What is this going to cause to have happen? What new userspace api is
> going to result? What will a user do with this?

This is useful when the USB role is the only way to know if the device
is charging from USB.
There is no charger IC on your platform?

Correct.



The API is the standard power supply charger API, you get a
/sys/class/power_supply/xxx/online node which tells you the state of
the charger.

The sole purpose of this is to give userspace applications a way to
know whether or not the charger is plugged.

> Is this going to always show up, no matter if the role is not even
> relevant for a power supply?

I guess it'd always show up, yes. In which case would the role not be
relevant for a power supply?
Do you also need it if the platform don't have battery?

I guess not. Would you prefer it to be disabled by default? If so, what would be the way to have it enabled? A flag in devicetree?


Is gpio-b-connector not always used for
OTG connectors?
It also supports device only mode, usually uses vBus pin to
enable/disable controller

Yes, that would work too. The problem would be a host-only gpio-b-connector.

-Paul