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. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
Patrick Georgi | 25509ee | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 18 | * Foundation, Inc. |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include <arch/io.h> |
| 22 | #include <console/console.h> |
| 23 | #include <device/device.h> |
| 24 | #include <device/pci.h> |
| 25 | #include <device/pci_ids.h> |
| 26 | #include <reg_script.h> |
| 27 | |
| 28 | #include <soc/iosf.h> |
| 29 | #include <soc/nvs.h> |
| 30 | #include <soc/pci_devs.h> |
| 31 | #include <soc/ramstage.h> |
| 32 | #include "chip.h" |
| 33 | |
| 34 | #define CAP_OVERRIDE_LOW 0xa0 |
| 35 | #define CAP_OVERRIDE_HIGH 0xa4 |
| 36 | # define USE_CAP_OVERRIDES (1 << 31) |
| 37 | |
| 38 | static void sd_init(device_t dev) |
| 39 | { |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame^] | 40 | struct soc_intel_braswell_config *config = dev->chip_info; |
| 41 | |
| 42 | printk(BIOS_SPEW, "%s/%s ( %s )\n", |
| 43 | __FILE__, __func__, dev_name(dev)); |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 44 | |
| 45 | if (config == NULL) |
| 46 | return; |
| 47 | |
| 48 | if (config->sdcard_cap_low != 0 || config->sdcard_cap_high != 0) { |
| 49 | printk(BIOS_DEBUG, "Overriding SD Card controller caps.\n"); |
| 50 | pci_write_config32(dev, CAP_OVERRIDE_LOW, |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame^] | 51 | config->sdcard_cap_low); |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 52 | pci_write_config32(dev, CAP_OVERRIDE_HIGH, |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame^] | 53 | config->sdcard_cap_high | USE_CAP_OVERRIDES); |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Lee Leahy | 3247172 | 2015-04-20 15:20:28 -0700 | [diff] [blame^] | 56 | if (config->sd_acpi_mode) |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 57 | scc_enable_acpi_mode(dev, SCC_SD_CTL, SCC_NVS_SD); |
| 58 | } |
| 59 | |
| 60 | static const struct device_operations device_ops = { |
| 61 | .read_resources = pci_dev_read_resources, |
| 62 | .set_resources = pci_dev_set_resources, |
| 63 | .enable_resources = pci_dev_enable_resources, |
| 64 | .init = sd_init, |
Lee Leahy | 77ff0b1 | 2015-05-05 15:07:29 -0700 | [diff] [blame] | 65 | .ops_pci = &soc_pci_ops, |
| 66 | }; |
| 67 | |
| 68 | static const struct pci_driver southcluster __pci_driver = { |
| 69 | .ops = &device_ops, |
| 70 | .vendor = PCI_VENDOR_ID_INTEL, |
| 71 | .device = SD_DEVID, |
| 72 | }; |