uio_driver.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. struct uio_map;
  19. /**
  20. * struct uio_mem - description of a UIO memory region
  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. * @map: for use by the UIO core only.
  26. */
  27. struct uio_mem {
  28. unsigned long addr;
  29. unsigned long size;
  30. int memtype;
  31. void __iomem *internal_addr;
  32. struct uio_map *map;
  33. };
  34. #define MAX_UIO_MAPS 5
  35. struct uio_device;
  36. /**
  37. * struct uio_info - UIO device capabilities
  38. * @uio_dev: the UIO device this info belongs to
  39. * @name: device name
  40. * @version: device driver version
  41. * @mem: list of mappable memory regions, size==0 for end of list
  42. * @irq: interrupt number or UIO_IRQ_CUSTOM
  43. * @irq_flags: flags for request_irq()
  44. * @priv: optional private data
  45. * @handler: the device's irq handler
  46. * @mmap: mmap operation for this uio device
  47. * @open: open operation for this uio device
  48. * @release: release operation for this uio device
  49. * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX
  50. */
  51. struct uio_info {
  52. struct uio_device *uio_dev;
  53. char *name;
  54. char *version;
  55. struct uio_mem mem[MAX_UIO_MAPS];
  56. long irq;
  57. unsigned long irq_flags;
  58. void *priv;
  59. irqreturn_t (*handler)(int irq, struct uio_info *dev_info);
  60. int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
  61. int (*open)(struct uio_info *info, struct inode *inode);
  62. int (*release)(struct uio_info *info, struct inode *inode);
  63. int (*irqcontrol)(struct uio_info *info, s32 irq_on);
  64. };
  65. extern int __must_check
  66. __uio_register_device(struct module *owner,
  67. struct device *parent,
  68. struct uio_info *info);
  69. static inline int __must_check
  70. uio_register_device(struct device *parent, struct uio_info *info)
  71. {
  72. return __uio_register_device(THIS_MODULE, parent, info);
  73. }
  74. extern void uio_unregister_device(struct uio_info *info);
  75. extern void uio_event_notify(struct uio_info *info);
  76. /* defines for uio_device->irq */
  77. #define UIO_IRQ_CUSTOM -1
  78. #define UIO_IRQ_NONE -2
  79. /* defines for uio_device->memtype */
  80. #define UIO_MEM_NONE 0
  81. #define UIO_MEM_PHYS 1
  82. #define UIO_MEM_LOGICAL 2
  83. #define UIO_MEM_VIRTUAL 3
  84. #endif /* _LINUX_UIO_DRIVER_H_ */