sdhci-esdhc-imx.c 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506
  1. /*
  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 <kernel@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. #include <linux/io.h>
  14. #include <linux/delay.h>
  15. #include <linux/err.h>
  16. #include <linux/clk.h>
  17. #include <linux/gpio.h>
  18. #include <linux/module.h>
  19. #include <linux/slab.h>
  20. #include <linux/mmc/host.h>
  21. #include <linux/mmc/mmc.h>
  22. #include <linux/mmc/sdio.h>
  23. #include <linux/mmc/slot-gpio.h>
  24. #include <linux/of.h>
  25. #include <linux/of_device.h>
  26. #include <linux/of_gpio.h>
  27. #include <linux/pinctrl/consumer.h>
  28. #include <linux/platform_data/mmc-esdhc-imx.h>
  29. #include <linux/pm_runtime.h>
  30. #include "sdhci-pltfm.h"
  31. #include "sdhci-esdhc.h"
  32. #define ESDHC_SYS_CTRL_DTOCV_MASK 0x0f
  33. #define ESDHC_CTRL_D3CD 0x08
  34. #define ESDHC_BURST_LEN_EN_INCR (1 << 27)
  35. /* VENDOR SPEC register */
  36. #define ESDHC_VENDOR_SPEC 0xc0
  37. #define ESDHC_VENDOR_SPEC_SDIO_QUIRK (1 << 1)
  38. #define ESDHC_VENDOR_SPEC_VSELECT (1 << 1)
  39. #define ESDHC_VENDOR_SPEC_FRC_SDCLK_ON (1 << 8)
  40. #define ESDHC_WTMK_LVL 0x44
  41. #define ESDHC_WTMK_DEFAULT_VAL 0x10401040
  42. #define ESDHC_WTMK_LVL_RD_WML_MASK 0x000000FF
  43. #define ESDHC_WTMK_LVL_RD_WML_SHIFT 0
  44. #define ESDHC_WTMK_LVL_WR_WML_MASK 0x00FF0000
  45. #define ESDHC_WTMK_LVL_WR_WML_SHIFT 16
  46. #define ESDHC_WTMK_LVL_WML_VAL_DEF 64
  47. #define ESDHC_WTMK_LVL_WML_VAL_MAX 128
  48. #define ESDHC_MIX_CTRL 0x48
  49. #define ESDHC_MIX_CTRL_DDREN (1 << 3)
  50. #define ESDHC_MIX_CTRL_AC23EN (1 << 7)
  51. #define ESDHC_MIX_CTRL_EXE_TUNE (1 << 22)
  52. #define ESDHC_MIX_CTRL_SMPCLK_SEL (1 << 23)
  53. #define ESDHC_MIX_CTRL_AUTO_TUNE_EN (1 << 24)
  54. #define ESDHC_MIX_CTRL_FBCLK_SEL (1 << 25)
  55. #define ESDHC_MIX_CTRL_HS400_EN (1 << 26)
  56. /* Bits 3 and 6 are not SDHCI standard definitions */
  57. #define ESDHC_MIX_CTRL_SDHCI_MASK 0xb7
  58. /* Tuning bits */
  59. #define ESDHC_MIX_CTRL_TUNING_MASK 0x03c00000
  60. /* dll control register */
  61. #define ESDHC_DLL_CTRL 0x60
  62. #define ESDHC_DLL_OVERRIDE_VAL_SHIFT 9
  63. #define ESDHC_DLL_OVERRIDE_EN_SHIFT 8
  64. /* tune control register */
  65. #define ESDHC_TUNE_CTRL_STATUS 0x68
  66. #define ESDHC_TUNE_CTRL_STEP 1
  67. #define ESDHC_TUNE_CTRL_MIN 0
  68. #define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1)
  69. /* strobe dll register */
  70. #define ESDHC_STROBE_DLL_CTRL 0x70
  71. #define ESDHC_STROBE_DLL_CTRL_ENABLE (1 << 0)
  72. #define ESDHC_STROBE_DLL_CTRL_RESET (1 << 1)
  73. #define ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_SHIFT 3
  74. #define ESDHC_STROBE_DLL_STATUS 0x74
  75. #define ESDHC_STROBE_DLL_STS_REF_LOCK (1 << 1)
  76. #define ESDHC_STROBE_DLL_STS_SLV_LOCK 0x1
  77. #define ESDHC_TUNING_CTRL 0xcc
  78. #define ESDHC_STD_TUNING_EN (1 << 24)
  79. /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
  80. #define ESDHC_TUNING_START_TAP_DEFAULT 0x1
  81. #define ESDHC_TUNING_START_TAP_MASK 0xff
  82. #define ESDHC_TUNING_STEP_MASK 0x00070000
  83. #define ESDHC_TUNING_STEP_SHIFT 16
  84. /* pinctrl state */
  85. #define ESDHC_PINCTRL_STATE_100MHZ "state_100mhz"
  86. #define ESDHC_PINCTRL_STATE_200MHZ "state_200mhz"
  87. /*
  88. * Our interpretation of the SDHCI_HOST_CONTROL register
  89. */
  90. #define ESDHC_CTRL_4BITBUS (0x1 << 1)
  91. #define ESDHC_CTRL_8BITBUS (0x2 << 1)
  92. #define ESDHC_CTRL_BUSWIDTH_MASK (0x3 << 1)
  93. /*
  94. * There is an INT DMA ERR mismatch between eSDHC and STD SDHC SPEC:
  95. * Bit25 is used in STD SPEC, and is reserved in fsl eSDHC design,
  96. * but bit28 is used as the INT DMA ERR in fsl eSDHC design.
  97. * Define this macro DMA error INT for fsl eSDHC
  98. */
  99. #define ESDHC_INT_VENDOR_SPEC_DMA_ERR (1 << 28)
  100. /*
  101. * The CMDTYPE of the CMD register (offset 0xE) should be set to
  102. * "11" when the STOP CMD12 is issued on imx53 to abort one
  103. * open ended multi-blk IO. Otherwise the TC INT wouldn't
  104. * be generated.
  105. * In exact block transfer, the controller doesn't complete the
  106. * operations automatically as required at the end of the
  107. * transfer and remains on hold if the abort command is not sent.
  108. * As a result, the TC flag is not asserted and SW received timeout
  109. * exception. Bit1 of Vendor Spec register is used to fix it.
  110. */
  111. #define ESDHC_FLAG_MULTIBLK_NO_INT BIT(1)
  112. /*
  113. * The flag tells that the ESDHC controller is an USDHC block that is
  114. * integrated on the i.MX6 series.
  115. */
  116. #define ESDHC_FLAG_USDHC BIT(3)
  117. /* The IP supports manual tuning process */
  118. #define ESDHC_FLAG_MAN_TUNING BIT(4)
  119. /* The IP supports standard tuning process */
  120. #define ESDHC_FLAG_STD_TUNING BIT(5)
  121. /* The IP has SDHCI_CAPABILITIES_1 register */
  122. #define ESDHC_FLAG_HAVE_CAP1 BIT(6)
  123. /*
  124. * The IP has erratum ERR004536
  125. * uSDHC: ADMA Length Mismatch Error occurs if the AHB read access is slow,
  126. * when reading data from the card
  127. * This flag is also set for i.MX25 and i.MX35 in order to get
  128. * SDHCI_QUIRK_BROKEN_ADMA, but for different reasons (ADMA capability bits).
  129. */
  130. #define ESDHC_FLAG_ERR004536 BIT(7)
  131. /* The IP supports HS200 mode */
  132. #define ESDHC_FLAG_HS200 BIT(8)
  133. /* The IP supports HS400 mode */
  134. #define ESDHC_FLAG_HS400 BIT(9)
  135. /* A clock frequency higher than this rate requires strobe dll control */
  136. #define ESDHC_STROBE_DLL_CLK_FREQ 100000000
  137. struct esdhc_soc_data {
  138. u32 flags;
  139. };
  140. static struct esdhc_soc_data esdhc_imx25_data = {
  141. .flags = ESDHC_FLAG_ERR004536,
  142. };
  143. static struct esdhc_soc_data esdhc_imx35_data = {
  144. .flags = ESDHC_FLAG_ERR004536,
  145. };
  146. static struct esdhc_soc_data esdhc_imx51_data = {
  147. .flags = 0,
  148. };
  149. static struct esdhc_soc_data esdhc_imx53_data = {
  150. .flags = ESDHC_FLAG_MULTIBLK_NO_INT,
  151. };
  152. static struct esdhc_soc_data usdhc_imx6q_data = {
  153. .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING,
  154. };
  155. static struct esdhc_soc_data usdhc_imx6sl_data = {
  156. .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
  157. | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_ERR004536
  158. | ESDHC_FLAG_HS200,
  159. };
  160. static struct esdhc_soc_data usdhc_imx6sx_data = {
  161. .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
  162. | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200,
  163. };
  164. static struct esdhc_soc_data usdhc_imx7d_data = {
  165. .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
  166. | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
  167. | ESDHC_FLAG_HS400,
  168. };
  169. struct pltfm_imx_data {
  170. u32 scratchpad;
  171. struct pinctrl *pinctrl;
  172. struct pinctrl_state *pins_default;
  173. struct pinctrl_state *pins_100mhz;
  174. struct pinctrl_state *pins_200mhz;
  175. const struct esdhc_soc_data *socdata;
  176. struct esdhc_platform_data boarddata;
  177. struct clk *clk_ipg;
  178. struct clk *clk_ahb;
  179. struct clk *clk_per;
  180. unsigned int actual_clock;
  181. enum {
  182. NO_CMD_PENDING, /* no multiblock command pending */
  183. MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */
  184. WAIT_FOR_INT, /* sent CMD12, waiting for response INT */
  185. } multiblock_status;
  186. u32 is_ddr;
  187. };
  188. static const struct platform_device_id imx_esdhc_devtype[] = {
  189. {
  190. .name = "sdhci-esdhc-imx25",
  191. .driver_data = (kernel_ulong_t) &esdhc_imx25_data,
  192. }, {
  193. .name = "sdhci-esdhc-imx35",
  194. .driver_data = (kernel_ulong_t) &esdhc_imx35_data,
  195. }, {
  196. .name = "sdhci-esdhc-imx51",
  197. .driver_data = (kernel_ulong_t) &esdhc_imx51_data,
  198. }, {
  199. /* sentinel */
  200. }
  201. };
  202. MODULE_DEVICE_TABLE(platform, imx_esdhc_devtype);
  203. static const struct of_device_id imx_esdhc_dt_ids[] = {
  204. { .compatible = "fsl,imx25-esdhc", .data = &esdhc_imx25_data, },
  205. { .compatible = "fsl,imx35-esdhc", .data = &esdhc_imx35_data, },
  206. { .compatible = "fsl,imx51-esdhc", .data = &esdhc_imx51_data, },
  207. { .compatible = "fsl,imx53-esdhc", .data = &esdhc_imx53_data, },
  208. { .compatible = "fsl,imx6sx-usdhc", .data = &usdhc_imx6sx_data, },
  209. { .compatible = "fsl,imx6sl-usdhc", .data = &usdhc_imx6sl_data, },
  210. { .compatible = "fsl,imx6q-usdhc", .data = &usdhc_imx6q_data, },
  211. { .compatible = "fsl,imx7d-usdhc", .data = &usdhc_imx7d_data, },
  212. { /* sentinel */ }
  213. };
  214. MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids);
  215. static inline int is_imx25_esdhc(struct pltfm_imx_data *data)
  216. {
  217. return data->socdata == &esdhc_imx25_data;
  218. }
  219. static inline int is_imx53_esdhc(struct pltfm_imx_data *data)
  220. {
  221. return data->socdata == &esdhc_imx53_data;
  222. }
  223. static inline int is_imx6q_usdhc(struct pltfm_imx_data *data)
  224. {
  225. return data->socdata == &usdhc_imx6q_data;
  226. }
  227. static inline int esdhc_is_usdhc(struct pltfm_imx_data *data)
  228. {
  229. return !!(data->socdata->flags & ESDHC_FLAG_USDHC);
  230. }
  231. static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
  232. {
  233. void __iomem *base = host->ioaddr + (reg & ~0x3);
  234. u32 shift = (reg & 0x3) * 8;
  235. writel(((readl(base) & ~(mask << shift)) | (val << shift)), base);
  236. }
  237. static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
  238. {
  239. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  240. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  241. u32 val = readl(host->ioaddr + reg);
  242. if (unlikely(reg == SDHCI_PRESENT_STATE)) {
  243. u32 fsl_prss = val;
  244. /* save the least 20 bits */
  245. val = fsl_prss & 0x000FFFFF;
  246. /* move dat[0-3] bits */
  247. val |= (fsl_prss & 0x0F000000) >> 4;
  248. /* move cmd line bit */
  249. val |= (fsl_prss & 0x00800000) << 1;
  250. }
  251. if (unlikely(reg == SDHCI_CAPABILITIES)) {
  252. /* ignore bit[0-15] as it stores cap_1 register val for mx6sl */
  253. if (imx_data->socdata->flags & ESDHC_FLAG_HAVE_CAP1)
  254. val &= 0xffff0000;
  255. /* In FSL esdhc IC module, only bit20 is used to indicate the
  256. * ADMA2 capability of esdhc, but this bit is messed up on
  257. * some SOCs (e.g. on MX25, MX35 this bit is set, but they
  258. * don't actually support ADMA2). So set the BROKEN_ADMA
  259. * quirk on MX25/35 platforms.
  260. */
  261. if (val & SDHCI_CAN_DO_ADMA1) {
  262. val &= ~SDHCI_CAN_DO_ADMA1;
  263. val |= SDHCI_CAN_DO_ADMA2;
  264. }
  265. }
  266. if (unlikely(reg == SDHCI_CAPABILITIES_1)) {
  267. if (esdhc_is_usdhc(imx_data)) {
  268. if (imx_data->socdata->flags & ESDHC_FLAG_HAVE_CAP1)
  269. val = readl(host->ioaddr + SDHCI_CAPABILITIES) & 0xFFFF;
  270. else
  271. /* imx6q/dl does not have cap_1 register, fake one */
  272. val = SDHCI_SUPPORT_DDR50 | SDHCI_SUPPORT_SDR104
  273. | SDHCI_SUPPORT_SDR50
  274. | SDHCI_USE_SDR50_TUNING
  275. | (SDHCI_TUNING_MODE_3 << SDHCI_RETUNING_MODE_SHIFT);
  276. if (imx_data->socdata->flags & ESDHC_FLAG_HS400)
  277. val |= SDHCI_SUPPORT_HS400;
  278. }
  279. }
  280. if (unlikely(reg == SDHCI_MAX_CURRENT) && esdhc_is_usdhc(imx_data)) {
  281. val = 0;
  282. val |= 0xFF << SDHCI_MAX_CURRENT_330_SHIFT;
  283. val |= 0xFF << SDHCI_MAX_CURRENT_300_SHIFT;
  284. val |= 0xFF << SDHCI_MAX_CURRENT_180_SHIFT;
  285. }
  286. if (unlikely(reg == SDHCI_INT_STATUS)) {
  287. if (val & ESDHC_INT_VENDOR_SPEC_DMA_ERR) {
  288. val &= ~ESDHC_INT_VENDOR_SPEC_DMA_ERR;
  289. val |= SDHCI_INT_ADMA_ERROR;
  290. }
  291. /*
  292. * mask off the interrupt we get in response to the manually
  293. * sent CMD12
  294. */
  295. if ((imx_data->multiblock_status == WAIT_FOR_INT) &&
  296. ((val & SDHCI_INT_RESPONSE) == SDHCI_INT_RESPONSE)) {
  297. val &= ~SDHCI_INT_RESPONSE;
  298. writel(SDHCI_INT_RESPONSE, host->ioaddr +
  299. SDHCI_INT_STATUS);
  300. imx_data->multiblock_status = NO_CMD_PENDING;
  301. }
  302. }
  303. return val;
  304. }
  305. static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
  306. {
  307. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  308. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  309. u32 data;
  310. if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE ||
  311. reg == SDHCI_INT_STATUS)) {
  312. if ((val & SDHCI_INT_CARD_INT) && !esdhc_is_usdhc(imx_data)) {
  313. /*
  314. * Clear and then set D3CD bit to avoid missing the
  315. * card interrupt. This is an eSDHC controller problem
  316. * so we need to apply the following workaround: clear
  317. * and set D3CD bit will make eSDHC re-sample the card
  318. * interrupt. In case a card interrupt was lost,
  319. * re-sample it by the following steps.
  320. */
  321. data = readl(host->ioaddr + SDHCI_HOST_CONTROL);
  322. data &= ~ESDHC_CTRL_D3CD;
  323. writel(data, host->ioaddr + SDHCI_HOST_CONTROL);
  324. data |= ESDHC_CTRL_D3CD;
  325. writel(data, host->ioaddr + SDHCI_HOST_CONTROL);
  326. }
  327. if (val & SDHCI_INT_ADMA_ERROR) {
  328. val &= ~SDHCI_INT_ADMA_ERROR;
  329. val |= ESDHC_INT_VENDOR_SPEC_DMA_ERR;
  330. }
  331. }
  332. if (unlikely((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
  333. && (reg == SDHCI_INT_STATUS)
  334. && (val & SDHCI_INT_DATA_END))) {
  335. u32 v;
  336. v = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
  337. v &= ~ESDHC_VENDOR_SPEC_SDIO_QUIRK;
  338. writel(v, host->ioaddr + ESDHC_VENDOR_SPEC);
  339. if (imx_data->multiblock_status == MULTIBLK_IN_PROCESS)
  340. {
  341. /* send a manual CMD12 with RESPTYP=none */
  342. data = MMC_STOP_TRANSMISSION << 24 |
  343. SDHCI_CMD_ABORTCMD << 16;
  344. writel(data, host->ioaddr + SDHCI_TRANSFER_MODE);
  345. imx_data->multiblock_status = WAIT_FOR_INT;
  346. }
  347. }
  348. writel(val, host->ioaddr + reg);
  349. }
  350. static u16 esdhc_readw_le(struct sdhci_host *host, int reg)
  351. {
  352. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  353. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  354. u16 ret = 0;
  355. u32 val;
  356. if (unlikely(reg == SDHCI_HOST_VERSION)) {
  357. reg ^= 2;
  358. if (esdhc_is_usdhc(imx_data)) {
  359. /*
  360. * The usdhc register returns a wrong host version.
  361. * Correct it here.
  362. */
  363. return SDHCI_SPEC_300;
  364. }
  365. }
  366. 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. if (esdhc_is_usdhc(imx_data)) {
  371. if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
  372. val = readl(host->ioaddr + ESDHC_MIX_CTRL);
  373. else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING)
  374. /* the std tuning bits is in ACMD12_ERR for imx6sl */
  375. val = readl(host->ioaddr + SDHCI_ACMD12_ERR);
  376. }
  377. if (val & ESDHC_MIX_CTRL_EXE_TUNE)
  378. ret |= SDHCI_CTRL_EXEC_TUNING;
  379. if (val & ESDHC_MIX_CTRL_SMPCLK_SEL)
  380. ret |= SDHCI_CTRL_TUNED_CLK;
  381. ret &= ~SDHCI_CTRL_PRESET_VAL_ENABLE;
  382. return ret;
  383. }
  384. if (unlikely(reg == SDHCI_TRANSFER_MODE)) {
  385. if (esdhc_is_usdhc(imx_data)) {
  386. u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
  387. ret = m & ESDHC_MIX_CTRL_SDHCI_MASK;
  388. /* Swap AC23 bit */
  389. if (m & ESDHC_MIX_CTRL_AC23EN) {
  390. ret &= ~ESDHC_MIX_CTRL_AC23EN;
  391. ret |= SDHCI_TRNS_AUTO_CMD23;
  392. }
  393. } else {
  394. ret = readw(host->ioaddr + SDHCI_TRANSFER_MODE);
  395. }
  396. return ret;
  397. }
  398. return readw(host->ioaddr + reg);
  399. }
  400. static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
  401. {
  402. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  403. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  404. u32 new_val = 0;
  405. switch (reg) {
  406. case SDHCI_CLOCK_CONTROL:
  407. new_val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
  408. if (val & SDHCI_CLOCK_CARD_EN)
  409. new_val |= ESDHC_VENDOR_SPEC_FRC_SDCLK_ON;
  410. else
  411. new_val &= ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON;
  412. writel(new_val, host->ioaddr + ESDHC_VENDOR_SPEC);
  413. return;
  414. case SDHCI_HOST_CONTROL2:
  415. new_val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
  416. if (val & SDHCI_CTRL_VDD_180)
  417. new_val |= ESDHC_VENDOR_SPEC_VSELECT;
  418. else
  419. new_val &= ~ESDHC_VENDOR_SPEC_VSELECT;
  420. writel(new_val, host->ioaddr + ESDHC_VENDOR_SPEC);
  421. if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
  422. new_val = readl(host->ioaddr + ESDHC_MIX_CTRL);
  423. if (val & SDHCI_CTRL_TUNED_CLK) {
  424. new_val |= ESDHC_MIX_CTRL_SMPCLK_SEL;
  425. new_val |= ESDHC_MIX_CTRL_AUTO_TUNE_EN;
  426. } else {
  427. new_val &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
  428. new_val &= ~ESDHC_MIX_CTRL_AUTO_TUNE_EN;
  429. }
  430. writel(new_val , host->ioaddr + ESDHC_MIX_CTRL);
  431. } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
  432. u32 v = readl(host->ioaddr + SDHCI_ACMD12_ERR);
  433. u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
  434. if (val & SDHCI_CTRL_TUNED_CLK) {
  435. v |= ESDHC_MIX_CTRL_SMPCLK_SEL;
  436. } else {
  437. v &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
  438. m &= ~ESDHC_MIX_CTRL_FBCLK_SEL;
  439. m &= ~ESDHC_MIX_CTRL_AUTO_TUNE_EN;
  440. }
  441. if (val & SDHCI_CTRL_EXEC_TUNING) {
  442. v |= ESDHC_MIX_CTRL_EXE_TUNE;
  443. m |= ESDHC_MIX_CTRL_FBCLK_SEL;
  444. m |= ESDHC_MIX_CTRL_AUTO_TUNE_EN;
  445. } else {
  446. v &= ~ESDHC_MIX_CTRL_EXE_TUNE;
  447. }
  448. writel(v, host->ioaddr + SDHCI_ACMD12_ERR);
  449. writel(m, host->ioaddr + ESDHC_MIX_CTRL);
  450. }
  451. return;
  452. case SDHCI_TRANSFER_MODE:
  453. if ((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
  454. && (host->cmd->opcode == SD_IO_RW_EXTENDED)
  455. && (host->cmd->data->blocks > 1)
  456. && (host->cmd->data->flags & MMC_DATA_READ)) {
  457. u32 v;
  458. v = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
  459. v |= ESDHC_VENDOR_SPEC_SDIO_QUIRK;
  460. writel(v, host->ioaddr + ESDHC_VENDOR_SPEC);
  461. }
  462. if (esdhc_is_usdhc(imx_data)) {
  463. u32 wml;
  464. u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
  465. /* Swap AC23 bit */
  466. if (val & SDHCI_TRNS_AUTO_CMD23) {
  467. val &= ~SDHCI_TRNS_AUTO_CMD23;
  468. val |= ESDHC_MIX_CTRL_AC23EN;
  469. }
  470. m = val | (m & ~ESDHC_MIX_CTRL_SDHCI_MASK);
  471. writel(m, host->ioaddr + ESDHC_MIX_CTRL);
  472. /* Set watermark levels for PIO access to maximum value
  473. * (128 words) to accommodate full 512 bytes buffer.
  474. * For DMA access restore the levels to default value.
  475. */
  476. m = readl(host->ioaddr + ESDHC_WTMK_LVL);
  477. if (val & SDHCI_TRNS_DMA)
  478. wml = ESDHC_WTMK_LVL_WML_VAL_DEF;
  479. else
  480. wml = ESDHC_WTMK_LVL_WML_VAL_MAX;
  481. m &= ~(ESDHC_WTMK_LVL_RD_WML_MASK |
  482. ESDHC_WTMK_LVL_WR_WML_MASK);
  483. m |= (wml << ESDHC_WTMK_LVL_RD_WML_SHIFT) |
  484. (wml << ESDHC_WTMK_LVL_WR_WML_SHIFT);
  485. writel(m, host->ioaddr + ESDHC_WTMK_LVL);
  486. } else {
  487. /*
  488. * Postpone this write, we must do it together with a
  489. * command write that is down below.
  490. */
  491. imx_data->scratchpad = val;
  492. }
  493. return;
  494. case SDHCI_COMMAND:
  495. if (host->cmd->opcode == MMC_STOP_TRANSMISSION)
  496. val |= SDHCI_CMD_ABORTCMD;
  497. if ((host->cmd->opcode == MMC_SET_BLOCK_COUNT) &&
  498. (imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
  499. imx_data->multiblock_status = MULTIBLK_IN_PROCESS;
  500. if (esdhc_is_usdhc(imx_data))
  501. writel(val << 16,
  502. host->ioaddr + SDHCI_TRANSFER_MODE);
  503. else
  504. writel(val << 16 | imx_data->scratchpad,
  505. host->ioaddr + SDHCI_TRANSFER_MODE);
  506. return;
  507. case SDHCI_BLOCK_SIZE:
  508. val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);
  509. break;
  510. }
  511. esdhc_clrset_le(host, 0xffff, val, reg);
  512. }
  513. static u8 esdhc_readb_le(struct sdhci_host *host, int reg)
  514. {
  515. u8 ret;
  516. u32 val;
  517. switch (reg) {
  518. case SDHCI_HOST_CONTROL:
  519. val = readl(host->ioaddr + reg);
  520. ret = val & SDHCI_CTRL_LED;
  521. ret |= (val >> 5) & SDHCI_CTRL_DMA_MASK;
  522. ret |= (val & ESDHC_CTRL_4BITBUS);
  523. ret |= (val & ESDHC_CTRL_8BITBUS) << 3;
  524. return ret;
  525. }
  526. return readb(host->ioaddr + reg);
  527. }
  528. static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
  529. {
  530. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  531. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  532. u32 new_val = 0;
  533. u32 mask;
  534. switch (reg) {
  535. case SDHCI_POWER_CONTROL:
  536. /*
  537. * FSL put some DMA bits here
  538. * If your board has a regulator, code should be here
  539. */
  540. return;
  541. case SDHCI_HOST_CONTROL:
  542. /* FSL messed up here, so we need to manually compose it. */
  543. new_val = val & SDHCI_CTRL_LED;
  544. /* ensure the endianness */
  545. new_val |= ESDHC_HOST_CONTROL_LE;
  546. /* bits 8&9 are reserved on mx25 */
  547. if (!is_imx25_esdhc(imx_data)) {
  548. /* DMA mode bits are shifted */
  549. new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5;
  550. }
  551. /*
  552. * Do not touch buswidth bits here. This is done in
  553. * esdhc_pltfm_bus_width.
  554. * Do not touch the D3CD bit either which is used for the
  555. * SDIO interrupt erratum workaround.
  556. */
  557. mask = 0xffff & ~(ESDHC_CTRL_BUSWIDTH_MASK | ESDHC_CTRL_D3CD);
  558. esdhc_clrset_le(host, mask, new_val, reg);
  559. return;
  560. case SDHCI_SOFTWARE_RESET:
  561. if (val & SDHCI_RESET_DATA)
  562. new_val = readl(host->ioaddr + SDHCI_HOST_CONTROL);
  563. break;
  564. }
  565. esdhc_clrset_le(host, 0xff, val, reg);
  566. if (reg == SDHCI_SOFTWARE_RESET) {
  567. if (val & SDHCI_RESET_ALL) {
  568. /*
  569. * The esdhc has a design violation to SDHC spec which
  570. * tells that software reset should not affect card
  571. * detection circuit. But esdhc clears its SYSCTL
  572. * register bits [0..2] during the software reset. This
  573. * will stop those clocks that card detection circuit
  574. * relies on. To work around it, we turn the clocks on
  575. * back to keep card detection circuit functional.
  576. */
  577. esdhc_clrset_le(host, 0x7, 0x7, ESDHC_SYSTEM_CONTROL);
  578. /*
  579. * The reset on usdhc fails to clear MIX_CTRL register.
  580. * Do it manually here.
  581. */
  582. if (esdhc_is_usdhc(imx_data)) {
  583. /*
  584. * the tuning bits should be kept during reset
  585. */
  586. new_val = readl(host->ioaddr + ESDHC_MIX_CTRL);
  587. writel(new_val & ESDHC_MIX_CTRL_TUNING_MASK,
  588. host->ioaddr + ESDHC_MIX_CTRL);
  589. imx_data->is_ddr = 0;
  590. }
  591. } else if (val & SDHCI_RESET_DATA) {
  592. /*
  593. * The eSDHC DAT line software reset clears at least the
  594. * data transfer width on i.MX25, so make sure that the
  595. * Host Control register is unaffected.
  596. */
  597. esdhc_clrset_le(host, 0xff, new_val,
  598. SDHCI_HOST_CONTROL);
  599. }
  600. }
  601. }
  602. static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host)
  603. {
  604. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  605. return pltfm_host->clock;
  606. }
  607. static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
  608. {
  609. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  610. return pltfm_host->clock / 256 / 16;
  611. }
  612. static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
  613. unsigned int clock)
  614. {
  615. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  616. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  617. unsigned int host_clock = pltfm_host->clock;
  618. int ddr_pre_div = imx_data->is_ddr ? 2 : 1;
  619. int pre_div = 1;
  620. int div = 1;
  621. u32 temp, val;
  622. if (clock == 0) {
  623. host->mmc->actual_clock = 0;
  624. if (esdhc_is_usdhc(imx_data)) {
  625. val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
  626. writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
  627. host->ioaddr + ESDHC_VENDOR_SPEC);
  628. }
  629. return;
  630. }
  631. /* For i.MX53 eSDHCv3, SYSCTL.SDCLKFS may not be set to 0. */
  632. if (is_imx53_esdhc(imx_data)) {
  633. /*
  634. * According to the i.MX53 reference manual, if DLLCTRL[10] can
  635. * be set, then the controller is eSDHCv3, else it is eSDHCv2.
  636. */
  637. val = readl(host->ioaddr + ESDHC_DLL_CTRL);
  638. writel(val | BIT(10), host->ioaddr + ESDHC_DLL_CTRL);
  639. temp = readl(host->ioaddr + ESDHC_DLL_CTRL);
  640. writel(val, host->ioaddr + ESDHC_DLL_CTRL);
  641. if (temp & BIT(10))
  642. pre_div = 2;
  643. }
  644. temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
  645. temp &= ~(ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
  646. | ESDHC_CLOCK_MASK);
  647. sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
  648. while (host_clock / (16 * pre_div * ddr_pre_div) > clock &&
  649. pre_div < 256)
  650. pre_div *= 2;
  651. while (host_clock / (div * pre_div * ddr_pre_div) > clock && div < 16)
  652. div++;
  653. host->mmc->actual_clock = host_clock / (div * pre_div * ddr_pre_div);
  654. dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
  655. clock, host->mmc->actual_clock);
  656. pre_div >>= 1;
  657. div--;
  658. temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
  659. temp |= (ESDHC_CLOCK_IPGEN | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN
  660. | (div << ESDHC_DIVIDER_SHIFT)
  661. | (pre_div << ESDHC_PREDIV_SHIFT));
  662. sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
  663. if (esdhc_is_usdhc(imx_data)) {
  664. val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
  665. writel(val | ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
  666. host->ioaddr + ESDHC_VENDOR_SPEC);
  667. }
  668. mdelay(1);
  669. }
  670. static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
  671. {
  672. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  673. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  674. struct esdhc_platform_data *boarddata = &imx_data->boarddata;
  675. switch (boarddata->wp_type) {
  676. case ESDHC_WP_GPIO:
  677. return mmc_gpio_get_ro(host->mmc);
  678. case ESDHC_WP_CONTROLLER:
  679. return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
  680. SDHCI_WRITE_PROTECT);
  681. case ESDHC_WP_NONE:
  682. break;
  683. }
  684. return -ENOSYS;
  685. }
  686. static void esdhc_pltfm_set_bus_width(struct sdhci_host *host, int width)
  687. {
  688. u32 ctrl;
  689. switch (width) {
  690. case MMC_BUS_WIDTH_8:
  691. ctrl = ESDHC_CTRL_8BITBUS;
  692. break;
  693. case MMC_BUS_WIDTH_4:
  694. ctrl = ESDHC_CTRL_4BITBUS;
  695. break;
  696. default:
  697. ctrl = 0;
  698. break;
  699. }
  700. esdhc_clrset_le(host, ESDHC_CTRL_BUSWIDTH_MASK, ctrl,
  701. SDHCI_HOST_CONTROL);
  702. }
  703. static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
  704. {
  705. u32 reg;
  706. /* FIXME: delay a bit for card to be ready for next tuning due to errors */
  707. mdelay(1);
  708. reg = readl(host->ioaddr + ESDHC_MIX_CTRL);
  709. reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL |
  710. ESDHC_MIX_CTRL_FBCLK_SEL;
  711. writel(reg, host->ioaddr + ESDHC_MIX_CTRL);
  712. writel(val << 8, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
  713. dev_dbg(mmc_dev(host->mmc),
  714. "tuning with delay 0x%x ESDHC_TUNE_CTRL_STATUS 0x%x\n",
  715. val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS));
  716. }
  717. static void esdhc_post_tuning(struct sdhci_host *host)
  718. {
  719. u32 reg;
  720. reg = readl(host->ioaddr + ESDHC_MIX_CTRL);
  721. reg &= ~ESDHC_MIX_CTRL_EXE_TUNE;
  722. reg |= ESDHC_MIX_CTRL_AUTO_TUNE_EN;
  723. writel(reg, host->ioaddr + ESDHC_MIX_CTRL);
  724. }
  725. static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
  726. {
  727. int min, max, avg, ret;
  728. /* find the mininum delay first which can pass tuning */
  729. min = ESDHC_TUNE_CTRL_MIN;
  730. while (min < ESDHC_TUNE_CTRL_MAX) {
  731. esdhc_prepare_tuning(host, min);
  732. if (!mmc_send_tuning(host->mmc, opcode, NULL))
  733. break;
  734. min += ESDHC_TUNE_CTRL_STEP;
  735. }
  736. /* find the maxinum delay which can not pass tuning */
  737. max = min + ESDHC_TUNE_CTRL_STEP;
  738. while (max < ESDHC_TUNE_CTRL_MAX) {
  739. esdhc_prepare_tuning(host, max);
  740. if (mmc_send_tuning(host->mmc, opcode, NULL)) {
  741. max -= ESDHC_TUNE_CTRL_STEP;
  742. break;
  743. }
  744. max += ESDHC_TUNE_CTRL_STEP;
  745. }
  746. /* use average delay to get the best timing */
  747. avg = (min + max) / 2;
  748. esdhc_prepare_tuning(host, avg);
  749. ret = mmc_send_tuning(host->mmc, opcode, NULL);
  750. esdhc_post_tuning(host);
  751. dev_dbg(mmc_dev(host->mmc), "tuning %s at 0x%x ret %d\n",
  752. ret ? "failed" : "passed", avg, ret);
  753. return ret;
  754. }
  755. static int esdhc_change_pinstate(struct sdhci_host *host,
  756. unsigned int uhs)
  757. {
  758. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  759. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  760. struct pinctrl_state *pinctrl;
  761. dev_dbg(mmc_dev(host->mmc), "change pinctrl state for uhs %d\n", uhs);
  762. if (IS_ERR(imx_data->pinctrl) ||
  763. IS_ERR(imx_data->pins_default) ||
  764. IS_ERR(imx_data->pins_100mhz) ||
  765. IS_ERR(imx_data->pins_200mhz))
  766. return -EINVAL;
  767. switch (uhs) {
  768. case MMC_TIMING_UHS_SDR50:
  769. case MMC_TIMING_UHS_DDR50:
  770. pinctrl = imx_data->pins_100mhz;
  771. break;
  772. case MMC_TIMING_UHS_SDR104:
  773. case MMC_TIMING_MMC_HS200:
  774. case MMC_TIMING_MMC_HS400:
  775. pinctrl = imx_data->pins_200mhz;
  776. break;
  777. default:
  778. /* back to default state for other legacy timing */
  779. pinctrl = imx_data->pins_default;
  780. }
  781. return pinctrl_select_state(imx_data->pinctrl, pinctrl);
  782. }
  783. /*
  784. * For HS400 eMMC, there is a data_strobe line. This signal is generated
  785. * by the device and used for data output and CRC status response output
  786. * in HS400 mode. The frequency of this signal follows the frequency of
  787. * CLK generated by host. The host receives the data which is aligned to the
  788. * edge of data_strobe line. Due to the time delay between CLK line and
  789. * data_strobe line, if the delay time is larger than one clock cycle,
  790. * then CLK and data_strobe line will be misaligned, read error shows up.
  791. * So when the CLK is higher than 100MHz, each clock cycle is short enough,
  792. * host should configure the delay target.
  793. */
  794. static void esdhc_set_strobe_dll(struct sdhci_host *host)
  795. {
  796. u32 v;
  797. if (host->mmc->actual_clock > ESDHC_STROBE_DLL_CLK_FREQ) {
  798. /* disable clock before enabling strobe dll */
  799. writel(readl(host->ioaddr + ESDHC_VENDOR_SPEC) &
  800. ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
  801. host->ioaddr + ESDHC_VENDOR_SPEC);
  802. /* force a reset on strobe dll */
  803. writel(ESDHC_STROBE_DLL_CTRL_RESET,
  804. host->ioaddr + ESDHC_STROBE_DLL_CTRL);
  805. /*
  806. * enable strobe dll ctrl and adjust the delay target
  807. * for the uSDHC loopback read clock
  808. */
  809. v = ESDHC_STROBE_DLL_CTRL_ENABLE |
  810. (7 << ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_SHIFT);
  811. writel(v, host->ioaddr + ESDHC_STROBE_DLL_CTRL);
  812. /* wait 1us to make sure strobe dll status register stable */
  813. udelay(1);
  814. v = readl(host->ioaddr + ESDHC_STROBE_DLL_STATUS);
  815. if (!(v & ESDHC_STROBE_DLL_STS_REF_LOCK))
  816. dev_warn(mmc_dev(host->mmc),
  817. "warning! HS400 strobe DLL status REF not lock!\n");
  818. if (!(v & ESDHC_STROBE_DLL_STS_SLV_LOCK))
  819. dev_warn(mmc_dev(host->mmc),
  820. "warning! HS400 strobe DLL status SLV not lock!\n");
  821. }
  822. }
  823. static void esdhc_reset_tuning(struct sdhci_host *host)
  824. {
  825. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  826. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  827. u32 ctrl;
  828. /* Reset the tuning circuit */
  829. if (esdhc_is_usdhc(imx_data)) {
  830. if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
  831. ctrl = readl(host->ioaddr + ESDHC_MIX_CTRL);
  832. ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
  833. ctrl &= ~ESDHC_MIX_CTRL_FBCLK_SEL;
  834. writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL);
  835. writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
  836. } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
  837. ctrl = readl(host->ioaddr + SDHCI_ACMD12_ERR);
  838. ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
  839. writel(ctrl, host->ioaddr + SDHCI_ACMD12_ERR);
  840. }
  841. }
  842. }
  843. static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
  844. {
  845. u32 m;
  846. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  847. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  848. struct esdhc_platform_data *boarddata = &imx_data->boarddata;
  849. /* disable ddr mode and disable HS400 mode */
  850. m = readl(host->ioaddr + ESDHC_MIX_CTRL);
  851. m &= ~(ESDHC_MIX_CTRL_DDREN | ESDHC_MIX_CTRL_HS400_EN);
  852. imx_data->is_ddr = 0;
  853. switch (timing) {
  854. case MMC_TIMING_UHS_SDR12:
  855. case MMC_TIMING_UHS_SDR25:
  856. case MMC_TIMING_UHS_SDR50:
  857. case MMC_TIMING_UHS_SDR104:
  858. case MMC_TIMING_MMC_HS200:
  859. writel(m, host->ioaddr + ESDHC_MIX_CTRL);
  860. break;
  861. case MMC_TIMING_UHS_DDR50:
  862. case MMC_TIMING_MMC_DDR52:
  863. m |= ESDHC_MIX_CTRL_DDREN;
  864. writel(m, host->ioaddr + ESDHC_MIX_CTRL);
  865. imx_data->is_ddr = 1;
  866. if (boarddata->delay_line) {
  867. u32 v;
  868. v = boarddata->delay_line <<
  869. ESDHC_DLL_OVERRIDE_VAL_SHIFT |
  870. (1 << ESDHC_DLL_OVERRIDE_EN_SHIFT);
  871. if (is_imx53_esdhc(imx_data))
  872. v <<= 1;
  873. writel(v, host->ioaddr + ESDHC_DLL_CTRL);
  874. }
  875. break;
  876. case MMC_TIMING_MMC_HS400:
  877. m |= ESDHC_MIX_CTRL_DDREN | ESDHC_MIX_CTRL_HS400_EN;
  878. writel(m, host->ioaddr + ESDHC_MIX_CTRL);
  879. imx_data->is_ddr = 1;
  880. /* update clock after enable DDR for strobe DLL lock */
  881. host->ops->set_clock(host, host->clock);
  882. esdhc_set_strobe_dll(host);
  883. break;
  884. case MMC_TIMING_LEGACY:
  885. default:
  886. esdhc_reset_tuning(host);
  887. break;
  888. }
  889. esdhc_change_pinstate(host, timing);
  890. }
  891. static void esdhc_reset(struct sdhci_host *host, u8 mask)
  892. {
  893. sdhci_reset(host, mask);
  894. sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
  895. sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
  896. }
  897. static unsigned int esdhc_get_max_timeout_count(struct sdhci_host *host)
  898. {
  899. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  900. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  901. /* Doc Erratum: the uSDHC actual maximum timeout count is 1 << 29 */
  902. return esdhc_is_usdhc(imx_data) ? 1 << 29 : 1 << 27;
  903. }
  904. static void esdhc_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
  905. {
  906. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  907. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  908. /* use maximum timeout counter */
  909. esdhc_clrset_le(host, ESDHC_SYS_CTRL_DTOCV_MASK,
  910. esdhc_is_usdhc(imx_data) ? 0xF : 0xE,
  911. SDHCI_TIMEOUT_CONTROL);
  912. }
  913. static struct sdhci_ops sdhci_esdhc_ops = {
  914. .read_l = esdhc_readl_le,
  915. .read_w = esdhc_readw_le,
  916. .read_b = esdhc_readb_le,
  917. .write_l = esdhc_writel_le,
  918. .write_w = esdhc_writew_le,
  919. .write_b = esdhc_writeb_le,
  920. .set_clock = esdhc_pltfm_set_clock,
  921. .get_max_clock = esdhc_pltfm_get_max_clock,
  922. .get_min_clock = esdhc_pltfm_get_min_clock,
  923. .get_max_timeout_count = esdhc_get_max_timeout_count,
  924. .get_ro = esdhc_pltfm_get_ro,
  925. .set_timeout = esdhc_set_timeout,
  926. .set_bus_width = esdhc_pltfm_set_bus_width,
  927. .set_uhs_signaling = esdhc_set_uhs_signaling,
  928. .reset = esdhc_reset,
  929. };
  930. static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
  931. .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_HISPD_BIT
  932. | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
  933. | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
  934. | SDHCI_QUIRK_BROKEN_CARD_DETECTION,
  935. .ops = &sdhci_esdhc_ops,
  936. };
  937. static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
  938. {
  939. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  940. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  941. int tmp;
  942. if (esdhc_is_usdhc(imx_data)) {
  943. /*
  944. * The imx6q ROM code will change the default watermark
  945. * level setting to something insane. Change it back here.
  946. */
  947. writel(ESDHC_WTMK_DEFAULT_VAL, host->ioaddr + ESDHC_WTMK_LVL);
  948. /*
  949. * ROM code will change the bit burst_length_enable setting
  950. * to zero if this usdhc is chosen to boot system. Change
  951. * it back here, otherwise it will impact the performance a
  952. * lot. This bit is used to enable/disable the burst length
  953. * for the external AHB2AXI bridge. It's useful especially
  954. * for INCR transfer because without burst length indicator,
  955. * the AHB2AXI bridge does not know the burst length in
  956. * advance. And without burst length indicator, AHB INCR
  957. * transfer can only be converted to singles on the AXI side.
  958. */
  959. writel(readl(host->ioaddr + SDHCI_HOST_CONTROL)
  960. | ESDHC_BURST_LEN_EN_INCR,
  961. host->ioaddr + SDHCI_HOST_CONTROL);
  962. /*
  963. * erratum ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL
  964. * TO1.1, it's harmless for MX6SL
  965. */
  966. writel(readl(host->ioaddr + 0x6c) | BIT(7),
  967. host->ioaddr + 0x6c);
  968. /* disable DLL_CTRL delay line settings */
  969. writel(0x0, host->ioaddr + ESDHC_DLL_CTRL);
  970. if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
  971. tmp = readl(host->ioaddr + ESDHC_TUNING_CTRL);
  972. tmp |= ESDHC_STD_TUNING_EN |
  973. ESDHC_TUNING_START_TAP_DEFAULT;
  974. if (imx_data->boarddata.tuning_start_tap) {
  975. tmp &= ~ESDHC_TUNING_START_TAP_MASK;
  976. tmp |= imx_data->boarddata.tuning_start_tap;
  977. }
  978. if (imx_data->boarddata.tuning_step) {
  979. tmp &= ~ESDHC_TUNING_STEP_MASK;
  980. tmp |= imx_data->boarddata.tuning_step
  981. << ESDHC_TUNING_STEP_SHIFT;
  982. }
  983. writel(tmp, host->ioaddr + ESDHC_TUNING_CTRL);
  984. }
  985. }
  986. }
  987. #ifdef CONFIG_OF
  988. static int
  989. sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
  990. struct sdhci_host *host,
  991. struct pltfm_imx_data *imx_data)
  992. {
  993. struct device_node *np = pdev->dev.of_node;
  994. struct esdhc_platform_data *boarddata = &imx_data->boarddata;
  995. int ret;
  996. if (of_get_property(np, "fsl,wp-controller", NULL))
  997. boarddata->wp_type = ESDHC_WP_CONTROLLER;
  998. boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
  999. if (gpio_is_valid(boarddata->wp_gpio))
  1000. boarddata->wp_type = ESDHC_WP_GPIO;
  1001. of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
  1002. of_property_read_u32(np, "fsl,tuning-start-tap",
  1003. &boarddata->tuning_start_tap);
  1004. if (of_find_property(np, "no-1-8-v", NULL))
  1005. boarddata->support_vsel = false;
  1006. else
  1007. boarddata->support_vsel = true;
  1008. if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line))
  1009. boarddata->delay_line = 0;
  1010. mmc_of_parse_voltage(np, &host->ocr_mask);
  1011. /* sdr50 and sdr104 need work on 1.8v signal voltage */
  1012. if ((boarddata->support_vsel) && esdhc_is_usdhc(imx_data) &&
  1013. !IS_ERR(imx_data->pins_default)) {
  1014. imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
  1015. ESDHC_PINCTRL_STATE_100MHZ);
  1016. imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
  1017. ESDHC_PINCTRL_STATE_200MHZ);
  1018. if (IS_ERR(imx_data->pins_100mhz) ||
  1019. IS_ERR(imx_data->pins_200mhz)) {
  1020. dev_warn(mmc_dev(host->mmc),
  1021. "could not get ultra high speed state, work on normal mode\n");
  1022. /*
  1023. * fall back to not supporting uhs by specifying no
  1024. * 1.8v quirk
  1025. */
  1026. host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
  1027. }
  1028. } else {
  1029. host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
  1030. }
  1031. /* call to generic mmc_of_parse to support additional capabilities */
  1032. ret = mmc_of_parse(host->mmc);
  1033. if (ret)
  1034. return ret;
  1035. if (mmc_gpio_get_cd(host->mmc) >= 0)
  1036. host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
  1037. return 0;
  1038. }
  1039. #else
  1040. static inline int
  1041. sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
  1042. struct sdhci_host *host,
  1043. struct pltfm_imx_data *imx_data)
  1044. {
  1045. return -ENODEV;
  1046. }
  1047. #endif
  1048. static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev,
  1049. struct sdhci_host *host,
  1050. struct pltfm_imx_data *imx_data)
  1051. {
  1052. struct esdhc_platform_data *boarddata = &imx_data->boarddata;
  1053. int err;
  1054. if (!host->mmc->parent->platform_data) {
  1055. dev_err(mmc_dev(host->mmc), "no board data!\n");
  1056. return -EINVAL;
  1057. }
  1058. imx_data->boarddata = *((struct esdhc_platform_data *)
  1059. host->mmc->parent->platform_data);
  1060. /* write_protect */
  1061. if (boarddata->wp_type == ESDHC_WP_GPIO) {
  1062. err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
  1063. if (err) {
  1064. dev_err(mmc_dev(host->mmc),
  1065. "failed to request write-protect gpio!\n");
  1066. return err;
  1067. }
  1068. host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
  1069. }
  1070. /* card_detect */
  1071. switch (boarddata->cd_type) {
  1072. case ESDHC_CD_GPIO:
  1073. err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
  1074. if (err) {
  1075. dev_err(mmc_dev(host->mmc),
  1076. "failed to request card-detect gpio!\n");
  1077. return err;
  1078. }
  1079. /* fall through */
  1080. case ESDHC_CD_CONTROLLER:
  1081. /* we have a working card_detect back */
  1082. host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
  1083. break;
  1084. case ESDHC_CD_PERMANENT:
  1085. host->mmc->caps |= MMC_CAP_NONREMOVABLE;
  1086. break;
  1087. case ESDHC_CD_NONE:
  1088. break;
  1089. }
  1090. 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. return 0;
  1103. }
  1104. static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
  1105. {
  1106. const struct of_device_id *of_id =
  1107. of_match_device(imx_esdhc_dt_ids, &pdev->dev);
  1108. struct sdhci_pltfm_host *pltfm_host;
  1109. struct sdhci_host *host;
  1110. int err;
  1111. struct pltfm_imx_data *imx_data;
  1112. host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata,
  1113. sizeof(*imx_data));
  1114. if (IS_ERR(host))
  1115. return PTR_ERR(host);
  1116. pltfm_host = sdhci_priv(host);
  1117. imx_data = sdhci_pltfm_priv(pltfm_host);
  1118. imx_data->socdata = of_id ? of_id->data : (struct esdhc_soc_data *)
  1119. pdev->id_entry->driver_data;
  1120. imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
  1121. if (IS_ERR(imx_data->clk_ipg)) {
  1122. err = PTR_ERR(imx_data->clk_ipg);
  1123. goto free_sdhci;
  1124. }
  1125. imx_data->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
  1126. if (IS_ERR(imx_data->clk_ahb)) {
  1127. err = PTR_ERR(imx_data->clk_ahb);
  1128. goto free_sdhci;
  1129. }
  1130. imx_data->clk_per = devm_clk_get(&pdev->dev, "per");
  1131. if (IS_ERR(imx_data->clk_per)) {
  1132. err = PTR_ERR(imx_data->clk_per);
  1133. goto free_sdhci;
  1134. }
  1135. pltfm_host->clk = imx_data->clk_per;
  1136. pltfm_host->clock = clk_get_rate(pltfm_host->clk);
  1137. err = clk_prepare_enable(imx_data->clk_per);
  1138. if (err)
  1139. goto free_sdhci;
  1140. err = clk_prepare_enable(imx_data->clk_ipg);
  1141. if (err)
  1142. goto disable_per_clk;
  1143. err = clk_prepare_enable(imx_data->clk_ahb);
  1144. if (err)
  1145. goto disable_ipg_clk;
  1146. imx_data->pinctrl = devm_pinctrl_get(&pdev->dev);
  1147. if (IS_ERR(imx_data->pinctrl)) {
  1148. err = PTR_ERR(imx_data->pinctrl);
  1149. goto disable_ahb_clk;
  1150. }
  1151. imx_data->pins_default = pinctrl_lookup_state(imx_data->pinctrl,
  1152. PINCTRL_STATE_DEFAULT);
  1153. if (IS_ERR(imx_data->pins_default))
  1154. dev_warn(mmc_dev(host->mmc), "could not get default state\n");
  1155. if (esdhc_is_usdhc(imx_data)) {
  1156. host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN;
  1157. host->mmc->caps |= MMC_CAP_1_8V_DDR;
  1158. if (!(imx_data->socdata->flags & ESDHC_FLAG_HS200))
  1159. host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;
  1160. /* clear tuning bits in case ROM has set it already */
  1161. writel(0x0, host->ioaddr + ESDHC_MIX_CTRL);
  1162. writel(0x0, host->ioaddr + SDHCI_ACMD12_ERR);
  1163. writel(0x0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
  1164. }
  1165. if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
  1166. sdhci_esdhc_ops.platform_execute_tuning =
  1167. esdhc_executing_tuning;
  1168. if (imx_data->socdata->flags & ESDHC_FLAG_ERR004536)
  1169. host->quirks |= SDHCI_QUIRK_BROKEN_ADMA;
  1170. if (imx_data->socdata->flags & ESDHC_FLAG_HS400)
  1171. host->quirks2 |= SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400;
  1172. if (of_id)
  1173. err = sdhci_esdhc_imx_probe_dt(pdev, host, imx_data);
  1174. else
  1175. err = sdhci_esdhc_imx_probe_nondt(pdev, host, imx_data);
  1176. if (err)
  1177. goto disable_ahb_clk;
  1178. sdhci_esdhc_imx_hwinit(host);
  1179. err = sdhci_add_host(host);
  1180. if (err)
  1181. goto disable_ahb_clk;
  1182. pm_runtime_set_active(&pdev->dev);
  1183. pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
  1184. pm_runtime_use_autosuspend(&pdev->dev);
  1185. pm_suspend_ignore_children(&pdev->dev, 1);
  1186. pm_runtime_enable(&pdev->dev);
  1187. return 0;
  1188. disable_ahb_clk:
  1189. clk_disable_unprepare(imx_data->clk_ahb);
  1190. disable_ipg_clk:
  1191. clk_disable_unprepare(imx_data->clk_ipg);
  1192. disable_per_clk:
  1193. clk_disable_unprepare(imx_data->clk_per);
  1194. free_sdhci:
  1195. sdhci_pltfm_free(pdev);
  1196. return err;
  1197. }
  1198. static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
  1199. {
  1200. struct sdhci_host *host = platform_get_drvdata(pdev);
  1201. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  1202. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  1203. int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
  1204. pm_runtime_get_sync(&pdev->dev);
  1205. pm_runtime_disable(&pdev->dev);
  1206. pm_runtime_put_noidle(&pdev->dev);
  1207. sdhci_remove_host(host, dead);
  1208. clk_disable_unprepare(imx_data->clk_per);
  1209. clk_disable_unprepare(imx_data->clk_ipg);
  1210. clk_disable_unprepare(imx_data->clk_ahb);
  1211. sdhci_pltfm_free(pdev);
  1212. return 0;
  1213. }
  1214. #ifdef CONFIG_PM_SLEEP
  1215. static int sdhci_esdhc_suspend(struct device *dev)
  1216. {
  1217. struct sdhci_host *host = dev_get_drvdata(dev);
  1218. if (host->tuning_mode != SDHCI_TUNING_MODE_3)
  1219. mmc_retune_needed(host->mmc);
  1220. return sdhci_suspend_host(host);
  1221. }
  1222. static int sdhci_esdhc_resume(struct device *dev)
  1223. {
  1224. struct sdhci_host *host = dev_get_drvdata(dev);
  1225. /* re-initialize hw state in case it's lost in low power mode */
  1226. sdhci_esdhc_imx_hwinit(host);
  1227. return sdhci_resume_host(host);
  1228. }
  1229. #endif
  1230. #ifdef CONFIG_PM
  1231. static int sdhci_esdhc_runtime_suspend(struct device *dev)
  1232. {
  1233. struct sdhci_host *host = dev_get_drvdata(dev);
  1234. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  1235. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  1236. int ret;
  1237. ret = sdhci_runtime_suspend_host(host);
  1238. if (ret)
  1239. return ret;
  1240. if (host->tuning_mode != SDHCI_TUNING_MODE_3)
  1241. mmc_retune_needed(host->mmc);
  1242. if (!sdhci_sdio_irq_enabled(host)) {
  1243. imx_data->actual_clock = host->mmc->actual_clock;
  1244. esdhc_pltfm_set_clock(host, 0);
  1245. clk_disable_unprepare(imx_data->clk_per);
  1246. clk_disable_unprepare(imx_data->clk_ipg);
  1247. }
  1248. clk_disable_unprepare(imx_data->clk_ahb);
  1249. return ret;
  1250. }
  1251. static int sdhci_esdhc_runtime_resume(struct device *dev)
  1252. {
  1253. struct sdhci_host *host = dev_get_drvdata(dev);
  1254. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  1255. struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
  1256. int err;
  1257. err = clk_prepare_enable(imx_data->clk_ahb);
  1258. if (err)
  1259. return err;
  1260. if (!sdhci_sdio_irq_enabled(host)) {
  1261. err = clk_prepare_enable(imx_data->clk_per);
  1262. if (err)
  1263. goto disable_ahb_clk;
  1264. err = clk_prepare_enable(imx_data->clk_ipg);
  1265. if (err)
  1266. goto disable_per_clk;
  1267. esdhc_pltfm_set_clock(host, imx_data->actual_clock);
  1268. }
  1269. err = sdhci_runtime_resume_host(host);
  1270. if (err)
  1271. goto disable_ipg_clk;
  1272. return 0;
  1273. disable_ipg_clk:
  1274. if (!sdhci_sdio_irq_enabled(host))
  1275. clk_disable_unprepare(imx_data->clk_ipg);
  1276. disable_per_clk:
  1277. if (!sdhci_sdio_irq_enabled(host))
  1278. clk_disable_unprepare(imx_data->clk_per);
  1279. disable_ahb_clk:
  1280. clk_disable_unprepare(imx_data->clk_ahb);
  1281. return err;
  1282. }
  1283. #endif
  1284. static const struct dev_pm_ops sdhci_esdhc_pmops = {
  1285. SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
  1286. SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
  1287. sdhci_esdhc_runtime_resume, NULL)
  1288. };
  1289. static struct platform_driver sdhci_esdhc_imx_driver = {
  1290. .driver = {
  1291. .name = "sdhci-esdhc-imx",
  1292. .of_match_table = imx_esdhc_dt_ids,
  1293. .pm = &sdhci_esdhc_pmops,
  1294. },
  1295. .id_table = imx_esdhc_devtype,
  1296. .probe = sdhci_esdhc_imx_probe,
  1297. .remove = sdhci_esdhc_imx_remove,
  1298. };
  1299. module_platform_driver(sdhci_esdhc_imx_driver);
  1300. MODULE_DESCRIPTION("SDHCI driver for Freescale i.MX eSDHC");
  1301. MODULE_AUTHOR("Wolfram Sang <kernel@pengutronix.de>");
  1302. MODULE_LICENSE("GPL v2");