diff mbox series

[1/3] dt-bindings: iio: accel: bma255: Fix interrupt type

Message ID 20210614163150.7774-2-stephan@gerhold.net (mailing list archive)
State Accepted
Headers show
Series dt-bindings: iio: accel: bma255: Fix interrupt type / merge bma180 | expand

Commit Message

Stephan Gerhold June 14, 2021, 4:31 p.m. UTC
Bosch accelerometers similar to BMA255 are initially configured to
emit an active-high interrupt signal. This is currently not re-configured
in the bmc150-accel driver so the interrupt should most certainly be
IRQ_TYPE_EDGE_RISING (or potentially IRQ_TYPE_LEVEL_HIGH).
(Unless there is some kind of inverter installed on the board...)

At the moment the bmc150-accel driver forcefully requests the IRQ
using IRQF_TRIGGER_RISING, which means that the IRQ type is currently
ignored in all existing device trees.

Fixes: 6259551 ("iio: accel: bmc150-accel: Add DT bindings")
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
It's probably better to let the bmc150-accel driver rely on the IRQ
type provided by the device tree in case of inverters or something.

However:
  1. We need to fix up several broken device trees first (I found
     IRQ_TYPE_LEVEL_LOW in some device trees).
  2. Similarly, I'm not sure if this might break some ACPI devices
     in case they have the wrong IRQ type listed?

As a first step this patch just fixes the documentation.
---
 Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Linus Walleij June 16, 2021, 8:37 a.m. UTC | #1
On Mon, Jun 14, 2021 at 6:34 PM Stephan Gerhold <stephan@gerhold.net> wrote:

> Bosch accelerometers similar to BMA255 are initially configured to
> emit an active-high interrupt signal. This is currently not re-configured
> in the bmc150-accel driver so the interrupt should most certainly be
> IRQ_TYPE_EDGE_RISING (or potentially IRQ_TYPE_LEVEL_HIGH).
> (Unless there is some kind of inverter installed on the board...)
>
> At the moment the bmc150-accel driver forcefully requests the IRQ
> using IRQF_TRIGGER_RISING, which means that the IRQ type is currently
> ignored in all existing device trees.
>
> Fixes: 6259551 ("iio: accel: bmc150-accel: Add DT bindings")
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

> However:
>   1. We need to fix up several broken device trees first (I found
>      IRQ_TYPE_LEVEL_LOW in some device trees).

Oh this situation... Some are mine I bet (I can fix those,
just poke me with something sharp.)

>   2. Similarly, I'm not sure if this might break some ACPI devices
>      in case they have the wrong IRQ type listed?

I never figured this out but Andy and maybe Bastien Nocera
knows more about this.

> As a first step this patch just fixes the documentation.

Fair enough, it makes things better.

Yours,
Linus Walleij
Linus Walleij June 17, 2021, 10:08 a.m. UTC | #2
On Wed, Jun 16, 2021 at 2:31 PM Jonathan Cameron <jic23@kernel.org> wrote:

> Be a little bit careful.  There is always the possibility
> someone has a board doing cheap level conversion via an inverter
> (I have one of those, though not with this device).
> We could in theory represent that explicitly, but I think this
> is still mostly done by just flipping the sense in DT and pretending
> the inverter doesn't exist.

This is what we do, the DT is not a 100% map of the actual
system, and we have no inverter driver, so that flag is used to
indicate "some electronics" that flip the polarity.

We should document that better though.

> So whilst it might superficially make sense to change it for
> all cases, make sure we get someone familiar with the board to
> sanity check them.

Was just thinking of those that I can test :)

Yours,
Linus Walleij
Rob Herring June 24, 2021, 8:38 p.m. UTC | #3
On Mon, 14 Jun 2021 18:31:48 +0200, Stephan Gerhold wrote:
> Bosch accelerometers similar to BMA255 are initially configured to
> emit an active-high interrupt signal. This is currently not re-configured
> in the bmc150-accel driver so the interrupt should most certainly be
> IRQ_TYPE_EDGE_RISING (or potentially IRQ_TYPE_LEVEL_HIGH).
> (Unless there is some kind of inverter installed on the board...)
> 
> At the moment the bmc150-accel driver forcefully requests the IRQ
> using IRQF_TRIGGER_RISING, which means that the IRQ type is currently
> ignored in all existing device trees.
> 
> Fixes: 6259551 ("iio: accel: bmc150-accel: Add DT bindings")
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
> It's probably better to let the bmc150-accel driver rely on the IRQ
> type provided by the device tree in case of inverters or something.
> 
> However:
>   1. We need to fix up several broken device trees first (I found
>      IRQ_TYPE_LEVEL_LOW in some device trees).
>   2. Similarly, I'm not sure if this might break some ACPI devices
>      in case they have the wrong IRQ type listed?
> 
> As a first step this patch just fixes the documentation.
> ---
>  Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Acked-by: Rob Herring <robh@kernel.org>
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml b/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml
index e830d5295b92..b37ba902e4a2 100644
--- a/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml
+++ b/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml
@@ -38,7 +38,7 @@  properties:
     description: |
       The first interrupt listed must be the one connected to the INT1 pin,
       the second (optional) interrupt listed must be the one connected to the
-      INT2 pin (if available).
+      INT2 pin (if available). The type should be IRQ_TYPE_EDGE_RISING.
 
   mount-matrix:
     description: an optional 3x3 mounting rotation matrix.
@@ -63,7 +63,7 @@  examples:
             reg = <0x08>;
             vddio-supply = <&vddio>;
             vdd-supply = <&vdd>;
-            interrupts = <57 IRQ_TYPE_EDGE_FALLING>;
+            interrupts = <57 IRQ_TYPE_EDGE_RISING>;
         };
     };
   - |