Lines Matching refs:host
82 static void mmc_should_fail_request(struct mmc_host *host, in mmc_should_fail_request() argument
97 !should_fail(&host->fail_mmc_request, data->blksz * data->blocks)) in mmc_should_fail_request()
106 static inline void mmc_should_fail_request(struct mmc_host *host, in mmc_should_fail_request() argument
119 void mmc_command_done(struct mmc_host *host, struct mmc_request *mrq) in mmc_command_done() argument
127 mmc_hostname(host), mrq->cmd->opcode); in mmc_command_done()
139 void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) in mmc_request_done() argument
147 !host->retune_crc_disable && in mmc_request_done()
151 mmc_retune_needed(host); in mmc_request_done()
153 if (err && cmd->retries && mmc_host_is_spi(host)) { in mmc_request_done()
158 if (host->ongoing_mrq == mrq) in mmc_request_done()
159 host->ongoing_mrq = NULL; in mmc_request_done()
163 trace_mmc_request_done(host, mrq); in mmc_request_done()
174 if (!err || !cmd->retries || mmc_card_removed(host->card)) { in mmc_request_done()
175 mmc_should_fail_request(host, mrq); in mmc_request_done()
177 if (!host->ongoing_mrq) in mmc_request_done()
178 led_trigger_event(host->led, LED_OFF); in mmc_request_done()
182 mmc_hostname(host), mrq->sbc->opcode, in mmc_request_done()
189 mmc_hostname(host), cmd->opcode, err, in mmc_request_done()
195 mmc_hostname(host), in mmc_request_done()
201 mmc_hostname(host), mrq->stop->opcode, in mmc_request_done()
217 static void __mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) in __mmc_start_request() argument
222 err = mmc_retune(host); in __mmc_start_request()
225 mmc_request_done(host, mrq); in __mmc_start_request()
235 host->ops->card_busy) { in __mmc_start_request()
238 while (host->ops->card_busy(host) && --tries) in __mmc_start_request()
243 mmc_request_done(host, mrq); in __mmc_start_request()
249 host->ongoing_mrq = mrq; in __mmc_start_request()
257 trace_mmc_request_start(host, mrq); in __mmc_start_request()
259 if (host->cqe_on) in __mmc_start_request()
260 host->cqe_ops->cqe_off(host); in __mmc_start_request()
262 host->ops->request(host, mrq); in __mmc_start_request()
265 static void mmc_mrq_pr_debug(struct mmc_host *host, struct mmc_request *mrq, in mmc_mrq_pr_debug() argument
270 mmc_hostname(host), mrq->sbc->opcode, in mmc_mrq_pr_debug()
276 mmc_hostname(host), cqe ? "CQE direct " : "", in mmc_mrq_pr_debug()
280 mmc_hostname(host), mrq->tag, mrq->data->blk_addr); in mmc_mrq_pr_debug()
286 mmc_hostname(host), mrq->data->blksz, in mmc_mrq_pr_debug()
294 mmc_hostname(host), mrq->stop->opcode, in mmc_mrq_pr_debug()
299 static int mmc_mrq_prep(struct mmc_host *host, struct mmc_request *mrq) in mmc_mrq_prep() argument
314 if (mrq->data->blksz > host->max_blk_size || in mmc_mrq_prep()
315 mrq->data->blocks > host->max_blk_count || in mmc_mrq_prep()
316 mrq->data->blocks * mrq->data->blksz > host->max_req_size) in mmc_mrq_prep()
336 int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) in mmc_start_request() argument
342 mmc_retune_hold(host); in mmc_start_request()
344 if (mmc_card_removed(host->card)) in mmc_start_request()
347 mmc_mrq_pr_debug(host, mrq, false); in mmc_start_request()
349 WARN_ON(!host->claimed); in mmc_start_request()
351 err = mmc_mrq_prep(host, mrq); in mmc_start_request()
355 led_trigger_event(host->led, LED_FULL); in mmc_start_request()
356 __mmc_start_request(host, mrq); in mmc_start_request()
367 static inline void mmc_wait_ongoing_tfr_cmd(struct mmc_host *host) in mmc_wait_ongoing_tfr_cmd() argument
369 struct mmc_request *ongoing_mrq = READ_ONCE(host->ongoing_mrq); in mmc_wait_ongoing_tfr_cmd()
379 static int __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq) in __mmc_start_req() argument
383 mmc_wait_ongoing_tfr_cmd(host); in __mmc_start_req()
388 err = mmc_start_request(host, mrq); in __mmc_start_req()
398 void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) in mmc_wait_for_req_done() argument
408 mmc_card_removed(host->card)) in mmc_wait_for_req_done()
411 mmc_retune_recheck(host); in mmc_wait_for_req_done()
414 mmc_hostname(host), cmd->opcode, cmd->error); in mmc_wait_for_req_done()
417 __mmc_start_request(host, mrq); in mmc_wait_for_req_done()
420 mmc_retune_release(host); in mmc_wait_for_req_done()
432 int mmc_cqe_start_req(struct mmc_host *host, struct mmc_request *mrq) in mmc_cqe_start_req() argument
442 err = mmc_retune(host); in mmc_cqe_start_req()
446 mrq->host = host; in mmc_cqe_start_req()
448 mmc_mrq_pr_debug(host, mrq, true); in mmc_cqe_start_req()
450 err = mmc_mrq_prep(host, mrq); in mmc_cqe_start_req()
454 err = host->cqe_ops->cqe_request(host, mrq); in mmc_cqe_start_req()
458 trace_mmc_request_start(host, mrq); in mmc_cqe_start_req()
465 mmc_hostname(host), mrq->cmd->opcode, err); in mmc_cqe_start_req()
468 mmc_hostname(host), mrq->tag, err); in mmc_cqe_start_req()
482 void mmc_cqe_request_done(struct mmc_host *host, struct mmc_request *mrq) in mmc_cqe_request_done() argument
484 mmc_should_fail_request(host, mrq); in mmc_cqe_request_done()
489 mmc_retune_needed(host); in mmc_cqe_request_done()
491 trace_mmc_request_done(host, mrq); in mmc_cqe_request_done()
495 mmc_hostname(host), mrq->cmd->opcode, mrq->cmd->error); in mmc_cqe_request_done()
498 mmc_hostname(host), mrq->tag); in mmc_cqe_request_done()
503 mmc_hostname(host), in mmc_cqe_request_done()
516 void mmc_cqe_post_req(struct mmc_host *host, struct mmc_request *mrq) in mmc_cqe_post_req() argument
518 if (host->cqe_ops->cqe_post_req) in mmc_cqe_post_req()
519 host->cqe_ops->cqe_post_req(host, mrq); in mmc_cqe_post_req()
535 int mmc_cqe_recovery(struct mmc_host *host) in mmc_cqe_recovery() argument
540 mmc_retune_hold_now(host); in mmc_cqe_recovery()
546 pr_warn("%s: running CQE recovery\n", mmc_hostname(host)); in mmc_cqe_recovery()
548 host->cqe_ops->cqe_recovery_start(host); in mmc_cqe_recovery()
555 mmc_wait_for_cmd(host, &cmd, 0); in mmc_cqe_recovery()
563 err = mmc_wait_for_cmd(host, &cmd, 0); in mmc_cqe_recovery()
565 host->cqe_ops->cqe_recovery_finish(host); in mmc_cqe_recovery()
567 mmc_retune_release(host); in mmc_cqe_recovery()
585 bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq) in mmc_is_req_done() argument
603 void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) in mmc_wait_for_req() argument
605 __mmc_start_req(host, mrq); in mmc_wait_for_req()
608 mmc_wait_for_req_done(host, mrq); in mmc_wait_for_req()
622 int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries) in mmc_wait_for_cmd() argument
626 WARN_ON(!host->claimed); in mmc_wait_for_cmd()
634 mmc_wait_for_req(host, &mrq); in mmc_wait_for_cmd()
684 if (card->host->ios.clock) in mmc_set_data_timeout()
686 (card->host->ios.clock / 1000); in mmc_set_data_timeout()
731 if (mmc_host_is_spi(card->host)) { in mmc_set_data_timeout()
747 static inline bool mmc_ctx_matches(struct mmc_host *host, struct mmc_ctx *ctx, in mmc_ctx_matches() argument
750 return host->claimer == ctx || in mmc_ctx_matches()
751 (!ctx && task && host->claimer->task == task); in mmc_ctx_matches()
754 static inline void mmc_ctx_set_claimer(struct mmc_host *host, in mmc_ctx_set_claimer() argument
758 if (!host->claimer) { in mmc_ctx_set_claimer()
760 host->claimer = ctx; in mmc_ctx_set_claimer()
762 host->claimer = &host->default_ctx; in mmc_ctx_set_claimer()
765 host->claimer->task = task; in mmc_ctx_set_claimer()
780 int __mmc_claim_host(struct mmc_host *host, struct mmc_ctx *ctx, in __mmc_claim_host() argument
791 add_wait_queue(&host->wq, &wait); in __mmc_claim_host()
792 spin_lock_irqsave(&host->lock, flags); in __mmc_claim_host()
796 if (stop || !host->claimed || mmc_ctx_matches(host, ctx, task)) in __mmc_claim_host()
798 spin_unlock_irqrestore(&host->lock, flags); in __mmc_claim_host()
800 spin_lock_irqsave(&host->lock, flags); in __mmc_claim_host()
804 host->claimed = 1; in __mmc_claim_host()
805 mmc_ctx_set_claimer(host, ctx, task); in __mmc_claim_host()
806 host->claim_cnt += 1; in __mmc_claim_host()
807 if (host->claim_cnt == 1) in __mmc_claim_host()
810 wake_up(&host->wq); in __mmc_claim_host()
811 spin_unlock_irqrestore(&host->lock, flags); in __mmc_claim_host()
812 remove_wait_queue(&host->wq, &wait); in __mmc_claim_host()
815 pm_runtime_get_sync(mmc_dev(host)); in __mmc_claim_host()
828 void mmc_release_host(struct mmc_host *host) in mmc_release_host() argument
832 WARN_ON(!host->claimed); in mmc_release_host()
834 spin_lock_irqsave(&host->lock, flags); in mmc_release_host()
835 if (--host->claim_cnt) { in mmc_release_host()
837 spin_unlock_irqrestore(&host->lock, flags); in mmc_release_host()
839 host->claimed = 0; in mmc_release_host()
840 host->claimer->task = NULL; in mmc_release_host()
841 host->claimer = NULL; in mmc_release_host()
842 spin_unlock_irqrestore(&host->lock, flags); in mmc_release_host()
843 wake_up(&host->wq); in mmc_release_host()
844 pm_runtime_mark_last_busy(mmc_dev(host)); in mmc_release_host()
845 if (host->caps & MMC_CAP_SYNC_RUNTIME_PM) in mmc_release_host()
846 pm_runtime_put_sync_suspend(mmc_dev(host)); in mmc_release_host()
848 pm_runtime_put_autosuspend(mmc_dev(host)); in mmc_release_host()
860 __mmc_claim_host(card->host, ctx, NULL); in mmc_get_card()
870 struct mmc_host *host = card->host; in mmc_put_card() local
872 WARN_ON(ctx && host->claimer != ctx); in mmc_put_card()
874 mmc_release_host(host); in mmc_put_card()
884 static inline void mmc_set_ios(struct mmc_host *host) in mmc_set_ios() argument
886 struct mmc_ios *ios = &host->ios; in mmc_set_ios()
890 mmc_hostname(host), ios->clock, ios->bus_mode, in mmc_set_ios()
894 host->ops->set_ios(host, ios); in mmc_set_ios()
900 void mmc_set_chip_select(struct mmc_host *host, int mode) in mmc_set_chip_select() argument
902 host->ios.chip_select = mode; in mmc_set_chip_select()
903 mmc_set_ios(host); in mmc_set_chip_select()
910 void mmc_set_clock(struct mmc_host *host, unsigned int hz) in mmc_set_clock() argument
912 WARN_ON(hz && hz < host->f_min); in mmc_set_clock()
914 if (hz > host->f_max) in mmc_set_clock()
915 hz = host->f_max; in mmc_set_clock()
917 host->ios.clock = hz; in mmc_set_clock()
918 mmc_set_ios(host); in mmc_set_clock()
923 struct mmc_host *host = card->host; in mmc_execute_tuning() local
927 if (!host->ops->execute_tuning) in mmc_execute_tuning()
930 if (host->cqe_on) in mmc_execute_tuning()
931 host->cqe_ops->cqe_off(host); in mmc_execute_tuning()
938 err = host->ops->execute_tuning(host, opcode); in mmc_execute_tuning()
940 mmc_retune_clear(host); in mmc_execute_tuning()
941 mmc_retune_enable(host); in mmc_execute_tuning()
946 if (!host->detect_change) { in mmc_execute_tuning()
948 mmc_hostname(host), err); in mmc_execute_tuning()
949 mmc_debugfs_err_stats_inc(host, MMC_ERR_TUNING); in mmc_execute_tuning()
958 void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode) in mmc_set_bus_mode() argument
960 host->ios.bus_mode = mode; in mmc_set_bus_mode()
961 mmc_set_ios(host); in mmc_set_bus_mode()
967 void mmc_set_bus_width(struct mmc_host *host, unsigned int width) in mmc_set_bus_width() argument
969 host->ios.bus_width = width; in mmc_set_bus_width()
970 mmc_set_ios(host); in mmc_set_bus_width()
976 void mmc_set_initial_state(struct mmc_host *host) in mmc_set_initial_state() argument
978 if (host->cqe_on) in mmc_set_initial_state()
979 host->cqe_ops->cqe_off(host); in mmc_set_initial_state()
981 mmc_retune_disable(host); in mmc_set_initial_state()
983 if (mmc_host_is_spi(host)) in mmc_set_initial_state()
984 host->ios.chip_select = MMC_CS_HIGH; in mmc_set_initial_state()
986 host->ios.chip_select = MMC_CS_DONTCARE; in mmc_set_initial_state()
987 host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; in mmc_set_initial_state()
988 host->ios.bus_width = MMC_BUS_WIDTH_1; in mmc_set_initial_state()
989 host->ios.timing = MMC_TIMING_LEGACY; in mmc_set_initial_state()
990 host->ios.drv_type = 0; in mmc_set_initial_state()
991 host->ios.enhanced_strobe = false; in mmc_set_initial_state()
997 if ((host->caps2 & MMC_CAP2_HS400_ES) && in mmc_set_initial_state()
998 host->ops->hs400_enhanced_strobe) in mmc_set_initial_state()
999 host->ops->hs400_enhanced_strobe(host, &host->ios); in mmc_set_initial_state()
1001 mmc_set_ios(host); in mmc_set_initial_state()
1003 mmc_crypto_set_initial_state(host); in mmc_set_initial_state()
1091 struct device_node *mmc_of_find_child_device(struct mmc_host *host, in mmc_of_find_child_device() argument
1096 if (!host->parent || !host->parent->of_node) in mmc_of_find_child_device()
1099 for_each_child_of_node(host->parent->of_node, node) { in mmc_of_find_child_device()
1111 u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) in mmc_select_voltage() argument
1120 dev_warn(mmc_dev(host), in mmc_select_voltage()
1125 ocr &= host->ocr_avail; in mmc_select_voltage()
1127 dev_warn(mmc_dev(host), "no support for card's volts\n"); in mmc_select_voltage()
1131 if (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) { in mmc_select_voltage()
1134 mmc_power_cycle(host, ocr); in mmc_select_voltage()
1144 if (bit != host->ios.vdd) in mmc_select_voltage()
1145 dev_warn(mmc_dev(host), "exceeding card's volts\n"); in mmc_select_voltage()
1151 int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) in mmc_set_signal_voltage() argument
1154 int old_signal_voltage = host->ios.signal_voltage; in mmc_set_signal_voltage()
1156 host->ios.signal_voltage = signal_voltage; in mmc_set_signal_voltage()
1157 if (host->ops->start_signal_voltage_switch) in mmc_set_signal_voltage()
1158 err = host->ops->start_signal_voltage_switch(host, &host->ios); in mmc_set_signal_voltage()
1161 host->ios.signal_voltage = old_signal_voltage; in mmc_set_signal_voltage()
1167 void mmc_set_initial_signal_voltage(struct mmc_host *host) in mmc_set_initial_signal_voltage() argument
1170 if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330)) in mmc_set_initial_signal_voltage()
1171 dev_dbg(mmc_dev(host), "Initial signal voltage of 3.3v\n"); in mmc_set_initial_signal_voltage()
1172 else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180)) in mmc_set_initial_signal_voltage()
1173 dev_dbg(mmc_dev(host), "Initial signal voltage of 1.8v\n"); in mmc_set_initial_signal_voltage()
1174 else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120)) in mmc_set_initial_signal_voltage()
1175 dev_dbg(mmc_dev(host), "Initial signal voltage of 1.2v\n"); in mmc_set_initial_signal_voltage()
1178 int mmc_host_set_uhs_voltage(struct mmc_host *host) in mmc_host_set_uhs_voltage() argument
1186 clock = host->ios.clock; in mmc_host_set_uhs_voltage()
1187 host->ios.clock = 0; in mmc_host_set_uhs_voltage()
1188 mmc_set_ios(host); in mmc_host_set_uhs_voltage()
1190 if (mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180)) in mmc_host_set_uhs_voltage()
1195 host->ios.clock = clock; in mmc_host_set_uhs_voltage()
1196 mmc_set_ios(host); in mmc_host_set_uhs_voltage()
1201 int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr) in mmc_set_uhs_voltage() argument
1210 if (!host->ops->start_signal_voltage_switch) in mmc_set_uhs_voltage()
1212 if (!host->ops->card_busy) in mmc_set_uhs_voltage()
1214 mmc_hostname(host)); in mmc_set_uhs_voltage()
1220 err = mmc_wait_for_cmd(host, &cmd, 0); in mmc_set_uhs_voltage()
1224 if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR)) in mmc_set_uhs_voltage()
1232 if (host->ops->card_busy && !host->ops->card_busy(host)) { in mmc_set_uhs_voltage()
1237 if (mmc_host_set_uhs_voltage(host)) { in mmc_set_uhs_voltage()
1253 if (host->ops->card_busy && host->ops->card_busy(host)) in mmc_set_uhs_voltage()
1259 "power cycling card\n", mmc_hostname(host)); in mmc_set_uhs_voltage()
1260 mmc_power_cycle(host, ocr); in mmc_set_uhs_voltage()
1269 void mmc_set_timing(struct mmc_host *host, unsigned int timing) in mmc_set_timing() argument
1271 host->ios.timing = timing; in mmc_set_timing()
1272 mmc_set_ios(host); in mmc_set_timing()
1278 void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type) in mmc_set_driver_type() argument
1280 host->ios.drv_type = drv_type; in mmc_set_driver_type()
1281 mmc_set_ios(host); in mmc_set_driver_type()
1287 struct mmc_host *host = card->host; in mmc_select_drive_strength() local
1292 if (!host->ops->select_drive_strength) in mmc_select_drive_strength()
1296 if (host->caps & MMC_CAP_DRIVER_TYPE_A) in mmc_select_drive_strength()
1299 if (host->caps & MMC_CAP_DRIVER_TYPE_C) in mmc_select_drive_strength()
1302 if (host->caps & MMC_CAP_DRIVER_TYPE_D) in mmc_select_drive_strength()
1311 return host->ops->select_drive_strength(card, max_dtr, in mmc_select_drive_strength()
1328 void mmc_power_up(struct mmc_host *host, u32 ocr) in mmc_power_up() argument
1330 if (host->ios.power_mode == MMC_POWER_ON) in mmc_power_up()
1333 mmc_pwrseq_pre_power_on(host); in mmc_power_up()
1335 host->ios.vdd = fls(ocr) - 1; in mmc_power_up()
1336 host->ios.power_mode = MMC_POWER_UP; in mmc_power_up()
1338 mmc_set_initial_state(host); in mmc_power_up()
1340 mmc_set_initial_signal_voltage(host); in mmc_power_up()
1346 mmc_delay(host->ios.power_delay_ms); in mmc_power_up()
1348 mmc_pwrseq_post_power_on(host); in mmc_power_up()
1350 host->ios.clock = host->f_init; in mmc_power_up()
1352 host->ios.power_mode = MMC_POWER_ON; in mmc_power_up()
1353 mmc_set_ios(host); in mmc_power_up()
1359 mmc_delay(host->ios.power_delay_ms); in mmc_power_up()
1362 void mmc_power_off(struct mmc_host *host) in mmc_power_off() argument
1364 if (host->ios.power_mode == MMC_POWER_OFF) in mmc_power_off()
1367 mmc_pwrseq_power_off(host); in mmc_power_off()
1369 host->ios.clock = 0; in mmc_power_off()
1370 host->ios.vdd = 0; in mmc_power_off()
1372 host->ios.power_mode = MMC_POWER_OFF; in mmc_power_off()
1374 mmc_set_initial_state(host); in mmc_power_off()
1384 void mmc_power_cycle(struct mmc_host *host, u32 ocr) in mmc_power_cycle() argument
1386 mmc_power_off(host); in mmc_power_cycle()
1389 mmc_power_up(host, ocr); in mmc_power_cycle()
1396 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops) in mmc_attach_bus() argument
1398 host->bus_ops = ops; in mmc_attach_bus()
1404 void mmc_detach_bus(struct mmc_host *host) in mmc_detach_bus() argument
1406 host->bus_ops = NULL; in mmc_detach_bus()
1409 void _mmc_detect_change(struct mmc_host *host, unsigned long delay, bool cd_irq) in _mmc_detect_change() argument
1416 if (cd_irq && !(host->caps & MMC_CAP_NEEDS_POLL)) in _mmc_detect_change()
1417 __pm_wakeup_event(host->ws, 5000); in _mmc_detect_change()
1419 host->detect_change = 1; in _mmc_detect_change()
1420 mmc_schedule_delayed_work(&host->detect, delay); in _mmc_detect_change()
1433 void mmc_detect_change(struct mmc_host *host, unsigned long delay) in mmc_detect_change() argument
1435 _mmc_detect_change(host, delay, true); in mmc_detect_change()
1524 (card->host->ios.clock / 1000); in mmc_mmc_erase_timeout()
1550 if (mmc_host_is_spi(card->host) && erase_timeout < 1000) in mmc_mmc_erase_timeout()
1605 mmc_retune_hold(card->host); in mmc_do_erase()
1643 err = mmc_wait_for_cmd(card->host, &cmd, 0); in mmc_do_erase()
1658 err = mmc_wait_for_cmd(card->host, &cmd, 0); in mmc_do_erase()
1670 use_r1b_resp = mmc_prepare_busy_cmd(card->host, &cmd, busy_timeout); in mmc_do_erase()
1672 err = mmc_wait_for_cmd(card->host, &cmd, 0); in mmc_do_erase()
1680 if (mmc_host_is_spi(card->host)) in mmc_do_erase()
1687 if ((card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) in mmc_do_erase()
1694 mmc_retune_release(card->host); in mmc_do_erase()
1876 struct mmc_host *host = card->host; in mmc_do_calc_max_discard() local
1879 unsigned int max_busy_timeout = host->max_busy_timeout ? in mmc_do_calc_max_discard()
1880 host->max_busy_timeout : MMC_ERASE_TIMEOUT_MS; in mmc_do_calc_max_discard()
1953 struct mmc_host *host = card->host; in mmc_calc_max_discard() local
1973 mmc_hostname(host), max_discard, host->max_busy_timeout ? in mmc_calc_max_discard()
1974 host->max_busy_timeout : MMC_ERASE_TIMEOUT_MS); in mmc_calc_max_discard()
1996 return mmc_wait_for_cmd(card->host, &cmd, 5); in mmc_set_blocklen()
2000 static void mmc_hw_reset_for_init(struct mmc_host *host) in mmc_hw_reset_for_init() argument
2002 mmc_pwrseq_reset(host); in mmc_hw_reset_for_init()
2004 if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->card_hw_reset) in mmc_hw_reset_for_init()
2006 host->ops->card_hw_reset(host); in mmc_hw_reset_for_init()
2021 struct mmc_host *host = card->host; in mmc_hw_reset() local
2024 ret = host->bus_ops->hw_reset(host); in mmc_hw_reset()
2027 mmc_hostname(host), ret); in mmc_hw_reset()
2035 struct mmc_host *host = card->host; in mmc_sw_reset() local
2038 if (!host->bus_ops->sw_reset) in mmc_sw_reset()
2041 ret = host->bus_ops->sw_reset(host); in mmc_sw_reset()
2044 mmc_hostname(host), ret); in mmc_sw_reset()
2050 static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) in mmc_rescan_try_freq() argument
2052 host->f_init = freq; in mmc_rescan_try_freq()
2055 mmc_hostname(host), __func__, host->f_init); in mmc_rescan_try_freq()
2057 mmc_power_up(host, host->ocr_avail); in mmc_rescan_try_freq()
2063 mmc_hw_reset_for_init(host); in mmc_rescan_try_freq()
2071 if (!(host->caps2 & MMC_CAP2_NO_SDIO)) in mmc_rescan_try_freq()
2072 sdio_reset(host); in mmc_rescan_try_freq()
2074 mmc_go_idle(host); in mmc_rescan_try_freq()
2076 if (!(host->caps2 & MMC_CAP2_NO_SD)) { in mmc_rescan_try_freq()
2077 if (mmc_send_if_cond_pcie(host, host->ocr_avail)) in mmc_rescan_try_freq()
2079 if (mmc_card_sd_express(host)) in mmc_rescan_try_freq()
2084 if (!(host->caps2 & MMC_CAP2_NO_SDIO)) in mmc_rescan_try_freq()
2085 if (!mmc_attach_sdio(host)) in mmc_rescan_try_freq()
2088 if (!(host->caps2 & MMC_CAP2_NO_SD)) in mmc_rescan_try_freq()
2089 if (!mmc_attach_sd(host)) in mmc_rescan_try_freq()
2092 if (!(host->caps2 & MMC_CAP2_NO_MMC)) in mmc_rescan_try_freq()
2093 if (!mmc_attach_mmc(host)) in mmc_rescan_try_freq()
2097 mmc_power_off(host); in mmc_rescan_try_freq()
2101 int _mmc_detect_card_removed(struct mmc_host *host) in _mmc_detect_card_removed() argument
2105 if (!host->card || mmc_card_removed(host->card)) in _mmc_detect_card_removed()
2108 ret = host->bus_ops->alive(host); in _mmc_detect_card_removed()
2117 if (!ret && host->ops->get_cd && !host->ops->get_cd(host)) { in _mmc_detect_card_removed()
2118 mmc_detect_change(host, msecs_to_jiffies(200)); in _mmc_detect_card_removed()
2119 pr_debug("%s: card removed too slowly\n", mmc_hostname(host)); in _mmc_detect_card_removed()
2123 mmc_card_set_removed(host->card); in _mmc_detect_card_removed()
2124 pr_debug("%s: card remove detected\n", mmc_hostname(host)); in _mmc_detect_card_removed()
2130 int mmc_detect_card_removed(struct mmc_host *host) in mmc_detect_card_removed() argument
2132 struct mmc_card *card = host->card; in mmc_detect_card_removed()
2135 WARN_ON(!host->claimed); in mmc_detect_card_removed()
2140 if (!mmc_card_is_removable(host)) in mmc_detect_card_removed()
2148 if (!host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL)) in mmc_detect_card_removed()
2151 host->detect_change = 0; in mmc_detect_card_removed()
2153 ret = _mmc_detect_card_removed(host); in mmc_detect_card_removed()
2154 if (ret && (host->caps & MMC_CAP_NEEDS_POLL)) { in mmc_detect_card_removed()
2159 cancel_delayed_work(&host->detect); in mmc_detect_card_removed()
2160 _mmc_detect_change(host, 0, false); in mmc_detect_card_removed()
2172 if ((!(card->host->caps2 & MMC_CAP2_ALT_GPT_TEGRA))) in mmc_card_alternative_gpt_sector()
2179 mmc_card_is_removable(card->host)) in mmc_card_alternative_gpt_sector()
2205 struct mmc_host *host = in mmc_rescan() local
2209 if (host->rescan_disable) in mmc_rescan()
2213 if (!mmc_card_is_removable(host) && host->rescan_entered) in mmc_rescan()
2215 host->rescan_entered = 1; in mmc_rescan()
2217 if (host->trigger_card_event && host->ops->card_event) { in mmc_rescan()
2218 mmc_claim_host(host); in mmc_rescan()
2219 host->ops->card_event(host); in mmc_rescan()
2220 mmc_release_host(host); in mmc_rescan()
2221 host->trigger_card_event = false; in mmc_rescan()
2225 if (host->bus_ops) in mmc_rescan()
2226 host->bus_ops->detect(host); in mmc_rescan()
2228 host->detect_change = 0; in mmc_rescan()
2231 if (host->bus_ops != NULL) in mmc_rescan()
2234 mmc_claim_host(host); in mmc_rescan()
2235 if (mmc_card_is_removable(host) && host->ops->get_cd && in mmc_rescan()
2236 host->ops->get_cd(host) == 0) { in mmc_rescan()
2237 mmc_power_off(host); in mmc_rescan()
2238 mmc_release_host(host); in mmc_rescan()
2243 if (mmc_card_sd_express(host)) { in mmc_rescan()
2244 mmc_release_host(host); in mmc_rescan()
2250 if (freq > host->f_max) { in mmc_rescan()
2253 freq = host->f_max; in mmc_rescan()
2255 if (!mmc_rescan_try_freq(host, max(freq, host->f_min))) in mmc_rescan()
2257 if (freqs[i] <= host->f_min) in mmc_rescan()
2265 host->err_stats[MMC_ERR_CMD_TIMEOUT] = 0; in mmc_rescan()
2266 mmc_release_host(host); in mmc_rescan()
2269 if (host->caps & MMC_CAP_NEEDS_POLL) in mmc_rescan()
2270 mmc_schedule_delayed_work(&host->detect, HZ); in mmc_rescan()
2273 void mmc_start_host(struct mmc_host *host) in mmc_start_host() argument
2275 host->f_init = max(min(freqs[0], host->f_max), host->f_min); in mmc_start_host()
2276 host->rescan_disable = 0; in mmc_start_host()
2278 if (!(host->caps2 & MMC_CAP2_NO_PRESCAN_POWERUP)) { in mmc_start_host()
2279 mmc_claim_host(host); in mmc_start_host()
2280 mmc_power_up(host, host->ocr_avail); in mmc_start_host()
2281 mmc_release_host(host); in mmc_start_host()
2284 mmc_gpiod_request_cd_irq(host); in mmc_start_host()
2285 _mmc_detect_change(host, 0, false); in mmc_start_host()
2288 void __mmc_stop_host(struct mmc_host *host) in __mmc_stop_host() argument
2290 if (host->slot.cd_irq >= 0) { in __mmc_stop_host()
2291 mmc_gpio_set_cd_wake(host, false); in __mmc_stop_host()
2292 disable_irq(host->slot.cd_irq); in __mmc_stop_host()
2295 host->rescan_disable = 1; in __mmc_stop_host()
2296 cancel_delayed_work_sync(&host->detect); in __mmc_stop_host()
2299 void mmc_stop_host(struct mmc_host *host) in mmc_stop_host() argument
2301 __mmc_stop_host(host); in mmc_stop_host()
2304 host->pm_flags = 0; in mmc_stop_host()
2306 if (host->bus_ops) { in mmc_stop_host()
2308 host->bus_ops->remove(host); in mmc_stop_host()
2309 mmc_claim_host(host); in mmc_stop_host()
2310 mmc_detach_bus(host); in mmc_stop_host()
2311 mmc_power_off(host); in mmc_stop_host()
2312 mmc_release_host(host); in mmc_stop_host()
2316 mmc_claim_host(host); in mmc_stop_host()
2317 mmc_power_off(host); in mmc_stop_host()
2318 mmc_release_host(host); in mmc_stop_host()