blob: 0ac4370cd98029c9672c0875496ff6fefaa89254 [file] [log] [blame]
Wolfram Sang95f25ef2010-10-15 12:21:04 +02001/*
2 * Freescale eSDHC i.MX controller driver for the platform bus.
3 *
4 * derived from the OF-version.
5 *
6 * Copyright (c) 2010 Pengutronix e.K.
7 * Author: Wolfram Sang <w.sang@pengutronix.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License.
12 */
13
14#include <linux/io.h>
15#include <linux/delay.h>
16#include <linux/err.h>
17#include <linux/clk.h>
Wolfram Sang0c6d49c2011-02-26 14:44:39 +010018#include <linux/gpio.h>
Shawn Guo66506f72011-08-15 10:28:18 +080019#include <linux/module.h>
Richard Zhue1498602011-03-25 09:18:27 -040020#include <linux/slab.h>
Wolfram Sang95f25ef2010-10-15 12:21:04 +020021#include <linux/mmc/host.h>
Richard Zhu58ac8172011-03-21 13:22:16 +080022#include <linux/mmc/mmc.h>
23#include <linux/mmc/sdio.h>
Shawn Guofbe5fdd2012-12-11 22:32:20 +080024#include <linux/mmc/slot-gpio.h>
Shawn Guoabfafc22011-06-30 15:44:44 +080025#include <linux/of.h>
26#include <linux/of_device.h>
27#include <linux/of_gpio.h>
Dong Aishenge62d8b82012-05-11 14:56:01 +080028#include <linux/pinctrl/consumer.h>
Arnd Bergmann82906b12012-08-24 15:14:29 +020029#include <linux/platform_data/mmc-esdhc-imx.h>
Wolfram Sang95f25ef2010-10-15 12:21:04 +020030#include "sdhci-pltfm.h"
31#include "sdhci-esdhc.h"
32
Shawn Guo60bf6392013-01-15 23:36:53 +080033#define ESDHC_CTRL_D3CD 0x08
Richard Zhu58ac8172011-03-21 13:22:16 +080034/* VENDOR SPEC register */
Shawn Guo60bf6392013-01-15 23:36:53 +080035#define ESDHC_VENDOR_SPEC 0xc0
36#define ESDHC_VENDOR_SPEC_SDIO_QUIRK (1 << 1)
Dong Aisheng03221912013-09-13 19:11:34 +080037#define ESDHC_VENDOR_SPEC_VSELECT (1 << 1)
Dong Aishengfed2f6e2013-09-13 19:11:33 +080038#define ESDHC_VENDOR_SPEC_FRC_SDCLK_ON (1 << 8)
Shawn Guo60bf6392013-01-15 23:36:53 +080039#define ESDHC_WTMK_LVL 0x44
40#define ESDHC_MIX_CTRL 0x48
Dong Aishengde5bdbf2013-10-18 19:48:46 +080041#define ESDHC_MIX_CTRL_DDREN (1 << 3)
Shawn Guo2a15f982013-01-21 19:02:26 +080042#define ESDHC_MIX_CTRL_AC23EN (1 << 7)
Dong Aisheng03221912013-09-13 19:11:34 +080043#define ESDHC_MIX_CTRL_EXE_TUNE (1 << 22)
44#define ESDHC_MIX_CTRL_SMPCLK_SEL (1 << 23)
45#define ESDHC_MIX_CTRL_FBCLK_SEL (1 << 25)
Shawn Guo2a15f982013-01-21 19:02:26 +080046/* Bits 3 and 6 are not SDHCI standard definitions */
47#define ESDHC_MIX_CTRL_SDHCI_MASK 0xb7
Dong Aishengd131a712013-11-04 16:38:26 +080048/* Tuning bits */
49#define ESDHC_MIX_CTRL_TUNING_MASK 0x03c00000
Richard Zhu58ac8172011-03-21 13:22:16 +080050
Dong Aisheng602519b2013-10-18 19:48:47 +080051/* dll control register */
52#define ESDHC_DLL_CTRL 0x60
53#define ESDHC_DLL_OVERRIDE_VAL_SHIFT 9
54#define ESDHC_DLL_OVERRIDE_EN_SHIFT 8
55
Dong Aisheng03221912013-09-13 19:11:34 +080056/* tune control register */
57#define ESDHC_TUNE_CTRL_STATUS 0x68
58#define ESDHC_TUNE_CTRL_STEP 1
59#define ESDHC_TUNE_CTRL_MIN 0
60#define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1)
61
Dong Aisheng6e9fd282013-10-18 19:48:43 +080062#define ESDHC_TUNING_CTRL 0xcc
63#define ESDHC_STD_TUNING_EN (1 << 24)
64/* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
65#define ESDHC_TUNING_START_TAP 0x1
66
Dong Aisheng03221912013-09-13 19:11:34 +080067#define ESDHC_TUNING_BLOCK_PATTERN_LEN 64
68
Dong Aishengad932202013-09-13 19:11:35 +080069/* pinctrl state */
70#define ESDHC_PINCTRL_STATE_100MHZ "state_100mhz"
71#define ESDHC_PINCTRL_STATE_200MHZ "state_200mhz"
72
Richard Zhu58ac8172011-03-21 13:22:16 +080073/*
Sascha Haueraf510792013-01-21 19:02:28 +080074 * Our interpretation of the SDHCI_HOST_CONTROL register
75 */
76#define ESDHC_CTRL_4BITBUS (0x1 << 1)
77#define ESDHC_CTRL_8BITBUS (0x2 << 1)
78#define ESDHC_CTRL_BUSWIDTH_MASK (0x3 << 1)
79
80/*
Richard Zhu97e4ba62011-08-11 16:51:46 -040081 * There is an INT DMA ERR mis-match between eSDHC and STD SDHC SPEC:
82 * Bit25 is used in STD SPEC, and is reserved in fsl eSDHC design,
83 * but bit28 is used as the INT DMA ERR in fsl eSDHC design.
84 * Define this macro DMA error INT for fsl eSDHC
85 */
Shawn Guo60bf6392013-01-15 23:36:53 +080086#define ESDHC_INT_VENDOR_SPEC_DMA_ERR (1 << 28)
Richard Zhu97e4ba62011-08-11 16:51:46 -040087
88/*
Richard Zhu58ac8172011-03-21 13:22:16 +080089 * The CMDTYPE of the CMD register (offset 0xE) should be set to
90 * "11" when the STOP CMD12 is issued on imx53 to abort one
91 * open ended multi-blk IO. Otherwise the TC INT wouldn't
92 * be generated.
93 * In exact block transfer, the controller doesn't complete the
94 * operations automatically as required at the end of the
95 * transfer and remains on hold if the abort command is not sent.
96 * As a result, the TC flag is not asserted and SW received timeout
97 * exeception. Bit1 of Vendor Spec registor is used to fix it.
98 */
Shawn Guo31fbb302013-10-17 15:19:44 +080099#define ESDHC_FLAG_MULTIBLK_NO_INT BIT(1)
100/*
101 * The flag enables the workaround for ESDHC errata ENGcm07207 which
102 * affects i.MX25 and i.MX35.
103 */
104#define ESDHC_FLAG_ENGCM07207 BIT(2)
Shawn Guo9d61c002013-10-17 15:19:45 +0800105/*
106 * The flag tells that the ESDHC controller is an USDHC block that is
107 * integrated on the i.MX6 series.
108 */
109#define ESDHC_FLAG_USDHC BIT(3)
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800110/* The IP supports manual tuning process */
111#define ESDHC_FLAG_MAN_TUNING BIT(4)
112/* The IP supports standard tuning process */
113#define ESDHC_FLAG_STD_TUNING BIT(5)
114/* The IP has SDHCI_CAPABILITIES_1 register */
115#define ESDHC_FLAG_HAVE_CAP1 BIT(6)
Richard Zhue1498602011-03-25 09:18:27 -0400116
Shawn Guof47c4bb2013-10-17 15:19:47 +0800117struct esdhc_soc_data {
118 u32 flags;
119};
120
121static struct esdhc_soc_data esdhc_imx25_data = {
122 .flags = ESDHC_FLAG_ENGCM07207,
123};
124
125static struct esdhc_soc_data esdhc_imx35_data = {
126 .flags = ESDHC_FLAG_ENGCM07207,
127};
128
129static struct esdhc_soc_data esdhc_imx51_data = {
130 .flags = 0,
131};
132
133static struct esdhc_soc_data esdhc_imx53_data = {
134 .flags = ESDHC_FLAG_MULTIBLK_NO_INT,
135};
136
137static struct esdhc_soc_data usdhc_imx6q_data = {
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800138 .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING,
139};
140
141static struct esdhc_soc_data usdhc_imx6sl_data = {
142 .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
143 | ESDHC_FLAG_HAVE_CAP1,
Shawn Guo57ed3312011-06-30 09:24:26 +0800144};
145
Richard Zhue1498602011-03-25 09:18:27 -0400146struct pltfm_imx_data {
Richard Zhue1498602011-03-25 09:18:27 -0400147 u32 scratchpad;
Dong Aishenge62d8b82012-05-11 14:56:01 +0800148 struct pinctrl *pinctrl;
Dong Aishengad932202013-09-13 19:11:35 +0800149 struct pinctrl_state *pins_default;
150 struct pinctrl_state *pins_100mhz;
151 struct pinctrl_state *pins_200mhz;
Shawn Guof47c4bb2013-10-17 15:19:47 +0800152 const struct esdhc_soc_data *socdata;
Shawn Guo842afc02011-07-06 22:57:48 +0800153 struct esdhc_platform_data boarddata;
Sascha Hauer52dac612012-03-07 09:31:34 +0100154 struct clk *clk_ipg;
155 struct clk *clk_ahb;
156 struct clk *clk_per;
Lucas Stach361b8482013-03-15 09:49:26 +0100157 enum {
158 NO_CMD_PENDING, /* no multiblock command pending*/
159 MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */
160 WAIT_FOR_INT, /* sent CMD12, waiting for response INT */
161 } multiblock_status;
Dong Aisheng03221912013-09-13 19:11:34 +0800162 u32 uhs_mode;
Dong Aishengde5bdbf2013-10-18 19:48:46 +0800163 u32 is_ddr;
Richard Zhue1498602011-03-25 09:18:27 -0400164};
165
Shawn Guo57ed3312011-06-30 09:24:26 +0800166static struct platform_device_id imx_esdhc_devtype[] = {
167 {
168 .name = "sdhci-esdhc-imx25",
Shawn Guof47c4bb2013-10-17 15:19:47 +0800169 .driver_data = (kernel_ulong_t) &esdhc_imx25_data,
Shawn Guo57ed3312011-06-30 09:24:26 +0800170 }, {
171 .name = "sdhci-esdhc-imx35",
Shawn Guof47c4bb2013-10-17 15:19:47 +0800172 .driver_data = (kernel_ulong_t) &esdhc_imx35_data,
Shawn Guo57ed3312011-06-30 09:24:26 +0800173 }, {
174 .name = "sdhci-esdhc-imx51",
Shawn Guof47c4bb2013-10-17 15:19:47 +0800175 .driver_data = (kernel_ulong_t) &esdhc_imx51_data,
Shawn Guo57ed3312011-06-30 09:24:26 +0800176 }, {
Shawn Guo57ed3312011-06-30 09:24:26 +0800177 /* sentinel */
178 }
179};
180MODULE_DEVICE_TABLE(platform, imx_esdhc_devtype);
181
Shawn Guoabfafc22011-06-30 15:44:44 +0800182static const struct of_device_id imx_esdhc_dt_ids[] = {
Shawn Guof47c4bb2013-10-17 15:19:47 +0800183 { .compatible = "fsl,imx25-esdhc", .data = &esdhc_imx25_data, },
184 { .compatible = "fsl,imx35-esdhc", .data = &esdhc_imx35_data, },
185 { .compatible = "fsl,imx51-esdhc", .data = &esdhc_imx51_data, },
186 { .compatible = "fsl,imx53-esdhc", .data = &esdhc_imx53_data, },
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800187 { .compatible = "fsl,imx6sl-usdhc", .data = &usdhc_imx6sl_data, },
Shawn Guof47c4bb2013-10-17 15:19:47 +0800188 { .compatible = "fsl,imx6q-usdhc", .data = &usdhc_imx6q_data, },
Shawn Guoabfafc22011-06-30 15:44:44 +0800189 { /* sentinel */ }
190};
191MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids);
192
Shawn Guo57ed3312011-06-30 09:24:26 +0800193static inline int is_imx25_esdhc(struct pltfm_imx_data *data)
194{
Shawn Guof47c4bb2013-10-17 15:19:47 +0800195 return data->socdata == &esdhc_imx25_data;
Shawn Guo57ed3312011-06-30 09:24:26 +0800196}
197
198static inline int is_imx53_esdhc(struct pltfm_imx_data *data)
199{
Shawn Guof47c4bb2013-10-17 15:19:47 +0800200 return data->socdata == &esdhc_imx53_data;
Shawn Guo57ed3312011-06-30 09:24:26 +0800201}
202
Shawn Guo95a24822011-09-19 17:32:21 +0800203static inline int is_imx6q_usdhc(struct pltfm_imx_data *data)
204{
Shawn Guof47c4bb2013-10-17 15:19:47 +0800205 return data->socdata == &usdhc_imx6q_data;
Shawn Guo95a24822011-09-19 17:32:21 +0800206}
207
Shawn Guo9d61c002013-10-17 15:19:45 +0800208static inline int esdhc_is_usdhc(struct pltfm_imx_data *data)
209{
Shawn Guof47c4bb2013-10-17 15:19:47 +0800210 return !!(data->socdata->flags & ESDHC_FLAG_USDHC);
Shawn Guo9d61c002013-10-17 15:19:45 +0800211}
212
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200213static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
214{
215 void __iomem *base = host->ioaddr + (reg & ~0x3);
216 u32 shift = (reg & 0x3) * 8;
217
218 writel(((readl(base) & ~(mask << shift)) | (val << shift)), base);
219}
220
Wolfram Sang7e29c302011-02-26 14:44:41 +0100221static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
222{
Lucas Stach361b8482013-03-15 09:49:26 +0100223 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
224 struct pltfm_imx_data *imx_data = pltfm_host->priv;
Wolfram Sang7e29c302011-02-26 14:44:41 +0100225 u32 val = readl(host->ioaddr + reg);
226
Dong Aisheng03221912013-09-13 19:11:34 +0800227 if (unlikely(reg == SDHCI_PRESENT_STATE)) {
228 u32 fsl_prss = val;
229 /* save the least 20 bits */
230 val = fsl_prss & 0x000FFFFF;
231 /* move dat[0-3] bits */
232 val |= (fsl_prss & 0x0F000000) >> 4;
233 /* move cmd line bit */
234 val |= (fsl_prss & 0x00800000) << 1;
235 }
236
Richard Zhu97e4ba62011-08-11 16:51:46 -0400237 if (unlikely(reg == SDHCI_CAPABILITIES)) {
Dong Aisheng6b4fb6712a2013-10-18 19:48:44 +0800238 /* ignore bit[0-15] as it stores cap_1 register val for mx6sl */
239 if (imx_data->socdata->flags & ESDHC_FLAG_HAVE_CAP1)
240 val &= 0xffff0000;
241
Richard Zhu97e4ba62011-08-11 16:51:46 -0400242 /* In FSL esdhc IC module, only bit20 is used to indicate the
243 * ADMA2 capability of esdhc, but this bit is messed up on
244 * some SOCs (e.g. on MX25, MX35 this bit is set, but they
245 * don't actually support ADMA2). So set the BROKEN_ADMA
246 * uirk on MX25/35 platforms.
247 */
248
249 if (val & SDHCI_CAN_DO_ADMA1) {
250 val &= ~SDHCI_CAN_DO_ADMA1;
251 val |= SDHCI_CAN_DO_ADMA2;
252 }
253 }
254
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800255 if (unlikely(reg == SDHCI_CAPABILITIES_1)) {
256 if (esdhc_is_usdhc(imx_data)) {
257 if (imx_data->socdata->flags & ESDHC_FLAG_HAVE_CAP1)
258 val = readl(host->ioaddr + SDHCI_CAPABILITIES) & 0xFFFF;
259 else
260 /* imx6q/dl does not have cap_1 register, fake one */
261 val = SDHCI_SUPPORT_DDR50 | SDHCI_SUPPORT_SDR104
Dong Aisheng888824b2013-10-18 19:48:48 +0800262 | SDHCI_SUPPORT_SDR50
263 | SDHCI_USE_SDR50_TUNING;
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800264 }
265 }
Dong Aisheng03221912013-09-13 19:11:34 +0800266
Shawn Guo9d61c002013-10-17 15:19:45 +0800267 if (unlikely(reg == SDHCI_MAX_CURRENT) && esdhc_is_usdhc(imx_data)) {
Dong Aisheng03221912013-09-13 19:11:34 +0800268 val = 0;
269 val |= 0xFF << SDHCI_MAX_CURRENT_330_SHIFT;
270 val |= 0xFF << SDHCI_MAX_CURRENT_300_SHIFT;
271 val |= 0xFF << SDHCI_MAX_CURRENT_180_SHIFT;
272 }
273
Richard Zhu97e4ba62011-08-11 16:51:46 -0400274 if (unlikely(reg == SDHCI_INT_STATUS)) {
Shawn Guo60bf6392013-01-15 23:36:53 +0800275 if (val & ESDHC_INT_VENDOR_SPEC_DMA_ERR) {
276 val &= ~ESDHC_INT_VENDOR_SPEC_DMA_ERR;
Richard Zhu97e4ba62011-08-11 16:51:46 -0400277 val |= SDHCI_INT_ADMA_ERROR;
278 }
Lucas Stach361b8482013-03-15 09:49:26 +0100279
280 /*
281 * mask off the interrupt we get in response to the manually
282 * sent CMD12
283 */
284 if ((imx_data->multiblock_status == WAIT_FOR_INT) &&
285 ((val & SDHCI_INT_RESPONSE) == SDHCI_INT_RESPONSE)) {
286 val &= ~SDHCI_INT_RESPONSE;
287 writel(SDHCI_INT_RESPONSE, host->ioaddr +
288 SDHCI_INT_STATUS);
289 imx_data->multiblock_status = NO_CMD_PENDING;
290 }
Richard Zhu97e4ba62011-08-11 16:51:46 -0400291 }
292
Wolfram Sang7e29c302011-02-26 14:44:41 +0100293 return val;
294}
295
296static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
297{
Richard Zhue1498602011-03-25 09:18:27 -0400298 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
299 struct pltfm_imx_data *imx_data = pltfm_host->priv;
Tony Lin0d588642011-08-11 16:45:59 -0400300 u32 data;
Richard Zhue1498602011-03-25 09:18:27 -0400301
Tony Lin0d588642011-08-11 16:45:59 -0400302 if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) {
Tony Lin0d588642011-08-11 16:45:59 -0400303 if (val & SDHCI_INT_CARD_INT) {
304 /*
305 * Clear and then set D3CD bit to avoid missing the
306 * card interrupt. This is a eSDHC controller problem
307 * so we need to apply the following workaround: clear
308 * and set D3CD bit will make eSDHC re-sample the card
309 * interrupt. In case a card interrupt was lost,
310 * re-sample it by the following steps.
311 */
312 data = readl(host->ioaddr + SDHCI_HOST_CONTROL);
Shawn Guo60bf6392013-01-15 23:36:53 +0800313 data &= ~ESDHC_CTRL_D3CD;
Tony Lin0d588642011-08-11 16:45:59 -0400314 writel(data, host->ioaddr + SDHCI_HOST_CONTROL);
Shawn Guo60bf6392013-01-15 23:36:53 +0800315 data |= ESDHC_CTRL_D3CD;
Tony Lin0d588642011-08-11 16:45:59 -0400316 writel(data, host->ioaddr + SDHCI_HOST_CONTROL);
317 }
318 }
Wolfram Sang7e29c302011-02-26 14:44:41 +0100319
Shawn Guof47c4bb2013-10-17 15:19:47 +0800320 if (unlikely((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
Richard Zhu58ac8172011-03-21 13:22:16 +0800321 && (reg == SDHCI_INT_STATUS)
322 && (val & SDHCI_INT_DATA_END))) {
323 u32 v;
Shawn Guo60bf6392013-01-15 23:36:53 +0800324 v = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
325 v &= ~ESDHC_VENDOR_SPEC_SDIO_QUIRK;
326 writel(v, host->ioaddr + ESDHC_VENDOR_SPEC);
Lucas Stach361b8482013-03-15 09:49:26 +0100327
328 if (imx_data->multiblock_status == MULTIBLK_IN_PROCESS)
329 {
330 /* send a manual CMD12 with RESPTYP=none */
331 data = MMC_STOP_TRANSMISSION << 24 |
332 SDHCI_CMD_ABORTCMD << 16;
333 writel(data, host->ioaddr + SDHCI_TRANSFER_MODE);
334 imx_data->multiblock_status = WAIT_FOR_INT;
335 }
Richard Zhu58ac8172011-03-21 13:22:16 +0800336 }
337
Richard Zhu97e4ba62011-08-11 16:51:46 -0400338 if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) {
339 if (val & SDHCI_INT_ADMA_ERROR) {
340 val &= ~SDHCI_INT_ADMA_ERROR;
Shawn Guo60bf6392013-01-15 23:36:53 +0800341 val |= ESDHC_INT_VENDOR_SPEC_DMA_ERR;
Richard Zhu97e4ba62011-08-11 16:51:46 -0400342 }
343 }
344
Wolfram Sang7e29c302011-02-26 14:44:41 +0100345 writel(val, host->ioaddr + reg);
346}
347
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200348static u16 esdhc_readw_le(struct sdhci_host *host, int reg)
349{
Shawn Guoef4d0882013-01-15 23:30:27 +0800350 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
351 struct pltfm_imx_data *imx_data = pltfm_host->priv;
Dong Aisheng03221912013-09-13 19:11:34 +0800352 u16 ret = 0;
353 u32 val;
Shawn Guoef4d0882013-01-15 23:30:27 +0800354
Shawn Guo95a24822011-09-19 17:32:21 +0800355 if (unlikely(reg == SDHCI_HOST_VERSION)) {
Shawn Guoef4d0882013-01-15 23:30:27 +0800356 reg ^= 2;
Shawn Guo9d61c002013-10-17 15:19:45 +0800357 if (esdhc_is_usdhc(imx_data)) {
Shawn Guoef4d0882013-01-15 23:30:27 +0800358 /*
359 * The usdhc register returns a wrong host version.
360 * Correct it here.
361 */
362 return SDHCI_SPEC_300;
363 }
Shawn Guo95a24822011-09-19 17:32:21 +0800364 }
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200365
Dong Aisheng03221912013-09-13 19:11:34 +0800366 if (unlikely(reg == SDHCI_HOST_CONTROL2)) {
367 val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
368 if (val & ESDHC_VENDOR_SPEC_VSELECT)
369 ret |= SDHCI_CTRL_VDD_180;
370
Shawn Guo9d61c002013-10-17 15:19:45 +0800371 if (esdhc_is_usdhc(imx_data)) {
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800372 if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
373 val = readl(host->ioaddr + ESDHC_MIX_CTRL);
374 else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING)
375 /* the std tuning bits is in ACMD12_ERR for imx6sl */
376 val = readl(host->ioaddr + SDHCI_ACMD12_ERR);
Dong Aisheng03221912013-09-13 19:11:34 +0800377 }
378
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800379 if (val & ESDHC_MIX_CTRL_EXE_TUNE)
380 ret |= SDHCI_CTRL_EXEC_TUNING;
381 if (val & ESDHC_MIX_CTRL_SMPCLK_SEL)
382 ret |= SDHCI_CTRL_TUNED_CLK;
383
Dong Aisheng03221912013-09-13 19:11:34 +0800384 ret |= (imx_data->uhs_mode & SDHCI_CTRL_UHS_MASK);
385 ret &= ~SDHCI_CTRL_PRESET_VAL_ENABLE;
386
387 return ret;
388 }
389
Dong Aisheng7dd109e2013-10-30 22:09:49 +0800390 if (unlikely(reg == SDHCI_TRANSFER_MODE)) {
391 if (esdhc_is_usdhc(imx_data)) {
392 u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
393 ret = m & ESDHC_MIX_CTRL_SDHCI_MASK;
394 /* Swap AC23 bit */
395 if (m & ESDHC_MIX_CTRL_AC23EN) {
396 ret &= ~ESDHC_MIX_CTRL_AC23EN;
397 ret |= SDHCI_TRNS_AUTO_CMD23;
398 }
399 } else {
400 ret = readw(host->ioaddr + SDHCI_TRANSFER_MODE);
401 }
402
403 return ret;
404 }
405
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200406 return readw(host->ioaddr + reg);
407}
408
409static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
410{
411 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
Richard Zhue1498602011-03-25 09:18:27 -0400412 struct pltfm_imx_data *imx_data = pltfm_host->priv;
Dong Aisheng03221912013-09-13 19:11:34 +0800413 u32 new_val = 0;
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200414
415 switch (reg) {
Dong Aisheng03221912013-09-13 19:11:34 +0800416 case SDHCI_CLOCK_CONTROL:
417 new_val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
418 if (val & SDHCI_CLOCK_CARD_EN)
419 new_val |= ESDHC_VENDOR_SPEC_FRC_SDCLK_ON;
420 else
421 new_val &= ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON;
422 writel(new_val, host->ioaddr + ESDHC_VENDOR_SPEC);
423 return;
424 case SDHCI_HOST_CONTROL2:
425 new_val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
426 if (val & SDHCI_CTRL_VDD_180)
427 new_val |= ESDHC_VENDOR_SPEC_VSELECT;
428 else
429 new_val &= ~ESDHC_VENDOR_SPEC_VSELECT;
430 writel(new_val, host->ioaddr + ESDHC_VENDOR_SPEC);
431 imx_data->uhs_mode = val & SDHCI_CTRL_UHS_MASK;
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800432 if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
433 new_val = readl(host->ioaddr + ESDHC_MIX_CTRL);
434 if (val & SDHCI_CTRL_TUNED_CLK)
435 new_val |= ESDHC_MIX_CTRL_SMPCLK_SEL;
436 else
437 new_val &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
438 writel(new_val , host->ioaddr + ESDHC_MIX_CTRL);
439 } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
440 u32 v = readl(host->ioaddr + SDHCI_ACMD12_ERR);
441 u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
Dong Aisheng8b2bb0ad2013-11-04 16:38:27 +0800442 if (val & SDHCI_CTRL_TUNED_CLK) {
443 v |= ESDHC_MIX_CTRL_SMPCLK_SEL;
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800444 } else {
Dong Aisheng8b2bb0ad2013-11-04 16:38:27 +0800445 v &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800446 m &= ~ESDHC_MIX_CTRL_FBCLK_SEL;
447 }
448
Dong Aisheng8b2bb0ad2013-11-04 16:38:27 +0800449 if (val & SDHCI_CTRL_EXEC_TUNING) {
450 v |= ESDHC_MIX_CTRL_EXE_TUNE;
451 m |= ESDHC_MIX_CTRL_FBCLK_SEL;
452 } else {
453 v &= ~ESDHC_MIX_CTRL_EXE_TUNE;
454 }
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800455
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800456 writel(v, host->ioaddr + SDHCI_ACMD12_ERR);
457 writel(m, host->ioaddr + ESDHC_MIX_CTRL);
458 }
Dong Aisheng03221912013-09-13 19:11:34 +0800459 return;
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200460 case SDHCI_TRANSFER_MODE:
Shawn Guof47c4bb2013-10-17 15:19:47 +0800461 if ((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
Richard Zhu58ac8172011-03-21 13:22:16 +0800462 && (host->cmd->opcode == SD_IO_RW_EXTENDED)
463 && (host->cmd->data->blocks > 1)
464 && (host->cmd->data->flags & MMC_DATA_READ)) {
465 u32 v;
Shawn Guo60bf6392013-01-15 23:36:53 +0800466 v = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
467 v |= ESDHC_VENDOR_SPEC_SDIO_QUIRK;
468 writel(v, host->ioaddr + ESDHC_VENDOR_SPEC);
Richard Zhu58ac8172011-03-21 13:22:16 +0800469 }
Shawn Guo69f54692013-01-21 19:02:24 +0800470
Shawn Guo9d61c002013-10-17 15:19:45 +0800471 if (esdhc_is_usdhc(imx_data)) {
Shawn Guo69f54692013-01-21 19:02:24 +0800472 u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
Shawn Guo2a15f982013-01-21 19:02:26 +0800473 /* Swap AC23 bit */
474 if (val & SDHCI_TRNS_AUTO_CMD23) {
475 val &= ~SDHCI_TRNS_AUTO_CMD23;
476 val |= ESDHC_MIX_CTRL_AC23EN;
477 }
478 m = val | (m & ~ESDHC_MIX_CTRL_SDHCI_MASK);
Shawn Guo69f54692013-01-21 19:02:24 +0800479 writel(m, host->ioaddr + ESDHC_MIX_CTRL);
480 } else {
481 /*
482 * Postpone this write, we must do it together with a
483 * command write that is down below.
484 */
485 imx_data->scratchpad = val;
486 }
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200487 return;
488 case SDHCI_COMMAND:
Lucas Stach361b8482013-03-15 09:49:26 +0100489 if (host->cmd->opcode == MMC_STOP_TRANSMISSION)
Richard Zhu58ac8172011-03-21 13:22:16 +0800490 val |= SDHCI_CMD_ABORTCMD;
Shawn Guo95a24822011-09-19 17:32:21 +0800491
Lucas Stach361b8482013-03-15 09:49:26 +0100492 if ((host->cmd->opcode == MMC_SET_BLOCK_COUNT) &&
Shawn Guof47c4bb2013-10-17 15:19:47 +0800493 (imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
Lucas Stach361b8482013-03-15 09:49:26 +0100494 imx_data->multiblock_status = MULTIBLK_IN_PROCESS;
495
Shawn Guo9d61c002013-10-17 15:19:45 +0800496 if (esdhc_is_usdhc(imx_data))
Shawn Guo95a24822011-09-19 17:32:21 +0800497 writel(val << 16,
498 host->ioaddr + SDHCI_TRANSFER_MODE);
Shawn Guo69f54692013-01-21 19:02:24 +0800499 else
Shawn Guo95a24822011-09-19 17:32:21 +0800500 writel(val << 16 | imx_data->scratchpad,
501 host->ioaddr + SDHCI_TRANSFER_MODE);
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200502 return;
503 case SDHCI_BLOCK_SIZE:
504 val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);
505 break;
506 }
507 esdhc_clrset_le(host, 0xffff, val, reg);
508}
509
510static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
511{
Wilson Callan9a0985b2012-07-19 02:49:16 -0400512 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
513 struct pltfm_imx_data *imx_data = pltfm_host->priv;
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200514 u32 new_val;
Sascha Haueraf510792013-01-21 19:02:28 +0800515 u32 mask;
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200516
517 switch (reg) {
518 case SDHCI_POWER_CONTROL:
519 /*
520 * FSL put some DMA bits here
521 * If your board has a regulator, code should be here
522 */
523 return;
524 case SDHCI_HOST_CONTROL:
Shawn Guo6b40d182013-01-15 23:36:52 +0800525 /* FSL messed up here, so we need to manually compose it. */
Sascha Haueraf510792013-01-21 19:02:28 +0800526 new_val = val & SDHCI_CTRL_LED;
Masanari Iida7122bbb2012-08-05 23:25:40 +0900527 /* ensure the endianness */
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200528 new_val |= ESDHC_HOST_CONTROL_LE;
Wilson Callan9a0985b2012-07-19 02:49:16 -0400529 /* bits 8&9 are reserved on mx25 */
530 if (!is_imx25_esdhc(imx_data)) {
531 /* DMA mode bits are shifted */
532 new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5;
533 }
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200534
Sascha Haueraf510792013-01-21 19:02:28 +0800535 /*
536 * Do not touch buswidth bits here. This is done in
537 * esdhc_pltfm_bus_width.
Martin Fuzzeyf6825742013-04-15 17:08:35 +0200538 * Do not touch the D3CD bit either which is used for the
539 * SDIO interrupt errata workaround.
Sascha Haueraf510792013-01-21 19:02:28 +0800540 */
Martin Fuzzeyf6825742013-04-15 17:08:35 +0200541 mask = 0xffff & ~(ESDHC_CTRL_BUSWIDTH_MASK | ESDHC_CTRL_D3CD);
Sascha Haueraf510792013-01-21 19:02:28 +0800542
543 esdhc_clrset_le(host, mask, new_val, reg);
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200544 return;
545 }
546 esdhc_clrset_le(host, 0xff, val, reg);
Shawn Guo913413c2011-06-21 22:41:51 +0800547
548 /*
549 * The esdhc has a design violation to SDHC spec which tells
550 * that software reset should not affect card detection circuit.
551 * But esdhc clears its SYSCTL register bits [0..2] during the
552 * software reset. This will stop those clocks that card detection
553 * circuit relies on. To work around it, we turn the clocks on back
554 * to keep card detection circuit functional.
555 */
Shawn Guo58c8c4f2013-01-21 19:02:25 +0800556 if ((reg == SDHCI_SOFTWARE_RESET) && (val & 1)) {
Shawn Guo913413c2011-06-21 22:41:51 +0800557 esdhc_clrset_le(host, 0x7, 0x7, ESDHC_SYSTEM_CONTROL);
Shawn Guo58c8c4f2013-01-21 19:02:25 +0800558 /*
559 * The reset on usdhc fails to clear MIX_CTRL register.
560 * Do it manually here.
561 */
Dong Aishengde5bdbf2013-10-18 19:48:46 +0800562 if (esdhc_is_usdhc(imx_data)) {
Dong Aishengd131a712013-11-04 16:38:26 +0800563 /* the tuning bits should be kept during reset */
564 new_val = readl(host->ioaddr + ESDHC_MIX_CTRL);
565 writel(new_val & ESDHC_MIX_CTRL_TUNING_MASK,
566 host->ioaddr + ESDHC_MIX_CTRL);
Dong Aishengde5bdbf2013-10-18 19:48:46 +0800567 imx_data->is_ddr = 0;
568 }
Shawn Guo58c8c4f2013-01-21 19:02:25 +0800569 }
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200570}
571
Lucas Stach0ddf03c2013-06-05 15:13:26 +0200572static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host)
573{
574 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
575 struct pltfm_imx_data *imx_data = pltfm_host->priv;
576 struct esdhc_platform_data *boarddata = &imx_data->boarddata;
577
578 u32 f_host = clk_get_rate(pltfm_host->clk);
579
580 if (boarddata->f_max && (boarddata->f_max < f_host))
581 return boarddata->f_max;
582 else
583 return f_host;
584}
585
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200586static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
587{
588 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
589
590 return clk_get_rate(pltfm_host->clk) / 256 / 16;
591}
592
Lucas Stach8ba95802013-06-05 15:13:25 +0200593static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
594 unsigned int clock)
595{
596 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
Dong Aishengfed2f6e2013-09-13 19:11:33 +0800597 struct pltfm_imx_data *imx_data = pltfm_host->priv;
Dong Aishengd31fc002013-09-13 19:11:32 +0800598 unsigned int host_clock = clk_get_rate(pltfm_host->clk);
599 int pre_div = 2;
600 int div = 1;
Dong Aishengfed2f6e2013-09-13 19:11:33 +0800601 u32 temp, val;
Lucas Stach8ba95802013-06-05 15:13:25 +0200602
Dong Aishengfed2f6e2013-09-13 19:11:33 +0800603 if (clock == 0) {
Shawn Guo9d61c002013-10-17 15:19:45 +0800604 if (esdhc_is_usdhc(imx_data)) {
Dong Aishengfed2f6e2013-09-13 19:11:33 +0800605 val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
606 writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
607 host->ioaddr + ESDHC_VENDOR_SPEC);
608 }
Dong Aishengd31fc002013-09-13 19:11:32 +0800609 goto out;
Dong Aishengfed2f6e2013-09-13 19:11:33 +0800610 }
Dong Aishengd31fc002013-09-13 19:11:32 +0800611
Dong Aishengde5bdbf2013-10-18 19:48:46 +0800612 if (esdhc_is_usdhc(imx_data) && !imx_data->is_ddr)
Dong Aisheng5f7886c2013-09-13 19:11:36 +0800613 pre_div = 1;
614
Dong Aishengd31fc002013-09-13 19:11:32 +0800615 temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
616 temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
617 | ESDHC_CLOCK_MASK);
618 sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
619
620 while (host_clock / pre_div / 16 > clock && pre_div < 256)
621 pre_div *= 2;
622
623 while (host_clock / pre_div / div > clock && div < 16)
624 div++;
625
Dong Aishenge76b8552013-09-13 19:11:37 +0800626 host->mmc->actual_clock = host_clock / pre_div / div;
Dong Aishengd31fc002013-09-13 19:11:32 +0800627 dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
Dong Aishenge76b8552013-09-13 19:11:37 +0800628 clock, host->mmc->actual_clock);
Dong Aishengd31fc002013-09-13 19:11:32 +0800629
Dong Aishengde5bdbf2013-10-18 19:48:46 +0800630 if (imx_data->is_ddr)
631 pre_div >>= 2;
632 else
633 pre_div >>= 1;
Dong Aishengd31fc002013-09-13 19:11:32 +0800634 div--;
635
636 temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
637 temp |= (ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
638 | (div << ESDHC_DIVIDER_SHIFT)
639 | (pre_div << ESDHC_PREDIV_SHIFT));
640 sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
Dong Aishengfed2f6e2013-09-13 19:11:33 +0800641
Shawn Guo9d61c002013-10-17 15:19:45 +0800642 if (esdhc_is_usdhc(imx_data)) {
Dong Aishengfed2f6e2013-09-13 19:11:33 +0800643 val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
644 writel(val | ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
645 host->ioaddr + ESDHC_VENDOR_SPEC);
646 }
647
Dong Aishengd31fc002013-09-13 19:11:32 +0800648 mdelay(1);
649out:
650 host->clock = clock;
Lucas Stach8ba95802013-06-05 15:13:25 +0200651}
652
Shawn Guo913413c2011-06-21 22:41:51 +0800653static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
654{
Shawn Guo842afc02011-07-06 22:57:48 +0800655 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
656 struct pltfm_imx_data *imx_data = pltfm_host->priv;
657 struct esdhc_platform_data *boarddata = &imx_data->boarddata;
Shawn Guo913413c2011-06-21 22:41:51 +0800658
659 switch (boarddata->wp_type) {
660 case ESDHC_WP_GPIO:
Shawn Guofbe5fdd2012-12-11 22:32:20 +0800661 return mmc_gpio_get_ro(host->mmc);
Shawn Guo913413c2011-06-21 22:41:51 +0800662 case ESDHC_WP_CONTROLLER:
663 return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
664 SDHCI_WRITE_PROTECT);
665 case ESDHC_WP_NONE:
666 break;
667 }
668
669 return -ENOSYS;
670}
671
Sascha Haueraf510792013-01-21 19:02:28 +0800672static int esdhc_pltfm_bus_width(struct sdhci_host *host, int width)
673{
674 u32 ctrl;
675
676 switch (width) {
677 case MMC_BUS_WIDTH_8:
678 ctrl = ESDHC_CTRL_8BITBUS;
679 break;
680 case MMC_BUS_WIDTH_4:
681 ctrl = ESDHC_CTRL_4BITBUS;
682 break;
683 default:
684 ctrl = 0;
685 break;
686 }
687
688 esdhc_clrset_le(host, ESDHC_CTRL_BUSWIDTH_MASK, ctrl,
689 SDHCI_HOST_CONTROL);
690
691 return 0;
692}
693
Dong Aisheng03221912013-09-13 19:11:34 +0800694static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
695{
696 u32 reg;
697
698 /* FIXME: delay a bit for card to be ready for next tuning due to errors */
699 mdelay(1);
700
Dong Aishengce090a42013-11-04 16:38:28 +0800701 pm_runtime_get_sync(host->mmc->parent);
Dong Aisheng03221912013-09-13 19:11:34 +0800702 reg = readl(host->ioaddr + ESDHC_MIX_CTRL);
703 reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL |
704 ESDHC_MIX_CTRL_FBCLK_SEL;
705 writel(reg, host->ioaddr + ESDHC_MIX_CTRL);
706 writel(val << 8, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
707 dev_dbg(mmc_dev(host->mmc),
708 "tunning with delay 0x%x ESDHC_TUNE_CTRL_STATUS 0x%x\n",
709 val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS));
710}
711
712static void esdhc_request_done(struct mmc_request *mrq)
713{
714 complete(&mrq->completion);
715}
716
717static int esdhc_send_tuning_cmd(struct sdhci_host *host, u32 opcode)
718{
719 struct mmc_command cmd = {0};
720 struct mmc_request mrq = {0};
721 struct mmc_data data = {0};
722 struct scatterlist sg;
723 char tuning_pattern[ESDHC_TUNING_BLOCK_PATTERN_LEN];
724
725 cmd.opcode = opcode;
726 cmd.arg = 0;
727 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
728
729 data.blksz = ESDHC_TUNING_BLOCK_PATTERN_LEN;
730 data.blocks = 1;
731 data.flags = MMC_DATA_READ;
732 data.sg = &sg;
733 data.sg_len = 1;
734
735 sg_init_one(&sg, tuning_pattern, sizeof(tuning_pattern));
736
737 mrq.cmd = &cmd;
738 mrq.cmd->mrq = &mrq;
739 mrq.data = &data;
740 mrq.data->mrq = &mrq;
741 mrq.cmd->data = mrq.data;
742
743 mrq.done = esdhc_request_done;
744 init_completion(&(mrq.completion));
745
746 disable_irq(host->irq);
747 spin_lock(&host->lock);
748 host->mrq = &mrq;
749
750 sdhci_send_command(host, mrq.cmd);
751
752 spin_unlock(&host->lock);
753 enable_irq(host->irq);
754
755 wait_for_completion(&mrq.completion);
756
757 if (cmd.error)
758 return cmd.error;
759 if (data.error)
760 return data.error;
761
762 return 0;
763}
764
765static void esdhc_post_tuning(struct sdhci_host *host)
766{
767 u32 reg;
768
769 reg = readl(host->ioaddr + ESDHC_MIX_CTRL);
770 reg &= ~ESDHC_MIX_CTRL_EXE_TUNE;
771 writel(reg, host->ioaddr + ESDHC_MIX_CTRL);
772}
773
774static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
775{
776 int min, max, avg, ret;
777
778 /* find the mininum delay first which can pass tuning */
779 min = ESDHC_TUNE_CTRL_MIN;
780 while (min < ESDHC_TUNE_CTRL_MAX) {
781 esdhc_prepare_tuning(host, min);
782 if (!esdhc_send_tuning_cmd(host, opcode))
783 break;
784 min += ESDHC_TUNE_CTRL_STEP;
785 }
786
787 /* find the maxinum delay which can not pass tuning */
788 max = min + ESDHC_TUNE_CTRL_STEP;
789 while (max < ESDHC_TUNE_CTRL_MAX) {
790 esdhc_prepare_tuning(host, max);
791 if (esdhc_send_tuning_cmd(host, opcode)) {
792 max -= ESDHC_TUNE_CTRL_STEP;
793 break;
794 }
795 max += ESDHC_TUNE_CTRL_STEP;
796 }
797
798 /* use average delay to get the best timing */
799 avg = (min + max) / 2;
800 esdhc_prepare_tuning(host, avg);
801 ret = esdhc_send_tuning_cmd(host, opcode);
802 esdhc_post_tuning(host);
803
804 dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n",
805 ret ? "failed" : "passed", avg, ret);
806
807 return ret;
808}
809
Dong Aishengad932202013-09-13 19:11:35 +0800810static int esdhc_change_pinstate(struct sdhci_host *host,
811 unsigned int uhs)
812{
813 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
814 struct pltfm_imx_data *imx_data = pltfm_host->priv;
815 struct pinctrl_state *pinctrl;
816
817 dev_dbg(mmc_dev(host->mmc), "change pinctrl state for uhs %d\n", uhs);
818
819 if (IS_ERR(imx_data->pinctrl) ||
820 IS_ERR(imx_data->pins_default) ||
821 IS_ERR(imx_data->pins_100mhz) ||
822 IS_ERR(imx_data->pins_200mhz))
823 return -EINVAL;
824
825 switch (uhs) {
826 case MMC_TIMING_UHS_SDR50:
827 pinctrl = imx_data->pins_100mhz;
828 break;
829 case MMC_TIMING_UHS_SDR104:
Dong Aisheng429a5b42013-10-30 22:10:42 +0800830 case MMC_TIMING_MMC_HS200:
Dong Aishengad932202013-09-13 19:11:35 +0800831 pinctrl = imx_data->pins_200mhz;
832 break;
833 default:
834 /* back to default state for other legacy timing */
835 pinctrl = imx_data->pins_default;
836 }
837
838 return pinctrl_select_state(imx_data->pinctrl, pinctrl);
839}
840
841static int esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
842{
843 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
844 struct pltfm_imx_data *imx_data = pltfm_host->priv;
Dong Aisheng602519b2013-10-18 19:48:47 +0800845 struct esdhc_platform_data *boarddata = &imx_data->boarddata;
Dong Aishengad932202013-09-13 19:11:35 +0800846
847 switch (uhs) {
848 case MMC_TIMING_UHS_SDR12:
849 imx_data->uhs_mode = SDHCI_CTRL_UHS_SDR12;
850 break;
851 case MMC_TIMING_UHS_SDR25:
852 imx_data->uhs_mode = SDHCI_CTRL_UHS_SDR25;
853 break;
854 case MMC_TIMING_UHS_SDR50:
855 imx_data->uhs_mode = SDHCI_CTRL_UHS_SDR50;
856 break;
857 case MMC_TIMING_UHS_SDR104:
Dong Aisheng429a5b42013-10-30 22:10:42 +0800858 case MMC_TIMING_MMC_HS200:
Dong Aishengad932202013-09-13 19:11:35 +0800859 imx_data->uhs_mode = SDHCI_CTRL_UHS_SDR104;
860 break;
861 case MMC_TIMING_UHS_DDR50:
862 imx_data->uhs_mode = SDHCI_CTRL_UHS_DDR50;
Dong Aishengde5bdbf2013-10-18 19:48:46 +0800863 writel(readl(host->ioaddr + ESDHC_MIX_CTRL) |
864 ESDHC_MIX_CTRL_DDREN,
865 host->ioaddr + ESDHC_MIX_CTRL);
866 imx_data->is_ddr = 1;
Dong Aisheng602519b2013-10-18 19:48:47 +0800867 if (boarddata->delay_line) {
868 u32 v;
869 v = boarddata->delay_line <<
870 ESDHC_DLL_OVERRIDE_VAL_SHIFT |
871 (1 << ESDHC_DLL_OVERRIDE_EN_SHIFT);
872 if (is_imx53_esdhc(imx_data))
873 v <<= 1;
874 writel(v, host->ioaddr + ESDHC_DLL_CTRL);
875 }
Dong Aishengad932202013-09-13 19:11:35 +0800876 break;
877 }
878
879 return esdhc_change_pinstate(host, uhs);
880}
881
Dong Aisheng6e9fd282013-10-18 19:48:43 +0800882static struct sdhci_ops sdhci_esdhc_ops = {
Richard Zhue1498602011-03-25 09:18:27 -0400883 .read_l = esdhc_readl_le,
Wolfram Sang0c6d49c2011-02-26 14:44:39 +0100884 .read_w = esdhc_readw_le,
Richard Zhue1498602011-03-25 09:18:27 -0400885 .write_l = esdhc_writel_le,
Wolfram Sang0c6d49c2011-02-26 14:44:39 +0100886 .write_w = esdhc_writew_le,
887 .write_b = esdhc_writeb_le,
Lucas Stach8ba95802013-06-05 15:13:25 +0200888 .set_clock = esdhc_pltfm_set_clock,
Lucas Stach0ddf03c2013-06-05 15:13:26 +0200889 .get_max_clock = esdhc_pltfm_get_max_clock,
Wolfram Sang0c6d49c2011-02-26 14:44:39 +0100890 .get_min_clock = esdhc_pltfm_get_min_clock,
Shawn Guo913413c2011-06-21 22:41:51 +0800891 .get_ro = esdhc_pltfm_get_ro,
Sascha Haueraf510792013-01-21 19:02:28 +0800892 .platform_bus_width = esdhc_pltfm_bus_width,
Dong Aishengad932202013-09-13 19:11:35 +0800893 .set_uhs_signaling = esdhc_set_uhs_signaling,
Wolfram Sang0c6d49c2011-02-26 14:44:39 +0100894};
895
Lars-Peter Clausen1db5eeb2013-03-13 19:26:03 +0100896static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
Richard Zhu97e4ba62011-08-11 16:51:46 -0400897 .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_HISPD_BIT
898 | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
899 | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
Shawn Guo85d65092011-05-27 23:48:12 +0800900 | SDHCI_QUIRK_BROKEN_CARD_DETECTION,
Shawn Guo85d65092011-05-27 23:48:12 +0800901 .ops = &sdhci_esdhc_ops,
902};
903
Shawn Guoabfafc22011-06-30 15:44:44 +0800904#ifdef CONFIG_OF
Bill Pembertonc3be1ef2012-11-19 13:23:06 -0500905static int
Shawn Guoabfafc22011-06-30 15:44:44 +0800906sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
907 struct esdhc_platform_data *boarddata)
908{
909 struct device_node *np = pdev->dev.of_node;
910
911 if (!np)
912 return -ENODEV;
913
Arnd Bergmann7f217792012-05-13 00:14:24 -0400914 if (of_get_property(np, "non-removable", NULL))
Shawn Guoabfafc22011-06-30 15:44:44 +0800915 boarddata->cd_type = ESDHC_CD_PERMANENT;
916
917 if (of_get_property(np, "fsl,cd-controller", NULL))
918 boarddata->cd_type = ESDHC_CD_CONTROLLER;
919
920 if (of_get_property(np, "fsl,wp-controller", NULL))
921 boarddata->wp_type = ESDHC_WP_CONTROLLER;
922
923 boarddata->cd_gpio = of_get_named_gpio(np, "cd-gpios", 0);
924 if (gpio_is_valid(boarddata->cd_gpio))
925 boarddata->cd_type = ESDHC_CD_GPIO;
926
927 boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
928 if (gpio_is_valid(boarddata->wp_gpio))
929 boarddata->wp_type = ESDHC_WP_GPIO;
930
Sascha Haueraf510792013-01-21 19:02:28 +0800931 of_property_read_u32(np, "bus-width", &boarddata->max_bus_width);
932
Lucas Stach0ddf03c2013-06-05 15:13:26 +0200933 of_property_read_u32(np, "max-frequency", &boarddata->f_max);
934
Dong Aishengad932202013-09-13 19:11:35 +0800935 if (of_find_property(np, "no-1-8-v", NULL))
936 boarddata->support_vsel = false;
937 else
938 boarddata->support_vsel = true;
939
Dong Aisheng602519b2013-10-18 19:48:47 +0800940 if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line))
941 boarddata->delay_line = 0;
942
Shawn Guoabfafc22011-06-30 15:44:44 +0800943 return 0;
944}
945#else
946static inline int
947sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
948 struct esdhc_platform_data *boarddata)
949{
950 return -ENODEV;
951}
952#endif
953
Bill Pembertonc3be1ef2012-11-19 13:23:06 -0500954static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200955{
Shawn Guoabfafc22011-06-30 15:44:44 +0800956 const struct of_device_id *of_id =
957 of_match_device(imx_esdhc_dt_ids, &pdev->dev);
Shawn Guo85d65092011-05-27 23:48:12 +0800958 struct sdhci_pltfm_host *pltfm_host;
959 struct sdhci_host *host;
960 struct esdhc_platform_data *boarddata;
Wolfram Sang0c6d49c2011-02-26 14:44:39 +0100961 int err;
Richard Zhue1498602011-03-25 09:18:27 -0400962 struct pltfm_imx_data *imx_data;
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200963
Christian Daudt0e748232013-05-29 13:50:05 -0700964 host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata, 0);
Shawn Guo85d65092011-05-27 23:48:12 +0800965 if (IS_ERR(host))
966 return PTR_ERR(host);
967
968 pltfm_host = sdhci_priv(host);
969
Shawn Guoe3af31c2012-11-26 14:39:43 +0800970 imx_data = devm_kzalloc(&pdev->dev, sizeof(*imx_data), GFP_KERNEL);
Shawn Guoabfafc22011-06-30 15:44:44 +0800971 if (!imx_data) {
972 err = -ENOMEM;
Shawn Guoe3af31c2012-11-26 14:39:43 +0800973 goto free_sdhci;
Shawn Guoabfafc22011-06-30 15:44:44 +0800974 }
Shawn Guo57ed3312011-06-30 09:24:26 +0800975
Shawn Guof47c4bb2013-10-17 15:19:47 +0800976 imx_data->socdata = of_id ? of_id->data : (struct esdhc_soc_data *)
977 pdev->id_entry->driver_data;
Shawn Guo85d65092011-05-27 23:48:12 +0800978 pltfm_host->priv = imx_data;
979
Sascha Hauer52dac612012-03-07 09:31:34 +0100980 imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
981 if (IS_ERR(imx_data->clk_ipg)) {
982 err = PTR_ERR(imx_data->clk_ipg);
Shawn Guoe3af31c2012-11-26 14:39:43 +0800983 goto free_sdhci;
Wolfram Sang95f25ef2010-10-15 12:21:04 +0200984 }
Sascha Hauer52dac612012-03-07 09:31:34 +0100985
986 imx_data->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
987 if (IS_ERR(imx_data->clk_ahb)) {
988 err = PTR_ERR(imx_data->clk_ahb);
Shawn Guoe3af31c2012-11-26 14:39:43 +0800989 goto free_sdhci;
Sascha Hauer52dac612012-03-07 09:31:34 +0100990 }
991
992 imx_data->clk_per = devm_clk_get(&pdev->dev, "per");
993 if (IS_ERR(imx_data->clk_per)) {
994 err = PTR_ERR(imx_data->clk_per);
Shawn Guoe3af31c2012-11-26 14:39:43 +0800995 goto free_sdhci;
Sascha Hauer52dac612012-03-07 09:31:34 +0100996 }
997
998 pltfm_host->clk = imx_data->clk_per;
999
1000 clk_prepare_enable(imx_data->clk_per);
1001 clk_prepare_enable(imx_data->clk_ipg);
1002 clk_prepare_enable(imx_data->clk_ahb);
Wolfram Sang95f25ef2010-10-15 12:21:04 +02001003
Dong Aishengad932202013-09-13 19:11:35 +08001004 imx_data->pinctrl = devm_pinctrl_get(&pdev->dev);
Dong Aishenge62d8b82012-05-11 14:56:01 +08001005 if (IS_ERR(imx_data->pinctrl)) {
1006 err = PTR_ERR(imx_data->pinctrl);
Shawn Guoe3af31c2012-11-26 14:39:43 +08001007 goto disable_clk;
Dong Aishenge62d8b82012-05-11 14:56:01 +08001008 }
1009
Dong Aishengad932202013-09-13 19:11:35 +08001010 imx_data->pins_default = pinctrl_lookup_state(imx_data->pinctrl,
1011 PINCTRL_STATE_DEFAULT);
1012 if (IS_ERR(imx_data->pins_default)) {
1013 err = PTR_ERR(imx_data->pins_default);
1014 dev_err(mmc_dev(host->mmc), "could not get default state\n");
1015 goto disable_clk;
1016 }
1017
Eric Bénardb89152822012-04-18 02:30:20 +02001018 host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
Eric Bénard37865fe2010-10-23 01:57:21 +02001019
Shawn Guof47c4bb2013-10-17 15:19:47 +08001020 if (imx_data->socdata->flags & ESDHC_FLAG_ENGCM07207)
Wolfram Sang0c6d49c2011-02-26 14:44:39 +01001021 /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
Richard Zhu97e4ba62011-08-11 16:51:46 -04001022 host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK
1023 | SDHCI_QUIRK_BROKEN_ADMA;
Wolfram Sang0c6d49c2011-02-26 14:44:39 +01001024
Shawn Guof750ba92011-11-10 16:39:32 +08001025 /*
1026 * The imx6q ROM code will change the default watermark level setting
1027 * to something insane. Change it back here.
1028 */
Dong Aisheng69ed60e2013-10-18 19:48:49 +08001029 if (esdhc_is_usdhc(imx_data)) {
Shawn Guo60bf6392013-01-15 23:36:53 +08001030 writel(0x08100810, host->ioaddr + ESDHC_WTMK_LVL);
Dong Aisheng69ed60e2013-10-18 19:48:49 +08001031 host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN;
Dong Aishenge2997c92013-10-30 22:09:52 +08001032 host->mmc->caps |= MMC_CAP_1_8V_DDR;
Dong Aisheng69ed60e2013-10-18 19:48:49 +08001033 }
Shawn Guof750ba92011-11-10 16:39:32 +08001034
Dong Aisheng6e9fd282013-10-18 19:48:43 +08001035 if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
1036 sdhci_esdhc_ops.platform_execute_tuning =
1037 esdhc_executing_tuning;
Dong Aisheng8b2bb0ad2013-11-04 16:38:27 +08001038
1039 if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING)
1040 writel(readl(host->ioaddr + ESDHC_TUNING_CTRL) |
1041 ESDHC_STD_TUNING_EN | ESDHC_TUNING_START_TAP,
1042 host->ioaddr + ESDHC_TUNING_CTRL);
1043
Shawn Guo842afc02011-07-06 22:57:48 +08001044 boarddata = &imx_data->boarddata;
Shawn Guoabfafc22011-06-30 15:44:44 +08001045 if (sdhci_esdhc_imx_probe_dt(pdev, boarddata) < 0) {
1046 if (!host->mmc->parent->platform_data) {
1047 dev_err(mmc_dev(host->mmc), "no board data!\n");
1048 err = -EINVAL;
Shawn Guoe3af31c2012-11-26 14:39:43 +08001049 goto disable_clk;
Shawn Guoabfafc22011-06-30 15:44:44 +08001050 }
1051 imx_data->boarddata = *((struct esdhc_platform_data *)
1052 host->mmc->parent->platform_data);
1053 }
Shawn Guo913413c2011-06-21 22:41:51 +08001054
1055 /* write_protect */
1056 if (boarddata->wp_type == ESDHC_WP_GPIO) {
Shawn Guofbe5fdd2012-12-11 22:32:20 +08001057 err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
Wolfram Sang0c6d49c2011-02-26 14:44:39 +01001058 if (err) {
Shawn Guofbe5fdd2012-12-11 22:32:20 +08001059 dev_err(mmc_dev(host->mmc),
1060 "failed to request write-protect gpio!\n");
1061 goto disable_clk;
Wolfram Sang0c6d49c2011-02-26 14:44:39 +01001062 }
Shawn Guofbe5fdd2012-12-11 22:32:20 +08001063 host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
Shawn Guo913413c2011-06-21 22:41:51 +08001064 }
Wolfram Sang7e29c302011-02-26 14:44:41 +01001065
Shawn Guo913413c2011-06-21 22:41:51 +08001066 /* card_detect */
Shawn Guo913413c2011-06-21 22:41:51 +08001067 switch (boarddata->cd_type) {
1068 case ESDHC_CD_GPIO:
Laurent Pinchart214fc302013-08-08 12:38:31 +02001069 err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
Wolfram Sang7e29c302011-02-26 14:44:41 +01001070 if (err) {
Shawn Guo913413c2011-06-21 22:41:51 +08001071 dev_err(mmc_dev(host->mmc),
Shawn Guofbe5fdd2012-12-11 22:32:20 +08001072 "failed to request card-detect gpio!\n");
Shawn Guoe3af31c2012-11-26 14:39:43 +08001073 goto disable_clk;
Wolfram Sang7e29c302011-02-26 14:44:41 +01001074 }
Shawn Guo913413c2011-06-21 22:41:51 +08001075 /* fall through */
Wolfram Sang7e29c302011-02-26 14:44:41 +01001076
Shawn Guo913413c2011-06-21 22:41:51 +08001077 case ESDHC_CD_CONTROLLER:
1078 /* we have a working card_detect back */
Wolfram Sang7e29c302011-02-26 14:44:41 +01001079 host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
Shawn Guo913413c2011-06-21 22:41:51 +08001080 break;
1081
1082 case ESDHC_CD_PERMANENT:
Dong Aishenge5260032013-10-30 22:09:51 +08001083 host->mmc->caps |= MMC_CAP_NONREMOVABLE;
Shawn Guo913413c2011-06-21 22:41:51 +08001084 break;
1085
1086 case ESDHC_CD_NONE:
1087 break;
Wolfram Sang0c6d49c2011-02-26 14:44:39 +01001088 }
Eric Bénard16a790b2010-10-23 01:57:22 +02001089
Sascha Haueraf510792013-01-21 19:02:28 +08001090 switch (boarddata->max_bus_width) {
1091 case 8:
1092 host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA;
1093 break;
1094 case 4:
1095 host->mmc->caps |= MMC_CAP_4_BIT_DATA;
1096 break;
1097 case 1:
1098 default:
1099 host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;
1100 break;
1101 }
1102
Dong Aishengad932202013-09-13 19:11:35 +08001103 /* sdr50 and sdr104 needs work on 1.8v signal voltage */
Shawn Guo9d61c002013-10-17 15:19:45 +08001104 if ((boarddata->support_vsel) && esdhc_is_usdhc(imx_data)) {
Dong Aishengad932202013-09-13 19:11:35 +08001105 imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
1106 ESDHC_PINCTRL_STATE_100MHZ);
1107 imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
1108 ESDHC_PINCTRL_STATE_200MHZ);
1109 if (IS_ERR(imx_data->pins_100mhz) ||
1110 IS_ERR(imx_data->pins_200mhz)) {
1111 dev_warn(mmc_dev(host->mmc),
1112 "could not get ultra high speed state, work on normal mode\n");
1113 /* fall back to not support uhs by specify no 1.8v quirk */
1114 host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
1115 }
1116 } else {
1117 host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
1118 }
1119
Shawn Guo85d65092011-05-27 23:48:12 +08001120 err = sdhci_add_host(host);
1121 if (err)
Shawn Guoe3af31c2012-11-26 14:39:43 +08001122 goto disable_clk;
Shawn Guo85d65092011-05-27 23:48:12 +08001123
Wolfram Sang95f25ef2010-10-15 12:21:04 +02001124 return 0;
Wolfram Sang7e29c302011-02-26 14:44:41 +01001125
Shawn Guoe3af31c2012-11-26 14:39:43 +08001126disable_clk:
Sascha Hauer52dac612012-03-07 09:31:34 +01001127 clk_disable_unprepare(imx_data->clk_per);
1128 clk_disable_unprepare(imx_data->clk_ipg);
1129 clk_disable_unprepare(imx_data->clk_ahb);
Shawn Guoe3af31c2012-11-26 14:39:43 +08001130free_sdhci:
Shawn Guo85d65092011-05-27 23:48:12 +08001131 sdhci_pltfm_free(pdev);
1132 return err;
Wolfram Sang95f25ef2010-10-15 12:21:04 +02001133}
1134
Bill Pemberton6e0ee712012-11-19 13:26:03 -05001135static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
Wolfram Sang95f25ef2010-10-15 12:21:04 +02001136{
Shawn Guo85d65092011-05-27 23:48:12 +08001137 struct sdhci_host *host = platform_get_drvdata(pdev);
Wolfram Sang95f25ef2010-10-15 12:21:04 +02001138 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
Richard Zhue1498602011-03-25 09:18:27 -04001139 struct pltfm_imx_data *imx_data = pltfm_host->priv;
Shawn Guo85d65092011-05-27 23:48:12 +08001140 int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
1141
1142 sdhci_remove_host(host, dead);
Wolfram Sang0c6d49c2011-02-26 14:44:39 +01001143
Sascha Hauer52dac612012-03-07 09:31:34 +01001144 clk_disable_unprepare(imx_data->clk_per);
1145 clk_disable_unprepare(imx_data->clk_ipg);
1146 clk_disable_unprepare(imx_data->clk_ahb);
1147
Shawn Guo85d65092011-05-27 23:48:12 +08001148 sdhci_pltfm_free(pdev);
1149
1150 return 0;
Wolfram Sang95f25ef2010-10-15 12:21:04 +02001151}
1152
Shawn Guo85d65092011-05-27 23:48:12 +08001153static struct platform_driver sdhci_esdhc_imx_driver = {
1154 .driver = {
1155 .name = "sdhci-esdhc-imx",
1156 .owner = THIS_MODULE,
Shawn Guoabfafc22011-06-30 15:44:44 +08001157 .of_match_table = imx_esdhc_dt_ids,
Manuel Lauss29495aa2011-11-03 11:09:45 +01001158 .pm = SDHCI_PLTFM_PMOPS,
Shawn Guo85d65092011-05-27 23:48:12 +08001159 },
Shawn Guo57ed3312011-06-30 09:24:26 +08001160 .id_table = imx_esdhc_devtype,
Shawn Guo85d65092011-05-27 23:48:12 +08001161 .probe = sdhci_esdhc_imx_probe,
Bill Pemberton0433c142012-11-19 13:20:26 -05001162 .remove = sdhci_esdhc_imx_remove,
Wolfram Sang95f25ef2010-10-15 12:21:04 +02001163};
Shawn Guo85d65092011-05-27 23:48:12 +08001164
Axel Lind1f81a62011-11-26 12:55:43 +08001165module_platform_driver(sdhci_esdhc_imx_driver);
Shawn Guo85d65092011-05-27 23:48:12 +08001166
1167MODULE_DESCRIPTION("SDHCI driver for Freescale i.MX eSDHC");
1168MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>");
1169MODULE_LICENSE("GPL v2");