Lines Matching refs:host
155 struct rt_mmcsd_host *host = card->host; in mmcsd_switch() local
194 mmcsd_send_request(host, &req); in mmcsd_switch()
209 if ((card->flags & CARD_FLAG_SDR104) && (card->host->flags & MMCSD_SUP_SDR104)) in mmcsd_switch()
213 else if ((card->flags & CARD_FLAG_SDR50) && (card->host->flags & MMCSD_SUP_SDR50)) in mmcsd_switch()
217 else if ((card->flags & CARD_FLAG_DDR50) && (card->host->flags & MMCSD_SUP_DDR50)) in mmcsd_switch()
242 mmcsd_send_request(host, &req); in mmcsd_switch()
278 mmcsd_set_timing(card->host, MMCSD_TIMING_UHS_SDR104); in mmcsd_switch()
279 mmcsd_set_clock(card->host, 208000000); in mmcsd_switch()
286 mmcsd_set_timing(card->host, MMCSD_TIMING_UHS_SDR50); in mmcsd_switch()
287 mmcsd_set_clock(card->host, 100000000); in mmcsd_switch()
294 mmcsd_set_timing(card->host, MMCSD_TIMING_UHS_DDR50); in mmcsd_switch()
295 mmcsd_set_clock(card->host, 50000000); in mmcsd_switch()
300 mmcsd_set_timing(card->host, MMCSD_TIMING_SD_HS); in mmcsd_switch()
301 mmcsd_set_clock(card->host, 50000000); in mmcsd_switch()
317 static rt_err_t mmcsd_app_cmd(struct rt_mmcsd_host *host, in mmcsd_app_cmd() argument
336 err = mmcsd_send_cmd(host, &cmd, 0); in mmcsd_app_cmd()
341 if (!controller_is_spi(host) && !(cmd.resp[0] & R1_APP_CMD)) in mmcsd_app_cmd()
348 rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host, in mmcsd_send_app_cmd() argument
367 err = mmcsd_app_cmd(host, card); in mmcsd_send_app_cmd()
371 if (controller_is_spi(host)) in mmcsd_send_app_cmd()
386 mmcsd_send_request(host, &req); in mmcsd_send_app_cmd()
393 if (controller_is_spi(host)) in mmcsd_send_app_cmd()
425 err = mmcsd_send_app_cmd(card->host, card, &cmd, 3); in mmcsd_app_set_bus_width()
432 rt_err_t mmcsd_send_app_op_cond(struct rt_mmcsd_host *host, in mmcsd_send_app_op_cond() argument
443 if (controller_is_spi(host)) in mmcsd_send_app_op_cond()
451 err = mmcsd_send_app_cmd(host, RT_NULL, &cmd, 3); in mmcsd_send_app_op_cond()
460 if (controller_is_spi(host)) in mmcsd_send_app_op_cond()
476 if (rocr && !controller_is_spi(host)) in mmcsd_send_app_op_cond()
487 rt_err_t mmcsd_send_if_cond(struct rt_mmcsd_host *host, rt_uint32_t ocr) in mmcsd_send_if_cond() argument
497 err = mmcsd_send_cmd(host, &cmd, 0); in mmcsd_send_if_cond()
501 if (controller_is_spi(host)) in mmcsd_send_if_cond()
512 rt_err_t mmcsd_get_card_addr(struct rt_mmcsd_host *host, rt_uint32_t *rca) in mmcsd_get_card_addr() argument
523 err = mmcsd_send_cmd(host, &cmd, 3); in mmcsd_get_card_addr()
545 err = mmcsd_app_cmd(card->host, card); in mmcsd_get_scr()
567 mmcsd_send_request(card->host, &req); in mmcsd_get_scr()
587 err = mmcsd_app_cmd(card->host, card); in mmcsd_read_sd_status()
609 mmcsd_send_request(card->host, &req); in mmcsd_read_sd_status()
632 static rt_err_t sd_switch_voltage(struct rt_mmcsd_host *host) in sd_switch_voltage() argument
641 err = mmcsd_send_cmd(host, &cmd, 0); in sd_switch_voltage()
648 static rt_err_t sd_switch_uhs_voltage(struct rt_mmcsd_host *host) in sd_switch_uhs_voltage() argument
650 if (host->ops->switch_uhs_voltage != RT_NULL) in sd_switch_uhs_voltage()
652 return host->ops->switch_uhs_voltage(host); in sd_switch_uhs_voltage()
657 static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host, in mmcsd_sd_init_card() argument
665 mmcsd_go_idle(host); in mmcsd_sd_init_card()
673 err = mmcsd_send_if_cond(host, ocr); in mmcsd_sd_init_card()
678 if (((host->valid_ocr & VDD_165_195) != 0) && (host->ops->switch_uhs_voltage != RT_NULL)) in mmcsd_sd_init_card()
682 err = mmcsd_send_app_op_cond(host, ocr, &ocr); in mmcsd_sd_init_card()
690 err = sd_switch_voltage(host); in mmcsd_sd_init_card()
693 err = sd_switch_uhs_voltage(host); in mmcsd_sd_init_card()
698 if (controller_is_spi(host)) in mmcsd_sd_init_card()
699 err = mmcsd_get_cid(host, resp); in mmcsd_sd_init_card()
701 err = mmcsd_all_get_cid(host, resp); in mmcsd_sd_init_card()
715 card->host = host; in mmcsd_sd_init_card()
721 if (!controller_is_spi(host)) in mmcsd_sd_init_card()
723 err = mmcsd_get_card_addr(host, &card->rca); in mmcsd_sd_init_card()
727 mmcsd_set_bus_mode(host, MMCSD_BUSMODE_PUSHPULL); in mmcsd_sd_init_card()
738 if (!controller_is_spi(host)) in mmcsd_sd_init_card()
751 if (controller_is_spi(host)) in mmcsd_sd_init_card()
753 err = mmcsd_spi_use_crc(host, 1); in mmcsd_sd_init_card()
758 mmcsd_set_timing(host, MMCSD_TIMING_LEGACY); in mmcsd_sd_init_card()
759 mmcsd_set_clock(host, 25000000); in mmcsd_sd_init_card()
761 if ((host->flags & MMCSD_BUSWIDTH_4) && (card->scr.sd_bus_widths & SD_SCR_BUS_WIDTH_4)) in mmcsd_sd_init_card()
767 mmcsd_set_bus_width(host, MMCSD_BUS_WIDTH_4); in mmcsd_sd_init_card()
801 mmcsd_set_clock(host, max_data_rate); in mmcsd_sd_init_card()
802 host->card = card; in mmcsd_sd_init_card()
816 rt_int32_t init_sd(struct rt_mmcsd_host *host, rt_uint32_t ocr) in init_sd() argument
823 if (controller_is_spi(host)) in init_sd()
825 mmcsd_go_idle(host); in init_sd()
827 err = mmcsd_spi_read_ocr(host, 0, &ocr); in init_sd()
832 current_ocr = mmcsd_select_voltage(host, ocr); in init_sd()
846 err = mmcsd_sd_init_card(host, current_ocr); in init_sd()
850 mmcsd_host_unlock(host); in init_sd()
852 err = rt_mmcsd_blk_probe(host->card); in init_sd()
855 mmcsd_host_lock(host); in init_sd()
860 mmcsd_host_lock(host); in init_sd()
861 rt_mmcsd_blk_remove(host->card); in init_sd()
862 rt_free(host->card); in init_sd()
863 host->card = RT_NULL; in init_sd()