From 98761a53222adb6e099e1165e5984472cc38c95b Mon Sep 17 00:00:00 2001
From: Alex Chuang <alex.chuang@amd.com>
Date: Fri, 27 May 2011 14:48:49 +0800
Subject: [PATCH 1/2] Add one config IDE_TO_AHCI to let SeaBIOS handle AHCI controller as IDE controller when ATA enable, and also let Windows OS to load AHCI inbox driver or chipset vender's AHCI driver. In other words, it means that SATA Hard Disk ran as IDE mode in SeaBIOS but AHCI mode in Windows OS.

---
 src/Kconfig |    6 ++++++
 src/ata.c   |    5 ++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/Kconfig b/src/Kconfig
index 123db01..37e3dfa 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -100,6 +100,12 @@ menu "Hardware support"
         default n
         help
             Use 32bit PIO accesses on ATA (minor optimization on PCI transfers).
+    config IDE_TO_AHCI
+        depends on ATA
+        bool "IDE to AHCI support"
+        default n
+        help
+            Handle AHCI controller as ATA controller when POST.
     config AHCI
         depends on DRIVES
         bool "AHCI controllers"
diff --git a/src/ata.c b/src/ata.c
index 397e402..1db1838 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -972,10 +972,13 @@ ata_init(void)
     foreachpci(bdf, max) {
         pcicount++;
         if (pci_config_readw(bdf, PCI_CLASS_DEVICE) != PCI_CLASS_STORAGE_IDE)
-            continue;
+            if ((! CONFIG_IDE_TO_AHCI) || (pci_config_readw(bdf, PCI_CLASS_DEVICE) != 0x0106))
+                continue;
 
         u8 pciirq = pci_config_readb(bdf, PCI_INTERRUPT_LINE);
         u8 prog_if = pci_config_readb(bdf, PCI_CLASS_PROG);
+        if (CONFIG_IDE_TO_AHCI && (pci_config_readw(bdf, PCI_CLASS_DEVICE) == 0x0106))
+            prog_if = 0x8F;
         int master = 0;
         if (CONFIG_ATA_DMA && prog_if & 0x80) {
             // Check for bus-mastering.
-- 
1.7.4

