devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Reid <preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
To: Karl-Heinz Schneider
	<karl-heinz-X5L7DgJ4l23oE99TX8zNy7NAH6kLmebB@public.gmane.org>,
	Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Dmitry Eremin-Solenikov
	<dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	andrea.merello-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH 1/1] power: sbs-manager: Add interrupt support and battery detect gpios
Date: Mon, 1 Aug 2016 14:52:16 +0800	[thread overview]
Message-ID: <ade6f7b9-dbaf-fd45-fd82-c3d69125ca8c@electromag.com.au> (raw)
In-Reply-To: <1469973873.5299.9.camel-X5L7DgJ4l23oE99TX8zNy7NAH6kLmebB@public.gmane.org>

On 31/07/2016 22:04, Karl-Heinz Schneider wrote:
> Am Donnerstag, den 28.07.2016, 10:45 -0500 schrieb Rob Herring:
>> On Thu, Jul 28, 2016 at 4:01 AM, Phil Reid <preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
>> wrote:
>>> On 28/07/2016 10:11, Phil Reid wrote:
>>>> G'day Karl / Rob,
>>>> On 28/07/2016 05:08, Karl-Heinz Schneider wrote:
>>>>> Am Mittwoch, den 27.07.2016, 09:46 -0500 schrieb Rob Herring:
>>>>>> On Mon, Jul 25, 2016 at 03:50:03PM +0800, Phil Reid wrote:
>>>>>>> This patch added irq support for the SMBALERT pin and
>>>>>>> notification of
>>>>>>> the battery removal / insertion. The sbs manager would
>>>>>>> typically be
>>>>>>> used with the corresponding sbs-battery driver that
>>>>>>> currently uses a
>>>>>>> gpio input for battery presence and interrupt. To remain
>>>>>>> compatible
>>>>>>> with
>>>>>>> that existing driver this patch implements GPIO inputs with
>>>>>>> interrupt
>>>>>>> support. IRQ masking is performed in software as the
>>>>>>> hardware does not
>>>>>>> support masking of notifications from each battery.
>>>>>>> In addition a power_supply change notification is generated
>>>>>>> for the sbs
>>>>>>> manager device when the AC present flag is changed.
>>>>>>> Tested with LTC1760 and dual sbs compatible batteries.
>>>>>>
>>>>>> Please don't submit a binding and immediately turn around and
>>>>>> add to it.
>>>>>> While that is often preferred for drivers or kernel features,
>>>>>> bindings
>>>>>> should be complete as possible and not evolve. Combine this
>>>>>> with your
>>>>>> previous patch add sbs-mgr if that hasn't been accepted yet.
>>>> That was from Karl. I'm happy to have this combined if he is.Me
>> Indeed it was. Still, it should be combined. You can leave the driver
>> implementation as multiple patches, just combine all the binding to a
>> single patch by itself.
> Will do that.
>>>>>> IMO, the sbs-bat should just be a interrupt and making it and
>>>>>> this
>>>>>> binding a GPIO is overkill. Since batteries nodes using this
>>>>>> will be
>>>>>> new, there's no reason the driver can't be updated to support
>>>>>> interrupts.
>>> I did consider this and didn't go that way as:
>>> 1) the current sbs-battery driver didn't support it.
>>> 2) Then there's also the problem of reporting  the presence of the
>>> battery
>>> to the battery driver.
>>> Without the GPIO support you resort to polling and looking for a
>>> NACK. Which
>>> didn't seem that nice.
>> The ability to read the current irq signal state with the irq api
>> would be nice. Of course you can't really count on being able to on
>> all irqs. Anyway, we shouldn't really design the binding around
>> kernel
>> limitations.
>>
>> As I understand how SMBALERT works, you have to poll the devices
>> anyway to determine which device is asserting the irq and to ack the
>> irq. Of course, here you are doing point to point connections, but
>> you
>> still need to know which batteries are present by reading the sbs-mgr
>> registers.
> The more interesting point for me is, that SMBALERT seems to provide an
> easy to use driver side interface. The code Registering the IRQ would
> vanish...
> Anyways I'm not very familiar with Linux IRQ handling, so I will follow
> your advise.

Just had a look at driver/i2c/i2c-smbus.c
This appears to be a generic driver to handle smbalert. Currently used by the i2c-parport driver.
Doesn't look to support device trees at the moment thou.
Patch series "RFC: I2C: i2c-smbus: add device tree support" from Andrea Merello looked to be adding generic support for it.
https://lkml.org/lkml/2016/4/13/157
Not sure where that's got to thou.

>>
>> Wouldn't switching the driver to level irq allow you to get the state
>> immediately without a gpio read? After all, the gpio read and irq
>> handler are reading the same register.
If it's asserted continuously how do you stop the irq firing all the time?
I guess you could register a high and low level irq and disable them alternatively.
Unless I'm missing something.

Keeping the gpio functionality also allows the battery detect to work without the irq
connected to the sbsm thru polling.

-- 
Regards
Phil Reid


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

  parent reply	other threads:[~2016-08-01  6:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-25  7:50 [PATCH 0/1] power: sbs-manager: Add interrupt support and battery detect gpios Phil Reid
2016-07-25  7:50 ` [PATCH 1/1] " Phil Reid
2016-07-27 14:46   ` Rob Herring
2016-07-27 21:08     ` Karl-Heinz Schneider
2016-07-28  2:11       ` Phil Reid
2016-07-28  9:01         ` Phil Reid
2016-07-28 15:45           ` Rob Herring
2016-07-31 14:04             ` Karl-Heinz Schneider
     [not found]               ` <1469973873.5299.9.camel-X5L7DgJ4l23oE99TX8zNy7NAH6kLmebB@public.gmane.org>
2016-08-01  6:52                 ` Phil Reid [this message]
     [not found]                   ` <ade6f7b9-dbaf-fd45-fd82-c3d69125ca8c-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
2016-08-23 19:58                     ` Karl-Heinz Schneider
     [not found]                       ` <1471982300.5080.17.camel-X5L7DgJ4l23oE99TX8zNy7NAH6kLmebB@public.gmane.org>
2016-08-24  1:37                         ` Phil Reid

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ade6f7b9-dbaf-fd45-fd82-c3d69125ca8c@electromag.com.au \
    --to=preid-qgqnfa1juf/o2in0hyhwsidd74u8msao@public.gmane.org \
    --cc=andrea.merello-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=karl-heinz-X5L7DgJ4l23oE99TX8zNy7NAH6kLmebB@public.gmane.org \
    --cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).