Version:  2.0.40 2.2.26 2.4.37 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16

Linux/drivers/mmc/host/tmio_mmc.c

  1 /*
  2  * linux/drivers/mmc/host/tmio_mmc.c
  3  *
  4  * Copyright (C) 2007 Ian Molton
  5  * Copyright (C) 2004 Ian Molton
  6  *
  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.
 10  *
 11  * Driver for the MMC / SD / SDIO cell found in:
 12  *
 13  * TC6393XB TC6391XB TC6387XB T7L66XB ASIC3
 14  */
 15 
 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>
 23 
 24 #include "tmio_mmc.h"
 25 
 26 #ifdef CONFIG_PM_SLEEP
 27 static int tmio_mmc_suspend(struct device *dev)
 28 {
 29         struct platform_device *pdev = to_platform_device(dev);
 30         const struct mfd_cell *cell = mfd_get_cell(pdev);
 31         int ret;
 32 
 33         ret = tmio_mmc_host_suspend(dev);
 34 
 35         /* Tell MFD core it can disable us now.*/
 36         if (!ret && cell->disable)
 37                 cell->disable(pdev);
 38 
 39         return ret;
 40 }
 41 
 42 static int tmio_mmc_resume(struct device *dev)
 43 {
 44         struct platform_device *pdev = to_platform_device(dev);
 45         const struct mfd_cell *cell = mfd_get_cell(pdev);
 46         int ret = 0;
 47 
 48         /* Tell the MFD core we are ready to be enabled */
 49         if (cell->resume)
 50                 ret = cell->resume(pdev);
 51 
 52         if (!ret)
 53                 ret = tmio_mmc_host_resume(dev);
 54 
 55         return ret;
 56 }
 57 #endif
 58 
 59 static int tmio_mmc_probe(struct platform_device *pdev)
 60 {
 61         const struct mfd_cell *cell = mfd_get_cell(pdev);
 62         struct tmio_mmc_data *pdata;
 63         struct tmio_mmc_host *host;
 64         struct resource *res;
 65         int ret = -EINVAL, irq;
 66 
 67         if (pdev->num_resources != 2)
 68                 goto out;
 69 
 70         pdata = pdev->dev.platform_data;
 71         if (!pdata || !pdata->hclk)
 72                 goto out;
 73 
 74         irq = platform_get_irq(pdev, 0);
 75         if (irq < 0) {
 76                 ret = irq;
 77                 goto out;
 78         }
 79 
 80         /* Tell the MFD core we are ready to be enabled */
 81         if (cell->enable) {
 82                 ret = cell->enable(pdev);
 83                 if (ret)
 84                         goto out;
 85         }
 86 
 87         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 88         if (!res)
 89                 return -EINVAL;
 90 
 91         /* SD control register space size is 0x200, 0x400 for bus_shift=1 */
 92         pdata->bus_shift = resource_size(res) >> 10;
 93         pdata->flags |= TMIO_MMC_HAVE_HIGH_REG;
 94 
 95         ret = tmio_mmc_host_probe(&host, pdev, pdata);
 96         if (ret)
 97                 goto cell_disable;
 98 
 99         ret = request_irq(irq, tmio_mmc_irq, IRQF_TRIGGER_FALLING,
100                                 dev_name(&pdev->dev), host);
101         if (ret)
102                 goto host_remove;
103 
104         pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc),
105                 (unsigned long)host->ctl, irq);
106 
107         return 0;
108 
109 host_remove:
110         tmio_mmc_host_remove(host);
111 cell_disable:
112         if (cell->disable)
113                 cell->disable(pdev);
114 out:
115         return ret;
116 }
117 
118 static int tmio_mmc_remove(struct platform_device *pdev)
119 {
120         const struct mfd_cell *cell = mfd_get_cell(pdev);
121         struct mmc_host *mmc = platform_get_drvdata(pdev);
122 
123         if (mmc) {
124                 struct tmio_mmc_host *host = mmc_priv(mmc);
125                 free_irq(platform_get_irq(pdev, 0), host);
126                 tmio_mmc_host_remove(host);
127                 if (cell->disable)
128                         cell->disable(pdev);
129         }
130 
131         return 0;
132 }
133 
134 /* ------------------- device registration ----------------------- */
135 
136 static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
137         SET_SYSTEM_SLEEP_PM_OPS(tmio_mmc_suspend, tmio_mmc_resume)
138 };
139 
140 static struct platform_driver tmio_mmc_driver = {
141         .driver = {
142                 .name = "tmio-mmc",
143                 .owner = THIS_MODULE,
144                 .pm = &tmio_mmc_dev_pm_ops,
145         },
146         .probe = tmio_mmc_probe,
147         .remove = tmio_mmc_remove,
148 };
149 
150 module_platform_driver(tmio_mmc_driver);
151 
152 MODULE_DESCRIPTION("Toshiba TMIO SD/MMC driver");
153 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
154 MODULE_LICENSE("GPL v2");
155 MODULE_ALIAS("platform:tmio-mmc");
156 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us