Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [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 <stdint.h> |
| 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 <baytrail/iosf.h> |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 29 | #include <baytrail/nvs.h> |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 30 | #include <baytrail/pci_devs.h> |
| 31 | #include <baytrail/ramstage.h> |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 32 | #include "chip.h" |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 33 | |
| 34 | static const struct reg_script emmc_ops[] = { |
| 35 | /* Enable 2ms card stable feature. */ |
| 36 | REG_PCI_OR32(0xa8, (1 << 24)), |
| 37 | /* Enable HS200 */ |
| 38 | REG_PCI_WRITE32(0xa0, 0x446cc801), |
| 39 | REG_PCI_WRITE32(0xa4, 0x80000807), |
| 40 | /* cfio_regs_score_special_bits.sdio1_dummy_loopback_en=1 */ |
| 41 | REG_IOSF_OR(IOSF_PORT_SCORE, 0x49c0, (1 << 3)), |
| 42 | /* CLKGATE_EN_1 . cr_scc_mipihsi_clkgate_en = 1 */ |
| 43 | REG_IOSF_RMW(IOSF_PORT_CCU, 0x1c, ~(3 << 26), (1 << 26)), |
| 44 | /* Set slew for HS200 */ |
| 45 | REG_IOSF_RMW(IOSF_PORT_SCORE, 0x48c0, ~0x3c, 0x3c), |
| 46 | REG_IOSF_RMW(IOSF_PORT_SCORE, 0x48c4, ~0x3c, 0x3c), |
| 47 | /* Max timeout */ |
| 48 | REG_RES_WRITE8(PCI_BASE_ADDRESS_0, 0x002e, 0x0e), |
| 49 | REG_SCRIPT_END, |
| 50 | }; |
| 51 | |
| 52 | static void emmc_init(device_t dev) |
| 53 | { |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 54 | struct soc_intel_baytrail_config *config = dev->chip_info; |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 55 | |
| 56 | if (config->scc_acpi_mode) |
| 57 | scc_enable_acpi_mode(dev, SCC_MMC_CTL, SCC_NVS_MMC); |
Aaron Durbin | 616f394 | 2013-12-10 17:12:44 -0800 | [diff] [blame^] | 58 | printk(BIOS_DEBUG, "eMMC init\n"); |
| 59 | reg_script_run_on_dev(dev, emmc_ops); |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | static struct device_operations device_ops = { |
| 63 | .read_resources = pci_dev_read_resources, |
| 64 | .set_resources = pci_dev_set_resources, |
| 65 | .enable_resources = pci_dev_enable_resources, |
| 66 | .init = emmc_init, |
| 67 | .enable = NULL, |
| 68 | .scan_bus = NULL, |
| 69 | .ops_pci = &soc_pci_ops, |
| 70 | }; |
| 71 | |
| 72 | static const struct pci_driver southcluster __pci_driver = { |
| 73 | .ops = &device_ops, |
| 74 | .vendor = PCI_VENDOR_ID_INTEL, |
| 75 | .device = MMC_DEVID, |
| 76 | }; |