Add support for AHCI BIOS/OS Handoff.
This allows clean handoff from BIOS implementing some asynchronous I/O to the OS AHCI driver. During attach driver declares OS ownership request and waits from 25ms to 2s for BIOS to complete operation and release the hardware. MFC after: 2 weeks
This commit is contained in:
parent
16b766eed4
commit
274328a4ef
@ -141,8 +141,28 @@ int
|
||||
ahci_ctlr_reset(device_t dev)
|
||||
{
|
||||
struct ahci_controller *ctlr = device_get_softc(dev);
|
||||
uint32_t v;
|
||||
int timeout;
|
||||
|
||||
/* BIOS/OS Handoff */
|
||||
if ((ATA_INL(ctlr->r_mem, AHCI_VS) >= 0x00010200) &&
|
||||
(ATA_INL(ctlr->r_mem, AHCI_CAP2) & AHCI_CAP2_BOH) &&
|
||||
((v = ATA_INL(ctlr->r_mem, AHCI_BOHC)) & AHCI_BOHC_OOS) == 0) {
|
||||
|
||||
/* Request OS ownership. */
|
||||
ATA_OUTL(ctlr->r_mem, AHCI_BOHC, v | AHCI_BOHC_OOS);
|
||||
|
||||
/* Wait up to 2s for BIOS ownership release. */
|
||||
for (timeout = 0; timeout < 80; timeout++) {
|
||||
DELAY(25000);
|
||||
v = ATA_INL(ctlr->r_mem, AHCI_BOHC);
|
||||
if ((v & AHCI_BOHC_BOS) == 0)
|
||||
break;
|
||||
if ((v & AHCI_BOHC_BB) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable AHCI mode */
|
||||
ATA_OUTL(ctlr->r_mem, AHCI_GHC, AHCI_GHC_AE);
|
||||
/* Reset AHCI controller */
|
||||
|
@ -214,6 +214,13 @@
|
||||
#define AHCI_CAP2_SADM 0x00000010
|
||||
#define AHCI_CAP2_DESO 0x00000020
|
||||
|
||||
#define AHCI_BOHC 0x28
|
||||
#define AHCI_BOHC_BOS 0x00000001
|
||||
#define AHCI_BOHC_OOS 0x00000002
|
||||
#define AHCI_BOHC_SOOE 0x00000004
|
||||
#define AHCI_BOHC_OOC 0x00000008
|
||||
#define AHCI_BOHC_BB 0x00000010
|
||||
|
||||
#define AHCI_VSCAP 0xa4
|
||||
#define AHCI_OFFSET 0x100
|
||||
#define AHCI_STEP 0x80
|
||||
|
Loading…
Reference in New Issue
Block a user