drivers/mmcsd/mmcsd_sdio.c|h: optimize macros for setting EXT_CSD
CMD6 can use these macros to set any writable EXT_CSD field, not just the bus width, so optimize these macro definitions to make them general. Signed-off-by: Yinzhe Wu <Yinzhe.Wu@sony.com> Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Reviewed-by: Jacky Cao <Jacky.Cao@sony.com> Tested-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
This commit is contained in:
parent
4f7f751d2a
commit
08ce36d292
@ -2522,8 +2522,7 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mmcsd_sendcmdpoll(priv, MMCSD_CMD6,
|
mmcsd_sendcmdpoll(priv, MMCSD_CMD6,
|
||||||
MMCSD_CMD6_MODE_WRITE_BYTE | MMCSD_CMD6_BUSWIDTH_RW |
|
MMC_CMD6_BUSWIDTH(EXT_CSD_BUS_WIDTH_4));
|
||||||
MMCSD_CMD6_BUS_WIDTH_4);
|
|
||||||
ret = mmcsd_recv_r1(priv, MMCSD_CMD6);
|
ret = mmcsd_recv_r1(priv, MMCSD_CMD6);
|
||||||
|
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
|
@ -40,23 +40,36 @@
|
|||||||
* [23:16] Location of target Byte in EXT_CSD
|
* [23:16] Location of target Byte in EXT_CSD
|
||||||
* [15:08] Value Byte
|
* [15:08] Value Byte
|
||||||
* [07:03] Always 0
|
* [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 MMC_CMD6_CMDSET_SHIFT (0)
|
||||||
# define MMCSD_CMD6_MODE_CMD_SET ((uint32_t)0x00 << MMCSD_CMD6_WRITE_BYTE_SHIFT) /* Change the command set */
|
#define MMC_CMD6_VALUE_SHIFT (8)
|
||||||
# define MMCSD_CMD6_MODE_SET_BITS ((uint32_t)0x01 << MMCSD_CMD6_WRITE_BYTE_SHIFT) /* Set bits which are 1 in value */
|
#define MMC_CMD6_INDEX_SHIFT (16)
|
||||||
# define MMCSD_CMD6_MODE_CLEAR_BITS ((uint32_t)0x02 << MMCSD_CMD6_WRITE_BYTE_SHIFT) /* Clear bits which are 1 in value */
|
#define MMC_CMD6_MODE_SHIFT (24)
|
||||||
# define MMCSD_CMD6_MODE_WRITE_BYTE ((uint32_t)0x03 << MMCSD_CMD6_WRITE_BYTE_SHIFT) /* Set target to value */
|
|
||||||
|
|
||||||
#define MMCSD_CMD6_BUS_WIDTH_SHIFT (8)
|
#define MMC_CMD6_CMDSET(cmdset) ((uint32_t)(cmdset) << MMC_CMD6_CMDSET_SHIFT)
|
||||||
# define MMCSD_CMD6_BUS_WIDTH_1 ((uint32_t)0x00 << MMCSD_CMD6_BUS_WIDTH_SHIFT) /* Card is in 1 bit mode */
|
#define MMC_CMD6_VALUE(value) ((uint32_t)(value) << MMC_CMD6_VALUE_SHIFT)
|
||||||
# define MMCSD_CMD6_BUS_WIDTH_4 ((uint32_t)0x01 << MMCSD_CMD6_BUS_WIDTH_SHIFT) /* Card is in 4 bit mode */
|
#define MMC_CMD6_INDEX(index) ((uint32_t)(index) << MMC_CMD6_INDEX_SHIFT)
|
||||||
# define MMCSD_CMD6_CSD_BUS_WIDTH_8 ((uint32_t)0x02 << MMCSD_CMD6_BUS_WIDTH_SHIFT) /* Card is in 8 bit mode */
|
#define MMC_CMD6_MODE(mode) ((uint32_t)(mode) << MMC_CMD6_MODE_SHIFT)
|
||||||
# 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_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:
|
/* CMD8 Argument:
|
||||||
* [31:12]: Reserved (shall be set to '0')
|
* [31:12]: Reserved (shall be set to '0')
|
||||||
|
Loading…
Reference in New Issue
Block a user