xref: /rk3399_rockchip-uboot/include/sdhci.h (revision 6d0e34bf4e21596563e5f5950d097a2eab4c81a8)
1af62a557SLei Wen /*
2af62a557SLei Wen  * Copyright 2011, Marvell Semiconductor Inc.
3af62a557SLei Wen  * Lei Wen <leiwen@marvell.com>
4af62a557SLei Wen  *
51a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
6af62a557SLei Wen  *
7af62a557SLei Wen  * Back ported to the 8xx platform (from the 8260 platform) by
8af62a557SLei Wen  * Murray.Jensen@cmst.csiro.au, 27-Jan-01.
9af62a557SLei Wen  */
10af62a557SLei Wen #ifndef __SDHCI_HW_H
11af62a557SLei Wen #define __SDHCI_HW_H
12af62a557SLei Wen 
13af62a557SLei Wen #include <asm/io.h>
146cf1b17cSLei Wen #include <mmc.h>
150347960bSSimon Glass #include <asm/gpio.h>
166cf1b17cSLei Wen 
17af62a557SLei Wen /*
18af62a557SLei Wen  * Controller registers
19af62a557SLei Wen  */
20af62a557SLei Wen 
21af62a557SLei Wen #define SDHCI_DMA_ADDRESS	0x00
22af62a557SLei Wen 
23af62a557SLei Wen #define SDHCI_BLOCK_SIZE	0x04
24af62a557SLei Wen #define  SDHCI_MAKE_BLKSZ(dma, blksz) (((dma & 0x7) << 12) | (blksz & 0xFFF))
25af62a557SLei Wen 
26af62a557SLei Wen #define SDHCI_BLOCK_COUNT	0x06
27af62a557SLei Wen 
28af62a557SLei Wen #define SDHCI_ARGUMENT		0x08
29af62a557SLei Wen 
30af62a557SLei Wen #define SDHCI_TRANSFER_MODE	0x0C
3191914581SJaehoon Chung #define  SDHCI_TRNS_DMA		BIT(0)
3291914581SJaehoon Chung #define  SDHCI_TRNS_BLK_CNT_EN	BIT(1)
3391914581SJaehoon Chung #define  SDHCI_TRNS_ACMD12	BIT(2)
3491914581SJaehoon Chung #define  SDHCI_TRNS_READ	BIT(4)
3591914581SJaehoon Chung #define  SDHCI_TRNS_MULTI	BIT(5)
36af62a557SLei Wen 
37af62a557SLei Wen #define SDHCI_COMMAND		0x0E
38af62a557SLei Wen #define  SDHCI_CMD_RESP_MASK	0x03
39af62a557SLei Wen #define  SDHCI_CMD_CRC		0x08
40af62a557SLei Wen #define  SDHCI_CMD_INDEX	0x10
41af62a557SLei Wen #define  SDHCI_CMD_DATA		0x20
42af62a557SLei Wen #define  SDHCI_CMD_ABORTCMD	0xC0
43af62a557SLei Wen 
44af62a557SLei Wen #define  SDHCI_CMD_RESP_NONE	0x00
45af62a557SLei Wen #define  SDHCI_CMD_RESP_LONG	0x01
46af62a557SLei Wen #define  SDHCI_CMD_RESP_SHORT	0x02
47af62a557SLei Wen #define  SDHCI_CMD_RESP_SHORT_BUSY 0x03
48af62a557SLei Wen 
49af62a557SLei Wen #define SDHCI_MAKE_CMD(c, f) (((c & 0xff) << 8) | (f & 0xff))
50af62a557SLei Wen #define SDHCI_GET_CMD(c) ((c>>8) & 0x3f)
51af62a557SLei Wen 
52af62a557SLei Wen #define SDHCI_RESPONSE		0x10
53af62a557SLei Wen 
54af62a557SLei Wen #define SDHCI_BUFFER		0x20
55af62a557SLei Wen 
56af62a557SLei Wen #define SDHCI_PRESENT_STATE	0x24
5791914581SJaehoon Chung #define  SDHCI_CMD_INHIBIT	BIT(0)
5891914581SJaehoon Chung #define  SDHCI_DATA_INHIBIT	BIT(1)
5991914581SJaehoon Chung #define  SDHCI_DOING_WRITE	BIT(8)
6091914581SJaehoon Chung #define  SDHCI_DOING_READ	BIT(9)
6191914581SJaehoon Chung #define  SDHCI_SPACE_AVAILABLE	BIT(10)
6291914581SJaehoon Chung #define  SDHCI_DATA_AVAILABLE	BIT(11)
6391914581SJaehoon Chung #define  SDHCI_CARD_PRESENT	BIT(16)
6491914581SJaehoon Chung #define  SDHCI_CARD_STATE_STABLE	BIT(17)
6591914581SJaehoon Chung #define  SDHCI_CARD_DETECT_PIN_LEVEL	BIT(18)
6691914581SJaehoon Chung #define  SDHCI_WRITE_PROTECT	BIT(19)
67af62a557SLei Wen 
68af62a557SLei Wen #define SDHCI_HOST_CONTROL	0x28
6991914581SJaehoon Chung #define  SDHCI_CTRL_LED		BIT(0)
7091914581SJaehoon Chung #define  SDHCI_CTRL_4BITBUS	BIT(1)
7191914581SJaehoon Chung #define  SDHCI_CTRL_HISPD	BIT(2)
72af62a557SLei Wen #define  SDHCI_CTRL_DMA_MASK	0x18
73af62a557SLei Wen #define   SDHCI_CTRL_SDMA	0x00
74af62a557SLei Wen #define   SDHCI_CTRL_ADMA1	0x08
75af62a557SLei Wen #define   SDHCI_CTRL_ADMA32	0x10
76af62a557SLei Wen #define   SDHCI_CTRL_ADMA64	0x18
7791914581SJaehoon Chung #define  SDHCI_CTRL_8BITBUS	BIT(5)
7891914581SJaehoon Chung #define  SDHCI_CTRL_CD_TEST_INS	BIT(6)
7991914581SJaehoon Chung #define  SDHCI_CTRL_CD_TEST	BIT(7)
80af62a557SLei Wen 
81af62a557SLei Wen #define SDHCI_POWER_CONTROL	0x29
82af62a557SLei Wen #define  SDHCI_POWER_ON		0x01
83af62a557SLei Wen #define  SDHCI_POWER_180	0x0A
84af62a557SLei Wen #define  SDHCI_POWER_300	0x0C
85af62a557SLei Wen #define  SDHCI_POWER_330	0x0E
86af62a557SLei Wen 
87af62a557SLei Wen #define SDHCI_BLOCK_GAP_CONTROL	0x2A
88af62a557SLei Wen 
89af62a557SLei Wen #define SDHCI_WAKE_UP_CONTROL	0x2B
9091914581SJaehoon Chung #define  SDHCI_WAKE_ON_INT	BIT(0)
9191914581SJaehoon Chung #define  SDHCI_WAKE_ON_INSERT	BIT(1)
9291914581SJaehoon Chung #define  SDHCI_WAKE_ON_REMOVE	BIT(2)
93af62a557SLei Wen 
94af62a557SLei Wen #define SDHCI_CLOCK_CONTROL	0x2C
95af62a557SLei Wen #define  SDHCI_DIVIDER_SHIFT	8
96af62a557SLei Wen #define  SDHCI_DIVIDER_HI_SHIFT	6
97af62a557SLei Wen #define  SDHCI_DIV_MASK	0xFF
98af62a557SLei Wen #define  SDHCI_DIV_MASK_LEN	8
99af62a557SLei Wen #define  SDHCI_DIV_HI_MASK	0x300
10091914581SJaehoon Chung #define  SDHCI_PROG_CLOCK_MODE  BIT(5)
10191914581SJaehoon Chung #define  SDHCI_CLOCK_CARD_EN	BIT(2)
10291914581SJaehoon Chung #define  SDHCI_CLOCK_INT_STABLE	BIT(1)
10391914581SJaehoon Chung #define  SDHCI_CLOCK_INT_EN	BIT(0)
104af62a557SLei Wen 
105af62a557SLei Wen #define SDHCI_TIMEOUT_CONTROL	0x2E
106af62a557SLei Wen 
107af62a557SLei Wen #define SDHCI_SOFTWARE_RESET	0x2F
108af62a557SLei Wen #define  SDHCI_RESET_ALL	0x01
109af62a557SLei Wen #define  SDHCI_RESET_CMD	0x02
110af62a557SLei Wen #define  SDHCI_RESET_DATA	0x04
111af62a557SLei Wen 
112af62a557SLei Wen #define SDHCI_INT_STATUS	0x30
113af62a557SLei Wen #define SDHCI_INT_ENABLE	0x34
114af62a557SLei Wen #define SDHCI_SIGNAL_ENABLE	0x38
11591914581SJaehoon Chung #define  SDHCI_INT_RESPONSE	BIT(0)
11691914581SJaehoon Chung #define  SDHCI_INT_DATA_END	BIT(1)
11791914581SJaehoon Chung #define  SDHCI_INT_DMA_END	BIT(3)
11891914581SJaehoon Chung #define  SDHCI_INT_SPACE_AVAIL	BIT(4)
11991914581SJaehoon Chung #define  SDHCI_INT_DATA_AVAIL	BIT(5)
12091914581SJaehoon Chung #define  SDHCI_INT_CARD_INSERT	BIT(6)
12191914581SJaehoon Chung #define  SDHCI_INT_CARD_REMOVE	BIT(7)
12291914581SJaehoon Chung #define  SDHCI_INT_CARD_INT	BIT(8)
12391914581SJaehoon Chung #define  SDHCI_INT_ERROR	BIT(15)
12491914581SJaehoon Chung #define  SDHCI_INT_TIMEOUT	BIT(16)
12591914581SJaehoon Chung #define  SDHCI_INT_CRC		BIT(17)
12691914581SJaehoon Chung #define  SDHCI_INT_END_BIT	BIT(18)
12791914581SJaehoon Chung #define  SDHCI_INT_INDEX	BIT(19)
12891914581SJaehoon Chung #define  SDHCI_INT_DATA_TIMEOUT	BIT(20)
12991914581SJaehoon Chung #define  SDHCI_INT_DATA_CRC	BIT(21)
13091914581SJaehoon Chung #define  SDHCI_INT_DATA_END_BIT	BIT(22)
13191914581SJaehoon Chung #define  SDHCI_INT_BUS_POWER	BIT(23)
13291914581SJaehoon Chung #define  SDHCI_INT_ACMD12ERR	BIT(24)
13391914581SJaehoon Chung #define  SDHCI_INT_ADMA_ERROR	BIT(25)
134af62a557SLei Wen 
135af62a557SLei Wen #define  SDHCI_INT_NORMAL_MASK	0x00007FFF
136af62a557SLei Wen #define  SDHCI_INT_ERROR_MASK	0xFFFF8000
137af62a557SLei Wen 
138af62a557SLei Wen #define  SDHCI_INT_CMD_MASK	(SDHCI_INT_RESPONSE | SDHCI_INT_TIMEOUT | \
139af62a557SLei Wen 		SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX)
140af62a557SLei Wen #define  SDHCI_INT_DATA_MASK	(SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \
141af62a557SLei Wen 		SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \
142af62a557SLei Wen 		SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \
143af62a557SLei Wen 		SDHCI_INT_DATA_END_BIT | SDHCI_INT_ADMA_ERROR)
144af62a557SLei Wen #define SDHCI_INT_ALL_MASK	((unsigned int)-1)
145af62a557SLei Wen 
146af62a557SLei Wen #define SDHCI_ACMD12_ERR	0x3C
147af62a557SLei Wen 
148af62a557SLei Wen /* 3E-3F reserved */
149af62a557SLei Wen 
150af62a557SLei Wen #define SDHCI_CAPABILITIES	0x40
151af62a557SLei Wen #define  SDHCI_TIMEOUT_CLK_MASK	0x0000003F
152af62a557SLei Wen #define  SDHCI_TIMEOUT_CLK_SHIFT 0
153af62a557SLei Wen #define  SDHCI_TIMEOUT_CLK_UNIT	0x00000080
154af62a557SLei Wen #define  SDHCI_CLOCK_BASE_MASK	0x00003F00
155af62a557SLei Wen #define  SDHCI_CLOCK_V3_BASE_MASK	0x0000FF00
156af62a557SLei Wen #define  SDHCI_CLOCK_BASE_SHIFT	8
157af62a557SLei Wen #define  SDHCI_MAX_BLOCK_MASK	0x00030000
158af62a557SLei Wen #define  SDHCI_MAX_BLOCK_SHIFT  16
15991914581SJaehoon Chung #define  SDHCI_CAN_DO_8BIT	BIT(18)
16091914581SJaehoon Chung #define  SDHCI_CAN_DO_ADMA2	BIT(19)
16191914581SJaehoon Chung #define  SDHCI_CAN_DO_ADMA1	BIT(20)
16291914581SJaehoon Chung #define  SDHCI_CAN_DO_HISPD	BIT(21)
16391914581SJaehoon Chung #define  SDHCI_CAN_DO_SDMA	BIT(22)
16491914581SJaehoon Chung #define  SDHCI_CAN_VDD_330	BIT(24)
16591914581SJaehoon Chung #define  SDHCI_CAN_VDD_300	BIT(25)
16691914581SJaehoon Chung #define  SDHCI_CAN_VDD_180	BIT(26)
16791914581SJaehoon Chung #define  SDHCI_CAN_64BIT	BIT(28)
168af62a557SLei Wen 
169af62a557SLei Wen #define SDHCI_CAPABILITIES_1	0x44
170a0d0d86fSWenyou Yang #define  SDHCI_CLOCK_MUL_MASK	0x00FF0000
171a0d0d86fSWenyou Yang #define  SDHCI_CLOCK_MUL_SHIFT	16
172af62a557SLei Wen 
173af62a557SLei Wen #define SDHCI_MAX_CURRENT	0x48
174af62a557SLei Wen 
175af62a557SLei Wen /* 4C-4F reserved for more max current */
176af62a557SLei Wen 
177af62a557SLei Wen #define SDHCI_SET_ACMD12_ERROR	0x50
178af62a557SLei Wen #define SDHCI_SET_INT_ERROR	0x52
179af62a557SLei Wen 
180af62a557SLei Wen #define SDHCI_ADMA_ERROR	0x54
181af62a557SLei Wen 
182af62a557SLei Wen /* 55-57 reserved */
183af62a557SLei Wen 
184af62a557SLei Wen #define SDHCI_ADMA_ADDRESS	0x58
185af62a557SLei Wen 
186af62a557SLei Wen /* 60-FB reserved */
187af62a557SLei Wen 
188af62a557SLei Wen #define SDHCI_SLOT_INT_STATUS	0xFC
189af62a557SLei Wen 
190af62a557SLei Wen #define SDHCI_HOST_VERSION	0xFE
191af62a557SLei Wen #define  SDHCI_VENDOR_VER_MASK	0xFF00
192af62a557SLei Wen #define  SDHCI_VENDOR_VER_SHIFT	8
193af62a557SLei Wen #define  SDHCI_SPEC_VER_MASK	0x00FF
194af62a557SLei Wen #define  SDHCI_SPEC_VER_SHIFT	0
195af62a557SLei Wen #define   SDHCI_SPEC_100	0
196af62a557SLei Wen #define   SDHCI_SPEC_200	1
197af62a557SLei Wen #define   SDHCI_SPEC_300	2
198af62a557SLei Wen 
199113e5dfcSJaehoon Chung #define SDHCI_GET_VERSION(x) (x->version & SDHCI_SPEC_VER_MASK)
200113e5dfcSJaehoon Chung 
201af62a557SLei Wen /*
202af62a557SLei Wen  * End of controller registers.
203af62a557SLei Wen  */
204af62a557SLei Wen 
205af62a557SLei Wen #define SDHCI_MAX_DIV_SPEC_200	256
206af62a557SLei Wen #define SDHCI_MAX_DIV_SPEC_300	2046
207af62a557SLei Wen 
208af62a557SLei Wen /*
209af62a557SLei Wen  * quirks
210af62a557SLei Wen  */
211af62a557SLei Wen #define SDHCI_QUIRK_32BIT_DMA_ADDR	(1 << 0)
2125af9a569SAjay Bhargav #define SDHCI_QUIRK_REG32_RW		(1 << 1)
2133a638320SJaehoon Chung #define SDHCI_QUIRK_BROKEN_R1B		(1 << 2)
214236bfecfSJaehoon Chung #define SDHCI_QUIRK_NO_HISPD_BIT	(1 << 3)
215236bfecfSJaehoon Chung #define SDHCI_QUIRK_BROKEN_VOLTAGE	(1 << 4)
21613243f2eSTushar Behera #define SDHCI_QUIRK_WAIT_SEND_CMD	(1 << 6)
217113e5dfcSJaehoon Chung #define SDHCI_QUIRK_USE_WIDE8		(1 << 8)
218af62a557SLei Wen 
2190d2f15f9SLei Wen /* to make gcc happy */
2200d2f15f9SLei Wen struct sdhci_host;
2210d2f15f9SLei Wen 
222af62a557SLei Wen /*
223af62a557SLei Wen  * Host SDMA buffer boundary. Valid values from 4K to 512K in powers of 2.
224af62a557SLei Wen  */
225af62a557SLei Wen #define SDHCI_DEFAULT_BOUNDARY_SIZE	(512 * 1024)
226af62a557SLei Wen #define SDHCI_DEFAULT_BOUNDARY_ARG	(7)
227af62a557SLei Wen struct sdhci_ops {
228af62a557SLei Wen #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
229af62a557SLei Wen 	u32	(*read_l)(struct sdhci_host *host, int reg);
230af62a557SLei Wen 	u16	(*read_w)(struct sdhci_host *host, int reg);
231af62a557SLei Wen 	u8	(*read_b)(struct sdhci_host *host, int reg);
232af62a557SLei Wen 	void	(*write_l)(struct sdhci_host *host, u32 val, int reg);
233af62a557SLei Wen 	void	(*write_w)(struct sdhci_host *host, u16 val, int reg);
234af62a557SLei Wen 	void	(*write_b)(struct sdhci_host *host, u8 val, int reg);
235af62a557SLei Wen #endif
236309bf02cSJaehoon Chung 	int	(*get_cd)(struct sdhci_host *host);
23762226b68SJaehoon Chung 	void	(*set_control_reg)(struct sdhci_host *host);
23862226b68SJaehoon Chung 	void	(*set_clock)(struct sdhci_host *host, u32 div);
239af62a557SLei Wen };
240af62a557SLei Wen 
241af62a557SLei Wen struct sdhci_host {
242cacd1d2fSMasahiro Yamada 	const char *name;
243af62a557SLei Wen 	void *ioaddr;
244af62a557SLei Wen 	unsigned int quirks;
245236bfecfSJaehoon Chung 	unsigned int host_caps;
246af62a557SLei Wen 	unsigned int version;
247*6d0e34bfSStefan Herbrechtsmeier 	unsigned int max_clk;   /* Maximum Base Clock frequency */
2486dffdbc3SWenyou Yang 	unsigned int clk_mul;   /* Clock Multiplier value */
249af62a557SLei Wen 	unsigned int clock;
2506cf1b17cSLei Wen 	struct mmc *mmc;
251af62a557SLei Wen 	const struct sdhci_ops *ops;
252b09ed6e4SJaehoon Chung 	int index;
253236bfecfSJaehoon Chung 
2543577fe8bSPiotr Wilczek 	int bus_width;
2550347960bSSimon Glass 	struct gpio_desc pwr_gpio;	/* Power GPIO */
2560347960bSSimon Glass 	struct gpio_desc cd_gpio;		/* Card Detect GPIO */
2573577fe8bSPiotr Wilczek 
258236bfecfSJaehoon Chung 	uint	voltages;
25993bfd616SPantelis Antoniou 
26093bfd616SPantelis Antoniou 	struct mmc_config cfg;
261af62a557SLei Wen };
262af62a557SLei Wen 
263af62a557SLei Wen #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
264af62a557SLei Wen 
265af62a557SLei Wen static inline void sdhci_writel(struct sdhci_host *host, u32 val, int reg)
266af62a557SLei Wen {
267af62a557SLei Wen 	if (unlikely(host->ops->write_l))
268af62a557SLei Wen 		host->ops->write_l(host, val, reg);
269af62a557SLei Wen 	else
270af62a557SLei Wen 		writel(val, host->ioaddr + reg);
271af62a557SLei Wen }
272af62a557SLei Wen 
273af62a557SLei Wen static inline void sdhci_writew(struct sdhci_host *host, u16 val, int reg)
274af62a557SLei Wen {
275af62a557SLei Wen 	if (unlikely(host->ops->write_w))
276af62a557SLei Wen 		host->ops->write_w(host, val, reg);
277af62a557SLei Wen 	else
278af62a557SLei Wen 		writew(val, host->ioaddr + reg);
279af62a557SLei Wen }
280af62a557SLei Wen 
281af62a557SLei Wen static inline void sdhci_writeb(struct sdhci_host *host, u8 val, int reg)
282af62a557SLei Wen {
283af62a557SLei Wen 	if (unlikely(host->ops->write_b))
284af62a557SLei Wen 		host->ops->write_b(host, val, reg);
285af62a557SLei Wen 	else
286af62a557SLei Wen 		writeb(val, host->ioaddr + reg);
287af62a557SLei Wen }
288af62a557SLei Wen 
289af62a557SLei Wen static inline u32 sdhci_readl(struct sdhci_host *host, int reg)
290af62a557SLei Wen {
291af62a557SLei Wen 	if (unlikely(host->ops->read_l))
292af62a557SLei Wen 		return host->ops->read_l(host, reg);
293af62a557SLei Wen 	else
294af62a557SLei Wen 		return readl(host->ioaddr + reg);
295af62a557SLei Wen }
296af62a557SLei Wen 
297af62a557SLei Wen static inline u16 sdhci_readw(struct sdhci_host *host, int reg)
298af62a557SLei Wen {
299af62a557SLei Wen 	if (unlikely(host->ops->read_w))
300af62a557SLei Wen 		return host->ops->read_w(host, reg);
301af62a557SLei Wen 	else
302af62a557SLei Wen 		return readw(host->ioaddr + reg);
303af62a557SLei Wen }
304af62a557SLei Wen 
305af62a557SLei Wen static inline u8 sdhci_readb(struct sdhci_host *host, int reg)
306af62a557SLei Wen {
307af62a557SLei Wen 	if (unlikely(host->ops->read_b))
308af62a557SLei Wen 		return host->ops->read_b(host, reg);
309af62a557SLei Wen 	else
310af62a557SLei Wen 		return readb(host->ioaddr + reg);
311af62a557SLei Wen }
312af62a557SLei Wen 
313af62a557SLei Wen #else
314af62a557SLei Wen 
315af62a557SLei Wen static inline void sdhci_writel(struct sdhci_host *host, u32 val, int reg)
316af62a557SLei Wen {
317af62a557SLei Wen 	writel(val, host->ioaddr + reg);
318af62a557SLei Wen }
319af62a557SLei Wen 
320af62a557SLei Wen static inline void sdhci_writew(struct sdhci_host *host, u16 val, int reg)
321af62a557SLei Wen {
322af62a557SLei Wen 	writew(val, host->ioaddr + reg);
323af62a557SLei Wen }
324af62a557SLei Wen 
325af62a557SLei Wen static inline void sdhci_writeb(struct sdhci_host *host, u8 val, int reg)
326af62a557SLei Wen {
327af62a557SLei Wen 	writeb(val, host->ioaddr + reg);
328af62a557SLei Wen }
329af62a557SLei Wen static inline u32 sdhci_readl(struct sdhci_host *host, int reg)
330af62a557SLei Wen {
331af62a557SLei Wen 	return readl(host->ioaddr + reg);
332af62a557SLei Wen }
333af62a557SLei Wen 
334af62a557SLei Wen static inline u16 sdhci_readw(struct sdhci_host *host, int reg)
335af62a557SLei Wen {
336af62a557SLei Wen 	return readw(host->ioaddr + reg);
337af62a557SLei Wen }
338af62a557SLei Wen 
339af62a557SLei Wen static inline u8 sdhci_readb(struct sdhci_host *host, int reg)
340af62a557SLei Wen {
341af62a557SLei Wen 	return readb(host->ioaddr + reg);
342af62a557SLei Wen }
343af62a557SLei Wen #endif
344af62a557SLei Wen 
345ef1e4edaSSimon Glass #ifdef CONFIG_BLK
346ef1e4edaSSimon Glass /**
347ef1e4edaSSimon Glass  * sdhci_setup_cfg() - Set up the configuration for DWMMC
348ef1e4edaSSimon Glass  *
349ef1e4edaSSimon Glass  * This is used to set up an SDHCI device when you are using CONFIG_BLK.
350ef1e4edaSSimon Glass  *
351ef1e4edaSSimon Glass  * This should be called from your MMC driver's probe() method once you have
352ef1e4edaSSimon Glass  * the information required.
353ef1e4edaSSimon Glass  *
354ef1e4edaSSimon Glass  * Generally your driver will have a platform data structure which holds both
355ef1e4edaSSimon Glass  * the configuration (struct mmc_config) and the MMC device info (struct mmc).
356ef1e4edaSSimon Glass  * For example:
357ef1e4edaSSimon Glass  *
358ef1e4edaSSimon Glass  * struct msm_sdhc_plat {
359ef1e4edaSSimon Glass  *	struct mmc_config cfg;
360ef1e4edaSSimon Glass  *	struct mmc mmc;
361ef1e4edaSSimon Glass  * };
362ef1e4edaSSimon Glass  *
363ef1e4edaSSimon Glass  * ...
364ef1e4edaSSimon Glass  *
365ef1e4edaSSimon Glass  * Inside U_BOOT_DRIVER():
366ef1e4edaSSimon Glass  *	.platdata_auto_alloc_size = sizeof(struct msm_sdhc_plat),
367ef1e4edaSSimon Glass  *
368ef1e4edaSSimon Glass  * To access platform data:
369ef1e4edaSSimon Glass  *	struct msm_sdhc_plat *plat = dev_get_platdata(dev);
370ef1e4edaSSimon Glass  *
371ef1e4edaSSimon Glass  * See msm_sdhci.c for an example.
372ef1e4edaSSimon Glass  *
373ef1e4edaSSimon Glass  * @cfg:	Configuration structure to fill in (generally &plat->mmc)
37414bed52dSJaehoon Chung  * @host:	SDHCI host structure
375*6d0e34bfSStefan Herbrechtsmeier  * @f_max:	Maximum supported clock frequency in HZ (0 for default)
376*6d0e34bfSStefan Herbrechtsmeier  * @f_min:	Minimum supported clock frequency in HZ (0 for default)
377ef1e4edaSSimon Glass  */
37814bed52dSJaehoon Chung int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host,
379*6d0e34bfSStefan Herbrechtsmeier 		    u32 f_max, u32 f_min);
380ef1e4edaSSimon Glass 
381ef1e4edaSSimon Glass /**
382ef1e4edaSSimon Glass  * sdhci_bind() - Set up a new MMC block device
383ef1e4edaSSimon Glass  *
384ef1e4edaSSimon Glass  * This is used to set up an SDHCI block device when you are using CONFIG_BLK.
385ef1e4edaSSimon Glass  * It should be called from your driver's bind() method.
386ef1e4edaSSimon Glass  *
387ef1e4edaSSimon Glass  * See msm_sdhci.c for an example.
388ef1e4edaSSimon Glass  *
389ef1e4edaSSimon Glass  * @dev:	Device to set up
390ef1e4edaSSimon Glass  * @mmc:	Pointer to mmc structure (normally &plat->mmc)
391ef1e4edaSSimon Glass  * @cfg:	Empty configuration structure (generally &plat->cfg). This is
392ef1e4edaSSimon Glass  *		normally all zeroes at this point. The only purpose of passing
393ef1e4edaSSimon Glass  *		this in is to set mmc->cfg to it.
394ef1e4edaSSimon Glass  * @return 0 if OK, -ve if the block device could not be created
395ef1e4edaSSimon Glass  */
396ef1e4edaSSimon Glass int sdhci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg);
397ef1e4edaSSimon Glass #else
398ef1e4edaSSimon Glass 
399ef1e4edaSSimon Glass /**
400ef1e4edaSSimon Glass  * add_sdhci() - Add a new SDHCI interface
401ef1e4edaSSimon Glass  *
402ef1e4edaSSimon Glass  * This is used when you are not using CONFIG_BLK. Convert your driver over!
403ef1e4edaSSimon Glass  *
404ef1e4edaSSimon Glass  * @host:	SDHCI host structure
405*6d0e34bfSStefan Herbrechtsmeier  * @f_max:	Maximum supported clock frequency in HZ (0 for default)
406*6d0e34bfSStefan Herbrechtsmeier  * @f_min:	Minimum supported clock frequency in HZ (0 for default)
407ef1e4edaSSimon Glass  * @return 0 if OK, -ve on error
408ef1e4edaSSimon Glass  */
409*6d0e34bfSStefan Herbrechtsmeier int add_sdhci(struct sdhci_host *host, u32 f_max, u32 f_min);
410ef1e4edaSSimon Glass #endif /* !CONFIG_BLK */
411ef1e4edaSSimon Glass 
412ef1e4edaSSimon Glass #ifdef CONFIG_DM_MMC_OPS
413ef1e4edaSSimon Glass /* Export the operations to drivers */
414ef1e4edaSSimon Glass int sdhci_probe(struct udevice *dev);
415ef1e4edaSSimon Glass extern const struct dm_mmc_ops sdhci_ops;
416ef1e4edaSSimon Glass #else
417ef1e4edaSSimon Glass #endif
418ef1e4edaSSimon Glass 
419af62a557SLei Wen #endif /* __SDHCI_HW_H */
420