Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <arch/io.h> |
| 21 | #include <console/console.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <device/pci_ids.h> |
| 25 | #include <reg_script.h> |
| 26 | |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame^] | 27 | #include <soc/iosf.h> |
| 28 | #include <soc/nvs.h> |
| 29 | #include <soc/pci_devs.h> |
| 30 | #include <soc/ramstage.h> |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 31 | #include "chip.h" |
| 32 | |
| 33 | #define CAP_OVERRIDE_LOW 0xa0 |
| 34 | #define CAP_OVERRIDE_HIGH 0xa4 |
| 35 | # define USE_CAP_OVERRIDES (1 << 31) |
| 36 | |
| 37 | static void sd_init(device_t dev) |
| 38 | { |
| 39 | struct soc_intel_baytrail_config *config = dev->chip_info; |
| 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, |
| 47 | config->sdcard_cap_low); |
| 48 | pci_write_config32(dev, CAP_OVERRIDE_HIGH, |
| 49 | config->sdcard_cap_high | USE_CAP_OVERRIDES); |
| 50 | } |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 51 | |
| 52 | if (config->scc_acpi_mode) |
| 53 | scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD); |
Aaron Durbin | 8b120a8 | 2013-12-10 08:35:51 -0800 | [diff] [blame] | 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, |
| 61 | .enable = NULL, |
| 62 | .scan_bus = NULL, |
| 63 | .ops_pci = &soc_pci_ops, |
| 64 | }; |
| 65 | |
| 66 | static const struct pci_driver southcluster __pci_driver = { |
| 67 | .ops = &device_ops, |
| 68 | .vendor = PCI_VENDOR_ID_INTEL, |
| 69 | .device = SD_DEVID, |
| 70 | }; |