| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <device/device.h> |
| 5 |
#include <device/pci.h> |
| 6 |
#include <device/pci_ids.h> |
| 7 |
#include <option.h> |
| 8 |
|
| 9 |
#define ASM1061_CTRL_REG 0xec |
| 10 |
#define ASM1061_PCI_CFG_UNLOCK (1 << 2) |
| 11 |
|
| 12 |
static void asm1061_enable(struct device *const dev) |
| 13 |
{ |
| 14 |
printk(BIOS_INFO, "Disabling ASPM for %s [%04x/%04x]\n", |
| 15 |
dev_path(dev), dev->vendor, dev->device); |
| 16 |
dev->disable_pcie_aspm = 1; |
| 17 |
|
| 18 |
u8 sata_mode = get_uint_option("sata_mode", 0); |
| 19 |
pci_or_config8(dev, ASM1061_CTRL_REG, ASM1061_PCI_CFG_UNLOCK); |
| 20 |
if (sata_mode == 0) { |
| 21 |
printk(BIOS_INFO, "Setting AHCI mode for %s [%04x/%04x]\n", |
| 22 |
dev_path(dev), dev->vendor, dev->device); |
| 23 |
pci_write_config16(dev, PCI_CLASS_DEVICE, PCI_CLASS_STORAGE_SATA); |
| 24 |
} else { |
| 25 |
printk(BIOS_INFO, "Setting IDE mode for %s [%04x/%04x]\n", |
| 26 |
dev_path(dev), dev->vendor, dev->device); |
| 27 |
pci_write_config16(dev, PCI_CLASS_DEVICE, PCI_CLASS_STORAGE_IDE); |
| 28 |
} |
| 29 |
pci_and_config8(dev, ASM1061_CTRL_REG, ~ASM1061_PCI_CFG_UNLOCK); |
| 30 |
} |
| 31 |
|
| 32 |
static struct device_operations asm1061_ops = { |
| 33 |
.read_resources = pci_dev_read_resources, |
| 34 |
.set_resources = pci_dev_set_resources, |
| 35 |
.enable_resources = pci_dev_enable_resources, |
| 36 |
.enable = asm1061_enable, |
| 37 |
}; |
| 38 |
|
| 39 |
static const unsigned short pci_device_ids[] = { |
| 40 |
0x0611, |
| 41 |
0 |
| 42 |
}; |
| 43 |
|
| 44 |
static const struct pci_driver asmedia_asm1061 __pci_driver = { |
| 45 |
.ops = &asm1061_ops, |
| 46 |
.vendor = 0x1b21, |
| 47 |
.devices = pci_device_ids, |
| 48 |
}; |