uio_driver.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * include/linux/uio_driver.h
  3. *
  4. * Copyright(C) 2005, Benedikt Spranger <b.spranger@linutronix.de>
  5. * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
  6. * Copyright(C) 2006, Hans J. Koch <hjk@linutronix.de>
  7. * Copyright(C) 2006, Greg Kroah-Hartman <greg@kroah.com>
  8. *
  9. * Userspace IO driver.
  10. *
  11. * Licensed under the GPLv2 only.
  12. */
  13. #ifndef _UIO_DRIVER_H_
  14. #define _UIO_DRIVER_H_
  15. #include <linux/module.h>
  16. #include <linux/fs.h>
  17. #include <linux/interrupt.h>
  18. /**
  19. * struct uio_mem - description of a UIO memory region
  20. * @kobj: kobject for this mapping
  21. * @addr: address of the device's memory
  22. * @size: size of IO
  23. * @memtype: type of memory addr points to
  24. * @internal_addr: ioremap-ped version of addr, for driver internal use
  25. */
  26. struct uio_mem {
  27. struct kobject kobj;
  28. unsigned long addr;
  29. unsigned long size;
  30. int memtype;
  31. void __iomem *internal_addr;
  32. };
  33. #define MAX_UIO_MAPS 5
  34. struct uio_device;
  35. /**
  36. * struct uio_info - UIO device capabilities
  37. * @uio_dev: the UIO device this info belongs to
  38. * @name: device name
  39. * @version: device driver version
  40. * @mem: list of mappable memory regions, size==0 for end of list
  41. * @irq: interrupt number or UIO_IRQ_CUSTOM
  42. * @irq_flags: flags for request_irq()
  43. * @priv: optional private data
  44. * @handler: the device's irq handler
  45. * @mmap: mmap operation for this uio device
  46. * @open: open operation for this uio device
  47. * @release: release operation for this uio device
  48. */
  49. struct uio_info {
  50. struct uio_device *uio_dev;
  51. char *name;
  52. char *version;
  53. struct uio_mem mem[MAX_UIO_MAPS];
  54. long irq;
  55. unsigned long irq_flags;
  56. void *priv;
  57. irqreturn_t (*handler)(int irq, struct uio_info *dev_info);
  58. int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
  59. int (*open)(struct uio_info *info, struct inode *inode);
  60. int (*release)(struct uio_info *info, struct inode *inode);
  61. };
  62. extern int __must_check
  63. __uio_register_device(struct module *owner,
  64. struct device *parent,
  65. struct uio_info *info);
  66. static inline int __must_check
  67. uio_register_device(struct device *parent, struct uio_info *info)
  68. {
  69. return __uio_register_device(THIS_MODULE, parent, info);
  70. }
  71. extern void uio_unregister_device(struct uio_info *info);
  72. extern void uio_event_notify(struct uio_info *info);
  73. /* defines for uio_device->irq */
  74. #define UIO_IRQ_CUSTOM -1
  75. #define UIO_IRQ_NONE -2
  76. /* defines for uio_device->memtype */
  77. #define UIO_MEM_NONE 0
  78. #define UIO_MEM_PHYS 1
  79. #define UIO_MEM_LOGICAL 2
  80. #define UIO_MEM_VIRTUAL 3
  81. #endif /* _LINUX_UIO_DRIVER_H_ */