Lines Matching +full:sdhci +full:- +full:caps
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"
54 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_init_wakeup()
55 struct sdhci_pci_slot *slot = chip->slots[i]; in sdhci_pci_init_wakeup()
58 pm_flags |= slot->host->mmc->pm_flags; in sdhci_pci_init_wakeup()
59 if (slot->host->mmc->caps & MMC_CAP_CD_WAKE) in sdhci_pci_init_wakeup()
65 return device_wakeup_enable(&chip->pdev->dev); in sdhci_pci_init_wakeup()
67 return device_wakeup_disable(&chip->pdev->dev); in sdhci_pci_init_wakeup()
78 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_suspend_host()
79 struct sdhci_pci_slot *slot = chip->slots[i]; in sdhci_pci_suspend_host()
85 host = slot->host; in sdhci_pci_suspend_host()
87 if (chip->pm_retune && host->tuning_mode != SDHCI_TUNING_MODE_3) in sdhci_pci_suspend_host()
88 mmc_retune_needed(host->mmc); in sdhci_pci_suspend_host()
94 if (device_may_wakeup(&chip->pdev->dev)) in sdhci_pci_suspend_host()
95 mmc_gpio_set_cd_wake(host->mmc, true); in sdhci_pci_suspend_host()
101 while (--i >= 0) in sdhci_pci_suspend_host()
102 sdhci_resume_host(chip->slots[i]->host); in sdhci_pci_suspend_host()
111 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_resume_host()
112 slot = chip->slots[i]; in sdhci_pci_resume_host()
116 ret = sdhci_resume_host(slot->host); in sdhci_pci_resume_host()
120 mmc_gpio_set_cd_wake(slot->host->mmc, false); in sdhci_pci_resume_host()
130 ret = cqhci_suspend(chip->slots[0]->host->mmc); in sdhci_cqhci_suspend()
145 return cqhci_resume(chip->slots[0]->host->mmc); in sdhci_cqhci_resume()
156 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_runtime_suspend_host()
157 slot = chip->slots[i]; in sdhci_pci_runtime_suspend_host()
161 host = slot->host; in sdhci_pci_runtime_suspend_host()
167 if (chip->rpm_retune && in sdhci_pci_runtime_suspend_host()
168 host->tuning_mode != SDHCI_TUNING_MODE_3) in sdhci_pci_runtime_suspend_host()
169 mmc_retune_needed(host->mmc); in sdhci_pci_runtime_suspend_host()
175 while (--i >= 0) in sdhci_pci_runtime_suspend_host()
176 sdhci_runtime_resume_host(chip->slots[i]->host, 0); in sdhci_pci_runtime_suspend_host()
185 for (i = 0; i < chip->num_slots; i++) { in sdhci_pci_runtime_resume_host()
186 slot = chip->slots[i]; in sdhci_pci_runtime_resume_host()
190 ret = sdhci_runtime_resume_host(slot->host, 0); in sdhci_pci_runtime_resume_host()
202 ret = cqhci_suspend(chip->slots[0]->host->mmc); in sdhci_cqhci_runtime_suspend()
217 return cqhci_resume(chip->slots[0]->host->mmc); in sdhci_cqhci_runtime_resume()
229 cqhci_irq(host->mmc, intmask, cmd_error, data_error); in sdhci_cqhci_irq()
247 if (chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG || in ricoh_probe()
248 chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SONY) in ricoh_probe()
249 chip->quirks |= SDHCI_QUIRK_NO_CARD_NO_RESET; in ricoh_probe()
255 u32 caps = in ricoh_mmc_probe_slot() local
264 __sdhci_read_caps(slot->host, NULL, &caps, &caps1); in ricoh_mmc_probe_slot()
307 if (!(host->flags & SDHCI_DEVICE_DEAD)) in ene_714_set_ios()
313 slot->host->mmc_host_ops.set_ios = ene_714_set_ios; in ene_714_probe_slot()
341 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; in mrst_hc_probe_slot()
355 chip->num_slots = 1; in mrst_hc_probe()
361 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; in pch_hc_probe_slot()
367 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE; in mfd_emmc_probe_slot()
368 slot->host->mmc->caps2 |= MMC_CAP2_BOOTPART_NOACC; in mfd_emmc_probe_slot()
374 slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE; in mfd_sdio_probe_slot()
422 if (pdev->device != PCI_DEVICE_ID_INTEL_BYT_EMMC && in byt_ocp_setting()
423 pdev->device != PCI_DEVICE_ID_INTEL_BYT_SDIO && in byt_ocp_setting()
424 pdev->device != PCI_DEVICE_ID_INTEL_BYT_SD && in byt_ocp_setting()
425 pdev->device != PCI_DEVICE_ID_INTEL_BYT_EMMC2) in byt_ocp_setting()
430 dev_err(&pdev->dev, "%s read error\n", __func__); in byt_ocp_setting()
441 dev_err(&pdev->dev, "%s write error\n", __func__); in byt_ocp_setting()
445 dev_dbg(&pdev->dev, "%s completed\n", __func__); in byt_ocp_setting()
489 return -EOPNOTSUPP; in __intel_dsm()
491 if (obj->type != ACPI_TYPE_BUFFER || obj->buffer.length < 1) { in __intel_dsm()
492 err = -EINVAL; in __intel_dsm()
496 len = min_t(size_t, obj->buffer.length, 4); in __intel_dsm()
499 memcpy(result, obj->buffer.pointer, len); in __intel_dsm()
509 if (fn > 31 || !(intel_host->dsm_fns & (1 << fn))) in intel_dsm()
510 return -EOPNOTSUPP; in intel_dsm()
521 intel_host->d3_retune = true; in intel_dsm_init()
523 err = __intel_dsm(intel_host, dev, INTEL_DSM_FNS, &intel_host->dsm_fns); in intel_dsm_init()
531 mmc_hostname(mmc), intel_host->dsm_fns); in intel_dsm_init()
534 intel_host->drv_strength = err ? 0 : val; in intel_dsm_init()
537 intel_host->d3_retune = err ? true : !!val; in intel_dsm_init()
559 struct sdhci_host *host = mmc_priv(card->host); in intel_select_drive_strength()
563 if (!(mmc_driver_type_mask(intel_host->drv_strength) & card_drv)) in intel_select_drive_strength()
566 return intel_host->drv_strength; in intel_select_drive_strength()
601 if (intel_host->needs_pwr_off) { in sdhci_intel_set_power()
602 intel_host->needs_pwr_off = false; in sdhci_intel_set_power()
615 * Bus power might not enable after D3 -> D0 transition due to the in sdhci_intel_set_power()
647 if (ios->enhanced_strobe) in intel_hs400_enhanced_strobe()
669 switch (ios->signal_voltage) { in intel_start_signal_voltage_switch()
711 struct device *dev = &slot->chip->pdev->dev; in byt_read_dsm()
712 struct mmc_host *mmc = slot->host->mmc; in byt_read_dsm()
715 slot->chip->rpm_retune = intel_host->d3_retune; in byt_read_dsm()
748 struct sdhci_host *host = slot->host; in intel_cache_ltr()
750 intel_host->active_ltr = readl(host->ioaddr + INTEL_ACTIVELTR); in intel_cache_ltr()
751 intel_host->idle_ltr = readl(host->ioaddr + INTEL_IDLELTR); in intel_cache_ltr()
757 struct sdhci_pci_slot *slot = chip->slots[0]; in intel_ltr_set()
759 struct sdhci_host *host = slot->host; in intel_ltr_set()
769 ltr = readl(host->ioaddr + INTEL_ACTIVELTR); in intel_ltr_set()
788 if (ltr == intel_host->active_ltr) in intel_ltr_set()
791 writel(ltr, host->ioaddr + INTEL_ACTIVELTR); in intel_ltr_set()
792 writel(ltr, host->ioaddr + INTEL_IDLELTR); in intel_ltr_set()
802 switch (chip->pdev->device) { in intel_use_ltr()
818 struct device *dev = &chip->pdev->dev; in intel_ltr_expose()
823 dev->power.set_latency_tolerance = intel_ltr_set; in intel_ltr_expose()
829 struct device *dev = &chip->pdev->dev; in intel_ltr_hide()
835 dev->power.set_latency_tolerance = NULL; in intel_ltr_hide()
840 struct mmc_host_ops *ops = &slot->host->mmc_host_ops; in byt_probe_slot()
841 struct device *dev = &slot->chip->pdev->dev; in byt_probe_slot()
842 struct mmc_host *mmc = slot->host->mmc; in byt_probe_slot()
846 byt_ocp_setting(slot->chip->pdev); in byt_probe_slot()
848 ops->execute_tuning = intel_execute_tuning; in byt_probe_slot()
849 ops->start_signal_voltage_switch = intel_start_signal_voltage_switch; in byt_probe_slot()
851 device_property_read_u32(dev, "max-frequency", &mmc->f_max); in byt_probe_slot()
853 if (!mmc->slotno) { in byt_probe_slot()
854 slot->chip->slots[mmc->slotno] = slot; in byt_probe_slot()
855 intel_ltr_expose(slot->chip); in byt_probe_slot()
862 struct mmc_host *mmc = slot->host->mmc; in byt_add_debugfs()
863 struct dentry *dir = mmc->debugfs_root; in byt_add_debugfs()
865 if (!intel_use_ltr(slot->chip)) in byt_add_debugfs()
868 debugfs_create_x32("active_ltr", 0444, dir, &intel_host->active_ltr); in byt_add_debugfs()
869 debugfs_create_x32("idle_ltr", 0444, dir, &intel_host->idle_ltr); in byt_add_debugfs()
876 int ret = sdhci_add_host(slot->host); in byt_add_host()
885 struct mmc_host *mmc = slot->host->mmc; in byt_remove_slot()
887 if (!mmc->slotno) in byt_remove_slot()
888 intel_ltr_hide(slot->chip); in byt_remove_slot()
894 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | in byt_emmc_probe_slot()
898 slot->hw_reset = sdhci_pci_int_hw_reset; in byt_emmc_probe_slot()
899 if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BSW_EMMC) in byt_emmc_probe_slot()
900 slot->host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */ in byt_emmc_probe_slot()
901 slot->host->mmc_host_ops.select_drive_strength = in byt_emmc_probe_slot()
908 return slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_GLK_EMMC && in glk_broken_cqhci()
915 return slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_JSL_EMMC && in jsl_broken_hs400es()
924 slot->host->mmc->caps2 |= MMC_CAP2_CQE; in glk_emmc_probe_slot()
926 if (slot->chip->pdev->device != PCI_DEVICE_ID_INTEL_GLK_EMMC) { in glk_emmc_probe_slot()
928 slot->host->mmc->caps2 |= MMC_CAP2_HS400_ES; in glk_emmc_probe_slot()
929 slot->host->mmc_host_ops.hs400_enhanced_strobe = in glk_emmc_probe_slot()
932 slot->host->mmc->caps2 |= MMC_CAP2_CQE_DCMD; in glk_emmc_probe_slot()
946 struct device *dev = &slot->chip->pdev->dev; in glk_emmc_add_host()
947 struct sdhci_host *host = slot->host; in glk_emmc_add_host()
958 ret = -ENOMEM; in glk_emmc_add_host()
962 cq_host->mmio = host->ioaddr + 0x200; in glk_emmc_add_host()
963 cq_host->quirks |= CQHCI_QUIRK_SHORT_TXFR_DESC_SZ; in glk_emmc_add_host()
964 cq_host->ops = &glk_cqhci_ops; in glk_emmc_add_host()
966 dma64 = host->flags & SDHCI_USE_64_BIT_DMA; in glk_emmc_add_host()
968 cq_host->caps |= CQHCI_TASK_DESC_SZ_128; in glk_emmc_add_host()
970 ret = cqhci_init(cq_host, host->mmc, dma64); in glk_emmc_add_host()
995 struct sdhci_pci_slot *slot = chip->slots[0]; in glk_rpm_retune_wa()
997 struct sdhci_host *host = slot->host; in glk_rpm_retune_wa()
1002 if (intel_host->rpm_retune_ok || !mmc_can_retune(host->mmc)) in glk_rpm_retune_wa()
1009 intel_host->glk_rx_ctrl1 = glk_rx_ctrl1; in glk_rpm_retune_wa()
1010 intel_host->glk_tun_val = glk_tun_val; in glk_rpm_retune_wa()
1014 if (!intel_host->glk_tun_val) in glk_rpm_retune_wa()
1017 if (glk_rx_ctrl1 != intel_host->glk_rx_ctrl1) { in glk_rpm_retune_wa()
1018 intel_host->rpm_retune_ok = true; in glk_rpm_retune_wa()
1023 (intel_host->glk_tun_val << 1)); in glk_rpm_retune_wa()
1030 intel_host->rpm_retune_ok = true; in glk_rpm_retune_wa()
1031 chip->rpm_retune = true; in glk_rpm_retune_wa()
1032 mmc_retune_needed(host->mmc); in glk_rpm_retune_wa()
1033 pr_info("%s: Requiring re-tune after rpm resume", mmc_hostname(host->mmc)); in glk_rpm_retune_wa()
1038 if (chip->pdev->device == PCI_DEVICE_ID_INTEL_GLK_EMMC && in glk_rpm_retune_chk()
1039 !chip->rpm_retune) in glk_rpm_retune_chk()
1064 status = acpi_evaluate_integer(ACPI_HANDLE(&slot->chip->pdev->dev), in ni_set_max_freq()
1067 dev_err(&slot->chip->pdev->dev, in ni_set_max_freq()
1069 return -EINVAL; in ni_set_max_freq()
1072 slot->host->mmc->f_max = max_freq * 1000000; in ni_set_max_freq()
1093 slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE | in ni_byt_sdio_probe_slot()
1101 slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE | in byt_sdio_probe_slot()
1109 u8 reg = sdhci_readb(slot->host, SDHCI_POWER_CONTROL); in byt_needs_pwr_off()
1111 intel_host->needs_pwr_off = reg & SDHCI_POWER_ON; in byt_needs_pwr_off()
1117 slot->host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY | in byt_sd_probe_slot()
1119 slot->cd_idx = 0; in byt_sd_probe_slot()
1120 slot->cd_override_level = true; in byt_sd_probe_slot()
1121 if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXT_SD || in byt_sd_probe_slot()
1122 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXTM_SD || in byt_sd_probe_slot()
1123 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD || in byt_sd_probe_slot()
1124 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_GLK_SD) in byt_sd_probe_slot()
1125 slot->host->mmc_host_ops.get_cd = bxt_get_cd; in byt_sd_probe_slot()
1127 if (slot->chip->pdev->subsystem_vendor == PCI_VENDOR_ID_NI && in byt_sd_probe_slot()
1128 slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3) in byt_sd_probe_slot()
1129 slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V; in byt_sd_probe_slot()
1140 byt_ocp_setting(chip->pdev); in byt_resume()
1151 byt_ocp_setting(chip->pdev); in byt_runtime_resume()
1294 device = ACPI_COMPANION(&slot->chip->pdev->dev); in intel_mrfld_mmc_fix_up_power_slot()
1304 unsigned int func = PCI_FUNC(slot->chip->pdev->devfn); in intel_mrfld_mmc_probe_slot()
1309 slot->host->mmc->caps |= MMC_CAP_NONREMOVABLE | in intel_mrfld_mmc_probe_slot()
1314 slot->cd_idx = 0; in intel_mrfld_mmc_probe_slot()
1315 slot->cd_override_level = true; in intel_mrfld_mmc_probe_slot()
1319 * completely in the custom ->get_cd() callback. in intel_mrfld_mmc_probe_slot()
1321 slot->host->mmc_host_ops.get_cd = mrfld_get_cd; in intel_mrfld_mmc_probe_slot()
1322 slot->host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; in intel_mrfld_mmc_probe_slot()
1326 slot->host->ocr_mask = MMC_VDD_20_21 | MMC_VDD_165_195; in intel_mrfld_mmc_probe_slot()
1327 slot->host->mmc->caps |= MMC_CAP_NONREMOVABLE | in intel_mrfld_mmc_probe_slot()
1331 return -ENODEV; in intel_mrfld_mmc_probe_slot()
1351 ret = pci_read_config_byte(chip->pdev, 0xAE, &scratch); in jmicron_pmos()
1364 ret = pci_write_config_byte(chip->pdev, 0xAE, scratch); in jmicron_pmos()
1375 if (chip->pdev->revision == 0) { in jmicron_probe()
1376 chip->quirks |= SDHCI_QUIRK_32BIT_DMA_ADDR | in jmicron_probe()
1395 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_SD) in jmicron_probe()
1397 else if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD) in jmicron_probe()
1406 if ((PCI_SLOT(chip->pdev->devfn) == in jmicron_probe()
1407 PCI_SLOT(sd_dev->devfn)) && in jmicron_probe()
1408 (chip->pdev->bus == sd_dev->bus)) in jmicron_probe()
1414 dev_info(&chip->pdev->dev, "Refusing to bind to " in jmicron_probe()
1416 return -ENODEV; in jmicron_probe()
1426 dev_err(&chip->pdev->dev, "Failure enabling card power\n"); in jmicron_probe()
1430 /* quirk for unsable RO-detection on JM388 chips */ in jmicron_probe()
1431 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_SD || in jmicron_probe()
1432 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) in jmicron_probe()
1433 chip->quirks |= SDHCI_QUIRK_UNSTABLE_RO_DETECT; in jmicron_probe()
1442 scratch = readb(host->ioaddr + 0xC0); in jmicron_enable_mmc()
1449 writeb(scratch, host->ioaddr + 0xC0); in jmicron_enable_mmc()
1454 if (slot->chip->pdev->revision == 0) { in jmicron_probe_slot()
1457 version = readl(slot->host->ioaddr + SDHCI_HOST_VERSION); in jmicron_probe_slot()
1467 slot->host->quirks |= SDHCI_QUIRK_BROKEN_ADMA; in jmicron_probe_slot()
1471 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { in jmicron_probe_slot()
1472 slot->host->ocr_avail_sd = MMC_VDD_32_33 | MMC_VDD_33_34 | in jmicron_probe_slot()
1475 slot->host->ocr_avail_mmc = MMC_VDD_32_33 | MMC_VDD_33_34 | in jmicron_probe_slot()
1483 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || in jmicron_probe_slot()
1484 slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) in jmicron_probe_slot()
1485 jmicron_enable_mmc(slot->host, 1); in jmicron_probe_slot()
1487 slot->host->mmc->caps |= MMC_CAP_BUS_WIDTH_TEST; in jmicron_probe_slot()
1497 if (slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || in jmicron_remove_slot()
1498 slot->chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) in jmicron_remove_slot()
1499 jmicron_enable_mmc(slot->host, 0); in jmicron_remove_slot()
1511 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || in jmicron_suspend()
1512 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { in jmicron_suspend()
1513 for (i = 0; i < chip->num_slots; i++) in jmicron_suspend()
1514 jmicron_enable_mmc(chip->slots[i]->host, 0); in jmicron_suspend()
1524 if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC || in jmicron_resume()
1525 chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) { in jmicron_resume()
1526 for (i = 0; i < chip->num_slots; i++) in jmicron_resume()
1527 jmicron_enable_mmc(chip->slots[i]->host, 1); in jmicron_resume()
1532 dev_err(&chip->pdev->dev, "Failure enabling card power\n"); in jmicron_resume()
1573 if ((chip->pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) { in syskt_probe()
1574 chip->pdev->class &= ~0x0000FF; in syskt_probe()
1575 chip->pdev->class |= PCI_SDHCI_IFDMA; in syskt_probe()
1584 u8 board_rev = readb(slot->host->ioaddr + SYSKT_BOARD_REV); in syskt_probe_slot()
1585 u8 chip_rev = readb(slot->host->ioaddr + SYSKT_CHIP_REV); in syskt_probe_slot()
1586 dev_info(&slot->chip->pdev->dev, "SysKonnect CardBus2SDIO, " in syskt_probe_slot()
1591 slot->host->quirks |= SDHCI_QUIRK_FORCE_DMA; in syskt_probe_slot()
1593 writeb(SYSKT_POWER_330, slot->host->ioaddr + SYSKT_POWER_DATA); in syskt_probe_slot()
1594 writeb(SYSKT_POWER_START, slot->host->ioaddr + SYSKT_POWER_CMD); in syskt_probe_slot()
1598 ps = readw(slot->host->ioaddr + SYSKT_POWER_STATUS); in syskt_probe_slot()
1602 } while (--tm); in syskt_probe_slot()
1604 dev_err(&slot->chip->pdev->dev, in syskt_probe_slot()
1606 writeb(0, slot->host->ioaddr + SYSKT_POWER_CMD); in syskt_probe_slot()
1607 return -ENODEV; in syskt_probe_slot()
1621 if (chip->pdev->revision == 0x10) in via_probe()
1622 chip->quirks |= SDHCI_QUIRK_DELAY_AFTER_POWER; in via_probe()
1633 slot->host->mmc->caps2 |= MMC_CAP2_HS200; in rtsx_probe_slot()
1696 struct pci_dev *pdev = slot->chip->pdev; in amd_execute_tuning_hs200()
1707 if (mmc_send_tuning(host->mmc, opcode, NULL)) { in amd_execute_tuning_hs200()
1719 dev_err(&pdev->dev, "no tuning point found\n"); in amd_execute_tuning_hs200()
1720 return -EIO; in amd_execute_tuning_hs200()
1723 amd_config_tuning_phase(pdev, valid_win_end - valid_win_max / 2); in amd_execute_tuning_hs200()
1727 host->mmc->retune_period = 0; in amd_execute_tuning_hs200()
1737 if (host->timing == MMC_TIMING_MMC_HS200) in amd_execute_tuning()
1740 /* Otherwise perform standard SDHCI tuning */ in amd_execute_tuning()
1746 struct mmc_host_ops *ops = &slot->host->mmc_host_ops; in amd_probe_slot()
1748 ops->execute_tuning = amd_execute_tuning; in amd_probe_slot()
1766 if (smbus_dev->revision < 0x51) in amd_probe()
1778 chip->quirks2 |= SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD; in amd_probe()
1791 struct pci_dev *pdev = slot->chip->pdev; in amd_sdhci_reset()
1799 if (pdev->device == 0x7906 && (mask & SDHCI_RESET_ALL)) { in amd_sdhci_reset()
1805 pr_debug("%s: power_state=%u\n", mmc_hostname(host->mmc), in amd_sdhci_reset()
1806 pdev->current_state); in amd_sdhci_reset()
1949 * SDHCI core callbacks *
1959 pdev = slot->chip->pdev; in sdhci_pci_enable_dma()
1961 if (((pdev->class & 0xFFFF00) == (PCI_CLASS_SYSTEM_SDHCI << 8)) && in sdhci_pci_enable_dma()
1962 ((pdev->class & 0x0000FF) != PCI_SDHCI_IFDMA) && in sdhci_pci_enable_dma()
1963 (host->flags & SDHCI_USE_SDMA)) { in sdhci_pci_enable_dma()
1964 dev_warn(&pdev->dev, "Will use DMA mode even though HW " in sdhci_pci_enable_dma()
1977 if (slot->hw_reset) in sdhci_pci_hw_reset()
1978 slot->hw_reset(host); in sdhci_pci_hw_reset()
2004 if (chip->fixes && chip->fixes->suspend) in sdhci_pci_suspend()
2005 return chip->fixes->suspend(chip); in sdhci_pci_suspend()
2017 if (chip->fixes && chip->fixes->resume) in sdhci_pci_resume()
2018 return chip->fixes->resume(chip); in sdhci_pci_resume()
2032 if (chip->fixes && chip->fixes->runtime_suspend) in sdhci_pci_runtime_suspend()
2033 return chip->fixes->runtime_suspend(chip); in sdhci_pci_runtime_suspend()
2045 if (chip->fixes && chip->fixes->runtime_resume) in sdhci_pci_runtime_resume()
2046 return chip->fixes->runtime_resume(chip); in sdhci_pci_runtime_resume()
2071 if (chip->fixes && chip->fixes->cd_gpio_override) in sdhci_pci_add_gpio_lookup_table()
2072 dmi_id = dmi_first_match(chip->fixes->cd_gpio_override); in sdhci_pci_add_gpio_lookup_table()
2077 cd_gpio_lookup_table = dmi_id->driver_data; in sdhci_pci_add_gpio_lookup_table()
2078 for (count = 0; cd_gpio_lookup_table->table[count].key; count++) in sdhci_pci_add_gpio_lookup_table()
2081 cd_gpio_lookup_table = kmemdup(dmi_id->driver_data, in sdhci_pci_add_gpio_lookup_table()
2086 return ERR_PTR(-ENOMEM); in sdhci_pci_add_gpio_lookup_table()
2107 size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0; in sdhci_pci_probe_slot()
2110 dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar); in sdhci_pci_probe_slot()
2111 return ERR_PTR(-ENODEV); in sdhci_pci_probe_slot()
2115 dev_err(&pdev->dev, "Invalid iomem size. You may " in sdhci_pci_probe_slot()
2119 if ((pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) { in sdhci_pci_probe_slot()
2120 dev_err(&pdev->dev, "Vendor specific interface. Aborting.\n"); in sdhci_pci_probe_slot()
2121 return ERR_PTR(-ENODEV); in sdhci_pci_probe_slot()
2124 if ((pdev->class & 0x0000FF) > PCI_SDHCI_IFVENDOR) { in sdhci_pci_probe_slot()
2125 dev_err(&pdev->dev, "Unknown interface. Aborting.\n"); in sdhci_pci_probe_slot()
2126 return ERR_PTR(-ENODEV); in sdhci_pci_probe_slot()
2129 host = sdhci_alloc_host(&pdev->dev, sizeof(*slot) + priv_size); in sdhci_pci_probe_slot()
2131 dev_err(&pdev->dev, "cannot allocate host\n"); in sdhci_pci_probe_slot()
2137 slot->chip = chip; in sdhci_pci_probe_slot()
2138 slot->host = host; in sdhci_pci_probe_slot()
2139 slot->cd_idx = -1; in sdhci_pci_probe_slot()
2141 host->hw_name = "PCI"; in sdhci_pci_probe_slot()
2142 host->ops = chip->fixes && chip->fixes->ops ? in sdhci_pci_probe_slot()
2143 chip->fixes->ops : in sdhci_pci_probe_slot()
2145 host->quirks = chip->quirks; in sdhci_pci_probe_slot()
2146 host->quirks2 = chip->quirks2; in sdhci_pci_probe_slot()
2148 host->irq = pdev->irq; in sdhci_pci_probe_slot()
2150 ret = pcim_iomap_regions(pdev, BIT(bar), mmc_hostname(host->mmc)); in sdhci_pci_probe_slot()
2152 dev_err(&pdev->dev, "cannot request region\n"); in sdhci_pci_probe_slot()
2156 host->ioaddr = pcim_iomap_table(pdev)[bar]; in sdhci_pci_probe_slot()
2158 if (chip->fixes && chip->fixes->probe_slot) { in sdhci_pci_probe_slot()
2159 ret = chip->fixes->probe_slot(slot); in sdhci_pci_probe_slot()
2164 host->mmc->pm_caps = MMC_PM_KEEP_POWER; in sdhci_pci_probe_slot()
2165 host->mmc->slotno = slotno; in sdhci_pci_probe_slot()
2166 host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP; in sdhci_pci_probe_slot()
2168 if (device_can_wakeup(&pdev->dev)) in sdhci_pci_probe_slot()
2169 host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; in sdhci_pci_probe_slot()
2171 if (host->mmc->caps & MMC_CAP_CD_WAKE) in sdhci_pci_probe_slot()
2172 device_init_wakeup(&pdev->dev, true); in sdhci_pci_probe_slot()
2174 if (slot->cd_idx >= 0) { in sdhci_pci_probe_slot()
2183 ret = mmc_gpiod_request_cd(host->mmc, "cd", slot->cd_idx, in sdhci_pci_probe_slot()
2184 slot->cd_override_level, 0); in sdhci_pci_probe_slot()
2188 if (ret && ret != -EPROBE_DEFER) in sdhci_pci_probe_slot()
2189 ret = mmc_gpiod_request_cd(host->mmc, NULL, in sdhci_pci_probe_slot()
2190 slot->cd_idx, in sdhci_pci_probe_slot()
2191 slot->cd_override_level, in sdhci_pci_probe_slot()
2193 if (ret == -EPROBE_DEFER) in sdhci_pci_probe_slot()
2197 dev_warn(&pdev->dev, "failed to setup card detect gpio\n"); in sdhci_pci_probe_slot()
2198 slot->cd_idx = -1; in sdhci_pci_probe_slot()
2202 if (chip->fixes && chip->fixes->add_host) in sdhci_pci_probe_slot()
2203 ret = chip->fixes->add_host(slot); in sdhci_pci_probe_slot()
2213 if (chip->fixes && chip->fixes->own_cd_for_runtime_pm && slot->cd_idx < 0) in sdhci_pci_probe_slot()
2214 chip->allow_runtime_pm = false; in sdhci_pci_probe_slot()
2219 if (chip->fixes && chip->fixes->remove_slot) in sdhci_pci_probe_slot()
2220 chip->fixes->remove_slot(slot, 0); in sdhci_pci_probe_slot()
2234 scratch = readl(slot->host->ioaddr + SDHCI_INT_STATUS); in sdhci_pci_remove_slot()
2235 if (scratch == (u32)-1) in sdhci_pci_remove_slot()
2238 sdhci_remove_host(slot->host, dead); in sdhci_pci_remove_slot()
2240 if (slot->chip->fixes && slot->chip->fixes->remove_slot) in sdhci_pci_remove_slot()
2241 slot->chip->fixes->remove_slot(slot, dead); in sdhci_pci_remove_slot()
2243 sdhci_free_host(slot->host); in sdhci_pci_remove_slot()
2274 dev_info(&pdev->dev, "SDHCI controller found [%04x:%04x] (rev %x)\n", in sdhci_pci_probe()
2275 (int)pdev->vendor, (int)pdev->device, (int)pdev->revision); in sdhci_pci_probe()
2282 dev_dbg(&pdev->dev, "found %d slot(s)\n", slots); in sdhci_pci_probe()
2293 dev_err(&pdev->dev, "Invalid first BAR. Aborting.\n"); in sdhci_pci_probe()
2294 return -ENODEV; in sdhci_pci_probe()
2301 chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); in sdhci_pci_probe()
2303 return -ENOMEM; in sdhci_pci_probe()
2305 chip->pdev = pdev; in sdhci_pci_probe()
2306 chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data; in sdhci_pci_probe()
2307 if (chip->fixes) { in sdhci_pci_probe()
2308 chip->quirks = chip->fixes->quirks; in sdhci_pci_probe()
2309 chip->quirks2 = chip->fixes->quirks2; in sdhci_pci_probe()
2310 chip->allow_runtime_pm = chip->fixes->allow_runtime_pm; in sdhci_pci_probe()
2312 chip->num_slots = slots; in sdhci_pci_probe()
2313 chip->pm_retune = true; in sdhci_pci_probe()
2314 chip->rpm_retune = true; in sdhci_pci_probe()
2318 if (chip->fixes && chip->fixes->probe) { in sdhci_pci_probe()
2319 ret = chip->fixes->probe(chip); in sdhci_pci_probe()
2324 slots = chip->num_slots; /* Quirk may have changed this */ in sdhci_pci_probe()
2329 for (i--; i >= 0; i--) in sdhci_pci_probe()
2330 sdhci_pci_remove_slot(chip->slots[i]); in sdhci_pci_probe()
2334 chip->slots[i] = slot; in sdhci_pci_probe()
2337 if (chip->allow_runtime_pm) in sdhci_pci_probe()
2338 sdhci_pci_runtime_pm_allow(&pdev->dev); in sdhci_pci_probe()
2348 if (chip->allow_runtime_pm) in sdhci_pci_remove()
2349 sdhci_pci_runtime_pm_forbid(&pdev->dev); in sdhci_pci_remove()
2351 for (i = 0; i < chip->num_slots; i++) in sdhci_pci_remove()
2352 sdhci_pci_remove_slot(chip->slots[i]); in sdhci_pci_remove()
2356 .name = "sdhci-pci",