blob: 3bfad01f4b278b7ccc3bc9e1467621e2ef3a7f82 [file] [log] [blame]
Angel Ponsc3f58f62020-04-05 15:46:41 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin15921692013-11-12 16:44:18 -06002
Aaron Durbin15921692013-11-12 16:44:18 -06003#include <console/console.h>
4#include <device/device.h>
5#include <device/pci.h>
6#include <device/pci_ids.h>
7#include <reg_script.h>
8
Kyösti Mälkkif3f2aa82020-12-21 15:17:01 +02009#include <soc/device_nvs.h>
Julius Werner18ea2d32014-10-07 16:42:17 -070010#include <soc/iosf.h>
Julius Werner18ea2d32014-10-07 16:42:17 -070011#include <soc/pci_devs.h>
12#include <soc/ramstage.h>
Duncan Laurie430bf0d2013-12-10 14:37:42 -080013#include "chip.h"
Aaron Durbin15921692013-11-12 16:44:18 -060014
15static const struct reg_script emmc_ops[] = {
16 /* Enable 2ms card stable feature. */
17 REG_PCI_OR32(0xa8, (1 << 24)),
18 /* Enable HS200 */
19 REG_PCI_WRITE32(0xa0, 0x446cc801),
20 REG_PCI_WRITE32(0xa4, 0x80000807),
21 /* cfio_regs_score_special_bits.sdio1_dummy_loopback_en=1 */
22 REG_IOSF_OR(IOSF_PORT_SCORE, 0x49c0, (1 << 3)),
23 /* CLKGATE_EN_1 . cr_scc_mipihsi_clkgate_en = 1 */
24 REG_IOSF_RMW(IOSF_PORT_CCU, 0x1c, ~(3 << 26), (1 << 26)),
25 /* Set slew for HS200 */
26 REG_IOSF_RMW(IOSF_PORT_SCORE, 0x48c0, ~0x3c, 0x3c),
27 REG_IOSF_RMW(IOSF_PORT_SCORE, 0x48c4, ~0x3c, 0x3c),
28 /* Max timeout */
29 REG_RES_WRITE8(PCI_BASE_ADDRESS_0, 0x002e, 0x0e),
30 REG_SCRIPT_END,
31};
32
Elyes HAOUAS17a3ceb2018-05-22 10:42:28 +020033static void emmc_init(struct device *dev)
Aaron Durbin15921692013-11-12 16:44:18 -060034{
Kyösti Mälkki8950cfb2019-07-13 22:16:25 +030035 struct soc_intel_baytrail_config *config = config_of(dev);
Duncan Laurie430bf0d2013-12-10 14:37:42 -080036
Aaron Durbin616f3942013-12-10 17:12:44 -080037 printk(BIOS_DEBUG, "eMMC init\n");
38 reg_script_run_on_dev(dev, emmc_ops);
Duncan Lauriec29d6b82013-12-12 16:55:36 -080039
40 if (config->scc_acpi_mode)
41 scc_enable_acpi_mode(dev, SCC_MMC_CTL, SCC_NVS_MMC);
Aaron Durbin15921692013-11-12 16:44:18 -060042}
43
44static struct device_operations device_ops = {
45 .read_resources = pci_dev_read_resources,
46 .set_resources = pci_dev_set_resources,
47 .enable_resources = pci_dev_enable_resources,
48 .init = emmc_init,
Aaron Durbin15921692013-11-12 16:44:18 -060049 .ops_pci = &soc_pci_ops,
50};
51
52static const struct pci_driver southcluster __pci_driver = {
53 .ops = &device_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010054 .vendor = PCI_VID_INTEL,
Mate Kukri45b51e02020-07-03 14:44:49 +020055 .device = MMC45_DEVID,
Aaron Durbin15921692013-11-12 16:44:18 -060056};