uio_driver.h 3.5 KB

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