blob: 577469d3aaade42094cbd8d6a5410728394af063 [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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <arch/io.h>
21#include <console/console.h>
22#include <device/device.h>
23#include <device/pci.h>
24#include <device/pci_ids.h>
25#include <reg_script.h>
26
Julius Werner18ea2d32014-10-07 16:42:17 -070027#include <soc/iosf.h>
28#include <soc/nvs.h>
29#include <soc/pci_devs.h>
30#include <soc/ramstage.h>
Aaron Durbin8b120a82013-12-10 08:35:51 -080031#include "chip.h"
32
33#define CAP_OVERRIDE_LOW 0xa0
34#define CAP_OVERRIDE_HIGH 0xa4
35# define USE_CAP_OVERRIDES (1 << 31)
36
37static void sd_init(device_t dev)
38{
39 struct soc_intel_baytrail_config *config = dev->chip_info;
40
41 if (config == NULL)
42 return;
43
44 if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) {
45 printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n");
46 pci_write_config32(dev, CAP_OVERRIDE_LOW,
47 config->sdcard_cap_low);
48 pci_write_config32(dev, CAP_OVERRIDE_HIGH,
49 config->sdcard_cap_high | USE_CAP_OVERRIDES);
50 }
Duncan Laurie430bf0d2013-12-10 14:37:42 -080051
52 if (config->scc_acpi_mode)
53 scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD);
Aaron Durbin8b120a82013-12-10 08:35:51 -080054}
55
56static const struct device_operations device_ops = {
57 .read_resources = pci_dev_read_resources,
58 .set_resources = pci_dev_set_resources,
59 .enable_resources = pci_dev_enable_resources,
60 .init = sd_init,
61 .enable = NULL,
62 .scan_bus = NULL,
63 .ops_pci = &soc_pci_ops,
64};
65
66static const struct pci_driver southcluster __pci_driver = {
67 .ops = &device_ops,
68 .vendor = PCI_VENDOR_ID_INTEL,
69 .device = SD_DEVID,
70};