Commit 79d0d8a7 authored by Wolfgang Grandegger's avatar Wolfgang Grandegger Committed by Marc Kleine-Budde

can: bfin_can/ti_hecc/mscan: add missing do_get_berr_counter callback

Cc: Anant Gole <anantgole@ti.com>
Signed-off-by: default avatarWolfgang Grandegger <wg@grandegger.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 03c49daa
...@@ -224,6 +224,20 @@ static int bfin_can_set_mode(struct net_device *dev, enum can_mode mode) ...@@ -224,6 +224,20 @@ static int bfin_can_set_mode(struct net_device *dev, enum can_mode mode)
return 0; 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) static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct bfin_can_priv *priv = netdev_priv(dev); struct bfin_can_priv *priv = netdev_priv(dev);
...@@ -509,6 +523,7 @@ struct net_device *alloc_bfin_candev(void) ...@@ -509,6 +523,7 @@ struct net_device *alloc_bfin_candev(void)
priv->can.bittiming_const = &bfin_can_bittiming_const; priv->can.bittiming_const = &bfin_can_bittiming_const;
priv->can.do_set_bittiming = bfin_can_set_bittiming; priv->can.do_set_bittiming = bfin_can_set_bittiming;
priv->can.do_set_mode = bfin_can_set_mode; 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; priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
return dev; return dev;
......
...@@ -560,6 +560,18 @@ static int mscan_do_set_bittiming(struct net_device *dev) ...@@ -560,6 +560,18 @@ static int mscan_do_set_bittiming(struct net_device *dev)
return 0; 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) static int mscan_open(struct net_device *dev)
{ {
int ret; int ret;
...@@ -639,8 +651,10 @@ int register_mscandev(struct net_device *dev, int mscan_clksrc) ...@@ -639,8 +651,10 @@ int register_mscandev(struct net_device *dev, int mscan_clksrc)
else else
ctl1 &= ~MSCAN_CLKSRC; 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_BORM; /* bus-off recovery upon request */
}
ctl1 |= MSCAN_CANE; ctl1 |= MSCAN_CANE;
out_8(&regs->canctl1, ctl1); out_8(&regs->canctl1, ctl1);
......
...@@ -458,6 +458,17 @@ static int ti_hecc_do_set_mode(struct net_device *ndev, enum can_mode mode) ...@@ -458,6 +458,17 @@ static int ti_hecc_do_set_mode(struct net_device *ndev, enum can_mode mode)
return ret; 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 * ti_hecc_xmit: HECC Transmit
* *
...@@ -922,6 +933,7 @@ static int ti_hecc_probe(struct platform_device *pdev) ...@@ -922,6 +933,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
priv->can.bittiming_const = &ti_hecc_bittiming_const; priv->can.bittiming_const = &ti_hecc_bittiming_const;
priv->can.do_set_mode = ti_hecc_do_set_mode; priv->can.do_set_mode = ti_hecc_do_set_mode;
priv->can.do_get_state = ti_hecc_get_state; 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; priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
spin_lock_init(&priv->mbx_lock); spin_lock_init(&priv->mbx_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment