This source file includes following definitions.
- ipack_get_carrier
- ipack_put_carrier
1
2
3
4
5
6
7
8
9 #include <linux/mod_devicetable.h>
10 #include <linux/device.h>
11 #include <linux/interrupt.h>
12
13 #define IPACK_IDPROM_OFFSET_I 0x01
14 #define IPACK_IDPROM_OFFSET_P 0x03
15 #define IPACK_IDPROM_OFFSET_A 0x05
16 #define IPACK_IDPROM_OFFSET_C 0x07
17 #define IPACK_IDPROM_OFFSET_MANUFACTURER_ID 0x09
18 #define IPACK_IDPROM_OFFSET_MODEL 0x0B
19 #define IPACK_IDPROM_OFFSET_REVISION 0x0D
20 #define IPACK_IDPROM_OFFSET_RESERVED 0x0F
21 #define IPACK_IDPROM_OFFSET_DRIVER_ID_L 0x11
22 #define IPACK_IDPROM_OFFSET_DRIVER_ID_H 0x13
23 #define IPACK_IDPROM_OFFSET_NUM_BYTES 0x15
24 #define IPACK_IDPROM_OFFSET_CRC 0x17
25
26
27
28
29
30
31 #define IPACK_ID_VERSION_INVALID 0x00
32 #define IPACK_ID_VERSION_1 0x01
33 #define IPACK_ID_VERSION_2 0x02
34
35
36 #define IPACK1_VENDOR_ID_RESERVED1 0x00
37 #define IPACK1_VENDOR_ID_RESERVED2 0xFF
38 #define IPACK1_VENDOR_ID_UNREGISTRED01 0x01
39 #define IPACK1_VENDOR_ID_UNREGISTRED02 0x02
40 #define IPACK1_VENDOR_ID_UNREGISTRED03 0x03
41 #define IPACK1_VENDOR_ID_UNREGISTRED04 0x04
42 #define IPACK1_VENDOR_ID_UNREGISTRED05 0x05
43 #define IPACK1_VENDOR_ID_UNREGISTRED06 0x06
44 #define IPACK1_VENDOR_ID_UNREGISTRED07 0x07
45 #define IPACK1_VENDOR_ID_UNREGISTRED08 0x08
46 #define IPACK1_VENDOR_ID_UNREGISTRED09 0x09
47 #define IPACK1_VENDOR_ID_UNREGISTRED10 0x0A
48 #define IPACK1_VENDOR_ID_UNREGISTRED11 0x0B
49 #define IPACK1_VENDOR_ID_UNREGISTRED12 0x0C
50 #define IPACK1_VENDOR_ID_UNREGISTRED13 0x0D
51 #define IPACK1_VENDOR_ID_UNREGISTRED14 0x0E
52 #define IPACK1_VENDOR_ID_UNREGISTRED15 0x0F
53
54 #define IPACK1_VENDOR_ID_SBS 0xF0
55 #define IPACK1_DEVICE_ID_SBS_OCTAL_232 0x22
56 #define IPACK1_DEVICE_ID_SBS_OCTAL_422 0x2A
57 #define IPACK1_DEVICE_ID_SBS_OCTAL_485 0x48
58
59 struct ipack_bus_ops;
60 struct ipack_driver;
61
62 enum ipack_space {
63 IPACK_IO_SPACE = 0,
64 IPACK_ID_SPACE,
65 IPACK_INT_SPACE,
66 IPACK_MEM8_SPACE,
67 IPACK_MEM16_SPACE,
68
69
70 IPACK_SPACE_COUNT,
71 };
72
73
74
75 struct ipack_region {
76 phys_addr_t start;
77 size_t size;
78 };
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94 struct ipack_device {
95 unsigned int slot;
96 struct ipack_bus_device *bus;
97 struct device dev;
98 void (*release) (struct ipack_device *dev);
99 struct ipack_region region[IPACK_SPACE_COUNT];
100 u8 *id;
101 size_t id_avail;
102 u32 id_vendor;
103 u32 id_device;
104 u8 id_format;
105 unsigned int id_crc_correct:1;
106 unsigned int speed_8mhz:1;
107 unsigned int speed_32mhz:1;
108 };
109
110
111
112
113
114
115
116
117
118 struct ipack_driver_ops {
119 int (*probe) (struct ipack_device *dev);
120 void (*remove) (struct ipack_device *dev);
121 };
122
123
124
125
126
127
128
129 struct ipack_driver {
130 struct device_driver driver;
131 const struct ipack_device_id *id_table;
132 const struct ipack_driver_ops *ops;
133 };
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 struct ipack_bus_ops {
153 int (*request_irq) (struct ipack_device *dev,
154 irqreturn_t (*handler)(void *), void *arg);
155 int (*free_irq) (struct ipack_device *dev);
156 int (*get_clockrate) (struct ipack_device *dev);
157 int (*set_clockrate) (struct ipack_device *dev, int mherz);
158 int (*get_error) (struct ipack_device *dev);
159 int (*get_timeout) (struct ipack_device *dev);
160 int (*reset_timeout) (struct ipack_device *dev);
161 };
162
163
164
165
166
167
168
169
170
171 struct ipack_bus_device {
172 struct module *owner;
173 struct device *parent;
174 int slots;
175 int bus_nr;
176 const struct ipack_bus_ops *ops;
177 };
178
179
180
181
182
183
184
185
186
187
188
189 struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
190 const struct ipack_bus_ops *ops,
191 struct module *owner);
192
193
194
195
196 int ipack_bus_unregister(struct ipack_bus_device *bus);
197
198
199
200
201
202
203
204 int ipack_driver_register(struct ipack_driver *edrv, struct module *owner,
205 const char *name);
206 void ipack_driver_unregister(struct ipack_driver *edrv);
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224 int ipack_device_init(struct ipack_device *dev);
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239 int ipack_device_add(struct ipack_device *dev);
240 void ipack_device_del(struct ipack_device *dev);
241
242 void ipack_get_device(struct ipack_device *dev);
243 void ipack_put_device(struct ipack_device *dev);
244
245
246
247
248
249
250
251
252 #define DEFINE_IPACK_DEVICE_TABLE(_table) \
253 const struct ipack_device_id _table[]
254
255
256
257
258
259
260
261
262
263 #define IPACK_DEVICE(_format, vend, dev) \
264 .format = (_format), \
265 .vendor = (vend), \
266 .device = (dev)
267
268
269
270
271
272
273 static inline int ipack_get_carrier(struct ipack_device *dev)
274 {
275 return try_module_get(dev->bus->owner);
276 }
277
278
279
280
281
282
283 static inline void ipack_put_carrier(struct ipack_device *dev)
284 {
285 module_put(dev->bus->owner);
286 }