mcp2515: Use DT-supplied interrupt flags
authorPhil Elwell <phil@raspberrypi.org>
Tue, 14 Nov 2017 11:03:22 +0000 (11:03 +0000)
committerRaspbian kernel package updater <root@raspbian.org>
Sat, 31 Mar 2018 14:57:24 +0000 (15:57 +0100)
The MCP2515 datasheet clearly describes a level-triggered interrupt
pin. Therefore the receiving interrupt controller must also be
configured for level-triggered operation otherwise there is a danger
of a missed interrupt condition blocking all subsequent interrupts.
The ONESHOT flag ensures that the interrupt is masked until the
threaded interrupt handler exits.

Rather than change the flags globally (they must have worked for at
least one user), allow the flags to be overridden from Device Tree
in the event that the device has a DT node.

See: https://github.com/raspberrypi/linux/issues/2175
     https://github.com/raspberrypi/linux/issues/2263

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
arch/arm/boot/dts/overlays/mcp2515-can0-overlay.dts
arch/arm/boot/dts/overlays/mcp2515-can1-overlay.dts
drivers/net/can/spi/mcp251x.c

index c96cdae27fb15055c4a6ec55d1ee45644768c392..03eb5486fa9c4cdb74cfc7a228dc7cea0105b8b5 100755 (executable)
@@ -60,7 +60,7 @@
                 pinctrl-0 = <&can0_pins>;
                 spi-max-frequency = <10000000>;
                 interrupt-parent = <&gpio>;
-                interrupts = <25 0x2>;
+                interrupts = <25 8>; /* IRQ_TYPE_LEVEL_LOW */
                 clocks = <&can0_osc>;
             };
         };
index 67bd0d9bdaa2ff767d284010a69ecfe3f2aa1fd1..dc773fa3b50cea849ffede35f42d30175c11718c 100644 (file)
@@ -60,7 +60,7 @@
                 pinctrl-0 = <&can1_pins>;
                 spi-max-frequency = <10000000>;
                 interrupt-parent = <&gpio>;
-                interrupts = <25 0x2>;
+                interrupts = <25 8>; /* IRQ_TYPE_LEVEL_LOW */
                 clocks = <&can1_osc>;
             };
         };
index f3f05fea8e1f8e0ad3a1ebd7461d2019835e1d47..6c2d3aba25918f5536b2d67292334e746df06c5e 100644 (file)
@@ -952,6 +952,9 @@ static int mcp251x_open(struct net_device *net)
        priv->tx_skb = NULL;
        priv->tx_len = 0;
 
+       if (spi->dev.of_node)
+           flags = 0;
+
        ret = request_threaded_irq(spi->irq, NULL, mcp251x_can_ist,
                                   flags | IRQF_ONESHOT, DEVICE_NAME, priv);
        if (ret) {