can: sja1000: clear interrupts on start
authorMirza Krak <mirza.krak@hostmobility.com>
Tue, 10 Nov 2015 13:59:34 +0000 (14:59 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 30 Dec 2015 02:25:57 +0000 (02:25 +0000)
commit 7cecd9ab80f43972c056dc068338f7bcc407b71c upstream.

According to SJA1000 data sheet error-warning (EI) interrupt is not
cleared by setting the controller in to reset-mode.

Then if we have the following case:
- system is suspended (echo mem > /sys/power/state) and SJA1000 is left
  in operating state
- A bus error condition occurs which activates EI interrupt, system is
  still suspended which means EI interrupt will be not be handled nor
  cleared.

If the above two events occur, on resume there is no way to return the
SJA1000 to operating state, except to cycle power to it.

By simply reading the IR register on start we will clear any previous
conditions that could be present.

Signed-off-by: Mirza Krak <mirza.krak@hostmobility.com>
Reported-by: Christian Magnusson <Christian.Magnusson@semcon.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[bwh: Backported to 3.2: s/SJA1000_IR/REG_IR/]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/can/sja1000/sja1000.c

index 568b821..faff53b 100644 (file)
@@ -177,6 +177,9 @@ static void sja1000_start(struct net_device *dev)
        priv->write_reg(priv, REG_RXERR, 0x0);
        priv->read_reg(priv, REG_ECC);
 
+       /* clear interrupt flags */
+       priv->read_reg(priv, REG_IR);
+
        /* leave reset mode */
        set_normal_mode(dev);
 }