mmcsd_cmd.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * File : mmcsd_cmd.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-07-25 weety first version
  23. */
  24. #ifndef __CMD_H__
  25. #define __CMD_H__
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /* class 1 */
  30. #define GO_IDLE_STATE 0 /* bc */
  31. #define SEND_OP_COND 1 /* bcr [31:0] OCR R3 */
  32. #define ALL_SEND_CID 2 /* bcr R2 */
  33. #define SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */
  34. #define SET_DSR 4 /* bc [31:16] RCA */
  35. #define SWITCH 6 /* ac [31:0] See below R1b */
  36. #define SELECT_CARD 7 /* ac [31:16] RCA R1 */
  37. #define SEND_EXT_CSD 8 /* adtc R1 */
  38. #define SEND_CSD 9 /* ac [31:16] RCA R2 */
  39. #define SEND_CID 10 /* ac [31:16] RCA R2 */
  40. #define READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
  41. #define STOP_TRANSMISSION 12 /* ac R1b */
  42. #define SEND_STATUS 13 /* ac [31:16] RCA R1 */
  43. #define GO_INACTIVE_STATE 15 /* ac [31:16] RCA */
  44. #define SPI_READ_OCR 58 /* spi spi_R3 */
  45. #define SPI_CRC_ON_OFF 59 /* spi [0:0] flag spi_R1 */
  46. /* class 2 */
  47. #define SET_BLOCKLEN 16 /* ac [31:0] block len R1 */
  48. #define READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */
  49. #define READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */
  50. /* class 3 */
  51. #define WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
  52. /* class 4 */
  53. #define SET_BLOCK_COUNT 23 /* adtc [31:0] data addr R1 */
  54. #define WRITE_BLOCK 24 /* adtc [31:0] data addr R1 */
  55. #define WRITE_MULTIPLE_BLOCK 25 /* adtc R1 */
  56. #define PROGRAM_CID 26 /* adtc R1 */
  57. #define PROGRAM_CSD 27 /* adtc R1 */
  58. /* class 6 */
  59. #define SET_WRITE_PROT 28 /* ac [31:0] data addr R1b */
  60. #define CLR_WRITE_PROT 29 /* ac [31:0] data addr R1b */
  61. #define SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */
  62. /* class 5 */
  63. #define ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */
  64. #define ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */
  65. #define ERASE 38 /* ac R1b */
  66. /* class 9 */
  67. #define FAST_IO 39 /* ac <Complex> R4 */
  68. #define GO_IRQ_STATE 40 /* bcr R5 */
  69. /* class 7 */
  70. #define LOCK_UNLOCK 42 /* adtc R1b */
  71. /* class 8 */
  72. #define APP_CMD 55 /* ac [31:16] RCA R1 */
  73. #define GEN_CMD 56 /* adtc [0] RD/WR R1 */
  74. /* SD commands type argument response */
  75. /* class 0 */
  76. /* This is basically the same command as for MMC with some quirks. */
  77. #define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */
  78. #define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */
  79. /* class 10 */
  80. #define SD_SWITCH 6 /* adtc [31:0] See below R1 */
  81. /* Application commands */
  82. #define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */
  83. #define SD_APP_SEND_NUM_WR_BLKS 22 /* adtc R1 */
  84. #define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */
  85. #define SD_APP_SEND_SCR 51 /* adtc R1 */
  86. #define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */
  87. #define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */
  88. #define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */
  89. /* SDIO commands type argument response */
  90. #define SD_IO_SEND_OP_COND 5 /* bcr [23:0] OCR R4 */
  91. #define SD_IO_RW_DIRECT 52 /* ac [31:0] See below R5 */
  92. #define SD_IO_RW_EXTENDED 53 /* adtc [31:0] See below R5 */
  93. /* CMD52 arguments */
  94. #define SDIO_ARG_CMD52_READ (0<<31)
  95. #define SDIO_ARG_CMD52_WRITE (1u<<31)
  96. #define SDIO_ARG_CMD52_FUNC_SHIFT 28
  97. #define SDIO_ARG_CMD52_FUNC_MASK 0x7
  98. #define SDIO_ARG_CMD52_RAW_FLAG (1u<<27)
  99. #define SDIO_ARG_CMD52_REG_SHIFT 9
  100. #define SDIO_ARG_CMD52_REG_MASK 0x1ffff
  101. #define SDIO_ARG_CMD52_DATA_SHIFT 0
  102. #define SDIO_ARG_CMD52_DATA_MASK 0xff
  103. #define SDIO_R5_DATA(resp) ((resp)[0] & 0xff)
  104. /* CMD53 arguments */
  105. #define SDIO_ARG_CMD53_READ (0<<31)
  106. #define SDIO_ARG_CMD53_WRITE (1u<<31)
  107. #define SDIO_ARG_CMD53_FUNC_SHIFT 28
  108. #define SDIO_ARG_CMD53_FUNC_MASK 0x7
  109. #define SDIO_ARG_CMD53_BLOCK_MODE (1u<<27)
  110. #define SDIO_ARG_CMD53_INCREMENT (1u<<26)
  111. #define SDIO_ARG_CMD53_REG_SHIFT 9
  112. #define SDIO_ARG_CMD53_REG_MASK 0x1ffff
  113. #define SDIO_ARG_CMD53_LENGTH_SHIFT 0
  114. #define SDIO_ARG_CMD53_LENGTH_MASK 0x1ff
  115. #define SDIO_ARG_CMD53_LENGTH_MAX 511
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif