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,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue