1 | /* $Id: ioport.h,v 1.1.1.1 2003/07/02 13:57:00 eleph Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * ioport.h Definitions of routines for detecting, reserving and
|
---|
5 | * allocating system resources.
|
---|
6 | *
|
---|
7 | * Authors: Linus Torvalds
|
---|
8 | */
|
---|
9 |
|
---|
10 | #ifndef _LINUX_IOPORT_H
|
---|
11 | #define _LINUX_IOPORT_H
|
---|
12 |
|
---|
13 | #include <linux/types.h>
|
---|
14 | #include <linux/minmax.h>
|
---|
15 |
|
---|
16 | /*
|
---|
17 | * Resources are tree-like, allowing
|
---|
18 | * nesting etc..
|
---|
19 | */
|
---|
20 | struct resource {
|
---|
21 | const char *name;
|
---|
22 | unsigned long start, end;
|
---|
23 | unsigned long flags;
|
---|
24 | struct resource *parent, *sibling, *child;
|
---|
25 | };
|
---|
26 |
|
---|
27 | /*
|
---|
28 | * IO resources have these defined flags.
|
---|
29 | */
|
---|
30 | #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
|
---|
31 |
|
---|
32 | #define IORESOURCE_IO 0x00000100 /* Resource type */
|
---|
33 | #define IORESOURCE_MEM 0x00000200
|
---|
34 | #define IORESOURCE_IRQ 0x00000400
|
---|
35 | #define IORESOURCE_DMA 0x00000800
|
---|
36 |
|
---|
37 | #define IORESOURCE_PREFETCH 0x00001000 /* No side effects */
|
---|
38 | #define IORESOURCE_READONLY 0x00002000
|
---|
39 | #define IORESOURCE_CACHEABLE 0x00004000
|
---|
40 | #define IORESOURCE_RANGELENGTH 0x00008000
|
---|
41 | #define IORESOURCE_SHADOWABLE 0x00010000
|
---|
42 |
|
---|
43 | #define IORESOURCE_UNSET 0x20000000
|
---|
44 | #define IORESOURCE_AUTO 0x40000000
|
---|
45 | #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */
|
---|
46 |
|
---|
47 | /* ISA PnP IRQ specific bits (IORESOURCE_BITS) */
|
---|
48 | #define IORESOURCE_IRQ_HIGHEDGE (1<<0)
|
---|
49 | #define IORESOURCE_IRQ_LOWEDGE (1<<1)
|
---|
50 | #define IORESOURCE_IRQ_HIGHLEVEL (1<<2)
|
---|
51 | #define IORESOURCE_IRQ_LOWLEVEL (1<<3)
|
---|
52 |
|
---|
53 | /* ISA PnP DMA specific bits (IORESOURCE_BITS) */
|
---|
54 | #define IORESOURCE_DMA_TYPE_MASK (3<<0)
|
---|
55 | #define IORESOURCE_DMA_8BIT (0<<0)
|
---|
56 | #define IORESOURCE_DMA_8AND16BIT (1<<0)
|
---|
57 | #define IORESOURCE_DMA_16BIT (2<<0)
|
---|
58 |
|
---|
59 | #define IORESOURCE_DMA_MASTER (1<<2)
|
---|
60 | #define IORESOURCE_DMA_BYTE (1<<3)
|
---|
61 | #define IORESOURCE_DMA_WORD (1<<4)
|
---|
62 |
|
---|
63 | #define IORESOURCE_DMA_SPEED_MASK (3<<6)
|
---|
64 | #define IORESOURCE_DMA_COMPATIBLE (0<<6)
|
---|
65 | #define IORESOURCE_DMA_TYPEA (1<<6)
|
---|
66 | #define IORESOURCE_DMA_TYPEB (2<<6)
|
---|
67 | #define IORESOURCE_DMA_TYPEF (3<<6)
|
---|
68 |
|
---|
69 | /* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */
|
---|
70 | #define IORESOURCE_MEM_WRITEABLE (1<<0) /* dup: IORESOURCE_READONLY */
|
---|
71 | #define IORESOURCE_MEM_CACHEABLE (1<<1) /* dup: IORESOURCE_CACHEABLE */
|
---|
72 | #define IORESOURCE_MEM_RANGELENGTH (1<<2) /* dup: IORESOURCE_RANGELENGTH */
|
---|
73 | #define IORESOURCE_MEM_TYPE_MASK (3<<3)
|
---|
74 | #define IORESOURCE_MEM_8BIT (0<<3)
|
---|
75 | #define IORESOURCE_MEM_16BIT (1<<3)
|
---|
76 | #define IORESOURCE_MEM_8AND16BIT (2<<3)
|
---|
77 | #define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */
|
---|
78 | #define IORESOURCE_MEM_EXPANSIONROM (1<<6)
|
---|
79 |
|
---|
80 | /* PC/ISA/whatever - the normal PC address spaces: IO and memory */
|
---|
81 | extern struct resource ioport_resource;
|
---|
82 | extern struct resource iomem_resource;
|
---|
83 |
|
---|
84 | extern int get_resource_list(struct resource *, char *buf, int size);
|
---|
85 |
|
---|
86 | extern int request_resource(struct resource *root, struct resource *newres);
|
---|
87 | extern int release_resource(struct resource *newres);
|
---|
88 | extern int allocate_resource(struct resource *root, struct resource *newres,
|
---|
89 | unsigned long size,
|
---|
90 | unsigned long min, unsigned long max,
|
---|
91 | unsigned long align);
|
---|
92 |
|
---|
93 | /* Convenience shorthand with allocation */
|
---|
94 | #define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
|
---|
95 | #define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name))
|
---|
96 |
|
---|
97 | extern struct resource * __request_region(struct resource *, unsigned long start, unsigned long n, const char *name);
|
---|
98 |
|
---|
99 | /* Compatibility cruft */
|
---|
100 | #define check_region(start,n) __check_region(&ioport_resource, (start), (n))
|
---|
101 | #define release_region(start,n) __release_region(&ioport_resource, (start), (n))
|
---|
102 | #define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n))
|
---|
103 | #define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n))
|
---|
104 |
|
---|
105 | extern int __check_region(struct resource *, unsigned long, unsigned long);
|
---|
106 | extern void __release_region(struct resource *, unsigned long, unsigned long);
|
---|
107 |
|
---|
108 | #define get_ioport_list(buf) get_resource_list(&ioport_resource, buf, PAGE_SIZE)
|
---|
109 | #define get_mem_list(buf) get_resource_list(&iomem_resource, buf, PAGE_SIZE)
|
---|
110 |
|
---|
111 | #define HAVE_AUTOIRQ
|
---|
112 | extern void autoirq_setup(int waittime);
|
---|
113 | extern int autoirq_report(int waittime);
|
---|
114 |
|
---|
115 | extern struct resource * __devm_request_region(struct device *dev,
|
---|
116 | struct resource *parent, resource_size_t start,
|
---|
117 | resource_size_t n, const char *name);
|
---|
118 |
|
---|
119 | #define devm_request_region(dev,start,n,name) \
|
---|
120 | __devm_request_region(dev, &ioport_resource, (start), (n), (name))
|
---|
121 | #endif /* _LINUX_IOPORT_H */
|
---|