diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 3411483..5f8a1f5 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "pci.h" /* The Mellanox Tavor device gives false positive parity errors @@ -876,6 +877,44 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev) } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); +static void __devinit quirk_apple_sata(struct pci_dev *pdev) +{ + int ret; + u16 device; + + /* Apple machines are broken using ata_piix, but don't + * properly set PCI_CLASS_STORAGE_SATA. + */ + ret = dmi_name_in_vendors("Apple Computer, Inc."); + if (!ret) + return; + + /* Blat the DEVICE_ID to the AHCI variant */ + switch (pdev->device) { + case 0x27c4: + device = 0x27c5; + break; + case 0x2680: + device = 0x2680; + break; + default: + return; + } + + /* Set PCI_CLASS_STORAGE_SATA_AHCI */ + if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { + pci_write_config_byte(pdev, PCI_CLASS_PROG, 0x01); + pci_write_config_byte(pdev, PCI_CLASS_DEVICE, 0x06); + pci_write_config_byte(pdev, PCI_CLASS_DEVICE+1, 0x01); + } + + pci_write_config_word(pdev, PCI_DEVICE_ID, device); + pdev->device = device; + pdev->class = PCI_CLASS_STORAGE_SATA_AHCI; +} +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x27c4, quirk_apple_sata); /* MacBookPro */ +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2680, quirk_apple_sata); /* MacPro */ + /* * Serverworks CSB5 IDE does not fully support native mode */