sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / mmc / host / sdhci-s3c.c
blobde219ca7ea7c398d73e250f0d281b4e1fdc0a2db
1 /* linux/drivers/mmc/host/sdhci-s3c.c
3 * Copyright 2008 Openmoko Inc.
4 * Copyright 2008 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/
8 * SDHCI (HSMMC) support for Samsung SoC
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/spinlock.h>
16 #include <linux/delay.h>
17 #include <linux/dma-mapping.h>
18 #include <linux/platform_device.h>
19 #include <linux/platform_data/mmc-sdhci-s3c.h>
20 #include <linux/slab.h>
21 #include <linux/clk.h>
22 #include <linux/io.h>
23 #include <linux/gpio.h>
24 #include <linux/module.h>
25 #include <linux/of.h>
26 #include <linux/of_gpio.h>
27 #include <linux/pm.h>
28 #include <linux/pm_runtime.h>
30 #include <linux/mmc/host.h>
32 #include "sdhci-s3c-regs.h"
33 #include "sdhci.h"
35 #define MAX_BUS_CLK (4)
37 /**
38 * struct sdhci_s3c - S3C SDHCI instance
39 * @host: The SDHCI host created
40 * @pdev: The platform device we where created from.
41 * @ioarea: The resource created when we claimed the IO area.
42 * @pdata: The platform data for this controller.
43 * @cur_clk: The index of the current bus clock.
44 * @clk_io: The clock for the internal bus interface.
45 * @clk_bus: The clocks that are available for the SD/MMC bus clock.
47 struct sdhci_s3c {
48 struct sdhci_host *host;
49 struct platform_device *pdev;
50 struct resource *ioarea;
51 struct s3c_sdhci_platdata *pdata;
52 int cur_clk;
53 int ext_cd_irq;
54 int ext_cd_gpio;
56 struct clk *clk_io;
57 struct clk *clk_bus[MAX_BUS_CLK];
58 unsigned long clk_rates[MAX_BUS_CLK];
60 bool no_divider;
63 /**
64 * struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data
65 * @sdhci_quirks: sdhci host specific quirks.
67 * Specifies platform specific configuration of sdhci controller.
68 * Note: A structure for driver specific platform data is used for future
69 * expansion of its usage.
71 struct sdhci_s3c_drv_data {
72 unsigned int sdhci_quirks;
73 bool no_divider;
76 static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
78 return sdhci_priv(host);
81 /**
82 * sdhci_s3c_get_max_clk - callback to get maximum clock frequency.
83 * @host: The SDHCI host instance.
85 * Callback to return the maximum clock rate acheivable by the controller.
87 static unsigned int sdhci_s3c_get_max_clk(struct sdhci_host *host)
89 struct sdhci_s3c *ourhost = to_s3c(host);
90 unsigned long rate, max = 0;
91 int src;
93 for (src = 0; src < MAX_BUS_CLK; src++) {
94 rate = ourhost->clk_rates[src];
95 if (rate > max)
96 max = rate;
99 return max;
103 * sdhci_s3c_consider_clock - consider one the bus clocks for current setting
104 * @ourhost: Our SDHCI instance.
105 * @src: The source clock index.
106 * @wanted: The clock frequency wanted.
108 static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
109 unsigned int src,
110 unsigned int wanted)
112 unsigned long rate;
113 struct clk *clksrc = ourhost->clk_bus[src];
114 int shift;
116 if (IS_ERR(clksrc))
117 return UINT_MAX;
120 * If controller uses a non-standard clock division, find the best clock
121 * speed possible with selected clock source and skip the division.
123 if (ourhost->no_divider) {
124 spin_unlock_irq(&ourhost->host->lock);
125 rate = clk_round_rate(clksrc, wanted);
126 spin_lock_irq(&ourhost->host->lock);
127 return wanted - rate;
130 rate = ourhost->clk_rates[src];
132 for (shift = 0; shift <= 8; ++shift) {
133 if ((rate >> shift) <= wanted)
134 break;
137 if (shift > 8) {
138 dev_dbg(&ourhost->pdev->dev,
139 "clk %d: rate %ld, min rate %lu > wanted %u\n",
140 src, rate, rate / 256, wanted);
141 return UINT_MAX;
144 dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n",
145 src, rate, wanted, rate >> shift);
147 return wanted - (rate >> shift);
151 * sdhci_s3c_set_clock - callback on clock change
152 * @host: The SDHCI host being changed
153 * @clock: The clock rate being requested.
155 * When the card's clock is going to be changed, look at the new frequency
156 * and find the best clock source to go with it.
158 static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
160 struct sdhci_s3c *ourhost = to_s3c(host);
161 unsigned int best = UINT_MAX;
162 unsigned int delta;
163 int best_src = 0;
164 int src;
165 u32 ctrl;
167 host->mmc->actual_clock = 0;
169 /* don't bother if the clock is going off. */
170 if (clock == 0) {
171 sdhci_set_clock(host, clock);
172 return;
175 for (src = 0; src < MAX_BUS_CLK; src++) {
176 delta = sdhci_s3c_consider_clock(ourhost, src, clock);
177 if (delta < best) {
178 best = delta;
179 best_src = src;
183 dev_dbg(&ourhost->pdev->dev,
184 "selected source %d, clock %d, delta %d\n",
185 best_src, clock, best);
187 /* select the new clock source */
188 if (ourhost->cur_clk != best_src) {
189 struct clk *clk = ourhost->clk_bus[best_src];
191 clk_prepare_enable(clk);
192 if (ourhost->cur_clk >= 0)
193 clk_disable_unprepare(
194 ourhost->clk_bus[ourhost->cur_clk]);
196 ourhost->cur_clk = best_src;
197 host->max_clk = ourhost->clk_rates[best_src];
200 /* turn clock off to card before changing clock source */
201 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
203 ctrl = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
204 ctrl &= ~S3C_SDHCI_CTRL2_SELBASECLK_MASK;
205 ctrl |= best_src << S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
206 writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL2);
208 /* reprogram default hardware configuration */
209 writel(S3C64XX_SDHCI_CONTROL4_DRIVE_9mA,
210 host->ioaddr + S3C64XX_SDHCI_CONTROL4);
212 ctrl = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
213 ctrl |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
214 S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
215 S3C_SDHCI_CTRL2_ENFBCLKRX |
216 S3C_SDHCI_CTRL2_DFCNT_NONE |
217 S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
218 writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL2);
220 /* reconfigure the controller for new clock rate */
221 ctrl = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
222 if (clock < 25 * 1000000)
223 ctrl |= (S3C_SDHCI_CTRL3_FCSEL3 | S3C_SDHCI_CTRL3_FCSEL2);
224 writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL3);
226 sdhci_set_clock(host, clock);
230 * sdhci_s3c_get_min_clock - callback to get minimal supported clock value
231 * @host: The SDHCI host being queried
233 * To init mmc host properly a minimal clock value is needed. For high system
234 * bus clock's values the standard formula gives values out of allowed range.
235 * The clock still can be set to lower values, if clock source other then
236 * system bus is selected.
238 static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
240 struct sdhci_s3c *ourhost = to_s3c(host);
241 unsigned long rate, min = ULONG_MAX;
242 int src;
244 for (src = 0; src < MAX_BUS_CLK; src++) {
245 rate = ourhost->clk_rates[src] / 256;
246 if (!rate)
247 continue;
248 if (rate < min)
249 min = rate;
252 return min;
255 /* sdhci_cmu_get_max_clk - callback to get maximum clock frequency.*/
256 static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
258 struct sdhci_s3c *ourhost = to_s3c(host);
259 unsigned long rate, max = 0;
260 int src;
262 for (src = 0; src < MAX_BUS_CLK; src++) {
263 struct clk *clk;
265 clk = ourhost->clk_bus[src];
266 if (IS_ERR(clk))
267 continue;
269 rate = clk_round_rate(clk, ULONG_MAX);
270 if (rate > max)
271 max = rate;
274 return max;
277 /* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. */
278 static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
280 struct sdhci_s3c *ourhost = to_s3c(host);
281 unsigned long rate, min = ULONG_MAX;
282 int src;
284 for (src = 0; src < MAX_BUS_CLK; src++) {
285 struct clk *clk;
287 clk = ourhost->clk_bus[src];
288 if (IS_ERR(clk))
289 continue;
291 rate = clk_round_rate(clk, 0);
292 if (rate < min)
293 min = rate;
296 return min;
299 /* sdhci_cmu_set_clock - callback on clock change.*/
300 static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
302 struct sdhci_s3c *ourhost = to_s3c(host);
303 struct device *dev = &ourhost->pdev->dev;
304 unsigned long timeout;
305 u16 clk = 0;
306 int ret;
308 host->mmc->actual_clock = 0;
310 /* If the clock is going off, set to 0 at clock control register */
311 if (clock == 0) {
312 sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
313 return;
316 sdhci_s3c_set_clock(host, clock);
318 /* Reset SD Clock Enable */
319 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
320 clk &= ~SDHCI_CLOCK_CARD_EN;
321 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
323 spin_unlock_irq(&host->lock);
324 ret = clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
325 spin_lock_irq(&host->lock);
326 if (ret != 0) {
327 dev_err(dev, "%s: failed to set clock rate %uHz\n",
328 mmc_hostname(host->mmc), clock);
329 return;
332 clk = SDHCI_CLOCK_INT_EN;
333 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
335 /* Wait max 20 ms */
336 timeout = 20;
337 while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
338 & SDHCI_CLOCK_INT_STABLE)) {
339 if (timeout == 0) {
340 dev_err(dev, "%s: Internal clock never stabilised.\n",
341 mmc_hostname(host->mmc));
342 return;
344 timeout--;
345 mdelay(1);
348 clk |= SDHCI_CLOCK_CARD_EN;
349 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
353 * sdhci_s3c_set_bus_width - support 8bit buswidth
354 * @host: The SDHCI host being queried
355 * @width: MMC_BUS_WIDTH_ macro for the bus width being requested
357 * We have 8-bit width support but is not a v3 controller.
358 * So we add platform_bus_width() and support 8bit width.
360 static void sdhci_s3c_set_bus_width(struct sdhci_host *host, int width)
362 u8 ctrl;
364 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
366 switch (width) {
367 case MMC_BUS_WIDTH_8:
368 ctrl |= SDHCI_CTRL_8BITBUS;
369 ctrl &= ~SDHCI_CTRL_4BITBUS;
370 break;
371 case MMC_BUS_WIDTH_4:
372 ctrl |= SDHCI_CTRL_4BITBUS;
373 ctrl &= ~SDHCI_CTRL_8BITBUS;
374 break;
375 default:
376 ctrl &= ~SDHCI_CTRL_4BITBUS;
377 ctrl &= ~SDHCI_CTRL_8BITBUS;
378 break;
381 sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
384 static struct sdhci_ops sdhci_s3c_ops = {
385 .get_max_clock = sdhci_s3c_get_max_clk,
386 .set_clock = sdhci_s3c_set_clock,
387 .get_min_clock = sdhci_s3c_get_min_clock,
388 .set_bus_width = sdhci_s3c_set_bus_width,
389 .reset = sdhci_reset,
390 .set_uhs_signaling = sdhci_set_uhs_signaling,
393 #ifdef CONFIG_OF
394 static int sdhci_s3c_parse_dt(struct device *dev,
395 struct sdhci_host *host, struct s3c_sdhci_platdata *pdata)
397 struct device_node *node = dev->of_node;
398 u32 max_width;
400 /* if the bus-width property is not specified, assume width as 1 */
401 if (of_property_read_u32(node, "bus-width", &max_width))
402 max_width = 1;
403 pdata->max_width = max_width;
405 /* get the card detection method */
406 if (of_get_property(node, "broken-cd", NULL)) {
407 pdata->cd_type = S3C_SDHCI_CD_NONE;
408 return 0;
411 if (of_get_property(node, "non-removable", NULL)) {
412 pdata->cd_type = S3C_SDHCI_CD_PERMANENT;
413 return 0;
416 if (of_get_named_gpio(node, "cd-gpios", 0))
417 return 0;
419 /* assuming internal card detect that will be configured by pinctrl */
420 pdata->cd_type = S3C_SDHCI_CD_INTERNAL;
421 return 0;
423 #else
424 static int sdhci_s3c_parse_dt(struct device *dev,
425 struct sdhci_host *host, struct s3c_sdhci_platdata *pdata)
427 return -EINVAL;
429 #endif
431 static const struct of_device_id sdhci_s3c_dt_match[];
433 static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
434 struct platform_device *pdev)
436 #ifdef CONFIG_OF
437 if (pdev->dev.of_node) {
438 const struct of_device_id *match;
439 match = of_match_node(sdhci_s3c_dt_match, pdev->dev.of_node);
440 return (struct sdhci_s3c_drv_data *)match->data;
442 #endif
443 return (struct sdhci_s3c_drv_data *)
444 platform_get_device_id(pdev)->driver_data;
447 static int sdhci_s3c_probe(struct platform_device *pdev)
449 struct s3c_sdhci_platdata *pdata;
450 struct sdhci_s3c_drv_data *drv_data;
451 struct device *dev = &pdev->dev;
452 struct sdhci_host *host;
453 struct sdhci_s3c *sc;
454 struct resource *res;
455 int ret, irq, ptr, clks;
457 if (!pdev->dev.platform_data && !pdev->dev.of_node) {
458 dev_err(dev, "no device data specified\n");
459 return -ENOENT;
462 irq = platform_get_irq(pdev, 0);
463 if (irq < 0) {
464 dev_err(dev, "no irq specified\n");
465 return irq;
468 host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c));
469 if (IS_ERR(host)) {
470 dev_err(dev, "sdhci_alloc_host() failed\n");
471 return PTR_ERR(host);
473 sc = sdhci_priv(host);
475 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
476 if (!pdata) {
477 ret = -ENOMEM;
478 goto err_pdata_io_clk;
481 if (pdev->dev.of_node) {
482 ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata);
483 if (ret)
484 goto err_pdata_io_clk;
485 } else {
486 memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata));
487 sc->ext_cd_gpio = -1; /* invalid gpio number */
490 drv_data = sdhci_s3c_get_driver_data(pdev);
492 sc->host = host;
493 sc->pdev = pdev;
494 sc->pdata = pdata;
495 sc->cur_clk = -1;
497 platform_set_drvdata(pdev, host);
499 sc->clk_io = devm_clk_get(dev, "hsmmc");
500 if (IS_ERR(sc->clk_io)) {
501 dev_err(dev, "failed to get io clock\n");
502 ret = PTR_ERR(sc->clk_io);
503 goto err_pdata_io_clk;
506 /* enable the local io clock and keep it running for the moment. */
507 clk_prepare_enable(sc->clk_io);
509 for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
510 char name[14];
512 snprintf(name, 14, "mmc_busclk.%d", ptr);
513 sc->clk_bus[ptr] = devm_clk_get(dev, name);
514 if (IS_ERR(sc->clk_bus[ptr]))
515 continue;
517 clks++;
518 sc->clk_rates[ptr] = clk_get_rate(sc->clk_bus[ptr]);
520 dev_info(dev, "clock source %d: %s (%ld Hz)\n",
521 ptr, name, sc->clk_rates[ptr]);
524 if (clks == 0) {
525 dev_err(dev, "failed to find any bus clocks\n");
526 ret = -ENOENT;
527 goto err_no_busclks;
530 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
531 host->ioaddr = devm_ioremap_resource(&pdev->dev, res);
532 if (IS_ERR(host->ioaddr)) {
533 ret = PTR_ERR(host->ioaddr);
534 goto err_req_regs;
537 /* Ensure we have minimal gpio selected CMD/CLK/Detect */
538 if (pdata->cfg_gpio)
539 pdata->cfg_gpio(pdev, pdata->max_width);
541 host->hw_name = "samsung-hsmmc";
542 host->ops = &sdhci_s3c_ops;
543 host->quirks = 0;
544 host->quirks2 = 0;
545 host->irq = irq;
547 /* Setup quirks for the controller */
548 host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC;
549 host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
550 if (drv_data) {
551 host->quirks |= drv_data->sdhci_quirks;
552 sc->no_divider = drv_data->no_divider;
555 #ifndef CONFIG_MMC_SDHCI_S3C_DMA
557 /* we currently see overruns on errors, so disable the SDMA
558 * support as well. */
559 host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
561 #endif /* CONFIG_MMC_SDHCI_S3C_DMA */
563 /* It seems we do not get an DATA transfer complete on non-busy
564 * transfers, not sure if this is a problem with this specific
565 * SDHCI block, or a missing configuration that needs to be set. */
566 host->quirks |= SDHCI_QUIRK_NO_BUSY_IRQ;
568 /* This host supports the Auto CMD12 */
569 host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
571 /* Samsung SoCs need BROKEN_ADMA_ZEROLEN_DESC */
572 host->quirks |= SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC;
574 if (pdata->cd_type == S3C_SDHCI_CD_NONE ||
575 pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
576 host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
578 if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
579 host->mmc->caps = MMC_CAP_NONREMOVABLE;
581 switch (pdata->max_width) {
582 case 8:
583 host->mmc->caps |= MMC_CAP_8_BIT_DATA;
584 case 4:
585 host->mmc->caps |= MMC_CAP_4_BIT_DATA;
586 break;
589 if (pdata->pm_caps)
590 host->mmc->pm_caps |= pdata->pm_caps;
592 host->quirks |= (SDHCI_QUIRK_32BIT_DMA_ADDR |
593 SDHCI_QUIRK_32BIT_DMA_SIZE);
595 /* HSMMC on Samsung SoCs uses SDCLK as timeout clock */
596 host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
599 * If controller does not have internal clock divider,
600 * we can use overriding functions instead of default.
602 if (sc->no_divider) {
603 sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
604 sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
605 sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
608 /* It supports additional host capabilities if needed */
609 if (pdata->host_caps)
610 host->mmc->caps |= pdata->host_caps;
612 if (pdata->host_caps2)
613 host->mmc->caps2 |= pdata->host_caps2;
615 pm_runtime_enable(&pdev->dev);
616 pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
617 pm_runtime_use_autosuspend(&pdev->dev);
618 pm_suspend_ignore_children(&pdev->dev, 1);
620 ret = mmc_of_parse(host->mmc);
621 if (ret)
622 goto err_req_regs;
624 ret = sdhci_add_host(host);
625 if (ret) {
626 dev_err(dev, "sdhci_add_host() failed\n");
627 goto err_req_regs;
630 #ifdef CONFIG_PM
631 if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
632 clk_disable_unprepare(sc->clk_io);
633 #endif
634 return 0;
636 err_req_regs:
637 pm_runtime_disable(&pdev->dev);
639 err_no_busclks:
640 clk_disable_unprepare(sc->clk_io);
642 err_pdata_io_clk:
643 sdhci_free_host(host);
645 return ret;
648 static int sdhci_s3c_remove(struct platform_device *pdev)
650 struct sdhci_host *host = platform_get_drvdata(pdev);
651 struct sdhci_s3c *sc = sdhci_priv(host);
653 if (sc->ext_cd_irq)
654 free_irq(sc->ext_cd_irq, sc);
656 #ifdef CONFIG_PM
657 if (sc->pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
658 clk_prepare_enable(sc->clk_io);
659 #endif
660 sdhci_remove_host(host, 1);
662 pm_runtime_dont_use_autosuspend(&pdev->dev);
663 pm_runtime_disable(&pdev->dev);
665 clk_disable_unprepare(sc->clk_io);
667 sdhci_free_host(host);
669 return 0;
672 #ifdef CONFIG_PM_SLEEP
673 static int sdhci_s3c_suspend(struct device *dev)
675 struct sdhci_host *host = dev_get_drvdata(dev);
677 return sdhci_suspend_host(host);
680 static int sdhci_s3c_resume(struct device *dev)
682 struct sdhci_host *host = dev_get_drvdata(dev);
684 return sdhci_resume_host(host);
686 #endif
688 #ifdef CONFIG_PM
689 static int sdhci_s3c_runtime_suspend(struct device *dev)
691 struct sdhci_host *host = dev_get_drvdata(dev);
692 struct sdhci_s3c *ourhost = to_s3c(host);
693 struct clk *busclk = ourhost->clk_io;
694 int ret;
696 ret = sdhci_runtime_suspend_host(host);
698 if (ourhost->cur_clk >= 0)
699 clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
700 clk_disable_unprepare(busclk);
701 return ret;
704 static int sdhci_s3c_runtime_resume(struct device *dev)
706 struct sdhci_host *host = dev_get_drvdata(dev);
707 struct sdhci_s3c *ourhost = to_s3c(host);
708 struct clk *busclk = ourhost->clk_io;
709 int ret;
711 clk_prepare_enable(busclk);
712 if (ourhost->cur_clk >= 0)
713 clk_prepare_enable(ourhost->clk_bus[ourhost->cur_clk]);
714 ret = sdhci_runtime_resume_host(host);
715 return ret;
717 #endif
719 static const struct dev_pm_ops sdhci_s3c_pmops = {
720 SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
721 SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
722 NULL)
725 #if defined(CONFIG_CPU_EXYNOS4210) || defined(CONFIG_SOC_EXYNOS4212)
726 static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
727 .no_divider = true,
729 #define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)&exynos4_sdhci_drv_data)
730 #else
731 #define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)NULL)
732 #endif
734 static const struct platform_device_id sdhci_s3c_driver_ids[] = {
736 .name = "s3c-sdhci",
737 .driver_data = (kernel_ulong_t)NULL,
738 }, {
739 .name = "exynos4-sdhci",
740 .driver_data = EXYNOS4_SDHCI_DRV_DATA,
744 MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);
746 #ifdef CONFIG_OF
747 static const struct of_device_id sdhci_s3c_dt_match[] = {
748 { .compatible = "samsung,s3c6410-sdhci", },
749 { .compatible = "samsung,exynos4210-sdhci",
750 .data = (void *)EXYNOS4_SDHCI_DRV_DATA },
753 MODULE_DEVICE_TABLE(of, sdhci_s3c_dt_match);
754 #endif
756 static struct platform_driver sdhci_s3c_driver = {
757 .probe = sdhci_s3c_probe,
758 .remove = sdhci_s3c_remove,
759 .id_table = sdhci_s3c_driver_ids,
760 .driver = {
761 .name = "s3c-sdhci",
762 .of_match_table = of_match_ptr(sdhci_s3c_dt_match),
763 .pm = &sdhci_s3c_pmops,
767 module_platform_driver(sdhci_s3c_driver);
769 MODULE_DESCRIPTION("Samsung SDHCI (HSMMC) glue");
770 MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
771 MODULE_LICENSE("GPL v2");
772 MODULE_ALIAS("platform:s3c-sdhci");