Angel Pons | c3f58f6 | 2020-04-05 15:46:41 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 2 | |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 3 | #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älkki | f3f2aa8 | 2020-12-21 15:17:01 +0200 | [diff] [blame] | 9 | #include <soc/device_nvs.h> |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 10 | #include <soc/iosf.h> |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 11 | #include <soc/pci_devs.h> |
| 12 | #include <soc/ramstage.h> |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 13 | #include "chip.h" |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 14 | |
| 15 | static 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 HAOUAS | 17a3ceb | 2018-05-22 10:42:28 +0200 | [diff] [blame] | 33 | static void emmc_init(struct device *dev) |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 34 | { |
Kyösti Mälkki | 8950cfb | 2019-07-13 22:16:25 +0300 | [diff] [blame] | 35 | struct soc_intel_baytrail_config *config = config_of(dev); |
Duncan Laurie | 430bf0d | 2013-12-10 14:37:42 -0800 | [diff] [blame] | 36 | |
Aaron Durbin | 616f394 | 2013-12-10 17:12:44 -0800 | [diff] [blame] | 37 | printk(BIOS_DEBUG, "eMMC init\n"); |
| 38 | reg_script_run_on_dev(dev, emmc_ops); |
Duncan Laurie | c29d6b8 | 2013-12-12 16:55:36 -0800 | [diff] [blame] | 39 | |
| 40 | if (config->scc_acpi_mode) |
| 41 | scc_enable_acpi_mode(dev, SCC_MMC_CTL, SCC_NVS_MMC); |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static 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 Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 49 | .ops_pci = &soc_pci_ops, |
| 50 | }; |
| 51 | |
| 52 | static const struct pci_driver southcluster __pci_driver = { |
| 53 | .ops = &device_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 54 | .vendor = PCI_VID_INTEL, |
Mate Kukri | 45b51e0 | 2020-07-03 14:44:49 +0200 | [diff] [blame] | 55 | .device = MMC45_DEVID, |
Aaron Durbin | 1592169 | 2013-11-12 16:44:18 -0600 | [diff] [blame] | 56 | }; |