blob: d53d5535f08372e2bc1c3ceba76aa7df7b51ce6d [file] [log] [blame]
Mariusz Szafranskia4041332017-08-02 17:28:17 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 - 2009 coresystems GmbH
5 * Copyright (C) 2014 - 2017 Intel Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
Kyösti Mälkki13f66502019-03-03 08:01:05 +020018#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020019#include <device/pci_ops.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020020#include <console/console.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include <device/pci_ids.h>
24
25#include <soc/pci_devs.h>
26#include <soc/ramstage.h>
27#include <soc/sata.h>
28
29#include "chip.h"
30
31static void sata_init(struct device *dev)
32{
33 u32 reg32;
34 u16 reg16;
35 u32 abar;
36
Mariusz Szafranskia4041332017-08-02 17:28:17 +020037 printk(BIOS_DEBUG, "SATA: Initializing...\n");
38
Mariusz Szafranskia4041332017-08-02 17:28:17 +020039 /* SATA configuration is handled by the FSP */
40
41 /* Enable BARs */
42 pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER |
43 PCI_COMMAND_MEMORY |
44 PCI_COMMAND_IO);
45
46 printk(BIOS_DEBUG, "SATA: Controller in AHCI mode.\n");
47
48 /* Set the controller mode */
49 reg16 = pci_read_config16(dev, SATA_MAP);
50 reg16 &= ~(3 << 6);
51 reg16 |= SATA_MAP_AHCI;
52 pci_write_config16(dev, SATA_MAP, reg16);
53
54 /* Initialize AHCI memory-mapped space */
55 abar = pci_read_config32(dev, PCI_BASE_ADDRESS_5);
56 printk(BIOS_DEBUG, "ABAR: %08X\n", abar);
57
58 /* Enable AHCI Mode */
59 reg32 = read32((void *)(abar + 0x04));
60 reg32 |= (1 << 31);
61 write32((void *)(abar + 0x04), reg32);
62}
63
Elyes HAOUAS2ec41832018-05-27 17:40:58 +020064static void sata_enable(struct device *dev) { /* TODO */ }
Mariusz Szafranskia4041332017-08-02 17:28:17 +020065
66static struct device_operations sata_ops = {
67 .read_resources = pci_dev_read_resources,
68 .set_resources = pci_dev_set_resources,
69 .enable_resources = pci_dev_enable_resources,
70 .init = sata_init,
71 .enable = sata_enable,
72 .scan_bus = 0,
73 .ops_pci = &soc_pci_ops,
74};
75
76static const unsigned short pci_device_ids[] = {
Felix Singerdbc90df2019-11-22 00:10:20 +010077 PCI_DEVICE_ID_INTEL_DENVERTON_SATA_AHCI_1,
78 PCI_DEVICE_ID_INTEL_DENVERTON_SATA_AHCI_2,
Mariusz Szafranskia4041332017-08-02 17:28:17 +020079 0
80};
81
82static const struct pci_driver soc_sata __pci_driver = {
83 .ops = &sata_ops,
84 .vendor = PCI_VENDOR_ID_INTEL,
85 .devices = pci_device_ids,
86};