Re: [PATCH] power: twl4030_charger: clear IRQs after handling them
From: Nishanth Menon
Date: Tue May 06 2014 - 20:24:56 EST
On 16:00-20140425, Felipe Balbi wrote:
> On Fri, Apr 25, 2014 at 03:58:10PM -0500, Nishanth Menon wrote:
> > On 04/16/2014 11:35 AM, Tony Lindgren wrote:
> > > * Felipe Balbi <balbi@xxxxxx> [140416 08:18]:
> > >> TRM says we *must* write 1 to each bit we're handling
> > >> in order to clear the IRQ status and bring IRQ line
> > >> low. This patch implements that.
> > >>
> > >> Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> > >> ---
> > >>
> > >> Russell, I don't have HW to test, but this should
> > >> solve the problem you saw when not using battery
> > >> with Zoom board. Let me know if it doesn't.
> > >
> > > BTW, looks like we're enabling BCI automatically in twl4030.dtsi
> > > while the legacy booting does not have TWL_COMMON_PDATA_BCI
> > > enabled for LDP. Anyways, for LDP BCI should be enabled for
> > > sure, that's the only way to power at least the earlier LDP
> > > revisions.
> > >
> > I picked up https://patchwork.kernel.org/patch/4002371/ for testing.
> >
> > Unfortunately, it does not seem to work in my tests:
>
> alright, I'll have a look after I get this other issue out of the way.
> Probably not until next week.
I dug a bit more into this earlier today. It makes a little sense
considering that TWL4030 was created in a world where mobile devices did
not consider battery was hot pluggable entity..
Long story short:
a) the BCI interrupt status register is read-on-clear (see
drivers/mfd/twl4030-irq.c set_cor is set to true for bci) - so the patch
https://patchwork.kernel.org/patch/4002371/ is practically a NOP.
b) BATSTS is a result of MADC monitoring the thermistor and is
continually generated. I tried a bunch of tricks that I could come up
with to try to do a hotplug support, but either we have infinite
interrupts (due to regeneration of event) or I loose detection ability.
So, to keep things simple I created the following patch that seems to
handle:
a) no battery connected, powered off charger - bci disabled
b) battery connected, powered off charger - bci active
c) battery connected, no charger - bci active
note: if battery was connected, and booted and we hotplug battery out,
we still have the spam of messages.. that is a seperate patch
(basically do an orderly shutdown - I cant think of anything else we
could possible do there)
Let me know your views.. if this approach is fine, I can post out formal
patches for the same.
-----8<----