exm_driver.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 _EXM_DRIVER_H_
  14. #define _EXM_DRIVER_H_
  15. #include <linux/fs.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/vmalloc.h>
  18. struct module;
  19. struct exm_map;
  20. /**
  21. * struct exm_mem - description of a EXM memory region
  22. * @name: name of the memory region for identification
  23. * @addr: address of the device's memory (phys_addr is used since
  24. * addr can be logical, virtual, or physical & phys_addr_t
  25. * should always be large enough to handle any of the
  26. * address types)
  27. * @size: size of IO
  28. * @memtype: type of memory addr points to
  29. * @internal_addr: ioremap-ped version of addr, for driver internal use
  30. * @map: for use by the EXM core only.
  31. */
  32. struct exm_mem {
  33. const char *name;
  34. phys_addr_t addr;
  35. unsigned long size;
  36. int memtype;
  37. void __iomem *internal_addr;
  38. struct exm_map *map;
  39. };
  40. #define MAX_EXM_MAPS 5
  41. struct exm_portio;
  42. /**
  43. * struct exm_port - description of a EXM port region
  44. * @name: name of the port region for identification
  45. * @start: start of port region
  46. * @size: size of port region
  47. * @porttype: type of port (see EXM_PORT_* below)
  48. * @portio: for use by the EXM core only.
  49. */
  50. struct exm_port {
  51. const char *name;
  52. unsigned long start;
  53. unsigned long size;
  54. int porttype;
  55. struct exm_portio *portio;
  56. };
  57. #define MAX_EXM_PORT_REGIONS 5
  58. struct exm_device;
  59. /**
  60. * struct exm_info - EXM device capabilities
  61. * @exm_dev: the EXM device this info belongs to
  62. * @name: device name
  63. * @version: device driver version
  64. * @mem: list of mappable memory regions, size==0 for end of list
  65. * @port: list of port regions, size==0 for end of list
  66. * @irq: interrupt number or EXM_IRQ_CUSTOM
  67. * @irq_flags: flags for request_irq()
  68. * @priv: optional private data
  69. * @handler: the device's irq handler
  70. * @mmap: mmap operation for this exm device
  71. * @open: open operation for this exm device
  72. * @release: release operation for this exm device
  73. * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/exmX
  74. */
  75. struct exm_info {
  76. struct exm_device *exm_dev;
  77. const char *name;
  78. const char *version;
  79. struct exm_mem mem[MAX_EXM_MAPS];
  80. struct exm_port port[MAX_EXM_PORT_REGIONS];
  81. long irq;
  82. unsigned long irq_flags;
  83. void *priv;
  84. irqreturn_t (*handler)(int irq, struct exm_info *dev_info);
  85. int (*mmap)(struct exm_info *info, struct vm_area_struct *vma);
  86. int (*open)(struct exm_info *info, struct inode *inode);
  87. int (*release)(struct exm_info *info, struct inode *inode);
  88. int (*irqcontrol)(struct exm_info *info, s32 irq_on);
  89. };
  90. extern int __must_check
  91. __exm_register_device(struct module *owner, struct device *parent, struct exm_info *info);
  92. /* use a define to avoid include chaining to get THIS_MODULE */
  93. #define exm_register_device(parent, info) \
  94. __exm_register_device(THIS_MODULE, parent, info)
  95. extern void exm_unregister_device(struct exm_info *info);
  96. extern void exm_event_notify(struct exm_info *info);
  97. /* defines for exm_info->irq */
  98. #define EXM_IRQ_CUSTOM -1
  99. #define EXM_IRQ_NONE 0
  100. /* defines for exm_mem->memtype */
  101. #define EXM_MEM_NONE 0
  102. #define EXM_MEM_PHYS 1
  103. #define EXM_MEM_LOGICAL 2
  104. #define EXM_MEM_VIRTUAL 3
  105. /* defines for exm_port->porttype */
  106. #define EXM_PORT_NONE 0
  107. #define EXM_PORT_X86 1
  108. #define EXM_PORT_GPIO 2
  109. #define EXM_PORT_OTHER 3
  110. extern bool extmem_in_mspace(struct vm_area_struct *vma);
  111. extern unsigned long get_virt_from_mspace(unsigned long pa);
  112. extern void *extmem_malloc_page_align(size_t bytes);
  113. extern size_t extmem_get_mem_size(unsigned long pgoff);
  114. extern void extmem_free(void *mem);
  115. extern void init_debug_alloc_pool_aligned(void);
  116. #endif /* _LINUX_EXM_DRIVER_H_ */