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