1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LINUX_RIO_DRV_H
14#define LINUX_RIO_DRV_H
15
16#include <linux/types.h>
17#include <linux/ioport.h>
18#include <linux/list.h>
19#include <linux/errno.h>
20#include <linux/device.h>
21#include <linux/string.h>
22#include <linux/rio.h>
23
24extern int __rio_local_read_config_32(struct rio_mport *port, u32 offset,
25 u32 * data);
26extern int __rio_local_write_config_32(struct rio_mport *port, u32 offset,
27 u32 data);
28extern int __rio_local_read_config_16(struct rio_mport *port, u32 offset,
29 u16 * data);
30extern int __rio_local_write_config_16(struct rio_mport *port, u32 offset,
31 u16 data);
32extern int __rio_local_read_config_8(struct rio_mport *port, u32 offset,
33 u8 * data);
34extern int __rio_local_write_config_8(struct rio_mport *port, u32 offset,
35 u8 data);
36
37extern int rio_mport_read_config_32(struct rio_mport *port, u16 destid,
38 u8 hopcount, u32 offset, u32 * data);
39extern int rio_mport_write_config_32(struct rio_mport *port, u16 destid,
40 u8 hopcount, u32 offset, u32 data);
41extern int rio_mport_read_config_16(struct rio_mport *port, u16 destid,
42 u8 hopcount, u32 offset, u16 * data);
43extern int rio_mport_write_config_16(struct rio_mport *port, u16 destid,
44 u8 hopcount, u32 offset, u16 data);
45extern int rio_mport_read_config_8(struct rio_mport *port, u16 destid,
46 u8 hopcount, u32 offset, u8 * data);
47extern int rio_mport_write_config_8(struct rio_mport *port, u16 destid,
48 u8 hopcount, u32 offset, u8 data);
49
50
51
52
53
54
55
56
57
58
59static inline int rio_local_read_config_32(struct rio_mport *port, u32 offset,
60 u32 * data)
61{
62 return __rio_local_read_config_32(port, offset, data);
63}
64
65
66
67
68
69
70
71
72
73
74static inline int rio_local_write_config_32(struct rio_mport *port, u32 offset,
75 u32 data)
76{
77 return __rio_local_write_config_32(port, offset, data);
78}
79
80
81
82
83
84
85
86
87
88
89static inline int rio_local_read_config_16(struct rio_mport *port, u32 offset,
90 u16 * data)
91{
92 return __rio_local_read_config_16(port, offset, data);
93}
94
95
96
97
98
99
100
101
102
103
104
105static inline int rio_local_write_config_16(struct rio_mport *port, u32 offset,
106 u16 data)
107{
108 return __rio_local_write_config_16(port, offset, data);
109}
110
111
112
113
114
115
116
117
118
119
120static inline int rio_local_read_config_8(struct rio_mport *port, u32 offset,
121 u8 * data)
122{
123 return __rio_local_read_config_8(port, offset, data);
124}
125
126
127
128
129
130
131
132
133
134
135static inline int rio_local_write_config_8(struct rio_mport *port, u32 offset,
136 u8 data)
137{
138 return __rio_local_write_config_8(port, offset, data);
139}
140
141
142
143
144
145
146
147
148
149
150static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset,
151 u32 * data)
152{
153 return rio_mport_read_config_32(rdev->net->hport, rdev->destid,
154 rdev->hopcount, offset, data);
155};
156
157
158
159
160
161
162
163
164
165
166static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
167 u32 data)
168{
169 return rio_mport_write_config_32(rdev->net->hport, rdev->destid,
170 rdev->hopcount, offset, data);
171};
172
173
174
175
176
177
178
179
180
181
182static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
183 u16 * data)
184{
185 return rio_mport_read_config_16(rdev->net->hport, rdev->destid,
186 rdev->hopcount, offset, data);
187};
188
189
190
191
192
193
194
195
196
197
198static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
199 u16 data)
200{
201 return rio_mport_write_config_16(rdev->net->hport, rdev->destid,
202 rdev->hopcount, offset, data);
203};
204
205
206
207
208
209
210
211
212
213
214static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
215{
216 return rio_mport_read_config_8(rdev->net->hport, rdev->destid,
217 rdev->hopcount, offset, data);
218};
219
220
221
222
223
224
225
226
227
228
229static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data)
230{
231 return rio_mport_write_config_8(rdev->net->hport, rdev->destid,
232 rdev->hopcount, offset, data);
233};
234
235extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid,
236 u16 data);
237
238
239
240
241
242
243
244
245
246static inline int rio_send_doorbell(struct rio_dev *rdev, u16 data)
247{
248 return rio_mport_send_doorbell(rdev->net->hport, rdev->destid, data);
249};
250
251
252
253
254
255
256
257
258
259
260
261static inline void rio_init_mbox_res(struct resource *res, int start, int end)
262{
263 memset(res, 0, sizeof(struct resource));
264 res->start = start;
265 res->end = end;
266 res->flags = RIO_RESOURCE_MAILBOX;
267}
268
269
270
271
272
273
274
275
276
277
278
279static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end)
280{
281 memset(res, 0, sizeof(struct resource));
282 res->start = start;
283 res->end = end;
284 res->flags = RIO_RESOURCE_DOORBELL;
285}
286
287
288
289
290
291
292
293
294
295
296#define RIO_DEVICE(dev,ven) \
297 .did = (dev), .vid = (ven), \
298 .asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID
299
300
301extern int rio_request_outb_mbox(struct rio_mport *, void *, int, int,
302 void (*)(struct rio_mport *, void *,int, int));
303extern int rio_release_outb_mbox(struct rio_mport *, int);
304
305
306
307
308
309
310
311
312
313
314
315
316static inline int rio_add_outb_message(struct rio_mport *mport,
317 struct rio_dev *rdev, int mbox,
318 void *buffer, size_t len)
319{
320 return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len);
321}
322
323extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int,
324 void (*)(struct rio_mport *, void *, int, int));
325extern int rio_release_inb_mbox(struct rio_mport *, int);
326
327
328
329
330
331
332
333
334
335
336static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox,
337 void *buffer)
338{
339 return rio_hw_add_inb_buffer(mport, mbox, buffer);
340}
341
342
343
344
345
346
347
348
349static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox)
350{
351 return rio_hw_get_inb_message(mport, mbox);
352}
353
354
355extern int rio_request_inb_dbell(struct rio_mport *, void *, u16, u16,
356 void (*)(struct rio_mport *, void *, u16, u16, u16));
357extern int rio_release_inb_dbell(struct rio_mport *, u16, u16);
358extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16);
359extern int rio_release_outb_dbell(struct rio_dev *, struct resource *);
360
361
362int rio_claim_resource(struct rio_dev *, int);
363int rio_request_regions(struct rio_dev *, char *);
364void rio_release_regions(struct rio_dev *);
365int rio_request_region(struct rio_dev *, int, char *);
366void rio_release_region(struct rio_dev *, int);
367
368
369extern int rio_request_inb_pwrite(struct rio_dev *,
370 int (*)(struct rio_dev *, union rio_pw_msg*, int));
371extern int rio_release_inb_pwrite(struct rio_dev *);
372extern int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg);
373
374
375int rio_register_driver(struct rio_driver *);
376void rio_unregister_driver(struct rio_driver *);
377struct rio_dev *rio_dev_get(struct rio_dev *);
378void rio_dev_put(struct rio_dev *);
379
380
381
382
383
384
385
386
387static inline const char *rio_name(struct rio_dev *rdev)
388{
389 return dev_name(&rdev->dev);
390}
391
392
393
394
395
396
397
398
399static inline void *rio_get_drvdata(struct rio_dev *rdev)
400{
401 return dev_get_drvdata(&rdev->dev);
402}
403
404
405
406
407
408
409
410
411
412static inline void rio_set_drvdata(struct rio_dev *rdev, void *data)
413{
414 dev_set_drvdata(&rdev->dev, data);
415}
416
417
418extern u16 rio_local_get_device_id(struct rio_mport *port);
419extern struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from);
420extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did,
421 struct rio_dev *from);
422
423#endif
424