linux-can-fixes-for-3.17-20140821
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlP1svIACgkQjTAFq1RaXHPV6wCfWtoj6987iIwKYSuz9q8nUB03 YtsAn0o3r44apjJT6uwEIfFR1M6NCuQK =5Bee -----END PGP SIGNATURE----- Merge tag 'linux-can-fixes-for-3.17-20140821' of git://gitorious.org/linux-can/linux-can Marc Kleine-Budde says: ==================== pull-request: can 2014-08-21 The first patch is from Mirza Krak, it fixes the initialization of the hardware in the sja1000 driver. The next patch is contributed by Dan Carpenter, it fixes the error handling in the c_can's probe function. Then there are two patches for the flexcan driver, one by Alexander Stein, which fixes the resetting of the bus error interrupt mask, the other one by Sebastian Andrzej Siewior which adds an additional error state transition message. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Коммит
215a004c61
|
@ -280,7 +280,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
|
|||
|
||||
priv->raminit_ctrlreg = devm_ioremap(&pdev->dev, res->start,
|
||||
resource_size(res));
|
||||
if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
|
||||
if (!priv->raminit_ctrlreg || priv->instance < 0)
|
||||
dev_info(&pdev->dev, "control memory is not used for raminit\n");
|
||||
else
|
||||
priv->raminit = c_can_hw_raminit_ti;
|
||||
|
|
|
@ -549,6 +549,13 @@ static void do_state(struct net_device *dev,
|
|||
|
||||
/* process state changes depending on the new state */
|
||||
switch (new_state) {
|
||||
case CAN_STATE_ERROR_WARNING:
|
||||
netdev_dbg(dev, "Error Warning\n");
|
||||
cf->can_id |= CAN_ERR_CRTL;
|
||||
cf->data[1] = (bec.txerr > bec.rxerr) ?
|
||||
CAN_ERR_CRTL_TX_WARNING :
|
||||
CAN_ERR_CRTL_RX_WARNING;
|
||||
break;
|
||||
case CAN_STATE_ERROR_ACTIVE:
|
||||
netdev_dbg(dev, "Error Active\n");
|
||||
cf->can_id |= CAN_ERR_PROT;
|
||||
|
@ -852,6 +859,8 @@ static int flexcan_chip_start(struct net_device *dev)
|
|||
if (priv->devtype_data->features & FLEXCAN_HAS_BROKEN_ERR_STATE ||
|
||||
priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
|
||||
reg_ctrl |= FLEXCAN_CTRL_ERR_MSK;
|
||||
else
|
||||
reg_ctrl &= ~FLEXCAN_CTRL_ERR_MSK;
|
||||
|
||||
/* save for later use */
|
||||
priv->reg_ctrl_default = reg_ctrl;
|
||||
|
|
|
@ -172,6 +172,35 @@ static void set_normal_mode(struct net_device *dev)
|
|||
netdev_err(dev, "setting SJA1000 into normal mode failed!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize SJA1000 chip:
|
||||
* - reset chip
|
||||
* - set output mode
|
||||
* - set baudrate
|
||||
* - enable interrupts
|
||||
* - start operating mode
|
||||
*/
|
||||
static void chipset_init(struct net_device *dev)
|
||||
{
|
||||
struct sja1000_priv *priv = netdev_priv(dev);
|
||||
|
||||
/* set clock divider and output control register */
|
||||
priv->write_reg(priv, SJA1000_CDR, priv->cdr | CDR_PELICAN);
|
||||
|
||||
/* set acceptance filter (accept all) */
|
||||
priv->write_reg(priv, SJA1000_ACCC0, 0x00);
|
||||
priv->write_reg(priv, SJA1000_ACCC1, 0x00);
|
||||
priv->write_reg(priv, SJA1000_ACCC2, 0x00);
|
||||
priv->write_reg(priv, SJA1000_ACCC3, 0x00);
|
||||
|
||||
priv->write_reg(priv, SJA1000_ACCM0, 0xFF);
|
||||
priv->write_reg(priv, SJA1000_ACCM1, 0xFF);
|
||||
priv->write_reg(priv, SJA1000_ACCM2, 0xFF);
|
||||
priv->write_reg(priv, SJA1000_ACCM3, 0xFF);
|
||||
|
||||
priv->write_reg(priv, SJA1000_OCR, priv->ocr | OCR_MODE_NORMAL);
|
||||
}
|
||||
|
||||
static void sja1000_start(struct net_device *dev)
|
||||
{
|
||||
struct sja1000_priv *priv = netdev_priv(dev);
|
||||
|
@ -180,6 +209,10 @@ static void sja1000_start(struct net_device *dev)
|
|||
if (priv->can.state != CAN_STATE_STOPPED)
|
||||
set_reset_mode(dev);
|
||||
|
||||
/* Initialize chip if uninitialized at this stage */
|
||||
if (!(priv->read_reg(priv, SJA1000_CDR) & CDR_PELICAN))
|
||||
chipset_init(dev);
|
||||
|
||||
/* Clear error counters and error code capture */
|
||||
priv->write_reg(priv, SJA1000_TXERR, 0x0);
|
||||
priv->write_reg(priv, SJA1000_RXERR, 0x0);
|
||||
|
@ -236,35 +269,6 @@ static int sja1000_get_berr_counter(const struct net_device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize SJA1000 chip:
|
||||
* - reset chip
|
||||
* - set output mode
|
||||
* - set baudrate
|
||||
* - enable interrupts
|
||||
* - start operating mode
|
||||
*/
|
||||
static void chipset_init(struct net_device *dev)
|
||||
{
|
||||
struct sja1000_priv *priv = netdev_priv(dev);
|
||||
|
||||
/* set clock divider and output control register */
|
||||
priv->write_reg(priv, SJA1000_CDR, priv->cdr | CDR_PELICAN);
|
||||
|
||||
/* set acceptance filter (accept all) */
|
||||
priv->write_reg(priv, SJA1000_ACCC0, 0x00);
|
||||
priv->write_reg(priv, SJA1000_ACCC1, 0x00);
|
||||
priv->write_reg(priv, SJA1000_ACCC2, 0x00);
|
||||
priv->write_reg(priv, SJA1000_ACCC3, 0x00);
|
||||
|
||||
priv->write_reg(priv, SJA1000_ACCM0, 0xFF);
|
||||
priv->write_reg(priv, SJA1000_ACCM1, 0xFF);
|
||||
priv->write_reg(priv, SJA1000_ACCM2, 0xFF);
|
||||
priv->write_reg(priv, SJA1000_ACCM3, 0xFF);
|
||||
|
||||
priv->write_reg(priv, SJA1000_OCR, priv->ocr | OCR_MODE_NORMAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* transmit a CAN message
|
||||
* message layout in the sk_buff should be like this:
|
||||
|
|
Загрузка…
Ссылка в новой задаче