Blame view

include/linux/uio_driver.h 3.38 KB
beafc54c4   Hans J. Koch   UIO: Add the User...
1
2
3
4
5
  /*
   * include/linux/uio_driver.h
   *
   * Copyright(C) 2005, Benedikt Spranger <b.spranger@linutronix.de>
   * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
318af55dd   Hans J. Koch   uio: Change mail ...
6
   * Copyright(C) 2006, Hans J. Koch <hjk@hansjkoch.de>
beafc54c4   Hans J. Koch   UIO: Add the User...
7
8
9
10
11
12
13
14
15
16
17
18
19
   * Copyright(C) 2006, Greg Kroah-Hartman <greg@kroah.com>
   *
   * Userspace IO driver.
   *
   * Licensed under the GPLv2 only.
   */
  
  #ifndef _UIO_DRIVER_H_
  #define _UIO_DRIVER_H_
  
  #include <linux/module.h>
  #include <linux/fs.h>
  #include <linux/interrupt.h>
81e7c6a63   Greg Kroah-Hartman   UIO: fix kobject ...
20
  struct uio_map;
beafc54c4   Hans J. Koch   UIO: Add the User...
21
22
  /**
   * struct uio_mem - description of a UIO memory region
820577911   Hans J. Koch   UIO: Add name att...
23
   * @name:		name of the memory region for identification
beafc54c4   Hans J. Koch   UIO: Add the User...
24
25
26
27
   * @addr:		address of the device's memory
   * @size:		size of IO
   * @memtype:		type of memory addr points to
   * @internal_addr:	ioremap-ped version of addr, for driver internal use
81e7c6a63   Greg Kroah-Hartman   UIO: fix kobject ...
28
   * @map:		for use by the UIO core only.
beafc54c4   Hans J. Koch   UIO: Add the User...
29
30
   */
  struct uio_mem {
820577911   Hans J. Koch   UIO: Add name att...
31
  	const char		*name;
beafc54c4   Hans J. Koch   UIO: Add the User...
32
33
34
35
  	unsigned long		addr;
  	unsigned long		size;
  	int			memtype;
  	void __iomem		*internal_addr;
81e7c6a63   Greg Kroah-Hartman   UIO: fix kobject ...
36
  	struct uio_map		*map;
beafc54c4   Hans J. Koch   UIO: Add the User...
37
  };
6d8333c24   Uwe Kleine-König   UIO: minor style ...
38
  #define MAX_UIO_MAPS	5
beafc54c4   Hans J. Koch   UIO: Add the User...
39

e70c412ee   Hans J. Koch   UIO: Pass informa...
40
41
42
43
  struct uio_portio;
  
  /**
   * struct uio_port - description of a UIO port region
820577911   Hans J. Koch   UIO: Add name att...
44
   * @name:		name of the port region for identification
e70c412ee   Hans J. Koch   UIO: Pass informa...
45
46
47
48
49
50
   * @start:		start of port region
   * @size:		size of port region
   * @porttype:		type of port (see UIO_PORT_* below)
   * @portio:		for use by the UIO core only.
   */
  struct uio_port {
820577911   Hans J. Koch   UIO: Add name att...
51
  	const char		*name;
e70c412ee   Hans J. Koch   UIO: Pass informa...
52
53
54
55
56
57
58
  	unsigned long		start;
  	unsigned long		size;
  	int			porttype;
  	struct uio_portio	*portio;
  };
  
  #define MAX_UIO_PORT_REGIONS	5
beafc54c4   Hans J. Koch   UIO: Add the User...
59
60
61
62
63
64
65
66
  struct uio_device;
  
  /**
   * struct uio_info - UIO device capabilities
   * @uio_dev:		the UIO device this info belongs to
   * @name:		device name
   * @version:		device driver version
   * @mem:		list of mappable memory regions, size==0 for end of list
e70c412ee   Hans J. Koch   UIO: Pass informa...
67
   * @port:		list of port regions, size==0 for end of list
beafc54c4   Hans J. Koch   UIO: Add the User...
68
69
70
71
72
73
74
   * @irq:		interrupt number or UIO_IRQ_CUSTOM
   * @irq_flags:		flags for request_irq()
   * @priv:		optional private data
   * @handler:		the device's irq handler
   * @mmap:		mmap operation for this uio device
   * @open:		open operation for this uio device
   * @release:		release operation for this uio device
328a14e70   Hans J. Koch   UIO: Add write fu...
75
   * @irqcontrol:		disable/enable irqs when 0/1 is written to /dev/uioX
beafc54c4   Hans J. Koch   UIO: Add the User...
76
77
78
   */
  struct uio_info {
  	struct uio_device	*uio_dev;
b8ac9fc0e   Stephen Rothwell   uio: make uio_inf...
79
80
  	const char		*name;
  	const char		*version;
beafc54c4   Hans J. Koch   UIO: Add the User...
81
  	struct uio_mem		mem[MAX_UIO_MAPS];
e70c412ee   Hans J. Koch   UIO: Pass informa...
82
  	struct uio_port		port[MAX_UIO_PORT_REGIONS];
beafc54c4   Hans J. Koch   UIO: Add the User...
83
84
85
86
87
88
89
  	long			irq;
  	unsigned long		irq_flags;
  	void			*priv;
  	irqreturn_t (*handler)(int irq, struct uio_info *dev_info);
  	int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
  	int (*open)(struct uio_info *info, struct inode *inode);
  	int (*release)(struct uio_info *info, struct inode *inode);
328a14e70   Hans J. Koch   UIO: Add write fu...
90
  	int (*irqcontrol)(struct uio_info *info, s32 irq_on);
beafc54c4   Hans J. Koch   UIO: Add the User...
91
92
93
94
95
96
97
98
99
100
101
102
103
  };
  
  extern int __must_check
  	__uio_register_device(struct module *owner,
  			      struct device *parent,
  			      struct uio_info *info);
  static inline int __must_check
  	uio_register_device(struct device *parent, struct uio_info *info)
  {
  	return __uio_register_device(THIS_MODULE, parent, info);
  }
  extern void uio_unregister_device(struct uio_info *info);
  extern void uio_event_notify(struct uio_info *info);
6d8333c24   Uwe Kleine-König   UIO: minor style ...
104
  /* defines for uio_info->irq */
beafc54c4   Hans J. Koch   UIO: Add the User...
105
  #define UIO_IRQ_CUSTOM	-1
6427a7655   Eric W. Biederman   uio: Cleanup irq ...
106
  #define UIO_IRQ_NONE	0
beafc54c4   Hans J. Koch   UIO: Add the User...
107

6d8333c24   Uwe Kleine-König   UIO: minor style ...
108
  /* defines for uio_mem->memtype */
beafc54c4   Hans J. Koch   UIO: Add the User...
109
110
111
112
  #define UIO_MEM_NONE	0
  #define UIO_MEM_PHYS	1
  #define UIO_MEM_LOGICAL	2
  #define UIO_MEM_VIRTUAL 3
e70c412ee   Hans J. Koch   UIO: Pass informa...
113
114
115
116
117
  /* defines for uio_port->porttype */
  #define UIO_PORT_NONE	0
  #define UIO_PORT_X86	1
  #define UIO_PORT_GPIO	2
  #define UIO_PORT_OTHER	3
beafc54c4   Hans J. Koch   UIO: Add the User...
118
  #endif /* _LINUX_UIO_DRIVER_H_ */