Lines Matching +full:sdhci +full:- +full:caps +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* linux/drivers/mmc/host/sdhci-pci.c - SDHCI on PCI bus interface
4 * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
8 * - JMicron (hardware and technical support)
17 #include <linux/dma-mapping.h>
33 #include <linux/mmc/slot-gpio.h>
41 #include "sdhci.h"
42 #include "sdhci-cqhci.h"
43 #include "sdhci-pci.h"
44 #include "sdhci-uhs2.h"
55 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_init_wakeup()
56 struct sdhci_pci_slot *slot = chip->slots[i]; in sdhci_pci_init_wakeup()
59 pm_flags |= slot->host->mmc->pm_flags; in sdhci_pci_init_wakeup()
60 if (slot->host->mmc->caps & MMC_CAP_CD_WAKE) in sdhci_pci_init_wakeup()
66 return device_wakeup_enable(&chip->pdev->dev); in sdhci_pci_init_wakeup()
68 device_wakeup_disable(&chip->pdev->dev); in sdhci_pci_init_wakeup()
79 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_suspend_host()
80 struct sdhci_pci_slot *slot = chip->slots[i]; in sdhci_pci_suspend_host()
86 host = slot->host; in sdhci_pci_suspend_host()
88 if (chip->pm_retune && host->tuning_mode != SDHCI_TUNING_MODE_3) in sdhci_pci_suspend_host()
89 mmc_retune_needed(host->mmc); in sdhci_pci_suspend_host()
95 if (device_may_wakeup(&chip->pdev->dev)) in sdhci_pci_suspend_host()
96 mmc_gpio_set_cd_wake(host->mmc, true); in sdhci_pci_suspend_host()
102 while (--i >= 0) in sdhci_pci_suspend_host()
103 sdhci_resume_host(chip->slots[i]->host); in sdhci_pci_suspend_host()
112 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_resume_host()
113 slot = chip->slots[i]; in sdhci_pci_resume_host()
117 ret = sdhci_resume_host(slot->host); in sdhci_pci_resume_host()
121 mmc_gpio_set_cd_wake(slot->host->mmc, false); in sdhci_pci_resume_host()
131 ret = cqhci_suspend(chip->slots[0]->host->mmc); in sdhci_cqhci_suspend()
146 return cqhci_resume(chip->slots[0]->host->mmc); in sdhci_cqhci_resume()
157 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_runtime_suspend_host()
158 slot = chip->slots[i]; in sdhci_pci_runtime_suspend_host()
162 host = slot->host; in sdhci_pci_runtime_suspend_host()
168 if (chip->rpm_retune && in sdhci_pci_runtime_suspend_host()
169 host->tuning_mode != SDHCI_TUNING_MODE_3) in sdhci_pci_runtime_suspend_host()
170 mmc_retune_needed(host->mmc); in sdhci_pci_runtime_suspend_host()
176 while (--i >= 0) in sdhci_pci_runtime_suspend_host()
177 sdhci_runtime_resume_host(chip->slots[i]->host, 0); in sdhci_pci_runtime_suspend_host()
186 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_runtime_resume_host()
187 slot = chip->slots[i]; in sdhci_pci_runtime_resume_host()
191 ret = sdhci_runtime_resume_host(slot->host, 0); in sdhci_pci_runtime_resume_host()
203 ret = cqhci_suspend(chip->slots[0]->host->mmc); in sdhci_cqhci_runtime_suspend()
218 return cqhci_resume(chip->slots[0]->host->mmc); in sdhci_cqhci_runtime_resume()
230 cqhci_irq(host->mmc, intmask, cmd_error, data_error); in sdhci_cqhci_irq()
248 if (chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG || in ricoh_probe()
249 chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SONY) in ricoh_probe()
250 chip->quirks |= SDHCI_QUIRK_NO_CARD_NO_RESET; in ricoh_probe()
256 u32 caps = in ricoh_mmc_probe_slot() local
265 __sdhci_read_caps(slot->host, NULL, &caps, &caps1); in ricoh_mmc_probe_slot()
308 if (!(host->flags & SDHCI_DEVICE_DEAD)) in ene_714_set_ios()
314 slot->host->mmc_host_ops.set_ios = ene_714_set_ios; in ene_714_probe_slot()
342 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; in mrst_hc_probe_slot()
356 chip->num_slots = 1; in mrst_hc_probe()
362 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; in pch_hc_probe_slot()
368 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE; in mfd_emmc_probe_slot()
369 slot->host->mmc->caps2 |= MMC_CAP2_BOOTPART_NOACC; in mfd_emmc_probe_slot()
375 slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE; in mfd_sdio_probe_slot()
423 if (pdev->device != PCI_DEVICE_ID_INTEL_BYT_EMMC && in byt_ocp_setting()
424 pdev->device != PCI_DEVICE_ID_INTEL_BYT_SDIO && in byt_ocp_setting()
425 pdev->device != PCI_DEVICE_ID_INTEL_BYT_SD && in byt_ocp_setting()
426 pdev->device != PCI_DEVICE_ID_INTEL_BYT_EMMC2) in byt_ocp_setting()
431 dev_err(&pdev->dev, "%s read error\n", __func__); in byt_ocp_setting()
442 dev_err(&pdev->dev, "%s write error\n", __func__); in byt_ocp_setting()
446 dev_dbg(&pdev->dev, "%s completed\n", __func__); in byt_ocp_setting()
491 return -EOPNOTSUPP; in __intel_dsm()
493 if (obj->buffer.length < 1) { in __intel_dsm()
494 err = -EINVAL; in __intel_dsm()
498 len = min_t(size_t, obj->buffer.length, 4); in __intel_dsm()
501 memcpy(result, obj->buffer.pointer, len); in __intel_dsm()
511 if (fn > 31 || !(intel_host->dsm_fns & (1 << fn))) in intel_dsm()
512 return -EOPNOTSUPP; in intel_dsm()
523 intel_host->d3_retune = true; in intel_dsm_init()
525 err = __intel_dsm(intel_host, dev, INTEL_DSM_FNS, &intel_host->dsm_fns); in intel_dsm_init()
532 pr_debug("%s: DSM function mask %#x\n", in intel_dsm_init()
533 mmc_hostname(mmc), intel_host->dsm_fns); in intel_dsm_init()
536 intel_host->drv_strength = err ? 0 : val; in intel_dsm_init()
539 intel_host->d3_retune = err ? true : !!val; in intel_dsm_init()
561 struct sdhci_host *host = mmc_priv(card->host); in intel_select_drive_strength()
565 if (!(mmc_driver_type_mask(intel_host->drv_strength) & card_drv)) in intel_select_drive_strength()
568 return intel_host->drv_strength; in intel_select_drive_strength()
603 if (intel_host->needs_pwr_off) { in sdhci_intel_set_power()
604 intel_host->needs_pwr_off = false; in sdhci_intel_set_power()
614 if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD || in sdhci_intel_set_power()
615 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BYT_SD) in sdhci_intel_set_power()
621 * Bus power might not enable after D3 -> D0 transition due to the in sdhci_intel_set_power()
653 if (ios->enhanced_strobe) in intel_hs400_enhanced_strobe()
675 switch (ios->signal_voltage) { in intel_start_signal_voltage_switch()
717 struct device *dev = &slot->chip->pdev->dev; in byt_read_dsm()
718 struct mmc_host *mmc = slot->host->mmc; in byt_read_dsm()
721 slot->chip->rpm_retune = intel_host->d3_retune; in byt_read_dsm()
754 struct sdhci_host *host = slot->host; in intel_cache_ltr()
756 intel_host->active_ltr = readl(host->ioaddr + INTEL_ACTIVELTR); in intel_cache_ltr()
757 intel_host->idle_ltr = readl(host->ioaddr + INTEL_IDLELTR); in intel_cache_ltr()
763 struct sdhci_pci_slot *slot = chip->slots[0]; in intel_ltr_set()
765 struct sdhci_host *host = slot->host; in intel_ltr_set()
775 ltr = readl(host->ioaddr + INTEL_ACTIVELTR); in intel_ltr_set()
794 if (ltr == intel_host->active_ltr) in intel_ltr_set()
797 writel(ltr, host->ioaddr + INTEL_ACTIVELTR); in intel_ltr_set()
798 writel(ltr, host->ioaddr + INTEL_IDLELTR); in intel_ltr_set()
808 switch (chip->pdev->device) { in intel_use_ltr()
824 struct device *dev = &chip->pdev->dev; in intel_ltr_expose()
829 dev->power.set_latency_tolerance = intel_ltr_set; in intel_ltr_expose()
835 struct device *dev = &chip->pdev->dev; in intel_ltr_hide()
841 dev->power.set_latency_tolerance = NULL; in intel_ltr_hide()
846 struct mmc_host_ops *ops = &slot->host->mmc_host_ops; in byt_probe_slot()
847 struct device *dev = &slot->chip->pdev->dev; in byt_probe_slot()
848 struct mmc_host *mmc = slot->host->mmc; in byt_probe_slot()
852 byt_ocp_setting(slot->chip->pdev); in byt_probe_slot()
854 ops->execute_tuning = intel_execute_tuning; in byt_probe_slot()
855 ops->start_signal_voltage_switch = intel_start_signal_voltage_switch; in byt_probe_slot()
857 device_property_read_u32(dev, "max-frequency", &mmc->f_max); in byt_probe_slot()
859 if (!mmc->slotno) { in byt_probe_slot()
860 slot->chip->slots[mmc->slotno] = slot; in byt_probe_slot()
861 intel_ltr_expose(slot->chip); in byt_probe_slot()
868 struct mmc_host *mmc = slot->host->mmc; in byt_add_debugfs()
869 struct dentry *dir = mmc->debugfs_root; in byt_add_debugfs()
871 if (!intel_use_ltr(slot->chip)) in byt_add_debugfs()
874 debugfs_create_x32("active_ltr", 0444, dir, &intel_host->active_ltr); in byt_add_debugfs()
875 debugfs_create_x32("idle_ltr", 0444, dir, &intel_host->idle_ltr); in byt_add_debugfs()
882 int ret = sdhci_add_host(slot->host); in byt_add_host()
891 struct mmc_host *mmc = slot->host->mmc; in byt_remove_slot()
893 if (!mmc->slotno) in byt_remove_slot()
894 intel_ltr_hide(slot->chip); in byt_remove_slot()
900 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | in byt_emmc_probe_slot()
904 slot->hw_reset = sdhci_pci_int_hw_reset; in byt_emmc_probe_slot()
905 if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BSW_EMMC) in byt_emmc_probe_slot()
906 slot->host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */ in byt_emmc_probe_slot()
907 slot->host->mmc_host_ops.select_drive_strength = in byt_emmc_probe_slot()
914 return slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_GLK_EMMC && in glk_broken_cqhci()
921 return slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_JSL_EMMC && in jsl_broken_hs400es()
930 slot->host->mmc->caps2 |= MMC_CAP2_CQE; in glk_emmc_probe_slot()
932 if (slot->chip->pdev->device != PCI_DEVICE_ID_INTEL_GLK_EMMC) { in glk_emmc_probe_slot()
934 slot->host->mmc->caps2 |= MMC_CAP2_HS400_ES; in glk_emmc_probe_slot()
935 slot->host->mmc_host_ops.hs400_enhanced_strobe = in glk_emmc_probe_slot()
938 slot->host->mmc->caps2 |= MMC_CAP2_CQE_DCMD; in glk_emmc_probe_slot()
952 struct device *dev = &slot->chip->pdev->dev; in glk_emmc_add_host()
953 struct sdhci_host *host = slot->host; in glk_emmc_add_host()
964 ret = -ENOMEM; in glk_emmc_add_host()
968 cq_host->mmio = host->ioaddr + 0x200; in glk_emmc_add_host()
969 cq_host->quirks |= CQHCI_QUIRK_SHORT_TXFR_DESC_SZ; in glk_emmc_add_host()
970 cq_host->ops = &glk_cqhci_ops; in glk_emmc_add_host()
972 dma64 = host->flags & SDHCI_USE_64_BIT_DMA; in glk_emmc_add_host()
974 cq_host->caps |= CQHCI_TASK_DESC_SZ_128; in glk_emmc_add_host()
976 ret = cqhci_init(cq_host, host->mmc, dma64); in glk_emmc_add_host()
1001 struct sdhci_pci_slot *slot = chip->slots[0]; in glk_rpm_retune_wa()
1003 struct sdhci_host *host = slot->host; in glk_rpm_retune_wa()
1008 if (intel_host->rpm_retune_ok || !mmc_can_retune(host->mmc)) in glk_rpm_retune_wa()
1015 intel_host->glk_rx_ctrl1 = glk_rx_ctrl1; in glk_rpm_retune_wa()
1016 intel_host->glk_tun_val = glk_tun_val; in glk_rpm_retune_wa()
1020 if (!intel_host->glk_tun_val) in glk_rpm_retune_wa()
1023 if (glk_rx_ctrl1 != intel_host->glk_rx_ctrl1) { in glk_rpm_retune_wa()
1024 intel_host->rpm_retune_ok = true; in glk_rpm_retune_wa()
1029 (intel_host->glk_tun_val << 1)); in glk_rpm_retune_wa()
1036 intel_host->rpm_retune_ok = true; in glk_rpm_retune_wa()
1037 chip->rpm_retune = true; in glk_rpm_retune_wa()
1038 mmc_retune_needed(host->mmc); in glk_rpm_retune_wa()
1039 pr_info("%s: Requiring re-tune after rpm resume", mmc_hostname(host->mmc)); in glk_rpm_retune_wa()
1044 if (chip->pdev->device == PCI_DEVICE_ID_INTEL_GLK_EMMC && in glk_rpm_retune_chk()
1045 !chip->rpm_retune) in glk_rpm_retune_chk()
1070 status = acpi_evaluate_integer(ACPI_HANDLE(&slot->chip->pdev->dev), in ni_set_max_freq()
1073 dev_err(&slot->chip->pdev->dev, in ni_set_max_freq()
1075 return -EINVAL; in ni_set_max_freq()
1078 slot->host->mmc->f_max = max_freq * 1000000; in ni_set_max_freq()
1099 slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE | in ni_byt_sdio_probe_slot()
1107 slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE | in byt_sdio_probe_slot()
1115 u8 reg = sdhci_readb(slot->host, SDHCI_POWER_CONTROL); in byt_needs_pwr_off()
1117 intel_host->needs_pwr_off = reg & SDHCI_POWER_ON; in byt_needs_pwr_off()
1123 slot->host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY | in byt_sd_probe_slot()
1125 slot->cd_idx = 0; in byt_sd_probe_slot()
1126 slot->cd_override_level = true; in byt_sd_probe_slot()
1127 if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXT_SD || in byt_sd_probe_slot()
1128 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXTM_SD || in byt_sd_probe_slot()
1129 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD || in byt_sd_probe_slot()
1130 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_GLK_SD) in byt_sd_probe_slot()
1131 slot->host->mmc_host_ops.get_cd = bxt_get_cd; in byt_sd_probe_slot()
1133 if (slot->chip->pdev->subsystem_vendor == PCI_VENDOR_ID_NI && in byt_sd_probe_slot()
1134 slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3) in byt_sd_probe_slot()
1135 slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V; in byt_sd_probe_slot()
1146 byt_ocp_setting(chip->pdev); in byt_resume()
1157 byt_ocp_setting(chip->pdev); in byt_runtime_resume()
1300 device = ACPI_COMPANION(&slot->chip->pdev->dev); in intel_mrfld_mmc_fix_up_power_slot()
1310 unsigned int func = PCI_FUNC(slot->chip->pdev->devfn); in intel_mrfld_mmc_probe_slot()
1315 slot->host->mmc->caps |= MMC_CAP_NONREMOVABLE | in intel_mrfld_mmc_probe_slot()
1320 slot->cd_idx = 0; in intel_mrfld_mmc_probe_slot()
1321 slot->cd_override_level = true; in intel_mrfld_mmc_probe_slot()
1325 * completely in the custom ->get_cd() callback. in intel_mrfld_mmc_probe_slot()
1327 slot->host->mmc_host_ops.get_cd = mrfld_get_cd; in intel_mrfld_mmc_probe_slot()
1328 slot->host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; in intel_mrfld_mmc_probe_slot()
1332 slot->host->ocr_mask = MMC_VDD_20_21 | MMC_VDD_165_195; in intel_mrfld_mmc_probe_slot()
1333 slot->host->mmc->caps |= MMC_CAP_NONREMOVABLE | in intel_mrfld_mmc_probe_slot()
1337 return -ENODEV; in intel_mrfld_mmc_probe_slot()
1374 ret = pci_read_config_byte(chip->pdev, 0xAE, &scratch); in jmicron_pmos()
1387 ret = pci_write_config_byte(chip->pdev, 0xAE, scratch); in jmicron_pmos()
1398 if (chip->pdev->revision == 0) { in jmicron_probe()
1399 chip->quirks |= SDHCI_QUIRK_32BIT_DMA_ADDR | in jmicron_probe()
1418 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_SD) in jmicron_probe()
1420 else if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD) in jmicron_probe()
1429 if ((PCI_SLOT(chip->pdev->devfn) == in jmicron_probe()
1430 PCI_SLOT(sd_dev->devfn)) && in jmicron_probe()
1431 (chip->pdev->bus == sd_dev->bus)) in jmicron_probe()
1437 dev_info(&chip->pdev->dev, "Refusing to bind to " in jmicron_probe()
1439 return -ENODEV; in jmicron_probe()
1449 dev_err(&chip->pdev->dev, "Failure enabling card power\n"); in jmicron_probe()
1460 scratch = readb(host->ioaddr + 0xC0); in jmicron_enable_mmc()
1467 writeb(scratch, host->ioaddr + 0xC0); in jmicron_enable_mmc()
1472 if (slot->chip->pdev->revision == 0) { in jmicron_probe_slot()
1475 version = readl(slot->host->ioaddr + SDHCI_HOST_VERSION); in jmicron_probe_slot()
1485 slot->host->quirks |= SDHCI_QUIRK_BROKEN_ADMA; in jmicron_probe_slot()
1489 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { in jmicron_probe_slot()
1490 slot->host->ocr_avail_sd = MMC_VDD_32_33 | MMC_VDD_33_34 | in jmicron_probe_slot()
1493 slot->host->ocr_avail_mmc = MMC_VDD_32_33 | MMC_VDD_33_34 | in jmicron_probe_slot()
1501 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || in jmicron_probe_slot()
1502 slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) in jmicron_probe_slot()
1503 jmicron_enable_mmc(slot->host, 1); in jmicron_probe_slot()
1505 slot->host->mmc->caps |= MMC_CAP_BUS_WIDTH_TEST; in jmicron_probe_slot()
1507 /* Handle unstable RO-detection on JM388 chips */ in jmicron_probe_slot()
1508 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD || in jmicron_probe_slot()
1509 slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) in jmicron_probe_slot()
1510 slot->host->mmc_host_ops.get_ro = jmicron_jmb388_get_ro; in jmicron_probe_slot()
1520 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || in jmicron_remove_slot()
1521 slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) in jmicron_remove_slot()
1522 jmicron_enable_mmc(slot->host, 0); in jmicron_remove_slot()
1534 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || in jmicron_suspend()
1535 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { in jmicron_suspend()
1536 for (i = 0; i < chip->num_slots; i++) in jmicron_suspend()
1537 jmicron_enable_mmc(chip->slots[i]->host, 0); in jmicron_suspend()
1547 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || in jmicron_resume()
1548 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { in jmicron_resume()
1549 for (i = 0; i < chip->num_slots; i++) in jmicron_resume()
1550 jmicron_enable_mmc(chip->slots[i]->host, 1); in jmicron_resume()
1555 dev_err(&chip->pdev->dev, "Failure enabling card power\n"); in jmicron_resume()
1596 if ((chip->pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) { in syskt_probe()
1597 chip->pdev->class &= ~0x0000FF; in syskt_probe()
1598 chip->pdev->class |= PCI_SDHCI_IFDMA; in syskt_probe()
1607 u8 board_rev = readb(slot->host->ioaddr + SYSKT_BOARD_REV); in syskt_probe_slot()
1608 u8 chip_rev = readb(slot->host->ioaddr + SYSKT_CHIP_REV); in syskt_probe_slot()
1609 dev_info(&slot->chip->pdev->dev, "SysKonnect CardBus2SDIO, " in syskt_probe_slot()
1614 slot->host->quirks |= SDHCI_QUIRK_FORCE_DMA; in syskt_probe_slot()
1616 writeb(SYSKT_POWER_330, slot->host->ioaddr + SYSKT_POWER_DATA); in syskt_probe_slot()
1617 writeb(SYSKT_POWER_START, slot->host->ioaddr + SYSKT_POWER_CMD); in syskt_probe_slot()
1621 ps = readw(slot->host->ioaddr + SYSKT_POWER_STATUS); in syskt_probe_slot()
1625 } while (--tm); in syskt_probe_slot()
1627 dev_err(&slot->chip->pdev->dev, in syskt_probe_slot()
1629 writeb(0, slot->host->ioaddr + SYSKT_POWER_CMD); in syskt_probe_slot()
1630 return -ENODEV; in syskt_probe_slot()
1644 if (chip->pdev->revision == 0x10) in via_probe()
1645 chip->quirks |= SDHCI_QUIRK_DELAY_AFTER_POWER; in via_probe()
1656 slot->host->mmc->caps2 |= MMC_CAP2_HS200; in rtsx_probe_slot()
1719 struct pci_dev *pdev = slot->chip->pdev; in amd_execute_tuning_hs200()
1730 if (mmc_send_tuning(host->mmc, opcode, NULL)) { in amd_execute_tuning_hs200()
1742 dev_err(&pdev->dev, "no tuning point found\n"); in amd_execute_tuning_hs200()
1743 return -EIO; in amd_execute_tuning_hs200()
1746 amd_config_tuning_phase(pdev, valid_win_end - valid_win_max / 2); in amd_execute_tuning_hs200()
1750 host->mmc->retune_period = 0; in amd_execute_tuning_hs200()
1760 if (host->timing == MMC_TIMING_MMC_HS200) in amd_execute_tuning()
1763 /* Otherwise perform standard SDHCI tuning */ in amd_execute_tuning()
1769 struct mmc_host_ops *ops = &slot->host->mmc_host_ops; in amd_probe_slot()
1771 ops->execute_tuning = amd_execute_tuning; in amd_probe_slot()
1789 if (smbus_dev->revision < 0x51) in amd_probe()
1801 chip->quirks2 |= SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD; in amd_probe()
1811 static void amd_sdhci_reset(struct sdhci_host *host, u8 mask) in amd_sdhci_reset() argument
1814 struct pci_dev *pdev = slot->chip->pdev; in amd_sdhci_reset()
1822 if (pdev->device == 0x7906 && (mask & SDHCI_RESET_ALL)) { in amd_sdhci_reset()
1828 pr_debug("%s: power_state=%u\n", mmc_hostname(host->mmc), in amd_sdhci_reset()
1829 pdev->current_state); in amd_sdhci_reset()
1851 return sdhci_reset(host, mask); in amd_sdhci_reset()
1972 * SDHCI core callbacks *
1982 pdev = slot->chip->pdev; in sdhci_pci_enable_dma()
1984 if (((pdev->class & 0xFFFF00) == (PCI_CLASS_SYSTEM_SDHCI << 8)) && in sdhci_pci_enable_dma()
1985 ((pdev->class & 0x0000FF) != PCI_SDHCI_IFDMA) && in sdhci_pci_enable_dma()
1986 (host->flags & SDHCI_USE_SDMA)) { in sdhci_pci_enable_dma()
1987 dev_warn(&pdev->dev, "Will use DMA mode even though HW " in sdhci_pci_enable_dma()
2000 if (slot->hw_reset) in sdhci_pci_hw_reset()
2001 slot->hw_reset(host); in sdhci_pci_hw_reset()
2027 if (chip->fixes && chip->fixes->suspend) in sdhci_pci_suspend()
2028 return chip->fixes->suspend(chip); in sdhci_pci_suspend()
2040 if (chip->fixes && chip->fixes->resume) in sdhci_pci_resume()
2041 return chip->fixes->resume(chip); in sdhci_pci_resume()
2055 if (chip->fixes && chip->fixes->runtime_suspend) in sdhci_pci_runtime_suspend()
2056 return chip->fixes->runtime_suspend(chip); in sdhci_pci_runtime_suspend()
2068 if (chip->fixes && chip->fixes->runtime_resume) in sdhci_pci_runtime_resume()
2069 return chip->fixes->runtime_resume(chip); in sdhci_pci_runtime_resume()
2094 if (chip->fixes && chip->fixes->cd_gpio_override) in sdhci_pci_add_gpio_lookup_table()
2095 dmi_id = dmi_first_match(chip->fixes->cd_gpio_override); in sdhci_pci_add_gpio_lookup_table()
2100 cd_gpio_lookup_table = dmi_id->driver_data; in sdhci_pci_add_gpio_lookup_table()
2101 for (count = 0; cd_gpio_lookup_table->table[count].key; count++) in sdhci_pci_add_gpio_lookup_table()
2104 cd_gpio_lookup_table = kmemdup(dmi_id->driver_data, in sdhci_pci_add_gpio_lookup_table()
2109 return ERR_PTR(-ENOMEM); in sdhci_pci_add_gpio_lookup_table()
2130 size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0; in sdhci_pci_probe_slot()
2133 dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar); in sdhci_pci_probe_slot()
2134 return ERR_PTR(-ENODEV); in sdhci_pci_probe_slot()
2138 dev_err(&pdev->dev, "Invalid iomem size. You may " in sdhci_pci_probe_slot()
2142 if ((pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) { in sdhci_pci_probe_slot()
2143 dev_err(&pdev->dev, "Vendor specific interface. Aborting.\n"); in sdhci_pci_probe_slot()
2144 return ERR_PTR(-ENODEV); in sdhci_pci_probe_slot()
2147 if ((pdev->class & 0x0000FF) > PCI_SDHCI_IFVENDOR) { in sdhci_pci_probe_slot()
2148 dev_err(&pdev->dev, "Unknown interface. Aborting.\n"); in sdhci_pci_probe_slot()
2149 return ERR_PTR(-ENODEV); in sdhci_pci_probe_slot()
2152 host = sdhci_alloc_host(&pdev->dev, sizeof(*slot) + priv_size); in sdhci_pci_probe_slot()
2154 dev_err(&pdev->dev, "cannot allocate host\n"); in sdhci_pci_probe_slot()
2160 slot->chip = chip; in sdhci_pci_probe_slot()
2161 slot->host = host; in sdhci_pci_probe_slot()
2162 slot->cd_idx = -1; in sdhci_pci_probe_slot()
2164 host->hw_name = "PCI"; in sdhci_pci_probe_slot()
2165 host->ops = chip->fixes && chip->fixes->ops ? in sdhci_pci_probe_slot()
2166 chip->fixes->ops : in sdhci_pci_probe_slot()
2168 host->quirks = chip->quirks; in sdhci_pci_probe_slot()
2169 host->quirks2 = chip->quirks2; in sdhci_pci_probe_slot()
2171 host->irq = pdev->irq; in sdhci_pci_probe_slot()
2173 ret = pcim_iomap_regions(pdev, BIT(bar), mmc_hostname(host->mmc)); in sdhci_pci_probe_slot()
2175 dev_err(&pdev->dev, "cannot request region\n"); in sdhci_pci_probe_slot()
2179 host->ioaddr = pcim_iomap_table(pdev)[bar]; in sdhci_pci_probe_slot()
2181 if (chip->fixes && chip->fixes->probe_slot) { in sdhci_pci_probe_slot()
2182 ret = chip->fixes->probe_slot(slot); in sdhci_pci_probe_slot()
2187 host->mmc->pm_caps = MMC_PM_KEEP_POWER; in sdhci_pci_probe_slot()
2188 host->mmc->slotno = slotno; in sdhci_pci_probe_slot()
2189 host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP; in sdhci_pci_probe_slot()
2191 if (device_can_wakeup(&pdev->dev)) in sdhci_pci_probe_slot()
2192 host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; in sdhci_pci_probe_slot()
2194 if (host->mmc->caps & MMC_CAP_CD_WAKE) in sdhci_pci_probe_slot()
2195 device_init_wakeup(&pdev->dev, true); in sdhci_pci_probe_slot()
2197 if (slot->cd_idx >= 0) { in sdhci_pci_probe_slot()
2206 ret = mmc_gpiod_request_cd(host->mmc, "cd", slot->cd_idx, in sdhci_pci_probe_slot()
2207 slot->cd_override_level, 0); in sdhci_pci_probe_slot()
2211 if (ret && ret != -EPROBE_DEFER) in sdhci_pci_probe_slot()
2212 ret = mmc_gpiod_request_cd(host->mmc, NULL, in sdhci_pci_probe_slot()
2213 slot->cd_idx, in sdhci_pci_probe_slot()
2214 slot->cd_override_level, in sdhci_pci_probe_slot()
2216 if (ret == -EPROBE_DEFER) in sdhci_pci_probe_slot()
2220 dev_warn(&pdev->dev, "failed to setup card detect gpio\n"); in sdhci_pci_probe_slot()
2221 slot->cd_idx = -1; in sdhci_pci_probe_slot()
2225 if (chip->fixes && chip->fixes->add_host) in sdhci_pci_probe_slot()
2226 ret = chip->fixes->add_host(slot); in sdhci_pci_probe_slot()
2236 if (chip->fixes && chip->fixes->own_cd_for_runtime_pm && slot->cd_idx < 0) in sdhci_pci_probe_slot()
2237 chip->allow_runtime_pm = false; in sdhci_pci_probe_slot()
2242 if (chip->fixes && chip->fixes->remove_slot) in sdhci_pci_probe_slot()
2243 chip->fixes->remove_slot(slot, 0); in sdhci_pci_probe_slot()
2257 scratch = readl(slot->host->ioaddr + SDHCI_INT_STATUS); in sdhci_pci_remove_slot()
2258 if (scratch == (u32)-1) in sdhci_pci_remove_slot()
2261 if (slot->chip->fixes && slot->chip->fixes->remove_host) in sdhci_pci_remove_slot()
2262 slot->chip->fixes->remove_host(slot, dead); in sdhci_pci_remove_slot()
2264 sdhci_remove_host(slot->host, dead); in sdhci_pci_remove_slot()
2266 if (slot->chip->fixes && slot->chip->fixes->remove_slot) in sdhci_pci_remove_slot()
2267 slot->chip->fixes->remove_slot(slot, dead); in sdhci_pci_remove_slot()
2269 sdhci_free_host(slot->host); in sdhci_pci_remove_slot()
2274 return sdhci_uhs2_add_host(slot->host); in sdhci_pci_uhs2_add_host()
2279 sdhci_uhs2_remove_host(slot->host, dead); in sdhci_pci_uhs2_remove_host()
2310 dev_info(&pdev->dev, "SDHCI controller found [%04x:%04x] (rev %x)\n", in sdhci_pci_probe()
2311 (int)pdev->vendor, (int)pdev->device, (int)pdev->revision); in sdhci_pci_probe()
2318 dev_dbg(&pdev->dev, "found %d slot(s)\n", slots); in sdhci_pci_probe()
2329 dev_err(&pdev->dev, "Invalid first BAR. Aborting.\n"); in sdhci_pci_probe()
2330 return -ENODEV; in sdhci_pci_probe()
2337 chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); in sdhci_pci_probe()
2339 return -ENOMEM; in sdhci_pci_probe()
2341 chip->pdev = pdev; in sdhci_pci_probe()
2342 chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data; in sdhci_pci_probe()
2343 if (chip->fixes) { in sdhci_pci_probe()
2344 chip->quirks = chip->fixes->quirks; in sdhci_pci_probe()
2345 chip->quirks2 = chip->fixes->quirks2; in sdhci_pci_probe()
2346 chip->allow_runtime_pm = chip->fixes->allow_runtime_pm; in sdhci_pci_probe()
2348 chip->num_slots = slots; in sdhci_pci_probe()
2349 chip->pm_retune = true; in sdhci_pci_probe()
2350 chip->rpm_retune = true; in sdhci_pci_probe()
2354 if (chip->fixes && chip->fixes->probe) { in sdhci_pci_probe()
2355 ret = chip->fixes->probe(chip); in sdhci_pci_probe()
2360 slots = chip->num_slots; /* Quirk may have changed this */ in sdhci_pci_probe()
2365 for (i--; i >= 0; i--) in sdhci_pci_probe()
2366 sdhci_pci_remove_slot(chip->slots[i]); in sdhci_pci_probe()
2370 chip->slots[i] = slot; in sdhci_pci_probe()
2373 if (chip->allow_runtime_pm) in sdhci_pci_probe()
2374 sdhci_pci_runtime_pm_allow(&pdev->dev); in sdhci_pci_probe()
2384 if (chip->allow_runtime_pm) in sdhci_pci_remove()
2385 sdhci_pci_runtime_pm_forbid(&pdev->dev); in sdhci_pci_remove()
2387 for (i = 0; i < chip->num_slots; i++) in sdhci_pci_remove()
2388 sdhci_pci_remove_slot(chip->slots[i]); in sdhci_pci_remove()
2392 .name = "sdhci-pci",