Lines Matching refs:host

19 #include <linux/mmc/host.h>
178 mmc_hostname(card->host), csd_struct);
202 mmc_hostname(card->host), scr_struct);
233 mmc_hostname(card->host));
244 mmc_hostname(card->host));
269 mmc_hostname(card->host));
290 mmc_hostname(card->host));
300 mmc_hostname(card->host));
312 * If the host or the card can't do the switch,
319 mmc_hostname(card->host));
354 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))
365 "switch capabilities.\n", mmc_hostname(card->host));
375 mmc_hostname(card->host));
395 * If the host doesn't support any of the Driver Types A,C or D,
399 if (!(card->host->caps & (MMC_CAP_DRIVER_TYPE_A | MMC_CAP_DRIVER_TYPE_C
403 if (!card->host->ops->select_drive_strength)
406 if (card->host->caps & MMC_CAP_DRIVER_TYPE_A)
409 if (card->host->caps & MMC_CAP_DRIVER_TYPE_C)
412 if (card->host->caps & MMC_CAP_DRIVER_TYPE_D)
430 mmc_host_clk_hold(card->host);
431 drive_strength = card->host->ops->select_drive_strength(
434 mmc_host_clk_release(card->host);
442 mmc_hostname(card->host));
446 mmc_set_driver_type(card->host, drive_strength);
454 * If the host doesn't support any of the UHS-I modes, fallback on
457 if (!mmc_host_uhs(card->host)) {
462 if ((card->host->caps & MMC_CAP_UHS_SDR104) &&
465 } else if ((card->host->caps & MMC_CAP_UHS_DDR50) &&
468 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |
472 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |
476 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |
520 mmc_hostname(card->host));
522 mmc_set_timing(card->host, timing);
523 mmc_set_clock(card->host, card->sw_caps.uhs_max_dtr);
529 /* Get host's max current setting at its current voltage */
530 static u32 sd_get_host_max_current(struct mmc_host *host)
534 voltage = 1 << host->ios.vdd;
537 max_current = host->max_current_180;
541 max_current = host->max_current_300;
545 max_current = host->max_current_330;
574 max_current = sd_get_host_max_current(card->host);
577 * We only check host's capability here, if we set a limit that is
582 * maximum 300ma from the host.
600 mmc_hostname(card->host));
624 "switch capabilities.\n", mmc_hostname(card->host));
629 if ((card->host->caps & MMC_CAP_4_BIT_DATA) &&
635 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
639 * Select the bus speed mode depending on host
663 if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning &&
666 mmc_host_clk_hold(card->host);
667 err = card->host->ops->execute_tuning(card->host,
669 mmc_host_clk_release(card->host);
718 int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
728 pr_warn("%s: Skipping voltage switch\n", mmc_hostname(host));
737 mmc_go_idle(host);
745 err = mmc_send_if_cond(host, ocr);
750 * If the host supports one of UHS-I modes, request the card
754 if (retries && mmc_host_uhs(host))
758 * If the host can supply more than 150mA at current voltage,
761 max_current = sd_get_host_max_current(host);
765 err = mmc_send_app_op_cond(host, ocr, rocr);
773 if (!mmc_host_is_spi(host) && rocr &&
775 err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180,
786 if (mmc_host_is_spi(host))
787 err = mmc_send_cid(host, cid);
789 err = mmc_all_send_cid(host, cid);
794 int mmc_sd_get_csd(struct mmc_host *host, struct mmc_card *card)
812 int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,
852 mmc_hostname(host));
858 mmc_hostname(host), retries);
875 if (mmc_host_is_spi(host)) {
876 err = mmc_spi_set_crc(host, use_spi_crc);
887 if (host->ops->get_ro) {
888 mmc_host_clk_hold(card->host);
889 ro = host->ops->get_ro(host);
890 mmc_host_clk_release(card->host);
894 pr_warn("%s: host does not support reading read-only switch, assuming write-enable\n",
895 mmc_hostname(host));
924 static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
932 BUG_ON(!host);
933 WARN_ON(!host->claimed);
935 err = mmc_sd_get_cid(host, ocr, cid, &rocr);
948 card = mmc_alloc_card(host, &sd_type);
960 if (!mmc_host_is_spi(host)) {
961 err = mmc_send_relative_addr(host, &card->rca);
967 err = mmc_sd_get_csd(host, card);
978 if (card->csd.dsr_imp && host->dsr_req)
979 mmc_set_dsr(host);
984 if (!mmc_host_is_spi(host)) {
990 err = mmc_sd_setup_card(host, card, oldcard != NULL);
1005 mmc_set_timing(card->host, MMC_TIMING_SD_HS);
1012 mmc_set_clock(host, mmc_sd_get_max_clock(card));
1017 if ((host->caps & MMC_CAP_4_BIT_DATA) &&
1023 mmc_set_bus_width(host, MMC_BUS_WIDTH_4);
1027 host->card = card;
1040 static void mmc_sd_remove(struct mmc_host *host)
1042 BUG_ON(!host);
1043 BUG_ON(!host->card);
1045 mmc_remove_card(host->card);
1046 host->card = NULL;
1052 static int mmc_sd_alive(struct mmc_host *host)
1054 return mmc_send_status(host->card, NULL);
1058 * Card detection callback from host.
1060 static void mmc_sd_detect(struct mmc_host *host)
1067 BUG_ON(!host);
1068 BUG_ON(!host->card);
1070 mmc_get_card(host->card);
1077 err = mmc_send_status(host->card, NULL);
1087 __func__, mmc_hostname(host), err);
1090 err = _mmc_detect_card_removed(host);
1093 mmc_put_card(host->card);
1096 mmc_sd_remove(host);
1098 mmc_claim_host(host);
1099 mmc_detach_bus(host);
1100 mmc_power_off(host);
1101 mmc_release_host(host);
1105 static int _mmc_sd_suspend(struct mmc_host *host)
1109 BUG_ON(!host);
1110 BUG_ON(!host->card);
1112 mmc_claim_host(host);
1114 if (mmc_card_suspended(host->card))
1117 if (!mmc_host_is_spi(host))
1118 err = mmc_deselect_cards(host);
1121 mmc_power_off(host);
1122 mmc_card_set_suspended(host->card);
1126 mmc_release_host(host);
1133 static int mmc_sd_suspend(struct mmc_host *host)
1137 err = _mmc_sd_suspend(host);
1139 pm_runtime_disable(&host->card->dev);
1140 pm_runtime_set_suspended(&host->card->dev);
1150 static int _mmc_sd_resume(struct mmc_host *host)
1157 BUG_ON(!host);
1158 BUG_ON(!host->card);
1160 mmc_claim_host(host);
1162 if (!mmc_card_suspended(host->card))
1165 mmc_power_up(host, host->card->ocr);
1169 err = mmc_sd_init_card(host, host->card->ocr, host->card);
1173 mmc_hostname(host), err, retries);
1181 err = mmc_sd_init_card(host, host->card->ocr, host->card);
1183 mmc_card_clr_suspended(host->card);
1186 mmc_release_host(host);
1193 static int mmc_sd_resume(struct mmc_host *host)
1197 if (!(host->caps & MMC_CAP_RUNTIME_RESUME)) {
1198 err = _mmc_sd_resume(host);
1199 pm_runtime_set_active(&host->card->dev);
1200 pm_runtime_mark_last_busy(&host->card->dev);
1202 pm_runtime_enable(&host->card->dev);
1210 static int mmc_sd_runtime_suspend(struct mmc_host *host)
1214 if (!(host->caps & MMC_CAP_AGGRESSIVE_PM))
1217 err = _mmc_sd_suspend(host);
1220 mmc_hostname(host), err);
1228 static int mmc_sd_runtime_resume(struct mmc_host *host)
1232 if (!(host->caps & (MMC_CAP_AGGRESSIVE_PM | MMC_CAP_RUNTIME_RESUME)))
1235 err = _mmc_sd_resume(host);
1238 mmc_hostname(host), err);
1243 static int mmc_sd_power_restore(struct mmc_host *host)
1247 mmc_claim_host(host);
1248 ret = mmc_sd_init_card(host, host->card->ocr, host->card);
1249 mmc_release_host(host);
1269 int mmc_attach_sd(struct mmc_host *host)
1277 BUG_ON(!host);
1278 WARN_ON(!host->claimed);
1280 err = mmc_send_app_op_cond(host, 0, &ocr);
1284 mmc_attach_bus(host, &mmc_sd_ops);
1285 if (host->ocr_avail_sd)
1286 host->ocr_avail = host->ocr_avail_sd;
1291 if (mmc_host_is_spi(host)) {
1292 mmc_go_idle(host);
1294 err = mmc_spi_read_ocr(host, 0, &ocr);
1299 rocr = mmc_select_voltage(host, ocr);
1315 err = mmc_sd_init_card(host, rocr, NULL);
1325 mmc_hostname(host), err);
1329 err = mmc_sd_init_card(host, rocr, NULL);
1334 mmc_release_host(host);
1335 err = mmc_add_card(host->card);
1336 mmc_claim_host(host);
1343 mmc_release_host(host);
1344 mmc_remove_card(host->card);
1345 host->card = NULL;
1346 mmc_claim_host(host);
1348 mmc_detach_bus(host);
1351 mmc_hostname(host), err);