2 * ISA Plug & Play support
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef LINUX_ISAPNP_H
23 #define LINUX_ISAPNP_H
25 #include <linux/config.h>
28 * Configuration registers (TODO: change by specification)
31 #define ISAPNP_CFG_ACTIVATE 0x30 /* byte */
32 #define ISAPNP_CFG_MEM 0x40 /* 4 * dword */
33 #define ISAPNP_CFG_PORT 0x60 /* 8 * word */
34 #define ISAPNP_CFG_IRQ 0x70 /* 2 * word */
35 #define ISAPNP_CFG_DMA 0x74 /* 2 * byte */
41 #define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
42 ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
43 ((((c)-'A'+1)&0x1f)<<8))
44 #define ISAPNP_DEVICE(x) ((((x)&0xf000)>>8)|\
48 #define ISAPNP_FUNCTION(x) ISAPNP_DEVICE(x)
56 #include <linux/pci.h>
58 #define ISAPNP_PORT_FLAG_16BITADDR (1<<0)
59 #define ISAPNP_PORT_FLAG_FIXED (1<<1)
62 unsigned short min
; /* min base number */
63 unsigned short max
; /* max base number */
64 unsigned char align
; /* align boundary */
65 unsigned char size
; /* size of range */
66 unsigned char flags
; /* port flags */
67 unsigned char pad
; /* pad */
68 struct isapnp_resources
*res
; /* parent */
69 struct isapnp_port
*next
; /* next port */
73 unsigned short map
; /* bitmaks for IRQ lines */
74 unsigned char flags
; /* IRQ flags */
75 unsigned char pad
; /* pad */
76 struct isapnp_resources
*res
; /* parent */
77 struct isapnp_irq
*next
; /* next IRQ */
81 unsigned char map
; /* bitmask for DMA channels */
82 unsigned char flags
; /* DMA flags */
83 struct isapnp_resources
*res
; /* parent */
84 struct isapnp_dma
*next
; /* next port */
88 unsigned int min
; /* min base number */
89 unsigned int max
; /* max base number */
90 unsigned int align
; /* align boundary */
91 unsigned int size
; /* size of range */
92 unsigned char flags
; /* memory flags */
93 unsigned char pad
; /* pad */
94 struct isapnp_resources
*res
; /* parent */
95 struct isapnp_mem
*next
; /* next memory resource */
100 unsigned char data
[17];
101 struct isapnp_resources
*res
; /* parent */
102 struct isapnp_mem32
*next
; /* next 32-bit memory resource */
105 #define ISAPNP_RES_PRIORITY_PREFERRED 0
106 #define ISAPNP_RES_PRIORITY_ACCEPTABLE 1
107 #define ISAPNP_RES_PRIORITY_FUNCTIONAL 2
108 #define ISAPNP_RES_PRIORITY_INVALID 65535
110 struct isapnp_resources
{
111 unsigned short priority
; /* priority */
112 unsigned short dependent
; /* dependent resources */
113 struct isapnp_port
*port
; /* first port */
114 struct isapnp_irq
*irq
; /* first IRQ */
115 struct isapnp_dma
*dma
; /* first DMA */
116 struct isapnp_mem
*mem
; /* first memory resource */
117 struct isapnp_mem32
*mem32
; /* first 32-bit memory */
118 struct pci_dev
*dev
; /* parent */
119 struct isapnp_resources
*alt
; /* alternative resource (aka dependent resources) */
120 struct isapnp_resources
*next
; /* next resource */
123 #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
125 /* lowlevel configuration */
126 int isapnp_present(void);
127 int isapnp_cfg_begin(int csn
, int device
);
128 int isapnp_cfg_end(void);
129 unsigned char isapnp_read_byte(unsigned char idx
);
130 unsigned short isapnp_read_word(unsigned char idx
);
131 unsigned int isapnp_read_dword(unsigned char idx
);
132 void isapnp_write_byte(unsigned char idx
, unsigned char val
);
133 void isapnp_write_word(unsigned char idx
, unsigned short val
);
134 void isapnp_write_dword(unsigned char idx
, unsigned int val
);
135 void isapnp_wake(unsigned char csn
);
136 void isapnp_device(unsigned char device
);
137 void isapnp_activate(unsigned char device
);
138 void isapnp_deactivate(unsigned char device
);
140 struct pci_bus
*isapnp_find_card(unsigned short vendor
,
141 unsigned short device
,
142 struct pci_bus
*from
);
143 struct pci_dev
*isapnp_find_dev(struct pci_bus
*card
,
144 unsigned short vendor
,
145 unsigned short function
,
146 struct pci_dev
*from
);
148 void isapnp_resource_change(struct resource
*resource
,
152 int isapnp_init(void);
154 #else /* !CONFIG_ISAPNP */
156 /* lowlevel configuration */
157 extern inline int isapnp_present(void) { return 0; }
158 extern inline int isapnp_cfg_begin(int csn
, int device
) { return -ENODEV
; }
159 extern inline int isapnp_cfg_end(void) { return -ENODEV
; }
160 extern inline unsigned char isapnp_read_byte(unsigned char idx
) { return 0xff; }
161 extern inline unsigned short isapnp_read_word(unsigned char idx
) { return 0xffff; }
162 extern inline unsigned int isapnp_read_dword(unsigned char idx
) { return 0xffffffff; }
163 extern inline void isapnp_write_byte(unsigned char idx
, unsigned char val
) { ; }
164 extern inline void isapnp_write_word(unsigned char idx
, unsigned short val
) { ; }
165 extern inline void isapnp_write_dword(unsigned char idx
, unsigned int val
) { ; }
166 extern void isapnp_wake(unsigned char csn
) { ; }
167 extern void isapnp_device(unsigned char device
) { ; }
168 extern void isapnp_activate(unsigned char device
) { ; }
169 extern void isapnp_deactivate(unsigned char device
) { ; }
171 extern struct pci_bus
*isapnp_find_card(unsigned short vendor
,
172 unsigned short device
,
173 struct pci_bus
*from
) { return NULL
; }
174 extern struct pci_dev
*isapnp_find_dev(struct pci_bus
*card
,
175 unsigned short vendor
,
176 unsigned short function
,
177 struct pci_dev
*from
) { return NULL
; }
178 extern void isapnp_resource_change(struct resource
*resource
,
180 unsigned long size
) { ; }
182 #endif /* CONFIG_ISAPNP */
184 #endif /* __KERNEL__ */
185 #endif /* LINUX_ISAPNP_H */