00001 /************************************************************************** 00002 * 00003 * isapnp.h -- Etherboot isapnp support for the 3Com 3c515 00004 * Written 2002-2003 by Timothy Legge <tlegge@rogers.com> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 * 00020 * Portions of this code: 00021 * Copyright (C) 2001 P.J.H.Fox (fox@roestock.demon.co.uk) 00022 * 00023 * 00024 * 00025 * REVISION HISTORY: 00026 * ================ 00027 * Version 0.1 April 26, 2002 TJL 00028 * Version 0.2 01/08/2003 TJL Renamed from 3c515_isapnp.h 00029 * 00030 * 00031 * Generalised into an ISAPnP bus that can be used by more than just 00032 * the 3c515 by Michael Brown <mbrown@fensystems.co.uk> 00033 * 00034 ***************************************************************************/ 00035 00036 FILE_LICENCE ( GPL2_OR_LATER ); 00037 00038 #ifndef ISAPNP_H 00039 #define ISAPNP_H 00040 00041 #include <stdint.h> 00042 #include <gpxe/isa_ids.h> 00043 #include <gpxe/device.h> 00044 #include <gpxe/tables.h> 00045 00046 /* 00047 * ISAPnP constants 00048 * 00049 */ 00050 00051 /* Port addresses */ 00052 #define ISAPNP_ADDRESS 0x279 00053 #define ISAPNP_WRITE_DATA 0xa79 00054 #define ISAPNP_READ_PORT_MIN 0x203 00055 #define ISAPNP_READ_PORT_START 0x213 /* ISAPnP spec says 0x203, but 00056 * Linux ISAPnP starts at 00057 * 0x213 with no explanatory 00058 * comment. 0x203 probably 00059 * clashes with something. */ 00060 #define ISAPNP_READ_PORT_MAX 0x3ff 00061 #define ISAPNP_READ_PORT_STEP 0x10 /* Can be any multiple of 4 00062 * according to the spec, but 00063 * since ISA I/O addresses are 00064 * allocated in blocks of 16, 00065 * it makes no sense to use 00066 * any value less than 16. 00067 */ 00068 00069 /* Card select numbers */ 00070 #define ISAPNP_CSN_MIN 0x01 00071 #define ISAPNP_CSN_MAX 0x0f 00072 00073 /* Registers */ 00074 #define ISAPNP_READPORT 0x00 00075 #define ISAPNP_SERIALISOLATION 0x01 00076 #define ISAPNP_CONFIGCONTROL 0x02 00077 #define ISAPNP_WAKE 0x03 00078 #define ISAPNP_RESOURCEDATA 0x04 00079 #define ISAPNP_STATUS 0x05 00080 #define ISAPNP_CARDSELECTNUMBER 0x06 00081 #define ISAPNP_LOGICALDEVICENUMBER 0x07 00082 #define ISAPNP_ACTIVATE 0x30 00083 #define ISAPNP_IORANGECHECK 0x31 00084 #define ISAPNP_IOBASE(n) ( 0x60 + ( (n) * 2 ) ) 00085 #define ISAPNP_IRQNO(n) ( 0x70 + ( (n) * 2 ) ) 00086 #define ISAPNP_IRQTYPE(n) ( 0x71 + ( (n) * 2 ) ) 00087 00088 /* Bits in the CONFIGCONTROL register */ 00089 #define ISAPNP_CONFIG_RESET ( 1 << 0 ) 00090 #define ISAPNP_CONFIG_WAIT_FOR_KEY ( 1 << 1 ) 00091 #define ISAPNP_CONFIG_RESET_CSN ( 1 << 2 ) 00092 #define ISAPNP_CONFIG_RESET_DRV ( ISAPNP_CONFIG_RESET | \ 00093 ISAPNP_CONFIG_WAIT_FOR_KEY | \ 00094 ISAPNP_CONFIG_RESET_CSN ) 00095 00096 /* The LFSR used for the initiation key and for checksumming */ 00097 #define ISAPNP_LFSR_SEED 0x6a 00098 00099 /* Small tags */ 00100 #define ISAPNP_IS_SMALL_TAG(tag) ( ! ( (tag) & 0x80 ) ) 00101 #define ISAPNP_SMALL_TAG_NAME(tag) ( ( (tag) >> 3 ) & 0xf ) 00102 #define ISAPNP_SMALL_TAG_LEN(tag) ( ( (tag) & 0x7 ) ) 00103 #define ISAPNP_TAG_PNPVERNO 0x01 00104 #define ISAPNP_TAG_LOGDEVID 0x02 00105 #define ISAPNP_TAG_COMPATDEVID 0x03 00106 #define ISAPNP_TAG_IRQ 0x04 00107 #define ISAPNP_TAG_DMA 0x05 00108 #define ISAPNP_TAG_STARTDEP 0x06 00109 #define ISAPNP_TAG_ENDDEP 0x07 00110 #define ISAPNP_TAG_IOPORT 0x08 00111 #define ISAPNP_TAG_FIXEDIO 0x09 00112 #define ISAPNP_TAG_RSVDSHORTA 0x0A 00113 #define ISAPNP_TAG_RSVDSHORTB 0x0B 00114 #define ISAPNP_TAG_RSVDSHORTC 0x0C 00115 #define ISAPNP_TAG_RSVDSHORTD 0x0D 00116 #define ISAPNP_TAG_VENDORSHORT 0x0E 00117 #define ISAPNP_TAG_END 0x0F 00118 /* Large tags */ 00119 #define ISAPNP_IS_LARGE_TAG(tag) ( ( (tag) & 0x80 ) ) 00120 #define ISAPNP_LARGE_TAG_NAME(tag) (tag) 00121 #define ISAPNP_TAG_MEMRANGE 0x81 00122 #define ISAPNP_TAG_ANSISTR 0x82 00123 #define ISAPNP_TAG_UNICODESTR 0x83 00124 #define ISAPNP_TAG_VENDORLONG 0x84 00125 #define ISAPNP_TAG_MEM32RANGE 0x85 00126 #define ISAPNP_TAG_FIXEDMEM32RANGE 0x86 00127 #define ISAPNP_TAG_RSVDLONG0 0xF0 00128 #define ISAPNP_TAG_RSVDLONG1 0xF1 00129 #define ISAPNP_TAG_RSVDLONG2 0xF2 00130 #define ISAPNP_TAG_RSVDLONG3 0xF3 00131 #define ISAPNP_TAG_RSVDLONG4 0xF4 00132 #define ISAPNP_TAG_RSVDLONG5 0xF5 00133 #define ISAPNP_TAG_RSVDLONG6 0xF6 00134 #define ISAPNP_TAG_RSVDLONG7 0xF7 00135 #define ISAPNP_TAG_RSVDLONG8 0xF8 00136 #define ISAPNP_TAG_RSVDLONG9 0xF9 00137 #define ISAPNP_TAG_RSVDLONGA 0xFA 00138 #define ISAPNP_TAG_RSVDLONGB 0xFB 00139 #define ISAPNP_TAG_RSVDLONGC 0xFC 00140 #define ISAPNP_TAG_RSVDLONGD 0xFD 00141 #define ISAPNP_TAG_RSVDLONGE 0xFE 00142 #define ISAPNP_TAG_RSVDLONGF 0xFF 00143 #define ISAPNP_TAG_PSEUDO_NEWBOARD 0x100 00144 00145 /** An ISAPnP serial identifier */ 00146 struct isapnp_identifier { 00147 /** Vendor ID */ 00148 uint16_t vendor_id; 00149 /** Product ID */ 00150 uint16_t prod_id; 00151 /** Serial number */ 00152 uint32_t serial; 00153 /** Checksum */ 00154 uint8_t checksum; 00155 } __attribute__ (( packed )); 00156 00157 /** An ISAPnP logical device ID structure */ 00158 struct isapnp_logdevid { 00159 /** Vendor ID */ 00160 uint16_t vendor_id; 00161 /** Product ID */ 00162 uint16_t prod_id; 00163 /** Flags */ 00164 uint16_t flags; 00165 } __attribute__ (( packed )); 00166 00167 /** An ISAPnP device ID list entry */ 00168 struct isapnp_device_id { 00169 /** Name */ 00170 const char *name; 00171 /** Vendor ID */ 00172 uint16_t vendor_id; 00173 /** Product ID */ 00174 uint16_t prod_id; 00175 }; 00176 00177 /** An ISAPnP device */ 00178 struct isapnp_device { 00179 /** Generic device */ 00180 struct device dev; 00181 /** Vendor ID */ 00182 uint16_t vendor_id; 00183 /** Product ID */ 00184 uint16_t prod_id; 00185 /** I/O address */ 00186 uint16_t ioaddr; 00187 /** Interrupt number */ 00188 uint8_t irqno; 00189 /** Card Select Number */ 00190 uint8_t csn; 00191 /** Logical Device ID */ 00192 uint8_t logdev; 00193 /** Driver for this device */ 00194 struct isapnp_driver *driver; 00195 /** Driver-private data 00196 * 00197 * Use isapnp_set_drvdata() and isapnp_get_drvdata() to access 00198 * this field. 00199 */ 00200 void *priv; 00201 /** Driver name */ 00202 const char *driver_name; 00203 }; 00204 00205 /** An ISAPnP driver */ 00206 struct isapnp_driver { 00207 /** ISAPnP ID table */ 00208 struct isapnp_device_id *ids; 00209 /** Number of entries in ISAPnP ID table */ 00210 unsigned int id_count; 00211 /** 00212 * Probe device 00213 * 00214 * @v isapnp ISAPnP device 00215 * @v id Matching entry in ID table 00216 * @ret rc Return status code 00217 */ 00218 int ( * probe ) ( struct isapnp_device *isapnp, 00219 const struct isapnp_device_id *id ); 00220 /** 00221 * Remove device 00222 * 00223 * @v isapnp ISAPnP device 00224 */ 00225 void ( * remove ) ( struct isapnp_device *isapnp ); 00226 }; 00227 00228 /** ISAPnP driver table */ 00229 #define ISAPNP_DRIVERS __table ( struct isapnp_driver, "isapnp_drivers" ) 00230 00231 /** Declare an ISAPnP driver */ 00232 #define __isapnp_driver __table_entry ( ISAPNP_DRIVERS, 01 ) 00233 00234 extern uint16_t isapnp_read_port; 00235 00236 extern void isapnp_device_activation ( struct isapnp_device *isapnp, 00237 int activation ); 00238 00239 /** 00240 * Activate ISAPnP device 00241 * 00242 * @v isapnp ISAPnP device 00243 */ 00244 static inline void activate_isapnp_device ( struct isapnp_device *isapnp ) { 00245 isapnp_device_activation ( isapnp, 1 ); 00246 } 00247 00248 /** 00249 * Deactivate ISAPnP device 00250 * 00251 * @v isapnp ISAPnP device 00252 */ 00253 static inline void deactivate_isapnp_device ( struct isapnp_device *isapnp ) { 00254 isapnp_device_activation ( isapnp, 0 ); 00255 } 00256 00257 /** 00258 * Set ISAPnP driver-private data 00259 * 00260 * @v isapnp ISAPnP device 00261 * @v priv Private data 00262 */ 00263 static inline void isapnp_set_drvdata ( struct isapnp_device *isapnp, 00264 void *priv ) { 00265 isapnp->priv = priv; 00266 } 00267 00268 /** 00269 * Get ISAPnP driver-private data 00270 * 00271 * @v isapnp ISAPnP device 00272 * @ret priv Private data 00273 */ 00274 static inline void * isapnp_get_drvdata ( struct isapnp_device *isapnp ) { 00275 return isapnp->priv; 00276 } 00277 00278 #endif /* ISAPNP_H */
1.5.7.1