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