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 u8 hopcount = 0xff;
154 u16 destid = rdev->destid;
155
156 if (rdev->rswitch) {
157 destid = rdev->rswitch->destid;
158 hopcount = rdev->rswitch->hopcount;
159 }
160
161 return rio_mport_read_config_32(rdev->net->hport, destid, hopcount,
162 offset, data);
163};
164
165
166
167
168
169
170
171
172
173
174static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
175 u32 data)
176{
177 u8 hopcount = 0xff;
178 u16 destid = rdev->destid;
179
180 if (rdev->rswitch) {
181 destid = rdev->rswitch->destid;
182 hopcount = rdev->rswitch->hopcount;
183 }
184
185 return rio_mport_write_config_32(rdev->net->hport, destid, hopcount,
186 offset, data);
187};
188
189
190
191
192
193
194
195
196
197
198static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
199 u16 * data)
200{
201 u8 hopcount = 0xff;
202 u16 destid = rdev->destid;
203
204 if (rdev->rswitch) {
205 destid = rdev->rswitch->destid;
206 hopcount = rdev->rswitch->hopcount;
207 }
208
209 return rio_mport_read_config_16(rdev->net->hport, destid, hopcount,
210 offset, data);
211};
212
213
214
215
216
217
218
219
220
221
222static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
223 u16 data)
224{
225 u8 hopcount = 0xff;
226 u16 destid = rdev->destid;
227
228 if (rdev->rswitch) {
229 destid = rdev->rswitch->destid;
230 hopcount = rdev->rswitch->hopcount;
231 }
232
233 return rio_mport_write_config_16(rdev->net->hport, destid, hopcount,
234 offset, data);
235};
236
237
238
239
240
241
242
243
244
245
246static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
247{
248 u8 hopcount = 0xff;
249 u16 destid = rdev->destid;
250
251 if (rdev->rswitch) {
252 destid = rdev->rswitch->destid;
253 hopcount = rdev->rswitch->hopcount;
254 }
255
256 return rio_mport_read_config_8(rdev->net->hport, destid, hopcount,
257 offset, data);
258};
259
260
261
262
263
264
265
266
267
268
269static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data)
270{
271 u8 hopcount = 0xff;
272 u16 destid = rdev->destid;
273
274 if (rdev->rswitch) {
275 destid = rdev->rswitch->destid;
276 hopcount = rdev->rswitch->hopcount;
277 }
278
279 return rio_mport_write_config_8(rdev->net->hport, destid, hopcount,
280 offset, data);
281};
282
283extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid,
284 u16 data);
285
286
287
288
289
290
291
292
293
294static inline int rio_send_doorbell(struct rio_dev *rdev, u16 data)
295{
296 return rio_mport_send_doorbell(rdev->net->hport, rdev->destid, data);
297};
298
299
300
301
302
303
304
305
306
307
308
309static inline void rio_init_mbox_res(struct resource *res, int start, int end)
310{
311 memset(res, 0, sizeof(struct resource));
312 res->start = start;
313 res->end = end;
314 res->flags = RIO_RESOURCE_MAILBOX;
315}
316
317
318
319
320
321
322
323
324
325
326
327static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end)
328{
329 memset(res, 0, sizeof(struct resource));
330 res->start = start;
331 res->end = end;
332 res->flags = RIO_RESOURCE_DOORBELL;
333}
334
335
336
337
338
339
340
341
342
343
344#define RIO_DEVICE(dev,ven) \
345 .did = (dev), .vid = (ven), \
346 .asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID
347
348
349extern int rio_request_outb_mbox(struct rio_mport *, void *, int, int,
350 void (*)(struct rio_mport *, void *,int, int));
351extern int rio_release_outb_mbox(struct rio_mport *, int);
352
353
354
355
356
357
358
359
360
361
362
363
364static inline int rio_add_outb_message(struct rio_mport *mport,
365 struct rio_dev *rdev, int mbox,
366 void *buffer, size_t len)
367{
368 return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len);
369}
370
371extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int,
372 void (*)(struct rio_mport *, void *, int, int));
373extern int rio_release_inb_mbox(struct rio_mport *, int);
374
375
376
377
378
379
380
381
382
383
384static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox,
385 void *buffer)
386{
387 return rio_hw_add_inb_buffer(mport, mbox, buffer);
388}
389
390
391
392
393
394
395
396
397static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox)
398{
399 return rio_hw_get_inb_message(mport, mbox);
400}
401
402
403extern int rio_request_inb_dbell(struct rio_mport *, void *, u16, u16,
404 void (*)(struct rio_mport *, void *, u16, u16, u16));
405extern int rio_release_inb_dbell(struct rio_mport *, u16, u16);
406extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16);
407extern int rio_release_outb_dbell(struct rio_dev *, struct resource *);
408
409
410int rio_claim_resource(struct rio_dev *, int);
411int rio_request_regions(struct rio_dev *, char *);
412void rio_release_regions(struct rio_dev *);
413int rio_request_region(struct rio_dev *, int, char *);
414void rio_release_region(struct rio_dev *, int);
415
416
417int rio_register_driver(struct rio_driver *);
418void rio_unregister_driver(struct rio_driver *);
419struct rio_dev *rio_dev_get(struct rio_dev *);
420void rio_dev_put(struct rio_dev *);
421
422
423
424
425
426
427
428
429static inline const char *rio_name(struct rio_dev *rdev)
430{
431 return dev_name(&rdev->dev);
432}
433
434
435
436
437
438
439
440
441static inline void *rio_get_drvdata(struct rio_dev *rdev)
442{
443 return dev_get_drvdata(&rdev->dev);
444}
445
446
447
448
449
450
451
452
453
454static inline void rio_set_drvdata(struct rio_dev *rdev, void *data)
455{
456 dev_set_drvdata(&rdev->dev, data);
457}
458
459
460extern u16 rio_local_get_device_id(struct rio_mport *port);
461extern struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from);
462extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did,
463 struct rio_dev *from);
464
465#endif
466