Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 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 <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 Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 18 | #include <linux/gpio.h> |
Shawn Guo | 66506f7 | 2011-08-15 10:28:18 +0800 | [diff] [blame] | 19 | #include <linux/module.h> |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 20 | #include <linux/slab.h> |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 21 | #include <linux/mmc/host.h> |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 22 | #include <linux/mmc/mmc.h> |
| 23 | #include <linux/mmc/sdio.h> |
Shawn Guo | fbe5fdd | 2012-12-11 22:32:20 +0800 | [diff] [blame] | 24 | #include <linux/mmc/slot-gpio.h> |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 25 | #include <linux/of.h> |
| 26 | #include <linux/of_device.h> |
| 27 | #include <linux/of_gpio.h> |
Dong Aisheng | e62d8b8 | 2012-05-11 14:56:01 +0800 | [diff] [blame] | 28 | #include <linux/pinctrl/consumer.h> |
Arnd Bergmann | 82906b1 | 2012-08-24 15:14:29 +0200 | [diff] [blame] | 29 | #include <linux/platform_data/mmc-esdhc-imx.h> |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 30 | #include "sdhci-pltfm.h" |
| 31 | #include "sdhci-esdhc.h" |
| 32 | |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 33 | #define ESDHC_CTRL_D3CD 0x08 |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 34 | /* VENDOR SPEC register */ |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 35 | #define ESDHC_VENDOR_SPEC 0xc0 |
| 36 | #define ESDHC_VENDOR_SPEC_SDIO_QUIRK (1 << 1) |
| 37 | #define ESDHC_WTMK_LVL 0x44 |
| 38 | #define ESDHC_MIX_CTRL 0x48 |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 39 | |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 40 | /* |
Richard Zhu | 97e4ba6 | 2011-08-11 16:51:46 -0400 | [diff] [blame] | 41 | * There is an INT DMA ERR mis-match between eSDHC and STD SDHC SPEC: |
| 42 | * Bit25 is used in STD SPEC, and is reserved in fsl eSDHC design, |
| 43 | * but bit28 is used as the INT DMA ERR in fsl eSDHC design. |
| 44 | * Define this macro DMA error INT for fsl eSDHC |
| 45 | */ |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 46 | #define ESDHC_INT_VENDOR_SPEC_DMA_ERR (1 << 28) |
Richard Zhu | 97e4ba6 | 2011-08-11 16:51:46 -0400 | [diff] [blame] | 47 | |
| 48 | /* |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 49 | * The CMDTYPE of the CMD register (offset 0xE) should be set to |
| 50 | * "11" when the STOP CMD12 is issued on imx53 to abort one |
| 51 | * open ended multi-blk IO. Otherwise the TC INT wouldn't |
| 52 | * be generated. |
| 53 | * In exact block transfer, the controller doesn't complete the |
| 54 | * operations automatically as required at the end of the |
| 55 | * transfer and remains on hold if the abort command is not sent. |
| 56 | * As a result, the TC flag is not asserted and SW received timeout |
| 57 | * exeception. Bit1 of Vendor Spec registor is used to fix it. |
| 58 | */ |
| 59 | #define ESDHC_FLAG_MULTIBLK_NO_INT (1 << 1) |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 60 | |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 61 | enum imx_esdhc_type { |
| 62 | IMX25_ESDHC, |
| 63 | IMX35_ESDHC, |
| 64 | IMX51_ESDHC, |
| 65 | IMX53_ESDHC, |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 66 | IMX6Q_USDHC, |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 67 | }; |
| 68 | |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 69 | struct pltfm_imx_data { |
| 70 | int flags; |
| 71 | u32 scratchpad; |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 72 | enum imx_esdhc_type devtype; |
Dong Aisheng | e62d8b8 | 2012-05-11 14:56:01 +0800 | [diff] [blame] | 73 | struct pinctrl *pinctrl; |
Shawn Guo | 842afc0 | 2011-07-06 22:57:48 +0800 | [diff] [blame] | 74 | struct esdhc_platform_data boarddata; |
Sascha Hauer | 52dac61 | 2012-03-07 09:31:34 +0100 | [diff] [blame] | 75 | struct clk *clk_ipg; |
| 76 | struct clk *clk_ahb; |
| 77 | struct clk *clk_per; |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 78 | }; |
| 79 | |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 80 | static struct platform_device_id imx_esdhc_devtype[] = { |
| 81 | { |
| 82 | .name = "sdhci-esdhc-imx25", |
| 83 | .driver_data = IMX25_ESDHC, |
| 84 | }, { |
| 85 | .name = "sdhci-esdhc-imx35", |
| 86 | .driver_data = IMX35_ESDHC, |
| 87 | }, { |
| 88 | .name = "sdhci-esdhc-imx51", |
| 89 | .driver_data = IMX51_ESDHC, |
| 90 | }, { |
| 91 | .name = "sdhci-esdhc-imx53", |
| 92 | .driver_data = IMX53_ESDHC, |
| 93 | }, { |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 94 | .name = "sdhci-usdhc-imx6q", |
| 95 | .driver_data = IMX6Q_USDHC, |
| 96 | }, { |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 97 | /* sentinel */ |
| 98 | } |
| 99 | }; |
| 100 | MODULE_DEVICE_TABLE(platform, imx_esdhc_devtype); |
| 101 | |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 102 | static const struct of_device_id imx_esdhc_dt_ids[] = { |
| 103 | { .compatible = "fsl,imx25-esdhc", .data = &imx_esdhc_devtype[IMX25_ESDHC], }, |
| 104 | { .compatible = "fsl,imx35-esdhc", .data = &imx_esdhc_devtype[IMX35_ESDHC], }, |
| 105 | { .compatible = "fsl,imx51-esdhc", .data = &imx_esdhc_devtype[IMX51_ESDHC], }, |
| 106 | { .compatible = "fsl,imx53-esdhc", .data = &imx_esdhc_devtype[IMX53_ESDHC], }, |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 107 | { .compatible = "fsl,imx6q-usdhc", .data = &imx_esdhc_devtype[IMX6Q_USDHC], }, |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 108 | { /* sentinel */ } |
| 109 | }; |
| 110 | MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids); |
| 111 | |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 112 | static inline int is_imx25_esdhc(struct pltfm_imx_data *data) |
| 113 | { |
| 114 | return data->devtype == IMX25_ESDHC; |
| 115 | } |
| 116 | |
| 117 | static inline int is_imx35_esdhc(struct pltfm_imx_data *data) |
| 118 | { |
| 119 | return data->devtype == IMX35_ESDHC; |
| 120 | } |
| 121 | |
| 122 | static inline int is_imx51_esdhc(struct pltfm_imx_data *data) |
| 123 | { |
| 124 | return data->devtype == IMX51_ESDHC; |
| 125 | } |
| 126 | |
| 127 | static inline int is_imx53_esdhc(struct pltfm_imx_data *data) |
| 128 | { |
| 129 | return data->devtype == IMX53_ESDHC; |
| 130 | } |
| 131 | |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 132 | static inline int is_imx6q_usdhc(struct pltfm_imx_data *data) |
| 133 | { |
| 134 | return data->devtype == IMX6Q_USDHC; |
| 135 | } |
| 136 | |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 137 | static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg) |
| 138 | { |
| 139 | void __iomem *base = host->ioaddr + (reg & ~0x3); |
| 140 | u32 shift = (reg & 0x3) * 8; |
| 141 | |
| 142 | writel(((readl(base) & ~(mask << shift)) | (val << shift)), base); |
| 143 | } |
| 144 | |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 145 | static u32 esdhc_readl_le(struct sdhci_host *host, int reg) |
| 146 | { |
Shawn Guo | 842afc0 | 2011-07-06 22:57:48 +0800 | [diff] [blame] | 147 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 148 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
| 149 | struct esdhc_platform_data *boarddata = &imx_data->boarddata; |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 150 | |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 151 | u32 val = readl(host->ioaddr + reg); |
| 152 | |
Richard Zhu | 97e4ba6 | 2011-08-11 16:51:46 -0400 | [diff] [blame] | 153 | if (unlikely(reg == SDHCI_CAPABILITIES)) { |
| 154 | /* In FSL esdhc IC module, only bit20 is used to indicate the |
| 155 | * ADMA2 capability of esdhc, but this bit is messed up on |
| 156 | * some SOCs (e.g. on MX25, MX35 this bit is set, but they |
| 157 | * don't actually support ADMA2). So set the BROKEN_ADMA |
| 158 | * uirk on MX25/35 platforms. |
| 159 | */ |
| 160 | |
| 161 | if (val & SDHCI_CAN_DO_ADMA1) { |
| 162 | val &= ~SDHCI_CAN_DO_ADMA1; |
| 163 | val |= SDHCI_CAN_DO_ADMA2; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if (unlikely(reg == SDHCI_INT_STATUS)) { |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 168 | if (val & ESDHC_INT_VENDOR_SPEC_DMA_ERR) { |
| 169 | val &= ~ESDHC_INT_VENDOR_SPEC_DMA_ERR; |
Richard Zhu | 97e4ba6 | 2011-08-11 16:51:46 -0400 | [diff] [blame] | 170 | val |= SDHCI_INT_ADMA_ERROR; |
| 171 | } |
| 172 | } |
| 173 | |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 174 | return val; |
| 175 | } |
| 176 | |
| 177 | static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) |
| 178 | { |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 179 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 180 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
Shawn Guo | 842afc0 | 2011-07-06 22:57:48 +0800 | [diff] [blame] | 181 | struct esdhc_platform_data *boarddata = &imx_data->boarddata; |
Tony Lin | 0d58864 | 2011-08-11 16:45:59 -0400 | [diff] [blame] | 182 | u32 data; |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 183 | |
Tony Lin | 0d58864 | 2011-08-11 16:45:59 -0400 | [diff] [blame] | 184 | if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) { |
Tony Lin | 0d58864 | 2011-08-11 16:45:59 -0400 | [diff] [blame] | 185 | if (val & SDHCI_INT_CARD_INT) { |
| 186 | /* |
| 187 | * Clear and then set D3CD bit to avoid missing the |
| 188 | * card interrupt. This is a eSDHC controller problem |
| 189 | * so we need to apply the following workaround: clear |
| 190 | * and set D3CD bit will make eSDHC re-sample the card |
| 191 | * interrupt. In case a card interrupt was lost, |
| 192 | * re-sample it by the following steps. |
| 193 | */ |
| 194 | data = readl(host->ioaddr + SDHCI_HOST_CONTROL); |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 195 | data &= ~ESDHC_CTRL_D3CD; |
Tony Lin | 0d58864 | 2011-08-11 16:45:59 -0400 | [diff] [blame] | 196 | writel(data, host->ioaddr + SDHCI_HOST_CONTROL); |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 197 | data |= ESDHC_CTRL_D3CD; |
Tony Lin | 0d58864 | 2011-08-11 16:45:59 -0400 | [diff] [blame] | 198 | writel(data, host->ioaddr + SDHCI_HOST_CONTROL); |
| 199 | } |
| 200 | } |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 201 | |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 202 | if (unlikely((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT) |
| 203 | && (reg == SDHCI_INT_STATUS) |
| 204 | && (val & SDHCI_INT_DATA_END))) { |
| 205 | u32 v; |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 206 | v = readl(host->ioaddr + ESDHC_VENDOR_SPEC); |
| 207 | v &= ~ESDHC_VENDOR_SPEC_SDIO_QUIRK; |
| 208 | writel(v, host->ioaddr + ESDHC_VENDOR_SPEC); |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 209 | } |
| 210 | |
Richard Zhu | 97e4ba6 | 2011-08-11 16:51:46 -0400 | [diff] [blame] | 211 | if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) { |
| 212 | if (val & SDHCI_INT_ADMA_ERROR) { |
| 213 | val &= ~SDHCI_INT_ADMA_ERROR; |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 214 | val |= ESDHC_INT_VENDOR_SPEC_DMA_ERR; |
Richard Zhu | 97e4ba6 | 2011-08-11 16:51:46 -0400 | [diff] [blame] | 215 | } |
| 216 | } |
| 217 | |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 218 | writel(val, host->ioaddr + reg); |
| 219 | } |
| 220 | |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 221 | static u16 esdhc_readw_le(struct sdhci_host *host, int reg) |
| 222 | { |
Shawn Guo | ef4d088 | 2013-01-15 23:30:27 +0800 | [diff] [blame] | 223 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 224 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
| 225 | |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 226 | if (unlikely(reg == SDHCI_HOST_VERSION)) { |
Shawn Guo | ef4d088 | 2013-01-15 23:30:27 +0800 | [diff] [blame] | 227 | reg ^= 2; |
| 228 | if (is_imx6q_usdhc(imx_data)) { |
| 229 | /* |
| 230 | * The usdhc register returns a wrong host version. |
| 231 | * Correct it here. |
| 232 | */ |
| 233 | return SDHCI_SPEC_300; |
| 234 | } |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 235 | } |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 236 | |
| 237 | return readw(host->ioaddr + reg); |
| 238 | } |
| 239 | |
| 240 | static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) |
| 241 | { |
| 242 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 243 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 244 | |
| 245 | switch (reg) { |
| 246 | case SDHCI_TRANSFER_MODE: |
| 247 | /* |
| 248 | * Postpone this write, we must do it together with a |
| 249 | * command write that is down below. |
| 250 | */ |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 251 | if ((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT) |
| 252 | && (host->cmd->opcode == SD_IO_RW_EXTENDED) |
| 253 | && (host->cmd->data->blocks > 1) |
| 254 | && (host->cmd->data->flags & MMC_DATA_READ)) { |
| 255 | u32 v; |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 256 | v = readl(host->ioaddr + ESDHC_VENDOR_SPEC); |
| 257 | v |= ESDHC_VENDOR_SPEC_SDIO_QUIRK; |
| 258 | writel(v, host->ioaddr + ESDHC_VENDOR_SPEC); |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 259 | } |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 260 | imx_data->scratchpad = val; |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 261 | return; |
| 262 | case SDHCI_COMMAND: |
Sascha Hauer | 5b6b0ad | 2012-02-17 11:51:49 +0100 | [diff] [blame] | 263 | if ((host->cmd->opcode == MMC_STOP_TRANSMISSION || |
| 264 | host->cmd->opcode == MMC_SET_BLOCK_COUNT) && |
| 265 | (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)) |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 266 | val |= SDHCI_CMD_ABORTCMD; |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 267 | |
| 268 | if (is_imx6q_usdhc(imx_data)) { |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 269 | u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL); |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 270 | m = imx_data->scratchpad | (m & 0xffff0000); |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 271 | writel(m, host->ioaddr + ESDHC_MIX_CTRL); |
Shawn Guo | 95a2482 | 2011-09-19 17:32:21 +0800 | [diff] [blame] | 272 | writel(val << 16, |
| 273 | host->ioaddr + SDHCI_TRANSFER_MODE); |
| 274 | } else { |
| 275 | writel(val << 16 | imx_data->scratchpad, |
| 276 | host->ioaddr + SDHCI_TRANSFER_MODE); |
| 277 | } |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 278 | return; |
| 279 | case SDHCI_BLOCK_SIZE: |
| 280 | val &= ~SDHCI_MAKE_BLKSZ(0x7, 0); |
| 281 | break; |
| 282 | } |
| 283 | esdhc_clrset_le(host, 0xffff, val, reg); |
| 284 | } |
| 285 | |
| 286 | static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg) |
| 287 | { |
Wilson Callan | 9a0985b | 2012-07-19 02:49:16 -0400 | [diff] [blame] | 288 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 289 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 290 | u32 new_val; |
| 291 | |
| 292 | switch (reg) { |
| 293 | case SDHCI_POWER_CONTROL: |
| 294 | /* |
| 295 | * FSL put some DMA bits here |
| 296 | * If your board has a regulator, code should be here |
| 297 | */ |
| 298 | return; |
| 299 | case SDHCI_HOST_CONTROL: |
Shawn Guo | 6b40d18 | 2013-01-15 23:36:52 +0800 | [diff] [blame] | 300 | /* FSL messed up here, so we need to manually compose it. */ |
| 301 | new_val = val & (SDHCI_CTRL_LED | SDHCI_CTRL_4BITBUS); |
Masanari Iida | 7122bbb | 2012-08-05 23:25:40 +0900 | [diff] [blame] | 302 | /* ensure the endianness */ |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 303 | new_val |= ESDHC_HOST_CONTROL_LE; |
Wilson Callan | 9a0985b | 2012-07-19 02:49:16 -0400 | [diff] [blame] | 304 | /* bits 8&9 are reserved on mx25 */ |
| 305 | if (!is_imx25_esdhc(imx_data)) { |
| 306 | /* DMA mode bits are shifted */ |
| 307 | new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5; |
| 308 | } |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 309 | |
| 310 | esdhc_clrset_le(host, 0xffff, new_val, reg); |
| 311 | return; |
| 312 | } |
| 313 | esdhc_clrset_le(host, 0xff, val, reg); |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 314 | |
| 315 | /* |
| 316 | * The esdhc has a design violation to SDHC spec which tells |
| 317 | * that software reset should not affect card detection circuit. |
| 318 | * But esdhc clears its SYSCTL register bits [0..2] during the |
| 319 | * software reset. This will stop those clocks that card detection |
| 320 | * circuit relies on. To work around it, we turn the clocks on back |
| 321 | * to keep card detection circuit functional. |
| 322 | */ |
| 323 | if ((reg == SDHCI_SOFTWARE_RESET) && (val & 1)) |
| 324 | esdhc_clrset_le(host, 0x7, 0x7, ESDHC_SYSTEM_CONTROL); |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host) |
| 328 | { |
| 329 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 330 | |
| 331 | return clk_get_rate(pltfm_host->clk); |
| 332 | } |
| 333 | |
| 334 | static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host) |
| 335 | { |
| 336 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 337 | |
| 338 | return clk_get_rate(pltfm_host->clk) / 256 / 16; |
| 339 | } |
| 340 | |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 341 | static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host) |
| 342 | { |
Shawn Guo | 842afc0 | 2011-07-06 22:57:48 +0800 | [diff] [blame] | 343 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 344 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
| 345 | struct esdhc_platform_data *boarddata = &imx_data->boarddata; |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 346 | |
| 347 | switch (boarddata->wp_type) { |
| 348 | case ESDHC_WP_GPIO: |
Shawn Guo | fbe5fdd | 2012-12-11 22:32:20 +0800 | [diff] [blame] | 349 | return mmc_gpio_get_ro(host->mmc); |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 350 | case ESDHC_WP_CONTROLLER: |
| 351 | return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) & |
| 352 | SDHCI_WRITE_PROTECT); |
| 353 | case ESDHC_WP_NONE: |
| 354 | break; |
| 355 | } |
| 356 | |
| 357 | return -ENOSYS; |
| 358 | } |
| 359 | |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 360 | static struct sdhci_ops sdhci_esdhc_ops = { |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 361 | .read_l = esdhc_readl_le, |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 362 | .read_w = esdhc_readw_le, |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 363 | .write_l = esdhc_writel_le, |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 364 | .write_w = esdhc_writew_le, |
| 365 | .write_b = esdhc_writeb_le, |
| 366 | .set_clock = esdhc_set_clock, |
| 367 | .get_max_clock = esdhc_pltfm_get_max_clock, |
| 368 | .get_min_clock = esdhc_pltfm_get_min_clock, |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 369 | .get_ro = esdhc_pltfm_get_ro, |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 370 | }; |
| 371 | |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 372 | static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { |
Richard Zhu | 97e4ba6 | 2011-08-11 16:51:46 -0400 | [diff] [blame] | 373 | .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_HISPD_BIT |
| 374 | | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC |
| 375 | | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 376 | | SDHCI_QUIRK_BROKEN_CARD_DETECTION, |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 377 | .ops = &sdhci_esdhc_ops, |
| 378 | }; |
| 379 | |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 380 | #ifdef CONFIG_OF |
Bill Pemberton | c3be1ef | 2012-11-19 13:23:06 -0500 | [diff] [blame] | 381 | static int |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 382 | sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, |
| 383 | struct esdhc_platform_data *boarddata) |
| 384 | { |
| 385 | struct device_node *np = pdev->dev.of_node; |
| 386 | |
| 387 | if (!np) |
| 388 | return -ENODEV; |
| 389 | |
Arnd Bergmann | 7f21779 | 2012-05-13 00:14:24 -0400 | [diff] [blame] | 390 | if (of_get_property(np, "non-removable", NULL)) |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 391 | boarddata->cd_type = ESDHC_CD_PERMANENT; |
| 392 | |
| 393 | if (of_get_property(np, "fsl,cd-controller", NULL)) |
| 394 | boarddata->cd_type = ESDHC_CD_CONTROLLER; |
| 395 | |
| 396 | if (of_get_property(np, "fsl,wp-controller", NULL)) |
| 397 | boarddata->wp_type = ESDHC_WP_CONTROLLER; |
| 398 | |
| 399 | boarddata->cd_gpio = of_get_named_gpio(np, "cd-gpios", 0); |
| 400 | if (gpio_is_valid(boarddata->cd_gpio)) |
| 401 | boarddata->cd_type = ESDHC_CD_GPIO; |
| 402 | |
| 403 | boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0); |
| 404 | if (gpio_is_valid(boarddata->wp_gpio)) |
| 405 | boarddata->wp_type = ESDHC_WP_GPIO; |
| 406 | |
| 407 | return 0; |
| 408 | } |
| 409 | #else |
| 410 | static inline int |
| 411 | sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, |
| 412 | struct esdhc_platform_data *boarddata) |
| 413 | { |
| 414 | return -ENODEV; |
| 415 | } |
| 416 | #endif |
| 417 | |
Bill Pemberton | c3be1ef | 2012-11-19 13:23:06 -0500 | [diff] [blame] | 418 | static int sdhci_esdhc_imx_probe(struct platform_device *pdev) |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 419 | { |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 420 | const struct of_device_id *of_id = |
| 421 | of_match_device(imx_esdhc_dt_ids, &pdev->dev); |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 422 | struct sdhci_pltfm_host *pltfm_host; |
| 423 | struct sdhci_host *host; |
| 424 | struct esdhc_platform_data *boarddata; |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 425 | int err; |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 426 | struct pltfm_imx_data *imx_data; |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 427 | |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 428 | host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata); |
| 429 | if (IS_ERR(host)) |
| 430 | return PTR_ERR(host); |
| 431 | |
| 432 | pltfm_host = sdhci_priv(host); |
| 433 | |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 434 | imx_data = devm_kzalloc(&pdev->dev, sizeof(*imx_data), GFP_KERNEL); |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 435 | if (!imx_data) { |
| 436 | err = -ENOMEM; |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 437 | goto free_sdhci; |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 438 | } |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 439 | |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 440 | if (of_id) |
| 441 | pdev->id_entry = of_id->data; |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 442 | imx_data->devtype = pdev->id_entry->driver_data; |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 443 | pltfm_host->priv = imx_data; |
| 444 | |
Sascha Hauer | 52dac61 | 2012-03-07 09:31:34 +0100 | [diff] [blame] | 445 | imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); |
| 446 | if (IS_ERR(imx_data->clk_ipg)) { |
| 447 | err = PTR_ERR(imx_data->clk_ipg); |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 448 | goto free_sdhci; |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 449 | } |
Sascha Hauer | 52dac61 | 2012-03-07 09:31:34 +0100 | [diff] [blame] | 450 | |
| 451 | imx_data->clk_ahb = devm_clk_get(&pdev->dev, "ahb"); |
| 452 | if (IS_ERR(imx_data->clk_ahb)) { |
| 453 | err = PTR_ERR(imx_data->clk_ahb); |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 454 | goto free_sdhci; |
Sascha Hauer | 52dac61 | 2012-03-07 09:31:34 +0100 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | imx_data->clk_per = devm_clk_get(&pdev->dev, "per"); |
| 458 | if (IS_ERR(imx_data->clk_per)) { |
| 459 | err = PTR_ERR(imx_data->clk_per); |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 460 | goto free_sdhci; |
Sascha Hauer | 52dac61 | 2012-03-07 09:31:34 +0100 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | pltfm_host->clk = imx_data->clk_per; |
| 464 | |
| 465 | clk_prepare_enable(imx_data->clk_per); |
| 466 | clk_prepare_enable(imx_data->clk_ipg); |
| 467 | clk_prepare_enable(imx_data->clk_ahb); |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 468 | |
Dong Aisheng | e62d8b8 | 2012-05-11 14:56:01 +0800 | [diff] [blame] | 469 | imx_data->pinctrl = devm_pinctrl_get_select_default(&pdev->dev); |
| 470 | if (IS_ERR(imx_data->pinctrl)) { |
| 471 | err = PTR_ERR(imx_data->pinctrl); |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 472 | goto disable_clk; |
Dong Aisheng | e62d8b8 | 2012-05-11 14:56:01 +0800 | [diff] [blame] | 473 | } |
| 474 | |
Eric BĂ©nard | b8915282 | 2012-04-18 02:30:20 +0200 | [diff] [blame] | 475 | host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; |
Eric BĂ©nard | 37865fe | 2010-10-23 01:57:21 +0200 | [diff] [blame] | 476 | |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 477 | if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data)) |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 478 | /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */ |
Richard Zhu | 97e4ba6 | 2011-08-11 16:51:46 -0400 | [diff] [blame] | 479 | host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK |
| 480 | | SDHCI_QUIRK_BROKEN_ADMA; |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 481 | |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 482 | if (is_imx53_esdhc(imx_data)) |
Richard Zhu | 58ac817 | 2011-03-21 13:22:16 +0800 | [diff] [blame] | 483 | imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT; |
| 484 | |
Shawn Guo | f750ba9 | 2011-11-10 16:39:32 +0800 | [diff] [blame] | 485 | /* |
| 486 | * The imx6q ROM code will change the default watermark level setting |
| 487 | * to something insane. Change it back here. |
| 488 | */ |
| 489 | if (is_imx6q_usdhc(imx_data)) |
Shawn Guo | 60bf639 | 2013-01-15 23:36:53 +0800 | [diff] [blame^] | 490 | writel(0x08100810, host->ioaddr + ESDHC_WTMK_LVL); |
Shawn Guo | f750ba9 | 2011-11-10 16:39:32 +0800 | [diff] [blame] | 491 | |
Shawn Guo | 842afc0 | 2011-07-06 22:57:48 +0800 | [diff] [blame] | 492 | boarddata = &imx_data->boarddata; |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 493 | if (sdhci_esdhc_imx_probe_dt(pdev, boarddata) < 0) { |
| 494 | if (!host->mmc->parent->platform_data) { |
| 495 | dev_err(mmc_dev(host->mmc), "no board data!\n"); |
| 496 | err = -EINVAL; |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 497 | goto disable_clk; |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 498 | } |
| 499 | imx_data->boarddata = *((struct esdhc_platform_data *) |
| 500 | host->mmc->parent->platform_data); |
| 501 | } |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 502 | |
| 503 | /* write_protect */ |
| 504 | if (boarddata->wp_type == ESDHC_WP_GPIO) { |
Shawn Guo | fbe5fdd | 2012-12-11 22:32:20 +0800 | [diff] [blame] | 505 | err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio); |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 506 | if (err) { |
Shawn Guo | fbe5fdd | 2012-12-11 22:32:20 +0800 | [diff] [blame] | 507 | dev_err(mmc_dev(host->mmc), |
| 508 | "failed to request write-protect gpio!\n"); |
| 509 | goto disable_clk; |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 510 | } |
Shawn Guo | fbe5fdd | 2012-12-11 22:32:20 +0800 | [diff] [blame] | 511 | host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 512 | } |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 513 | |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 514 | /* card_detect */ |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 515 | switch (boarddata->cd_type) { |
| 516 | case ESDHC_CD_GPIO: |
Shawn Guo | fbe5fdd | 2012-12-11 22:32:20 +0800 | [diff] [blame] | 517 | err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio); |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 518 | if (err) { |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 519 | dev_err(mmc_dev(host->mmc), |
Shawn Guo | fbe5fdd | 2012-12-11 22:32:20 +0800 | [diff] [blame] | 520 | "failed to request card-detect gpio!\n"); |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 521 | goto disable_clk; |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 522 | } |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 523 | /* fall through */ |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 524 | |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 525 | case ESDHC_CD_CONTROLLER: |
| 526 | /* we have a working card_detect back */ |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 527 | host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; |
Shawn Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 528 | break; |
| 529 | |
| 530 | case ESDHC_CD_PERMANENT: |
| 531 | host->mmc->caps = MMC_CAP_NONREMOVABLE; |
| 532 | break; |
| 533 | |
| 534 | case ESDHC_CD_NONE: |
| 535 | break; |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 536 | } |
Eric BĂ©nard | 16a790b | 2010-10-23 01:57:22 +0200 | [diff] [blame] | 537 | |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 538 | err = sdhci_add_host(host); |
| 539 | if (err) |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 540 | goto disable_clk; |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 541 | |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 542 | return 0; |
Wolfram Sang | 7e29c30 | 2011-02-26 14:44:41 +0100 | [diff] [blame] | 543 | |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 544 | disable_clk: |
Sascha Hauer | 52dac61 | 2012-03-07 09:31:34 +0100 | [diff] [blame] | 545 | clk_disable_unprepare(imx_data->clk_per); |
| 546 | clk_disable_unprepare(imx_data->clk_ipg); |
| 547 | clk_disable_unprepare(imx_data->clk_ahb); |
Shawn Guo | e3af31c | 2012-11-26 14:39:43 +0800 | [diff] [blame] | 548 | free_sdhci: |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 549 | sdhci_pltfm_free(pdev); |
| 550 | return err; |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 551 | } |
| 552 | |
Bill Pemberton | 6e0ee71 | 2012-11-19 13:26:03 -0500 | [diff] [blame] | 553 | static int sdhci_esdhc_imx_remove(struct platform_device *pdev) |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 554 | { |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 555 | struct sdhci_host *host = platform_get_drvdata(pdev); |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 556 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
Richard Zhu | e149860 | 2011-03-25 09:18:27 -0400 | [diff] [blame] | 557 | struct pltfm_imx_data *imx_data = pltfm_host->priv; |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 558 | int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); |
| 559 | |
| 560 | sdhci_remove_host(host, dead); |
Wolfram Sang | 0c6d49c | 2011-02-26 14:44:39 +0100 | [diff] [blame] | 561 | |
Sascha Hauer | 52dac61 | 2012-03-07 09:31:34 +0100 | [diff] [blame] | 562 | clk_disable_unprepare(imx_data->clk_per); |
| 563 | clk_disable_unprepare(imx_data->clk_ipg); |
| 564 | clk_disable_unprepare(imx_data->clk_ahb); |
| 565 | |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 566 | sdhci_pltfm_free(pdev); |
| 567 | |
| 568 | return 0; |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 569 | } |
| 570 | |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 571 | static struct platform_driver sdhci_esdhc_imx_driver = { |
| 572 | .driver = { |
| 573 | .name = "sdhci-esdhc-imx", |
| 574 | .owner = THIS_MODULE, |
Shawn Guo | abfafc2 | 2011-06-30 15:44:44 +0800 | [diff] [blame] | 575 | .of_match_table = imx_esdhc_dt_ids, |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 576 | .pm = SDHCI_PLTFM_PMOPS, |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 577 | }, |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 578 | .id_table = imx_esdhc_devtype, |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 579 | .probe = sdhci_esdhc_imx_probe, |
Bill Pemberton | 0433c14 | 2012-11-19 13:20:26 -0500 | [diff] [blame] | 580 | .remove = sdhci_esdhc_imx_remove, |
Wolfram Sang | 95f25ef | 2010-10-15 12:21:04 +0200 | [diff] [blame] | 581 | }; |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 582 | |
Axel Lin | d1f81a6 | 2011-11-26 12:55:43 +0800 | [diff] [blame] | 583 | module_platform_driver(sdhci_esdhc_imx_driver); |
Shawn Guo | 85d6509 | 2011-05-27 23:48:12 +0800 | [diff] [blame] | 584 | |
| 585 | MODULE_DESCRIPTION("SDHCI driver for Freescale i.MX eSDHC"); |
| 586 | MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>"); |
| 587 | MODULE_LICENSE("GPL v2"); |