blob: 12e77c9230e1ec9ba32ae83310944111bbf26823 [file] [log] [blame]
Angel Ponsba38f372020-04-05 15:46:45 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahy77ff0b12015-05-05 15:07:29 -07002
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02003#include <device/pci_ops.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -07004#include <console/console.h>
5#include <device/device.h>
6#include <device/pci.h>
7#include <device/pci_ids.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -07008
Kyösti Mälkkif3f2aa82020-12-21 15:17:01 +02009#include <soc/device_nvs.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -070010#include <soc/iosf.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -070011#include <soc/pci_devs.h>
12#include <soc/ramstage.h>
13#include "chip.h"
14
Angel Ponsaee7ab22020-03-19 00:31:58 +010015#define CAP_OVERRIDE_LOW 0xa0
16#define CAP_OVERRIDE_HIGH 0xa4
17#define USE_CAP_OVERRIDES (1 << 31)
Lee Leahy77ff0b12015-05-05 15:07:29 -070018
Elyes HAOUASb13fac32018-05-24 22:29:44 +020019static void sd_init(struct device *dev)
Lee Leahy77ff0b12015-05-05 15:07:29 -070020{
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +030021 struct soc_intel_braswell_config *config = config_of(dev);
Lee Leahy32471722015-04-20 15:20:28 -070022
Lee Leahy77ff0b12015-05-05 15:07:29 -070023 if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) {
24 printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n");
Angel Ponsaee7ab22020-03-19 00:31:58 +010025 pci_write_config32(dev, CAP_OVERRIDE_LOW, config->sdcard_cap_low);
26 pci_write_config32(dev, CAP_OVERRIDE_HIGH, config->sdcard_cap_high |
27 USE_CAP_OVERRIDES);
Lee Leahy77ff0b12015-05-05 15:07:29 -070028 }
29
Lee Leahy32471722015-04-20 15:20:28 -070030 if (config->sd_acpi_mode)
Lee Leahy77ff0b12015-05-05 15:07:29 -070031 scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD);
32}
33
34static const struct device_operations device_ops = {
35 .read_resources = pci_dev_read_resources,
36 .set_resources = pci_dev_set_resources,
37 .enable_resources = pci_dev_enable_resources,
38 .init = sd_init,
Lee Leahy77ff0b12015-05-05 15:07:29 -070039 .ops_pci = &soc_pci_ops,
40};
41
42static const struct pci_driver southcluster __pci_driver = {
43 .ops = &device_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010044 .vendor = PCI_VID_INTEL,
Lee Leahy77ff0b12015-05-05 15:07:29 -070045 .device = SD_DEVID,
46};