blob: 8709e24c4d7c7969e8024424ef99b16954dd9d0b [file] [log] [blame]
Angel Ponsc3f58f62020-04-05 15:46:41 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Aaron Durbin8b120a82013-12-10 08:35:51 -08003
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Aaron Durbin8b120a82013-12-10 08:35:51 -08005#include <console/console.h>
6#include <device/device.h>
7#include <device/pci.h>
8#include <device/pci_ids.h>
9#include <reg_script.h>
10
Julius Werner18ea2d32014-10-07 16:42:17 -070011#include <soc/iosf.h>
12#include <soc/nvs.h>
13#include <soc/pci_devs.h>
14#include <soc/ramstage.h>
Aaron Durbin8b120a82013-12-10 08:35:51 -080015#include "chip.h"
16
17#define CAP_OVERRIDE_LOW 0xa0
18#define CAP_OVERRIDE_HIGH 0xa4
19# define USE_CAP_OVERRIDES (1 << 31)
20
Elyes HAOUAS17a3ceb2018-05-22 10:42:28 +020021static void sd_init(struct device *dev)
Aaron Durbin8b120a82013-12-10 08:35:51 -080022{
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +030023 struct soc_intel_baytrail_config *config = config_of(dev);
Aaron Durbin8b120a82013-12-10 08:35:51 -080024
25 if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) {
26 printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n");
27 pci_write_config32(dev, CAP_OVERRIDE_LOW,
28 config->sdcard_cap_low);
29 pci_write_config32(dev, CAP_OVERRIDE_HIGH,
30 config->sdcard_cap_high | USE_CAP_OVERRIDES);
31 }
Duncan Laurie430bf0d2013-12-10 14:37:42 -080032
33 if (config->scc_acpi_mode)
34 scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD);
Aaron Durbin8b120a82013-12-10 08:35:51 -080035}
36
37static const struct device_operations device_ops = {
38 .read_resources = pci_dev_read_resources,
39 .set_resources = pci_dev_set_resources,
40 .enable_resources = pci_dev_enable_resources,
41 .init = sd_init,
Aaron Durbin8b120a82013-12-10 08:35:51 -080042 .ops_pci = &soc_pci_ops,
43};
44
45static const struct pci_driver southcluster __pci_driver = {
46 .ops = &device_ops,
47 .vendor = PCI_VENDOR_ID_INTEL,
48 .device = SD_DEVID,
49};