1 /*- 2 * Copyright (c) 2003 S�ren Schmidt <sos@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer, 10 * without modification, immediately at the beginning of the file. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * $FreeBSD$ 29 */ 30 31 /* structure holding chipset config info */ 32 struct ata_chip_id { 33 u_int32_t chipid; 34 u_int8_t chiprev; 35 int cfg1; 36 int cfg2; 37 u_int8_t max_dma; 38 char *text; 39 }; 40 41 /* structure describing a PCI ATA controller */ 42 struct ata_pci_controller { 43 struct resource *r_bmio; 44 struct resource *r_mem; 45 struct resource *r_irq; 46 void *handle; 47 struct ata_chip_id *chip; 48 int (*chipinit)(device_t); 49 int (*allocate)(device_t, struct ata_channel *); 50 int (*dmainit)(struct ata_channel *); 51 void (*setmode)(struct ata_device *, int); 52 void (*locking)(struct ata_channel *, int); 53 int locked_ch; 54 int channels; 55 struct { 56 void (*function)(void *); 57 void *argument; 58 } interrupt[4]; /* XXX SOS max ch# for now */ 59 }; 60 61 #define ATA_MASTERDEV(dev) ((pci_get_progif(dev) & 0x80) && \ 62 (pci_get_progif(dev) & 0x05) != 0x05) 63 64 /* defines for known chipset PCI id's */ 65 #define ATA_ACARD_ID 0x1191 66 #define ATA_ATP850 0x00021191 67 #define ATA_ATP850A 0x00041191 68 #define ATA_ATP850R 0x00051191 69 #define ATA_ATP860A 0x00061191 70 #define ATA_ATP860R 0x00071191 71 #define ATA_ATP865A 0x00081191 72 #define ATA_ATP865R 0x00091191 73 74 #define ATA_AMD_ID 0x1022 75 #define ATA_AMD755 0x74011022 76 #define ATA_AMD756 0x74091022 77 #define ATA_AMD766 0x74111022 78 #define ATA_AMD768 0x74411022 79 #define ATA_AMD8111 0x74691022 80 81 #define ATA_ACER_LABS_ID 0x10b9 82 #define ATA_ALI_5229 0x522910b9 83 84 #define ATA_CYRIX_ID 0x1078 85 #define ATA_CYRIX_5530 0x01021078 86 87 #define ATA_CYPRESS_ID 0x1080 88 #define ATA_CYPRESS_82C693 0xc6931080 89 90 #define ATA_DEC_21150 0x00221011 91 92 #define ATA_HIGHPOINT_ID 0x1103 93 #define ATA_HPT366 0x00041103 94 #define ATA_HPT372 0x00051103 95 #define ATA_HPT302 0x00061103 96 #define ATA_HPT371 0x00071103 97 #define ATA_HPT374 0x00081103 98 99 #define ATA_INTEL_ID 0x8086 100 #define ATA_I960RM 0x09628086 101 #define ATA_I82371FB 0x12308086 102 #define ATA_I82371SB 0x70108086 103 #define ATA_I82371AB 0x71118086 104 #define ATA_I82443MX 0x71998086 105 #define ATA_I82451NX 0x84ca8086 106 #define ATA_I82372FB 0x76018086 107 #define ATA_I82801AB 0x24218086 108 #define ATA_I82801AA 0x24118086 109 #define ATA_I82801BA 0x244a8086 110 #define ATA_I82801BA_1 0x244b8086 111 #define ATA_I82801CA 0x248a8086 112 #define ATA_I82801CA_1 0x248b8086 113 #define ATA_I82801DB 0x24cb8086 114 115 #define ATA_NVIDIA_ID 0x10de 116 #define ATA_NFORCE1 0x01bc10de 117 #define ATA_NFORCE2 0x006510de 118 119 #define ATA_PROMISE_ID 0x105a 120 #define ATA_PDC20246 0x4d33105a 121 #define ATA_PDC20262 0x4d38105a 122 #define ATA_PDC20263 0x0d38105a 123 #define ATA_PDC20265 0x0d30105a 124 #define ATA_PDC20267 0x4d30105a 125 #define ATA_PDC20268 0x4d68105a 126 #define ATA_PDC20268R 0x6268105a 127 #define ATA_PDC20269 0x4d69105a 128 #define ATA_PDC20271 0x6269105a 129 #define ATA_PDC20275 0x1275105a 130 #define ATA_PDC20276 0x5275105a 131 #define ATA_PDC20277 0x7275105a 132 #define ATA_PDC20376 0x3376105a 133 #define ATA_PDC20621 0x6621105a 134 135 #define ATA_SERVERWORKS_ID 0x1166 136 #define ATA_ROSB4 0x02111166 137 #define ATA_CSB5 0x02121166 138 #define ATA_CSB6 0x02131166 139 #define ATA_CSB6_1 0x02171166 140 141 #define ATA_SILICON_IMAGE_ID 0x1095 142 #define ATA_SII0680 0x06801095 143 #define ATA_CMD646 0x06461095 144 #define ATA_CMD648 0x06481095 145 #define ATA_CMD649 0x06491095 146 147 #define ATA_SIS_ID 0x1039 148 #define ATA_SISSOUTH 0x00081039 149 #define ATA_SIS5511 0x55111039 150 #define ATA_SIS5513 0x55131039 151 #define ATA_SIS5518 0x55181039 152 #define ATA_SIS5571 0x55711039 153 #define ATA_SIS5591 0x55911039 154 #define ATA_SIS5596 0x55961039 155 #define ATA_SIS5597 0x55971039 156 #define ATA_SIS5598 0x55981039 157 #define ATA_SIS5600 0x56001039 158 #define ATA_SIS530 0x05301039 159 #define ATA_SIS540 0x05401039 160 #define ATA_SIS550 0x05501039 161 #define ATA_SIS620 0x06201039 162 #define ATA_SIS630 0x06301039 163 #define ATA_SIS635 0x06351039 164 #define ATA_SIS633 0x06331039 165 #define ATA_SIS640 0x06401039 166 #define ATA_SIS645 0x06451039 167 #define ATA_SIS646 0x06461039 168 #define ATA_SIS648 0x06481039 169 #define ATA_SIS650 0x06501039 170 #define ATA_SIS651 0x06511039 171 #define ATA_SIS652 0x06521039 172 #define ATA_SIS655 0x06551039 173 #define ATA_SIS658 0x06581039 174 #define ATA_SIS730 0x07301039 175 #define ATA_SIS733 0x07331039 176 #define ATA_SIS735 0x07351039 177 #define ATA_SIS740 0x07401039 178 #define ATA_SIS745 0x07451039 179 #define ATA_SIS746 0x07461039 180 #define ATA_SIS748 0x07481039 181 #define ATA_SIS750 0x07501039 182 #define ATA_SIS751 0x07511039 183 #define ATA_SIS752 0x07521039 184 #define ATA_SIS755 0x07551039 185 #define ATA_SIS961 0x09611039 186 #define ATA_SIS962 0x09621039 187 #define ATA_SIS963 0x09631039 188 189 #define ATA_VIA_ID 0x1106 190 #define ATA_VIA82C571 0x05711106 191 #define ATA_VIA82C586 0x05861106 192 #define ATA_VIA82C596 0x05961106 193 #define ATA_VIA82C686 0x06861106 194 #define ATA_VIA8231 0x82311106 195 #define ATA_VIA8233 0x30741106 196 #define ATA_VIA8233A 0x31471106 197 #define ATA_VIA8233C 0x31091106 198 #define ATA_VIA8235 0x31771106 199 #define ATA_VIA8361 0x31121106 200 #define ATA_VIA8363 0x03051106 201 #define ATA_VIA8371 0x03911106 202 #define ATA_VIA8662 0x31021106 203 204 /* chipset setup related defines */ 205 #define ATPOLD 1 206 207 #define ALIOLD 0x01 208 #define ALINEW 0x02 209 210 #define HPT366 0 211 #define HPT370 1 212 #define HPT372 2 213 #define HPT374 3 214 #define HPTOLD 0x01 215 216 #define PROLD 0 217 #define PRNEW 1 218 #define PRTX 2 219 #define PRMEM 3 220 #define PRTX4 0x01 221 #define PRSX6K 0x02 222 223 #define SWKS33 0 224 #define SWKS66 1 225 #define SWKS100 2 226 227 #define SII_INTR 0x01 228 #define SII_SETCLK 0x02 229 #define SII_ENINTR 0x04 230 231 #define SIS_SOUTH 1 232 #define SIS133NEW 2 233 #define SIS133OLD 3 234 #define SIS100NEW 4 235 #define SIS100OLD 5 236 #define SIS66 6 237 238 #define VIA33 0 239 #define VIA66 1 240 #define VIA100 2 241 #define VIA133 3 242 #define AMDNVIDIA 4 243 #define AMDCABLE 0x01 244 #define AMDBUG 0x02 245 #define NVIDIA 0x04 246 #define VIACLK 0x08 247 #define VIABUG 0x10 248 249 /* global prototypes */ 250 int ata_dmainit(struct ata_channel *); 251 int ata_dmastart(struct ata_channel *, caddr_t, int32_t, int); 252 int ata_dmastop(struct ata_channel *); 253 254 int ata_generic_ident(device_t); 255 int ata_acard_ident(device_t); 256 int ata_ali_ident(device_t); 257 int ata_amd_ident(device_t); 258 int ata_cyrix_ident(device_t); 259 int ata_cypress_ident(device_t); 260 int ata_highpoint_ident(device_t); 261 int ata_intel_ident(device_t); 262 int ata_nvidia_ident(device_t); 263 int ata_promise_ident(device_t); 264 int ata_serverworks_ident(device_t); 265 int ata_sii_ident(device_t); 266 int ata_sis_ident(device_t); 267 int ata_via_ident(device_t); 268