blob: 97983f749480acbb988897ee519b5b76fcee15c7 [file] [log] [blame]
Lee Leahy77ff0b12015-05-05 15:07:29 -07001/*
2 * This file is part of the coreboot project.
3 *
Lee Leahy77ff0b12015-05-05 15:07:29 -07004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Lee Leahy77ff0b12015-05-05 15:07:29 -070013 */
14
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020015#include <device/pci_ops.h>
Lee Leahy77ff0b12015-05-05 15:07:29 -070016#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <device/pci_ids.h>
20#include <reg_script.h>
21
22#include <soc/iosf.h>
23#include <soc/nvs.h>
24#include <soc/pci_devs.h>
25#include <soc/ramstage.h>
26#include "chip.h"
27
Angel Ponsaee7ab22020-03-19 00:31:58 +010028#define CAP_OVERRIDE_LOW 0xa0
29#define CAP_OVERRIDE_HIGH 0xa4
30#define USE_CAP_OVERRIDES (1 << 31)
Lee Leahy77ff0b12015-05-05 15:07:29 -070031
Elyes HAOUASb13fac32018-05-24 22:29:44 +020032static void sd_init(struct device *dev)
Lee Leahy77ff0b12015-05-05 15:07:29 -070033{
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +030034 struct soc_intel_braswell_config *config = config_of(dev);
Lee Leahy32471722015-04-20 15:20:28 -070035
Angel Ponsaee7ab22020-03-19 00:31:58 +010036 printk(BIOS_SPEW, "%s/%s (%s)\n", __FILE__, __func__, dev_name(dev));
Lee Leahy77ff0b12015-05-05 15:07:29 -070037
Lee Leahy77ff0b12015-05-05 15:07:29 -070038 if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) {
39 printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n");
Angel Ponsaee7ab22020-03-19 00:31:58 +010040 pci_write_config32(dev, CAP_OVERRIDE_LOW, config->sdcard_cap_low);
41 pci_write_config32(dev, CAP_OVERRIDE_HIGH, config->sdcard_cap_high |
42 USE_CAP_OVERRIDES);
Lee Leahy77ff0b12015-05-05 15:07:29 -070043 }
44
Lee Leahy32471722015-04-20 15:20:28 -070045 if (config->sd_acpi_mode)
Lee Leahy77ff0b12015-05-05 15:07:29 -070046 scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD);
47}
48
49static const struct device_operations device_ops = {
50 .read_resources = pci_dev_read_resources,
51 .set_resources = pci_dev_set_resources,
52 .enable_resources = pci_dev_enable_resources,
53 .init = sd_init,
Lee Leahy77ff0b12015-05-05 15:07:29 -070054 .ops_pci = &soc_pci_ops,
55};
56
57static const struct pci_driver southcluster __pci_driver = {
58 .ops = &device_ops,
59 .vendor = PCI_VENDOR_ID_INTEL,
60 .device = SD_DEVID,
61};