[PATCH v3 1/2] flexcan: add err_irq handler for flexcan

qiang.zhao at freescale.com qiang.zhao at freescale.com
Mon Jun 23 17:26:27 EST 2014


On 06/23/2014 03:18 PM, Marc Kleine-Budde wrote:

> 
> On 06/23/2014 09:11 AM, Zhao Qiang wrote:
> > when flexcan is not physically linked, command 'cantest' will trigger
> > an err_irq, add err_irq handler for it.
> >
> > Signed-off-by: Zhao Qiang <B45475 at freescale.com>
> > ---
> > Changes for v2:
> > 	- use a space instead of tab
> > 	- use flexcan_poll_state instead of print Changes for v3:
> > 	- return IRQ_HANDLED if err is triggered
> > 	- stop transmitted packets when there is an err_interrupt
> >
> >  drivers/net/can/flexcan.c | 35 ++++++++++++++++++++++++++++++++++-
> >  1 file changed, 34 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> > index f425ec2..6802a25 100644
> > --- a/drivers/net/can/flexcan.c
> > +++ b/drivers/net/can/flexcan.c
> > @@ -208,6 +208,7 @@ struct flexcan_priv {
> >  	void __iomem *base;
> >  	u32 reg_esr;
> >  	u32 reg_ctrl_default;
> > +	unsigned int err_irq;
> >
> >  	struct clk *clk_ipg;
> >  	struct clk *clk_per;
> > @@ -744,6 +745,24 @@ static irqreturn_t flexcan_irq(int irq, void
> *dev_id)
> >  	return IRQ_HANDLED;
> >  }
> >
> > +static irqreturn_t flexcan_err_irq(int irq, void *dev_id) {
> > +	struct net_device *dev = dev_id;
> > +	struct flexcan_priv *priv = netdev_priv(dev);
> > +	struct flexcan_regs __iomem *regs = priv->base;
> > +	u32 reg_ctrl, reg_esr;
> > +
> > +	reg_esr = flexcan_read(&regs->esr);
> > +	reg_ctrl = flexcan_read(&regs->ctrl);
> > +	if (reg_esr & FLEXCAN_ESR_TX_WRN) {
> 
> When does the hardware trigger the interrupt?

When there is no wire link between tx and rx, tx start transfer and doesn’t get the ack.

> 
> > +		flexcan_write(reg_esr & ~FLEXCAN_ESR_TX_WRN, &regs->esr);
> > +		flexcan_write(reg_ctrl & ~FLEXCAN_CTRL_ERR_MSK, &regs->ctrl);
> > +		netif_stop_queue(dev);
> 
> Why are you stopping the txqueue?

There is no wire link, tx can't transfer successfully. 

> 
> > +		return IRQ_HANDLED;
> > +	}
> > +	return IRQ_NONE;
> > +}
> > +
> 
> Marc
> 
> --
> Pengutronix e.K.                  | Marc Kleine-Budde           |
> Industrial Linux Solutions        | Phone: +49-231-2826-924     |
> Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
> Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



More information about the Linuxppc-dev mailing list