sdio.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*
  2. * SDIO spec header file
  3. * Protocol and standard (common) device definitions
  4. *
  5. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  6. *
  7. * Copyright (C) 1999-2020, Broadcom Corporation
  8. *
  9. * Unless you and Broadcom execute a separate written software license
  10. * agreement governing use of this software, this software is licensed to you
  11. * under the terms of the GNU General Public License version 2 (the "GPL"),
  12. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  13. * following added to such license:
  14. *
  15. * As a special exception, the copyright holders of this software give you
  16. * permission to link this software with independent modules, and to copy and
  17. * distribute the resulting executable under terms of your choice, provided that
  18. * you also meet, for each linked independent module, the terms and conditions of
  19. * the license of that module. An independent module is a module which is not
  20. * derived from this software. The special exception does not apply to any
  21. * modifications of the software.
  22. *
  23. * Notwithstanding the above, under no circumstances may you combine this
  24. * software in any way with any other Broadcom software provided under a license
  25. * other than the GPL, without Broadcom's express prior written consent.
  26. *
  27. *
  28. * <<Broadcom-WL-IPTag/Open:>>
  29. *
  30. * $Id: sdio.h 689948 2017-03-14 05:21:03Z $
  31. */
  32. #ifndef _SDIO_H
  33. #define _SDIO_H
  34. #ifdef BCMSDIO
  35. /* CCCR structure for function 0 */
  36. typedef volatile struct {
  37. uint8 cccr_sdio_rev; /* RO, cccr and sdio revision */
  38. uint8 sd_rev; /* RO, sd spec revision */
  39. uint8 io_en; /* I/O enable */
  40. uint8 io_rdy; /* I/O ready reg */
  41. uint8 intr_ctl; /* Master and per function interrupt enable control */
  42. uint8 intr_status; /* RO, interrupt pending status */
  43. uint8 io_abort; /* read/write abort or reset all functions */
  44. uint8 bus_inter; /* bus interface control */
  45. uint8 capability; /* RO, card capability */
  46. uint8 cis_base_low; /* 0x9 RO, common CIS base address, LSB */
  47. uint8 cis_base_mid;
  48. uint8 cis_base_high; /* 0xB RO, common CIS base address, MSB */
  49. /* suspend/resume registers */
  50. uint8 bus_suspend; /* 0xC */
  51. uint8 func_select; /* 0xD */
  52. uint8 exec_flag; /* 0xE */
  53. uint8 ready_flag; /* 0xF */
  54. uint8 fn0_blk_size[2]; /* 0x10(LSB), 0x11(MSB) */
  55. uint8 power_control; /* 0x12 (SDIO version 1.10) */
  56. uint8 speed_control; /* 0x13 */
  57. } sdio_regs_t;
  58. /* SDIO Device CCCR offsets */
  59. #define SDIOD_CCCR_REV 0x00
  60. #define SDIOD_CCCR_SDREV 0x01
  61. #define SDIOD_CCCR_IOEN 0x02
  62. #define SDIOD_CCCR_IORDY 0x03
  63. #define SDIOD_CCCR_INTEN 0x04
  64. #define SDIOD_CCCR_INTPEND 0x05
  65. #define SDIOD_CCCR_IOABORT 0x06
  66. #define SDIOD_CCCR_BICTRL 0x07
  67. #define SDIOD_CCCR_CAPABLITIES 0x08
  68. #define SDIOD_CCCR_CISPTR_0 0x09
  69. #define SDIOD_CCCR_CISPTR_1 0x0A
  70. #define SDIOD_CCCR_CISPTR_2 0x0B
  71. #define SDIOD_CCCR_BUSSUSP 0x0C
  72. #define SDIOD_CCCR_FUNCSEL 0x0D
  73. #define SDIOD_CCCR_EXECFLAGS 0x0E
  74. #define SDIOD_CCCR_RDYFLAGS 0x0F
  75. #define SDIOD_CCCR_BLKSIZE_0 0x10
  76. #define SDIOD_CCCR_BLKSIZE_1 0x11
  77. #define SDIOD_CCCR_POWER_CONTROL 0x12
  78. #define SDIOD_CCCR_SPEED_CONTROL 0x13
  79. #define SDIOD_CCCR_UHSI_SUPPORT 0x14
  80. #define SDIOD_CCCR_DRIVER_STRENGTH 0x15
  81. #define SDIOD_CCCR_INTR_EXTN 0x16
  82. /* Broadcom extensions (corerev >= 1) */
  83. #define SDIOD_CCCR_BRCM_CARDCAP 0xf0
  84. #define SDIOD_CCCR_BRCM_CARDCAP_CMD14_SUPPORT 0x02
  85. #define SDIOD_CCCR_BRCM_CARDCAP_CMD14_EXT 0x04
  86. #define SDIOD_CCCR_BRCM_CARDCAP_CMD_NODEC 0x08
  87. #define SDIOD_CCCR_BRCM_CARDCTL 0xf1
  88. #define SDIOD_CCCR_BRCM_SEPINT 0xf2
  89. /* cccr_sdio_rev */
  90. #define SDIO_REV_SDIOID_MASK 0xf0 /* SDIO spec revision number */
  91. #define SDIO_REV_CCCRID_MASK 0x0f /* CCCR format version number */
  92. #define SDIO_SPEC_VERSION_3_0 0x40 /* SDIO spec version 3.0 */
  93. /* sd_rev */
  94. #define SD_REV_PHY_MASK 0x0f /* SD format version number */
  95. /* io_en */
  96. #define SDIO_FUNC_ENABLE_1 0x02 /* function 1 I/O enable */
  97. #define SDIO_FUNC_ENABLE_2 0x04 /* function 2 I/O enable */
  98. #if defined(BT_OVER_SDIO)
  99. #define SDIO_FUNC_ENABLE_3 0x08 /* function 2 I/O enable */
  100. #define SDIO_FUNC_DISABLE_3 0xF0 /* function 2 I/O enable */
  101. #endif /* defined (BT_OVER_SDIO) */
  102. /* io_rdys */
  103. #define SDIO_FUNC_READY_1 0x02 /* function 1 I/O ready */
  104. #define SDIO_FUNC_READY_2 0x04 /* function 2 I/O ready */
  105. /* intr_ctl */
  106. #define INTR_CTL_MASTER_EN 0x1 /* interrupt enable master */
  107. #define INTR_CTL_FUNC1_EN 0x2 /* interrupt enable for function 1 */
  108. #define INTR_CTL_FUNC2_EN 0x4 /* interrupt enable for function 2 */
  109. #if defined(BT_OVER_SDIO)
  110. #define INTR_CTL_FUNC3_EN 0x8 /* interrupt enable for function 3 */
  111. #endif /* defined (BT_OVER_SDIO) */
  112. /* intr_status */
  113. #define INTR_STATUS_FUNC1 0x2 /* interrupt pending for function 1 */
  114. #define INTR_STATUS_FUNC2 0x4 /* interrupt pending for function 2 */
  115. /* io_abort */
  116. #define IO_ABORT_RESET_ALL 0x08 /* I/O card reset */
  117. #define IO_ABORT_FUNC_MASK 0x07 /* abort selction: function x */
  118. /* bus_inter */
  119. #define BUS_CARD_DETECT_DIS 0x80 /* Card Detect disable */
  120. #define BUS_SPI_CONT_INTR_CAP 0x40 /* support continuous SPI interrupt */
  121. #define BUS_SPI_CONT_INTR_EN 0x20 /* continuous SPI interrupt enable */
  122. #define BUS_SD_DATA_WIDTH_MASK 0x03 /* bus width mask */
  123. #define BUS_SD_DATA_WIDTH_4BIT 0x02 /* bus width 4-bit mode */
  124. #define BUS_SD_DATA_WIDTH_1BIT 0x00 /* bus width 1-bit mode */
  125. /* capability */
  126. #define SDIO_CAP_4BLS 0x80 /* 4-bit support for low speed card */
  127. #define SDIO_CAP_LSC 0x40 /* low speed card */
  128. #define SDIO_CAP_E4MI 0x20 /* enable interrupt between block of data in 4-bit mode */
  129. #define SDIO_CAP_S4MI 0x10 /* support interrupt between block of data in 4-bit mode */
  130. #define SDIO_CAP_SBS 0x08 /* support suspend/resume */
  131. #define SDIO_CAP_SRW 0x04 /* support read wait */
  132. #define SDIO_CAP_SMB 0x02 /* support multi-block transfer */
  133. #define SDIO_CAP_SDC 0x01 /* Support Direct commands during multi-byte transfer */
  134. /* power_control */
  135. #define SDIO_POWER_SMPC 0x01 /* supports master power control (RO) */
  136. #define SDIO_POWER_EMPC 0x02 /* enable master power control (allow > 200mA) (RW) */
  137. /* speed_control (control device entry into high-speed clocking mode) */
  138. #define SDIO_SPEED_SHS 0x01 /* supports high-speed [clocking] mode (RO) */
  139. #define SDIO_SPEED_EHS 0x02 /* enable high-speed [clocking] mode (RW) */
  140. #define SDIO_SPEED_UHSI_DDR50 0x08
  141. /* for setting bus speed in card: 0x13h */
  142. #define SDIO_BUS_SPEED_UHSISEL_M BITFIELD_MASK(3)
  143. #define SDIO_BUS_SPEED_UHSISEL_S 1
  144. /* for getting bus speed cap in card: 0x14h */
  145. #define SDIO_BUS_SPEED_UHSICAP_M BITFIELD_MASK(3)
  146. #define SDIO_BUS_SPEED_UHSICAP_S 0
  147. /* for getting driver type CAP in card: 0x15h */
  148. #define SDIO_BUS_DRVR_TYPE_CAP_M BITFIELD_MASK(3)
  149. #define SDIO_BUS_DRVR_TYPE_CAP_S 0
  150. /* for setting driver type selection in card: 0x15h */
  151. #define SDIO_BUS_DRVR_TYPE_SEL_M BITFIELD_MASK(2)
  152. #define SDIO_BUS_DRVR_TYPE_SEL_S 4
  153. /* for getting async int support in card: 0x16h */
  154. #define SDIO_BUS_ASYNCINT_CAP_M BITFIELD_MASK(1)
  155. #define SDIO_BUS_ASYNCINT_CAP_S 0
  156. /* for setting async int selection in card: 0x16h */
  157. #define SDIO_BUS_ASYNCINT_SEL_M BITFIELD_MASK(1)
  158. #define SDIO_BUS_ASYNCINT_SEL_S 1
  159. /* brcm sepint */
  160. #define SDIO_SEPINT_MASK 0x01 /* route sdpcmdev intr onto separate pad (chip-specific) */
  161. #define SDIO_SEPINT_OE 0x02 /* 1 asserts output enable for above pad */
  162. #define SDIO_SEPINT_ACT_HI 0x04 /* use active high interrupt level instead of active low */
  163. /* FBR structure for function 1-7, FBR addresses and register offsets */
  164. typedef volatile struct {
  165. uint8 devctr; /* device interface, CSA control */
  166. uint8 ext_dev; /* extended standard I/O device type code */
  167. uint8 pwr_sel; /* power selection support */
  168. uint8 PAD[6]; /* reserved */
  169. uint8 cis_low; /* CIS LSB */
  170. uint8 cis_mid;
  171. uint8 cis_high; /* CIS MSB */
  172. uint8 csa_low; /* code storage area, LSB */
  173. uint8 csa_mid;
  174. uint8 csa_high; /* code storage area, MSB */
  175. uint8 csa_dat_win; /* data access window to function */
  176. uint8 fnx_blk_size[2]; /* block size, little endian */
  177. } sdio_fbr_t;
  178. /* Maximum number of I/O funcs */
  179. #define SDIOD_MAX_FUNCS 8
  180. #define SDIOD_MAX_IOFUNCS 7
  181. /* SDIO Device FBR Start Address */
  182. #define SDIOD_FBR_STARTADDR 0x100
  183. /* SDIO Device FBR Size */
  184. #define SDIOD_FBR_SIZE 0x100
  185. /* Macro to calculate FBR register base */
  186. #define SDIOD_FBR_BASE(n) ((n) * 0x100)
  187. /* Function register offsets */
  188. #define SDIOD_FBR_DEVCTR 0x00 /* basic info for function */
  189. #define SDIOD_FBR_EXT_DEV 0x01 /* extended I/O device code */
  190. #define SDIOD_FBR_PWR_SEL 0x02 /* power selection bits */
  191. /* SDIO Function CIS ptr offset */
  192. #define SDIOD_FBR_CISPTR_0 0x09
  193. #define SDIOD_FBR_CISPTR_1 0x0A
  194. #define SDIOD_FBR_CISPTR_2 0x0B
  195. /* Code Storage Area pointer */
  196. #define SDIOD_FBR_CSA_ADDR_0 0x0C
  197. #define SDIOD_FBR_CSA_ADDR_1 0x0D
  198. #define SDIOD_FBR_CSA_ADDR_2 0x0E
  199. #define SDIOD_FBR_CSA_DATA 0x0F
  200. /* SDIO Function I/O Block Size */
  201. #define SDIOD_FBR_BLKSIZE_0 0x10
  202. #define SDIOD_FBR_BLKSIZE_1 0x11
  203. /* devctr */
  204. #define SDIOD_FBR_DEVCTR_DIC 0x0f /* device interface code */
  205. #define SDIOD_FBR_DECVTR_CSA 0x40 /* CSA support flag */
  206. #define SDIOD_FBR_DEVCTR_CSA_EN 0x80 /* CSA enabled */
  207. /* interface codes */
  208. #define SDIOD_DIC_NONE 0 /* SDIO standard interface is not supported */
  209. #define SDIOD_DIC_UART 1
  210. #define SDIOD_DIC_BLUETOOTH_A 2
  211. #define SDIOD_DIC_BLUETOOTH_B 3
  212. #define SDIOD_DIC_GPS 4
  213. #define SDIOD_DIC_CAMERA 5
  214. #define SDIOD_DIC_PHS 6
  215. #define SDIOD_DIC_WLAN 7
  216. #define SDIOD_DIC_EXT 0xf /* extended device interface, read ext_dev register */
  217. /* pwr_sel */
  218. #define SDIOD_PWR_SEL_SPS 0x01 /* supports power selection */
  219. #define SDIOD_PWR_SEL_EPS 0x02 /* enable power selection (low-current mode) */
  220. /* misc defines */
  221. #define SDIO_FUNC_0 0
  222. #define SDIO_FUNC_1 1
  223. #define SDIO_FUNC_2 2
  224. #define SDIO_FUNC_4 4
  225. #define SDIO_FUNC_5 5
  226. #define SDIO_FUNC_6 6
  227. #define SDIO_FUNC_7 7
  228. #define SD_CARD_TYPE_UNKNOWN 0 /* bad type or unrecognized */
  229. #define SD_CARD_TYPE_IO 1 /* IO only card */
  230. #define SD_CARD_TYPE_MEMORY 2 /* memory only card */
  231. #define SD_CARD_TYPE_COMBO 3 /* IO and memory combo card */
  232. #define SDIO_MAX_BLOCK_SIZE 2048 /* maximum block size for block mode operation */
  233. #define SDIO_MIN_BLOCK_SIZE 1 /* minimum block size for block mode operation */
  234. /* Card registers: status bit position */
  235. #define CARDREG_STATUS_BIT_OUTOFRANGE 31
  236. #define CARDREG_STATUS_BIT_COMCRCERROR 23
  237. #define CARDREG_STATUS_BIT_ILLEGALCOMMAND 22
  238. #define CARDREG_STATUS_BIT_ERROR 19
  239. #define CARDREG_STATUS_BIT_IOCURRENTSTATE3 12
  240. #define CARDREG_STATUS_BIT_IOCURRENTSTATE2 11
  241. #define CARDREG_STATUS_BIT_IOCURRENTSTATE1 10
  242. #define CARDREG_STATUS_BIT_IOCURRENTSTATE0 9
  243. #define CARDREG_STATUS_BIT_FUN_NUM_ERROR 4
  244. #define SD_CMD_GO_IDLE_STATE 0 /* mandatory for SDIO */
  245. #define SD_CMD_SEND_OPCOND 1
  246. #define SD_CMD_MMC_SET_RCA 3
  247. #define SD_CMD_IO_SEND_OP_COND 5 /* mandatory for SDIO */
  248. #define SD_CMD_SELECT_DESELECT_CARD 7
  249. #define SD_CMD_SEND_CSD 9
  250. #define SD_CMD_SEND_CID 10
  251. #define SD_CMD_STOP_TRANSMISSION 12
  252. #define SD_CMD_SEND_STATUS 13
  253. #define SD_CMD_GO_INACTIVE_STATE 15
  254. #define SD_CMD_SET_BLOCKLEN 16
  255. #define SD_CMD_READ_SINGLE_BLOCK 17
  256. #define SD_CMD_READ_MULTIPLE_BLOCK 18
  257. #define SD_CMD_WRITE_BLOCK 24
  258. #define SD_CMD_WRITE_MULTIPLE_BLOCK 25
  259. #define SD_CMD_PROGRAM_CSD 27
  260. #define SD_CMD_SET_WRITE_PROT 28
  261. #define SD_CMD_CLR_WRITE_PROT 29
  262. #define SD_CMD_SEND_WRITE_PROT 30
  263. #define SD_CMD_ERASE_WR_BLK_START 32
  264. #define SD_CMD_ERASE_WR_BLK_END 33
  265. #define SD_CMD_ERASE 38
  266. #define SD_CMD_LOCK_UNLOCK 42
  267. #define SD_CMD_IO_RW_DIRECT 52 /* mandatory for SDIO */
  268. #define SD_CMD_IO_RW_EXTENDED 53 /* mandatory for SDIO */
  269. #define SD_CMD_APP_CMD 55
  270. #define SD_CMD_GEN_CMD 56
  271. #define SD_CMD_READ_OCR 58
  272. #define SD_CMD_CRC_ON_OFF 59 /* mandatory for SDIO */
  273. #define SD_ACMD_SD_STATUS 13
  274. #define SD_ACMD_SEND_NUM_WR_BLOCKS 22
  275. #define SD_ACMD_SET_WR_BLOCK_ERASE_CNT 23
  276. #define SD_ACMD_SD_SEND_OP_COND 41
  277. #define SD_ACMD_SET_CLR_CARD_DETECT 42
  278. #define SD_ACMD_SEND_SCR 51
  279. /* argument for SD_CMD_IO_RW_DIRECT and SD_CMD_IO_RW_EXTENDED */
  280. #define SD_IO_OP_READ 0 /* Read_Write: Read */
  281. #define SD_IO_OP_WRITE 1 /* Read_Write: Write */
  282. #define SD_IO_RW_NORMAL 0 /* no RAW */
  283. #define SD_IO_RW_RAW 1 /* RAW */
  284. #define SD_IO_BYTE_MODE 0 /* Byte Mode */
  285. #define SD_IO_BLOCK_MODE 1 /* BlockMode */
  286. #define SD_IO_FIXED_ADDRESS 0 /* fix Address */
  287. #define SD_IO_INCREMENT_ADDRESS 1 /* IncrementAddress */
  288. /* build SD_CMD_IO_RW_DIRECT Argument */
  289. #define SDIO_IO_RW_DIRECT_ARG(rw, raw, func, addr, data) \
  290. ((((rw) & 1) << 31) | (((func) & 0x7) << 28) | (((raw) & 1) << 27) | \
  291. (((addr) & 0x1FFFF) << 9) | ((data) & 0xFF))
  292. /* build SD_CMD_IO_RW_EXTENDED Argument */
  293. #define SDIO_IO_RW_EXTENDED_ARG(rw, blk, func, addr, inc_addr, count) \
  294. ((((rw) & 1) << 31) | (((func) & 0x7) << 28) | (((blk) & 1) << 27) | \
  295. (((inc_addr) & 1) << 26) | (((addr) & 0x1FFFF) << 9) | ((count) & 0x1FF))
  296. /* SDIO response parameters */
  297. #define SD_RSP_NO_NONE 0
  298. #define SD_RSP_NO_1 1
  299. #define SD_RSP_NO_2 2
  300. #define SD_RSP_NO_3 3
  301. #define SD_RSP_NO_4 4
  302. #define SD_RSP_NO_5 5
  303. #define SD_RSP_NO_6 6
  304. /* Modified R6 response (to CMD3) */
  305. #define SD_RSP_MR6_COM_CRC_ERROR 0x8000
  306. #define SD_RSP_MR6_ILLEGAL_COMMAND 0x4000
  307. #define SD_RSP_MR6_ERROR 0x2000
  308. /* Modified R1 in R4 Response (to CMD5) */
  309. #define SD_RSP_MR1_SBIT 0x80
  310. #define SD_RSP_MR1_PARAMETER_ERROR 0x40
  311. #define SD_RSP_MR1_RFU5 0x20
  312. #define SD_RSP_MR1_FUNC_NUM_ERROR 0x10
  313. #define SD_RSP_MR1_COM_CRC_ERROR 0x08
  314. #define SD_RSP_MR1_ILLEGAL_COMMAND 0x04
  315. #define SD_RSP_MR1_RFU1 0x02
  316. #define SD_RSP_MR1_IDLE_STATE 0x01
  317. /* R5 response (to CMD52 and CMD53) */
  318. #define SD_RSP_R5_COM_CRC_ERROR 0x80
  319. #define SD_RSP_R5_ILLEGAL_COMMAND 0x40
  320. #define SD_RSP_R5_IO_CURRENTSTATE1 0x20
  321. #define SD_RSP_R5_IO_CURRENTSTATE0 0x10
  322. #define SD_RSP_R5_ERROR 0x08
  323. #define SD_RSP_R5_RFU 0x04
  324. #define SD_RSP_R5_FUNC_NUM_ERROR 0x02
  325. #define SD_RSP_R5_OUT_OF_RANGE 0x01
  326. #define SD_RSP_R5_ERRBITS 0xCB
  327. /* ------------------------------------------------
  328. * SDIO Commands and responses
  329. *
  330. * I/O only commands are:
  331. * CMD0, CMD3, CMD5, CMD7, CMD14, CMD15, CMD52, CMD53
  332. * ------------------------------------------------
  333. */
  334. /* SDIO Commands */
  335. #define SDIOH_CMD_0 0
  336. #define SDIOH_CMD_3 3
  337. #define SDIOH_CMD_5 5
  338. #define SDIOH_CMD_7 7
  339. #define SDIOH_CMD_11 11
  340. #define SDIOH_CMD_14 14
  341. #define SDIOH_CMD_15 15
  342. #define SDIOH_CMD_19 19
  343. #define SDIOH_CMD_52 52
  344. #define SDIOH_CMD_53 53
  345. #define SDIOH_CMD_59 59
  346. /* SDIO Command Responses */
  347. #define SDIOH_RSP_NONE 0
  348. #define SDIOH_RSP_R1 1
  349. #define SDIOH_RSP_R2 2
  350. #define SDIOH_RSP_R3 3
  351. #define SDIOH_RSP_R4 4
  352. #define SDIOH_RSP_R5 5
  353. #define SDIOH_RSP_R6 6
  354. /*
  355. * SDIO Response Error flags
  356. */
  357. #define SDIOH_RSP5_ERROR_FLAGS 0xCB
  358. /* ------------------------------------------------
  359. * SDIO Command structures. I/O only commands are:
  360. *
  361. * CMD0, CMD3, CMD5, CMD7, CMD15, CMD52, CMD53
  362. * ------------------------------------------------
  363. */
  364. #define CMD5_OCR_M BITFIELD_MASK(24)
  365. #define CMD5_OCR_S 0
  366. #define CMD5_S18R_M BITFIELD_MASK(1)
  367. #define CMD5_S18R_S 24
  368. #define CMD7_RCA_M BITFIELD_MASK(16)
  369. #define CMD7_RCA_S 16
  370. #define CMD14_RCA_M BITFIELD_MASK(16)
  371. #define CMD14_RCA_S 16
  372. #define CMD14_SLEEP_M BITFIELD_MASK(1)
  373. #define CMD14_SLEEP_S 15
  374. #define CMD_15_RCA_M BITFIELD_MASK(16)
  375. #define CMD_15_RCA_S 16
  376. #define CMD52_DATA_M BITFIELD_MASK(8) /* Bits [7:0] - Write Data/Stuff bits of CMD52
  377. */
  378. #define CMD52_DATA_S 0
  379. #define CMD52_REG_ADDR_M BITFIELD_MASK(17) /* Bits [25:9] - register address */
  380. #define CMD52_REG_ADDR_S 9
  381. #define CMD52_RAW_M BITFIELD_MASK(1) /* Bit 27 - Read after Write flag */
  382. #define CMD52_RAW_S 27
  383. #define CMD52_FUNCTION_M BITFIELD_MASK(3) /* Bits [30:28] - Function number */
  384. #define CMD52_FUNCTION_S 28
  385. #define CMD52_RW_FLAG_M BITFIELD_MASK(1) /* Bit 31 - R/W flag */
  386. #define CMD52_RW_FLAG_S 31
  387. #define CMD53_BYTE_BLK_CNT_M BITFIELD_MASK(9) /* Bits [8:0] - Byte/Block Count of CMD53 */
  388. #define CMD53_BYTE_BLK_CNT_S 0
  389. #define CMD53_REG_ADDR_M BITFIELD_MASK(17) /* Bits [25:9] - register address */
  390. #define CMD53_REG_ADDR_S 9
  391. #define CMD53_OP_CODE_M BITFIELD_MASK(1) /* Bit 26 - R/W Operation Code */
  392. #define CMD53_OP_CODE_S 26
  393. #define CMD53_BLK_MODE_M BITFIELD_MASK(1) /* Bit 27 - Block Mode */
  394. #define CMD53_BLK_MODE_S 27
  395. #define CMD53_FUNCTION_M BITFIELD_MASK(3) /* Bits [30:28] - Function number */
  396. #define CMD53_FUNCTION_S 28
  397. #define CMD53_RW_FLAG_M BITFIELD_MASK(1) /* Bit 31 - R/W flag */
  398. #define CMD53_RW_FLAG_S 31
  399. /* ------------------------------------------------------
  400. * SDIO Command Response structures for SD1 and SD4 modes
  401. * -----------------------------------------------------
  402. */
  403. #define RSP4_IO_OCR_M BITFIELD_MASK(24) /* Bits [23:0] - Card's OCR Bits [23:0] */
  404. #define RSP4_IO_OCR_S 0
  405. #define RSP4_S18A_M BITFIELD_MASK(1) /* Bits [23:0] - Card's OCR Bits [23:0] */
  406. #define RSP4_S18A_S 24
  407. #define RSP4_STUFF_M BITFIELD_MASK(3) /* Bits [26:24] - Stuff bits */
  408. #define RSP4_STUFF_S 24
  409. #define RSP4_MEM_PRESENT_M BITFIELD_MASK(1) /* Bit 27 - Memory present */
  410. #define RSP4_MEM_PRESENT_S 27
  411. #define RSP4_NUM_FUNCS_M BITFIELD_MASK(3) /* Bits [30:28] - Number of I/O funcs */
  412. #define RSP4_NUM_FUNCS_S 28
  413. #define RSP4_CARD_READY_M BITFIELD_MASK(1) /* Bit 31 - SDIO card ready */
  414. #define RSP4_CARD_READY_S 31
  415. #define RSP6_STATUS_M BITFIELD_MASK(16) /* Bits [15:0] - Card status bits [19,22,23,12:0]
  416. */
  417. #define RSP6_STATUS_S 0
  418. #define RSP6_IO_RCA_M BITFIELD_MASK(16) /* Bits [31:16] - RCA bits[31-16] */
  419. #define RSP6_IO_RCA_S 16
  420. #define RSP1_AKE_SEQ_ERROR_M BITFIELD_MASK(1) /* Bit 3 - Authentication seq error */
  421. #define RSP1_AKE_SEQ_ERROR_S 3
  422. #define RSP1_APP_CMD_M BITFIELD_MASK(1) /* Bit 5 - Card expects ACMD */
  423. #define RSP1_APP_CMD_S 5
  424. #define RSP1_READY_FOR_DATA_M BITFIELD_MASK(1) /* Bit 8 - Ready for data (buff empty) */
  425. #define RSP1_READY_FOR_DATA_S 8
  426. #define RSP1_CURR_STATE_M BITFIELD_MASK(4) /* Bits [12:9] - State of card
  427. * when Cmd was received
  428. */
  429. #define RSP1_CURR_STATE_S 9
  430. #define RSP1_EARSE_RESET_M BITFIELD_MASK(1) /* Bit 13 - Erase seq cleared */
  431. #define RSP1_EARSE_RESET_S 13
  432. #define RSP1_CARD_ECC_DISABLE_M BITFIELD_MASK(1) /* Bit 14 - Card ECC disabled */
  433. #define RSP1_CARD_ECC_DISABLE_S 14
  434. #define RSP1_WP_ERASE_SKIP_M BITFIELD_MASK(1) /* Bit 15 - Partial blocks erased due to W/P */
  435. #define RSP1_WP_ERASE_SKIP_S 15
  436. #define RSP1_CID_CSD_OVERW_M BITFIELD_MASK(1) /* Bit 16 - Illegal write to CID or R/O bits
  437. * of CSD
  438. */
  439. #define RSP1_CID_CSD_OVERW_S 16
  440. #define RSP1_ERROR_M BITFIELD_MASK(1) /* Bit 19 - General/Unknown error */
  441. #define RSP1_ERROR_S 19
  442. #define RSP1_CC_ERROR_M BITFIELD_MASK(1) /* Bit 20 - Internal Card Control error */
  443. #define RSP1_CC_ERROR_S 20
  444. #define RSP1_CARD_ECC_FAILED_M BITFIELD_MASK(1) /* Bit 21 - Card internal ECC failed
  445. * to correct data
  446. */
  447. #define RSP1_CARD_ECC_FAILED_S 21
  448. #define RSP1_ILLEGAL_CMD_M BITFIELD_MASK(1) /* Bit 22 - Cmd not legal for the card state */
  449. #define RSP1_ILLEGAL_CMD_S 22
  450. #define RSP1_COM_CRC_ERROR_M BITFIELD_MASK(1) /* Bit 23 - CRC check of previous command failed
  451. */
  452. #define RSP1_COM_CRC_ERROR_S 23
  453. #define RSP1_LOCK_UNLOCK_FAIL_M BITFIELD_MASK(1) /* Bit 24 - Card lock-unlock Cmd Seq error */
  454. #define RSP1_LOCK_UNLOCK_FAIL_S 24
  455. #define RSP1_CARD_LOCKED_M BITFIELD_MASK(1) /* Bit 25 - Card locked by the host */
  456. #define RSP1_CARD_LOCKED_S 25
  457. #define RSP1_WP_VIOLATION_M BITFIELD_MASK(1) /* Bit 26 - Attempt to program
  458. * write-protected blocks
  459. */
  460. #define RSP1_WP_VIOLATION_S 26
  461. #define RSP1_ERASE_PARAM_M BITFIELD_MASK(1) /* Bit 27 - Invalid erase blocks */
  462. #define RSP1_ERASE_PARAM_S 27
  463. #define RSP1_ERASE_SEQ_ERR_M BITFIELD_MASK(1) /* Bit 28 - Erase Cmd seq error */
  464. #define RSP1_ERASE_SEQ_ERR_S 28
  465. #define RSP1_BLK_LEN_ERR_M BITFIELD_MASK(1) /* Bit 29 - Block length error */
  466. #define RSP1_BLK_LEN_ERR_S 29
  467. #define RSP1_ADDR_ERR_M BITFIELD_MASK(1) /* Bit 30 - Misaligned address */
  468. #define RSP1_ADDR_ERR_S 30
  469. #define RSP1_OUT_OF_RANGE_M BITFIELD_MASK(1) /* Bit 31 - Cmd arg was out of range */
  470. #define RSP1_OUT_OF_RANGE_S 31
  471. #define RSP5_DATA_M BITFIELD_MASK(8) /* Bits [0:7] - data */
  472. #define RSP5_DATA_S 0
  473. #define RSP5_FLAGS_M BITFIELD_MASK(8) /* Bit [15:8] - Rsp flags */
  474. #define RSP5_FLAGS_S 8
  475. #define RSP5_STUFF_M BITFIELD_MASK(16) /* Bits [31:16] - Stuff bits */
  476. #define RSP5_STUFF_S 16
  477. /* ----------------------------------------------
  478. * SDIO Command Response structures for SPI mode
  479. * ----------------------------------------------
  480. */
  481. #define SPIRSP4_IO_OCR_M BITFIELD_MASK(16) /* Bits [15:0] - Card's OCR Bits [23:8] */
  482. #define SPIRSP4_IO_OCR_S 0
  483. #define SPIRSP4_STUFF_M BITFIELD_MASK(3) /* Bits [18:16] - Stuff bits */
  484. #define SPIRSP4_STUFF_S 16
  485. #define SPIRSP4_MEM_PRESENT_M BITFIELD_MASK(1) /* Bit 19 - Memory present */
  486. #define SPIRSP4_MEM_PRESENT_S 19
  487. #define SPIRSP4_NUM_FUNCS_M BITFIELD_MASK(3) /* Bits [22:20] - Number of I/O funcs */
  488. #define SPIRSP4_NUM_FUNCS_S 20
  489. #define SPIRSP4_CARD_READY_M BITFIELD_MASK(1) /* Bit 23 - SDIO card ready */
  490. #define SPIRSP4_CARD_READY_S 23
  491. #define SPIRSP4_IDLE_STATE_M BITFIELD_MASK(1) /* Bit 24 - idle state */
  492. #define SPIRSP4_IDLE_STATE_S 24
  493. #define SPIRSP4_ILLEGAL_CMD_M BITFIELD_MASK(1) /* Bit 26 - Illegal Cmd error */
  494. #define SPIRSP4_ILLEGAL_CMD_S 26
  495. #define SPIRSP4_COM_CRC_ERROR_M BITFIELD_MASK(1) /* Bit 27 - COM CRC error */
  496. #define SPIRSP4_COM_CRC_ERROR_S 27
  497. #define SPIRSP4_FUNC_NUM_ERROR_M BITFIELD_MASK(1) /* Bit 28 - Function number error
  498. */
  499. #define SPIRSP4_FUNC_NUM_ERROR_S 28
  500. #define SPIRSP4_PARAM_ERROR_M BITFIELD_MASK(1) /* Bit 30 - Parameter Error Bit */
  501. #define SPIRSP4_PARAM_ERROR_S 30
  502. #define SPIRSP4_START_BIT_M BITFIELD_MASK(1) /* Bit 31 - Start Bit */
  503. #define SPIRSP4_START_BIT_S 31
  504. #define SPIRSP5_DATA_M BITFIELD_MASK(8) /* Bits [23:16] - R/W Data */
  505. #define SPIRSP5_DATA_S 16
  506. #define SPIRSP5_IDLE_STATE_M BITFIELD_MASK(1) /* Bit 24 - Idle state */
  507. #define SPIRSP5_IDLE_STATE_S 24
  508. #define SPIRSP5_ILLEGAL_CMD_M BITFIELD_MASK(1) /* Bit 26 - Illegal Cmd error */
  509. #define SPIRSP5_ILLEGAL_CMD_S 26
  510. #define SPIRSP5_COM_CRC_ERROR_M BITFIELD_MASK(1) /* Bit 27 - COM CRC error */
  511. #define SPIRSP5_COM_CRC_ERROR_S 27
  512. #define SPIRSP5_FUNC_NUM_ERROR_M BITFIELD_MASK(1) /* Bit 28 - Function number error
  513. */
  514. #define SPIRSP5_FUNC_NUM_ERROR_S 28
  515. #define SPIRSP5_PARAM_ERROR_M BITFIELD_MASK(1) /* Bit 30 - Parameter Error Bit */
  516. #define SPIRSP5_PARAM_ERROR_S 30
  517. #define SPIRSP5_START_BIT_M BITFIELD_MASK(1) /* Bit 31 - Start Bit */
  518. #define SPIRSP5_START_BIT_S 31
  519. /* RSP6 card status format; Pg 68 Physical Layer spec v 1.10 */
  520. #define RSP6STAT_AKE_SEQ_ERROR_M BITFIELD_MASK(1) /* Bit 3 - Authentication seq error
  521. */
  522. #define RSP6STAT_AKE_SEQ_ERROR_S 3
  523. #define RSP6STAT_APP_CMD_M BITFIELD_MASK(1) /* Bit 5 - Card expects ACMD */
  524. #define RSP6STAT_APP_CMD_S 5
  525. #define RSP6STAT_READY_FOR_DATA_M BITFIELD_MASK(1) /* Bit 8 - Ready for data
  526. * (buff empty)
  527. */
  528. #define RSP6STAT_READY_FOR_DATA_S 8
  529. #define RSP6STAT_CURR_STATE_M BITFIELD_MASK(4) /* Bits [12:9] - Card state at
  530. * Cmd reception
  531. */
  532. #define RSP6STAT_CURR_STATE_S 9
  533. #define RSP6STAT_ERROR_M BITFIELD_MASK(1) /* Bit 13 - General/Unknown error Bit 19
  534. */
  535. #define RSP6STAT_ERROR_S 13
  536. #define RSP6STAT_ILLEGAL_CMD_M BITFIELD_MASK(1) /* Bit 14 - Illegal cmd for
  537. * card state Bit 22
  538. */
  539. #define RSP6STAT_ILLEGAL_CMD_S 14
  540. #define RSP6STAT_COM_CRC_ERROR_M BITFIELD_MASK(1) /* Bit 15 - CRC previous command
  541. * failed Bit 23
  542. */
  543. #define RSP6STAT_COM_CRC_ERROR_S 15
  544. #define SDIOH_XFER_TYPE_READ SD_IO_OP_READ
  545. #define SDIOH_XFER_TYPE_WRITE SD_IO_OP_WRITE
  546. /* command issue options */
  547. #define CMD_OPTION_DEFAULT 0
  548. #define CMD_OPTION_TUNING 1
  549. #endif /* def BCMSDIO */
  550. #endif /* _SDIO_H */