public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Phil Reid
	<preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3 4/5] pinctrl: mcp23s08: configure irq polarity using irq data
Date: Tue, 21 Nov 2017 16:21:42 +0100	[thread overview]
Message-ID: <20171121152142.zg3r57gl2kenjwgi@earth> (raw)
In-Reply-To: <c191a9d6-3ebb-e95b-7342-aa18598ddf2b-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 5292 bytes --]

Hi,

On Tue, Nov 21, 2017 at 10:46:29PM +0800, Phil Reid wrote:
> G'day Sebastian,
> 
> On 21/11/2017 21:34, Sebastian Reichel wrote:
> > Hi,
> > 
> > On Tue, Nov 21, 2017 at 04:21:30PM +0800, Phil Reid wrote:
> > > The irq polarity is already encoded in the irq config. Use that to
> > > determine the polarity for the mcp32s08 irq output instead of the
> > > custom microchip,irq-active-high property.
> > > 
> > > Signed-off-by: Phil Reid <preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
> > > ---
> > 
> > I don't like, that we use the flags for configuring the host
> > interrupt input and the mcp23xxx interrupt output. Usually
> > when the interrupt line has an inverter on it, board DTS files
> > just toggle the interrupts polarity. This will not work with
> > this patch applied. We would need to explicitly add an inverter
> > in the interrupt line, which is completely different to how its
> > implemented everywhere else (I know at least some Tegra devices
> > have implicit inverters on interrupt lines).
> > 
> > In case this is really wanted, this patch and the first patch
> > should be merged to avoid temporarily exposing the splitted
> > logic.
> > 
> Thanks for looking at the series.
> 
> Yes I understand where your coming from. And that's exactly what I
> was trying to do in v2. I have 2 of these devices with open drain output
> that is feed to an inverter. So active low output from devices and irq
> consumer is active high input.
> 
> However Linux wasn't a fan of the property and wanted it gone.

I guess s/Linux/Linus Walleij/?

> He suggested we need a "inverter" device to allow for that in the
> device tree. I haven't got my head around how to do that thou.

Just to be on the same term, we are talking about these two variants:

--------------------------------------------
gpio: host-gpio {
    random-properties;
}

inv: line-inverter {
    /*
     * configure the gpio controller input to be active low
     * and the inverter interrupt output to be active low
     */
    interrupts = <&gpio ACTIVE_LOW>;
};

mcp23xxx {
    random-properties;

    /*
     * configure the chip interrupt output to be active high 
     * and the inverter interrupt input to be active high
     */
    interrupts = <&inv ACTIVE_HIGH>;
}
--------------------------------------------

versus

--------------------------------------------
gpio: host-gpio {
    random-properties;
}

mcp23xxx {
    random-properties;

    /* configure host interrupt input pin to be active low */
    interrupts = <&gpio ACTIVE_LOW>;

    /* configure chip interrupt output pin to be active high */
    microchip,irq-active-high;
}
--------------------------------------------

I think this is something, that Rob should comment on. Obviously at
least in the mainline kernel nobody implemented the first solution
(since there is no fitting interrupt-invert driver), but there are
a few instances of the second variant. On the other hand the first
solution describes the hardware more detailed.

> And if someone is relying on that implicit behaviour are we allowed
> to break things? Probably ok with this one as it's currently not possible
> due to code patch 1 removes.
> 
> If we need to model the invert to get the patches accepted I look into that.
> I don't actually need it for my system as I can set open-drain with overrides
> the active-high control on this device, while have active high irq consumer.
> :)

IMHO the explicit line-inverter is a bit over-engineered and
implicit line-inverter is enough, but I'm fine with both solutions.
I think the DT binding maintainers should comment on this though,
since it's pretty much a core decision about interrupt specifiers.

-- Sebastian

> > >   drivers/pinctrl/pinctrl-mcp23s08.c | 11 ++++++++---
> > >   1 file changed, 8 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
> > > index 8ff9b77..6b3f810 100644
> > > --- a/drivers/pinctrl/pinctrl-mcp23s08.c
> > > +++ b/drivers/pinctrl/pinctrl-mcp23s08.c
> > > @@ -773,6 +773,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
> > >   	bool mirror = false;
> > >   	bool irq_active_high = false;
> > >   	bool open_drain = false;
> > > +	u32 irq_trig;
> > >   	mutex_init(&mcp->lock);
> > > @@ -863,9 +864,13 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
> > >   	mcp->irq_controller =
> > >   		device_property_read_bool(dev, "interrupt-controller");
> > >   	if (mcp->irq && mcp->irq_controller) {
> > > -		irq_active_high =
> > > -			device_property_read_bool(dev,
> > > -					      "microchip,irq-active-high");
> > > +		if (device_property_present(dev, "microchip,irq-active-high"))
> > > +			dev_warn(dev,
> > > +				 "microchip,irq-active-high is deprecated\n");
> > > +
> > > +		irq_trig = irqd_get_trigger_type(irq_get_irq_data(mcp->irq));
> > > +		if (irq_trig == IRQF_TRIGGER_HIGH)
> > > +			irq_active_high = true;
> > >   		mirror = device_property_read_bool(dev, "microchip,irq-mirror");
> > >   		open_drain = device_property_read_bool(dev, "drive-open-drain");
> > > -- 
> > > 1.8.3.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2017-11-21 15:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21  8:21 [PATCH v3 0/5] pinctrl: mcp32s08: add open drain config for irq Phil Reid
2017-11-21  8:21 ` [PATCH v3 2/5] dt-bindings: pinctrl: mcp23s08: add documentation for drive-open-drain Phil Reid
2017-11-21 12:56   ` Sebastian Reichel
     [not found]   ` <1511252491-79952-3-git-send-email-preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
2017-11-21 18:37     ` Rob Herring
     [not found] ` <1511252491-79952-1-git-send-email-preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
2017-11-21  8:21   ` [PATCH v3 1/5] pinctrl: mcp23s08: remove hard coded irq polarity in irq_setup Phil Reid
2017-11-21 13:17     ` Sebastian Reichel
2017-11-21  8:21   ` [PATCH v3 3/5] pinctrl: mcp23s08: add open drain configuration for irq output Phil Reid
2017-11-21 12:57     ` Sebastian Reichel
2017-11-21  8:21   ` [PATCH v3 4/5] pinctrl: mcp23s08: configure irq polarity using irq data Phil Reid
2017-11-21 13:34     ` Sebastian Reichel
2017-11-21 14:46       ` Phil Reid
     [not found]         ` <c191a9d6-3ebb-e95b-7342-aa18598ddf2b-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org>
2017-11-21 15:21           ` Sebastian Reichel [this message]
2017-11-21 15:38             ` Phil Reid
2017-11-21 16:04             ` Alexander Stein
2017-11-21 16:30               ` Sebastian Reichel
2017-11-30 14:21             ` Linus Walleij
2017-11-30 15:50               ` Marc Zyngier
2017-12-01  8:38                 ` Linus Walleij
2017-11-30 14:17     ` Linus Walleij
2017-11-21  8:21 ` [PATCH v3 5/5] dt-bindings: pinctrl: deprecate 'microchip,irq-active-high' property Phil Reid
2017-11-21 18:37   ` Rob Herring

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=20171121152142.zg3r57gl2kenjwgi@earth \
    --to=sre-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=preid-qgqNFa1JUf/o2iN0hyhwsIdd74u8MsAO@public.gmane.org \
    --cc=robh+dt-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