2 * sja1000.h - Philips SJA1000 network device driver
4 * Copyright (c) 2003 Matthias Brukner, Trajet Gmbh, Rebenring 33,
5 * 38106 Braunschweig, GERMANY
7 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
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.
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
43 * Send feedback to <socketcan-users@lists.berlios.de>
50 #include <linux/can/dev.h>
51 #include <linux/can/platform/sja1000.h>
53 #define SJA1000_MAX_IRQ 20 /* max. number of interrupts handled in ISR */
55 /* SJA1000 registers - manual section 6.4 (Pelican Mode) */
64 #define REG_RXERR 0x0E
65 #define REG_TXERR 0x0F
66 #define REG_ACCC0 0x10
67 #define REG_ACCC1 0x11
68 #define REG_ACCC2 0x12
69 #define REG_ACCC3 0x13
70 #define REG_ACCM0 0x14
71 #define REG_ACCM1 0x15
72 #define REG_ACCM2 0x16
73 #define REG_ACCM3 0x17
77 /* Common registers - manual section 6.5 */
111 /* interrupt sources */
123 /* status register content */
133 #define SR_CRIT (SR_BS|SR_ES)
140 #define ECC_FORM 0x40
141 #define ECC_STUFF 0x80
142 #define ECC_MASK 0xc0
145 * Flags for sja1000priv.flags
147 #define SJA1000_CUSTOM_IRQ_HANDLER 0x1
150 * SJA1000 private data structure
152 struct sja1000_priv {
153 struct can_priv can; /* must be the first member */
155 struct sk_buff *echo_skb;
157 /* the lower-layer is responsible for appropriate locking */
158 u8 (*read_reg) (const struct net_device *dev, int reg);
159 void (*write_reg) (const struct net_device *dev, int reg, u8 val);
160 void (*pre_irq) (const struct net_device *dev);
161 void (*post_irq) (const struct net_device *dev);
163 void *priv; /* for board-specific data */
164 struct net_device *dev;
166 unsigned long irq_flags; /* for request_irq() */
168 u16 flags; /* custom mode flags */
169 u8 ocr; /* output control register */
170 u8 cdr; /* clock divider register */
173 struct net_device *alloc_sja1000dev(int sizeof_priv);
174 void free_sja1000dev(struct net_device *dev);
175 int register_sja1000dev(struct net_device *dev);
176 void unregister_sja1000dev(struct net_device *dev);
178 irqreturn_t sja1000_interrupt(int irq, void *dev_id);
180 #endif /* SJA1000_DEV_H */