2 * $Id: sja1000.h,v 2.0 2006/04/13 10:37:21 ethuerm Exp $
4 * sja1000.h - Philips SJA1000 network device driver
6 * Copyright (c) 2003 Matthias Brukner, Trajet Gmbh, Rebenring 33,
7 * 38106 Braunschweig, GERMANY
9 * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, the following disclaimer and
17 * the referenced file 'COPYING'.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of Volkswagen nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * Alternatively, provided that this notice is retained in full, this
26 * software may be distributed under the terms of the GNU General
27 * Public License ("GPL") version 2 as distributed in the 'COPYING'
28 * file from the main directory of the linux kernel source.
30 * The provided data structures and external interfaces from this code
31 * are not restricted to be used by modules with a GPL compatible license.
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
36 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
38 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
40 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
41 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
46 * Send feedback to <llcf@volkswagen.de>
53 #define SJA1000_IO_SIZE_BASIC 0x20
54 #define SJA1000_IO_SIZE_PELICAN 0x80
56 #define SJA1000_IO_SIZE_ISA 0x20
58 #define DEFAULT_SPEED 100 /* kBit/s */
60 #define TX_TIMEOUT (HZ/20) /* 50ms */
61 #define RESTART_MS 100 /* restart chip on persistent errors in 100ms */
62 #define MAX_BUS_ERRORS 200 /* prevent from flooding bus error interrupts */
64 /* SJA1000 registers - manual section 6.4 (Pelican Mode) */
73 #define REG_RXERR 0x0E
74 #define REG_TXERR 0x0F
75 #define REG_ACCC0 0x10
76 #define REG_ACCC1 0x11
77 #define REG_ACCC2 0x12
78 #define REG_ACCC3 0x13
79 #define REG_ACCM0 0x14
80 #define REG_ACCM1 0x15
81 #define REG_ACCM2 0x16
82 #define REG_ACCM3 0x17
86 /* Common registers - manual section 6.5 */
120 /* interrupt sources */
132 /* status register content */
142 #define SR_CRIT (SR_BS|SR_ES)
152 #define SAMPLE_POINT 75
153 #define JUMPWIDTH 0x40
156 #define REG_READ(addr) ((struct can_priv*)netdev_priv(dev))->reg_read(dev,addr)
157 #define REG_WRITE(addr,data) ((struct can_priv*)netdev_priv(dev))->reg_write(dev,addr,data)
159 #define SJA1000_CHIP_NAME "sja1000"
160 #define PROCBASE "net/drivers" /* /proc/ ... */
163 * private data structure:
164 * reg_read and reg_write are functions to access the sja1000 registers
167 struct net_device_stats stats;
175 struct timer_list timer;
176 uint8_t (*reg_read)(struct net_device *dev, int reg);
177 void (*reg_write)(struct net_device *dev, int reg, uint8_t val);
178 struct can_device_stats can_stats;
182 #define STATE_UNINITIALIZED 0
183 #define STATE_PROBE 1
184 #define STATE_ACTIVE 2
185 #define STATE_ERROR_ACTIVE 3
186 #define STATE_ERROR_PASSIVE 4
187 #define STATE_BUS_OFF 5
188 #define STATE_RESET_MODE 6
190 void sja1000_setup(struct net_device *dev);
191 void sja1000_proc_init(const char *drv_name, struct net_device **dev, int max);
192 void sja1000_proc_delete(const char *drv_name);
194 #endif /* __SJA1000_H__ */