MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / init_mmc

Function init_mmc

components/drivers/sdio/dev_mmc.c:741–792  ·  view source on GitHub ↗

* Starting point for mmc card init. */

Source from the content-addressed store, hash-verified

739 * Starting point for mmc card init.
740 */
741rt_int32_t init_mmc(struct rt_mmcsd_host *host, rt_uint32_t ocr)
742{
743 rt_int32_t err;
744 rt_uint32_t current_ocr;
745 /*
746 * We need to get OCR a different way for SPI.
747 */
748 if (controller_is_spi(host))
749 {
750 err = mmcsd_spi_read_ocr(host, 0, &ocr);
751 if (err)
752 goto err;
753 }
754
755 current_ocr = mmcsd_select_voltage(host, ocr);
756
757 /*
758 * Can we support the voltage(s) of the card(s)?
759 */
760 if (!current_ocr)
761 {
762 err = -RT_ERROR;
763 goto err;
764 }
765
766 /*
767 * Detect and init the card.
768 */
769 err = mmcsd_mmc_init_card(host, current_ocr);
770 if (err)
771 goto err;
772
773 mmcsd_host_unlock(host);
774
775 err = rt_mmcsd_blk_probe(host->card);
776 if (err)
777 goto remove_card;
778 mmcsd_host_lock(host);
779
780 return 0;
781
782remove_card:
783 mmcsd_host_lock(host);
784 rt_mmcsd_blk_remove(host->card);
785 rt_free(host->card);
786 host->card = RT_NULL;
787err:
788
789 LOG_E("init MMC card failed!");
790
791 return err;
792}

Callers 1

mmcsd_detectFunction · 0.85

Calls 8

mmcsd_spi_read_ocrFunction · 0.85
mmcsd_select_voltageFunction · 0.85
mmcsd_mmc_init_cardFunction · 0.85
mmcsd_host_unlockFunction · 0.85
rt_mmcsd_blk_probeFunction · 0.85
mmcsd_host_lockFunction · 0.85
rt_mmcsd_blk_removeFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected