Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Google Inc. |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame] | 5 | * Copyright (C) 2015 Intel Corp. |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 17 | #include <device/pci_ops.h> |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 18 | #include <console/console.h> |
| 19 | #include <device/device.h> |
| 20 | #include <device/pci.h> |
| 21 | #include <device/pci_ids.h> |
| 22 | #include <reg_script.h> |
| 23 | |
| 24 | #include <soc/iosf.h> |
| 25 | #include <soc/nvs.h> |
| 26 | #include <soc/pci_devs.h> |
| 27 | #include <soc/ramstage.h> |
| 28 | #include "chip.h" |
| 29 | |
| 30 | #define CAP_OVERRIDE_LOW 0xa0 |
| 31 | #define CAP_OVERRIDE_HIGH 0xa4 |
| 32 | # define USE_CAP_OVERRIDES (1 << 31) |
| 33 | |
Elyes HAOUAS | b13fac3 | 2018-05-24 22:29:44 +0200 | [diff] [blame] | 34 | static void sd_init(struct device *dev) |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 35 | { |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame] | 36 | struct soc_intel_braswell_config *config = dev->chip_info; |
| 37 | |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 38 | printk(BIOS_SPEW, "%s/%s (%s)\n", |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame] | 39 | __FILE__, __func__, dev_name(dev)); |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 40 | |
| 41 | if (config == NULL) |
| 42 | return; |
| 43 | |
| 44 | if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) { |
| 45 | printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n"); |
| 46 | pci_write_config32(dev, CAP_OVERRIDE_LOW, |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame] | 47 | config->sdcard_cap_low); |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 48 | pci_write_config32(dev, CAP_OVERRIDE_HIGH, |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame] | 49 | config->sdcard_cap_high | USE_CAP_OVERRIDES); |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame] | 52 | if (config->sd_acpi_mode) |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 53 | scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD); |
| 54 | } |
| 55 | |
| 56 | static const struct device_operations device_ops = { |
| 57 | .read_resources = pci_dev_read_resources, |
| 58 | .set_resources = pci_dev_set_resources, |
| 59 | .enable_resources = pci_dev_enable_resources, |
| 60 | .init = sd_init, |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 61 | .ops_pci = &soc_pci_ops, |
| 62 | }; |
| 63 | |
| 64 | static const struct pci_driver southcluster __pci_driver = { |
| 65 | .ops = &device_ops, |
| 66 | .vendor = PCI_VENDOR_ID_INTEL, |
| 67 | .device = SD_DEVID, |
| 68 | }; |