1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef _UIO_DRIVER_H_
15#define _UIO_DRIVER_H_
16
17#include <linux/device.h>
18#include <linux/fs.h>
19#include <linux/interrupt.h>
20
21struct module;
22struct uio_map;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38struct uio_mem {
39 const char *name;
40 phys_addr_t addr;
41 unsigned long offs;
42 resource_size_t size;
43 int memtype;
44 void __iomem *internal_addr;
45 struct uio_map *map;
46};
47
48#define MAX_UIO_MAPS 5
49
50struct uio_portio;
51
52
53
54
55
56
57
58
59
60struct uio_port {
61 const char *name;
62 unsigned long start;
63 unsigned long size;
64 int porttype;
65 struct uio_portio *portio;
66};
67
68#define MAX_UIO_PORT_REGIONS 5
69
70struct uio_device {
71 struct module *owner;
72 struct device dev;
73 int minor;
74 atomic_t event;
75 struct fasync_struct *async_queue;
76 wait_queue_head_t wait;
77 struct uio_info *info;
78 struct mutex info_lock;
79 struct kobject *map_dir;
80 struct kobject *portio_dir;
81};
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99struct uio_info {
100 struct uio_device *uio_dev;
101 const char *name;
102 const char *version;
103 struct uio_mem mem[MAX_UIO_MAPS];
104 struct uio_port port[MAX_UIO_PORT_REGIONS];
105 long irq;
106 unsigned long irq_flags;
107 void *priv;
108 irqreturn_t (*handler)(int irq, struct uio_info *dev_info);
109 int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
110 int (*open)(struct uio_info *info, struct inode *inode);
111 int (*release)(struct uio_info *info, struct inode *inode);
112 int (*irqcontrol)(struct uio_info *info, s32 irq_on);
113};
114
115extern int __must_check
116 __uio_register_device(struct module *owner,
117 struct device *parent,
118 struct uio_info *info);
119
120
121#define uio_register_device(parent, info) \
122 __uio_register_device(THIS_MODULE, parent, info)
123
124extern void uio_unregister_device(struct uio_info *info);
125extern void uio_event_notify(struct uio_info *info);
126
127
128#define UIO_IRQ_CUSTOM -1
129#define UIO_IRQ_NONE 0
130
131
132#define UIO_MEM_NONE 0
133#define UIO_MEM_PHYS 1
134#define UIO_MEM_LOGICAL 2
135#define UIO_MEM_VIRTUAL 3
136#define UIO_MEM_IOVA 4
137
138
139#define UIO_PORT_NONE 0
140#define UIO_PORT_X86 1
141#define UIO_PORT_GPIO 2
142#define UIO_PORT_OTHER 3
143
144#endif
145