| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <device/device.h> |
| 5 |
#include <device/mmio.h> |
| 6 |
#include <device/pci.h> |
| 7 |
#include <device/pci_def.h> |
| 8 |
#include <device/pci_ids.h> |
| 9 |
#include <device/pci_ops.h> |
| 10 |
#include <soc/sata.h> |
| 11 |
|
| 12 |
static void sata_init(struct device *dev) |
| 13 |
{ |
| 14 |
uint32_t reg32, abar; |
| 15 |
|
| 16 |
printk(BIOS_DEBUG, "Set SATA controller in AHCI mode.\n"); |
| 17 |
|
| 18 |
uint16_t reg16 = pci_read_config16(dev, SATA_MAP); |
| 19 |
reg16 &= ~(3 << 6); |
| 20 |
reg16 |= SATA_MAP_AHCI; |
| 21 |
pci_write_config16(dev, SATA_MAP, reg16); |
| 22 |
|
| 23 |
|
| 24 |
abar = pci_read_config32(dev, SATA_ABAR); |
| 25 |
|
| 26 |
|
| 27 |
reg32 = read32p(abar + SATA_GHC); |
| 28 |
reg32 |= SATA_GHC_AE; |
| 29 |
write32p(abar + SATA_GHC, reg32); |
| 30 |
} |
| 31 |
|
| 32 |
static struct device_operations snr_sata_ops = { |
| 33 |
.read_resources = pci_dev_read_resources, |
| 34 |
.set_resources = pci_dev_set_resources, |
| 35 |
.enable_resources = pci_dev_enable_resources, |
| 36 |
.init = sata_init, |
| 37 |
.final = pci_dev_request_bus_master, |
| 38 |
.ops_pci = &pci_dev_ops_pci, |
| 39 |
}; |
| 40 |
|
| 41 |
static const unsigned short snr_sata_ids[] = { |
| 42 |
PCI_DID_INTEL_SNR_SATA0, |
| 43 |
PCI_DID_INTEL_SNR_SATA2, |
| 44 |
0, |
| 45 |
}; |
| 46 |
|
| 47 |
static const struct pci_driver snr_sata_driver __pci_driver = { |
| 48 |
.ops = &snr_sata_ops, |
| 49 |
.vendor = PCI_VID_INTEL, |
| 50 |
.devices = snr_sata_ids, |
| 51 |
}; |