[sdio]开启emmc内部cache加快传输 (#7896)

This commit is contained in:
heyuanjie87 2023-08-01 01:48:50 -05:00 committed by GitHub
parent 43e0423b7b
commit a98b11747f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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);