blob: ff99b632808dc136844d84852f5f87b6b824bd00 [file] [log] [blame]
Olof Johansson03d2bfc2011-01-01 23:52:56 -05001/*
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include <linux/err.h>
Paul Gortmaker96547f52011-07-03 15:15:51 -040016#include <linux/module.h>
Olof Johansson03d2bfc2011-01-01 23:52:56 -050017#include <linux/init.h>
18#include <linux/platform_device.h>
19#include <linux/clk.h>
20#include <linux/io.h>
Stephen Warren55cd65e2011-08-30 13:17:16 -060021#include <linux/of.h>
Stephen Warren3e44a1a2012-02-01 16:30:55 -070022#include <linux/of_device.h>
Grant Likely275173b2011-08-23 12:15:33 -060023#include <linux/of_gpio.h>
Olof Johansson03d2bfc2011-01-01 23:52:56 -050024#include <linux/gpio.h>
25#include <linux/mmc/card.h>
26#include <linux/mmc/host.h>
27
Russell Kinge6b750d2011-07-26 10:59:32 +010028#include <asm/gpio.h>
Stephen Warrenea5abbd2011-09-26 19:00:02 +010029
Olof Johansson03d2bfc2011-01-01 23:52:56 -050030#include "sdhci-pltfm.h"
31
Pavan Kunapulica5879d2012-04-18 18:48:02 +053032/* Tegra SDHOST controller vendor register definitions */
33#define SDHCI_TEGRA_VENDOR_MISC_CTRL 0x120
34#define SDHCI_MISC_CTRL_ENABLE_SDHCI_SPEC_300 0x20
35
Stephen Warren3e44a1a2012-02-01 16:30:55 -070036#define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0)
37#define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1)
Pavan Kunapulica5879d2012-04-18 18:48:02 +053038#define NVQUIRK_ENABLE_SDHCI_SPEC_300 BIT(2)
Stephen Warren3e44a1a2012-02-01 16:30:55 -070039
40struct sdhci_tegra_soc_data {
41 struct sdhci_pltfm_data *pdata;
42 u32 nvquirks;
43};
44
45struct sdhci_tegra {
Stephen Warren3e44a1a2012-02-01 16:30:55 -070046 const struct sdhci_tegra_soc_data *soc_data;
Stephen Warren0e786102013-02-15 15:07:19 -070047 int cd_gpio;
48 int wp_gpio;
49 int power_gpio;
50 int is_8bit;
Stephen Warren3e44a1a2012-02-01 16:30:55 -070051};
52
Olof Johansson03d2bfc2011-01-01 23:52:56 -050053static u32 tegra_sdhci_readl(struct sdhci_host *host, int reg)
54{
55 u32 val;
56
57 if (unlikely(reg == SDHCI_PRESENT_STATE)) {
58 /* Use wp_gpio here instead? */
59 val = readl(host->ioaddr + reg);
60 return val | SDHCI_WRITE_PROTECT;
61 }
62
63 return readl(host->ioaddr + reg);
64}
65
66static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg)
67{
Stephen Warren3e44a1a2012-02-01 16:30:55 -070068 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
69 struct sdhci_tegra *tegra_host = pltfm_host->priv;
70 const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
71
72 if (unlikely((soc_data->nvquirks & NVQUIRK_FORCE_SDHCI_SPEC_200) &&
73 (reg == SDHCI_HOST_VERSION))) {
Olof Johansson03d2bfc2011-01-01 23:52:56 -050074 /* Erratum: Version register is invalid in HW. */
75 return SDHCI_SPEC_200;
76 }
77
78 return readw(host->ioaddr + reg);
79}
80
81static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg)
82{
Stephen Warren3e44a1a2012-02-01 16:30:55 -070083 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
84 struct sdhci_tegra *tegra_host = pltfm_host->priv;
85 const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
86
Olof Johansson03d2bfc2011-01-01 23:52:56 -050087 /* Seems like we're getting spurious timeout and crc errors, so
88 * disable signalling of them. In case of real errors software
89 * timers should take care of eventually detecting them.
90 */
91 if (unlikely(reg == SDHCI_SIGNAL_ENABLE))
92 val &= ~(SDHCI_INT_TIMEOUT|SDHCI_INT_CRC);
93
94 writel(val, host->ioaddr + reg);
95
Stephen Warren3e44a1a2012-02-01 16:30:55 -070096 if (unlikely((soc_data->nvquirks & NVQUIRK_ENABLE_BLOCK_GAP_DET) &&
97 (reg == SDHCI_INT_ENABLE))) {
Olof Johansson03d2bfc2011-01-01 23:52:56 -050098 /* Erratum: Must enable block gap interrupt detection */
99 u8 gap_ctrl = readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL);
100 if (val & SDHCI_INT_CARD_INT)
101 gap_ctrl |= 0x8;
102 else
103 gap_ctrl &= ~0x8;
104 writeb(gap_ctrl, host->ioaddr + SDHCI_BLOCK_GAP_CONTROL);
105 }
106}
107
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700108static unsigned int tegra_sdhci_get_ro(struct sdhci_host *host)
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500109{
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700110 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
111 struct sdhci_tegra *tegra_host = pltfm_host->priv;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500112
Stephen Warren0e786102013-02-15 15:07:19 -0700113 if (!gpio_is_valid(tegra_host->wp_gpio))
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500114 return -1;
115
Stephen Warren0e786102013-02-15 15:07:19 -0700116 return gpio_get_value(tegra_host->wp_gpio);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500117}
118
119static irqreturn_t carddetect_irq(int irq, void *data)
120{
121 struct sdhci_host *sdhost = (struct sdhci_host *)data;
122
123 tasklet_schedule(&sdhost->card_tasklet);
124 return IRQ_HANDLED;
125};
126
Pavan Kunapulica5879d2012-04-18 18:48:02 +0530127static void tegra_sdhci_reset_exit(struct sdhci_host *host, u8 mask)
128{
129 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
130 struct sdhci_tegra *tegra_host = pltfm_host->priv;
131 const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
132
133 if (!(mask & SDHCI_RESET_ALL))
134 return;
135
136 /* Erratum: Enable SDHCI spec v3.00 support */
137 if (soc_data->nvquirks & NVQUIRK_ENABLE_SDHCI_SPEC_300) {
138 u32 misc_ctrl;
139
140 misc_ctrl = sdhci_readb(host, SDHCI_TEGRA_VENDOR_MISC_CTRL);
141 misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_SDHCI_SPEC_300;
142 sdhci_writeb(host, misc_ctrl, SDHCI_TEGRA_VENDOR_MISC_CTRL);
143 }
144}
145
Sascha Hauer7bc088d2013-01-21 19:02:27 +0800146static int tegra_sdhci_buswidth(struct sdhci_host *host, int bus_width)
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500147{
Grant Likely275173b2011-08-23 12:15:33 -0600148 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700149 struct sdhci_tegra *tegra_host = pltfm_host->priv;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500150 u32 ctrl;
151
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500152 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
Stephen Warren0e786102013-02-15 15:07:19 -0700153 if (tegra_host->is_8bit && bus_width == MMC_BUS_WIDTH_8) {
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500154 ctrl &= ~SDHCI_CTRL_4BITBUS;
155 ctrl |= SDHCI_CTRL_8BITBUS;
156 } else {
157 ctrl &= ~SDHCI_CTRL_8BITBUS;
158 if (bus_width == MMC_BUS_WIDTH_4)
159 ctrl |= SDHCI_CTRL_4BITBUS;
160 else
161 ctrl &= ~SDHCI_CTRL_4BITBUS;
162 }
163 sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
164 return 0;
165}
166
Shawn Guo85d65092011-05-27 23:48:12 +0800167static struct sdhci_ops tegra_sdhci_ops = {
168 .get_ro = tegra_sdhci_get_ro,
169 .read_l = tegra_sdhci_readl,
170 .read_w = tegra_sdhci_readw,
171 .write_l = tegra_sdhci_writel,
Sascha Hauer7bc088d2013-01-21 19:02:27 +0800172 .platform_bus_width = tegra_sdhci_buswidth,
Pavan Kunapulica5879d2012-04-18 18:48:02 +0530173 .platform_reset_exit = tegra_sdhci_reset_exit,
Shawn Guo85d65092011-05-27 23:48:12 +0800174};
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500175
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700176static struct sdhci_pltfm_data sdhci_tegra20_pdata = {
Shawn Guo85d65092011-05-27 23:48:12 +0800177 .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
178 SDHCI_QUIRK_SINGLE_POWER_WRITE |
179 SDHCI_QUIRK_NO_HISPD_BIT |
180 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC,
181 .ops = &tegra_sdhci_ops,
182};
183
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700184static struct sdhci_tegra_soc_data soc_data_tegra20 = {
185 .pdata = &sdhci_tegra20_pdata,
186 .nvquirks = NVQUIRK_FORCE_SDHCI_SPEC_200 |
187 NVQUIRK_ENABLE_BLOCK_GAP_DET,
188};
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700189
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700190static struct sdhci_pltfm_data sdhci_tegra30_pdata = {
191 .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
192 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
193 SDHCI_QUIRK_SINGLE_POWER_WRITE |
194 SDHCI_QUIRK_NO_HISPD_BIT |
195 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC,
196 .ops = &tegra_sdhci_ops,
197};
198
199static struct sdhci_tegra_soc_data soc_data_tegra30 = {
200 .pdata = &sdhci_tegra30_pdata,
Pavan Kunapulica5879d2012-04-18 18:48:02 +0530201 .nvquirks = NVQUIRK_ENABLE_SDHCI_SPEC_300,
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700202};
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700203
Rhyland Klein5ebf2552013-02-20 13:35:17 -0500204static struct sdhci_pltfm_data sdhci_tegra114_pdata = {
205 .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
206 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
207 SDHCI_QUIRK_SINGLE_POWER_WRITE |
208 SDHCI_QUIRK_NO_HISPD_BIT |
209 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC,
210 .ops = &tegra_sdhci_ops,
211};
212
213static struct sdhci_tegra_soc_data soc_data_tegra114 = {
214 .pdata = &sdhci_tegra114_pdata,
215};
216
Bill Pemberton498d83e2012-11-19 13:24:22 -0500217static const struct of_device_id sdhci_tegra_dt_match[] = {
Rhyland Klein5ebf2552013-02-20 13:35:17 -0500218 { .compatible = "nvidia,tegra114-sdhci", .data = &soc_data_tegra114 },
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700219 { .compatible = "nvidia,tegra30-sdhci", .data = &soc_data_tegra30 },
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700220 { .compatible = "nvidia,tegra20-sdhci", .data = &soc_data_tegra20 },
Grant Likely275173b2011-08-23 12:15:33 -0600221 {}
222};
223MODULE_DEVICE_TABLE(of, sdhci_dt_ids);
224
Stephen Warren0e786102013-02-15 15:07:19 -0700225static void sdhci_tegra_parse_dt(struct device *dev,
226 struct sdhci_tegra *tegra_host)
Grant Likely275173b2011-08-23 12:15:33 -0600227{
Stephen Warren0e786102013-02-15 15:07:19 -0700228 struct device_node *np = dev->of_node;
Stephen Warrenc11bd552012-05-21 16:43:42 -0600229 u32 bus_width;
Grant Likely275173b2011-08-23 12:15:33 -0600230
Stephen Warren0e786102013-02-15 15:07:19 -0700231 tegra_host->cd_gpio = of_get_named_gpio(np, "cd-gpios", 0);
232 tegra_host->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
233 tegra_host->power_gpio = of_get_named_gpio(np, "power-gpios", 0);
Stephen Warrenc11bd552012-05-21 16:43:42 -0600234
235 if (of_property_read_u32(np, "bus-width", &bus_width) == 0 &&
236 bus_width == 8)
Stephen Warren0e786102013-02-15 15:07:19 -0700237 tegra_host->is_8bit = 1;
Grant Likely275173b2011-08-23 12:15:33 -0600238}
239
Bill Pembertonc3be1ef2012-11-19 13:23:06 -0500240static int sdhci_tegra_probe(struct platform_device *pdev)
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500241{
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700242 const struct of_device_id *match;
243 const struct sdhci_tegra_soc_data *soc_data;
244 struct sdhci_host *host;
Shawn Guo85d65092011-05-27 23:48:12 +0800245 struct sdhci_pltfm_host *pltfm_host;
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700246 struct sdhci_tegra *tegra_host;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500247 struct clk *clk;
248 int rc;
249
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700250 match = of_match_device(sdhci_tegra_dt_match, &pdev->dev);
Joseph Lob37f9d92012-08-17 15:04:31 +0800251 if (!match)
252 return -EINVAL;
253 soc_data = match->data;
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700254
255 host = sdhci_pltfm_init(pdev, soc_data->pdata);
Shawn Guo85d65092011-05-27 23:48:12 +0800256 if (IS_ERR(host))
257 return PTR_ERR(host);
Shawn Guo85d65092011-05-27 23:48:12 +0800258 pltfm_host = sdhci_priv(host);
259
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700260 tegra_host = devm_kzalloc(&pdev->dev, sizeof(*tegra_host), GFP_KERNEL);
261 if (!tegra_host) {
262 dev_err(mmc_dev(host->mmc), "failed to allocate tegra_host\n");
263 rc = -ENOMEM;
Stephen Warren0e786102013-02-15 15:07:19 -0700264 goto err_alloc_tegra_host;
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700265 }
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700266 tegra_host->soc_data = soc_data;
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700267 pltfm_host->priv = tegra_host;
Grant Likely275173b2011-08-23 12:15:33 -0600268
Stephen Warren0e786102013-02-15 15:07:19 -0700269 sdhci_tegra_parse_dt(&pdev->dev, tegra_host);
270
271 if (gpio_is_valid(tegra_host->power_gpio)) {
272 rc = gpio_request(tegra_host->power_gpio, "sdhci_power");
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500273 if (rc) {
274 dev_err(mmc_dev(host->mmc),
275 "failed to allocate power gpio\n");
Shawn Guo85d65092011-05-27 23:48:12 +0800276 goto err_power_req;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500277 }
Stephen Warren0e786102013-02-15 15:07:19 -0700278 gpio_direction_output(tegra_host->power_gpio, 1);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500279 }
280
Stephen Warren0e786102013-02-15 15:07:19 -0700281 if (gpio_is_valid(tegra_host->cd_gpio)) {
282 rc = gpio_request(tegra_host->cd_gpio, "sdhci_cd");
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500283 if (rc) {
284 dev_err(mmc_dev(host->mmc),
285 "failed to allocate cd gpio\n");
Shawn Guo85d65092011-05-27 23:48:12 +0800286 goto err_cd_req;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500287 }
Stephen Warren0e786102013-02-15 15:07:19 -0700288 gpio_direction_input(tegra_host->cd_gpio);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500289
Stephen Warren0e786102013-02-15 15:07:19 -0700290 rc = request_irq(gpio_to_irq(tegra_host->cd_gpio),
291 carddetect_irq,
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500292 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
293 mmc_hostname(host->mmc), host);
294
295 if (rc) {
296 dev_err(mmc_dev(host->mmc), "request irq error\n");
Shawn Guo85d65092011-05-27 23:48:12 +0800297 goto err_cd_irq_req;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500298 }
299
300 }
301
Stephen Warren0e786102013-02-15 15:07:19 -0700302 if (gpio_is_valid(tegra_host->wp_gpio)) {
303 rc = gpio_request(tegra_host->wp_gpio, "sdhci_wp");
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500304 if (rc) {
305 dev_err(mmc_dev(host->mmc),
306 "failed to allocate wp gpio\n");
Shawn Guo85d65092011-05-27 23:48:12 +0800307 goto err_wp_req;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500308 }
Stephen Warren0e786102013-02-15 15:07:19 -0700309 gpio_direction_input(tegra_host->wp_gpio);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500310 }
311
312 clk = clk_get(mmc_dev(host->mmc), NULL);
313 if (IS_ERR(clk)) {
314 dev_err(mmc_dev(host->mmc), "clk err\n");
315 rc = PTR_ERR(clk);
Shawn Guo85d65092011-05-27 23:48:12 +0800316 goto err_clk_get;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500317 }
Prashant Gaikwad1e674bc2012-06-05 09:59:37 +0530318 clk_prepare_enable(clk);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500319 pltfm_host->clk = clk;
320
Stephen Warren0e786102013-02-15 15:07:19 -0700321 if (tegra_host->is_8bit)
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500322 host->mmc->caps |= MMC_CAP_8_BIT_DATA;
323
Shawn Guo85d65092011-05-27 23:48:12 +0800324 rc = sdhci_add_host(host);
325 if (rc)
326 goto err_add_host;
327
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500328 return 0;
329
Shawn Guo85d65092011-05-27 23:48:12 +0800330err_add_host:
Prashant Gaikwad1e674bc2012-06-05 09:59:37 +0530331 clk_disable_unprepare(pltfm_host->clk);
Shawn Guo85d65092011-05-27 23:48:12 +0800332 clk_put(pltfm_host->clk);
333err_clk_get:
Stephen Warren0e786102013-02-15 15:07:19 -0700334 if (gpio_is_valid(tegra_host->wp_gpio))
335 gpio_free(tegra_host->wp_gpio);
Shawn Guo85d65092011-05-27 23:48:12 +0800336err_wp_req:
Stephen Warren0e786102013-02-15 15:07:19 -0700337 if (gpio_is_valid(tegra_host->cd_gpio))
338 free_irq(gpio_to_irq(tegra_host->cd_gpio), host);
Shawn Guo85d65092011-05-27 23:48:12 +0800339err_cd_irq_req:
Stephen Warren0e786102013-02-15 15:07:19 -0700340 if (gpio_is_valid(tegra_host->cd_gpio))
341 gpio_free(tegra_host->cd_gpio);
Shawn Guo85d65092011-05-27 23:48:12 +0800342err_cd_req:
Stephen Warren0e786102013-02-15 15:07:19 -0700343 if (gpio_is_valid(tegra_host->power_gpio))
344 gpio_free(tegra_host->power_gpio);
Shawn Guo85d65092011-05-27 23:48:12 +0800345err_power_req:
Stephen Warren0e786102013-02-15 15:07:19 -0700346err_alloc_tegra_host:
Shawn Guo85d65092011-05-27 23:48:12 +0800347 sdhci_pltfm_free(pdev);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500348 return rc;
349}
350
Bill Pemberton6e0ee712012-11-19 13:26:03 -0500351static int sdhci_tegra_remove(struct platform_device *pdev)
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500352{
Shawn Guo85d65092011-05-27 23:48:12 +0800353 struct sdhci_host *host = platform_get_drvdata(pdev);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500354 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700355 struct sdhci_tegra *tegra_host = pltfm_host->priv;
Shawn Guo85d65092011-05-27 23:48:12 +0800356 int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
357
358 sdhci_remove_host(host, dead);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500359
Stephen Warren0e786102013-02-15 15:07:19 -0700360 if (gpio_is_valid(tegra_host->wp_gpio))
361 gpio_free(tegra_host->wp_gpio);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500362
Stephen Warren0e786102013-02-15 15:07:19 -0700363 if (gpio_is_valid(tegra_host->cd_gpio)) {
364 free_irq(gpio_to_irq(tegra_host->cd_gpio), host);
365 gpio_free(tegra_host->cd_gpio);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500366 }
367
Stephen Warren0e786102013-02-15 15:07:19 -0700368 if (gpio_is_valid(tegra_host->power_gpio))
369 gpio_free(tegra_host->power_gpio);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500370
Prashant Gaikwad1e674bc2012-06-05 09:59:37 +0530371 clk_disable_unprepare(pltfm_host->clk);
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500372 clk_put(pltfm_host->clk);
Shawn Guo85d65092011-05-27 23:48:12 +0800373
374 sdhci_pltfm_free(pdev);
375
376 return 0;
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500377}
378
Shawn Guo85d65092011-05-27 23:48:12 +0800379static struct platform_driver sdhci_tegra_driver = {
380 .driver = {
381 .name = "sdhci-tegra",
382 .owner = THIS_MODULE,
Grant Likely275173b2011-08-23 12:15:33 -0600383 .of_match_table = sdhci_tegra_dt_match,
Manuel Lauss29495aa2011-11-03 11:09:45 +0100384 .pm = SDHCI_PLTFM_PMOPS,
Shawn Guo85d65092011-05-27 23:48:12 +0800385 },
386 .probe = sdhci_tegra_probe,
Bill Pemberton0433c142012-11-19 13:20:26 -0500387 .remove = sdhci_tegra_remove,
Olof Johansson03d2bfc2011-01-01 23:52:56 -0500388};
389
Axel Lind1f81a62011-11-26 12:55:43 +0800390module_platform_driver(sdhci_tegra_driver);
Shawn Guo85d65092011-05-27 23:48:12 +0800391
392MODULE_DESCRIPTION("SDHCI driver for Tegra");
Stephen Warren3e44a1a2012-02-01 16:30:55 -0700393MODULE_AUTHOR("Google, Inc.");
Shawn Guo85d65092011-05-27 23:48:12 +0800394MODULE_LICENSE("GPL v2");