1/*- 2 * Copyright (c) 1998,1999,2000 S�ren Schmidt 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 --- 11 unchanged lines hidden (view full) --- 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: head/sys/dev/ata/ata-all.c 64695 2000-08-16 07:09:04Z sos $ |
29 */ 30 31#include "ata.h" 32#include "isa.h" 33#include "card.h" 34#include "pci.h" 35#include "atadisk.h" 36#include "atapicd.h" --- 228 unchanged lines hidden (view full) --- 265 266 case 0x522910b9: 267 return "AcerLabs Aladdin ATA33 controller"; 268 269 case 0x05711106: 270 if (ata_find_dev(dev, 0x05861106, 0)) 271 return "VIA 82C586 ATA33 controller"; 272 if (ata_find_dev(dev, 0x05961106, 0x12)) |
273 return "VIA 82C596 ATA66 controller"; |
274 if (ata_find_dev(dev, 0x05961106, 0)) 275 return "VIA 82C596 ATA33 controller"; 276 if (ata_find_dev(dev, 0x06861106, 0)) 277 return "VIA 82C686 ATA66 controller"; 278 return "VIA Apollo ATA controller"; 279 280 case 0x55131039: 281 return "SiS 5591 ATA33 controller"; --- 129 unchanged lines hidden (view full) --- 411 /* do extra chipset specific setups */ 412 switch (type) { 413 case 0x522910b9: /* Aladdin need to activate the ATAPI FIFO */ 414 pci_write_config(dev, 0x53, 415 (pci_read_config(dev, 0x53, 1) & ~0x01) | 0x02, 1); 416 break; 417 418 case 0x4d38105a: /* Promise 66's need their clock changed */ |
419 case 0x4d30105a: /* Promise 100's too */ |
420 outb(rman_get_start(sc->bmio) + 0x11, 421 inb(rman_get_start(sc->bmio) + 0x11) | 0x0a); 422 /* FALLTHROUGH */ 423 424 case 0x4d33105a: /* Promise's need burst mode to be turned on */ 425 outb(rman_get_start(sc->bmio) + 0x1f, 426 inb(rman_get_start(sc->bmio) + 0x1f) | 0x01); 427 break; --- 302 unchanged lines hidden (view full) --- 730 731static int 732ata_pcisub_probe(device_t dev) 733{ 734 struct ata_softc *scp = device_get_softc(dev); 735 736 /* kids of pci ata chipsets has their physical unit number in ivars */ 737 scp->unit = (uintptr_t) device_get_ivars(dev); |
738 scp->chiptype = pci_get_devid(device_get_parent(dev)); |
739 return ata_probe(dev); 740} 741 742static device_method_t ata_pcisub_methods[] = { 743 /* device interface */ 744 DEVMETHOD(device_probe, ata_pcisub_probe), 745 DEVMETHOD(device_attach, ata_attach), 746 DEVMETHOD(device_detach, ata_detach), --- 76 unchanged lines hidden (view full) --- 823 mask |= 0x02; 824 if (bootverbose) 825 ata_printf(scp, -1, "mask=%02x status0=%02x status1=%02x\n", 826 mask, status0, status1); 827 if (!mask) 828 goto failure; 829 830 ata_reset(scp, &mask); |
831 |
832 if (bootverbose) 833 ata_printf(scp, -1, "devices = 0x%x\n", scp->devices); |
834 835 if (!mask) |
836 goto failure; |
837 |
838 TAILQ_INIT(&scp->ata_queue); 839 TAILQ_INIT(&scp->atapi_queue); 840 return 0; 841 842failure: 843 if (io) 844 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); 845 if (altio) --- 354 unchanged lines hidden (view full) --- 1200#endif 1201 scp->active = ATA_IDLE; 1202} 1203 1204void 1205ata_reset(struct ata_softc *scp, int32_t *mask) 1206{ 1207 int32_t timeout; |
1208 u_int8_t status0 = ATA_S_BUSY, status1 = ATA_S_BUSY; |
1209 1210 /* reset channel */ 1211 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER); 1212 DELAY(1); 1213 inb(scp->ioaddr + ATA_STATUS); 1214 outb(scp->altioaddr, ATA_A_IDS | ATA_A_RESET); 1215 DELAY(10000); 1216 outb(scp->altioaddr, ATA_A_IDS); 1217 DELAY(10000); 1218 inb(scp->ioaddr + ATA_ERROR); 1219 DELAY(3000); 1220 1221 /* wait for BUSY to go inactive */ 1222 for (timeout = 0; timeout < 310000; timeout++) { |
1223 if (status0 & ATA_S_BUSY) { 1224 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER); 1225 DELAY(1); 1226 status0 = inb(scp->ioaddr + ATA_STATUS); 1227 if (!(status0 & ATA_S_BUSY)) { 1228 /* check for ATAPI signature while its still there */ 1229 if (inb(scp->ioaddr + ATA_CYL_LSB) == ATAPI_MAGIC_LSB && 1230 inb(scp->ioaddr + ATA_CYL_MSB) == ATAPI_MAGIC_MSB) 1231 scp->devices |= ATA_ATAPI_MASTER; 1232 } 1233 } 1234 if (status1 & ATA_S_BUSY) { 1235 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); 1236 DELAY(1); 1237 status1 = inb(scp->ioaddr + ATA_STATUS); 1238 if (!(status1 & ATA_S_BUSY)) { 1239 /* check for ATAPI signature while its still there */ 1240 if (inb(scp->ioaddr + ATA_CYL_LSB) == ATAPI_MAGIC_LSB && 1241 inb(scp->ioaddr + ATA_CYL_MSB) == ATAPI_MAGIC_MSB) 1242 scp->devices |= ATA_ATAPI_SLAVE; 1243 } 1244 } |
1245 if (*mask == 0x01) /* wait for master only */ 1246 if (!(status0 & ATA_S_BUSY)) 1247 break; 1248 if (*mask == 0x02) /* wait for slave only */ 1249 if (!(status1 & ATA_S_BUSY)) 1250 break; 1251 if (*mask == 0x03) /* wait for both master & slave */ 1252 if (!(status0 & ATA_S_BUSY) && !(status1 & ATA_S_BUSY)) --- 4 unchanged lines hidden (view full) --- 1257 outb(scp->altioaddr, ATA_A_4BIT); 1258 if (status0 & ATA_S_BUSY) 1259 *mask &= ~0x01; 1260 if (status1 & ATA_S_BUSY) 1261 *mask &= ~0x02; 1262 if (bootverbose) 1263 ata_printf(scp, -1, "mask=%02x status0=%02x status1=%02x\n", 1264 *mask, status0, status1); |
1265 if (!mask) { 1266 scp->devices = 0; 1267 return; 1268 } 1269 /* 1270 * OK, we have at least one device on the chain, checks for ATAPI 1271 * already done, if none check if its a good old ATA device. 1272 */ 1273 if (status0 != 0x00 && !(scp->devices & ATA_ATAPI_MASTER)) { 1274 outb(scp->ioaddr + ATA_DRIVE, (ATA_D_IBM | ATA_MASTER)); 1275 DELAY(1); 1276 outb(scp->ioaddr + ATA_ERROR, 0x58); 1277 outb(scp->ioaddr + ATA_CYL_LSB, 0xa5); 1278 if (inb(scp->ioaddr + ATA_ERROR) != 0x58 && 1279 inb(scp->ioaddr + ATA_CYL_LSB) == 0xa5) { 1280 scp->devices |= ATA_ATA_MASTER; 1281 } 1282 } 1283 if (status1 != 0x00 && !(scp->devices & ATA_ATAPI_SLAVE)) { 1284 outb(scp->ioaddr + ATA_DRIVE, (ATA_D_IBM | ATA_SLAVE)); 1285 DELAY(1); 1286 outb(scp->ioaddr + ATA_ERROR, 0x58); 1287 outb(scp->ioaddr + ATA_CYL_LSB, 0xa5); 1288 if (inb(scp->ioaddr + ATA_ERROR) != 0x58 && 1289 inb(scp->ioaddr + ATA_CYL_LSB) == 0xa5) { 1290 scp->devices |= ATA_ATA_SLAVE; 1291 } 1292 } |
1293} 1294 1295int32_t 1296ata_reinit(struct ata_softc *scp) 1297{ 1298 int32_t mask = 0, omask; 1299 1300 scp->active = ATA_REINITING; --- 423 unchanged lines hidden --- |