2 * Toshiba TC6387XB support
3 * Copyright (c) 2005 Ian Molton
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This file contains TC6387XB base support.
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <linux/err.h>
16 #include <linux/mfd/core.h>
17 #include <linux/mfd/tmio.h>
18 #include <linux/mfd/tc6387xb.h>
21 static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state)
23 struct tc6387xb_platform_data *pdata = platform_get_drvdata(dev);
25 if (pdata && pdata->suspend)
31 static int tc6387xb_resume(struct platform_device *dev)
33 struct tc6387xb_platform_data *pdata = platform_get_drvdata(dev);
35 if (pdata && pdata->resume)
41 #define tc6387xb_suspend NULL
42 #define tc6387xb_resume NULL
45 /*--------------------------------------------------------------------------*/
47 static int tc6387xb_mmc_enable(struct platform_device *mmc)
49 struct platform_device *dev = to_platform_device(mmc->dev.parent);
50 struct tc6387xb_platform_data *tc6387xb = dev->dev.platform_data;
52 if (tc6387xb->enable_clk32k)
53 tc6387xb->enable_clk32k(dev);
58 static int tc6387xb_mmc_disable(struct platform_device *mmc)
60 struct platform_device *dev = to_platform_device(mmc->dev.parent);
61 struct tc6387xb_platform_data *tc6387xb = dev->dev.platform_data;
63 if (tc6387xb->disable_clk32k)
64 tc6387xb->disable_clk32k(dev);
69 /*--------------------------------------------------------------------------*/
71 static struct resource tc6387xb_mmc_resources[] = {
75 .flags = IORESOURCE_MEM,
80 .flags = IORESOURCE_MEM,
85 .flags = IORESOURCE_IRQ,
89 static struct mfd_cell tc6387xb_cells[] = {
92 .enable = tc6387xb_mmc_enable,
93 .disable = tc6387xb_mmc_disable,
94 .num_resources = ARRAY_SIZE(tc6387xb_mmc_resources),
95 .resources = tc6387xb_mmc_resources,
99 static int tc6387xb_probe(struct platform_device *dev)
101 struct tc6387xb_platform_data *data = platform_get_drvdata(dev);
102 struct resource *iomem;
105 iomem = platform_get_resource(dev, IORESOURCE_MEM, 0);
111 ret = platform_get_irq(dev, 0);
117 if (data && data->enable)
120 printk(KERN_INFO "Toshiba tc6387xb initialised\n");
122 ret = mfd_add_devices(&dev->dev, dev->id, tc6387xb_cells,
123 ARRAY_SIZE(tc6387xb_cells), iomem, irq);
132 static int tc6387xb_remove(struct platform_device *dev)
134 struct tc6387xb_platform_data *data = platform_get_drvdata(dev);
136 if (data && data->disable)
139 /* FIXME - free the resources! */
145 static struct platform_driver tc6387xb_platform_driver = {
149 .probe = tc6387xb_probe,
150 .remove = tc6387xb_remove,
151 .suspend = tc6387xb_suspend,
152 .resume = tc6387xb_resume,
156 static int __init tc6387xb_init(void)
158 return platform_driver_register(&tc6387xb_platform_driver);
161 static void __exit tc6387xb_exit(void)
163 platform_driver_unregister(&tc6387xb_platform_driver);
166 module_init(tc6387xb_init);
167 module_exit(tc6387xb_exit);
169 MODULE_DESCRIPTION("Toshiba TC6387XB core driver");
170 MODULE_LICENSE("GPL v2");
171 MODULE_AUTHOR("Ian Molton");
172 MODULE_ALIAS("platform:tc6387xb");