1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2011-07-25 weety first version 9 */ 10 11 #ifndef __CMD_H__ 12 #define __CMD_H__ 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 /* class 1 */ 19 #define GO_IDLE_STATE 0 /* bc */ 20 #define SEND_OP_COND 1 /* bcr [31:0] OCR R3 */ 21 #define ALL_SEND_CID 2 /* bcr R2 */ 22 #define SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */ 23 #define SET_DSR 4 /* bc [31:16] RCA */ 24 #define SWITCH 6 /* ac [31:0] See below R1b */ 25 #define SELECT_CARD 7 /* ac [31:16] RCA R1 */ 26 #define SEND_EXT_CSD 8 /* adtc R1 */ 27 #define SEND_CSD 9 /* ac [31:16] RCA R2 */ 28 #define SEND_CID 10 /* ac [31:16] RCA R2 */ 29 #define READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */ 30 #define STOP_TRANSMISSION 12 /* ac R1b */ 31 #define SEND_STATUS 13 /* ac [31:16] RCA R1 */ 32 #define GO_INACTIVE_STATE 15 /* ac [31:16] RCA */ 33 #define SPI_READ_OCR 58 /* spi spi_R3 */ 34 #define SPI_CRC_ON_OFF 59 /* spi [0:0] flag spi_R1 */ 35 36 /* class 2 */ 37 #define SET_BLOCKLEN 16 /* ac [31:0] block len R1 */ 38 #define READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */ 39 #define READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */ 40 41 /* class 3 */ 42 #define WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ 43 44 /* class 4 */ 45 #define SET_BLOCK_COUNT 23 /* adtc [31:0] data addr R1 */ 46 #define WRITE_BLOCK 24 /* adtc [31:0] data addr R1 */ 47 #define WRITE_MULTIPLE_BLOCK 25 /* adtc R1 */ 48 #define PROGRAM_CID 26 /* adtc R1 */ 49 #define PROGRAM_CSD 27 /* adtc R1 */ 50 51 /* class 6 */ 52 #define SET_WRITE_PROT 28 /* ac [31:0] data addr R1b */ 53 #define CLR_WRITE_PROT 29 /* ac [31:0] data addr R1b */ 54 #define SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */ 55 56 /* class 5 */ 57 #define ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */ 58 #define ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */ 59 #define ERASE 38 /* ac R1b */ 60 61 /* class 9 */ 62 #define FAST_IO 39 /* ac <Complex> R4 */ 63 #define GO_IRQ_STATE 40 /* bcr R5 */ 64 65 /* class 7 */ 66 #define LOCK_UNLOCK 42 /* adtc R1b */ 67 68 /* class 8 */ 69 #define APP_CMD 55 /* ac [31:16] RCA R1 */ 70 #define GEN_CMD 56 /* adtc [0] RD/WR R1 */ 71 72 73 /* SD commands type argument response */ 74 /* class 0 */ 75 /* This is basically the same command as for MMC with some quirks. */ 76 #define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */ 77 #define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */ 78 79 /* class 10 */ 80 #define SD_SWITCH 6 /* adtc [31:0] See below R1 */ 81 82 /* Application commands */ 83 #define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */ 84 #define SD_APP_SEND_NUM_WR_BLKS 22 /* adtc R1 */ 85 #define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */ 86 #define SD_APP_SEND_SCR 51 /* adtc R1 */ 87 88 #define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */ 89 #define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */ 90 #define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */ 91 92 93 /* SDIO commands type argument response */ 94 #define SD_IO_SEND_OP_COND 5 /* bcr [23:0] OCR R4 */ 95 #define SD_IO_RW_DIRECT 52 /* ac [31:0] See below R5 */ 96 #define SD_IO_RW_EXTENDED 53 /* adtc [31:0] See below R5 */ 97 98 99 /* CMD52 arguments */ 100 #define SDIO_ARG_CMD52_READ (0<<31) 101 #define SDIO_ARG_CMD52_WRITE (1u<<31) 102 #define SDIO_ARG_CMD52_FUNC_SHIFT 28 103 #define SDIO_ARG_CMD52_FUNC_MASK 0x7 104 #define SDIO_ARG_CMD52_RAW_FLAG (1u<<27) 105 #define SDIO_ARG_CMD52_REG_SHIFT 9 106 #define SDIO_ARG_CMD52_REG_MASK 0x1ffff 107 #define SDIO_ARG_CMD52_DATA_SHIFT 0 108 #define SDIO_ARG_CMD52_DATA_MASK 0xff 109 #define SDIO_R5_DATA(resp) ((resp)[0] & 0xff) 110 111 /* CMD53 arguments */ 112 #define SDIO_ARG_CMD53_READ (0<<31) 113 #define SDIO_ARG_CMD53_WRITE (1u<<31) 114 #define SDIO_ARG_CMD53_FUNC_SHIFT 28 115 #define SDIO_ARG_CMD53_FUNC_MASK 0x7 116 #define SDIO_ARG_CMD53_BLOCK_MODE (1u<<27) 117 #define SDIO_ARG_CMD53_INCREMENT (1u<<26) 118 #define SDIO_ARG_CMD53_REG_SHIFT 9 119 #define SDIO_ARG_CMD53_REG_MASK 0x1ffff 120 #define SDIO_ARG_CMD53_LENGTH_SHIFT 0 121 #define SDIO_ARG_CMD53_LENGTH_MASK 0x1ff 122 #define SDIO_ARG_CMD53_LENGTH_MAX 511 123 124 125 #ifdef __cplusplus 126 } 127 #endif 128 129 #endif 130