mmci.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/drivers/mmc/host/mmci.h - ARM PrimeCell MMCI PL180/1 driver
  4. *
  5. * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
  6. */
  7. #define MMCIPOWER 0x000
  8. #define MCI_PWR_OFF 0x00
  9. #define MCI_PWR_UP 0x02
  10. #define MCI_PWR_ON 0x03
  11. #define MCI_OD (1 << 6)
  12. #define MCI_ROD (1 << 7)
  13. /*
  14. * The ST Micro version does not have ROD and reuse the voltage registers for
  15. * direction settings.
  16. */
  17. #define MCI_ST_DATA2DIREN (1 << 2)
  18. #define MCI_ST_CMDDIREN (1 << 3)
  19. #define MCI_ST_DATA0DIREN (1 << 4)
  20. #define MCI_ST_DATA31DIREN (1 << 5)
  21. #define MCI_ST_FBCLKEN (1 << 7)
  22. #define MCI_ST_DATA74DIREN (1 << 8)
  23. /*
  24. * The STM32 sdmmc does not have PWR_UP/OD/ROD
  25. * and uses the power register for
  26. */
  27. #define MCI_STM32_PWR_CYC 0x02
  28. #define MCI_STM32_VSWITCH BIT(2)
  29. #define MCI_STM32_VSWITCHEN BIT(3)
  30. #define MCI_STM32_DIRPOL BIT(4)
  31. #define MMCICLOCK 0x004
  32. #define MCI_CLK_ENABLE (1 << 8)
  33. #define MCI_CLK_PWRSAVE (1 << 9)
  34. #define MCI_CLK_BYPASS (1 << 10)
  35. #define MCI_4BIT_BUS (1 << 11)
  36. /*
  37. * 8bit wide buses, hardware flow contronl, negative edges and clock inversion
  38. * supported in ST Micro U300 and Ux500 versions
  39. */
  40. #define MCI_ST_8BIT_BUS (1 << 12)
  41. #define MCI_ST_U300_HWFCEN (1 << 13)
  42. #define MCI_ST_UX500_NEG_EDGE (1 << 13)
  43. #define MCI_ST_UX500_HWFCEN (1 << 14)
  44. #define MCI_ST_UX500_CLK_INV (1 << 15)
  45. /* Modified PL180 on Versatile Express platform */
  46. #define MCI_ARM_HWFCEN (1 << 12)
  47. /* Modified on Qualcomm Integrations */
  48. #define MCI_QCOM_CLK_WIDEBUS_8 (BIT(10) | BIT(11))
  49. #define MCI_QCOM_CLK_FLOWENA BIT(12)
  50. #define MCI_QCOM_CLK_INVERTOUT BIT(13)
  51. /* select in latch data and command in */
  52. #define MCI_QCOM_CLK_SELECT_IN_FBCLK BIT(15)
  53. #define MCI_QCOM_CLK_SELECT_IN_DDR_MODE (BIT(14) | BIT(15))
  54. /* Modified on STM32 sdmmc */
  55. #define MCI_STM32_CLK_CLKDIV_MSK GENMASK(9, 0)
  56. #define MCI_STM32_CLK_WIDEBUS_4 BIT(14)
  57. #define MCI_STM32_CLK_WIDEBUS_8 BIT(15)
  58. #define MCI_STM32_CLK_NEGEDGE BIT(16)
  59. #define MCI_STM32_CLK_HWFCEN BIT(17)
  60. #define MCI_STM32_CLK_DDR BIT(18)
  61. #define MCI_STM32_CLK_BUSSPEED BIT(19)
  62. #define MCI_STM32_CLK_SEL_MSK GENMASK(21, 20)
  63. #define MCI_STM32_CLK_SELCK (0 << 20)
  64. #define MCI_STM32_CLK_SELCKIN (1 << 20)
  65. #define MCI_STM32_CLK_SELFBCK (2 << 20)
  66. #define MMCIARGUMENT 0x008
  67. /* The command register controls the Command Path State Machine (CPSM) */
  68. #define MMCICOMMAND 0x00c
  69. #define MCI_CPSM_RESPONSE BIT(6)
  70. #define MCI_CPSM_LONGRSP BIT(7)
  71. #define MCI_CPSM_INTERRUPT BIT(8)
  72. #define MCI_CPSM_PENDING BIT(9)
  73. #define MCI_CPSM_ENABLE BIT(10)
  74. /* Command register flag extenstions in the ST Micro versions */
  75. #define MCI_CPSM_ST_SDIO_SUSP BIT(11)
  76. #define MCI_CPSM_ST_ENCMD_COMPL BIT(12)
  77. #define MCI_CPSM_ST_NIEN BIT(13)
  78. #define MCI_CPSM_ST_CE_ATACMD BIT(14)
  79. /* Command register flag extensions in the Qualcomm versions */
  80. #define MCI_CPSM_QCOM_PROGENA BIT(11)
  81. #define MCI_CPSM_QCOM_DATCMD BIT(12)
  82. #define MCI_CPSM_QCOM_MCIABORT BIT(13)
  83. #define MCI_CPSM_QCOM_CCSENABLE BIT(14)
  84. #define MCI_CPSM_QCOM_CCSDISABLE BIT(15)
  85. #define MCI_CPSM_QCOM_AUTO_CMD19 BIT(16)
  86. #define MCI_CPSM_QCOM_AUTO_CMD21 BIT(21)
  87. /* Command register in STM32 sdmmc versions */
  88. #define MCI_CPSM_STM32_CMDTRANS BIT(6)
  89. #define MCI_CPSM_STM32_CMDSTOP BIT(7)
  90. #define MCI_CPSM_STM32_WAITRESP_MASK GENMASK(9, 8)
  91. #define MCI_CPSM_STM32_NORSP (0 << 8)
  92. #define MCI_CPSM_STM32_SRSP_CRC (1 << 8)
  93. #define MCI_CPSM_STM32_SRSP (2 << 8)
  94. #define MCI_CPSM_STM32_LRSP_CRC (3 << 8)
  95. #define MCI_CPSM_STM32_ENABLE BIT(12)
  96. #define MMCIRESPCMD 0x010
  97. #define MMCIRESPONSE0 0x014
  98. #define MMCIRESPONSE1 0x018
  99. #define MMCIRESPONSE2 0x01c
  100. #define MMCIRESPONSE3 0x020
  101. #define MMCIDATATIMER 0x024
  102. #define MMCIDATALENGTH 0x028
  103. /* The data control register controls the Data Path State Machine (DPSM) */
  104. #define MMCIDATACTRL 0x02c
  105. #define MCI_DPSM_ENABLE BIT(0)
  106. #define MCI_DPSM_DIRECTION BIT(1)
  107. #define MCI_DPSM_MODE BIT(2)
  108. #define MCI_DPSM_DMAENABLE BIT(3)
  109. #define MCI_DPSM_BLOCKSIZE BIT(4)
  110. /* Control register extensions in the ST Micro U300 and Ux500 versions */
  111. #define MCI_DPSM_ST_RWSTART BIT(8)
  112. #define MCI_DPSM_ST_RWSTOP BIT(9)
  113. #define MCI_DPSM_ST_RWMOD BIT(10)
  114. #define MCI_DPSM_ST_SDIOEN BIT(11)
  115. /* Control register extensions in the ST Micro Ux500 versions */
  116. #define MCI_DPSM_ST_DMAREQCTL BIT(12)
  117. #define MCI_DPSM_ST_DBOOTMODEEN BIT(13)
  118. #define MCI_DPSM_ST_BUSYMODE BIT(14)
  119. #define MCI_DPSM_ST_DDRMODE BIT(15)
  120. /* Control register extensions in the Qualcomm versions */
  121. #define MCI_DPSM_QCOM_DATA_PEND BIT(17)
  122. #define MCI_DPSM_QCOM_RX_DATA_PEND BIT(20)
  123. /* Control register extensions in STM32 versions */
  124. #define MCI_DPSM_STM32_MODE_BLOCK (0 << 2)
  125. #define MCI_DPSM_STM32_MODE_SDIO (1 << 2)
  126. #define MCI_DPSM_STM32_MODE_STREAM (2 << 2)
  127. #define MCI_DPSM_STM32_MODE_BLOCK_STOP (3 << 2)
  128. #define MMCIDATACNT 0x030
  129. #define MMCISTATUS 0x034
  130. #define MCI_CMDCRCFAIL (1 << 0)
  131. #define MCI_DATACRCFAIL (1 << 1)
  132. #define MCI_CMDTIMEOUT (1 << 2)
  133. #define MCI_DATATIMEOUT (1 << 3)
  134. #define MCI_TXUNDERRUN (1 << 4)
  135. #define MCI_RXOVERRUN (1 << 5)
  136. #define MCI_CMDRESPEND (1 << 6)
  137. #define MCI_CMDSENT (1 << 7)
  138. #define MCI_DATAEND (1 << 8)
  139. #define MCI_STARTBITERR (1 << 9)
  140. #define MCI_DATABLOCKEND (1 << 10)
  141. #define MCI_CMDACTIVE (1 << 11)
  142. #define MCI_TXACTIVE (1 << 12)
  143. #define MCI_RXACTIVE (1 << 13)
  144. #define MCI_TXFIFOHALFEMPTY (1 << 14)
  145. #define MCI_RXFIFOHALFFULL (1 << 15)
  146. #define MCI_TXFIFOFULL (1 << 16)
  147. #define MCI_RXFIFOFULL (1 << 17)
  148. #define MCI_TXFIFOEMPTY (1 << 18)
  149. #define MCI_RXFIFOEMPTY (1 << 19)
  150. #define MCI_TXDATAAVLBL (1 << 20)
  151. #define MCI_RXDATAAVLBL (1 << 21)
  152. /* Extended status bits for the ST Micro variants */
  153. #define MCI_ST_SDIOIT (1 << 22)
  154. #define MCI_ST_CEATAEND (1 << 23)
  155. #define MCI_ST_CARDBUSY (1 << 24)
  156. /* Extended status bits for the STM32 variants */
  157. #define MCI_STM32_BUSYD0 BIT(20)
  158. #define MCI_STM32_BUSYD0END BIT(21)
  159. #define MCI_STM32_VSWEND BIT(25)
  160. #define MMCICLEAR 0x038
  161. #define MCI_CMDCRCFAILCLR (1 << 0)
  162. #define MCI_DATACRCFAILCLR (1 << 1)
  163. #define MCI_CMDTIMEOUTCLR (1 << 2)
  164. #define MCI_DATATIMEOUTCLR (1 << 3)
  165. #define MCI_TXUNDERRUNCLR (1 << 4)
  166. #define MCI_RXOVERRUNCLR (1 << 5)
  167. #define MCI_CMDRESPENDCLR (1 << 6)
  168. #define MCI_CMDSENTCLR (1 << 7)
  169. #define MCI_DATAENDCLR (1 << 8)
  170. #define MCI_STARTBITERRCLR (1 << 9)
  171. #define MCI_DATABLOCKENDCLR (1 << 10)
  172. /* Extended status bits for the ST Micro variants */
  173. #define MCI_ST_SDIOITC (1 << 22)
  174. #define MCI_ST_CEATAENDC (1 << 23)
  175. #define MCI_ST_BUSYENDC (1 << 24)
  176. /* Extended clear bits for the STM32 variants */
  177. #define MCI_STM32_VSWENDC BIT(25)
  178. #define MCI_STM32_CKSTOPC BIT(26)
  179. #define MMCIMASK0 0x03c
  180. #define MCI_CMDCRCFAILMASK (1 << 0)
  181. #define MCI_DATACRCFAILMASK (1 << 1)
  182. #define MCI_CMDTIMEOUTMASK (1 << 2)
  183. #define MCI_DATATIMEOUTMASK (1 << 3)
  184. #define MCI_TXUNDERRUNMASK (1 << 4)
  185. #define MCI_RXOVERRUNMASK (1 << 5)
  186. #define MCI_CMDRESPENDMASK (1 << 6)
  187. #define MCI_CMDSENTMASK (1 << 7)
  188. #define MCI_DATAENDMASK (1 << 8)
  189. #define MCI_STARTBITERRMASK (1 << 9)
  190. #define MCI_DATABLOCKENDMASK (1 << 10)
  191. #define MCI_CMDACTIVEMASK (1 << 11)
  192. #define MCI_TXACTIVEMASK (1 << 12)
  193. #define MCI_RXACTIVEMASK (1 << 13)
  194. #define MCI_TXFIFOHALFEMPTYMASK (1 << 14)
  195. #define MCI_RXFIFOHALFFULLMASK (1 << 15)
  196. #define MCI_TXFIFOFULLMASK (1 << 16)
  197. #define MCI_RXFIFOFULLMASK (1 << 17)
  198. #define MCI_TXFIFOEMPTYMASK (1 << 18)
  199. #define MCI_RXFIFOEMPTYMASK (1 << 19)
  200. #define MCI_TXDATAAVLBLMASK (1 << 20)
  201. #define MCI_RXDATAAVLBLMASK (1 << 21)
  202. /* Extended status bits for the ST Micro variants */
  203. #define MCI_ST_SDIOITMASK (1 << 22)
  204. #define MCI_ST_CEATAENDMASK (1 << 23)
  205. #define MCI_ST_BUSYENDMASK (1 << 24)
  206. /* Extended status bits for the STM32 variants */
  207. #define MCI_STM32_BUSYD0ENDMASK BIT(21)
  208. #define MMCIMASK1 0x040
  209. /* STM32 sdmmc data FIFO threshold register */
  210. #define MMCI_STM32_FIFOTHRR 0x044
  211. #define MMCI_STM32_THR_MASK GENMASK(3, 0)
  212. #define MMCIFIFOCNT 0x048
  213. #define MMCIFIFO 0x080 /* to 0x0bc */
  214. /* STM32 sdmmc registers for IDMA (Internal DMA) */
  215. #define MMCI_STM32_IDMACTRLR 0x050
  216. #define MMCI_STM32_IDMAEN BIT(0)
  217. #define MMCI_STM32_IDMALLIEN BIT(1)
  218. #define MMCI_STM32_IDMABSIZER 0x054
  219. #define MMCI_STM32_IDMABASE0R 0x058
  220. #define MMCI_STM32_IDMALAR 0x64
  221. #define MMCI_STM32_IDMALA_MASK GENMASK(13, 0)
  222. #define MMCI_STM32_ABR BIT(29)
  223. #define MMCI_STM32_ULS BIT(30)
  224. #define MMCI_STM32_ULA BIT(31)
  225. #define MMCI_STM32_IDMABAR 0x68
  226. #define MCI_IRQENABLE \
  227. (MCI_CMDCRCFAILMASK | MCI_DATACRCFAILMASK | MCI_CMDTIMEOUTMASK | \
  228. MCI_DATATIMEOUTMASK | MCI_TXUNDERRUNMASK | MCI_RXOVERRUNMASK | \
  229. MCI_CMDRESPENDMASK | MCI_CMDSENTMASK)
  230. /* These interrupts are directed to IRQ1 when two IRQ lines are available */
  231. #define MCI_IRQ_PIO_MASK \
  232. (MCI_RXFIFOHALFFULLMASK | MCI_RXDATAAVLBLMASK | \
  233. MCI_TXFIFOHALFEMPTYMASK)
  234. #define MCI_IRQ_PIO_STM32_MASK \
  235. (MCI_RXFIFOHALFFULLMASK | MCI_TXFIFOHALFEMPTYMASK)
  236. #define NR_SG 128
  237. #define MMCI_PINCTRL_STATE_OPENDRAIN "opendrain"
  238. struct clk;
  239. struct dma_chan;
  240. struct mmci_host;
  241. /**
  242. * enum mmci_busy_state - enumerate the busy detect wait states
  243. *
  244. * This is used for the state machine waiting for different busy detect
  245. * interrupts on hardware that fire a single IRQ for start and end of
  246. * the busy detect phase on DAT0.
  247. */
  248. enum mmci_busy_state {
  249. MMCI_BUSY_WAITING_FOR_START_IRQ,
  250. MMCI_BUSY_WAITING_FOR_END_IRQ,
  251. MMCI_BUSY_DONE,
  252. };
  253. /**
  254. * struct variant_data - MMCI variant-specific quirks
  255. * @clkreg: default value for MCICLOCK register
  256. * @clkreg_enable: enable value for MMCICLOCK register
  257. * @clkreg_8bit_bus_enable: enable value for 8 bit bus
  258. * @clkreg_neg_edge_enable: enable value for inverted data/cmd output
  259. * @cmdreg_cpsm_enable: enable value for CPSM
  260. * @cmdreg_lrsp_crc: enable value for long response with crc
  261. * @cmdreg_srsp_crc: enable value for short response with crc
  262. * @cmdreg_srsp: enable value for short response without crc
  263. * @cmdreg_stop: enable value for stop and abort transmission
  264. * @datalength_bits: number of bits in the MMCIDATALENGTH register
  265. * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY
  266. * is asserted (likewise for RX)
  267. * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY
  268. * is asserted (likewise for RX)
  269. * @data_cmd_enable: enable value for data commands.
  270. * @st_sdio: enable ST specific SDIO logic
  271. * @st_clkdiv: true if using a ST-specific clock divider algorithm
  272. * @stm32_clkdiv: true if using a STM32-specific clock divider algorithm
  273. * @datactrl_mask_ddrmode: ddr mode mask in datactrl register.
  274. * @datactrl_mask_sdio: SDIO enable mask in datactrl register
  275. * @datactrl_blocksz: block size in power of two
  276. * @datactrl_any_blocksz: true if block any block sizes are accepted by
  277. * hardware, such as with some SDIO traffic that send
  278. * odd packets.
  279. * @dma_power_of_2: DMA only works with blocks that are a power of 2.
  280. * @datactrl_first: true if data must be setup before send command
  281. * @datacnt_useless: true if you could not use datacnt register to read
  282. * remaining data
  283. * @pwrreg_powerup: power up value for MMCIPOWER register
  284. * @f_max: maximum clk frequency supported by the controller.
  285. * @signal_direction: input/out direction of bus signals can be indicated
  286. * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock
  287. * @busy_detect: true if the variant supports busy detection on DAT0.
  288. * @busy_timeout: true if the variant starts data timer when the DPSM
  289. * enter in Wait_R or Busy state.
  290. * @busy_dpsm_flag: bitmask enabling busy detection in the DPSM
  291. * @busy_detect_flag: bitmask identifying the bit in the MMCISTATUS register
  292. * indicating that the card is busy
  293. * @busy_detect_mask: bitmask identifying the bit in the MMCIMASK0 to mask for
  294. * getting busy end detection interrupts
  295. * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply
  296. * @explicit_mclk_control: enable explicit mclk control in driver.
  297. * @qcom_fifo: enables qcom specific fifo pio read logic.
  298. * @qcom_dml: enables qcom specific dma glue for dma transfers.
  299. * @reversed_irq_handling: handle data irq before cmd irq.
  300. * @mmcimask1: true if variant have a MMCIMASK1 register.
  301. * @irq_pio_mask: bitmask used to manage interrupt pio transfert in mmcimask
  302. * register
  303. * @start_err: bitmask identifying the STARTBITERR bit inside MMCISTATUS
  304. * register.
  305. * @opendrain: bitmask identifying the OPENDRAIN bit inside MMCIPOWER register
  306. * @dma_lli: true if variant has dma link list feature.
  307. * @supports_sdio_irq: allow SD I/O card to interrupt the host
  308. * @stm32_idmabsize_mask: stm32 sdmmc idma buffer size.
  309. * @dma_flow_controller: use peripheral as flow controller for DMA.
  310. */
  311. struct variant_data {
  312. unsigned int clkreg;
  313. unsigned int clkreg_enable;
  314. unsigned int clkreg_8bit_bus_enable;
  315. unsigned int clkreg_neg_edge_enable;
  316. unsigned int cmdreg_cpsm_enable;
  317. unsigned int cmdreg_lrsp_crc;
  318. unsigned int cmdreg_srsp_crc;
  319. unsigned int cmdreg_srsp;
  320. unsigned int cmdreg_stop;
  321. unsigned int datalength_bits;
  322. unsigned int fifosize;
  323. unsigned int fifohalfsize;
  324. unsigned int data_cmd_enable;
  325. unsigned int datactrl_mask_ddrmode;
  326. unsigned int datactrl_mask_sdio;
  327. unsigned int datactrl_blocksz;
  328. u8 datactrl_any_blocksz:1;
  329. u8 dma_power_of_2:1;
  330. u8 datactrl_first:1;
  331. u8 datacnt_useless:1;
  332. u8 st_sdio:1;
  333. u8 st_clkdiv:1;
  334. u8 stm32_clkdiv:1;
  335. u32 pwrreg_powerup;
  336. u32 f_max;
  337. u8 signal_direction:1;
  338. u8 pwrreg_clkgate:1;
  339. u8 busy_detect:1;
  340. u8 busy_timeout:1;
  341. u32 busy_dpsm_flag;
  342. u32 busy_detect_flag;
  343. u32 busy_detect_mask;
  344. u8 pwrreg_nopower:1;
  345. u8 explicit_mclk_control:1;
  346. u8 qcom_fifo:1;
  347. u8 qcom_dml:1;
  348. u8 reversed_irq_handling:1;
  349. u8 mmcimask1:1;
  350. unsigned int irq_pio_mask;
  351. u32 start_err;
  352. u32 opendrain;
  353. u8 dma_lli:1;
  354. bool supports_sdio_irq;
  355. u32 stm32_idmabsize_mask;
  356. u32 stm32_idmabsize_align;
  357. bool dma_flow_controller;
  358. void (*init)(struct mmci_host *host);
  359. };
  360. /* mmci variant callbacks */
  361. struct mmci_host_ops {
  362. int (*validate_data)(struct mmci_host *host, struct mmc_data *data);
  363. int (*prep_data)(struct mmci_host *host, struct mmc_data *data,
  364. bool next);
  365. void (*unprep_data)(struct mmci_host *host, struct mmc_data *data,
  366. int err);
  367. u32 (*get_datactrl_cfg)(struct mmci_host *host);
  368. void (*get_next_data)(struct mmci_host *host, struct mmc_data *data);
  369. int (*dma_setup)(struct mmci_host *host);
  370. void (*dma_release)(struct mmci_host *host);
  371. int (*dma_start)(struct mmci_host *host, unsigned int *datactrl);
  372. void (*dma_finalize)(struct mmci_host *host, struct mmc_data *data);
  373. void (*dma_error)(struct mmci_host *host);
  374. void (*set_clkreg)(struct mmci_host *host, unsigned int desired);
  375. void (*set_pwrreg)(struct mmci_host *host, unsigned int pwr);
  376. bool (*busy_complete)(struct mmci_host *host, struct mmc_command *cmd, u32 status, u32 err_msk);
  377. void (*pre_sig_volt_switch)(struct mmci_host *host);
  378. int (*post_sig_volt_switch)(struct mmci_host *host, struct mmc_ios *ios);
  379. };
  380. struct mmci_host {
  381. phys_addr_t phybase;
  382. void __iomem *base;
  383. struct mmc_request *mrq;
  384. struct mmc_command *cmd;
  385. struct mmc_command stop_abort;
  386. struct mmc_data *data;
  387. struct mmc_host *mmc;
  388. struct clk *clk;
  389. u8 singleirq:1;
  390. struct reset_control *rst;
  391. spinlock_t lock;
  392. unsigned int mclk;
  393. /* cached value of requested clk in set_ios */
  394. unsigned int clock_cache;
  395. unsigned int cclk;
  396. u32 pwr_reg;
  397. u32 pwr_reg_add;
  398. u32 clk_reg;
  399. u32 clk_reg_add;
  400. u32 datactrl_reg;
  401. enum mmci_busy_state busy_state;
  402. u32 busy_status;
  403. u32 mask1_reg;
  404. u8 vqmmc_enabled:1;
  405. struct mmci_platform_data *plat;
  406. struct mmc_host_ops *mmc_ops;
  407. struct mmci_host_ops *ops;
  408. struct variant_data *variant;
  409. void *variant_priv;
  410. struct pinctrl *pinctrl;
  411. struct pinctrl_state *pins_opendrain;
  412. u8 hw_designer;
  413. u8 hw_revision:4;
  414. struct timer_list timer;
  415. unsigned int oldstat;
  416. u32 irq_action;
  417. /* pio stuff */
  418. struct sg_mapping_iter sg_miter;
  419. unsigned int size;
  420. int (*get_rx_fifocnt)(struct mmci_host *h, u32 status, int remain);
  421. u8 use_dma:1;
  422. u8 dma_in_progress:1;
  423. void *dma_priv;
  424. s32 next_cookie;
  425. struct delayed_work ux500_busy_timeout_work;
  426. };
  427. #define dma_inprogress(host) ((host)->dma_in_progress)
  428. void mmci_write_clkreg(struct mmci_host *host, u32 clk);
  429. void mmci_write_pwrreg(struct mmci_host *host, u32 pwr);
  430. static inline u32 mmci_dctrl_blksz(struct mmci_host *host)
  431. {
  432. return (ffs(host->data->blksz) - 1) << 4;
  433. }
  434. #ifdef CONFIG_DMA_ENGINE
  435. int mmci_dmae_prep_data(struct mmci_host *host, struct mmc_data *data,
  436. bool next);
  437. void mmci_dmae_unprep_data(struct mmci_host *host, struct mmc_data *data,
  438. int err);
  439. void mmci_dmae_get_next_data(struct mmci_host *host, struct mmc_data *data);
  440. int mmci_dmae_setup(struct mmci_host *host);
  441. void mmci_dmae_release(struct mmci_host *host);
  442. int mmci_dmae_start(struct mmci_host *host, unsigned int *datactrl);
  443. void mmci_dmae_finalize(struct mmci_host *host, struct mmc_data *data);
  444. void mmci_dmae_error(struct mmci_host *host);
  445. #endif
  446. #ifdef CONFIG_MMC_QCOM_DML
  447. void qcom_variant_init(struct mmci_host *host);
  448. #else
  449. static inline void qcom_variant_init(struct mmci_host *host) {}
  450. #endif
  451. #ifdef CONFIG_MMC_STM32_SDMMC
  452. void sdmmc_variant_init(struct mmci_host *host);
  453. #else
  454. static inline void sdmmc_variant_init(struct mmci_host *host) {}
  455. #endif