blob: 872f6f98eb7cfe65736b74a45ea9ebf3a6839e0a [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>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020017#include <device/pci_ops.h>
Aaron Durbin8b120a82013-12-10 08:35:51 -080018#include <console/console.h>
19#include <device/device.h>
20#include <device/pci.h>
21#include <device/pci_ids.h>
22#include <reg_script.h>
23
Julius Werner18ea2d32014-10-07 16:42:17 -070024#include <soc/iosf.h>
25#include <soc/nvs.h>
26#include <soc/pci_devs.h>
27#include <soc/ramstage.h>
Aaron Durbin8b120a82013-12-10 08:35:51 -080028#include "chip.h"
29
30#define CAP_OVERRIDE_LOW 0xa0
31#define CAP_OVERRIDE_HIGH 0xa4
32# define USE_CAP_OVERRIDES (1 << 31)
33
Elyes HAOUAS17a3ceb2018-05-22 10:42:28 +020034static void sd_init(struct device *dev)
Aaron Durbin8b120a82013-12-10 08:35:51 -080035{
36 struct soc_intel_baytrail_config *config = dev->chip_info;
37
38 if (config == NULL)
39 return;
40
41 if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) {
42 printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n");
43 pci_write_config32(dev, CAP_OVERRIDE_LOW,
44 config->sdcard_cap_low);
45 pci_write_config32(dev, CAP_OVERRIDE_HIGH,
46 config->sdcard_cap_high | USE_CAP_OVERRIDES);
47 }
Duncan Laurie430bf0d2013-12-10 14:37:42 -080048
49 if (config->scc_acpi_mode)
50 scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD);
Aaron Durbin8b120a82013-12-10 08:35:51 -080051}
52
53static const struct device_operations device_ops = {
54 .read_resources = pci_dev_read_resources,
55 .set_resources = pci_dev_set_resources,
56 .enable_resources = pci_dev_enable_resources,
57 .init = sd_init,
58 .enable = NULL,
59 .scan_bus = NULL,
60 .ops_pci = &soc_pci_ops,
61};
62
63static const struct pci_driver southcluster __pci_driver = {
64 .ops = &device_ops,
65 .vendor = PCI_VENDOR_ID_INTEL,
66 .device = SD_DEVID,
67};