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 | |
Angel Pons | 31929bf | 2020-07-07 17:59:14 +0200 | [diff] [blame^] | 15 | #define CAP_OVERRIDE_LOW 0xa0 |
| 16 | #define CAP_OVERRIDE_HIGH 0xa4 |
| 17 | #define USE_CAP_OVERRIDES (1 << 31) |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 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"); |
Angel Pons | 31929bf | 2020-07-07 17:59:14 +0200 | [diff] [blame^] | 25 | 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); |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 28 | } |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 29 | |
| 30 | if (config->scc_acpi_mode) |
| 31 | scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD); |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static 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, |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 39 | .ops_pci = &soc_pci_ops, |
| 40 | }; |
| 41 | |
| 42 | static const struct pci_driver southcluster __pci_driver = { |
| 43 | .ops = &device_ops, |
| 44 | .vendor = PCI_VENDOR_ID_INTEL, |
| 45 | .device = SD_DEVID, |
| 46 | }; |