Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion components/drivers/include/drivers/mmcsd_card.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions components/drivers/sdio/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down