[sundance] Add reset completion check
[gpxe.git] / src / include / gpxe / isapnp.h
blob07797a9939018e809acc8731406a98e0e9269eac
1 /**************************************************************************
3 * isapnp.h -- Etherboot isapnp support for the 3Com 3c515
4 * Written 2002-2003 by Timothy Legge <tlegge@rogers.com>
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.
20 * Portions of this code:
21 * Copyright (C) 2001 P.J.H.Fox (fox@roestock.demon.co.uk)
25 * REVISION HISTORY:
26 * ================
27 * Version 0.1 April 26, 2002 TJL
28 * Version 0.2 01/08/2003 TJL Renamed from 3c515_isapnp.h
31 * Generalised into an ISAPnP bus that can be used by more than just
32 * the 3c515 by Michael Brown <mbrown@fensystems.co.uk>
34 ***************************************************************************/
36 #ifndef ISAPNP_H
37 #define ISAPNP_H
39 #include <stdint.h>
40 #include <gpxe/isa_ids.h>
41 #include <gpxe/device.h>
42 #include <gpxe/tables.h>
45 * ISAPnP constants
49 /* Port addresses */
50 #define ISAPNP_ADDRESS 0x279
51 #define ISAPNP_WRITE_DATA 0xa79
52 #define ISAPNP_READ_PORT_MIN 0x203
53 #define ISAPNP_READ_PORT_START 0x213 /* ISAPnP spec says 0x203, but
54 * Linux ISAPnP starts at
55 * 0x213 with no explanatory
56 * comment. 0x203 probably
57 * clashes with something. */
58 #define ISAPNP_READ_PORT_MAX 0x3ff
59 #define ISAPNP_READ_PORT_STEP 0x10 /* Can be any multiple of 4
60 * according to the spec, but
61 * since ISA I/O addresses are
62 * allocated in blocks of 16,
63 * it makes no sense to use
64 * any value less than 16.
67 /* Card select numbers */
68 #define ISAPNP_CSN_MIN 0x01
69 #define ISAPNP_CSN_MAX 0x0f
71 /* Registers */
72 #define ISAPNP_READPORT 0x00
73 #define ISAPNP_SERIALISOLATION 0x01
74 #define ISAPNP_CONFIGCONTROL 0x02
75 #define ISAPNP_WAKE 0x03
76 #define ISAPNP_RESOURCEDATA 0x04
77 #define ISAPNP_STATUS 0x05
78 #define ISAPNP_CARDSELECTNUMBER 0x06
79 #define ISAPNP_LOGICALDEVICENUMBER 0x07
80 #define ISAPNP_ACTIVATE 0x30
81 #define ISAPNP_IORANGECHECK 0x31
82 #define ISAPNP_IOBASE(n) ( 0x60 + ( (n) * 2 ) )
83 #define ISAPNP_IRQNO(n) ( 0x70 + ( (n) * 2 ) )
84 #define ISAPNP_IRQTYPE(n) ( 0x71 + ( (n) * 2 ) )
86 /* Bits in the CONFIGCONTROL register */
87 #define ISAPNP_CONFIG_RESET ( 1 << 0 )
88 #define ISAPNP_CONFIG_WAIT_FOR_KEY ( 1 << 1 )
89 #define ISAPNP_CONFIG_RESET_CSN ( 1 << 2 )
90 #define ISAPNP_CONFIG_RESET_DRV ( ISAPNP_CONFIG_RESET | \
91 ISAPNP_CONFIG_WAIT_FOR_KEY | \
92 ISAPNP_CONFIG_RESET_CSN )
94 /* The LFSR used for the initiation key and for checksumming */
95 #define ISAPNP_LFSR_SEED 0x6a
97 /* Small tags */
98 #define ISAPNP_IS_SMALL_TAG(tag) ( ! ( (tag) & 0x80 ) )
99 #define ISAPNP_SMALL_TAG_NAME(tag) ( ( (tag) >> 3 ) & 0xf )
100 #define ISAPNP_SMALL_TAG_LEN(tag) ( ( (tag) & 0x7 ) )
101 #define ISAPNP_TAG_PNPVERNO 0x01
102 #define ISAPNP_TAG_LOGDEVID 0x02
103 #define ISAPNP_TAG_COMPATDEVID 0x03
104 #define ISAPNP_TAG_IRQ 0x04
105 #define ISAPNP_TAG_DMA 0x05
106 #define ISAPNP_TAG_STARTDEP 0x06
107 #define ISAPNP_TAG_ENDDEP 0x07
108 #define ISAPNP_TAG_IOPORT 0x08
109 #define ISAPNP_TAG_FIXEDIO 0x09
110 #define ISAPNP_TAG_RSVDSHORTA 0x0A
111 #define ISAPNP_TAG_RSVDSHORTB 0x0B
112 #define ISAPNP_TAG_RSVDSHORTC 0x0C
113 #define ISAPNP_TAG_RSVDSHORTD 0x0D
114 #define ISAPNP_TAG_VENDORSHORT 0x0E
115 #define ISAPNP_TAG_END 0x0F
116 /* Large tags */
117 #define ISAPNP_IS_LARGE_TAG(tag) ( ( (tag) & 0x80 ) )
118 #define ISAPNP_LARGE_TAG_NAME(tag) (tag)
119 #define ISAPNP_TAG_MEMRANGE 0x81
120 #define ISAPNP_TAG_ANSISTR 0x82
121 #define ISAPNP_TAG_UNICODESTR 0x83
122 #define ISAPNP_TAG_VENDORLONG 0x84
123 #define ISAPNP_TAG_MEM32RANGE 0x85
124 #define ISAPNP_TAG_FIXEDMEM32RANGE 0x86
125 #define ISAPNP_TAG_RSVDLONG0 0xF0
126 #define ISAPNP_TAG_RSVDLONG1 0xF1
127 #define ISAPNP_TAG_RSVDLONG2 0xF2
128 #define ISAPNP_TAG_RSVDLONG3 0xF3
129 #define ISAPNP_TAG_RSVDLONG4 0xF4
130 #define ISAPNP_TAG_RSVDLONG5 0xF5
131 #define ISAPNP_TAG_RSVDLONG6 0xF6
132 #define ISAPNP_TAG_RSVDLONG7 0xF7
133 #define ISAPNP_TAG_RSVDLONG8 0xF8
134 #define ISAPNP_TAG_RSVDLONG9 0xF9
135 #define ISAPNP_TAG_RSVDLONGA 0xFA
136 #define ISAPNP_TAG_RSVDLONGB 0xFB
137 #define ISAPNP_TAG_RSVDLONGC 0xFC
138 #define ISAPNP_TAG_RSVDLONGD 0xFD
139 #define ISAPNP_TAG_RSVDLONGE 0xFE
140 #define ISAPNP_TAG_RSVDLONGF 0xFF
141 #define ISAPNP_TAG_PSEUDO_NEWBOARD 0x100
143 /** An ISAPnP serial identifier */
144 struct isapnp_identifier {
145 /** Vendor ID */
146 uint16_t vendor_id;
147 /** Product ID */
148 uint16_t prod_id;
149 /** Serial number */
150 uint32_t serial;
151 /** Checksum */
152 uint8_t checksum;
153 } __attribute__ (( packed ));
155 /** An ISAPnP logical device ID structure */
156 struct isapnp_logdevid {
157 /** Vendor ID */
158 uint16_t vendor_id;
159 /** Product ID */
160 uint16_t prod_id;
161 /** Flags */
162 uint16_t flags;
163 } __attribute__ (( packed ));
165 /** An ISAPnP device ID list entry */
166 struct isapnp_device_id {
167 /** Name */
168 const char *name;
169 /** Vendor ID */
170 uint16_t vendor_id;
171 /** Product ID */
172 uint16_t prod_id;
175 /** An ISAPnP device */
176 struct isapnp_device {
177 /** Generic device */
178 struct device dev;
179 /** Vendor ID */
180 uint16_t vendor_id;
181 /** Product ID */
182 uint16_t prod_id;
183 /** I/O address */
184 uint16_t ioaddr;
185 /** Interrupt number */
186 uint8_t irqno;
187 /** Card Select Number */
188 uint8_t csn;
189 /** Logical Device ID */
190 uint8_t logdev;
191 /** Driver for this device */
192 struct isapnp_driver *driver;
193 /** Driver-private data
195 * Use isapnp_set_drvdata() and isapnp_get_drvdata() to access
196 * this field.
198 void *priv;
199 /** Driver name */
200 const char *driver_name;
203 /** An ISAPnP driver */
204 struct isapnp_driver {
205 /** ISAPnP ID table */
206 struct isapnp_device_id *ids;
207 /** Number of entries in ISAPnP ID table */
208 unsigned int id_count;
210 * Probe device
212 * @v isapnp ISAPnP device
213 * @v id Matching entry in ID table
214 * @ret rc Return status code
216 int ( * probe ) ( struct isapnp_device *isapnp,
217 const struct isapnp_device_id *id );
219 * Remove device
221 * @v isapnp ISAPnP device
223 void ( * remove ) ( struct isapnp_device *isapnp );
226 /** Declare an ISAPnP driver */
227 #define __isapnp_driver __table ( struct isapnp_driver, isapnp_drivers, 01 )
229 extern uint16_t isapnp_read_port;
231 extern void isapnp_device_activation ( struct isapnp_device *isapnp,
232 int activation );
235 * Activate ISAPnP device
237 * @v isapnp ISAPnP device
239 static inline void activate_isapnp_device ( struct isapnp_device *isapnp ) {
240 isapnp_device_activation ( isapnp, 1 );
244 * Deactivate ISAPnP device
246 * @v isapnp ISAPnP device
248 static inline void deactivate_isapnp_device ( struct isapnp_device *isapnp ) {
249 isapnp_device_activation ( isapnp, 0 );
253 * Set ISAPnP driver-private data
255 * @v isapnp ISAPnP device
256 * @v priv Private data
258 static inline void isapnp_set_drvdata ( struct isapnp_device *isapnp,
259 void *priv ) {
260 isapnp->priv = priv;
264 * Get ISAPnP driver-private data
266 * @v isapnp ISAPnP device
267 * @ret priv Private data
269 static inline void * isapnp_get_drvdata ( struct isapnp_device *isapnp ) {
270 return isapnp->priv;
273 #endif /* ISAPNP_H */