Try again with supporting AHCI chipsets with partly implemented ports.

This commit is contained in:
Søren Schmidt 2007-02-21 19:03:34 +00:00
parent f7a66f06ec
commit 4471f79eb4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=166877
2 changed files with 16 additions and 5 deletions

View file

@ -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,

View file

@ -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);
}