dw_mmc.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /*
  2. * Synopsys DesignWare Multimedia Card Interface driver
  3. * (Based on NXP driver for lpc 31xx)
  4. *
  5. * Copyright (C) 2009 NXP Semiconductors
  6. * Copyright (C) 2009, 2010 Imagination Technologies Ltd.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #ifndef _DW_MMC_H_
  14. #define _DW_MMC_H_
  15. #include <linux/scatterlist.h>
  16. #include <linux/mmc/core.h>
  17. #include <linux/dmaengine.h>
  18. #include <linux/reset.h>
  19. #include <linux/interrupt.h>
  20. #define MAX_MCI_SLOTS 2
  21. enum dw_mci_state {
  22. STATE_IDLE = 0,
  23. STATE_SENDING_CMD,
  24. STATE_SENDING_DATA,
  25. STATE_DATA_BUSY,
  26. STATE_SENDING_STOP,
  27. STATE_DATA_ERROR,
  28. STATE_SENDING_CMD11,
  29. STATE_WAITING_CMD11_DONE,
  30. };
  31. enum {
  32. EVENT_CMD_COMPLETE = 0,
  33. EVENT_XFER_COMPLETE,
  34. EVENT_DATA_COMPLETE,
  35. EVENT_DATA_ERROR,
  36. };
  37. enum dw_mci_cookie {
  38. COOKIE_UNMAPPED,
  39. COOKIE_PRE_MAPPED, /* mapped by pre_req() of dwmmc */
  40. COOKIE_MAPPED, /* mapped by prepare_data() of dwmmc */
  41. };
  42. struct mmc_data;
  43. enum {
  44. TRANS_MODE_PIO = 0,
  45. TRANS_MODE_IDMAC,
  46. TRANS_MODE_EDMAC
  47. };
  48. struct dw_mci_dma_slave {
  49. struct dma_chan *ch;
  50. enum dma_transfer_direction direction;
  51. };
  52. /**
  53. * struct dw_mci - MMC controller state shared between all slots
  54. * @lock: Spinlock protecting the queue and associated data.
  55. * @irq_lock: Spinlock protecting the INTMASK setting.
  56. * @regs: Pointer to MMIO registers.
  57. * @fifo_reg: Pointer to MMIO registers for data FIFO
  58. * @sg: Scatterlist entry currently being processed by PIO code, if any.
  59. * @sg_miter: PIO mapping scatterlist iterator.
  60. * @cur_slot: The slot which is currently using the controller.
  61. * @mrq: The request currently being processed on @cur_slot,
  62. * or NULL if the controller is idle.
  63. * @cmd: The command currently being sent to the card, or NULL.
  64. * @data: The data currently being transferred, or NULL if no data
  65. * transfer is in progress.
  66. * @stop_abort: The command currently prepared for stoping transfer.
  67. * @prev_blksz: The former transfer blksz record.
  68. * @timing: Record of current ios timing.
  69. * @use_dma: Whether DMA channel is initialized or not.
  70. * @using_dma: Whether DMA is in use for the current transfer.
  71. * @dma_64bit_address: Whether DMA supports 64-bit address mode or not.
  72. * @sg_dma: Bus address of DMA buffer.
  73. * @sg_cpu: Virtual address of DMA buffer.
  74. * @dma_ops: Pointer to platform-specific DMA callbacks.
  75. * @cmd_status: Snapshot of SR taken upon completion of the current
  76. * @ring_size: Buffer size for idma descriptors.
  77. * command. Only valid when EVENT_CMD_COMPLETE is pending.
  78. * @dms: structure of slave-dma private data.
  79. * @phy_regs: physical address of controller's register map
  80. * @data_status: Snapshot of SR taken upon completion of the current
  81. * data transfer. Only valid when EVENT_DATA_COMPLETE or
  82. * EVENT_DATA_ERROR is pending.
  83. * @stop_cmdr: Value to be loaded into CMDR when the stop command is
  84. * to be sent.
  85. * @dir_status: Direction of current transfer.
  86. * @tasklet: Tasklet running the request state machine.
  87. * @pending_events: Bitmask of events flagged by the interrupt handler
  88. * to be processed by the tasklet.
  89. * @completed_events: Bitmask of events which the state machine has
  90. * processed.
  91. * @state: Tasklet state.
  92. * @queue: List of slots waiting for access to the controller.
  93. * @bus_hz: The rate of @mck in Hz. This forms the basis for MMC bus
  94. * rate and timeout calculations.
  95. * @current_speed: Configured rate of the controller.
  96. * @num_slots: Number of slots available.
  97. * @fifoth_val: The value of FIFOTH register.
  98. * @verid: Denote Version ID.
  99. * @dev: Device associated with the MMC controller.
  100. * @pdata: Platform data associated with the MMC controller.
  101. * @drv_data: Driver specific data for identified variant of the controller
  102. * @priv: Implementation defined private data.
  103. * @biu_clk: Pointer to bus interface unit clock instance.
  104. * @ciu_clk: Pointer to card interface unit clock instance.
  105. * @slot: Slots sharing this MMC controller.
  106. * @fifo_depth: depth of FIFO.
  107. * @data_addr_override: override fifo reg offset with this value.
  108. * @wm_aligned: force fifo watermark equal with data length in PIO mode.
  109. * Set as true if alignment is needed.
  110. * @data_shift: log2 of FIFO item size.
  111. * @part_buf_start: Start index in part_buf.
  112. * @part_buf_count: Bytes of partial data in part_buf.
  113. * @part_buf: Simple buffer for partial fifo reads/writes.
  114. * @push_data: Pointer to FIFO push function.
  115. * @pull_data: Pointer to FIFO pull function.
  116. * @vqmmc_enabled: Status of vqmmc, should be true or false.
  117. * @irq_flags: The flags to be passed to request_irq.
  118. * @irq: The irq value to be passed to request_irq.
  119. * @sdio_id0: Number of slot0 in the SDIO interrupt registers.
  120. * @cmd11_timer: Timer for SD3.0 voltage switch over scheme.
  121. * @dto_timer: Timer for broken data transfer over scheme.
  122. *
  123. * Locking
  124. * =======
  125. *
  126. * @lock is a softirq-safe spinlock protecting @queue as well as
  127. * @cur_slot, @mrq and @state. These must always be updated
  128. * at the same time while holding @lock.
  129. *
  130. * @irq_lock is an irq-safe spinlock protecting the INTMASK register
  131. * to allow the interrupt handler to modify it directly. Held for only long
  132. * enough to read-modify-write INTMASK and no other locks are grabbed when
  133. * holding this one.
  134. *
  135. * The @mrq field of struct dw_mci_slot is also protected by @lock,
  136. * and must always be written at the same time as the slot is added to
  137. * @queue.
  138. *
  139. * @pending_events and @completed_events are accessed using atomic bit
  140. * operations, so they don't need any locking.
  141. *
  142. * None of the fields touched by the interrupt handler need any
  143. * locking. However, ordering is important: Before EVENT_DATA_ERROR or
  144. * EVENT_DATA_COMPLETE is set in @pending_events, all data-related
  145. * interrupts must be disabled and @data_status updated with a
  146. * snapshot of SR. Similarly, before EVENT_CMD_COMPLETE is set, the
  147. * CMDRDY interrupt must be disabled and @cmd_status updated with a
  148. * snapshot of SR, and before EVENT_XFER_COMPLETE can be set, the
  149. * bytes_xfered field of @data must be written. This is ensured by
  150. * using barriers.
  151. */
  152. struct dw_mci {
  153. spinlock_t lock;
  154. spinlock_t irq_lock;
  155. void __iomem *regs;
  156. void __iomem *fifo_reg;
  157. u32 data_addr_override;
  158. bool wm_aligned;
  159. struct scatterlist *sg;
  160. struct sg_mapping_iter sg_miter;
  161. struct dw_mci_slot *cur_slot;
  162. struct mmc_request *mrq;
  163. struct mmc_command *cmd;
  164. struct mmc_data *data;
  165. struct mmc_command stop_abort;
  166. unsigned int prev_blksz;
  167. unsigned char timing;
  168. /* DMA interface members*/
  169. int use_dma;
  170. int using_dma;
  171. int dma_64bit_address;
  172. dma_addr_t sg_dma;
  173. void *sg_cpu;
  174. const struct dw_mci_dma_ops *dma_ops;
  175. /* For idmac */
  176. unsigned int ring_size;
  177. /* For edmac */
  178. struct dw_mci_dma_slave *dms;
  179. /* Registers's physical base address */
  180. resource_size_t phy_regs;
  181. u32 cmd_status;
  182. u32 data_status;
  183. u32 stop_cmdr;
  184. u32 dir_status;
  185. struct tasklet_struct tasklet;
  186. unsigned long pending_events;
  187. unsigned long completed_events;
  188. enum dw_mci_state state;
  189. struct list_head queue;
  190. u32 bus_hz;
  191. u32 current_speed;
  192. u32 num_slots;
  193. u32 fifoth_val;
  194. u16 verid;
  195. struct device *dev;
  196. struct dw_mci_board *pdata;
  197. const struct dw_mci_drv_data *drv_data;
  198. void *priv;
  199. struct clk *biu_clk;
  200. struct clk *ciu_clk;
  201. struct dw_mci_slot *slot[MAX_MCI_SLOTS];
  202. /* FIFO push and pull */
  203. int fifo_depth;
  204. int data_shift;
  205. u8 part_buf_start;
  206. u8 part_buf_count;
  207. union {
  208. u16 part_buf16;
  209. u32 part_buf32;
  210. u64 part_buf;
  211. };
  212. void (*push_data)(struct dw_mci *host, void *buf, int cnt);
  213. void (*pull_data)(struct dw_mci *host, void *buf, int cnt);
  214. bool vqmmc_enabled;
  215. unsigned long irq_flags; /* IRQ flags */
  216. int irq;
  217. int sdio_id0;
  218. struct timer_list cmd11_timer;
  219. struct timer_list dto_timer;
  220. };
  221. /* DMA ops for Internal/External DMAC interface */
  222. struct dw_mci_dma_ops {
  223. /* DMA Ops */
  224. int (*init)(struct dw_mci *host);
  225. int (*start)(struct dw_mci *host, unsigned int sg_len);
  226. void (*complete)(void *host);
  227. void (*stop)(struct dw_mci *host);
  228. void (*cleanup)(struct dw_mci *host);
  229. void (*exit)(struct dw_mci *host);
  230. };
  231. struct dma_pdata;
  232. /* Board platform data */
  233. struct dw_mci_board {
  234. u32 num_slots;
  235. unsigned int bus_hz; /* Clock speed at the cclk_in pad */
  236. u32 caps; /* Capabilities */
  237. u32 caps2; /* More capabilities */
  238. u32 pm_caps; /* PM capabilities */
  239. /*
  240. * Override fifo depth. If 0, autodetect it from the FIFOTH register,
  241. * but note that this may not be reliable after a bootloader has used
  242. * it.
  243. */
  244. unsigned int fifo_depth;
  245. /* delay in mS before detecting cards after interrupt */
  246. u32 detect_delay_ms;
  247. struct reset_control *rstc;
  248. struct dw_mci_dma_ops *dma_ops;
  249. struct dma_pdata *data;
  250. };
  251. #define DW_MMC_240A 0x240a
  252. #define DW_MMC_280A 0x280a
  253. #define SDMMC_CTRL 0x000
  254. #define SDMMC_PWREN 0x004
  255. #define SDMMC_CLKDIV 0x008
  256. #define SDMMC_CLKSRC 0x00c
  257. #define SDMMC_CLKENA 0x010
  258. #define SDMMC_TMOUT 0x014
  259. #define SDMMC_CTYPE 0x018
  260. #define SDMMC_BLKSIZ 0x01c
  261. #define SDMMC_BYTCNT 0x020
  262. #define SDMMC_INTMASK 0x024
  263. #define SDMMC_CMDARG 0x028
  264. #define SDMMC_CMD 0x02c
  265. #define SDMMC_RESP0 0x030
  266. #define SDMMC_RESP1 0x034
  267. #define SDMMC_RESP2 0x038
  268. #define SDMMC_RESP3 0x03c
  269. #define SDMMC_MINTSTS 0x040
  270. #define SDMMC_RINTSTS 0x044
  271. #define SDMMC_STATUS 0x048
  272. #define SDMMC_FIFOTH 0x04c
  273. #define SDMMC_CDETECT 0x050
  274. #define SDMMC_WRTPRT 0x054
  275. #define SDMMC_GPIO 0x058
  276. #define SDMMC_TCBCNT 0x05c
  277. #define SDMMC_TBBCNT 0x060
  278. #define SDMMC_DEBNCE 0x064
  279. #define SDMMC_USRID 0x068
  280. #define SDMMC_VERID 0x06c
  281. #define SDMMC_HCON 0x070
  282. #define SDMMC_UHS_REG 0x074
  283. #define SDMMC_RST_N 0x078
  284. #define SDMMC_BMOD 0x080
  285. #define SDMMC_PLDMND 0x084
  286. #define SDMMC_DBADDR 0x088
  287. #define SDMMC_IDSTS 0x08c
  288. #define SDMMC_IDINTEN 0x090
  289. #define SDMMC_DSCADDR 0x094
  290. #define SDMMC_BUFADDR 0x098
  291. #define SDMMC_CDTHRCTL 0x100
  292. #define SDMMC_DATA(x) (x)
  293. /*
  294. * Registers to support idmac 64-bit address mode
  295. */
  296. #define SDMMC_DBADDRL 0x088
  297. #define SDMMC_DBADDRU 0x08c
  298. #define SDMMC_IDSTS64 0x090
  299. #define SDMMC_IDINTEN64 0x094
  300. #define SDMMC_DSCADDRL 0x098
  301. #define SDMMC_DSCADDRU 0x09c
  302. #define SDMMC_BUFADDRL 0x0A0
  303. #define SDMMC_BUFADDRU 0x0A4
  304. /*
  305. * Data offset is difference according to Version
  306. * Lower than 2.40a : data register offest is 0x100
  307. */
  308. #define DATA_OFFSET 0x100
  309. #define DATA_240A_OFFSET 0x200
  310. /* shift bit field */
  311. #define _SBF(f, v) ((v) << (f))
  312. /* Control register defines */
  313. #define SDMMC_CTRL_USE_IDMAC BIT(25)
  314. #define SDMMC_CTRL_CEATA_INT_EN BIT(11)
  315. #define SDMMC_CTRL_SEND_AS_CCSD BIT(10)
  316. #define SDMMC_CTRL_SEND_CCSD BIT(9)
  317. #define SDMMC_CTRL_ABRT_READ_DATA BIT(8)
  318. #define SDMMC_CTRL_SEND_IRQ_RESP BIT(7)
  319. #define SDMMC_CTRL_READ_WAIT BIT(6)
  320. #define SDMMC_CTRL_DMA_ENABLE BIT(5)
  321. #define SDMMC_CTRL_INT_ENABLE BIT(4)
  322. #define SDMMC_CTRL_DMA_RESET BIT(2)
  323. #define SDMMC_CTRL_FIFO_RESET BIT(1)
  324. #define SDMMC_CTRL_RESET BIT(0)
  325. /* Clock Enable register defines */
  326. #define SDMMC_CLKEN_LOW_PWR BIT(16)
  327. #define SDMMC_CLKEN_ENABLE BIT(0)
  328. /* time-out register defines */
  329. #define SDMMC_TMOUT_DATA(n) _SBF(8, (n))
  330. #define SDMMC_TMOUT_DATA_MSK 0xFFFFFF00
  331. #define SDMMC_TMOUT_RESP(n) ((n) & 0xFF)
  332. #define SDMMC_TMOUT_RESP_MSK 0xFF
  333. /* card-type register defines */
  334. #define SDMMC_CTYPE_8BIT BIT(16)
  335. #define SDMMC_CTYPE_4BIT BIT(0)
  336. #define SDMMC_CTYPE_1BIT 0
  337. /* Interrupt status & mask register defines */
  338. #define SDMMC_INT_SDIO(n) BIT(16 + (n))
  339. #define SDMMC_INT_EBE BIT(15)
  340. #define SDMMC_INT_ACD BIT(14)
  341. #define SDMMC_INT_SBE BIT(13)
  342. #define SDMMC_INT_HLE BIT(12)
  343. #define SDMMC_INT_FRUN BIT(11)
  344. #define SDMMC_INT_HTO BIT(10)
  345. #define SDMMC_INT_VOLT_SWITCH BIT(10) /* overloads bit 10! */
  346. #define SDMMC_INT_DRTO BIT(9)
  347. #define SDMMC_INT_RTO BIT(8)
  348. #define SDMMC_INT_DCRC BIT(7)
  349. #define SDMMC_INT_RCRC BIT(6)
  350. #define SDMMC_INT_RXDR BIT(5)
  351. #define SDMMC_INT_TXDR BIT(4)
  352. #define SDMMC_INT_DATA_OVER BIT(3)
  353. #define SDMMC_INT_CMD_DONE BIT(2)
  354. #define SDMMC_INT_RESP_ERR BIT(1)
  355. #define SDMMC_INT_CD BIT(0)
  356. #define SDMMC_INT_ERROR 0xbfc2
  357. /* Command register defines */
  358. #define SDMMC_CMD_START BIT(31)
  359. #define SDMMC_CMD_USE_HOLD_REG BIT(29)
  360. #define SDMMC_CMD_VOLT_SWITCH BIT(28)
  361. #define SDMMC_CMD_CCS_EXP BIT(23)
  362. #define SDMMC_CMD_CEATA_RD BIT(22)
  363. #define SDMMC_CMD_UPD_CLK BIT(21)
  364. #define SDMMC_CMD_INIT BIT(15)
  365. #define SDMMC_CMD_STOP BIT(14)
  366. #define SDMMC_CMD_PRV_DAT_WAIT BIT(13)
  367. #define SDMMC_CMD_SEND_STOP BIT(12)
  368. #define SDMMC_CMD_STRM_MODE BIT(11)
  369. #define SDMMC_CMD_DAT_WR BIT(10)
  370. #define SDMMC_CMD_DAT_EXP BIT(9)
  371. #define SDMMC_CMD_RESP_CRC BIT(8)
  372. #define SDMMC_CMD_RESP_LONG BIT(7)
  373. #define SDMMC_CMD_RESP_EXP BIT(6)
  374. #define SDMMC_CMD_INDX(n) ((n) & 0x1F)
  375. /* Status register defines */
  376. #define SDMMC_GET_FCNT(x) (((x)>>17) & 0x1FFF)
  377. #define SDMMC_STATUS_DMA_REQ BIT(31)
  378. #define SDMMC_STATUS_BUSY BIT(9)
  379. /* FIFOTH register defines */
  380. #define SDMMC_SET_FIFOTH(m, r, t) (((m) & 0x7) << 28 | \
  381. ((r) & 0xFFF) << 16 | \
  382. ((t) & 0xFFF))
  383. /* HCON register defines */
  384. #define DMA_INTERFACE_IDMA (0x0)
  385. #define DMA_INTERFACE_DWDMA (0x1)
  386. #define DMA_INTERFACE_GDMA (0x2)
  387. #define DMA_INTERFACE_NODMA (0x3)
  388. #define SDMMC_GET_TRANS_MODE(x) (((x)>>16) & 0x3)
  389. #define SDMMC_GET_SLOT_NUM(x) ((((x)>>1) & 0x1F) + 1)
  390. #define SDMMC_GET_HDATA_WIDTH(x) (((x)>>7) & 0x7)
  391. #define SDMMC_GET_ADDR_CONFIG(x) (((x)>>27) & 0x1)
  392. /* Internal DMAC interrupt defines */
  393. #define SDMMC_IDMAC_INT_AI BIT(9)
  394. #define SDMMC_IDMAC_INT_NI BIT(8)
  395. #define SDMMC_IDMAC_INT_CES BIT(5)
  396. #define SDMMC_IDMAC_INT_DU BIT(4)
  397. #define SDMMC_IDMAC_INT_FBE BIT(2)
  398. #define SDMMC_IDMAC_INT_RI BIT(1)
  399. #define SDMMC_IDMAC_INT_TI BIT(0)
  400. /* Internal DMAC bus mode bits */
  401. #define SDMMC_IDMAC_ENABLE BIT(7)
  402. #define SDMMC_IDMAC_FB BIT(1)
  403. #define SDMMC_IDMAC_SWRESET BIT(0)
  404. /* H/W reset */
  405. #define SDMMC_RST_HWACTIVE 0x1
  406. /* Version ID register define */
  407. #define SDMMC_GET_VERID(x) ((x) & 0xFFFF)
  408. /* Card read threshold */
  409. #define SDMMC_SET_THLD(v, x) (((v) & 0xFFF) << 16 | (x))
  410. #define SDMMC_CARD_WR_THR_EN BIT(2)
  411. #define SDMMC_CARD_RD_THR_EN BIT(0)
  412. /* UHS-1 register defines */
  413. #define SDMMC_UHS_18V BIT(0)
  414. /* All ctrl reset bits */
  415. #define SDMMC_CTRL_ALL_RESET_FLAGS \
  416. (SDMMC_CTRL_RESET | SDMMC_CTRL_FIFO_RESET | SDMMC_CTRL_DMA_RESET)
  417. /* FIFO register access macros. These should not change the data endian-ness
  418. * as they are written to memory to be dealt with by the upper layers */
  419. #define mci_fifo_readw(__reg) __raw_readw(__reg)
  420. #define mci_fifo_readl(__reg) __raw_readl(__reg)
  421. #define mci_fifo_readq(__reg) __raw_readq(__reg)
  422. #define mci_fifo_writew(__value, __reg) __raw_writew(__reg, __value)
  423. #define mci_fifo_writel(__value, __reg) __raw_writel(__reg, __value)
  424. #define mci_fifo_writeq(__value, __reg) __raw_writeq(__reg, __value)
  425. /* Register access macros */
  426. #define mci_readl(dev, reg) \
  427. readl_relaxed((dev)->regs + SDMMC_##reg)
  428. #define mci_writel(dev, reg, value) \
  429. writel_relaxed((value), (dev)->regs + SDMMC_##reg)
  430. /* 16-bit FIFO access macros */
  431. #define mci_readw(dev, reg) \
  432. readw_relaxed((dev)->regs + SDMMC_##reg)
  433. #define mci_writew(dev, reg, value) \
  434. writew_relaxed((value), (dev)->regs + SDMMC_##reg)
  435. /* 64-bit FIFO access macros */
  436. #ifdef readq
  437. #define mci_readq(dev, reg) \
  438. readq_relaxed((dev)->regs + SDMMC_##reg)
  439. #define mci_writeq(dev, reg, value) \
  440. writeq_relaxed((value), (dev)->regs + SDMMC_##reg)
  441. #else
  442. /*
  443. * Dummy readq implementation for architectures that don't define it.
  444. *
  445. * We would assume that none of these architectures would configure
  446. * the IP block with a 64bit FIFO width, so this code will never be
  447. * executed on those machines. Defining these macros here keeps the
  448. * rest of the code free from ifdefs.
  449. */
  450. #define mci_readq(dev, reg) \
  451. (*(volatile u64 __force *)((dev)->regs + SDMMC_##reg))
  452. #define mci_writeq(dev, reg, value) \
  453. (*(volatile u64 __force *)((dev)->regs + SDMMC_##reg) = (value))
  454. #define __raw_writeq(__value, __reg) \
  455. (*(volatile u64 __force *)(__reg) = (__value))
  456. #define __raw_readq(__reg) (*(volatile u64 __force *)(__reg))
  457. #endif
  458. extern int dw_mci_probe(struct dw_mci *host);
  459. extern void dw_mci_remove(struct dw_mci *host);
  460. #ifdef CONFIG_PM
  461. extern int dw_mci_runtime_suspend(struct device *device);
  462. extern int dw_mci_runtime_resume(struct device *device);
  463. #endif
  464. /**
  465. * struct dw_mci_slot - MMC slot state
  466. * @mmc: The mmc_host representing this slot.
  467. * @host: The MMC controller this slot is using.
  468. * @ctype: Card type for this slot.
  469. * @mrq: mmc_request currently being processed or waiting to be
  470. * processed, or NULL when the slot is idle.
  471. * @queue_node: List node for placing this node in the @queue list of
  472. * &struct dw_mci.
  473. * @clock: Clock rate configured by set_ios(). Protected by host->lock.
  474. * @__clk_old: The last clock value that was requested from core.
  475. * Keeping track of this helps us to avoid spamming the console.
  476. * @flags: Random state bits associated with the slot.
  477. * @id: Number of this slot.
  478. * @sdio_id: Number of this slot in the SDIO interrupt registers.
  479. */
  480. struct dw_mci_slot {
  481. struct mmc_host *mmc;
  482. struct dw_mci *host;
  483. u32 ctype;
  484. struct mmc_request *mrq;
  485. struct list_head queue_node;
  486. unsigned int clock;
  487. unsigned int __clk_old;
  488. unsigned long flags;
  489. #define DW_MMC_CARD_PRESENT 0
  490. #define DW_MMC_CARD_NEED_INIT 1
  491. #define DW_MMC_CARD_NO_LOW_PWR 2
  492. #define DW_MMC_CARD_NO_USE_HOLD 3
  493. #define DW_MMC_CARD_NEEDS_POLL 4
  494. int id;
  495. int sdio_id;
  496. };
  497. /**
  498. * dw_mci driver data - dw-mshc implementation specific driver data.
  499. * @caps: mmc subsystem specified capabilities of the controller(s).
  500. * @init: early implementation specific initialization.
  501. * @set_ios: handle bus specific extensions.
  502. * @parse_dt: parse implementation specific device tree properties.
  503. * @execute_tuning: implementation specific tuning procedure.
  504. *
  505. * Provide controller implementation specific extensions. The usage of this
  506. * data structure is fully optional and usage of each member in this structure
  507. * is optional as well.
  508. */
  509. struct dw_mci_drv_data {
  510. unsigned long *caps;
  511. int (*init)(struct dw_mci *host);
  512. void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
  513. int (*parse_dt)(struct dw_mci *host);
  514. int (*execute_tuning)(struct dw_mci_slot *slot, u32 opcode);
  515. int (*prepare_hs400_tuning)(struct dw_mci *host,
  516. struct mmc_ios *ios);
  517. int (*switch_voltage)(struct mmc_host *mmc,
  518. struct mmc_ios *ios);
  519. };
  520. #endif /* _DW_MMC_H_ */