xref: /openbmc/linux/drivers/mmc/host/sdhci-pxav3.c (revision 7c52d7bb)
1a702c8abSZhangfei Gao /*
2a702c8abSZhangfei Gao  * Copyright (C) 2010 Marvell International Ltd.
3a702c8abSZhangfei Gao  *		Zhangfei Gao <zhangfei.gao@marvell.com>
4a702c8abSZhangfei Gao  *		Kevin Wang <dwang4@marvell.com>
5a702c8abSZhangfei Gao  *		Mingwei Wang <mwwang@marvell.com>
6a702c8abSZhangfei Gao  *		Philip Rakity <prakity@marvell.com>
7a702c8abSZhangfei Gao  *		Mark Brown <markb@marvell.com>
8a702c8abSZhangfei Gao  *
9a702c8abSZhangfei Gao  * This software is licensed under the terms of the GNU General Public
10a702c8abSZhangfei Gao  * License version 2, as published by the Free Software Foundation, and
11a702c8abSZhangfei Gao  * may be copied, distributed, and modified under those terms.
12a702c8abSZhangfei Gao  *
13a702c8abSZhangfei Gao  * This program is distributed in the hope that it will be useful,
14a702c8abSZhangfei Gao  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15a702c8abSZhangfei Gao  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16a702c8abSZhangfei Gao  * GNU General Public License for more details.
17a702c8abSZhangfei Gao  *
18a702c8abSZhangfei Gao  */
19a702c8abSZhangfei Gao #include <linux/err.h>
20a702c8abSZhangfei Gao #include <linux/init.h>
21a702c8abSZhangfei Gao #include <linux/platform_device.h>
22a702c8abSZhangfei Gao #include <linux/clk.h>
23a702c8abSZhangfei Gao #include <linux/io.h>
24a702c8abSZhangfei Gao #include <linux/gpio.h>
25a702c8abSZhangfei Gao #include <linux/mmc/card.h>
26a702c8abSZhangfei Gao #include <linux/mmc/host.h>
278f63795cSChris Ball #include <linux/mmc/slot-gpio.h>
28bfed345eSZhangfei Gao #include <linux/platform_data/pxa_sdhci.h>
29a702c8abSZhangfei Gao #include <linux/slab.h>
30a702c8abSZhangfei Gao #include <linux/delay.h>
3188b47679SPaul Gortmaker #include <linux/module.h>
32b650352dSChris Ball #include <linux/of.h>
33b650352dSChris Ball #include <linux/of_device.h>
348f63795cSChris Ball #include <linux/of_gpio.h>
35b650352dSChris Ball 
36a702c8abSZhangfei Gao #include "sdhci.h"
37a702c8abSZhangfei Gao #include "sdhci-pltfm.h"
38a702c8abSZhangfei Gao 
39a702c8abSZhangfei Gao #define SD_CLOCK_BURST_SIZE_SETUP		0x10A
40a702c8abSZhangfei Gao #define SDCLK_SEL	0x100
41a702c8abSZhangfei Gao #define SDCLK_DELAY_SHIFT	9
42a702c8abSZhangfei Gao #define SDCLK_DELAY_MASK	0x1f
43a702c8abSZhangfei Gao 
44a702c8abSZhangfei Gao #define SD_CFG_FIFO_PARAM       0x100
45a702c8abSZhangfei Gao #define SDCFG_GEN_PAD_CLK_ON	(1<<6)
46a702c8abSZhangfei Gao #define SDCFG_GEN_PAD_CLK_CNT_MASK	0xFF
47a702c8abSZhangfei Gao #define SDCFG_GEN_PAD_CLK_CNT_SHIFT	24
48a702c8abSZhangfei Gao 
49a702c8abSZhangfei Gao #define SD_SPI_MODE          0x108
50a702c8abSZhangfei Gao #define SD_CE_ATA_1          0x10C
51a702c8abSZhangfei Gao 
52a702c8abSZhangfei Gao #define SD_CE_ATA_2          0x10E
53a702c8abSZhangfei Gao #define SDCE_MISC_INT		(1<<2)
54a702c8abSZhangfei Gao #define SDCE_MISC_INT_EN	(1<<1)
55a702c8abSZhangfei Gao 
56a702c8abSZhangfei Gao static void pxav3_set_private_registers(struct sdhci_host *host, u8 mask)
57a702c8abSZhangfei Gao {
58a702c8abSZhangfei Gao 	struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc));
59a702c8abSZhangfei Gao 	struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
60a702c8abSZhangfei Gao 
61a702c8abSZhangfei Gao 	if (mask == SDHCI_RESET_ALL) {
62a702c8abSZhangfei Gao 		/*
63a702c8abSZhangfei Gao 		 * tune timing of read data/command when crc error happen
64a702c8abSZhangfei Gao 		 * no performance impact
65a702c8abSZhangfei Gao 		 */
66a702c8abSZhangfei Gao 		if (pdata && 0 != pdata->clk_delay_cycles) {
67a702c8abSZhangfei Gao 			u16 tmp;
68a702c8abSZhangfei Gao 
69a702c8abSZhangfei Gao 			tmp = readw(host->ioaddr + SD_CLOCK_BURST_SIZE_SETUP);
70a702c8abSZhangfei Gao 			tmp |= (pdata->clk_delay_cycles & SDCLK_DELAY_MASK)
71a702c8abSZhangfei Gao 				<< SDCLK_DELAY_SHIFT;
72a702c8abSZhangfei Gao 			tmp |= SDCLK_SEL;
73a702c8abSZhangfei Gao 			writew(tmp, host->ioaddr + SD_CLOCK_BURST_SIZE_SETUP);
74a702c8abSZhangfei Gao 		}
75a702c8abSZhangfei Gao 	}
76a702c8abSZhangfei Gao }
77a702c8abSZhangfei Gao 
78a702c8abSZhangfei Gao #define MAX_WAIT_COUNT 5
79a702c8abSZhangfei Gao static void pxav3_gen_init_74_clocks(struct sdhci_host *host, u8 power_mode)
80a702c8abSZhangfei Gao {
81a702c8abSZhangfei Gao 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
82a702c8abSZhangfei Gao 	struct sdhci_pxa *pxa = pltfm_host->priv;
83a702c8abSZhangfei Gao 	u16 tmp;
84a702c8abSZhangfei Gao 	int count;
85a702c8abSZhangfei Gao 
86a702c8abSZhangfei Gao 	if (pxa->power_mode == MMC_POWER_UP
87a702c8abSZhangfei Gao 			&& power_mode == MMC_POWER_ON) {
88a702c8abSZhangfei Gao 
89a702c8abSZhangfei Gao 		dev_dbg(mmc_dev(host->mmc),
90a702c8abSZhangfei Gao 				"%s: slot->power_mode = %d,"
91a702c8abSZhangfei Gao 				"ios->power_mode = %d\n",
92a702c8abSZhangfei Gao 				__func__,
93a702c8abSZhangfei Gao 				pxa->power_mode,
94a702c8abSZhangfei Gao 				power_mode);
95a702c8abSZhangfei Gao 
96a702c8abSZhangfei Gao 		/* set we want notice of when 74 clocks are sent */
97a702c8abSZhangfei Gao 		tmp = readw(host->ioaddr + SD_CE_ATA_2);
98a702c8abSZhangfei Gao 		tmp |= SDCE_MISC_INT_EN;
99a702c8abSZhangfei Gao 		writew(tmp, host->ioaddr + SD_CE_ATA_2);
100a702c8abSZhangfei Gao 
101a702c8abSZhangfei Gao 		/* start sending the 74 clocks */
102a702c8abSZhangfei Gao 		tmp = readw(host->ioaddr + SD_CFG_FIFO_PARAM);
103a702c8abSZhangfei Gao 		tmp |= SDCFG_GEN_PAD_CLK_ON;
104a702c8abSZhangfei Gao 		writew(tmp, host->ioaddr + SD_CFG_FIFO_PARAM);
105a702c8abSZhangfei Gao 
106a702c8abSZhangfei Gao 		/* slowest speed is about 100KHz or 10usec per clock */
107a702c8abSZhangfei Gao 		udelay(740);
108a702c8abSZhangfei Gao 		count = 0;
109a702c8abSZhangfei Gao 
110a702c8abSZhangfei Gao 		while (count++ < MAX_WAIT_COUNT) {
111a702c8abSZhangfei Gao 			if ((readw(host->ioaddr + SD_CE_ATA_2)
112a702c8abSZhangfei Gao 						& SDCE_MISC_INT) == 0)
113a702c8abSZhangfei Gao 				break;
114a702c8abSZhangfei Gao 			udelay(10);
115a702c8abSZhangfei Gao 		}
116a702c8abSZhangfei Gao 
117a702c8abSZhangfei Gao 		if (count == MAX_WAIT_COUNT)
118a702c8abSZhangfei Gao 			dev_warn(mmc_dev(host->mmc), "74 clock interrupt not cleared\n");
119a702c8abSZhangfei Gao 
120a702c8abSZhangfei Gao 		/* clear the interrupt bit if posted */
121a702c8abSZhangfei Gao 		tmp = readw(host->ioaddr + SD_CE_ATA_2);
122a702c8abSZhangfei Gao 		tmp |= SDCE_MISC_INT;
123a702c8abSZhangfei Gao 		writew(tmp, host->ioaddr + SD_CE_ATA_2);
124a702c8abSZhangfei Gao 	}
125a702c8abSZhangfei Gao 	pxa->power_mode = power_mode;
126a702c8abSZhangfei Gao }
127a702c8abSZhangfei Gao 
128a702c8abSZhangfei Gao static int pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
129a702c8abSZhangfei Gao {
130a702c8abSZhangfei Gao 	u16 ctrl_2;
131a702c8abSZhangfei Gao 
132a702c8abSZhangfei Gao 	/*
133a702c8abSZhangfei Gao 	 * Set V18_EN -- UHS modes do not work without this.
134a702c8abSZhangfei Gao 	 * does not change signaling voltage
135a702c8abSZhangfei Gao 	 */
136a702c8abSZhangfei Gao 	ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
137a702c8abSZhangfei Gao 
138a702c8abSZhangfei Gao 	/* Select Bus Speed Mode for host */
139a702c8abSZhangfei Gao 	ctrl_2 &= ~SDHCI_CTRL_UHS_MASK;
140a702c8abSZhangfei Gao 	switch (uhs) {
141a702c8abSZhangfei Gao 	case MMC_TIMING_UHS_SDR12:
142a702c8abSZhangfei Gao 		ctrl_2 |= SDHCI_CTRL_UHS_SDR12;
143a702c8abSZhangfei Gao 		break;
144a702c8abSZhangfei Gao 	case MMC_TIMING_UHS_SDR25:
145a702c8abSZhangfei Gao 		ctrl_2 |= SDHCI_CTRL_UHS_SDR25;
146a702c8abSZhangfei Gao 		break;
147a702c8abSZhangfei Gao 	case MMC_TIMING_UHS_SDR50:
148a702c8abSZhangfei Gao 		ctrl_2 |= SDHCI_CTRL_UHS_SDR50 | SDHCI_CTRL_VDD_180;
149a702c8abSZhangfei Gao 		break;
150a702c8abSZhangfei Gao 	case MMC_TIMING_UHS_SDR104:
151a702c8abSZhangfei Gao 		ctrl_2 |= SDHCI_CTRL_UHS_SDR104 | SDHCI_CTRL_VDD_180;
152a702c8abSZhangfei Gao 		break;
153a702c8abSZhangfei Gao 	case MMC_TIMING_UHS_DDR50:
154a702c8abSZhangfei Gao 		ctrl_2 |= SDHCI_CTRL_UHS_DDR50 | SDHCI_CTRL_VDD_180;
155a702c8abSZhangfei Gao 		break;
156a702c8abSZhangfei Gao 	}
157a702c8abSZhangfei Gao 
158a702c8abSZhangfei Gao 	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
159a702c8abSZhangfei Gao 	dev_dbg(mmc_dev(host->mmc),
160a702c8abSZhangfei Gao 		"%s uhs = %d, ctrl_2 = %04X\n",
161a702c8abSZhangfei Gao 		__func__, uhs, ctrl_2);
162a702c8abSZhangfei Gao 
163a702c8abSZhangfei Gao 	return 0;
164a702c8abSZhangfei Gao }
165a702c8abSZhangfei Gao 
16635d110e7SKevin Liu static u32 pxav3_get_max_clock(struct sdhci_host *host)
16735d110e7SKevin Liu {
16835d110e7SKevin Liu 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
16935d110e7SKevin Liu 
17035d110e7SKevin Liu 	return clk_get_rate(pltfm_host->clk);
17135d110e7SKevin Liu }
17235d110e7SKevin Liu 
173a702c8abSZhangfei Gao static struct sdhci_ops pxav3_sdhci_ops = {
174a702c8abSZhangfei Gao 	.platform_reset_exit = pxav3_set_private_registers,
175a702c8abSZhangfei Gao 	.set_uhs_signaling = pxav3_set_uhs_signaling,
176a702c8abSZhangfei Gao 	.platform_send_init_74_clocks = pxav3_gen_init_74_clocks,
17735d110e7SKevin Liu 	.get_max_clock = pxav3_get_max_clock,
178a702c8abSZhangfei Gao };
179a702c8abSZhangfei Gao 
180b650352dSChris Ball #ifdef CONFIG_OF
181b650352dSChris Ball static const struct of_device_id sdhci_pxav3_of_match[] = {
182b650352dSChris Ball 	{
183b650352dSChris Ball 		.compatible = "mrvl,pxav3-mmc",
184b650352dSChris Ball 	},
185b650352dSChris Ball 	{},
186b650352dSChris Ball };
187b650352dSChris Ball MODULE_DEVICE_TABLE(of, sdhci_pxav3_of_match);
188b650352dSChris Ball 
189b650352dSChris Ball static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
190b650352dSChris Ball {
191b650352dSChris Ball 	struct sdhci_pxa_platdata *pdata;
192b650352dSChris Ball 	struct device_node *np = dev->of_node;
193b650352dSChris Ball 	u32 bus_width;
194b650352dSChris Ball 	u32 clk_delay_cycles;
1958f63795cSChris Ball 	enum of_gpio_flags gpio_flags;
196b650352dSChris Ball 
197b650352dSChris Ball 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
198b650352dSChris Ball 	if (!pdata)
199b650352dSChris Ball 		return NULL;
200b650352dSChris Ball 
201b650352dSChris Ball 	if (of_find_property(np, "non-removable", NULL))
202b650352dSChris Ball 		pdata->flags |= PXA_FLAG_CARD_PERMANENT;
203b650352dSChris Ball 
204b650352dSChris Ball 	of_property_read_u32(np, "bus-width", &bus_width);
205b650352dSChris Ball 	if (bus_width == 8)
206b650352dSChris Ball 		pdata->flags |= PXA_FLAG_SD_8_BIT_CAPABLE_SLOT;
207b650352dSChris Ball 
208b650352dSChris Ball 	of_property_read_u32(np, "mrvl,clk-delay-cycles", &clk_delay_cycles);
209b650352dSChris Ball 	if (clk_delay_cycles > 0)
210b650352dSChris Ball 		pdata->clk_delay_cycles = clk_delay_cycles;
211b650352dSChris Ball 
2128f63795cSChris Ball 	pdata->ext_cd_gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &gpio_flags);
2138f63795cSChris Ball 	if (gpio_flags != OF_GPIO_ACTIVE_LOW)
2148f63795cSChris Ball 		pdata->host_caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
2158f63795cSChris Ball 
216b650352dSChris Ball 	return pdata;
217b650352dSChris Ball }
218b650352dSChris Ball #else
219b650352dSChris Ball static inline struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
220b650352dSChris Ball {
221b650352dSChris Ball 	return NULL;
222b650352dSChris Ball }
223b650352dSChris Ball #endif
224b650352dSChris Ball 
225a702c8abSZhangfei Gao static int __devinit sdhci_pxav3_probe(struct platform_device *pdev)
226a702c8abSZhangfei Gao {
227a702c8abSZhangfei Gao 	struct sdhci_pltfm_host *pltfm_host;
228a702c8abSZhangfei Gao 	struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
229a702c8abSZhangfei Gao 	struct device *dev = &pdev->dev;
230a702c8abSZhangfei Gao 	struct sdhci_host *host = NULL;
231a702c8abSZhangfei Gao 	struct sdhci_pxa *pxa = NULL;
232b650352dSChris Ball 	const struct of_device_id *match;
233b650352dSChris Ball 
234a702c8abSZhangfei Gao 	int ret;
235a702c8abSZhangfei Gao 	struct clk *clk;
236a702c8abSZhangfei Gao 
237a702c8abSZhangfei Gao 	pxa = kzalloc(sizeof(struct sdhci_pxa), GFP_KERNEL);
238a702c8abSZhangfei Gao 	if (!pxa)
239a702c8abSZhangfei Gao 		return -ENOMEM;
240a702c8abSZhangfei Gao 
241a702c8abSZhangfei Gao 	host = sdhci_pltfm_init(pdev, NULL);
242a702c8abSZhangfei Gao 	if (IS_ERR(host)) {
243a702c8abSZhangfei Gao 		kfree(pxa);
244a702c8abSZhangfei Gao 		return PTR_ERR(host);
245a702c8abSZhangfei Gao 	}
246a702c8abSZhangfei Gao 	pltfm_host = sdhci_priv(host);
247a702c8abSZhangfei Gao 	pltfm_host->priv = pxa;
248a702c8abSZhangfei Gao 
249164378efSChao Xie 	clk = clk_get(dev, NULL);
250a702c8abSZhangfei Gao 	if (IS_ERR(clk)) {
251a702c8abSZhangfei Gao 		dev_err(dev, "failed to get io clock\n");
252a702c8abSZhangfei Gao 		ret = PTR_ERR(clk);
253a702c8abSZhangfei Gao 		goto err_clk_get;
254a702c8abSZhangfei Gao 	}
255a702c8abSZhangfei Gao 	pltfm_host->clk = clk;
256164378efSChao Xie 	clk_prepare_enable(clk);
257a702c8abSZhangfei Gao 
258a702c8abSZhangfei Gao 	host->quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
259606a15e4SPhilip Rakity 		| SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
26035d110e7SKevin Liu 		| SDHCI_QUIRK_32BIT_ADMA_SIZE
26135d110e7SKevin Liu 		| SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN;
262a702c8abSZhangfei Gao 
263a702c8abSZhangfei Gao 	/* enable 1/8V DDR capable */
264a702c8abSZhangfei Gao 	host->mmc->caps |= MMC_CAP_1_8V_DDR;
265a702c8abSZhangfei Gao 
266b650352dSChris Ball 	match = of_match_device(of_match_ptr(sdhci_pxav3_of_match), &pdev->dev);
267b650352dSChris Ball 	if (match)
268b650352dSChris Ball 		pdata = pxav3_get_mmc_pdata(dev);
269b650352dSChris Ball 
270a702c8abSZhangfei Gao 	if (pdata) {
271a702c8abSZhangfei Gao 		if (pdata->flags & PXA_FLAG_CARD_PERMANENT) {
272a702c8abSZhangfei Gao 			/* on-chip device */
273a702c8abSZhangfei Gao 			host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
274a702c8abSZhangfei Gao 			host->mmc->caps |= MMC_CAP_NONREMOVABLE;
275a702c8abSZhangfei Gao 		}
276a702c8abSZhangfei Gao 
277a702c8abSZhangfei Gao 		/* If slot design supports 8 bit data, indicate this to MMC. */
278a702c8abSZhangfei Gao 		if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
279a702c8abSZhangfei Gao 			host->mmc->caps |= MMC_CAP_8_BIT_DATA;
280a702c8abSZhangfei Gao 
281a702c8abSZhangfei Gao 		if (pdata->quirks)
282a702c8abSZhangfei Gao 			host->quirks |= pdata->quirks;
2837c52d7bbSKevin Liu 		if (pdata->quirks2)
2847c52d7bbSKevin Liu 			host->quirks2 |= pdata->quirks2;
285a702c8abSZhangfei Gao 		if (pdata->host_caps)
286a702c8abSZhangfei Gao 			host->mmc->caps |= pdata->host_caps;
2878f63795cSChris Ball 		if (pdata->host_caps2)
2888f63795cSChris Ball 			host->mmc->caps2 |= pdata->host_caps2;
289a702c8abSZhangfei Gao 		if (pdata->pm_caps)
290a702c8abSZhangfei Gao 			host->mmc->pm_caps |= pdata->pm_caps;
2918f63795cSChris Ball 
2928f63795cSChris Ball 		if (gpio_is_valid(pdata->ext_cd_gpio)) {
2938f63795cSChris Ball 			ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio);
2948f63795cSChris Ball 			if (ret) {
2958f63795cSChris Ball 				dev_err(mmc_dev(host->mmc),
2968f63795cSChris Ball 					"failed to allocate card detect gpio\n");
2978f63795cSChris Ball 				goto err_cd_req;
2988f63795cSChris Ball 			}
2998f63795cSChris Ball 		}
300a702c8abSZhangfei Gao 	}
301a702c8abSZhangfei Gao 
302a702c8abSZhangfei Gao 	host->ops = &pxav3_sdhci_ops;
303a702c8abSZhangfei Gao 
304f4f24adeSChris Ball 	sdhci_get_of_property(pdev);
305f4f24adeSChris Ball 
306a702c8abSZhangfei Gao 	ret = sdhci_add_host(host);
307a702c8abSZhangfei Gao 	if (ret) {
308a702c8abSZhangfei Gao 		dev_err(&pdev->dev, "failed to add host\n");
309a702c8abSZhangfei Gao 		goto err_add_host;
310a702c8abSZhangfei Gao 	}
311a702c8abSZhangfei Gao 
312a702c8abSZhangfei Gao 	platform_set_drvdata(pdev, host);
313a702c8abSZhangfei Gao 
314a702c8abSZhangfei Gao 	return 0;
315a702c8abSZhangfei Gao 
316a702c8abSZhangfei Gao err_add_host:
317164378efSChao Xie 	clk_disable_unprepare(clk);
318a702c8abSZhangfei Gao 	clk_put(clk);
3198f63795cSChris Ball 	mmc_gpio_free_cd(host->mmc);
3208f63795cSChris Ball err_cd_req:
321a702c8abSZhangfei Gao err_clk_get:
322a702c8abSZhangfei Gao 	sdhci_pltfm_free(pdev);
323a702c8abSZhangfei Gao 	kfree(pxa);
324a702c8abSZhangfei Gao 	return ret;
325a702c8abSZhangfei Gao }
326a702c8abSZhangfei Gao 
327a702c8abSZhangfei Gao static int __devexit sdhci_pxav3_remove(struct platform_device *pdev)
328a702c8abSZhangfei Gao {
329a702c8abSZhangfei Gao 	struct sdhci_host *host = platform_get_drvdata(pdev);
330a702c8abSZhangfei Gao 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
331a702c8abSZhangfei Gao 	struct sdhci_pxa *pxa = pltfm_host->priv;
3328f63795cSChris Ball 	struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
333a702c8abSZhangfei Gao 
334a702c8abSZhangfei Gao 	sdhci_remove_host(host, 1);
335a702c8abSZhangfei Gao 
336164378efSChao Xie 	clk_disable_unprepare(pltfm_host->clk);
337a702c8abSZhangfei Gao 	clk_put(pltfm_host->clk);
3388f63795cSChris Ball 
3398f63795cSChris Ball 	if (gpio_is_valid(pdata->ext_cd_gpio))
3408f63795cSChris Ball 		mmc_gpio_free_cd(host->mmc);
3418f63795cSChris Ball 
342a702c8abSZhangfei Gao 	sdhci_pltfm_free(pdev);
343a702c8abSZhangfei Gao 	kfree(pxa);
344a702c8abSZhangfei Gao 
345a702c8abSZhangfei Gao 	platform_set_drvdata(pdev, NULL);
346a702c8abSZhangfei Gao 
347a702c8abSZhangfei Gao 	return 0;
348a702c8abSZhangfei Gao }
349a702c8abSZhangfei Gao 
350a702c8abSZhangfei Gao static struct platform_driver sdhci_pxav3_driver = {
351a702c8abSZhangfei Gao 	.driver		= {
352a702c8abSZhangfei Gao 		.name	= "sdhci-pxav3",
353b650352dSChris Ball #ifdef CONFIG_OF
354b650352dSChris Ball 		.of_match_table = sdhci_pxav3_of_match,
355b650352dSChris Ball #endif
356a702c8abSZhangfei Gao 		.owner	= THIS_MODULE,
35729495aa0SManuel Lauss 		.pm	= SDHCI_PLTFM_PMOPS,
358a702c8abSZhangfei Gao 	},
359a702c8abSZhangfei Gao 	.probe		= sdhci_pxav3_probe,
360a702c8abSZhangfei Gao 	.remove		= __devexit_p(sdhci_pxav3_remove),
361a702c8abSZhangfei Gao };
362a702c8abSZhangfei Gao 
363d1f81a64SAxel Lin module_platform_driver(sdhci_pxav3_driver);
364a702c8abSZhangfei Gao 
365a702c8abSZhangfei Gao MODULE_DESCRIPTION("SDHCI driver for pxav3");
366a702c8abSZhangfei Gao MODULE_AUTHOR("Marvell International Ltd.");
367a702c8abSZhangfei Gao MODULE_LICENSE("GPL v2");
368a702c8abSZhangfei Gao 
369