drivers/asmedia: Add code to enable AHCI for ASM1061
The ASMedia ASM1061 seems to default to IDE mode, which seems to be the source of payloads and Linux not recognizing/booting from drives connected to it. From the behaviour of vendor firmware on the ASRock Z87 Extreme 4, the mode can be changed by setting the PCI Subclass register to 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. To maintain consistency with chipset SATA ports, this is also configurable through the existing sata_mode CMOS option with the default set to AHCI. Tested on the ASUS Maximus VI Gene. Change-Id: I7a1470894261c7d14fadccdcade968f87f78fe23 Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/85816 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Riku Viitanen <riku.viitanen@protonmail.com> Reviewed-by: Jan Philipp Groß <jeangrande@mailbox.org>
This commit is contained in:
parent
d74039baff
commit
fee8bcbcfb
9 changed files with 57 additions and 39 deletions
|
|
@ -1,4 +1,4 @@
|
|||
## SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
config DRIVERS_ASMEDIA_ASPM_BLACKLIST
|
||||
config DRIVERS_ASMEDIA_ASM1061
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
## SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
ramstage-$(CONFIG_DRIVERS_ASMEDIA_ASPM_BLACKLIST) += aspm_blacklist.c
|
||||
ramstage-$(CONFIG_DRIVERS_ASMEDIA_ASM1061) += asm1061.c
|
||||
|
|
|
|||
48
src/drivers/asmedia/asm1061.c
Normal file
48
src/drivers/asmedia/asm1061.c
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
|
||||
#include <console/console.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pci.h>
|
||||
#include <device/pci_ids.h>
|
||||
#include <option.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;
|
||||
|
||||
u8 sata_mode = get_uint_option("sata_mode", 0);
|
||||
pci_or_config8(dev, ASM1061_CTRL_REG, ASM1061_PCI_CFG_UNLOCK);
|
||||
if (sata_mode == 0) {
|
||||
printk(BIOS_INFO, "Setting AHCI mode for %s [%04x/%04x]\n",
|
||||
dev_path(dev), dev->vendor, dev->device);
|
||||
pci_write_config16(dev, PCI_CLASS_DEVICE, PCI_CLASS_STORAGE_SATA);
|
||||
} else {
|
||||
printk(BIOS_INFO, "Setting IDE mode for %s [%04x/%04x]\n",
|
||||
dev_path(dev), dev->vendor, dev->device);
|
||||
pci_write_config16(dev, PCI_CLASS_DEVICE, PCI_CLASS_STORAGE_IDE);
|
||||
}
|
||||
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,
|
||||
};
|
||||
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -5,7 +5,7 @@ if BOARD_ASROCK_B75PRO3_M
|
|||
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
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ if BOARD_ASROCK_FATAL1TY_Z87_PROFESSIONAL
|
|||
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
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ if BOARD_ASROCK_H77PRO4_M
|
|||
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
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ config BOARD_ASUS_P8H61_M_LX3_R2_0
|
|||
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
|
|||
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
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ config BOARD_ASUS_P8H77_V
|
|||
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_LX2
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue