Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sja1000.c
Go to the documentation of this file.
1 /*
2  * sja1000.c - Philips SJA1000 network device driver
3  *
4  * Copyright (c) 2003 Matthias Brukner, Trajet Gmbh, Rebenring 33,
5  * 38106 Braunschweig, GERMANY
6  *
7  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of Volkswagen nor the names of its contributors
19  * may be used to endorse or promote products derived from this software
20  * without specific prior written permission.
21  *
22  * Alternatively, provided that this notice is retained in full, this
23  * software may be distributed under the terms of the GNU General
24  * Public License ("GPL") version 2, in which case the provisions of the
25  * GPL apply INSTEAD OF those given above.
26  *
27  * The provided data structures and external interfaces from this code
28  * are not restricted to be used by modules with a GPL compatible license.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
41  * DAMAGE.
42  *
43  */
44 
45 #include <linux/module.h>
46 #include <linux/init.h>
47 #include <linux/kernel.h>
48 #include <linux/sched.h>
49 #include <linux/types.h>
50 #include <linux/fcntl.h>
51 #include <linux/interrupt.h>
52 #include <linux/ptrace.h>
53 #include <linux/string.h>
54 #include <linux/errno.h>
55 #include <linux/netdevice.h>
56 #include <linux/if_arp.h>
57 #include <linux/if_ether.h>
58 #include <linux/skbuff.h>
59 #include <linux/delay.h>
60 
61 #include <linux/can/dev.h>
62 #include <linux/can/error.h>
63 
64 #include "sja1000.h"
65 
66 #define DRV_NAME "sja1000"
67 
68 MODULE_AUTHOR("Oliver Hartkopp <[email protected]>");
69 MODULE_LICENSE("Dual BSD/GPL");
70 MODULE_DESCRIPTION(DRV_NAME "CAN netdevice driver");
71 
72 static const struct can_bittiming_const sja1000_bittiming_const = {
73  .name = DRV_NAME,
74  .tseg1_min = 1,
75  .tseg1_max = 16,
76  .tseg2_min = 1,
77  .tseg2_max = 8,
78  .sjw_max = 4,
79  .brp_min = 1,
80  .brp_max = 64,
81  .brp_inc = 1,
82 };
83 
84 static void sja1000_write_cmdreg(struct sja1000_priv *priv, u8 val)
85 {
86  unsigned long flags;
87 
88  /*
89  * The command register needs some locking and time to settle
90  * the write_reg() operation - especially on SMP systems.
91  */
92  spin_lock_irqsave(&priv->cmdreg_lock, flags);
93  priv->write_reg(priv, REG_CMR, val);
94  priv->read_reg(priv, REG_SR);
95  spin_unlock_irqrestore(&priv->cmdreg_lock, flags);
96 }
97 
98 static int sja1000_is_absent(struct sja1000_priv *priv)
99 {
100  return (priv->read_reg(priv, REG_MOD) == 0xFF);
101 }
102 
103 static int sja1000_probe_chip(struct net_device *dev)
104 {
105  struct sja1000_priv *priv = netdev_priv(dev);
106 
107  if (priv->reg_base && sja1000_is_absent(priv)) {
108  printk(KERN_INFO "%s: probing @0x%lX failed\n",
109  DRV_NAME, dev->base_addr);
110  return 0;
111  }
112  return -1;
113 }
114 
115 static void set_reset_mode(struct net_device *dev)
116 {
117  struct sja1000_priv *priv = netdev_priv(dev);
118  unsigned char status = priv->read_reg(priv, REG_MOD);
119  int i;
120 
121  /* disable interrupts */
122  priv->write_reg(priv, REG_IER, IRQ_OFF);
123 
124  for (i = 0; i < 100; i++) {
125  /* check reset bit */
126  if (status & MOD_RM) {
127  priv->can.state = CAN_STATE_STOPPED;
128  return;
129  }
130 
131  priv->write_reg(priv, REG_MOD, MOD_RM); /* reset chip */
132  udelay(10);
133  status = priv->read_reg(priv, REG_MOD);
134  }
135 
136  netdev_err(dev, "setting SJA1000 into reset mode failed!\n");
137 }
138 
139 static void set_normal_mode(struct net_device *dev)
140 {
141  struct sja1000_priv *priv = netdev_priv(dev);
142  unsigned char status = priv->read_reg(priv, REG_MOD);
143  int i;
144 
145  for (i = 0; i < 100; i++) {
146  /* check reset bit */
147  if ((status & MOD_RM) == 0) {
148  priv->can.state = CAN_STATE_ERROR_ACTIVE;
149  /* enable interrupts */
150  if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
151  priv->write_reg(priv, REG_IER, IRQ_ALL);
152  else
153  priv->write_reg(priv, REG_IER,
154  IRQ_ALL & ~IRQ_BEI);
155  return;
156  }
157 
158  /* set chip to normal mode */
159  if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
160  priv->write_reg(priv, REG_MOD, MOD_LOM);
161  else
162  priv->write_reg(priv, REG_MOD, 0x00);
163 
164  udelay(10);
165 
166  status = priv->read_reg(priv, REG_MOD);
167  }
168 
169  netdev_err(dev, "setting SJA1000 into normal mode failed!\n");
170 }
171 
172 static void sja1000_start(struct net_device *dev)
173 {
174  struct sja1000_priv *priv = netdev_priv(dev);
175 
176  /* leave reset mode */
177  if (priv->can.state != CAN_STATE_STOPPED)
178  set_reset_mode(dev);
179 
180  /* Clear error counters and error code capture */
181  priv->write_reg(priv, REG_TXERR, 0x0);
182  priv->write_reg(priv, REG_RXERR, 0x0);
183  priv->read_reg(priv, REG_ECC);
184 
185  /* leave reset mode */
186  set_normal_mode(dev);
187 }
188 
189 static int sja1000_set_mode(struct net_device *dev, enum can_mode mode)
190 {
191  struct sja1000_priv *priv = netdev_priv(dev);
192 
193  if (!priv->open_time)
194  return -EINVAL;
195 
196  switch (mode) {
197  case CAN_MODE_START:
198  sja1000_start(dev);
199  if (netif_queue_stopped(dev))
200  netif_wake_queue(dev);
201  break;
202 
203  default:
204  return -EOPNOTSUPP;
205  }
206 
207  return 0;
208 }
209 
210 static int sja1000_set_bittiming(struct net_device *dev)
211 {
212  struct sja1000_priv *priv = netdev_priv(dev);
213  struct can_bittiming *bt = &priv->can.bittiming;
214  u8 btr0, btr1;
215 
216  btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6);
217  btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) |
218  (((bt->phase_seg2 - 1) & 0x7) << 4);
219  if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
220  btr1 |= 0x80;
221 
222  netdev_info(dev, "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
223 
224  priv->write_reg(priv, REG_BTR0, btr0);
225  priv->write_reg(priv, REG_BTR1, btr1);
226 
227  return 0;
228 }
229 
230 static int sja1000_get_berr_counter(const struct net_device *dev,
231  struct can_berr_counter *bec)
232 {
233  struct sja1000_priv *priv = netdev_priv(dev);
234 
235  bec->txerr = priv->read_reg(priv, REG_TXERR);
236  bec->rxerr = priv->read_reg(priv, REG_RXERR);
237 
238  return 0;
239 }
240 
241 /*
242  * initialize SJA1000 chip:
243  * - reset chip
244  * - set output mode
245  * - set baudrate
246  * - enable interrupts
247  * - start operating mode
248  */
249 static void chipset_init(struct net_device *dev)
250 {
251  struct sja1000_priv *priv = netdev_priv(dev);
252 
253  /* set clock divider and output control register */
254  priv->write_reg(priv, REG_CDR, priv->cdr | CDR_PELICAN);
255 
256  /* set acceptance filter (accept all) */
257  priv->write_reg(priv, REG_ACCC0, 0x00);
258  priv->write_reg(priv, REG_ACCC1, 0x00);
259  priv->write_reg(priv, REG_ACCC2, 0x00);
260  priv->write_reg(priv, REG_ACCC3, 0x00);
261 
262  priv->write_reg(priv, REG_ACCM0, 0xFF);
263  priv->write_reg(priv, REG_ACCM1, 0xFF);
264  priv->write_reg(priv, REG_ACCM2, 0xFF);
265  priv->write_reg(priv, REG_ACCM3, 0xFF);
266 
267  priv->write_reg(priv, REG_OCR, priv->ocr | OCR_MODE_NORMAL);
268 }
269 
270 /*
271  * transmit a CAN message
272  * message layout in the sk_buff should be like this:
273  * xx xx xx xx ff ll 00 11 22 33 44 55 66 77
274  * [ can-id ] [flags] [len] [can data (up to 8 bytes]
275  */
276 static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
277  struct net_device *dev)
278 {
279  struct sja1000_priv *priv = netdev_priv(dev);
280  struct can_frame *cf = (struct can_frame *)skb->data;
281  uint8_t fi;
282  uint8_t dlc;
283  canid_t id;
284  uint8_t dreg;
285  int i;
286 
287  if (can_dropped_invalid_skb(dev, skb))
288  return NETDEV_TX_OK;
289 
290  netif_stop_queue(dev);
291 
292  fi = dlc = cf->can_dlc;
293  id = cf->can_id;
294 
295  if (id & CAN_RTR_FLAG)
296  fi |= FI_RTR;
297 
298  if (id & CAN_EFF_FLAG) {
299  fi |= FI_FF;
300  dreg = EFF_BUF;
301  priv->write_reg(priv, REG_FI, fi);
302  priv->write_reg(priv, REG_ID1, (id & 0x1fe00000) >> (5 + 16));
303  priv->write_reg(priv, REG_ID2, (id & 0x001fe000) >> (5 + 8));
304  priv->write_reg(priv, REG_ID3, (id & 0x00001fe0) >> 5);
305  priv->write_reg(priv, REG_ID4, (id & 0x0000001f) << 3);
306  } else {
307  dreg = SFF_BUF;
308  priv->write_reg(priv, REG_FI, fi);
309  priv->write_reg(priv, REG_ID1, (id & 0x000007f8) >> 3);
310  priv->write_reg(priv, REG_ID2, (id & 0x00000007) << 5);
311  }
312 
313  for (i = 0; i < dlc; i++)
314  priv->write_reg(priv, dreg++, cf->data[i]);
315 
316  can_put_echo_skb(skb, dev, 0);
317 
318  if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
319  sja1000_write_cmdreg(priv, CMD_TR | CMD_AT);
320  else
321  sja1000_write_cmdreg(priv, CMD_TR);
322 
323  return NETDEV_TX_OK;
324 }
325 
326 static void sja1000_rx(struct net_device *dev)
327 {
328  struct sja1000_priv *priv = netdev_priv(dev);
329  struct net_device_stats *stats = &dev->stats;
330  struct can_frame *cf;
331  struct sk_buff *skb;
332  uint8_t fi;
333  uint8_t dreg;
334  canid_t id;
335  int i;
336 
337  /* create zero'ed CAN frame buffer */
338  skb = alloc_can_skb(dev, &cf);
339  if (skb == NULL)
340  return;
341 
342  fi = priv->read_reg(priv, REG_FI);
343 
344  if (fi & FI_FF) {
345  /* extended frame format (EFF) */
346  dreg = EFF_BUF;
347  id = (priv->read_reg(priv, REG_ID1) << (5 + 16))
348  | (priv->read_reg(priv, REG_ID2) << (5 + 8))
349  | (priv->read_reg(priv, REG_ID3) << 5)
350  | (priv->read_reg(priv, REG_ID4) >> 3);
351  id |= CAN_EFF_FLAG;
352  } else {
353  /* standard frame format (SFF) */
354  dreg = SFF_BUF;
355  id = (priv->read_reg(priv, REG_ID1) << 3)
356  | (priv->read_reg(priv, REG_ID2) >> 5);
357  }
358 
359  cf->can_dlc = get_can_dlc(fi & 0x0F);
360  if (fi & FI_RTR) {
361  id |= CAN_RTR_FLAG;
362  } else {
363  for (i = 0; i < cf->can_dlc; i++)
364  cf->data[i] = priv->read_reg(priv, dreg++);
365  }
366 
367  cf->can_id = id;
368 
369  /* release receive buffer */
370  sja1000_write_cmdreg(priv, CMD_RRB);
371 
372  netif_rx(skb);
373 
374  stats->rx_packets++;
375  stats->rx_bytes += cf->can_dlc;
376 }
377 
378 static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
379 {
380  struct sja1000_priv *priv = netdev_priv(dev);
381  struct net_device_stats *stats = &dev->stats;
382  struct can_frame *cf;
383  struct sk_buff *skb;
384  enum can_state state = priv->can.state;
385  uint8_t ecc, alc;
386 
387  skb = alloc_can_err_skb(dev, &cf);
388  if (skb == NULL)
389  return -ENOMEM;
390 
391  if (isrc & IRQ_DOI) {
392  /* data overrun interrupt */
393  netdev_dbg(dev, "data overrun interrupt\n");
394  cf->can_id |= CAN_ERR_CRTL;
395  cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
396  stats->rx_over_errors++;
397  stats->rx_errors++;
398  sja1000_write_cmdreg(priv, CMD_CDO); /* clear bit */
399  }
400 
401  if (isrc & IRQ_EI) {
402  /* error warning interrupt */
403  netdev_dbg(dev, "error warning interrupt\n");
404 
405  if (status & SR_BS) {
406  state = CAN_STATE_BUS_OFF;
407  cf->can_id |= CAN_ERR_BUSOFF;
408  can_bus_off(dev);
409  } else if (status & SR_ES) {
410  state = CAN_STATE_ERROR_WARNING;
411  } else
412  state = CAN_STATE_ERROR_ACTIVE;
413  }
414  if (isrc & IRQ_BEI) {
415  /* bus error interrupt */
416  priv->can.can_stats.bus_error++;
417  stats->rx_errors++;
418 
419  ecc = priv->read_reg(priv, REG_ECC);
420 
422 
423  switch (ecc & ECC_MASK) {
424  case ECC_BIT:
425  cf->data[2] |= CAN_ERR_PROT_BIT;
426  break;
427  case ECC_FORM:
428  cf->data[2] |= CAN_ERR_PROT_FORM;
429  break;
430  case ECC_STUFF:
431  cf->data[2] |= CAN_ERR_PROT_STUFF;
432  break;
433  default:
434  cf->data[2] |= CAN_ERR_PROT_UNSPEC;
435  cf->data[3] = ecc & ECC_SEG;
436  break;
437  }
438  /* Error occurred during transmission? */
439  if ((ecc & ECC_DIR) == 0)
440  cf->data[2] |= CAN_ERR_PROT_TX;
441  }
442  if (isrc & IRQ_EPI) {
443  /* error passive interrupt */
444  netdev_dbg(dev, "error passive interrupt\n");
445  if (status & SR_ES)
446  state = CAN_STATE_ERROR_PASSIVE;
447  else
448  state = CAN_STATE_ERROR_ACTIVE;
449  }
450  if (isrc & IRQ_ALI) {
451  /* arbitration lost interrupt */
452  netdev_dbg(dev, "arbitration lost interrupt\n");
453  alc = priv->read_reg(priv, REG_ALC);
454  priv->can.can_stats.arbitration_lost++;
455  stats->tx_errors++;
456  cf->can_id |= CAN_ERR_LOSTARB;
457  cf->data[0] = alc & 0x1f;
458  }
459 
460  if (state != priv->can.state && (state == CAN_STATE_ERROR_WARNING ||
461  state == CAN_STATE_ERROR_PASSIVE)) {
462  uint8_t rxerr = priv->read_reg(priv, REG_RXERR);
463  uint8_t txerr = priv->read_reg(priv, REG_TXERR);
464  cf->can_id |= CAN_ERR_CRTL;
465  if (state == CAN_STATE_ERROR_WARNING) {
466  priv->can.can_stats.error_warning++;
467  cf->data[1] = (txerr > rxerr) ?
470  } else {
471  priv->can.can_stats.error_passive++;
472  cf->data[1] = (txerr > rxerr) ?
475  }
476  cf->data[6] = txerr;
477  cf->data[7] = rxerr;
478  }
479 
480  priv->can.state = state;
481 
482  netif_rx(skb);
483 
484  stats->rx_packets++;
485  stats->rx_bytes += cf->can_dlc;
486 
487  return 0;
488 }
489 
491 {
492  struct net_device *dev = (struct net_device *)dev_id;
493  struct sja1000_priv *priv = netdev_priv(dev);
494  struct net_device_stats *stats = &dev->stats;
495  uint8_t isrc, status;
496  int n = 0;
497 
498  /* Shared interrupts and IRQ off? */
499  if (priv->read_reg(priv, REG_IER) == IRQ_OFF)
500  return IRQ_NONE;
501 
502  if (priv->pre_irq)
503  priv->pre_irq(priv);
504 
505  while ((isrc = priv->read_reg(priv, REG_IR)) && (n < SJA1000_MAX_IRQ)) {
506  n++;
507  status = priv->read_reg(priv, REG_SR);
508  /* check for absent controller due to hw unplug */
509  if (status == 0xFF && sja1000_is_absent(priv))
510  return IRQ_NONE;
511 
512  if (isrc & IRQ_WUI)
513  netdev_warn(dev, "wakeup interrupt\n");
514 
515  if (isrc & IRQ_TI) {
516  /* transmission buffer released */
517  if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT &&
518  !(status & SR_TCS)) {
519  stats->tx_errors++;
520  can_free_echo_skb(dev, 0);
521  } else {
522  /* transmission complete */
523  stats->tx_bytes +=
524  priv->read_reg(priv, REG_FI) & 0xf;
525  stats->tx_packets++;
526  can_get_echo_skb(dev, 0);
527  }
528  netif_wake_queue(dev);
529  }
530  if (isrc & IRQ_RI) {
531  /* receive interrupt */
532  while (status & SR_RBS) {
533  sja1000_rx(dev);
534  status = priv->read_reg(priv, REG_SR);
535  /* check for absent controller */
536  if (status == 0xFF && sja1000_is_absent(priv))
537  return IRQ_NONE;
538  }
539  }
540  if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) {
541  /* error interrupt */
542  if (sja1000_err(dev, isrc, status))
543  break;
544  }
545  }
546 
547  if (priv->post_irq)
548  priv->post_irq(priv);
549 
550  if (n >= SJA1000_MAX_IRQ)
551  netdev_dbg(dev, "%d messages handled in ISR", n);
552 
553  return (n) ? IRQ_HANDLED : IRQ_NONE;
554 }
556 
557 static int sja1000_open(struct net_device *dev)
558 {
559  struct sja1000_priv *priv = netdev_priv(dev);
560  int err;
561 
562  /* set chip into reset mode */
563  set_reset_mode(dev);
564 
565  /* common open */
566  err = open_candev(dev);
567  if (err)
568  return err;
569 
570  /* register interrupt handler, if not done by the device driver */
571  if (!(priv->flags & SJA1000_CUSTOM_IRQ_HANDLER)) {
572  err = request_irq(dev->irq, sja1000_interrupt, priv->irq_flags,
573  dev->name, (void *)dev);
574  if (err) {
575  close_candev(dev);
576  return -EAGAIN;
577  }
578  }
579 
580  /* init and start chi */
581  sja1000_start(dev);
582  priv->open_time = jiffies;
583 
584  netif_start_queue(dev);
585 
586  return 0;
587 }
588 
589 static int sja1000_close(struct net_device *dev)
590 {
591  struct sja1000_priv *priv = netdev_priv(dev);
592 
593  netif_stop_queue(dev);
594  set_reset_mode(dev);
595 
596  if (!(priv->flags & SJA1000_CUSTOM_IRQ_HANDLER))
597  free_irq(dev->irq, (void *)dev);
598 
599  close_candev(dev);
600 
601  priv->open_time = 0;
602 
603  return 0;
604 }
605 
606 struct net_device *alloc_sja1000dev(int sizeof_priv)
607 {
608  struct net_device *dev;
609  struct sja1000_priv *priv;
610 
611  dev = alloc_candev(sizeof(struct sja1000_priv) + sizeof_priv,
613  if (!dev)
614  return NULL;
615 
616  priv = netdev_priv(dev);
617 
618  priv->dev = dev;
619  priv->can.bittiming_const = &sja1000_bittiming_const;
620  priv->can.do_set_bittiming = sja1000_set_bittiming;
621  priv->can.do_set_mode = sja1000_set_mode;
622  priv->can.do_get_berr_counter = sja1000_get_berr_counter;
623  priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
626 
627  spin_lock_init(&priv->cmdreg_lock);
628 
629  if (sizeof_priv)
630  priv->priv = (void *)priv + sizeof(struct sja1000_priv);
631 
632  return dev;
633 }
635 
636 void free_sja1000dev(struct net_device *dev)
637 {
638  free_candev(dev);
639 }
641 
642 static const struct net_device_ops sja1000_netdev_ops = {
643  .ndo_open = sja1000_open,
644  .ndo_stop = sja1000_close,
645  .ndo_start_xmit = sja1000_start_xmit,
646 };
647 
649 {
650  if (!sja1000_probe_chip(dev))
651  return -ENODEV;
652 
653  dev->flags |= IFF_ECHO; /* we support local echo */
654  dev->netdev_ops = &sja1000_netdev_ops;
655 
656  set_reset_mode(dev);
657  chipset_init(dev);
658 
659  return register_candev(dev);
660 }
662 
664 {
665  set_reset_mode(dev);
666  unregister_candev(dev);
667 }
669 
670 static __init int sja1000_init(void)
671 {
672  printk(KERN_INFO "%s CAN netdevice driver\n", DRV_NAME);
673 
674  return 0;
675 }
676 
677 module_init(sja1000_init);
678 
679 static __exit void sja1000_exit(void)
680 {
681  printk(KERN_INFO "%s: driver removed\n", DRV_NAME);
682 }
683 
684 module_exit(sja1000_exit);