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

Function mmc_switch_to_hs400

components/drivers/sdio/dev_mmc.c:508–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506}
507
508static int mmc_switch_to_hs400(struct rt_mmcsd_card *card)
509{
510 struct rt_mmcsd_host *host = card->host;
511 int err;
512 rt_uint8_t ext_csd_bus_width;
513 rt_uint32_t hs_timing;
514
515 /* Switch to HS_TIMING to 0x01 (High Speed) */
516 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
517 EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS);
518 if (err != RT_EOK)
519 {
520 return err;
521 }
522 mmcsd_set_timing(card->host, MMCSD_TIMING_MMC_HS);
523 /* Host changes frequency to <= 52MHz */
524 mmcsd_set_clock(card->host, 52000000);
525
526 rt_bool_t support_enhanced_ds = ((card->ext_csd.enhanced_data_strobe != 0) &&
527 ((host->flags & MMCSD_SUP_ENH_DS) != 0));
528
529 /* Set the bus width to:
530 * 0x86 if enhanced data strobe is supported, or
531 * 0x06 if enhanced data strobe is not supported
532 */
533 ext_csd_bus_width = support_enhanced_ds ?
534 EXT_CSD_DDR_BUS_WIDTH_8_EH_DS :
535 EXT_CSD_DDR_BUS_WIDTH_8;
536
537 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
538 EXT_CSD_BUS_WIDTH,
539 ext_csd_bus_width);
540 if (err != RT_EOK)
541 {
542 return err;
543 }
544
545 /* Set HS_TIMING to 0x03 (HS400) */
546 err = mmc_switch(card,
547 EXT_CSD_CMD_SET_NORMAL,
548 EXT_CSD_HS_TIMING,
549 EXT_CSD_TIMING_HS400);
550 if (err != RT_EOK)
551 {
552 return err;
553 }
554
555 /* Change the Host timing accordingly */
556 hs_timing = support_enhanced_ds ?
557 MMCSD_TIMING_MMC_HS400_ENH_DS :
558 MMCSD_TIMING_MMC_HS400;
559 mmcsd_set_timing(host, hs_timing);
560
561 /* Host may changes frequency to <= 200MHz */
562 mmcsd_set_clock(card->host, card->max_data_rate);
563
564 return RT_EOK;
565}

Callers 1

mmc_select_hs400Function · 0.85

Calls 3

mmcsd_set_timingFunction · 0.85
mmcsd_set_clockFunction · 0.85
mmc_switchFunction · 0.70

Tested by

no test coverage detected