Angel Pons | c3f58f6 | 2020-04-05 15:46:41 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 3 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 5 | #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 Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 11 | #include <soc/iosf.h> |
| 12 | #include <soc/nvs.h> |
| 13 | #include <soc/pci_devs.h> |
| 14 | #include <soc/ramstage.h> |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 15 | #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 HAOUAS | 17a3ceb | 2018-05-22 10:42:28 +0200 | [diff] [blame] | 21 | static void sd_init(struct device *dev) |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 22 | { |
Kyösti Mälkki | 8950cfb | 2019-07-13 22:16:25 +0300 | [diff] [blame] | 23 | struct soc_intel_baytrail_config *config = config_of(dev); |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 24 | |
| 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 Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 32 | |
| 33 | if (config->scc_acpi_mode) |
| 34 | scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD); |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | static 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 Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 42 | .ops_pci = &soc_pci_ops, |
| 43 | }; |
| 44 | |
| 45 | static const struct pci_driver southcluster __pci_driver = { |
| 46 | .ops = &device_ops, |
| 47 | .vendor = PCI_VENDOR_ID_INTEL, |
| 48 | .device = SD_DEVID, |
| 49 | }; |