uio_driver.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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@hansjkoch.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. struct uio_map;
  19. /**
  20. * struct uio_mem - description of a UIO memory region
  21. * @name: name of the memory region for identification
  22. * @addr: address of the device's memory
  23. * @size: size of IO
  24. * @memtype: type of memory addr points to
  25. * @internal_addr: ioremap-ped version of addr, for driver internal use
  26. * @map: for use by the UIO core only.
  27. */
  28. struct uio_mem {
  29. const char *name;
  30. unsigned long addr;
  31. unsigned long size;
  32. int memtype;
  33. void __iomem *internal_addr;
  34. struct uio_map *map;
  35. };
  36. #define MAX_UIO_MAPS 5
  37. struct uio_portio;
  38. /**
  39. * struct uio_port - description of a UIO port region
  40. * @name: name of the port region for identification
  41. * @start: start of port region
  42. * @size: size of port region
  43. * @porttype: type of port (see UIO_PORT_* below)
  44. * @portio: for use by the UIO core only.
  45. */
  46. struct uio_port {
  47. const char *name;
  48. unsigned long start;
  49. unsigned long size;
  50. int porttype;
  51. struct uio_portio *portio;
  52. };
  53. #define MAX_UIO_PORT_REGIONS 5
  54. struct uio_device;
  55. /**
  56. * struct uio_info - UIO device capabilities
  57. * @uio_dev: the UIO device this info belongs to
  58. * @name: device name
  59. * @version: device driver version
  60. * @mem: list of mappable memory regions, size==0 for end of list
  61. * @port: list of port regions, size==0 for end of list
  62. * @irq: interrupt number or UIO_IRQ_CUSTOM
  63. * @irq_flags: flags for request_irq()
  64. * @priv: optional private data
  65. * @handler: the device's irq handler
  66. * @mmap: mmap operation for this uio device
  67. * @open: open operation for this uio device
  68. * @release: release operation for this uio device
  69. * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX
  70. */
  71. struct uio_info {
  72. struct uio_device *uio_dev;
  73. const char *name;
  74. const char *version;
  75. struct uio_mem mem[MAX_UIO_MAPS];
  76. struct uio_port port[MAX_UIO_PORT_REGIONS];
  77. long irq;
  78. unsigned long irq_flags;
  79. void *priv;
  80. irqreturn_t (*handler)(int irq, struct uio_info *dev_info);
  81. int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
  82. int (*open)(struct uio_info *info, struct inode *inode);
  83. int (*release)(struct uio_info *info, struct inode *inode);
  84. int (*irqcontrol)(struct uio_info *info, s32 irq_on);
  85. };
  86. extern int __must_check
  87. __uio_register_device(struct module *owner,
  88. struct device *parent,
  89. struct uio_info *info);
  90. static inline int __must_check
  91. uio_register_device(struct device *parent, struct uio_info *info)
  92. {
  93. return __uio_register_device(THIS_MODULE, parent, info);
  94. }
  95. extern void uio_unregister_device(struct uio_info *info);
  96. extern void uio_event_notify(struct uio_info *info);
  97. /* defines for uio_info->irq */
  98. #define UIO_IRQ_CUSTOM -1
  99. #define UIO_IRQ_NONE 0
  100. /* defines for uio_mem->memtype */
  101. #define UIO_MEM_NONE 0
  102. #define UIO_MEM_PHYS 1
  103. #define UIO_MEM_LOGICAL 2
  104. #define UIO_MEM_VIRTUAL 3
  105. /* defines for uio_port->porttype */
  106. #define UIO_PORT_NONE 0
  107. #define UIO_PORT_X86 1
  108. #define UIO_PORT_GPIO 2
  109. #define UIO_PORT_OTHER 3
  110. #endif /* _LINUX_UIO_DRIVER_H_ */