0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef _UIO_DRIVER_H_
0014 #define _UIO_DRIVER_H_
0015
0016 #include <linux/device.h>
0017 #include <linux/fs.h>
0018 #include <linux/interrupt.h>
0019
0020 struct module;
0021 struct uio_map;
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 struct uio_mem {
0038 const char *name;
0039 phys_addr_t addr;
0040 unsigned long offs;
0041 resource_size_t size;
0042 int memtype;
0043 void __iomem *internal_addr;
0044 struct uio_map *map;
0045 };
0046
0047 #define MAX_UIO_MAPS 5
0048
0049 struct uio_portio;
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 struct uio_port {
0060 const char *name;
0061 unsigned long start;
0062 unsigned long size;
0063 int porttype;
0064 struct uio_portio *portio;
0065 };
0066
0067 #define MAX_UIO_PORT_REGIONS 5
0068
0069 struct uio_device {
0070 struct module *owner;
0071 struct device dev;
0072 int minor;
0073 atomic_t event;
0074 struct fasync_struct *async_queue;
0075 wait_queue_head_t wait;
0076 struct uio_info *info;
0077 struct mutex info_lock;
0078 struct kobject *map_dir;
0079 struct kobject *portio_dir;
0080 };
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098 struct uio_info {
0099 struct uio_device *uio_dev;
0100 const char *name;
0101 const char *version;
0102 struct uio_mem mem[MAX_UIO_MAPS];
0103 struct uio_port port[MAX_UIO_PORT_REGIONS];
0104 long irq;
0105 unsigned long irq_flags;
0106 void *priv;
0107 irqreturn_t (*handler)(int irq, struct uio_info *dev_info);
0108 int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
0109 int (*open)(struct uio_info *info, struct inode *inode);
0110 int (*release)(struct uio_info *info, struct inode *inode);
0111 int (*irqcontrol)(struct uio_info *info, s32 irq_on);
0112 };
0113
0114 extern int __must_check
0115 __uio_register_device(struct module *owner,
0116 struct device *parent,
0117 struct uio_info *info);
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 #define uio_register_device(parent, info) \
0129 __uio_register_device(THIS_MODULE, parent, info)
0130
0131 extern void uio_unregister_device(struct uio_info *info);
0132 extern void uio_event_notify(struct uio_info *info);
0133
0134 extern int __must_check
0135 __devm_uio_register_device(struct module *owner,
0136 struct device *parent,
0137 struct uio_info *info);
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 #define devm_uio_register_device(parent, info) \
0149 __devm_uio_register_device(THIS_MODULE, parent, info)
0150
0151
0152 #define UIO_IRQ_CUSTOM -1
0153 #define UIO_IRQ_NONE 0
0154
0155
0156 #define UIO_MEM_NONE 0
0157 #define UIO_MEM_PHYS 1
0158 #define UIO_MEM_LOGICAL 2
0159 #define UIO_MEM_VIRTUAL 3
0160 #define UIO_MEM_IOVA 4
0161
0162
0163 #define UIO_PORT_NONE 0
0164 #define UIO_PORT_X86 1
0165 #define UIO_PORT_GPIO 2
0166 #define UIO_PORT_OTHER 3
0167
0168 #endif