2 * linux/drivers/mmc/host/tmio_mmc.c
4 * Copyright (C) 2007 Ian Molton
5 * Copyright (C) 2004 Ian Molton
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * Driver for the MMC / SD / SDIO cell found in:
13 * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
16 #include <linux/device.h>
17 #include <linux/mfd/core.h>
18 #include <linux/mfd/tmio.h>
19 #include <linux/mmc/host.h>
20 #include <linux/module.h>
21 #include <linux/pagemap.h>
22 #include <linux/scatterlist.h>
26 #ifdef CONFIG_PM_SLEEP
27 static int tmio_mmc_suspend(struct device *dev)
29 struct platform_device *pdev = to_platform_device(dev);
30 const struct mfd_cell *cell = mfd_get_cell(pdev);
33 ret = pm_runtime_force_suspend(dev);
35 /* Tell MFD core it can disable us now.*/
36 if (!ret && cell->disable)
42 static int tmio_mmc_resume(struct device *dev)
44 struct platform_device *pdev = to_platform_device(dev);
45 const struct mfd_cell *cell = mfd_get_cell(pdev);
48 /* Tell the MFD core we are ready to be enabled */
50 ret = cell->resume(pdev);
53 ret = pm_runtime_force_resume(dev);
59 static int tmio_mmc_probe(struct platform_device *pdev)
61 const struct mfd_cell *cell = mfd_get_cell(pdev);
62 struct tmio_mmc_data *pdata;
63 struct tmio_mmc_host *host;
65 int ret = -EINVAL, irq;
67 if (pdev->num_resources != 2)
70 pdata = pdev->dev.platform_data;
71 if (!pdata || !pdata->hclk)
74 irq = platform_get_irq(pdev, 0);
80 /* Tell the MFD core we are ready to be enabled */
82 ret = cell->enable(pdev);
87 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
91 pdata->flags |= TMIO_MMC_HAVE_HIGH_REG;
93 host = tmio_mmc_host_alloc(pdev);
97 /* SD control register space size is 0x200, 0x400 for bus_shift=1 */
98 host->bus_shift = resource_size(res) >> 10;
100 ret = tmio_mmc_host_probe(host, pdata);
104 ret = request_irq(irq, tmio_mmc_irq, IRQF_TRIGGER_FALLING,
105 dev_name(&pdev->dev), host);
109 pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc),
110 (unsigned long)host->ctl, irq);
115 tmio_mmc_host_remove(host);
117 tmio_mmc_host_free(host);
125 static int tmio_mmc_remove(struct platform_device *pdev)
127 const struct mfd_cell *cell = mfd_get_cell(pdev);
128 struct mmc_host *mmc = platform_get_drvdata(pdev);
131 struct tmio_mmc_host *host = mmc_priv(mmc);
132 free_irq(platform_get_irq(pdev, 0), host);
133 tmio_mmc_host_remove(host);
141 /* ------------------- device registration ----------------------- */
143 static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
144 SET_SYSTEM_SLEEP_PM_OPS(tmio_mmc_suspend, tmio_mmc_resume)
145 SET_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend,
146 tmio_mmc_host_runtime_resume,
150 static struct platform_driver tmio_mmc_driver = {
153 .pm = &tmio_mmc_dev_pm_ops,
155 .probe = tmio_mmc_probe,
156 .remove = tmio_mmc_remove,
159 module_platform_driver(tmio_mmc_driver);
161 MODULE_DESCRIPTION("Toshiba TMIO SD/MMC driver");
162 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
163 MODULE_LICENSE("GPL v2");
164 MODULE_ALIAS("platform:tmio-mmc");