diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index 65357e4400..177ac6ca51 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -2522,8 +2522,7 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv) */ mmcsd_sendcmdpoll(priv, MMCSD_CMD6, - MMCSD_CMD6_MODE_WRITE_BYTE | MMCSD_CMD6_BUSWIDTH_RW | - MMCSD_CMD6_BUS_WIDTH_4); + MMC_CMD6_BUSWIDTH(EXT_CSD_BUS_WIDTH_4)); ret = mmcsd_recv_r1(priv, MMCSD_CMD6); if (ret != OK) diff --git a/drivers/mmcsd/mmcsd_sdio.h b/drivers/mmcsd/mmcsd_sdio.h index e7305c6a3e..4f02e7415a 100644 --- a/drivers/mmcsd/mmcsd_sdio.h +++ b/drivers/mmcsd/mmcsd_sdio.h @@ -40,23 +40,36 @@ * [23:16] Location of target Byte in EXT_CSD * [15:08] Value Byte * [07:03] Always 0 - * [02:00] Command Set + * [02:00] Command Set(Ignored if not used to change the command set) */ -#define MMCSD_CMD6_BUSWIDTH_RWSHIFT (16) -# define MMCSD_CMD6_BUSWIDTH_RW ((uint32_t)0xb7 << MMCSD_CMD6_BUSWIDTH_RWSHIFT) /* R/W */ -#define MMCSD_CMD6_WRITE_BYTE_SHIFT (24) -# define MMCSD_CMD6_MODE_CMD_SET ((uint32_t)0x00 << MMCSD_CMD6_WRITE_BYTE_SHIFT) /* Change the command set */ -# define MMCSD_CMD6_MODE_SET_BITS ((uint32_t)0x01 << MMCSD_CMD6_WRITE_BYTE_SHIFT) /* Set bits which are 1 in value */ -# define MMCSD_CMD6_MODE_CLEAR_BITS ((uint32_t)0x02 << MMCSD_CMD6_WRITE_BYTE_SHIFT) /* Clear bits which are 1 in value */ -# define MMCSD_CMD6_MODE_WRITE_BYTE ((uint32_t)0x03 << MMCSD_CMD6_WRITE_BYTE_SHIFT) /* Set target to value */ +#define MMC_CMD6_CMDSET_SHIFT (0) +#define MMC_CMD6_VALUE_SHIFT (8) +#define MMC_CMD6_INDEX_SHIFT (16) +#define MMC_CMD6_MODE_SHIFT (24) -#define MMCSD_CMD6_BUS_WIDTH_SHIFT (8) -# define MMCSD_CMD6_BUS_WIDTH_1 ((uint32_t)0x00 << MMCSD_CMD6_BUS_WIDTH_SHIFT) /* Card is in 1 bit mode */ -# define MMCSD_CMD6_BUS_WIDTH_4 ((uint32_t)0x01 << MMCSD_CMD6_BUS_WIDTH_SHIFT) /* Card is in 4 bit mode */ -# define MMCSD_CMD6_CSD_BUS_WIDTH_8 ((uint32_t)0x02 << MMCSD_CMD6_BUS_WIDTH_SHIFT) /* Card is in 8 bit mode */ -# define MMCSD_CMD6_DDR_BUS_WIDTH_4 ((uint32_t)0x05 << MMCSD_CMD6_BUS_WIDTH_SHIFT) /* Card is in 4 bit DDR mode */ -# define MMCSD_CMD6_DDR_BUS_WIDTH_8 ((uint32_t)0x06 << MMCSD_CMD6_BUS_WIDTH_SHIFT) /* Card is in 8 bit DDR mode */ +#define MMC_CMD6_CMDSET(cmdset) ((uint32_t)(cmdset) << MMC_CMD6_CMDSET_SHIFT) +#define MMC_CMD6_VALUE(value) ((uint32_t)(value) << MMC_CMD6_VALUE_SHIFT) +#define MMC_CMD6_INDEX(index) ((uint32_t)(index) << MMC_CMD6_INDEX_SHIFT) +#define MMC_CMD6_MODE(mode) ((uint32_t)(mode) << MMC_CMD6_MODE_SHIFT) + +#define MMC_CMD6_MODE_CMD_SET (0x00) /* Change the command set */ +#define MMC_CMD6_MODE_SET_BITS (0x01) /* Set bits which are 1 in value */ +#define MMC_CMD6_MODE_CLEAR_BITS (0x02) /* Clear bits which are 1 in value */ +#define MMC_CMD6_MODE_WRITE_BYTE (0x03) /* Set target to value */ + +#define EXT_CSD_BUS_WIDTH 183 /* WO */ + +/* EXT_CSD_BUS_WIDTH */ +#define EXT_CSD_BUS_WIDTH_1 (0x00) /* Card is in 1 bit mode */ +#define EXT_CSD_BUS_WIDTH_4 (0x01) /* Card is in 4 bit mode */ +#define EXT_CSD_BUS_WIDTH_8 (0x02) /* Card is in 8 bit mode */ +#define EXT_CSD_DDR_BUS_WIDTH_4 (0x05) /* Card is in 4 bit DDR mode */ +#define EXT_CSD_DDR_BUS_WIDTH_8 (0x06) /* Card is in 8 bit DDR mode */ + +#define MMC_CMD6_BUSWIDTH(width) (MMC_CMD6_VALUE(width) | \ + MMC_CMD6_INDEX(EXT_CSD_BUS_WIDTH) | \ + MMC_CMD6_MODE(MMC_CMD6_MODE_WRITE_BYTE)) /* CMD8 Argument: * [31:12]: Reserved (shall be set to '0')