Lines Matching refs:host

45 	struct mmc_host *host;  member
49 static int sd_uhs2_power_up(struct mmc_host *host) in sd_uhs2_power_up() argument
51 if (host->ios.power_mode == MMC_POWER_ON) in sd_uhs2_power_up()
54 host->ios.vdd = fls(host->ocr_avail) - 1; in sd_uhs2_power_up()
55 host->ios.clock = host->f_init; in sd_uhs2_power_up()
56 host->ios.timing = MMC_TIMING_UHS2_SPEED_A; in sd_uhs2_power_up()
57 host->ios.power_mode = MMC_POWER_ON; in sd_uhs2_power_up()
59 return host->ops->uhs2_control(host, UHS2_SET_IOS); in sd_uhs2_power_up()
62 static int sd_uhs2_power_off(struct mmc_host *host) in sd_uhs2_power_off() argument
66 if (host->ios.power_mode == MMC_POWER_OFF) in sd_uhs2_power_off()
69 host->ios.vdd = 0; in sd_uhs2_power_off()
70 host->ios.clock = 0; in sd_uhs2_power_off()
71 host->ios.power_mode = MMC_POWER_OFF; in sd_uhs2_power_off()
72 host->uhs2_sd_tran = false; in sd_uhs2_power_off()
74 err = host->ops->uhs2_control(host, UHS2_SET_IOS); in sd_uhs2_power_off()
79 host->ios.timing = MMC_TIMING_LEGACY; in sd_uhs2_power_off()
88 static int sd_uhs2_phy_init(struct mmc_host *host) in sd_uhs2_phy_init() argument
92 err = host->ops->uhs2_control(host, UHS2_PHY_INIT); in sd_uhs2_phy_init()
95 mmc_hostname(host)); in sd_uhs2_phy_init()
137 static int sd_uhs2_dev_init(struct mmc_host *host) in sd_uhs2_dev_init() argument
147 dap = host->uhs2_caps.dap; in sd_uhs2_dev_init()
148 gap = host->uhs2_caps.gap; in sd_uhs2_dev_init()
189 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_dev_init()
193 mmc_hostname(host), __func__, err); in sd_uhs2_dev_init()
199 mmc_hostname(host)); in sd_uhs2_dev_init()
204 host->uhs2_caps.group_desc = gd; in sd_uhs2_dev_init()
214 mmc_hostname(host), __func__, err); in sd_uhs2_dev_init()
226 static int sd_uhs2_enum(struct mmc_host *host, u32 *node_id) in sd_uhs2_enum() argument
254 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_enum()
257 mmc_hostname(host), __func__, err); in sd_uhs2_enum()
263 mmc_hostname(host)); in sd_uhs2_enum()
279 static int sd_uhs2_config_read(struct mmc_host *host, struct mmc_card *card) in sd_uhs2_config_read() argument
306 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_config_read()
309 mmc_hostname(host), __func__, err); in sd_uhs2_config_read()
354 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_config_read()
357 mmc_hostname(host), __func__, err); in sd_uhs2_config_read()
411 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_config_read()
414 mmc_hostname(host), __func__, err); in sd_uhs2_config_read()
467 static int sd_uhs2_config_write(struct mmc_host *host, struct mmc_card *card) in sd_uhs2_config_write() argument
491 host->uhs2_caps.n_lanes_set = UHS2_DEV_CONFIG_GEN_SET_2L_FD_HD; in sd_uhs2_config_write()
508 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_config_write()
511 mmc_hostname(host), __func__, err); in sd_uhs2_config_write()
526 if (host->uhs2_caps.speed_range == UHS2_DEV_CONFIG_PHY_SET_SPEED_B) { in sd_uhs2_config_write()
528 host->uhs2_caps.n_lanes == UHS2_DEV_CONFIG_2L_HD_FD) { in sd_uhs2_config_write()
530 host->ios.timing = MMC_TIMING_UHS2_SPEED_B_HD; in sd_uhs2_config_write()
534 host->ios.timing = MMC_TIMING_UHS2_SPEED_B; in sd_uhs2_config_write()
540 host->uhs2_caps.n_lanes == UHS2_DEV_CONFIG_2L_HD_FD) { in sd_uhs2_config_write()
542 host->ios.timing = MMC_TIMING_UHS2_SPEED_A_HD; in sd_uhs2_config_write()
546 host->ios.timing = MMC_TIMING_UHS2_SPEED_A; in sd_uhs2_config_write()
555 host->uhs2_caps.n_lss_sync) >> 2) & in sd_uhs2_config_write()
557 host->uhs2_caps.n_lss_sync_set = card->uhs2_config.n_lss_sync_set; in sd_uhs2_config_write()
560 host->uhs2_caps.n_lss_dir) >> 3) & in sd_uhs2_config_write()
562 host->uhs2_caps.n_lss_dir_set = card->uhs2_config.n_lss_dir_set; in sd_uhs2_config_write()
574 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_config_write()
577 mmc_hostname(host), __func__, err); in sd_uhs2_config_write()
583 mmc_hostname(host), __func__, uhs2_cmd.uhs2_resp[2]); in sd_uhs2_config_write()
602 host->uhs2_caps.maxblk_len); in sd_uhs2_config_write()
603 host->uhs2_caps.maxblk_len_set = card->uhs2_config.maxblk_len_set; in sd_uhs2_config_write()
605 card->uhs2_config.n_fcu_set = min(card->uhs2_config.n_fcu, host->uhs2_caps.n_fcu); in sd_uhs2_config_write()
606 host->uhs2_caps.n_fcu_set = card->uhs2_config.n_fcu_set; in sd_uhs2_config_write()
609 host->uhs2_caps.n_data_gap_set = card->uhs2_config.n_data_gap_set; in sd_uhs2_config_write()
611 host->uhs2_caps.max_retry_set = 3; in sd_uhs2_config_write()
612 card->uhs2_config.max_retry_set = host->uhs2_caps.max_retry_set; in sd_uhs2_config_write()
623 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_config_write()
626 mmc_hostname(host), __func__, err); in sd_uhs2_config_write()
655 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_config_write()
658 mmc_hostname(host), __func__, err); in sd_uhs2_config_write()
663 err = host->ops->uhs2_control(host, UHS2_SET_CONFIG); in sd_uhs2_config_write()
665 pr_err("%s: %s: UHS2 SET_CONFIG fail!\n", mmc_hostname(host), __func__); in sd_uhs2_config_write()
672 static int sd_uhs2_go_dormant(struct mmc_host *host, u32 node_id) in sd_uhs2_go_dormant() argument
679 err = host->ops->uhs2_control(host, UHS2_DISABLE_INT); in sd_uhs2_go_dormant()
682 mmc_hostname(host), __func__); in sd_uhs2_go_dormant()
704 err = mmc_wait_for_cmd(host, &cmd, 0); in sd_uhs2_go_dormant()
707 mmc_hostname(host), __func__, err); in sd_uhs2_go_dormant()
712 err = host->ops->uhs2_control(host, UHS2_CHECK_DORMANT); in sd_uhs2_go_dormant()
717 err = host->ops->uhs2_control(host, UHS2_DISABLE_CLK); in sd_uhs2_go_dormant()
723 err = host->ops->uhs2_control(host, UHS2_ENABLE_CLK); in sd_uhs2_go_dormant()
728 err = host->ops->uhs2_control(host, UHS2_ENABLE_INT); in sd_uhs2_go_dormant()
733 err = host->ops->uhs2_control(host, UHS2_PHY_INIT); in sd_uhs2_go_dormant()
743 struct mmc_host *host = data->host; in sd_uhs2_wait_active_state_cb() local
747 err = mmc_wait_for_cmd(host, cmd, 0); in sd_uhs2_wait_active_state_cb()
759 static int sd_uhs2_go_dormant_state(struct mmc_host *host, u32 node_id) in sd_uhs2_go_dormant_state() argument
765 .host = host, in sd_uhs2_go_dormant_state()
769 err = sd_uhs2_go_dormant(host, node_id); in sd_uhs2_go_dormant_state()
772 mmc_hostname(host), __func__, err); in sd_uhs2_go_dormant_state()
790 err = __mmc_poll_for_busy(host, UHS2_WAIT_CFG_COMPLETE_PERIOD_US, in sd_uhs2_go_dormant_state()
794 pr_err("%s: %s: Not switch to Active in 100 ms\n", mmc_hostname(host), __func__); in sd_uhs2_go_dormant_state()
805 static int sd_uhs2_init_card(struct mmc_host *host, struct mmc_card *oldcard) in sd_uhs2_init_card() argument
811 err = sd_uhs2_dev_init(host); in sd_uhs2_init_card()
815 err = sd_uhs2_enum(host, &node_id); in sd_uhs2_init_card()
822 card = mmc_alloc_card(host, &sd_type); in sd_uhs2_init_card()
830 err = sd_uhs2_config_read(host, card); in sd_uhs2_init_card()
834 err = sd_uhs2_config_write(host, card); in sd_uhs2_init_card()
839 if (host->ios.timing == MMC_TIMING_UHS2_SPEED_B || in sd_uhs2_init_card()
840 host->ios.timing == MMC_TIMING_UHS2_SPEED_B_HD) { in sd_uhs2_init_card()
841 err = sd_uhs2_go_dormant_state(host, node_id); in sd_uhs2_init_card()
846 host->uhs2_sd_tran = true; in sd_uhs2_init_card()
847 host->card = card; in sd_uhs2_init_card()
863 static int sd_uhs2_legacy_init(struct mmc_host *host, struct mmc_card *card, in sd_uhs2_legacy_init() argument
874 err = __mmc_go_idle(host); in sd_uhs2_legacy_init()
881 err = mmc_send_if_cond(host, host->ocr_avail); in sd_uhs2_legacy_init()
888 err = mmc_send_app_op_cond(host, 0, &ocr); in sd_uhs2_legacy_init()
899 rocr = mmc_select_voltage(host, ocr); in sd_uhs2_legacy_init()
905 rocr = host->ocr_avail; in sd_uhs2_legacy_init()
912 err = mmc_send_app_op_cond(host, ocr, &rocr); in sd_uhs2_legacy_init()
916 err = mmc_send_cid(host, cid); in sd_uhs2_legacy_init()
923 mmc_hostname(host)); in sd_uhs2_legacy_init()
934 err = mmc_send_relative_addr(host, &card->rca); in sd_uhs2_legacy_init()
971 mmc_hostname(card->host)); in sd_uhs2_legacy_init()
985 ro = mmc_sd_get_ro(host); in sd_uhs2_legacy_init()
988 mmc_hostname(host)); in sd_uhs2_legacy_init()
996 static int sd_uhs2_reinit(struct mmc_host *host) in sd_uhs2_reinit() argument
998 struct mmc_card *card = host->card; in sd_uhs2_reinit()
1001 err = sd_uhs2_power_up(host); in sd_uhs2_reinit()
1005 err = sd_uhs2_phy_init(host); in sd_uhs2_reinit()
1009 err = sd_uhs2_init_card(host, card); in sd_uhs2_reinit()
1013 return sd_uhs2_legacy_init(host, card, true); in sd_uhs2_reinit()
1016 static void sd_uhs2_remove(struct mmc_host *host) in sd_uhs2_remove() argument
1018 mmc_remove_card(host->card); in sd_uhs2_remove()
1019 host->card = NULL; in sd_uhs2_remove()
1022 static int sd_uhs2_alive(struct mmc_host *host) in sd_uhs2_alive() argument
1024 return mmc_send_status(host->card, NULL); in sd_uhs2_alive()
1027 static void sd_uhs2_detect(struct mmc_host *host) in sd_uhs2_detect() argument
1031 mmc_get_card(host->card, NULL); in sd_uhs2_detect()
1032 err = _mmc_detect_card_removed(host); in sd_uhs2_detect()
1033 mmc_put_card(host->card, NULL); in sd_uhs2_detect()
1036 sd_uhs2_remove(host); in sd_uhs2_detect()
1038 mmc_claim_host(host); in sd_uhs2_detect()
1039 mmc_detach_bus(host); in sd_uhs2_detect()
1040 sd_uhs2_power_off(host); in sd_uhs2_detect()
1041 mmc_release_host(host); in sd_uhs2_detect()
1045 static int _sd_uhs2_suspend(struct mmc_host *host) in _sd_uhs2_suspend() argument
1047 struct mmc_card *card = host->card; in _sd_uhs2_suspend()
1049 mmc_claim_host(host); in _sd_uhs2_suspend()
1054 sd_uhs2_power_off(host); in _sd_uhs2_suspend()
1058 mmc_release_host(host); in _sd_uhs2_suspend()
1065 static int sd_uhs2_suspend(struct mmc_host *host) in sd_uhs2_suspend() argument
1069 err = _sd_uhs2_suspend(host); in sd_uhs2_suspend()
1071 pm_runtime_disable(&host->card->dev); in sd_uhs2_suspend()
1072 pm_runtime_set_suspended(&host->card->dev); in sd_uhs2_suspend()
1082 static int _mmc_sd_uhs2_resume(struct mmc_host *host) in _mmc_sd_uhs2_resume() argument
1086 mmc_claim_host(host); in _mmc_sd_uhs2_resume()
1088 if (!mmc_card_suspended(host->card)) in _mmc_sd_uhs2_resume()
1092 err = sd_uhs2_reinit(host); in _mmc_sd_uhs2_resume()
1093 mmc_card_clr_suspended(host->card); in _mmc_sd_uhs2_resume()
1096 mmc_release_host(host); in _mmc_sd_uhs2_resume()
1103 static int sd_uhs2_resume(struct mmc_host *host) in sd_uhs2_resume() argument
1105 pm_runtime_enable(&host->card->dev); in sd_uhs2_resume()
1112 static int sd_uhs2_runtime_suspend(struct mmc_host *host) in sd_uhs2_runtime_suspend() argument
1116 if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) in sd_uhs2_runtime_suspend()
1119 err = _sd_uhs2_suspend(host); in sd_uhs2_runtime_suspend()
1121 pr_err("%s: error %d doing aggressive suspend\n", mmc_hostname(host), err); in sd_uhs2_runtime_suspend()
1126 static int sd_uhs2_runtime_resume(struct mmc_host *host) in sd_uhs2_runtime_resume() argument
1130 err = _mmc_sd_uhs2_resume(host); in sd_uhs2_runtime_resume()
1132 pr_err("%s: error %d doing runtime resume\n", mmc_hostname(host), err); in sd_uhs2_runtime_resume()
1137 static int sd_uhs2_hw_reset(struct mmc_host *host) in sd_uhs2_hw_reset() argument
1139 sd_uhs2_power_off(host); in sd_uhs2_hw_reset()
1143 return sd_uhs2_reinit(host); in sd_uhs2_hw_reset()
1158 static int sd_uhs2_attach(struct mmc_host *host) in sd_uhs2_attach() argument
1162 err = sd_uhs2_power_up(host); in sd_uhs2_attach()
1166 err = sd_uhs2_phy_init(host); in sd_uhs2_attach()
1170 err = sd_uhs2_init_card(host, NULL); in sd_uhs2_attach()
1174 err = sd_uhs2_legacy_init(host, host->card, false); in sd_uhs2_attach()
1178 mmc_attach_bus(host, &sd_uhs2_ops); in sd_uhs2_attach()
1180 mmc_release_host(host); in sd_uhs2_attach()
1182 err = mmc_add_card(host->card); in sd_uhs2_attach()
1186 mmc_claim_host(host); in sd_uhs2_attach()
1190 sd_uhs2_remove(host); in sd_uhs2_attach()
1191 mmc_claim_host(host); in sd_uhs2_attach()
1193 mmc_detach_bus(host); in sd_uhs2_attach()
1194 sd_uhs2_power_off(host); in sd_uhs2_attach()
1207 int mmc_attach_sd_uhs2(struct mmc_host *host) in mmc_attach_sd_uhs2() argument
1211 if (!(host->caps2 & MMC_CAP2_SD_UHS2)) in mmc_attach_sd_uhs2()
1215 mmc_power_off(host); in mmc_attach_sd_uhs2()
1223 host->f_init = sd_uhs2_freqs[i]; in mmc_attach_sd_uhs2()
1225 mmc_hostname(host), __func__, host->f_init); in mmc_attach_sd_uhs2()
1226 err = sd_uhs2_attach(host); in mmc_attach_sd_uhs2()
1245 void mmc_uhs2_prepare_cmd(struct mmc_host *host, struct mmc_request *mrq) in mmc_uhs2_prepare_cmd() argument
1254 uhs2_cmd->header = host->card->uhs2_config.node_id; in mmc_uhs2_prepare_cmd()
1261 if (host->uhs2_app_cmd) { in mmc_uhs2_prepare_cmd()
1263 host->uhs2_app_cmd = false; in mmc_uhs2_prepare_cmd()
1275 cmd->uhs2_cmd->tmode_half_duplex = mmc_card_uhs2_hd_mode(host); in mmc_uhs2_prepare_cmd()
1284 if (mmc_card_uhs2_hd_mode(host)) in mmc_uhs2_prepare_cmd()