summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2013-01-17 00:08:14 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2013-01-17 00:08:14 +0000
commitfad525616fb7123191d22c709a96fe6a2cab946a (patch)
treeebc61e40a7fe56da5894348df5ce987961e81112 /sys/dev
parent67cecb36d7ec9fd60d5e34830b68c6b012ea2a60 (diff)
Force the latest 3 generations of Intel SATA chipsets into AHCI mode.
This makes MacBook Pro with bootcamp more happy to run OpenBSD since by default it boots up with IDE mode enabled on those chips which results in all sorts of troubles with the at least the DVD drive. With and OK kettenis@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/ahci.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/sys/dev/pci/ahci.c b/sys/dev/pci/ahci.c
index edd071050df..caf80d2fe5a 100644
--- a/sys/dev/pci/ahci.c
+++ b/sys/dev/pci/ahci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahci.c,v 1.194 2012/10/08 21:47:50 deraadt Exp $ */
+/* $OpenBSD: ahci.c,v 1.195 2013/01/17 00:08:13 claudio Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -58,6 +58,13 @@ int ahcidebug = AHCI_D_VERBOSE;
#define AHCI_PCI_ATI_SB600_LOCKED 0x01
#define AHCI_PCI_INTERFACE 0x01
+#define AHCI_PCI_INTEL_MAP 0x90
+#define AHCI_PCI_INTEL_MAP_SC_4P 0x00
+#define AHCI_PCI_INTEL_MAP_SC_6P 0x20
+#define AHCI_PCI_INTEL_MAP_SMS_IDE 0x00
+#define AHCI_PCI_INTEL_MAP_SMS_AHCI 0x40
+#define AHCI_PCI_INTEL_MAP_SMS_RAID 0x80
+
#define AHCI_REG_CAP 0x000 /* HBA Capabilities */
#define AHCI_REG_CAP_NP(_r) (((_r) & 0x1f)+1) /* Number of Ports */
#define AHCI_REG_CAP_SXS (1<<5) /* External SATA */
@@ -525,6 +532,22 @@ static const struct ahci_device ahci_devices[] = {
NULL, ahci_intel_attach },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EP80579_AHCI,
NULL, ahci_intel_attach },
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_1,
+ NULL, ahci_intel_attach },
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_2,
+ NULL, ahci_intel_attach },
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_4,
+ NULL, ahci_intel_attach },
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_3400_SATA_6,
+ NULL, ahci_intel_attach },
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_SATA_1,
+ NULL, ahci_intel_attach },
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_6SERIES_SATA_2,
+ NULL, ahci_intel_attach },
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_SATA_1,
+ NULL, ahci_intel_attach },
+ { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_7SERIES_SATA_2,
+ NULL, ahci_intel_attach },
{ PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8251_SATA,
ahci_no_match, ahci_vt8251_attach }
@@ -765,6 +788,19 @@ ahci_amd_hudson2_attach(struct ahci_softc *sc, struct pci_attach_args *pa)
int
ahci_intel_attach(struct ahci_softc *sc, struct pci_attach_args *pa)
{
+ /* switch from pciide(4) to ahci(4) mode */
+ if (PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_IDE) {
+ pcireg_t reg;
+
+ reg = pci_conf_read(pa->pa_pc, pa->pa_tag,
+ AHCI_PCI_INTEL_MAP);
+ pci_conf_write(pa->pa_pc, pa->pa_tag, AHCI_PCI_INTEL_MAP,
+ reg | AHCI_PCI_INTEL_MAP_SMS_AHCI |
+ AHCI_PCI_INTEL_MAP_SC_6P);
+ /* clear BAR since it keeps the old IO value */
+ pci_conf_write(pa->pa_pc, pa->pa_tag,
+ AHCI_PCI_BAR, 0);
+ }
sc->sc_flags |= AHCI_F_NO_PMP;
return (0);
}