Skip to content

Commit 1b4b338

Browse files
authoredJun 12, 2024··
【修复】修复ART-PI samrt上读取不到emmc/sd分区问题 (#9051)
Update sd.c
1 parent a12736e commit 1b4b338

File tree

1 file changed

+19
-20
lines changed
  • components/drivers/sdio

1 file changed

+19
-20
lines changed
 

Diff for: ‎components/drivers/sdio/sd.c

+19-20
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,25 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host,
755755
goto err1;
756756
}
757757

758+
/*
759+
* change SD card to the highest supported speed
760+
*/
761+
err = mmcsd_switch(card);
762+
if (err)
763+
goto err1;
764+
765+
/* set bus speed */
766+
max_data_rate = (unsigned int)-1;
767+
if (max_data_rate < card->hs_max_data_rate)
768+
{
769+
max_data_rate = card->hs_max_data_rate;
770+
}
771+
if (max_data_rate < card->max_data_rate)
772+
{
773+
max_data_rate = card->max_data_rate;
774+
}
775+
776+
mmcsd_set_clock(host, max_data_rate);
758777
/*switch bus width*/
759778
if ((host->flags & MMCSD_BUSWIDTH_4) && (card->scr.sd_bus_widths & SD_SCR_BUS_WIDTH_4))
760779
{
@@ -780,26 +799,6 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host,
780799
card->flags |= CARD_FLAG_SDR50 | CARD_FLAG_SDR104 | CARD_FLAG_DDR50;
781800
}
782801

783-
/*
784-
* change SD card to the highest supported speed
785-
*/
786-
err = mmcsd_switch(card);
787-
if (err)
788-
goto err1;
789-
790-
/* set bus speed */
791-
max_data_rate = (unsigned int)-1;
792-
if (max_data_rate < card->hs_max_data_rate)
793-
{
794-
max_data_rate = card->hs_max_data_rate;
795-
}
796-
if (max_data_rate < card->max_data_rate)
797-
{
798-
max_data_rate = card->max_data_rate;
799-
}
800-
801-
mmcsd_set_clock(host, max_data_rate);
802-
803802
host->card = card;
804803

805804
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.