Angel Pons | c3f58f6 | 2020-04-05 15:46:41 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 2 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 3 | #include <device/pci_ops.h> |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 4 | #include <console/console.h> |
| 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
| 7 | #include <device/pci_ids.h> |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 8 | |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 9 | #include <soc/iosf.h> |
| 10 | #include <soc/nvs.h> |
| 11 | #include <soc/pci_devs.h> |
| 12 | #include <soc/ramstage.h> |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 13 | #include "chip.h" |
| 14 | |
| 15 | #define CAP_OVERRIDE_LOW 0xa0 |
| 16 | #define CAP_OVERRIDE_HIGH 0xa4 |
| 17 | # define USE_CAP_OVERRIDES (1 << 31) |
| 18 | |
Elyes HAOUAS | 17a3ceb | 2018-05-22 10:42:28 +0200 | [diff] [blame] | 19 | static void sd_init(struct device *dev) |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 20 | { |
Kyösti Mälkki | 8950cfb | 2019-07-13 22:16:25 +0300 | [diff] [blame] | 21 | struct soc_intel_baytrail_config *config = config_of(dev); |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 22 | |
| 23 | if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) { |
| 24 | printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n"); |
| 25 | pci_write_config32(dev, CAP_OVERRIDE_LOW, |
| 26 | config->sdcard_cap_low); |
| 27 | pci_write_config32(dev, CAP_OVERRIDE_HIGH, |
| 28 | config->sdcard_cap_high | USE_CAP_OVERRIDES); |
| 29 | } |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 30 | |
| 31 | if (config->scc_acpi_mode) |
| 32 | scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD); |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | static const struct device_operations device_ops = { |
| 36 | .read_resources = pci_dev_read_resources, |
| 37 | .set_resources = pci_dev_set_resources, |
| 38 | .enable_resources = pci_dev_enable_resources, |
| 39 | .init = sd_init, |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 40 | .ops_pci = &soc_pci_ops, |
| 41 | }; |
| 42 | |
| 43 | static const struct pci_driver southcluster __pci_driver = { |
| 44 | .ops = &device_ops, |
| 45 | .vendor = PCI_VENDOR_ID_INTEL, |
| 46 | .device = SD_DEVID, |
| 47 | }; |