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/clk.h>
16 #include <linux/err.h>
17 #include <linux/mfd/core.h>
18 #include <linux/mfd/tmio.h>
19 #include <linux/mfd/tc6387xb.h>
26 static int tc6387xb_suspend(struct platform_device
*dev
, pm_message_t state
)
28 struct clk
*clk32k
= platform_get_drvdata(dev
);
29 struct tc6387xb_platform_data
*pdata
= dev
->dev
.platform_data
;
31 if (pdata
&& pdata
->suspend
)
38 static int tc6387xb_resume(struct platform_device
*dev
)
40 struct clk
*clk32k
= platform_get_drvdata(dev
);
41 struct tc6387xb_platform_data
*pdata
= dev
->dev
.platform_data
;
44 if (pdata
&& pdata
->resume
)
50 #define tc6387xb_suspend NULL
51 #define tc6387xb_resume NULL
54 /*--------------------------------------------------------------------------*/
56 static int tc6387xb_mmc_enable(struct platform_device
*mmc
)
58 struct platform_device
*dev
= to_platform_device(mmc
->dev
.parent
);
59 struct clk
*clk32k
= platform_get_drvdata(dev
);
66 static int tc6387xb_mmc_disable(struct platform_device
*mmc
)
68 struct platform_device
*dev
= to_platform_device(mmc
->dev
.parent
);
69 struct clk
*clk32k
= platform_get_drvdata(dev
);
76 /*--------------------------------------------------------------------------*/
78 static struct tmio_mmc_data tc6387xb_mmc_data
= {
82 static struct resource tc6387xb_mmc_resources
[] = {
86 .flags
= IORESOURCE_MEM
,
91 .flags
= IORESOURCE_MEM
,
96 .flags
= IORESOURCE_IRQ
,
100 static struct mfd_cell tc6387xb_cells
[] = {
101 [TC6387XB_CELL_MMC
] = {
103 .enable
= tc6387xb_mmc_enable
,
104 .disable
= tc6387xb_mmc_disable
,
105 .driver_data
= &tc6387xb_mmc_data
,
106 .num_resources
= ARRAY_SIZE(tc6387xb_mmc_resources
),
107 .resources
= tc6387xb_mmc_resources
,
111 static int tc6387xb_probe(struct platform_device
*dev
)
113 struct tc6387xb_platform_data
*pdata
= dev
->dev
.platform_data
;
114 struct resource
*iomem
;
118 iomem
= platform_get_resource(dev
, IORESOURCE_MEM
, 0);
123 ret
= platform_get_irq(dev
, 0);
129 clk32k
= clk_get(&dev
->dev
, "CLK_CK32K");
130 if (IS_ERR(clk32k
)) {
131 ret
= PTR_ERR(clk32k
);
134 platform_set_drvdata(dev
, clk32k
);
136 if (pdata
&& pdata
->enable
)
139 printk(KERN_INFO
"Toshiba tc6387xb initialised\n");
141 tc6387xb_cells
[TC6387XB_CELL_MMC
].platform_data
=
142 &tc6387xb_cells
[TC6387XB_CELL_MMC
];
143 tc6387xb_cells
[TC6387XB_CELL_MMC
].data_size
=
144 sizeof(tc6387xb_cells
[TC6387XB_CELL_MMC
]);
146 ret
= mfd_add_devices(&dev
->dev
, dev
->id
, tc6387xb_cells
,
147 ARRAY_SIZE(tc6387xb_cells
), iomem
, irq
);
157 static int tc6387xb_remove(struct platform_device
*dev
)
159 struct clk
*clk32k
= platform_get_drvdata(dev
);
161 mfd_remove_devices(&dev
->dev
);
164 platform_set_drvdata(dev
, NULL
);
170 static struct platform_driver tc6387xb_platform_driver
= {
174 .probe
= tc6387xb_probe
,
175 .remove
= tc6387xb_remove
,
176 .suspend
= tc6387xb_suspend
,
177 .resume
= tc6387xb_resume
,
181 static int __init
tc6387xb_init(void)
183 return platform_driver_register(&tc6387xb_platform_driver
);
186 static void __exit
tc6387xb_exit(void)
188 platform_driver_unregister(&tc6387xb_platform_driver
);
191 module_init(tc6387xb_init
);
192 module_exit(tc6387xb_exit
);
194 MODULE_DESCRIPTION("Toshiba TC6387XB core driver");
195 MODULE_LICENSE("GPL v2");
196 MODULE_AUTHOR("Ian Molton");
197 MODULE_ALIAS("platform:tc6387xb");