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/string.h>
21#include <linux/rio.h>
22
23extern int __rio_local_read_config_32(struct rio_mport *port, u32 offset,
24 u32 * data);
25extern int __rio_local_write_config_32(struct rio_mport *port, u32 offset,
26 u32 data);
27extern int __rio_local_read_config_16(struct rio_mport *port, u32 offset,
28 u16 * data);
29extern int __rio_local_write_config_16(struct rio_mport *port, u32 offset,
30 u16 data);
31extern int __rio_local_read_config_8(struct rio_mport *port, u32 offset,
32 u8 * data);
33extern int __rio_local_write_config_8(struct rio_mport *port, u32 offset,
34 u8 data);
35
36extern int rio_mport_read_config_32(struct rio_mport *port, u16 destid,
37 u8 hopcount, u32 offset, u32 * data);
38extern int rio_mport_write_config_32(struct rio_mport *port, u16 destid,
39 u8 hopcount, u32 offset, u32 data);
40extern int rio_mport_read_config_16(struct rio_mport *port, u16 destid,
41 u8 hopcount, u32 offset, u16 * data);
42extern int rio_mport_write_config_16(struct rio_mport *port, u16 destid,
43 u8 hopcount, u32 offset, u16 data);
44extern int rio_mport_read_config_8(struct rio_mport *port, u16 destid,
45 u8 hopcount, u32 offset, u8 * data);
46extern int rio_mport_write_config_8(struct rio_mport *port, u16 destid,
47 u8 hopcount, u32 offset, u8 data);
48
49
50
51
52
53
54
55
56
57
58static inline int rio_local_read_config_32(struct rio_mport *port, u32 offset,
59 u32 * data)
60{
61 return __rio_local_read_config_32(port, offset, data);
62}
63
64
65
66
67
68
69
70
71
72
73static inline int rio_local_write_config_32(struct rio_mport *port, u32 offset,
74 u32 data)
75{
76 return __rio_local_write_config_32(port, offset, data);
77}
78
79
80
81
82
83
84
85
86
87
88static inline int rio_local_read_config_16(struct rio_mport *port, u32 offset,
89 u16 * data)
90{
91 return __rio_local_read_config_16(port, offset, data);
92}
93
94
95
96
97
98
99
100
101
102
103
104static inline int rio_local_write_config_16(struct rio_mport *port, u32 offset,
105 u16 data)
106{
107 return __rio_local_write_config_16(port, offset, data);
108}
109
110
111
112
113
114
115
116
117
118
119static inline int rio_local_read_config_8(struct rio_mport *port, u32 offset,
120 u8 * data)
121{
122 return __rio_local_read_config_8(port, offset, data);
123}
124
125
126
127
128
129
130
131
132
133
134static inline int rio_local_write_config_8(struct rio_mport *port, u32 offset,
135 u8 data)
136{
137 return __rio_local_write_config_8(port, offset, data);
138}
139
140
141
142
143
144
145
146
147
148
149static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset,
150 u32 * data)
151{
152 return rio_mport_read_config_32(rdev->net->hport, rdev->destid,
153 rdev->hopcount, offset, data);
154};
155
156
157
158
159
160
161
162
163
164
165static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
166 u32 data)
167{
168 return rio_mport_write_config_32(rdev->net->hport, rdev->destid,
169 rdev->hopcount, offset, data);
170};
171
172
173
174
175
176
177
178
179
180
181static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
182 u16 * data)
183{
184 return rio_mport_read_config_16(rdev->net->hport, rdev->destid,
185 rdev->hopcount, offset, data);
186};
187
188
189
190
191
192
193
194
195
196
197static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
198 u16 data)
199{
200 return rio_mport_write_config_16(rdev->net->hport, rdev->destid,
201 rdev->hopcount, offset, data);
202};
203
204
205
206
207
208
209
210
211
212
213static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
214{
215 return rio_mport_read_config_8(rdev->net->hport, rdev->destid,
216 rdev->hopcount, offset, data);
217};
218
219
220
221
222
223
224
225
226
227
228static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data)
229{
230 return rio_mport_write_config_8(rdev->net->hport, rdev->destid,
231 rdev->hopcount, offset, data);
232};
233
234extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid,
235 u16 data);
236
237
238
239
240
241
242
243
244
245static inline int rio_send_doorbell(struct rio_dev *rdev, u16 data)
246{
247 return rio_mport_send_doorbell(rdev->net->hport, rdev->destid, data);
248};
249
250
251
252
253
254
255
256
257
258
259
260static inline void rio_init_mbox_res(struct resource *res, int start, int end)
261{
262 memset(res, 0, sizeof(struct resource));
263 res->start = start;
264 res->end = end;
265 res->flags = RIO_RESOURCE_MAILBOX;
266}
267
268
269
270
271
272
273
274
275
276
277
278static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end)
279{
280 memset(res, 0, sizeof(struct resource));
281 res->start = start;
282 res->end = end;
283 res->flags = RIO_RESOURCE_DOORBELL;
284}
285
286
287
288
289
290
291
292
293
294
295#define RIO_DEVICE(dev,ven) \
296 .did = (dev), .vid = (ven), \
297 .asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID
298
299
300extern int rio_request_outb_mbox(struct rio_mport *, void *, int, int,
301 void (*)(struct rio_mport *, void *,int, int));
302extern int rio_release_outb_mbox(struct rio_mport *, int);
303
304
305
306
307
308
309
310
311
312
313
314
315static inline int rio_add_outb_message(struct rio_mport *mport,
316 struct rio_dev *rdev, int mbox,
317 void *buffer, size_t len)
318{
319 return mport->ops->add_outb_message(mport, rdev, mbox,
320 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 mport->ops->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 mport->ops->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_map_inb_region(struct rio_mport *mport, dma_addr_t local,
370 u64 rbase, u32 size, u32 rflags);
371extern void rio_unmap_inb_region(struct rio_mport *mport, dma_addr_t lstart);
372extern int rio_map_outb_region(struct rio_mport *mport, u16 destid, u64 rbase,
373 u32 size, u32 rflags, dma_addr_t *local);
374extern void rio_unmap_outb_region(struct rio_mport *mport,
375 u16 destid, u64 rstart);
376
377
378extern int rio_request_inb_pwrite(struct rio_dev *,
379 int (*)(struct rio_dev *, union rio_pw_msg*, int));
380extern int rio_release_inb_pwrite(struct rio_dev *);
381extern int rio_add_mport_pw_handler(struct rio_mport *mport, void *dev_id,
382 int (*pwcback)(struct rio_mport *mport, void *dev_id,
383 union rio_pw_msg *msg, int step));
384extern int rio_del_mport_pw_handler(struct rio_mport *mport, void *dev_id,
385 int (*pwcback)(struct rio_mport *mport, void *dev_id,
386 union rio_pw_msg *msg, int step));
387extern int rio_inb_pwrite_handler(struct rio_mport *mport,
388 union rio_pw_msg *pw_msg);
389extern void rio_pw_enable(struct rio_mport *mport, int enable);
390
391
392int rio_register_driver(struct rio_driver *);
393void rio_unregister_driver(struct rio_driver *);
394struct rio_dev *rio_dev_get(struct rio_dev *);
395void rio_dev_put(struct rio_dev *);
396
397#ifdef CONFIG_RAPIDIO_DMA_ENGINE
398extern struct dma_chan *rio_request_dma(struct rio_dev *rdev);
399extern struct dma_chan *rio_request_mport_dma(struct rio_mport *mport);
400extern void rio_release_dma(struct dma_chan *dchan);
401extern struct dma_async_tx_descriptor *rio_dma_prep_slave_sg(
402 struct rio_dev *rdev, struct dma_chan *dchan,
403 struct rio_dma_data *data,
404 enum dma_transfer_direction direction, unsigned long flags);
405extern struct dma_async_tx_descriptor *rio_dma_prep_xfer(
406 struct dma_chan *dchan, u16 destid,
407 struct rio_dma_data *data,
408 enum dma_transfer_direction direction, unsigned long flags);
409#endif
410
411
412
413
414
415
416
417
418static inline const char *rio_name(struct rio_dev *rdev)
419{
420 return dev_name(&rdev->dev);
421}
422
423
424
425
426
427
428
429
430static inline void *rio_get_drvdata(struct rio_dev *rdev)
431{
432 return dev_get_drvdata(&rdev->dev);
433}
434
435
436
437
438
439
440
441
442
443static inline void rio_set_drvdata(struct rio_dev *rdev, void *data)
444{
445 dev_set_drvdata(&rdev->dev, data);
446}
447
448
449extern u16 rio_local_get_device_id(struct rio_mport *port);
450extern void rio_local_set_device_id(struct rio_mport *port, u16 did);
451extern struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from);
452extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did,
453 struct rio_dev *from);
454extern int rio_init_mports(void);
455
456#endif
457