Nicholas Chin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85816?usp=email )
Change subject: drivers/asmedia: Enable AHCI for ASM1061 ......................................................................
drivers/asmedia: Enable AHCI for ASM1061
The ASMedia ASM1061 seems to default to IDE mode, preventing SATA drives from working properly in Linux as it tries to load the AHCI driver for it. From the behaviour of vendor firmware on the ASRock Z87 Extreme 4, the mode can be changed by writing to the PCI Subclass register to be either 0x06 (SATA controller) or 0x01 (IDE controller). This register seems to be read only, but can be unlocked for writing by setting bit 2 at offset 0xEC in the PCI config space.
Since the ASMEDIA_ASPM_BLACKLIST driver already existed and only matched the ASM1061, rename it to ASMEDIA_ASM1061 and add the AHCI mode setting code to it.
Change-Id: I7a1470894261c7d14fadccdcade968f87f78fe23 Signed-off-by: Nicholas Chin nic.c3.14@gmail.com --- M src/drivers/asmedia/Kconfig M src/drivers/asmedia/Makefile.mk A src/drivers/asmedia/asm1061.c D src/drivers/asmedia/aspm_blacklist.c M src/mainboard/asrock/b75pro3-m/Kconfig M src/mainboard/asrock/fatal1ty_z87_professional/Kconfig M src/mainboard/asrock/h77pro4-m/Kconfig M src/mainboard/asus/h61-series/Kconfig M src/mainboard/asus/p8x7x-series/Kconfig 9 files changed, 49 insertions(+), 39 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/16/85816/1
diff --git a/src/drivers/asmedia/Kconfig b/src/drivers/asmedia/Kconfig index 055d9fb..f042f3d 100644 --- a/src/drivers/asmedia/Kconfig +++ b/src/drivers/asmedia/Kconfig @@ -1,4 +1,4 @@ ## SPDX-License-Identifier: GPL-2.0-only
-config DRIVERS_ASMEDIA_ASPM_BLACKLIST +config DRIVERS_ASMEDIA_ASM1061 bool diff --git a/src/drivers/asmedia/Makefile.mk b/src/drivers/asmedia/Makefile.mk index 1088eae..bbede71 100644 --- a/src/drivers/asmedia/Makefile.mk +++ b/src/drivers/asmedia/Makefile.mk @@ -1,3 +1,3 @@ ## SPDX-License-Identifier: GPL-2.0-only
-ramstage-$(CONFIG_DRIVERS_ASMEDIA_ASPM_BLACKLIST) += aspm_blacklist.c +ramstage-$(CONFIG_DRIVERS_ASMEDIA_1061) += asm1061.c diff --git a/src/drivers/asmedia/asm1061.c b/src/drivers/asmedia/asm1061.c new file mode 100644 index 0000000..fc92891 --- /dev/null +++ b/src/drivers/asmedia/asm1061.c @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <device/device.h> +#include <device/pci.h> +#include <device/pci_ids.h> + +#define ASM1061_CTRL_REG 0xec +#define ASM1061_PCI_CFG_UNLOCK (1 << 2) + +static void asm1061_enable(struct device *const dev) +{ + printk(BIOS_INFO, "Disabling ASPM for %s [%04x/%04x]\n", + dev_path(dev), dev->vendor, dev->device); + dev->disable_pcie_aspm = 1; + + printk(BIOS_INFO, "Setting AHCI mode for %s [%04x/%04x]\n", + dev_path(dev), dev->vendor, dev->device); + pci_or_config8(dev, ASM1061_CTRL_REG, ASM1061_PCI_CFG_UNLOCK); + pci_write_config16(dev, PCI_CLASS_DEVICE, PCI_CLASS_STORAGE_SATA); + pci_and_config8(dev, ASM1061_CTRL_REG, ~ASM1061_PCI_CFG_UNLOCK); +} + +static struct device_operations asm1061_ops = { + .read_resources = pci_dev_read_resources, + .set_resources = pci_dev_set_resources, + .enable_resources = pci_dev_enable_resources, + .enable = asm1061_enable, +}; + +static const unsigned short pci_device_ids[] = { + 0x0611, /* ASM1061 SATA IDE Controller */ + 0 +}; + +static const struct pci_driver asmedia_asm1061 __pci_driver = { + .ops = &asm1061_ops, + .vendor = 0x1b21, + .devices = pci_device_ids, +}; diff --git a/src/drivers/asmedia/aspm_blacklist.c b/src/drivers/asmedia/aspm_blacklist.c deleted file mode 100644 index 90d5217..0000000 --- a/src/drivers/asmedia/aspm_blacklist.c +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include <console/console.h> -#include <device/device.h> -#include <device/pci.h> - -static void disable_aspm(struct device *const dev) -{ - printk(BIOS_INFO, "Disabling ASPM for %s [%04x/%04x]\n", - dev_path(dev), dev->vendor, dev->device); - dev->disable_pcie_aspm = 1; -} - -static struct device_operations asmedia_noaspm_ops = { - .read_resources = pci_dev_read_resources, - .set_resources = pci_dev_set_resources, - .enable_resources = pci_dev_enable_resources, - .enable = disable_aspm, -}; - -static const unsigned short pci_device_ids[] = { - 0x0611, /* ASM1061 SATA IDE Controller */ - 0 -}; - -static const struct pci_driver asmedia_noaspm __pci_driver = { - .ops = &asmedia_noaspm_ops, - .vendor = 0x1b21, - .devices = pci_device_ids, -}; diff --git a/src/mainboard/asrock/b75pro3-m/Kconfig b/src/mainboard/asrock/b75pro3-m/Kconfig index d371bff..17d737f 100644 --- a/src/mainboard/asrock/b75pro3-m/Kconfig +++ b/src/mainboard/asrock/b75pro3-m/Kconfig @@ -5,7 +5,7 @@ config BOARD_SPECIFIC_OPTIONS def_bool y select BOARD_ROMSIZE_KB_8192 - select DRIVERS_ASMEDIA_ASPM_BLACKLIST + select DRIVERS_ASMEDIA_ASM1061 select HAVE_ACPI_RESUME select HAVE_ACPI_TABLES select HAVE_CMOS_DEFAULT diff --git a/src/mainboard/asrock/fatal1ty_z87_professional/Kconfig b/src/mainboard/asrock/fatal1ty_z87_professional/Kconfig index b1600ef..32c746d 100644 --- a/src/mainboard/asrock/fatal1ty_z87_professional/Kconfig +++ b/src/mainboard/asrock/fatal1ty_z87_professional/Kconfig @@ -4,7 +4,7 @@ config BOARD_SPECIFIC_OPTIONS def_bool y select BOARD_ROMSIZE_KB_8192 - select DRIVERS_ASMEDIA_ASPM_BLACKLIST + select DRIVERS_ASMEDIA_ASM1061 select HAVE_ACPI_RESUME select HAVE_ACPI_TABLES select INTEL_GMA_HAVE_VBT diff --git a/src/mainboard/asrock/h77pro4-m/Kconfig b/src/mainboard/asrock/h77pro4-m/Kconfig index 50bf86c..a9918b5 100644 --- a/src/mainboard/asrock/h77pro4-m/Kconfig +++ b/src/mainboard/asrock/h77pro4-m/Kconfig @@ -5,7 +5,7 @@ config BOARD_SPECIFIC_OPTIONS def_bool y select BOARD_ROMSIZE_KB_8192 - select DRIVERS_ASMEDIA_ASPM_BLACKLIST + select DRIVERS_ASMEDIA_ASM1061 select HAVE_ACPI_RESUME select HAVE_ACPI_TABLES select HAVE_CMOS_DEFAULT diff --git a/src/mainboard/asus/h61-series/Kconfig b/src/mainboard/asus/h61-series/Kconfig index 2f34719..08e7a22 100644 --- a/src/mainboard/asus/h61-series/Kconfig +++ b/src/mainboard/asus/h61-series/Kconfig @@ -41,7 +41,7 @@ config BOARD_ASUS_P8H61_M_PRO select BOARD_ASUS_H61_SERIES select BOARD_ROMSIZE_KB_4096 - select DRIVERS_ASMEDIA_ASPM_BLACKLIST + select DRIVERS_ASMEDIA_ASM1061 select HAVE_CMOS_DEFAULT select HAVE_OPTION_TABLE select MEMORY_MAPPED_TPM @@ -52,7 +52,7 @@ config BOARD_ASUS_P8H61_M_PRO_CM6630 select BOARD_ASUS_H61_SERIES select BOARD_ROMSIZE_KB_4096 - select DRIVERS_ASMEDIA_ASPM_BLACKLIST + select DRIVERS_ASMEDIA_ASM1061 select HAVE_CMOS_DEFAULT select HAVE_OPTION_TABLE select MEMORY_MAPPED_TPM diff --git a/src/mainboard/asus/p8x7x-series/Kconfig b/src/mainboard/asus/p8x7x-series/Kconfig index e278b56..133bd94 100644 --- a/src/mainboard/asus/p8x7x-series/Kconfig +++ b/src/mainboard/asus/p8x7x-series/Kconfig @@ -29,7 +29,7 @@ config BOARD_ASUS_P8Z77_M_PRO select BOARD_ASUS_P8X7X_SERIES select BOARD_ROMSIZE_KB_8192 - select DRIVERS_ASMEDIA_ASPM_BLACKLIST # for ASM1061 eSATA + select DRIVERS_ASMEDIA_ASM1061 # for ASM1061 eSATA select MEMORY_MAPPED_TPM select SUPERIO_NUVOTON_NCT6779D
@@ -43,7 +43,7 @@ config BOARD_ASUS_P8Z77_V select BOARD_ASUS_P8X7X_SERIES select BOARD_ROMSIZE_KB_8192 - select DRIVERS_ASMEDIA_ASPM_BLACKLIST # for ASM1061 eSATA + select DRIVERS_ASMEDIA_ASM1061 # for ASM1061 eSATA select MEMORY_MAPPED_TPM select MAINBOARD_USES_IFD_GBE_REGION select SUPERIO_NUVOTON_NCT6779D