diff options
author | David S. Miller <davem@davemloft.net> | 2014-08-22 00:53:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-08-22 00:53:15 -0400 |
commit | 215a004c61d2f12b130aeb2a9f609275ed6f61bb (patch) | |
tree | 475fcced95418aaf549bfdbd922f4b2331646281 /drivers/net | |
parent | 29aaee65bc28cc75281dc9fe0998cc5e10ac37f9 (diff) | |
parent | 8ce261d0bb491da957278cdcba207791f329d1da (diff) |
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>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/can/c_can/c_can_platform.c | 2 | ||||
-rw-r--r-- | drivers/net/can/flexcan.c | 9 | ||||
-rw-r--r-- | drivers/net/can/sja1000/sja1000.c | 62 |
3 files changed, 43 insertions, 30 deletions
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index 5dede6e64376..109cb44291f5 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c | |||
@@ -280,7 +280,7 @@ static int c_can_plat_probe(struct platform_device *pdev) | |||
280 | 280 | ||
281 | priv->raminit_ctrlreg = devm_ioremap(&pdev->dev, res->start, | 281 | priv->raminit_ctrlreg = devm_ioremap(&pdev->dev, res->start, |
282 | resource_size(res)); | 282 | resource_size(res)); |
283 | if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0) | 283 | if (!priv->raminit_ctrlreg || priv->instance < 0) |
284 | dev_info(&pdev->dev, "control memory is not used for raminit\n"); | 284 | dev_info(&pdev->dev, "control memory is not used for raminit\n"); |
285 | else | 285 | else |
286 | priv->raminit = c_can_hw_raminit_ti; | 286 | priv->raminit = c_can_hw_raminit_ti; |
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index f425ec2c7839..944aa5d3af6e 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c | |||
@@ -549,6 +549,13 @@ static void do_state(struct net_device *dev, | |||
549 | 549 | ||
550 | /* process state changes depending on the new state */ | 550 | /* process state changes depending on the new state */ |
551 | switch (new_state) { | 551 | switch (new_state) { |
552 | case CAN_STATE_ERROR_WARNING: | ||
553 | netdev_dbg(dev, "Error Warning\n"); | ||
554 | cf->can_id |= CAN_ERR_CRTL; | ||
555 | cf->data[1] = (bec.txerr > bec.rxerr) ? | ||
556 | CAN_ERR_CRTL_TX_WARNING : | ||
557 | CAN_ERR_CRTL_RX_WARNING; | ||
558 | break; | ||
552 | case CAN_STATE_ERROR_ACTIVE: | 559 | case CAN_STATE_ERROR_ACTIVE: |
553 | netdev_dbg(dev, "Error Active\n"); | 560 | netdev_dbg(dev, "Error Active\n"); |
554 | cf->can_id |= CAN_ERR_PROT; | 561 | cf->can_id |= CAN_ERR_PROT; |
@@ -852,6 +859,8 @@ static int flexcan_chip_start(struct net_device *dev) | |||
852 | if (priv->devtype_data->features & FLEXCAN_HAS_BROKEN_ERR_STATE || | 859 | if (priv->devtype_data->features & FLEXCAN_HAS_BROKEN_ERR_STATE || |
853 | priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) | 860 | priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) |
854 | reg_ctrl |= FLEXCAN_CTRL_ERR_MSK; | 861 | reg_ctrl |= FLEXCAN_CTRL_ERR_MSK; |
862 | else | ||
863 | reg_ctrl &= ~FLEXCAN_CTRL_ERR_MSK; | ||
855 | 864 | ||
856 | /* save for later use */ | 865 | /* save for later use */ |
857 | priv->reg_ctrl_default = reg_ctrl; | 866 | priv->reg_ctrl_default = reg_ctrl; |
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index d1692154ed1b..b27ac6074afb 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c | |||
@@ -172,6 +172,35 @@ static void set_normal_mode(struct net_device *dev) | |||
172 | netdev_err(dev, "setting SJA1000 into normal mode failed!\n"); | 172 | netdev_err(dev, "setting SJA1000 into normal mode failed!\n"); |
173 | } | 173 | } |
174 | 174 | ||
175 | /* | ||
176 | * initialize SJA1000 chip: | ||
177 | * - reset chip | ||
178 | * - set output mode | ||
179 | * - set baudrate | ||
180 | * - enable interrupts | ||
181 | * - start operating mode | ||
182 | */ | ||
183 | static void chipset_init(struct net_device *dev) | ||
184 | { | ||
185 | struct sja1000_priv *priv = netdev_priv(dev); | ||
186 | |||
187 | /* set clock divider and output control register */ | ||
188 | priv->write_reg(priv, SJA1000_CDR, priv->cdr | CDR_PELICAN); | ||
189 | |||
190 | /* set acceptance filter (accept all) */ | ||
191 | priv->write_reg(priv, SJA1000_ACCC0, 0x00); | ||
192 | priv->write_reg(priv, SJA1000_ACCC1, 0x00); | ||
193 | priv->write_reg(priv, SJA1000_ACCC2, 0x00); | ||
194 | priv->write_reg(priv, SJA1000_ACCC3, 0x00); | ||
195 | |||
196 | priv->write_reg(priv, SJA1000_ACCM0, 0xFF); | ||
197 | priv->write_reg(priv, SJA1000_ACCM1, 0xFF); | ||
198 | priv->write_reg(priv, SJA1000_ACCM2, 0xFF); | ||
199 | priv->write_reg(priv, SJA1000_ACCM3, 0xFF); | ||
200 | |||
201 | priv->write_reg(priv, SJA1000_OCR, priv->ocr | OCR_MODE_NORMAL); | ||
202 | } | ||
203 | |||
175 | static void sja1000_start(struct net_device *dev) | 204 | static void sja1000_start(struct net_device *dev) |
176 | { | 205 | { |
177 | struct sja1000_priv *priv = netdev_priv(dev); | 206 | struct sja1000_priv *priv = netdev_priv(dev); |
@@ -180,6 +209,10 @@ static void sja1000_start(struct net_device *dev) | |||
180 | if (priv->can.state != CAN_STATE_STOPPED) | 209 | if (priv->can.state != CAN_STATE_STOPPED) |
181 | set_reset_mode(dev); | 210 | set_reset_mode(dev); |
182 | 211 | ||
212 | /* Initialize chip if uninitialized at this stage */ | ||
213 | if (!(priv->read_reg(priv, SJA1000_CDR) & CDR_PELICAN)) | ||
214 | chipset_init(dev); | ||
215 | |||
183 | /* Clear error counters and error code capture */ | 216 | /* Clear error counters and error code capture */ |
184 | priv->write_reg(priv, SJA1000_TXERR, 0x0); | 217 | priv->write_reg(priv, SJA1000_TXERR, 0x0); |
185 | priv->write_reg(priv, SJA1000_RXERR, 0x0); | 218 | priv->write_reg(priv, SJA1000_RXERR, 0x0); |
@@ -237,35 +270,6 @@ static int sja1000_get_berr_counter(const struct net_device *dev, | |||
237 | } | 270 | } |
238 | 271 | ||
239 | /* | 272 | /* |
240 | * initialize SJA1000 chip: | ||
241 | * - reset chip | ||
242 | * - set output mode | ||
243 | * - set baudrate | ||
244 | * - enable interrupts | ||
245 | * - start operating mode | ||
246 | */ | ||
247 | static void chipset_init(struct net_device *dev) | ||
248 | { | ||
249 | struct sja1000_priv *priv = netdev_priv(dev); | ||
250 | |||
251 | /* set clock divider and output control register */ | ||
252 | priv->write_reg(priv, SJA1000_CDR, priv->cdr | CDR_PELICAN); | ||
253 | |||
254 | /* set acceptance filter (accept all) */ | ||
255 | priv->write_reg(priv, SJA1000_ACCC0, 0x00); | ||
256 | priv->write_reg(priv, SJA1000_ACCC1, 0x00); | ||
257 | priv->write_reg(priv, SJA1000_ACCC2, 0x00); | ||
258 | priv->write_reg(priv, SJA1000_ACCC3, 0x00); | ||
259 | |||
260 | priv->write_reg(priv, SJA1000_ACCM0, 0xFF); | ||
261 | priv->write_reg(priv, SJA1000_ACCM1, 0xFF); | ||
262 | priv->write_reg(priv, SJA1000_ACCM2, 0xFF); | ||
263 | priv->write_reg(priv, SJA1000_ACCM3, 0xFF); | ||
264 | |||
265 | priv->write_reg(priv, SJA1000_OCR, priv->ocr | OCR_MODE_NORMAL); | ||
266 | } | ||
267 | |||
268 | /* | ||
269 | * transmit a CAN message | 273 | * transmit a CAN message |
270 | * message layout in the sk_buff should be like this: | 274 | * message layout in the sk_buff should be like this: |
271 | * xx xx xx xx ff ll 00 11 22 33 44 55 66 77 | 275 | * xx xx xx xx ff ll 00 11 22 33 44 55 66 77 |