Re: bq24735 charger and ac-detect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2016-12-15 15:04, Jon Hunter wrote:
> 
> On 15/12/16 12:04, Peter Rosin wrote:
> 
> ...
> 
>>>                               The only other option is to add another
>>> property called something like 'ti,ac-detect-override-pol' to specify
>>> the polarity you want.
>>
>> How is that helping? It's no different that just saying active-low for
>> boards that do not invert ACOK (which is what I currently do in my dts,
>> but I hate doing it since it doesn't match dt docs and is therefore just
>> wrong).
> 
> By providing a means for the user to specify the polarity for their
> board. Of course the documentation would need to be updated as well. I
> think all solutions will be ugly if we need to preserve compatibility.
> 
>>> To be honest, I am not sure how this type of thing is normally handled.
>>> So probably best to put together a patch with whatever option you feel
>>> best and explain why this is needed and see what the dev-tree folks say.
>>
>> I suspect that at the end of the day documentation is less important than
>> regressions. But if there are more than one implementation of the same
>> spec and Linux is not following it, it's kind of harsh to change the spec
>> to match Linux. I doubt that there are any other users in this case though,
>> but what do I know?
>>
>> I'll send a patch re-documenting ti,ac-detect-gpios to specify AC absence
>> instead of AC presence, let's see what the dt people thinks...
> 
> Fine with me and of course that works for Tegra, but how does that
> ultimately help you? How do you tell the driver to use active-high
> instead of the default which is not active-low?

Oh, you didn't know that gpiod_set_value/gpiod_get_value takes care of
active high/low automatically. That explains the disconnect.

If I have this in my device tree:

bq24735-charger@9{
	compatible = "ti,bq24735";
	ti,ac-detect-gpios = <&ioexp 3 GPIO_ACTIVE_LOW>;
};

and do
	gpiod_get(dev, "ti,ac-detect", GPIOD_IN);

then gpiod_get_value() on that gpio descriptor will return 1 (as in
active) when the signal is low.

You have to use gpiod_get_raw_value to see what's on the actual line.
But that is almost always not interesting, the reasons for that should
be obvious from this discussion...

So, I lie and say GPIO_ACTIVE_LOW so that gpiod_get_value returns 0 when
AC is there (signal is high), and the driver inverts that and gets that
AC is present and starts charging.

Cheers,
peda

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux