From 50cad1536d782fd50a6b45f6a9766ef995d47d51 Mon Sep 17 00:00:00 2001 From: wanggang26 Date: Fri, 22 Sep 2023 22:43:27 +0800 Subject: [PATCH] emmc: add get emmc cid register interface. Signed-off-by: wanggang26 --- drivers/mmcsd/mmcsd_sdio.c | 68 +++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index 21c2734e79..50b2f31d70 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -3161,46 +3161,52 @@ static int mmcsd_general_cmd_read(FAR struct mmcsd_state_s *priv, static int mmcsd_iocmd(FAR struct mmcsd_state_s *priv, FAR struct mmc_ioc_cmd *ic_ptr) { + uint32_t opcode; int ret; DEBUGASSERT(priv != NULL && ic_ptr != NULL); - if (!ic_ptr->is_acmd) + opcode = ic_ptr->opcode & MMCSD_CMDIDX_MASK; + switch (opcode) { - uint32_t opcode = ic_ptr->opcode & MMCSD_CMDIDX_MASK; - switch (opcode) - { - case MMCSD_CMDIDX56: /* support general commands */ + case MMCSD_CMDIDX2: + { + memcpy((FAR void *)(uintptr_t)ic_ptr->data_ptr, + priv->cid, sizeof(priv->cid)); + } + break; + case MMCSD_CMDIDX56: /* support general commands */ + { + if (ic_ptr->write_flag) { - if (ic_ptr->write_flag) + ret = mmcsd_general_cmd_write(priv, + (FAR uint8_t *)(uintptr_t)(ic_ptr->data_ptr), + ic_ptr->arg); + if (ret != OK) { - ret = mmcsd_general_cmd_write(priv, - (FAR uint8_t *)(uintptr_t)(ic_ptr->data_ptr), - ic_ptr->arg); - if (ret != OK) - { - ferr("mmcsd_iocmd MMCSD_CMDIDX56 write failed.\n"); - return ret; - } - } - else - { - ret = mmcsd_general_cmd_read(priv, - (FAR uint8_t *)(uintptr_t)(ic_ptr->data_ptr), - ic_ptr->arg); - if (ret != OK) - { - ferr("mmcsd_iocmd MMCSD_CMDIDX56 read failed.\n"); - return ret; - } + ferr("mmcsd_iocmd MMCSD_CMDIDX56 write failed.\n"); + return ret; } } - break; - - default: - ferr("mmcsd_iocmd opcode unsupported.\n"); - return -EINVAL; - } + else + { + ret = mmcsd_general_cmd_read(priv, + (FAR uint8_t *)(uintptr_t)(ic_ptr->data_ptr), + ic_ptr->arg); + if (ret != OK) + { + ferr("mmcsd_iocmd MMCSD_CMDIDX56 read failed.\n"); + return ret; + } + } + } + break; + default: + { + ferr("mmcsd_iocmd opcode unsupported.\n"); + return -EINVAL; + } + break; } return OK;