mmc.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. #ifndef __MMC_H__
  2. #define __MMC_H__
  3. /* Standard MMC commands (4.1) type argument response */
  4. /* class 1 */
  5. #define MMC_GO_IDLE_STATE 0 /* bc */
  6. #define MMC_SEND_OP_COND 1 /* bcr [31:0] OCR R3 */
  7. #define MMC_ALL_SEND_CID 2 /* bcr R2 */
  8. #define MMC_SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */
  9. #define MMC_SET_DSR 4 /* bc [31:16] RCA */
  10. #define MMC_SLEEP_AWAKE 5 /* ac [31:16] RCA 15:flg R1b */
  11. #define MMC_SWITCH 6 /* ac [31:0] See below R1b */
  12. #define MMC_SELECT_CARD 7 /* ac [31:16] RCA R1 */
  13. #define MMC_SEND_EXT_CSD 8 /* adtc R1 */
  14. #define MMC_SEND_CSD 9 /* ac [31:16] RCA R2 */
  15. #define MMC_SEND_CID 10 /* ac [31:16] RCA R2 */
  16. #define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
  17. #define MMC_STOP_TRANSMISSION 12 /* ac R1b */
  18. #define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */
  19. #define MMC_BUS_TEST_R 14 /* adtc R1 */
  20. #define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */
  21. #define MMC_BUS_TEST_W 19 /* adtc R1 */
  22. #define MMC_SPI_READ_OCR 58 /* spi spi_R3 */
  23. #define MMC_SPI_CRC_ON_OFF 59 /* spi [0:0] flag spi_R1 */
  24. /* class 2 */
  25. #define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */
  26. #define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */
  27. #define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */
  28. #define MMC_SEND_TUNING_BLOCK 19 /* adtc R1 */
  29. #define MMC_SEND_TUNING_BLOCK_HS200 21 /* adtc R1 */
  30. /* class 3 */
  31. #define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */
  32. /* class 4 */
  33. #define MMC_SET_BLOCK_COUNT 23 /* adtc [31:0] data addr R1 */
  34. #define MMC_WRITE_BLOCK 24 /* adtc [31:0] data addr R1 */
  35. #define MMC_WRITE_MULTIPLE_BLOCK 25 /* adtc R1 */
  36. #define MMC_PROGRAM_CID 26 /* adtc R1 */
  37. #define MMC_PROGRAM_CSD 27 /* adtc R1 */
  38. /* class 6 */
  39. #define MMC_SET_WRITE_PROT 28 /* ac [31:0] data addr R1b */
  40. #define MMC_CLR_WRITE_PROT 29 /* ac [31:0] data addr R1b */
  41. #define MMC_SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */
  42. /* class 5 */
  43. #define MMC_ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */
  44. #define MMC_ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */
  45. #define MMC_ERASE 38 /* ac R1b */
  46. /* class 9 */
  47. #define MMC_FAST_IO 39 /* ac <Complex> R4 */
  48. #define MMC_GO_IRQ_STATE 40 /* bcr R5 */
  49. /* class 7 */
  50. #define MMC_LOCK_UNLOCK 42 /* adtc R1b */
  51. /* class 8 */
  52. #define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */
  53. #define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1 */
  54. /*
  55. MMC status in R1, for native mode (SPI bits are different)
  56. Type
  57. e : error bit
  58. s : status bit
  59. r : detected and set for the actual command response
  60. x : detected and set during command execution. the host must poll
  61. the card by sending status command in order to read these bits.
  62. Clear condition
  63. a : according to the card state
  64. b : always related to the previous command. Reception of
  65. a valid command will clear it (with a delay of one command)
  66. c : clear by read
  67. */
  68. #define R1_OUT_OF_RANGE (1 << 31) /* er, c */
  69. #define R1_ADDRESS_ERROR (1 << 30) /* erx, c */
  70. #define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */
  71. #define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */
  72. #define R1_ERASE_PARAM (1 << 27) /* ex, c */
  73. #define R1_WP_VIOLATION (1 << 26) /* erx, c */
  74. #define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */
  75. #define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */
  76. #define R1_COM_CRC_ERROR (1 << 23) /* er, b */
  77. #define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */
  78. #define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */
  79. #define R1_CC_ERROR (1 << 20) /* erx, c */
  80. #define R1_ERROR (1 << 19) /* erx, c */
  81. #define R1_UNDERRUN (1 << 18) /* ex, c */
  82. #define R1_OVERRUN (1 << 17) /* ex, c */
  83. #define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */
  84. #define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */
  85. #define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */
  86. #define R1_ERASE_RESET (1 << 13) /* sr, c */
  87. #define R1_STATUS(x) (x & 0xFFFFE000)
  88. #define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */
  89. #define R1_READY_FOR_DATA (1 << 8) /* sx, a */
  90. #define R1_SWITCH_ERROR (1 << 7) /* sx, c */
  91. #define R1_EXCEPTION_EVENT (1 << 6) /* sr, a */
  92. #define R1_APP_CMD (1 << 5) /* sr, c */
  93. #define R1_STATE_IDLE 0
  94. #define R1_STATE_READY 1
  95. #define R1_STATE_IDENT 2
  96. #define R1_STATE_STBY 3
  97. #define R1_STATE_TRAN 4
  98. #define R1_STATE_DATA 5
  99. #define R1_STATE_RCV 6
  100. #define R1_STATE_PRG 7
  101. #define R1_STATE_DIS 8
  102. /*
  103. * OCR register bits
  104. */
  105. #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */
  106. #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */
  107. #define MMC_VDD_21_22 0x00000200 /* VDD voltage 2.1 ~ 2.2 */
  108. #define MMC_VDD_22_23 0x00000400 /* VDD voltage 2.2 ~ 2.3 */
  109. #define MMC_VDD_23_24 0x00000800 /* VDD voltage 2.3 ~ 2.4 */
  110. #define MMC_VDD_24_25 0x00001000 /* VDD voltage 2.4 ~ 2.5 */
  111. #define MMC_VDD_25_26 0x00002000 /* VDD voltage 2.5 ~ 2.6 */
  112. #define MMC_VDD_26_27 0x00004000 /* VDD voltage 2.6 ~ 2.7 */
  113. #define MMC_VDD_27_28 0x00008000 /* VDD voltage 2.7 ~ 2.8 */
  114. #define MMC_VDD_28_29 0x00010000 /* VDD voltage 2.8 ~ 2.9 */
  115. #define MMC_VDD_29_30 0x00020000 /* VDD voltage 2.9 ~ 3.0 */
  116. #define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */
  117. #define MMC_VDD_31_32 0x00080000 /* VDD voltage 3.1 ~ 3.2 */
  118. #define MMC_VDD_32_33 0x00100000 /* VDD voltage 3.2 ~ 3.3 */
  119. #define MMC_VDD_33_34 0x00200000 /* VDD voltage 3.3 ~ 3.4 */
  120. #define MMC_VDD_34_35 0x00400000 /* VDD voltage 3.4 ~ 3.5 */
  121. #define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */
  122. #define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */
  123. /*
  124. * MMC bus width
  125. */
  126. #define MMC_BUS_WIDTH_1 0
  127. #define MMC_BUS_WIDTH_4 2
  128. #define MMC_BUS_WIDTH_8 3
  129. /*
  130. * MMC command flags
  131. */
  132. #define MMC_RSP_PRESENT (1 << 0)
  133. #define MMC_RSP_136 (1 << 1) /* 136 bit response */
  134. #define MMC_RSP_CRC (1 << 2) /* expect valid crc */
  135. #define MMC_RSP_BUSY (1 << 3) /* card may send busy */
  136. #define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */
  137. #define MMC_CMD_MASK (3 << 5) /* non-SPI command type */
  138. #define MMC_CMD_AC (0 << 5)
  139. #define MMC_CMD_ADTC (1 << 5)
  140. #define MMC_CMD_BC (2 << 5)
  141. #define MMC_CMD_BCR (3 << 5)
  142. /*
  143. * These are the native response types, and correspond to valid bit
  144. * patterns of the above flags. One additional valid pattern
  145. * is all zeros, which means we don't expect a response.
  146. */
  147. #define MMC_RSP_NONE (0)
  148. #define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
  149. #define MMC_RSP_R1B (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY)
  150. #define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC)
  151. #define MMC_RSP_R3 (MMC_RSP_PRESENT)
  152. #define MMC_RSP_R4 (MMC_RSP_PRESENT)
  153. #define MMC_RSP_R5 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
  154. #define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
  155. #define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
  156. #define mmc_resp_type(cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
  157. #define MMC_DATA_WRITE (1 << 16)
  158. #define MMC_DATA_READ (1 << 17)
  159. #define MMC_DATA_WRITE_DIRECT (1 << 18)
  160. #define MMC_DATA_READ_DIRECT (1 << 19)
  161. /*
  162. * CSD field definitions
  163. */
  164. #define CSD_STRUCT_VER_1_0 0 /* Valid for system specification 1.0 - 1.2 */
  165. #define CSD_STRUCT_VER_1_1 1 /* Valid for system specification 1.4 - 2.2 */
  166. #define CSD_STRUCT_VER_1_2 2 /* Valid for system specification 3.1 - 3.2 - 3.31 - 4.0 - 4.1 */
  167. #define CSD_STRUCT_EXT_CSD 3 /* Version is coded in CSD_STRUCTURE in EXT_CSD */
  168. #define CSD_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.2 */
  169. #define CSD_SPEC_VER_1 1 /* Implements system specification 1.4 */
  170. #define CSD_SPEC_VER_2 2 /* Implements system specification 2.0 - 2.2 */
  171. #define CSD_SPEC_VER_3 3 /* Implements system specification 3.1 - 3.2 - 3.31 */
  172. #define CSD_SPEC_VER_4 4 /* Implements system specification 4.0 - 4.1 */
  173. /*
  174. * EXT_CSD fields
  175. */
  176. #define EXT_CSD_FLUSH_CACHE 32 /* W */
  177. #define EXT_CSD_CACHE_CTRL 33 /* R/W */
  178. #define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */
  179. #define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */
  180. #define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */
  181. #define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */
  182. #define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */
  183. #define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */
  184. #define EXT_CSD_GP_SIZE_MULT 143 /* R/W */
  185. #define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */
  186. #define EXT_CSD_PARTITION_SUPPORT 160 /* RO */
  187. #define EXT_CSD_HPI_MGMT 161 /* R/W */
  188. #define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
  189. #define EXT_CSD_BKOPS_EN 163 /* R/W */
  190. #define EXT_CSD_BKOPS_START 164 /* W */
  191. #define EXT_CSD_SANITIZE_START 165 /* W */
  192. #define EXT_CSD_WR_REL_PARAM 166 /* RO */
  193. #define EXT_CSD_RPMB_MULT 168 /* RO */
  194. #define EXT_CSD_FW_CONFIG 169 /* R/W */
  195. #define EXT_CSD_BOOT_WP 173 /* R/W */
  196. #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */
  197. #define EXT_CSD_PART_CONFIG 179 /* R/W */
  198. #define EXT_CSD_ERASED_MEM_CONT 181 /* RO */
  199. #define EXT_CSD_BUS_WIDTH 183 /* R/W */
  200. #define EXT_CSD_HS_TIMING 185 /* R/W */
  201. #define EXT_CSD_POWER_CLASS 187 /* R/W */
  202. #define EXT_CSD_REV 192 /* RO */
  203. #define EXT_CSD_STRUCTURE 194 /* RO */
  204. #define EXT_CSD_CARD_TYPE 196 /* RO */
  205. #define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 /* RO */
  206. #define EXT_CSD_PART_SWITCH_TIME 199 /* RO */
  207. #define EXT_CSD_PWR_CL_52_195 200 /* RO */
  208. #define EXT_CSD_PWR_CL_26_195 201 /* RO */
  209. #define EXT_CSD_PWR_CL_52_360 202 /* RO */
  210. #define EXT_CSD_PWR_CL_26_360 203 /* RO */
  211. #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
  212. #define EXT_CSD_S_A_TIMEOUT 217 /* RO */
  213. #define EXT_CSD_REL_WR_SEC_C 222 /* RO */
  214. #define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */
  215. #define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */
  216. #define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
  217. #define EXT_CSD_BOOT_MULT 226 /* RO */
  218. #define EXT_CSD_SEC_TRIM_MULT 229 /* RO */
  219. #define EXT_CSD_SEC_ERASE_MULT 230 /* RO */
  220. #define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */
  221. #define EXT_CSD_TRIM_MULT 232 /* RO */
  222. #define EXT_CSD_PWR_CL_200_195 236 /* RO */
  223. #define EXT_CSD_PWR_CL_200_360 237 /* RO */
  224. #define EXT_CSD_PWR_CL_DDR_52_195 238 /* RO */
  225. #define EXT_CSD_PWR_CL_DDR_52_360 239 /* RO */
  226. #define EXT_CSD_BKOPS_STATUS 246 /* RO */
  227. #define EXT_CSD_POWER_OFF_LONG_TIME 247 /* RO */
  228. #define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */
  229. #define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */
  230. #define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */
  231. #define EXT_CSD_FIRMWARE_VERSION 254 /* RO, 8 bytes */
  232. #define EXT_CSD_SUPPORTED_MODE 493 /* RO */
  233. #define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */
  234. #define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */
  235. #define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */
  236. #define EXT_CSD_MAX_PACKED_READS 501 /* RO */
  237. #define EXT_CSD_BKOPS_SUPPORT 502 /* RO */
  238. #define EXT_CSD_HPI_FEATURES 503 /* RO */
  239. /*
  240. * EXT_CSD field definitions
  241. */
  242. #define EXT_CSD_WR_REL_PARAM_EN (1<<2)
  243. #define EXT_CSD_BOOT_WP_B_PWR_WP_DIS (0x40)
  244. #define EXT_CSD_BOOT_WP_B_PERM_WP_DIS (0x10)
  245. #define EXT_CSD_BOOT_WP_B_PERM_WP_EN (0x04)
  246. #define EXT_CSD_BOOT_WP_B_PWR_WP_EN (0x01)
  247. #define EXT_CSD_PART_CONFIG_ACC_MASK (0x7)
  248. #define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1)
  249. #define EXT_CSD_PART_CONFIG_ACC_RPMB (0x3)
  250. #define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4)
  251. #define EXT_CSD_PART_SUPPORT_PART_EN (0x1)
  252. #define EXT_CSD_CMD_SET_NORMAL (1<<0)
  253. #define EXT_CSD_CMD_SET_SECURE (1<<1)
  254. #define EXT_CSD_CMD_SET_CPSECURE (1<<2)
  255. #define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
  256. #define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */
  257. #define EXT_CSD_CARD_TYPE_MASK 0x3F /* Mask out reserved bits */
  258. #define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */
  259. /* DDR mode @1.8V or 3V I/O */
  260. #define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */
  261. /* DDR mode @1.2V I/O */
  262. #define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \
  263. | EXT_CSD_CARD_TYPE_DDR_1_2V)
  264. #define EXT_CSD_CARD_TYPE_SDR_1_8V (1<<4) /* Card can run at 200MHz */
  265. #define EXT_CSD_CARD_TYPE_SDR_1_2V (1<<5) /* Card can run at 200MHz */
  266. /* SDR mode @1.2V I/O */
  267. #define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
  268. #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
  269. #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */
  270. #define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */
  271. #define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */
  272. #define EXT_CSD_SEC_ER_EN BIT(0)
  273. #define EXT_CSD_SEC_BD_BLK_EN BIT(2)
  274. #define EXT_CSD_SEC_GB_CL_EN BIT(4)
  275. #define EXT_CSD_SEC_SANITIZE BIT(6) /* v4.5 only */
  276. #define EXT_CSD_RST_N_EN_MASK 0x3
  277. #define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */
  278. #define EXT_CSD_NO_POWER_NOTIFICATION 0
  279. #define EXT_CSD_POWER_ON 1
  280. #define EXT_CSD_POWER_OFF_SHORT 2
  281. #define EXT_CSD_POWER_OFF_LONG 3
  282. #define EXT_CSD_PWR_CL_8BIT_MASK 0xF0 /* 8 bit PWR CLS */
  283. #define EXT_CSD_PWR_CL_4BIT_MASK 0x0F /* 8 bit PWR CLS */
  284. #define EXT_CSD_PWR_CL_8BIT_SHIFT 4
  285. #define EXT_CSD_PWR_CL_4BIT_SHIFT 0
  286. #define EXT_CSD_PACKED_EVENT_EN BIT(3)
  287. /* mmc host capabilities */
  288. #define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */
  289. #define MMC_CAP_MMC_HIGHSPEED (1 << 1) /* Can do MMC high-speed timing */
  290. #define MMC_CAP_SD_HIGHSPEED (1 << 2) /* Can do SD high-speed timing */
  291. #define MMC_CAP_SDIO_IRQ (1 << 3) /* Can signal pending SDIO IRQs */
  292. struct mmc_cmd {
  293. uint8_t opcode;
  294. uint8_t reserved[3];
  295. uint32_t flags;
  296. uint32_t arg;
  297. uint32_t resp[4];
  298. uint32_t blk_num;
  299. uint32_t blk_size;
  300. uint8_t *buf;
  301. };
  302. typedef void (*sdio_irq_callback_t)(void *arg);
  303. struct mmc_driver_api {
  304. int (*set_clock)(const struct device *dev, unsigned int hz);
  305. int (*set_bus_width)(const struct device *dev, unsigned int width);
  306. int (*send_cmd)(const struct device *dev, struct mmc_cmd *cmd);
  307. unsigned int (*get_capability)(const struct device *dev);
  308. int (*set_sdio_irq_callback)(const struct device *dev,
  309. sdio_irq_callback_t callback,
  310. void *arg);
  311. int (*enable_sdio_irq)(const struct device *dev, bool enable);
  312. int (*release_device)(const struct device *dev);
  313. };
  314. static inline int mmc_set_clock(const struct device *dev, unsigned int hz)
  315. {
  316. const struct mmc_driver_api *api = dev->api;
  317. return api->set_clock(dev, hz);
  318. }
  319. static inline int mmc_set_bus_width(const struct device *dev, unsigned int width)
  320. {
  321. const struct mmc_driver_api *api = dev->api;
  322. return api->set_bus_width(dev, width);
  323. }
  324. static inline int mmc_set_sdio_irq_callback(const struct device *dev,
  325. sdio_irq_callback_t callback,
  326. void *arg)
  327. {
  328. const struct mmc_driver_api *api = dev->api;
  329. return api->set_sdio_irq_callback(dev, callback, arg);
  330. }
  331. static inline int mmc_enable_sdio_irq(const struct device *dev, bool enable)
  332. {
  333. const struct mmc_driver_api *api = dev->api;
  334. return api->enable_sdio_irq(dev, enable);
  335. }
  336. static inline int mmc_send_cmd(const struct device *dev, struct mmc_cmd *cmd)
  337. {
  338. const struct mmc_driver_api *api = dev->api;
  339. return api->send_cmd(dev, cmd);
  340. }
  341. static inline unsigned int mmc_get_capability(const struct device *dev)
  342. {
  343. const struct mmc_driver_api *api = dev->api;
  344. return api->get_capability(dev);
  345. }
  346. static inline int mmc_release_device(const struct device *dev)
  347. {
  348. const struct mmc_driver_api *api = dev->api;
  349. return api->release_device(dev);
  350. }
  351. #endif /* __MMC_H__ */