blob: 0c03e5690f15ae1d71978e37e9c7af9b27ce36ff [file] [log] [blame]
Aaron Durbin8b120a82013-12-10 08:35:51 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Aaron Durbin8b120a82013-12-10 08:35:51 -080014 */
15
16#include <arch/io.h>
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
21#include <reg_script.h>
22
Julius Werner18ea2d32014-10-07 16:42:17 -070023#include <soc/iosf.h>
24#include <soc/nvs.h>
25#include <soc/pci_devs.h>
26#include <soc/ramstage.h>
Aaron Durbin8b120a82013-12-10 08:35:51 -080027#include "chip.h"
28
29#define CAP_OVERRIDE_LOW 0xa0
30#define CAP_OVERRIDE_HIGH 0xa4
31# define USE_CAP_OVERRIDES (1 << 31)
32
Elyes HAOUAS17a3ceb2018-05-22 10:42:28 +020033static void sd_init(struct device *dev)
Aaron Durbin8b120a82013-12-10 08:35:51 -080034{
35 struct soc_intel_baytrail_config *config = dev->chip_info;
36
37 if (config == NULL)
38 return;
39
40 if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) {
41 printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n");
42 pci_write_config32(dev, CAP_OVERRIDE_LOW,
43 config->sdcard_cap_low);
44 pci_write_config32(dev, CAP_OVERRIDE_HIGH,
45 config->sdcard_cap_high | USE_CAP_OVERRIDES);
46 }
Duncan Laurie430bf0d2013-12-10 14:37:42 -080047
48 if (config->scc_acpi_mode)
49 scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD);
Aaron Durbin8b120a82013-12-10 08:35:51 -080050}
51
52static const struct device_operations device_ops = {
53 .read_resources = pci_dev_read_resources,
54 .set_resources = pci_dev_set_resources,
55 .enable_resources = pci_dev_enable_resources,
56 .init = sd_init,
57 .enable = NULL,
58 .scan_bus = NULL,
59 .ops_pci = &soc_pci_ops,
60};
61
62static const struct pci_driver southcluster __pci_driver = {
63 .ops = &device_ops,
64 .vendor = PCI_VENDOR_ID_INTEL,
65 .device = SD_DEVID,
66};