summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2007-02-21 19:03:34 +0000
committersos <sos@FreeBSD.org>2007-02-21 19:03:34 +0000
commita2861c6b3ab6834963fd37e787a02f1316fff16a (patch)
treee0cdcae96603d90f5e63223a29ac8bd01991e248 /sys/dev
parentcacf0d22c40108d2bf73286869a50235afa4a913 (diff)
downloadFreeBSD-src-a2861c6b3ab6834963fd37e787a02f1316fff16a.zip
FreeBSD-src-a2861c6b3ab6834963fd37e787a02f1316fff16a.tar.gz
Try again with supporting AHCI chipsets with partly implemented ports.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ata/ata-chipset.c14
-rw-r--r--sys/dev/ata/ata-pci.c7
2 files changed, 16 insertions, 5 deletions
diff --git a/sys/dev/ata/ata-chipset.c b/sys/dev/ata/ata-chipset.c
index d18aa35..dcd40f4 100644
--- a/sys/dev/ata/ata-chipset.c
+++ b/sys/dev/ata/ata-chipset.c
@@ -404,7 +404,9 @@ ata_ahci_chipinit(device_t dev)
ATA_INL(ctlr->r_res2, ATA_AHCI_GHC) | ATA_AHCI_GHC_AE);
/* get the number of HW channels */
- ctlr->channels = (ATA_INL(ctlr->r_res2, ATA_AHCI_CAP) & ATA_AHCI_NPMASK)+1;
+ ctlr->channels =
+ MAX(flsl(ATA_INL(ctlr->r_res2, ATA_AHCI_PI)),
+ (ATA_INL(ctlr->r_res2, ATA_AHCI_CAP) & ATA_AHCI_NPMASK) + 1);
/* clear interrupts */
ATA_OUTL(ctlr->r_res2, ATA_AHCI_IS, ATA_INL(ctlr->r_res2, ATA_AHCI_IS));
@@ -427,7 +429,8 @@ ata_ahci_chipinit(device_t dev)
device_printf(dev,
"AHCI Version %x%x.%x%x controller with %d ports detected\n",
(version >> 24) & 0xff, (version >> 16) & 0xff,
- (version >> 8) & 0xff, version & 0xff, ctlr->channels);
+ (version >> 8) & 0xff, version & 0xff,
+ (ATA_INL(ctlr->r_res2, ATA_AHCI_CAP) & ATA_AHCI_NPMASK) + 1);
return 0;
}
@@ -464,7 +467,7 @@ ata_ahci_allocate(device_t dev)
ch->hw.end_transaction = ata_ahci_end_transaction;
ch->hw.command = NULL; /* not used here */
- /* setup the work areas */
+ /* setup work areas */
ATA_OUTL(ctlr->r_res2, ATA_AHCI_P_CLB + offset,
ch->dma->work_bus + ATA_AHCI_CL_OFFSET);
ATA_OUTL(ctlr->r_res2, ATA_AHCI_P_CLBU + offset, 0x00000000);
@@ -663,6 +666,11 @@ ata_ahci_reset(device_t dev)
int offset = ch->unit << 7;
int timeout;
+ if (!(ATA_INL(ctlr->r_res2, ATA_AHCI_PI) & (1 << ch->unit))) {
+ device_printf(dev, "port not implemented\n");
+ ch->devices = 0;
+ }
+
/* kill off all activity on this channel */
cmd = ATA_INL(ctlr->r_res2, ATA_AHCI_P_CMD + offset);
ATA_OUTL(ctlr->r_res2, ATA_AHCI_P_CMD + offset,
diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c
index 1acd68d..3bc6d8f 100644
--- a/sys/dev/ata/ata-pci.c
+++ b/sys/dev/ata/ata-pci.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos@FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -568,8 +568,11 @@ ata_pcichannel_attach(device_t dev)
if (ch->dma)
ch->dma->alloc(dev);
- if ((error = ctlr->allocate(dev)))
+ if ((error = ctlr->allocate(dev))) {
+ if (ch->dma)
+ ch->dma->free(dev);
return error;
+ }
return ata_attach(dev);
}
OpenPOWER on IntegriCloud