blob: 347ca16f40e5bce9bb800d713ef608d0feddca89 [file] [log] [blame]
Angel Ponsc3f58f62020-04-05 15:46:41 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Aaron Durbin15921692013-11-12 16:44:18 -06003
4#include <stdint.h>
Aaron Durbin15921692013-11-12 16:44:18 -06005#include <console/console.h>
6#include <device/device.h>
7#include <device/pci.h>
8#include <device/pci_ids.h>
9#include <reg_script.h>
10
Julius Werner18ea2d32014-10-07 16:42:17 -070011#include <soc/iosf.h>
12#include <soc/nvs.h>
13#include <soc/pci_devs.h>
14#include <soc/ramstage.h>
Duncan Laurie430bf0d2013-12-10 14:37:42 -080015#include "chip.h"
Aaron Durbin15921692013-11-12 16:44:18 -060016
17static const struct reg_script emmc_ops[] = {
18 /* Enable 2ms card stable feature. */
19 REG_PCI_OR32(0xa8, (1 << 24)),
20 /* Enable HS200 */
21 REG_PCI_WRITE32(0xa0, 0x446cc801),
22 REG_PCI_WRITE32(0xa4, 0x80000807),
23 /* cfio_regs_score_special_bits.sdio1_dummy_loopback_en=1 */
24 REG_IOSF_OR(IOSF_PORT_SCORE, 0x49c0, (1 << 3)),
25 /* CLKGATE_EN_1 . cr_scc_mipihsi_clkgate_en = 1 */
26 REG_IOSF_RMW(IOSF_PORT_CCU, 0x1c, ~(3 << 26), (1 << 26)),
27 /* Set slew for HS200 */
28 REG_IOSF_RMW(IOSF_PORT_SCORE, 0x48c0, ~0x3c, 0x3c),
29 REG_IOSF_RMW(IOSF_PORT_SCORE, 0x48c4, ~0x3c, 0x3c),
30 /* Max timeout */
31 REG_RES_WRITE8(PCI_BASE_ADDRESS_0, 0x002e, 0x0e),
32 REG_SCRIPT_END,
33};
34
Elyes HAOUAS17a3ceb2018-05-22 10:42:28 +020035static void emmc_init(struct device *dev)
Aaron Durbin15921692013-11-12 16:44:18 -060036{
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +030037 struct soc_intel_baytrail_config *config = config_of(dev);
Duncan Laurie430bf0d2013-12-10 14:37:42 -080038
Aaron Durbin616f3942013-12-10 17:12:44 -080039 printk(BIOS_DEBUG, "eMMC init\n");
40 reg_script_run_on_dev(dev, emmc_ops);
Duncan Lauriec29d6b82013-12-12 16:55:36 -080041
42 if (config->scc_acpi_mode)
43 scc_enable_acpi_mode(dev, SCC_MMC_CTL, SCC_NVS_MMC);
Aaron Durbin15921692013-11-12 16:44:18 -060044}
45
46static struct device_operations device_ops = {
47 .read_resources = pci_dev_read_resources,
48 .set_resources = pci_dev_set_resources,
49 .enable_resources = pci_dev_enable_resources,
50 .init = emmc_init,
Aaron Durbin15921692013-11-12 16:44:18 -060051 .ops_pci = &soc_pci_ops,
52};
53
54static const struct pci_driver southcluster __pci_driver = {
55 .ops = &device_ops,
56 .vendor = PCI_VENDOR_ID_INTEL,
57 .device = MMC_DEVID,
58};