From a98b11747fc6b4cd25abaf3b6a896ff4ee574976 Mon Sep 17 00:00:00 2001 From: heyuanjie87 Date: Tue, 1 Aug 2023 01:48:50 -0500 Subject: [PATCH] =?UTF-8?q?[sdio]=E5=BC=80=E5=90=AFemmc=E5=86=85=E9=83=A8c?= =?UTF-8?q?ache=E5=8A=A0=E5=BF=AB=E4=BC=A0=E8=BE=93=20(#7896)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/include/drivers/mmcsd_card.h | 7 ++++++- components/drivers/sdio/mmc.c | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/components/drivers/include/drivers/mmcsd_card.h b/components/drivers/include/drivers/mmcsd_card.h index da10d1ecc6..d348c9affa 100644 --- a/components/drivers/include/drivers/mmcsd_card.h +++ b/components/drivers/include/drivers/mmcsd_card.h @@ -127,7 +127,10 @@ struct rt_sdio_function { #define SDIO_MAX_FUNCTIONS 7 - +struct rt_mmc_ext_csd +{ + rt_uint32_t cache_size; +}; struct rt_mmcsd_card { struct rt_mmcsd_host *host; @@ -164,6 +167,8 @@ struct rt_mmcsd_card { struct rt_sdio_cis cis; /* common tuple info */ struct rt_sdio_function *sdio_function[SDIO_MAX_FUNCTIONS + 1]; /* SDIO functions (devices) */ rt_list_t blk_devices; /* for block device list */ + + struct rt_mmc_ext_csd ext_csd; }; #ifdef __cplusplus diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index 567c1a4fa5..47c543396d 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -209,6 +209,12 @@ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) card->hs_max_data_rate = 52000000; } + card->ext_csd.cache_size = + ext_csd[EXT_CSD_CACHE_SIZE + 0] << 0 | + ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 | + ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 | + ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24; + card_capacity = *((rt_uint32_t *)&ext_csd[EXT_CSD_SEC_CNT]); card->card_sec_cnt = card_capacity; card_capacity *= card->card_blksize; @@ -613,6 +619,12 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host, goto err0; } + if (card->ext_csd.cache_size > 0) + { + mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_CACHE_CTRL, 1); + } + host->card = card; rt_free(ext_csd);