0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LINUX_RIO_DRV_H
0010 #define LINUX_RIO_DRV_H
0011
0012 #include <linux/types.h>
0013 #include <linux/ioport.h>
0014 #include <linux/list.h>
0015 #include <linux/errno.h>
0016 #include <linux/string.h>
0017 #include <linux/rio.h>
0018
0019 extern int __rio_local_read_config_32(struct rio_mport *port, u32 offset,
0020 u32 * data);
0021 extern int __rio_local_write_config_32(struct rio_mport *port, u32 offset,
0022 u32 data);
0023 extern int __rio_local_read_config_16(struct rio_mport *port, u32 offset,
0024 u16 * data);
0025 extern int __rio_local_write_config_16(struct rio_mport *port, u32 offset,
0026 u16 data);
0027 extern int __rio_local_read_config_8(struct rio_mport *port, u32 offset,
0028 u8 * data);
0029 extern int __rio_local_write_config_8(struct rio_mport *port, u32 offset,
0030 u8 data);
0031
0032 extern int rio_mport_read_config_32(struct rio_mport *port, u16 destid,
0033 u8 hopcount, u32 offset, u32 * data);
0034 extern int rio_mport_write_config_32(struct rio_mport *port, u16 destid,
0035 u8 hopcount, u32 offset, u32 data);
0036 extern int rio_mport_read_config_16(struct rio_mport *port, u16 destid,
0037 u8 hopcount, u32 offset, u16 * data);
0038 extern int rio_mport_write_config_16(struct rio_mport *port, u16 destid,
0039 u8 hopcount, u32 offset, u16 data);
0040 extern int rio_mport_read_config_8(struct rio_mport *port, u16 destid,
0041 u8 hopcount, u32 offset, u8 * data);
0042 extern int rio_mport_write_config_8(struct rio_mport *port, u16 destid,
0043 u8 hopcount, u32 offset, u8 data);
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 static inline int rio_local_read_config_32(struct rio_mport *port, u32 offset,
0055 u32 * data)
0056 {
0057 return __rio_local_read_config_32(port, offset, data);
0058 }
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 static inline int rio_local_write_config_32(struct rio_mport *port, u32 offset,
0070 u32 data)
0071 {
0072 return __rio_local_write_config_32(port, offset, data);
0073 }
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 static inline int rio_local_read_config_16(struct rio_mport *port, u32 offset,
0085 u16 * data)
0086 {
0087 return __rio_local_read_config_16(port, offset, data);
0088 }
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 static inline int rio_local_write_config_16(struct rio_mport *port, u32 offset,
0101 u16 data)
0102 {
0103 return __rio_local_write_config_16(port, offset, data);
0104 }
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115 static inline int rio_local_read_config_8(struct rio_mport *port, u32 offset,
0116 u8 * data)
0117 {
0118 return __rio_local_read_config_8(port, offset, data);
0119 }
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130 static inline int rio_local_write_config_8(struct rio_mport *port, u32 offset,
0131 u8 data)
0132 {
0133 return __rio_local_write_config_8(port, offset, data);
0134 }
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145 static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset,
0146 u32 * data)
0147 {
0148 return rio_mport_read_config_32(rdev->net->hport, rdev->destid,
0149 rdev->hopcount, offset, data);
0150 };
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161 static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
0162 u32 data)
0163 {
0164 return rio_mport_write_config_32(rdev->net->hport, rdev->destid,
0165 rdev->hopcount, offset, data);
0166 };
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
0178 u16 * data)
0179 {
0180 return rio_mport_read_config_16(rdev->net->hport, rdev->destid,
0181 rdev->hopcount, offset, data);
0182 };
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193 static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
0194 u16 data)
0195 {
0196 return rio_mport_write_config_16(rdev->net->hport, rdev->destid,
0197 rdev->hopcount, offset, data);
0198 };
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209 static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
0210 {
0211 return rio_mport_read_config_8(rdev->net->hport, rdev->destid,
0212 rdev->hopcount, offset, data);
0213 };
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224 static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data)
0225 {
0226 return rio_mport_write_config_8(rdev->net->hport, rdev->destid,
0227 rdev->hopcount, offset, data);
0228 };
0229
0230 extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid,
0231 u16 data);
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241 static inline int rio_send_doorbell(struct rio_dev *rdev, u16 data)
0242 {
0243 return rio_mport_send_doorbell(rdev->net->hport, rdev->destid, data);
0244 };
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256 static inline void rio_init_mbox_res(struct resource *res, int start, int end)
0257 {
0258 memset(res, 0, sizeof(struct resource));
0259 res->start = start;
0260 res->end = end;
0261 res->flags = RIO_RESOURCE_MAILBOX;
0262 }
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274 static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end)
0275 {
0276 memset(res, 0, sizeof(struct resource));
0277 res->start = start;
0278 res->end = end;
0279 res->flags = RIO_RESOURCE_DOORBELL;
0280 }
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291 #define RIO_DEVICE(dev,ven) \
0292 .did = (dev), .vid = (ven), \
0293 .asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID
0294
0295
0296 extern int rio_request_outb_mbox(struct rio_mport *, void *, int, int,
0297 void (*)(struct rio_mport *, void *,int, int));
0298 extern int rio_release_outb_mbox(struct rio_mport *, int);
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311 static inline int rio_add_outb_message(struct rio_mport *mport,
0312 struct rio_dev *rdev, int mbox,
0313 void *buffer, size_t len)
0314 {
0315 return mport->ops->add_outb_message(mport, rdev, mbox,
0316 buffer, len);
0317 }
0318
0319 extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int,
0320 void (*)(struct rio_mport *, void *, int, int));
0321 extern int rio_release_inb_mbox(struct rio_mport *, int);
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332 static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox,
0333 void *buffer)
0334 {
0335 return mport->ops->add_inb_buffer(mport, mbox, buffer);
0336 }
0337
0338
0339
0340
0341
0342
0343
0344
0345 static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox)
0346 {
0347 return mport->ops->get_inb_message(mport, mbox);
0348 }
0349
0350
0351 extern int rio_request_inb_dbell(struct rio_mport *, void *, u16, u16,
0352 void (*)(struct rio_mport *, void *, u16, u16, u16));
0353 extern int rio_release_inb_dbell(struct rio_mport *, u16, u16);
0354 extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16);
0355 extern int rio_release_outb_dbell(struct rio_dev *, struct resource *);
0356
0357
0358 int rio_claim_resource(struct rio_dev *, int);
0359 int rio_request_regions(struct rio_dev *, char *);
0360 void rio_release_regions(struct rio_dev *);
0361 int rio_request_region(struct rio_dev *, int, char *);
0362 void rio_release_region(struct rio_dev *, int);
0363
0364
0365 extern int rio_map_inb_region(struct rio_mport *mport, dma_addr_t local,
0366 u64 rbase, u32 size, u32 rflags);
0367 extern void rio_unmap_inb_region(struct rio_mport *mport, dma_addr_t lstart);
0368 extern int rio_map_outb_region(struct rio_mport *mport, u16 destid, u64 rbase,
0369 u32 size, u32 rflags, dma_addr_t *local);
0370 extern void rio_unmap_outb_region(struct rio_mport *mport,
0371 u16 destid, u64 rstart);
0372
0373
0374 extern int rio_request_inb_pwrite(struct rio_dev *,
0375 int (*)(struct rio_dev *, union rio_pw_msg*, int));
0376 extern int rio_release_inb_pwrite(struct rio_dev *);
0377 extern int rio_add_mport_pw_handler(struct rio_mport *mport, void *dev_id,
0378 int (*pwcback)(struct rio_mport *mport, void *dev_id,
0379 union rio_pw_msg *msg, int step));
0380 extern int rio_del_mport_pw_handler(struct rio_mport *mport, void *dev_id,
0381 int (*pwcback)(struct rio_mport *mport, void *dev_id,
0382 union rio_pw_msg *msg, int step));
0383 extern int rio_inb_pwrite_handler(struct rio_mport *mport,
0384 union rio_pw_msg *pw_msg);
0385 extern void rio_pw_enable(struct rio_mport *mport, int enable);
0386
0387
0388 int rio_register_driver(struct rio_driver *);
0389 void rio_unregister_driver(struct rio_driver *);
0390 struct rio_dev *rio_dev_get(struct rio_dev *);
0391 void rio_dev_put(struct rio_dev *);
0392
0393 #ifdef CONFIG_RAPIDIO_DMA_ENGINE
0394 extern struct dma_chan *rio_request_dma(struct rio_dev *rdev);
0395 extern struct dma_chan *rio_request_mport_dma(struct rio_mport *mport);
0396 extern void rio_release_dma(struct dma_chan *dchan);
0397 extern struct dma_async_tx_descriptor *rio_dma_prep_slave_sg(
0398 struct rio_dev *rdev, struct dma_chan *dchan,
0399 struct rio_dma_data *data,
0400 enum dma_transfer_direction direction, unsigned long flags);
0401 extern struct dma_async_tx_descriptor *rio_dma_prep_xfer(
0402 struct dma_chan *dchan, u16 destid,
0403 struct rio_dma_data *data,
0404 enum dma_transfer_direction direction, unsigned long flags);
0405 #endif
0406
0407
0408
0409
0410
0411
0412
0413
0414 static inline const char *rio_name(struct rio_dev *rdev)
0415 {
0416 return dev_name(&rdev->dev);
0417 }
0418
0419
0420
0421
0422
0423
0424
0425
0426 static inline void *rio_get_drvdata(struct rio_dev *rdev)
0427 {
0428 return dev_get_drvdata(&rdev->dev);
0429 }
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439 static inline void rio_set_drvdata(struct rio_dev *rdev, void *data)
0440 {
0441 dev_set_drvdata(&rdev->dev, data);
0442 }
0443
0444
0445 extern u16 rio_local_get_device_id(struct rio_mport *port);
0446 extern void rio_local_set_device_id(struct rio_mport *port, u16 did);
0447 extern int rio_init_mports(void);
0448
0449 #endif