blob: 18a5593cf7981563b22ba18da99b59f5a22d3e52 [file] [log] [blame]
Martin Roth5c354b92019-04-22 14:55:16 -06001/*
2 * This file is part of the coreboot project.
3 *
Martin Roth5c354b92019-04-22 14:55:16 -06004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <device/device.h>
16#include <device/pci.h>
Martin Roth5c354b92019-04-22 14:55:16 -060017#include <device/pci_ops.h>
18#include <device/pci_def.h>
19#include <amdblocks/sata.h>
20#include <soc/southbridge.h>
21
22void soc_enable_sata_features(struct device *dev)
23{
24 u8 *ahci_ptr;
25 u32 misc_ctl, cap_cfg;
26
27 u32 temp;
28
29 /* unlock the write-protect */
30 misc_ctl = pci_read_config32(dev, SATA_MISC_CONTROL_REG);
31 misc_ctl |= SATA_MISC_SUBCLASS_WREN;
32 pci_write_config32(dev, SATA_MISC_CONTROL_REG, misc_ctl);
33
34 /* set the SATA AHCI mode to allow port expanders */
35 ahci_ptr = (u8 *)(uintptr_t)ALIGN_DOWN(
36 pci_read_config32(dev, PCI_BASE_ADDRESS_5), 256);
37
38 cap_cfg = read32(ahci_ptr + SATA_CAPABILITIES_REG);
39 cap_cfg |= SATA_CAPABILITY_SPM;
40 write32(ahci_ptr + SATA_CAPABILITIES_REG, cap_cfg);
41
42 /* lock the write-protect */
43 temp = pci_read_config32(dev, SATA_MISC_CONTROL_REG);
44 temp &= ~SATA_MISC_SUBCLASS_WREN;
45 pci_write_config32(dev, SATA_MISC_CONTROL_REG, temp);
46};