x86/uv: Fix uninitialized spinlocks
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / mmc / host / tmio_mmc.c
bloba4ea10242787465d21f99e93e11516d8090cdef1
1 /*
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>
24 #include "tmio_mmc.h"
26 #ifdef CONFIG_PM
27 static int tmio_mmc_suspend(struct platform_device *dev, pm_message_t state)
29 const struct mfd_cell *cell = mfd_get_cell(dev);
30 int ret;
32 ret = tmio_mmc_host_suspend(&dev->dev);
34 /* Tell MFD core it can disable us now.*/
35 if (!ret && cell->disable)
36 cell->disable(dev);
38 return ret;
41 static int tmio_mmc_resume(struct platform_device *dev)
43 const struct mfd_cell *cell = mfd_get_cell(dev);
44 int ret = 0;
46 /* Tell the MFD core we are ready to be enabled */
47 if (cell->resume)
48 ret = cell->resume(dev);
50 if (!ret)
51 ret = tmio_mmc_host_resume(&dev->dev);
53 return ret;
55 #else
56 #define tmio_mmc_suspend NULL
57 #define tmio_mmc_resume NULL
58 #endif
60 static int __devinit tmio_mmc_probe(struct platform_device *pdev)
62 const struct mfd_cell *cell = mfd_get_cell(pdev);
63 struct tmio_mmc_data *pdata;
64 struct tmio_mmc_host *host;
65 int ret = -EINVAL, irq;
67 if (pdev->num_resources != 2)
68 goto out;
70 pdata = pdev->dev.platform_data;
71 if (!pdata || !pdata->hclk)
72 goto out;
74 irq = platform_get_irq(pdev, 0);
75 if (irq < 0) {
76 ret = irq;
77 goto out;
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;
87 ret = tmio_mmc_host_probe(&host, pdev, pdata);
88 if (ret)
89 goto cell_disable;
91 ret = request_irq(irq, tmio_mmc_irq, IRQF_TRIGGER_FALLING,
92 dev_name(&pdev->dev), host);
93 if (ret)
94 goto host_remove;
96 pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc),
97 (unsigned long)host->ctl, irq);
99 return 0;
101 host_remove:
102 tmio_mmc_host_remove(host);
103 cell_disable:
104 if (cell->disable)
105 cell->disable(pdev);
106 out:
107 return ret;
110 static int __devexit tmio_mmc_remove(struct platform_device *pdev)
112 const struct mfd_cell *cell = mfd_get_cell(pdev);
113 struct mmc_host *mmc = platform_get_drvdata(pdev);
115 platform_set_drvdata(pdev, NULL);
117 if (mmc) {
118 struct tmio_mmc_host *host = mmc_priv(mmc);
119 free_irq(platform_get_irq(pdev, 0), host);
120 tmio_mmc_host_remove(host);
121 if (cell->disable)
122 cell->disable(pdev);
125 return 0;
128 /* ------------------- device registration ----------------------- */
130 static struct platform_driver tmio_mmc_driver = {
131 .driver = {
132 .name = "tmio-mmc",
133 .owner = THIS_MODULE,
135 .probe = tmio_mmc_probe,
136 .remove = __devexit_p(tmio_mmc_remove),
137 .suspend = tmio_mmc_suspend,
138 .resume = tmio_mmc_resume,
142 static int __init tmio_mmc_init(void)
144 return platform_driver_register(&tmio_mmc_driver);
147 static void __exit tmio_mmc_exit(void)
149 platform_driver_unregister(&tmio_mmc_driver);
152 module_init(tmio_mmc_init);
153 module_exit(tmio_mmc_exit);
155 MODULE_DESCRIPTION("Toshiba TMIO SD/MMC driver");
156 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
157 MODULE_LICENSE("GPL v2");
158 MODULE_ALIAS("platform:tmio-mmc");