From: Stephan Gerhold <stephan@gerhold.net>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
linux-iio <linux-iio@vger.kernel.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>, Hans de Goede <hdegoede@redhat.com>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
<devicetree@vger.kernel.org>, Hans de Goede <hdegoede@redhat.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,"
<~postmarketos/upstreaming@lists.sr.ht>,
Nikita Travkin <nikita@trvn.ru>
Subject: Re: [PATCH 3/4] iio: accel: bmc150: Make it possible to configure INT2 instead of INT1
Date: Mon, 19 Jul 2021 20:36:51 +0200 [thread overview]
Message-ID: <YPXGQxPPID1SHOUO@gerhold.net> (raw)
In-Reply-To: <CAHp75VcZDSL5u2bP_ZFySmk7cPkHRycyA-+gMqSVWCpgFXhn7Q@mail.gmail.com>
On Mon, Jul 19, 2021 at 09:05:48PM +0300, Andy Shevchenko wrote:
> On Mon, Jul 19, 2021 at 8:29 PM Stephan Gerhold <stephan@gerhold.net> wrote:
> >
> > On Mon, Jul 19, 2021 at 07:19:05PM +0300, Andy Shevchenko wrote:
> > > On Mon, Jul 19, 2021 at 6:11 PM Stephan Gerhold <stephan@gerhold.net> wrote:
> > > > On Mon, Jul 19, 2021 at 06:01:01PM +0300, Andy Shevchenko wrote:
> > > > > On Mon, Jul 19, 2021 at 5:07 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> > > > > > On Mon, Jul 19, 2021 at 1:26 PM Stephan Gerhold <stephan@gerhold.net> wrote:
>
> ...
>
> > > > > > > #include <linux/acpi.h>
> > > > > > > +#include <linux/of_irq.h>
> > > > > > (...)
> > > > > > > + irq_info = bmc150_accel_interrupts_int1;
> > > > > > > + if (irq == of_irq_get_byname(dev->of_node, "INT2"))
> > > > > > > + irq_info = bmc150_accel_interrupts_int2;
> > > > > >
> > > > > > This looks a bit DT-specific, but I don't see that ACPI has
> > > > > > named IRQs so I don't know what to do about it either.
> > > > >
> > > > > Yeah, we only have so far the (de facto) established way of naming
> > > > > GPIO based IRQs, and not IOxAPIC ones.
> > > > >
> > > > > > What does platform_get_irq_byname() do on ACPI systems?
> > > > >
> > > > > See above.
> > > > >
> > > > > > If there is no obvious fix I would leave it like this until the
> > > > > > first ACPI used needing this comes along, but I think maybe
> > > > > > Andy has suggestions.
> > > > >
> > > > > The platform_get_irq_byname() should do something similar that has
> > > > > been done in platform_get_irq() WRT ACPI.
> > > > > Here for sure the platform_get_irq_byname() or its optional variant
> > > > > should be used.
> > > >
> > > > I don't think there is a platform device here, we only have the
> > > > i2c_client or spi_device. That's why I didn't use
> > > > platform_get_irq_byname(). :)
> > > >
> > > > Is there something equivalent for I2C/SPI drivers?
> > >
> > > Not yet. You probably need to supply some code there to allow
> > > multi-IRQ devices (in resource provider agnostic way).
> > >
> > > You need to provide fwnode_get_irq_byname() to be similar with
> > > https://elixir.bootlin.com/linux/latest/source/drivers/base/property.c#L1010
> > >
> > > Then use it in the drivers.
> > >
> > > And/or integrate into frameworks somehow (something in between the
> > > lines: https://elixir.bootlin.com/linux/latest/source/drivers/i2c/i2c-core-base.c#L461).
> > >
> >
> > Well, I don't think anyone has an ACPI use case for this right now so
> > it's probably better if this is done by someone who actually needs this
> > and can test it somewhere. :)
> >
> > I actually just "copied" this approach from some other IIO drivers where
> > this is done similarly (and additionally checked the source code to make
> > sure this won't break anything for ACPI platforms).
>
> I see in today's Linux Next snapshot:
>
> drivers/iio/accel/fxls8962af-core.c:774: irq =
> of_irq_get_byname(of_node, "INT2");
> drivers/iio/accel/mma8452.c:1616: irq2 =
> of_irq_get_byname(client->dev.of_node, "INT2");
> drivers/iio/gyro/fxas21002c_core.c:834: irq1 = of_irq_get_byname(np, "INT1");
> drivers/iio/imu/adis16480.c:1265: irq =
> of_irq_get_byname(of_node, adis16480_int_pin_names[i]);
> drivers/iio/imu/bmi160/bmi160_core.c:655: irq =
> of_irq_get_byname(of_node, "INT1");
> drivers/iio/imu/bmi160/bmi160_core.c:661: irq =
> of_irq_get_byname(of_node, "INT2");
>
> I believe we may stop distributing this and actually start using a
> common API. I don't want this to be spread again over all IIO. Btw, I
> have LSM9DS0, which supports two INT pins for IMU and currently it
> uses hard coded pin mapping.
>
Hm, I'm not quite sure how to implement this. Could you prepare a patch
that would implement such a common API? I would be happy to test it for
the device tree and make use of it in this patch.
To be honest, I mainly implemented support for the interrupt-names
because Jonathan mentioned this would be nice to have [1] and it kind of
fit well together with the BMC156 patch that needs the INT2 support.
I actually just use the if (data->type == BOSCH_BMC156) part from
PATCH 4/4 which does not depend on of_irq_get_byname().
Thanks,
Stephan
[1]: https://lore.kernel.org/linux-iio/20210611185941.3487efc6@jic23-huawei/
next prev parent reply other threads:[~2021-07-19 21:56 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-19 11:21 [PATCH 0/4] iio: accel: bmc150: Add support for INT2 and BMC156 Stephan Gerhold
2021-07-19 11:21 ` [PATCH 1/4] dt-bindings: iio: accel: bma255: Add interrupt-names Stephan Gerhold
2021-07-19 13:57 ` Linus Walleij
2021-07-24 16:00 ` Jonathan Cameron
2021-07-19 11:21 ` [PATCH 2/4] dt-bindings: iio: accel: bma255: Add bosch,bmc156_accel Stephan Gerhold
2021-07-19 13:58 ` Linus Walleij
2021-07-24 16:03 ` Jonathan Cameron
2021-07-29 19:10 ` Rob Herring
2021-07-29 19:10 ` Rob Herring
2021-07-19 11:21 ` [PATCH 3/4] iio: accel: bmc150: Make it possible to configure INT2 instead of INT1 Stephan Gerhold
2021-07-19 14:07 ` Linus Walleij
2021-07-19 15:01 ` Andy Shevchenko
2021-07-19 15:10 ` Stephan Gerhold
2021-07-19 16:19 ` Andy Shevchenko
2021-07-19 17:26 ` Stephan Gerhold
2021-07-19 18:05 ` Andy Shevchenko
2021-07-19 18:36 ` Stephan Gerhold [this message]
2021-07-20 15:04 ` Andy Shevchenko
2021-07-24 16:19 ` Jonathan Cameron
2021-07-24 18:06 ` Jonathan Cameron
2021-07-19 11:21 ` [PATCH 4/4] iio: accel: bmc150: Add support for BMC156 Stephan Gerhold
2021-07-19 14:08 ` Linus Walleij
2021-07-24 16:12 ` Jonathan Cameron
2021-07-27 18:32 ` Stephan Gerhold
2021-07-31 18:04 ` Jonathan Cameron
2021-07-19 12:34 ` [PATCH 0/4] iio: accel: bmc150: Add support for INT2 and BMC156 Andy Shevchenko
2021-07-19 12:42 ` Stephan Gerhold
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=YPXGQxPPID1SHOUO@gerhold.net \
--to=stephan@gerhold.net \
--cc=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=hdegoede@redhat.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=nikita@trvn.ru \
--cc=robh+dt@kernel.org \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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).