sync hh.org
[hh.org.git] / drivers / soc / tc6387xb.c
blob0afaeb30f769390c5cea4e93af031dcefc476733
1 /*
2 * linux/arch/arm/common/tc6387xb_soc.c
4 * Toshiba TC6387XB support
5 * Copyright (c) 2005 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 * This file contains TC6387XB base support.
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/delay.h>
19 #include <linux/errno.h>
20 #include <linux/ioport.h>
21 #include <linux/device.h>
22 #include <linux/slab.h>
23 #include <linux/spinlock.h>
24 #include <linux/soc/tmio_mmc.h>
26 #include <asm/hardware.h>
27 #include <asm/mach-types.h>
29 #include <soc/tc6387xb.h>
30 #include "soc-core.h"
32 struct tc6387xb_data {
33 int irq;
34 struct tc6387xb_platform_data *platform;
37 static void tc6387xb_hwinit(struct platform_device *dev)
39 struct tc6387xb_data *data = platform_get_drvdata(dev);
41 if (data && data->platform && data->platform->hw_init)
42 data->platform->hw_init();
46 #ifdef CONFIG_PM
48 static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state)
50 struct tc6387xb_data *data = platform_get_drvdata(dev);
52 if (data && data->platform && data->platform->suspend)
53 data->platform->suspend();
55 return 0;
58 static int tc6387xb_resume(struct platform_device *dev)
60 struct tc6387xb_data *data = platform_get_drvdata(dev);
62 if (data && data->platform && data->platform->resume)
63 data->platform->resume();
65 return 0;
67 #endif
69 static struct resource tc6387xb_mmc_resources[] = {
71 .name = "control",
72 .start = TC6387XB_MMC_CTL_BASE,
73 .end = TC6387XB_MMC_CTL_BASE + 0x1ff,
74 .flags = IORESOURCE_MEM,
77 .name = "config",
78 .start = TC6387XB_MMC_CNF_BASE,
79 .end = TC6387XB_MMC_CNF_BASE + 0xff,
80 .flags = IORESOURCE_MEM,
83 .start = TC6387XB_MMC_IRQ,
84 .end = TC6387XB_MMC_IRQ,
85 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_SOC_SUBDEVICE,
89 static struct soc_device_data tc6387xb_devices[] = {
91 .name = "tmio_mmc",
92 .res = tc6387xb_mmc_resources,
93 .num_resources = ARRAY_SIZE(tc6387xb_mmc_resources),
98 static int tc6387xb_probe(struct platform_device *pdev)
100 struct tc6387xb_data *data;
102 data = kmalloc(sizeof(struct tc6387xb_data), GFP_KERNEL);
103 if(!data)
104 return -ENOMEM;
106 data->irq = pdev->resource[1].start;
107 data->platform = pdev->dev.platform_data;
108 platform_set_drvdata(pdev, data);
110 tc6387xb_hwinit(pdev);
112 soc_add_devices(pdev, tc6387xb_devices, ARRAY_SIZE(tc6387xb_devices), &pdev->resource[0], data->irq);
114 /* Init finished. */
115 return 0;
118 static int tc6387xb_remove(struct platform_device *dev)
120 // struct tc6387xb_data *tchip = platform_get_drvdata(dev);
121 // int i;
123 /* Free the subdevice resources */
125 // Free IRQ ?
127 //FIXME - put chip to sleep?
129 /* Free core resources */
131 return 0;
135 static struct platform_driver tc6387xb_platform_driver = {
136 .driver = {
137 .name = "tc6387xb",
139 .probe = tc6387xb_probe,
140 .remove = tc6387xb_remove,
141 #ifdef CONFIG_PM
142 .suspend = tc6387xb_suspend,
143 .resume = tc6387xb_resume,
144 #endif
148 static int __init tc6387xb_init(void)
150 return platform_driver_register (&tc6387xb_platform_driver);
153 static void __exit tc6387xb_exit(void)
155 platform_driver_unregister(&tc6387xb_platform_driver);
158 module_init(tc6387xb_init);
159 module_exit(tc6387xb_exit);
161 MODULE_DESCRIPTION("Toshiba TC6387XB core driver");
162 MODULE_LICENSE("GPL");
163 MODULE_AUTHOR("Ian Molton");