Angel Pons | ba38f37 | 2020-04-05 15:46:45 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 2 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 3 | #include <device/pci_ops.h> |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 4 | #include <console/console.h> |
| 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
| 7 | #include <device/pci_ids.h> |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 8 | |
| 9 | #include <soc/iosf.h> |
| 10 | #include <soc/nvs.h> |
| 11 | #include <soc/pci_devs.h> |
| 12 | #include <soc/ramstage.h> |
| 13 | #include "chip.h" |
| 14 | |
Angel Pons | aee7ab2 | 2020-03-19 00:31:58 +0100 | [diff] [blame] | 15 | #define CAP_OVERRIDE_LOW 0xa0 |
| 16 | #define CAP_OVERRIDE_HIGH 0xa4 |
| 17 | #define USE_CAP_OVERRIDES (1 << 31) |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 18 | |
Elyes HAOUAS | b13fac3 | 2018-05-24 22:29:44 +0200 | [diff] [blame] | 19 | static void sd_init(struct device *dev) |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 20 | { |
Kyösti Mälkki | 8950cfb | 2019-07-13 22:16:25 +0300 | [diff] [blame] | 21 | struct soc_intel_braswell_config *config = config_of(dev); |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame] | 22 | |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 23 | if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) { |
| 24 | printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n"); |
Angel Pons | aee7ab2 | 2020-03-19 00:31:58 +0100 | [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); |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame] | 30 | if (config->sd_acpi_mode) |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 31 | scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD); |
| 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, |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [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 | }; |