1
2
3
4
5
6
7
8 #ifndef CC770_DEV_H
9 #define CC770_DEV_H
10
11 #include <linux/can/dev.h>
12
13 struct cc770_msgobj {
14 u8 ctrl0;
15 u8 ctrl1;
16 u8 id[4];
17 u8 config;
18 u8 data[8];
19 u8 dontuse;
20 } __packed;
21
22 struct cc770_regs {
23 union {
24 struct cc770_msgobj msgobj[16];
25 struct {
26 u8 control;
27 u8 status;
28 u8 cpu_interface;
29 u8 dontuse1;
30 u8 high_speed_read[2];
31 u8 global_mask_std[2];
32 u8 global_mask_ext[4];
33 u8 msg15_mask[4];
34 u8 dontuse2[15];
35 u8 clkout;
36 u8 dontuse3[15];
37 u8 bus_config;
38 u8 dontuse4[15];
39 u8 bit_timing_0;
40 u8 dontuse5[15];
41 u8 bit_timing_1;
42 u8 dontuse6[15];
43 u8 interrupt;
44 u8 dontuse7[15];
45 u8 rx_error_counter;
46 u8 dontuse8[15];
47 u8 tx_error_counter;
48 u8 dontuse9[31];
49 u8 p1_conf;
50 u8 dontuse10[15];
51 u8 p2_conf;
52 u8 dontuse11[15];
53 u8 p1_in;
54 u8 dontuse12[15];
55 u8 p2_in;
56 u8 dontuse13[15];
57 u8 p1_out;
58 u8 dontuse14[15];
59 u8 p2_out;
60 u8 dontuse15[15];
61 u8 serial_reset_addr;
62 };
63 };
64 } __packed;
65
66
67 #define CTRL_INI 0x01
68 #define CTRL_IE 0x02
69 #define CTRL_SIE 0x04
70 #define CTRL_EIE 0x08
71 #define CTRL_EAF 0x20
72 #define CTRL_CCE 0x40
73
74
75 #define STAT_LEC_STUFF 0x01
76 #define STAT_LEC_FORM 0x02
77 #define STAT_LEC_ACK 0x03
78 #define STAT_LEC_BIT1 0x04
79 #define STAT_LEC_BIT0 0x05
80 #define STAT_LEC_CRC 0x06
81 #define STAT_LEC_MASK 0x07
82 #define STAT_TXOK 0x08
83 #define STAT_RXOK 0x10
84 #define STAT_WAKE 0x20
85 #define STAT_WARN 0x40
86 #define STAT_BOFF 0x80
87
88
89
90
91
92
93
94
95
96
97 #define INTPND_RES 0x01
98 #define INTPND_SET 0x02
99 #define INTPND_UNC 0x03
100 #define RXIE_RES 0x04
101 #define RXIE_SET 0x08
102 #define RXIE_UNC 0x0c
103 #define TXIE_RES 0x10
104 #define TXIE_SET 0x20
105 #define TXIE_UNC 0x30
106 #define MSGVAL_RES 0x40
107 #define MSGVAL_SET 0x80
108 #define MSGVAL_UNC 0xc0
109
110
111 #define NEWDAT_RES 0x01
112 #define NEWDAT_SET 0x02
113 #define NEWDAT_UNC 0x03
114 #define MSGLST_RES 0x04
115 #define MSGLST_SET 0x08
116 #define MSGLST_UNC 0x0c
117 #define CPUUPD_RES 0x04
118 #define CPUUPD_SET 0x08
119 #define CPUUPD_UNC 0x0c
120 #define TXRQST_RES 0x10
121 #define TXRQST_SET 0x20
122 #define TXRQST_UNC 0x30
123 #define RMTPND_RES 0x40
124 #define RMTPND_SET 0x80
125 #define RMTPND_UNC 0xc0
126
127
128 #define MSGCFG_XTD 0x04
129 #define MSGCFG_DIR 0x08
130
131 #define MSGOBJ_FIRST 1
132 #define MSGOBJ_LAST 15
133
134 #define CC770_IO_SIZE 0x100
135 #define CC770_MAX_IRQ 20
136 #define CC770_MAX_MSG 4
137
138 #define CC770_ECHO_SKB_MAX 1
139
140 #define cc770_read_reg(priv, member) \
141 priv->read_reg(priv, offsetof(struct cc770_regs, member))
142
143 #define cc770_write_reg(priv, member, value) \
144 priv->write_reg(priv, offsetof(struct cc770_regs, member), value)
145
146
147
148
149 #define CC770_OBJ_FLAG_RX 0x01
150 #define CC770_OBJ_FLAG_RTR 0x02
151 #define CC770_OBJ_FLAG_EFF 0x04
152
153 enum {
154 CC770_OBJ_RX0 = 0,
155 CC770_OBJ_RX1,
156 CC770_OBJ_RX_RTR0,
157 CC770_OBJ_RX_RTR1,
158 CC770_OBJ_TX,
159 CC770_OBJ_MAX
160 };
161
162 #define obj2msgobj(o) (MSGOBJ_LAST - (o))
163
164
165
166
167 struct cc770_priv {
168 struct can_priv can;
169 struct sk_buff *echo_skb;
170
171
172 u8 (*read_reg)(const struct cc770_priv *priv, int reg);
173 void (*write_reg)(const struct cc770_priv *priv, int reg, u8 val);
174 void (*pre_irq)(const struct cc770_priv *priv);
175 void (*post_irq)(const struct cc770_priv *priv);
176
177 void *priv;
178 struct net_device *dev;
179
180 void __iomem *reg_base;
181 unsigned long irq_flags;
182
183 unsigned char obj_flags[CC770_OBJ_MAX];
184 u8 control_normal_mode;
185 u8 cpu_interface;
186 u8 clkout;
187 u8 bus_config;
188
189 struct sk_buff *tx_skb;
190 };
191
192 struct net_device *alloc_cc770dev(int sizeof_priv);
193 void free_cc770dev(struct net_device *dev);
194 int register_cc770dev(struct net_device *dev);
195 void unregister_cc770dev(struct net_device *dev);
196
197 #endif