Lines Matching refs:host

12 #include <linux/mmc/host.h>
21 #include "host.h"
138 * the host lock as we haven't registered the device yet.
160 mmc_hostname(card->host), cccr_vsn);
201 if (mmc_host_uhs(card->host)) {
266 if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
278 mmc_hostname(card->host), ctrl);
323 if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
343 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_1);
355 if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
388 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
402 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))
513 mmc_set_driver_type(card->host, drv_type);
525 * If the host doesn't support any of the UHS-I modes, fallback on
528 if (!mmc_host_uhs(card->host))
533 if ((card->host->caps & MMC_CAP_UHS_SDR104) &&
539 } else if ((card->host->caps & MMC_CAP_UHS_DDR50) &&
545 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |
552 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |
559 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 |
582 mmc_set_timing(card->host, timing);
583 mmc_set_clock(card->host, max_rate);
615 if (!mmc_host_is_spi(card->host) &&
616 ((card->host->ios.timing == MMC_TIMING_UHS_SDR50) ||
617 (card->host->ios.timing == MMC_TIMING_UHS_SDR104)))
623 static int mmc_sdio_pre_init(struct mmc_host *host, u32 ocr,
646 sdio_reset(host);
647 mmc_go_idle(host);
648 mmc_send_if_cond(host, ocr);
649 return mmc_send_io_op_cond(host, 0, NULL);
658 static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
667 WARN_ON(!host->claimed);
670 if (mmc_host_uhs(host))
675 pr_warn("%s: Skipping voltage switch\n", mmc_hostname(host));
682 err = mmc_send_io_op_cond(host, ocr, &rocr);
689 if (mmc_host_is_spi(host)) {
690 err = mmc_spi_set_crc(host, use_spi_crc);
698 card = mmc_alloc_card(host, &sdio_type);
703 mmc_sd_get_cid(host, ocr & rocr, card->raw_cid, NULL) == 0) {
723 if (host->ops->init_card)
724 host->ops->init_card(host, card);
730 * If the host and card support UHS-I mode request the card
741 err = mmc_set_uhs_voltage(host, ocr_card);
743 mmc_sdio_pre_init(host, ocr_card, card);
754 if (!mmc_host_is_spi(host)) {
755 err = mmc_send_relative_addr(host, &card->rca);
782 if (!mmc_host_is_spi(host)) {
792 * It's host's responsibility to fill cccr and cis
795 mmc_set_clock(host, card->cis.max_dtr);
798 mmc_set_timing(card->host, MMC_TIMING_SD_HS);
804 host->card = card;
815 mmc_sdio_pre_init(host, ocr_card, card);
845 err = mmc_sd_setup_card(host, card, oldcard != NULL);
848 mmc_go_idle(host);
849 if (mmc_host_is_spi(host))
851 mmc_spi_set_crc(host, use_spi_crc);
876 mmc_set_timing(card->host, MMC_TIMING_SD_HS);
883 mmc_set_clock(host, mmc_sdio_get_max_clock(card));
893 if (host->caps2 & MMC_CAP2_AVOID_3_3V &&
894 host->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330) {
896 mmc_hostname(host));
901 host->card = card;
905 pr_debug("%s: Perhaps the card was replaced\n", mmc_hostname(host));
912 static int mmc_sdio_reinit_card(struct mmc_host *host)
916 ret = mmc_sdio_pre_init(host, host->card->ocr, NULL);
920 return mmc_sdio_init_card(host, host->card->ocr, host->card);
926 static void mmc_sdio_remove(struct mmc_host *host)
930 for (i = 0;i < host->card->sdio_funcs;i++) {
931 if (host->card->sdio_func[i]) {
932 sdio_remove_func(host->card->sdio_func[i]);
933 host->card->sdio_func[i] = NULL;
937 mmc_remove_card(host->card);
938 host->card = NULL;
944 static int mmc_sdio_alive(struct mmc_host *host)
946 return mmc_select_card(host->card);
950 * Card detection callback from host.
952 static void mmc_sdio_detect(struct mmc_host *host)
957 if (host->caps & MMC_CAP_POWER_OFF_CARD) {
958 err = pm_runtime_resume_and_get(&host->card->dev);
963 mmc_claim_host(host);
968 err = _mmc_detect_card_removed(host);
970 mmc_release_host(host);
983 if (host->caps & MMC_CAP_POWER_OFF_CARD)
984 pm_runtime_put_sync(&host->card->dev);
988 mmc_sdio_remove(host);
990 mmc_claim_host(host);
991 mmc_detach_bus(host);
992 mmc_power_off(host);
993 mmc_release_host(host);
1002 static int mmc_sdio_pre_suspend(struct mmc_host *host)
1006 for (i = 0; i < host->card->sdio_funcs; i++) {
1007 struct sdio_func *func = host->card->sdio_func[i];
1019 if (!mmc_card_is_removable(host)) {
1020 dev_warn(mmc_dev(host),
1027 mmc_sdio_remove(host);
1028 mmc_claim_host(host);
1029 mmc_detach_bus(host);
1030 mmc_power_off(host);
1031 mmc_release_host(host);
1032 host->pm_flags = 0;
1040 static int mmc_sdio_suspend(struct mmc_host *host)
1042 WARN_ON(host->sdio_irqs && !mmc_card_keep_power(host));
1045 mmc_card_set_suspended(host->card);
1046 cancel_work_sync(&host->sdio_irq_work);
1048 mmc_claim_host(host);
1050 if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host))
1051 sdio_disable_4bit_bus(host->card);
1053 if (!mmc_card_keep_power(host)) {
1054 mmc_power_off(host);
1055 } else if (host->retune_period) {
1056 mmc_retune_timer_stop(host);
1057 mmc_retune_needed(host);
1060 mmc_release_host(host);
1065 static int mmc_sdio_resume(struct mmc_host *host)
1070 mmc_claim_host(host);
1077 if (!mmc_card_keep_power(host)) {
1078 mmc_power_up(host, host->card->ocr);
1085 if (host->caps & MMC_CAP_POWER_OFF_CARD) {
1086 pm_runtime_disable(&host->card->dev);
1087 pm_runtime_set_active(&host->card->dev);
1088 pm_runtime_enable(&host->card->dev);
1090 err = mmc_sdio_reinit_card(host);
1091 } else if (mmc_card_wake_sdio_irq(host)) {
1097 mmc_retune_hold_now(host);
1098 err = sdio_enable_4bit_bus(host->card);
1099 mmc_retune_release(host);
1106 mmc_card_clr_suspended(host->card);
1108 if (host->sdio_irqs) {
1109 if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD))
1110 wake_up_process(host->sdio_irq_thread);
1111 else if (host->caps & MMC_CAP_SDIO_IRQ)
1112 schedule_work(&host->sdio_irq_work);
1116 mmc_release_host(host);
1118 host->pm_flags &= ~MMC_PM_KEEP_POWER;
1122 static int mmc_sdio_runtime_suspend(struct mmc_host *host)
1125 mmc_claim_host(host);
1126 mmc_power_off(host);
1127 mmc_release_host(host);
1132 static int mmc_sdio_runtime_resume(struct mmc_host *host)
1137 mmc_claim_host(host);
1138 mmc_power_up(host, host->card->ocr);
1139 ret = mmc_sdio_reinit_card(host);
1140 mmc_release_host(host);
1151 static int mmc_sdio_hw_reset(struct mmc_host *host)
1153 struct mmc_card *card = host->card;
1163 host->rescan_entered = 0;
1165 _mmc_detect_change(host, 0, false);
1173 mmc_power_cycle(host, card->ocr);
1174 return mmc_sdio_reinit_card(host);
1177 static int mmc_sdio_sw_reset(struct mmc_host *host)
1179 mmc_set_clock(host, host->f_init);
1180 sdio_reset(host);
1181 mmc_go_idle(host);
1183 mmc_set_initial_state(host);
1184 mmc_set_initial_signal_voltage(host);
1186 return mmc_sdio_reinit_card(host);
1206 int mmc_attach_sdio(struct mmc_host *host)
1212 WARN_ON(!host->claimed);
1214 err = mmc_send_io_op_cond(host, 0, &ocr);
1218 mmc_attach_bus(host, &mmc_sdio_ops);
1219 if (host->ocr_avail_sdio)
1220 host->ocr_avail = host->ocr_avail_sdio;
1223 rocr = mmc_select_voltage(host, ocr);
1236 err = mmc_sdio_init_card(host, rocr, NULL);
1240 card = host->card;
1243 * Enable runtime PM only if supported by host+card+board
1245 if (host->caps & MMC_CAP_POWER_OFF_CARD) {
1276 err = sdio_init_func(host->card, i + 1);
1283 if (host->caps & MMC_CAP_POWER_OFF_CARD)
1290 mmc_release_host(host);
1291 err = mmc_add_card(host->card);
1299 err = sdio_add_func(host->card->sdio_func[i]);
1304 if (host->caps & MMC_CAP_POWER_OFF_CARD)
1307 mmc_claim_host(host);
1312 mmc_release_host(host);
1320 mmc_sdio_remove(host);
1321 mmc_claim_host(host);
1323 mmc_detach_bus(host);
1326 mmc_hostname(host), err);