6 * - Sascha Hauer, Marc Kleine-Budde, Pengutronix
7 * - Simon Kallweit, intefo AG
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the version 2 of the GNU General Public License
11 * as published by the Free Software Foundation
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/can.h>
27 #include <linux/platform_device.h>
41 CAN_TXRQST = 0x80, /* 32bit */
42 CAN_NEWDAT = 0x90, /* 32bit */
43 CAN_INTPND = 0xa0, /* 32bit */
44 CAN_MSGVAL = 0xb0, /* 32bit */
47 #define CAN_IF_COMR(x) (CAN_IF1 + (x) * 0x30 + 0x00)
48 #define CAN_IF_COMM(x) (CAN_IF1 + (x) * 0x30 + 0x02)
49 #define CAN_IF_MASK(x) (CAN_IF1 + (x) * 0x30 + 0x04) /* 32bit */
50 #define CAN_IF_ARB(x) (CAN_IF1 + (x) * 0x30 + 0x08) /* 32bit */
51 #define CAN_IF_MCONT(x) (CAN_IF1 + (x) * 0x30 + 0x0c)
52 #define CAN_IF_DATAA(x) (CAN_IF1 + (x) * 0x30 + 0x0e) /* 32bit */
53 #define CAN_IF_DATAB(x) (CAN_IF1 + (x) * 0x30 + 0x12) /* 32bit */
55 #define CONTROL_TEST (1<<7)
56 #define CONTROL_CCE (1<<6)
57 #define CONTROL_DAR (1<<5)
58 #define CONTROL_EIE (1<<3)
59 #define CONTROL_SIE (1<<2)
60 #define CONTROL_IE (1<<1)
61 #define CONTROL_INIT (1<<0)
63 #define TEST_RX (1<<7)
64 #define TEST_TX1 (1<<6)
65 #define TEST_TX2 (1<<5)
66 #define TEST_LBACK (1<<4)
67 #define TEST_SILENT (1<<3)
68 #define TEST_BASIC (1<<2)
70 #define STATUS_BOFF (1<<7)
71 #define STATUS_EWARN (1<<6)
72 #define STATUS_EPASS (1<<5)
73 #define STATUS_RXOK (1<<4)
74 #define STATUS_TXOK (1<<3)
75 #define STATUS_LEC_MASK (1<<2)
76 #define LEC_STUFF_ERROR 1
77 #define LEC_FORM_ERROR 2
78 #define LEC_ACK_ERROR 3
79 #define LEC_BIT1_ERROR 4
81 #define BTR_BRP_MASK 0x3f
82 #define BTR_BRP_SHIFT 0
83 #define BTR_SJW_SHIFT 6
84 #define BTR_SJW_MASK (0x3 << BTR_SJW_SHIFT)
85 #define BTR_TSEG1_SHIFT 8
86 #define BTR_TSEG1_MASK (0xf << BTR_TSEG1_SHIFT)
87 #define BTR_TSEG2_SHIFT 12
88 #define BTR_TSEG2_MASK (0x7 << BTR_TSEG2_SHIFT)
90 #define IF_COMR_BUSY (1<<15)
92 #define IF_COMM_WR (1<<7)
93 #define IF_COMM_MASK (1<<6)
94 #define IF_COMM_ARB (1<<5)
95 #define IF_COMM_CONTROL (1<<4)
96 #define IF_COMM_CLR_INT_PND (1<<3)
97 #define IF_COMM_TXRQST (1<<2)
98 #define IF_COMM_DATAA (1<<1)
99 #define IF_COMM_DATAB (1<<0)
101 #define IF_COMM_ALL (IF_COMM_MASK | IF_COMM_ARB | IF_COMM_CONTROL | \
102 IF_COMM_TXRQST | IF_COMM_DATAA | IF_COMM_DATAB)
104 #define IF_ARB_MSGVAL (1<<31)
105 #define IF_ARB_MSGXTD (1<<30)
106 #define IF_ARB_TRANSMIT (1<<29)
108 #define IF_MCONT_NEWDAT (1<<15)
109 #define IF_MCONT_MSGLST (1<<14)
110 #define IF_MCONT_INTPND (1<<13)
111 #define IF_MCONT_UMASK (1<<12)
112 #define IF_MCONT_TXIE (1<<11)
113 #define IF_MCONT_RXIE (1<<10)
114 #define IF_MCONT_RMTEN (1<<9)
115 #define IF_MCONT_TXRQST (1<<8)
116 #define IF_MCONT_EOB (1<<7)
118 #define MAX_OBJECT 31
119 #define MAX_TRANSMIT_OBJECT 15
120 #define RECEIVE_OBJECT_BITS 0xffff0000
124 struct net_device *dev;
127 struct delayed_work work;
128 u16 (*read_reg)(struct net_device *dev, enum c_regs reg);
129 void (*write_reg)(struct net_device *dev, enum c_regs reg, u16 val);
131 unsigned int bufstat[MAX_OBJECT + 1];
135 extern struct net_device *alloc_ccandev(int sizeof_priv);
136 extern void free_ccandev(struct net_device *dev);
137 extern int register_ccandev(struct net_device *dev);
138 extern void unregister_ccandev(struct net_device *dev);
140 #endif /* __CCAN_H__ */