From 20c8bc80d511b5cb81d6c6afba238c05bf16a32b Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Wed, 26 Sep 2007 18:55:29 +0000 Subject: [PATCH] The Jmicron AHCI controller on my machine is always in PATA emulation mode, despite using the "AHCI native" setting in the BIOS. Added switching to AHCI mode during init, this makes it work. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22322 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/busses/scsi/ahci/ahci_controller.cpp | 11 ++++++++++- src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp b/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp index ee1ccbf9ba..e9f23846fd 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp +++ b/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp @@ -86,6 +86,15 @@ AHCIController::Init() TRACE("pcicmd new 0x%04x\n", pcicmd); gPCI->write_pci_config(fPCIDevice, PCI_command, 2, pcicmd); + if (fPCIVendorID == PCI_VENDOR_JMICRON) { + uint32 ctrl = gPCI->read_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4); + TRACE("Jmicron controller control 1 old 0x%08lx\n", ctrl); + ctrl &= ~((1 << 9) | (1 << 12) | (1 << 14)); // disable SFF 8038i emulation + ctrl |= (1 << 8) | (1 << 13) | (1 << 15); // enable AHCI controller + TRACE("Jmicron controller control 1 new 0x%08lx\n", ctrl); + gPCI->write_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4, ctrl); + } + void *addr = (void *)pciInfo.u.h0.base_registers[5]; size_t size = pciInfo.u.h0.base_register_sizes[5]; @@ -243,7 +252,7 @@ AHCIController::ResetController() fRegs->pi = savePI; FlushPostedWrites(); - if (fPCIVendorID == 0x8086) { + if (fPCIVendorID == PCI_VENDOR_INTEL) { // Intel PCS—Port Control and Status // In AHCI enabled systems, bits[3:0] must always be set gPCI->write_pci_config(fPCIDevice, 0x92, 2, diff --git a/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h b/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h index fe8768e233..28b7ae6045 100644 --- a/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h +++ b/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h @@ -223,6 +223,10 @@ extern scsi_for_sim_interface *gSCSI; #define PCI_PCICMD_MSE 0x02 #define PCI_PCICMD_BME 0x04 +#define PCI_VENDOR_INTEL 0x8086 +#define PCI_VENDOR_JMICRON 0x197b +#define PCI_JMICRON_CONTROLLER_CONTROL_1 0x40 + #ifdef __cplusplus template