can: bfin_can/ti_hecc/mscan: add missing do_get_berr_counter callback
authorWolfgang Grandegger <wg@grandegger.com>
Wed, 1 Feb 2012 10:14:13 +0000 (11:14 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 3 Feb 2012 00:21:26 +0000 (01:21 +0100)
Cc: Anant Gole <anantgole@ti.com>
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/bfin_can.c
drivers/net/can/mscan/mscan.c
drivers/net/can/ti_hecc.c

index 349e0fa..e1e7f9d 100644 (file)
@@ -224,6 +224,20 @@ static int bfin_can_set_mode(struct net_device *dev, enum can_mode mode)
        return 0;
 }
 
+static int bfin_can_get_berr_counter(const struct net_device *dev,
+                                    struct can_berr_counter *bec)
+{
+       struct bfin_can_priv *priv = netdev_priv(dev);
+       struct bfin_can_regs __iomem *reg = priv->membase;
+
+       u16 cec = bfin_read(&reg->cec);
+
+       bec->txerr = cec >> 8;
+       bec->rxerr = cec;
+
+       return 0;
+}
+
 static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct bfin_can_priv *priv = netdev_priv(dev);
@@ -509,6 +523,7 @@ struct net_device *alloc_bfin_candev(void)
        priv->can.bittiming_const = &bfin_can_bittiming_const;
        priv->can.do_set_bittiming = bfin_can_set_bittiming;
        priv->can.do_set_mode = bfin_can_set_mode;
+       priv->can.do_get_berr_counter = bfin_can_get_berr_counter;
        priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
 
        return dev;
index 1c82dd8..d11b083 100644 (file)
@@ -560,6 +560,18 @@ static int mscan_do_set_bittiming(struct net_device *dev)
        return 0;
 }
 
+static int mscan_get_berr_counter(const struct net_device *dev,
+                                 struct can_berr_counter *bec)
+{
+       struct mscan_priv *priv = netdev_priv(dev);
+       struct mscan_regs __iomem *regs = priv->reg_base;
+
+       bec->txerr = in_8(&regs->cantxerr);
+       bec->rxerr = in_8(&regs->canrxerr);
+
+       return 0;
+}
+
 static int mscan_open(struct net_device *dev)
 {
        int ret;
@@ -639,8 +651,10 @@ int register_mscandev(struct net_device *dev, int mscan_clksrc)
        else
                ctl1 &= ~MSCAN_CLKSRC;
 
-       if (priv->type == MSCAN_TYPE_MPC5121)
+       if (priv->type == MSCAN_TYPE_MPC5121) {
+               priv->can.do_get_berr_counter = mscan_get_berr_counter;
                ctl1 |= MSCAN_BORM; /* bus-off recovery upon request */
+       }
 
        ctl1 |= MSCAN_CANE;
        out_8(&regs->canctl1, ctl1);
index df809e3..aee925a 100644 (file)
@@ -458,6 +458,17 @@ static int ti_hecc_do_set_mode(struct net_device *ndev, enum can_mode mode)
        return ret;
 }
 
+static int ti_hecc_get_berr_counter(const struct net_device *ndev,
+                                       struct can_berr_counter *bec)
+{
+       struct ti_hecc_priv *priv = netdev_priv(ndev);
+
+       bec->txerr = hecc_read(priv, HECC_CANTEC);
+       bec->rxerr = hecc_read(priv, HECC_CANREC);
+
+       return 0;
+}
+
 /*
  * ti_hecc_xmit: HECC Transmit
  *
@@ -922,6 +933,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
        priv->can.bittiming_const = &ti_hecc_bittiming_const;
        priv->can.do_set_mode = ti_hecc_do_set_mode;
        priv->can.do_get_state = ti_hecc_get_state;
+       priv->can.do_get_berr_counter = ti_hecc_get_berr_counter;
        priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
 
        spin_lock_init(&priv->mbx_lock);