Blame view
drivers/mfd/tc6387xb.c
5.49 KB
cbdfb4263 mfd: driver for t... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/* * Toshiba TC6387XB support * Copyright (c) 2005 Ian Molton * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This file contains TC6387XB base support. * */ #include <linux/module.h> #include <linux/platform_device.h> |
7acb706ca mfd: update TMIO ... |
15 |
#include <linux/clk.h> |
cbdfb4263 mfd: driver for t... |
16 17 18 19 |
#include <linux/err.h> #include <linux/mfd/core.h> #include <linux/mfd/tmio.h> #include <linux/mfd/tc6387xb.h> |
5a0e3ad6a include cleanup: ... |
20 |
#include <linux/slab.h> |
cbdfb4263 mfd: driver for t... |
21 |
|
d2432a632 mfd: tc6387 MMC p... |
22 23 24 |
enum { TC6387XB_CELL_MMC, }; |
64e8867ba mfd: tmio_mmc har... |
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
struct tc6387xb { void __iomem *scr; struct clk *clk32k; struct resource rscr; }; static struct resource tc6387xb_mmc_resources[] = { { .start = 0x800, .end = 0x9ff, .flags = IORESOURCE_MEM, }, { .start = 0, .end = 0, .flags = IORESOURCE_IRQ, }, }; /*--------------------------------------------------------------------------*/ |
cbdfb4263 mfd: driver for t... |
45 46 47 |
#ifdef CONFIG_PM static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) { |
64e8867ba mfd: tmio_mmc har... |
48 |
struct tc6387xb *tc6387xb = platform_get_drvdata(dev); |
7acb706ca mfd: update TMIO ... |
49 |
struct tc6387xb_platform_data *pdata = dev->dev.platform_data; |
cbdfb4263 mfd: driver for t... |
50 51 52 |
if (pdata && pdata->suspend) pdata->suspend(dev); |
64e8867ba mfd: tmio_mmc har... |
53 |
clk_disable(tc6387xb->clk32k); |
cbdfb4263 mfd: driver for t... |
54 55 56 57 58 59 |
return 0; } static int tc6387xb_resume(struct platform_device *dev) { |
64e8867ba mfd: tmio_mmc har... |
60 |
struct tc6387xb *tc6387xb = platform_get_drvdata(dev); |
7acb706ca mfd: update TMIO ... |
61 |
struct tc6387xb_platform_data *pdata = dev->dev.platform_data; |
cbdfb4263 mfd: driver for t... |
62 |
|
64e8867ba mfd: tmio_mmc har... |
63 |
clk_enable(tc6387xb->clk32k); |
cbdfb4263 mfd: driver for t... |
64 65 |
if (pdata && pdata->resume) pdata->resume(dev); |
64e8867ba mfd: tmio_mmc har... |
66 67 |
tmio_core_mmc_resume(tc6387xb->scr + 0x200, 0, tc6387xb_mmc_resources[0].start & 0xfffe); |
cbdfb4263 mfd: driver for t... |
68 69 70 71 72 73 74 75 |
return 0; } #else #define tc6387xb_suspend NULL #define tc6387xb_resume NULL #endif /*--------------------------------------------------------------------------*/ |
64e8867ba mfd: tmio_mmc har... |
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
static void tc6387xb_mmc_pwr(struct platform_device *mmc, int state) { struct platform_device *dev = to_platform_device(mmc->dev.parent); struct tc6387xb *tc6387xb = platform_get_drvdata(dev); tmio_core_mmc_pwr(tc6387xb->scr + 0x200, 0, state); } static void tc6387xb_mmc_clk_div(struct platform_device *mmc, int state) { struct platform_device *dev = to_platform_device(mmc->dev.parent); struct tc6387xb *tc6387xb = platform_get_drvdata(dev); tmio_core_mmc_clk_div(tc6387xb->scr + 0x200, 0, state); } |
cbdfb4263 mfd: driver for t... |
91 92 93 |
static int tc6387xb_mmc_enable(struct platform_device *mmc) { struct platform_device *dev = to_platform_device(mmc->dev.parent); |
64e8867ba mfd: tmio_mmc har... |
94 |
struct tc6387xb *tc6387xb = platform_get_drvdata(dev); |
cbdfb4263 mfd: driver for t... |
95 |
|
64e8867ba mfd: tmio_mmc har... |
96 97 98 99 |
clk_enable(tc6387xb->clk32k); tmio_core_mmc_enable(tc6387xb->scr + 0x200, 0, tc6387xb_mmc_resources[0].start & 0xfffe); |
cbdfb4263 mfd: driver for t... |
100 101 102 103 104 105 106 |
return 0; } static int tc6387xb_mmc_disable(struct platform_device *mmc) { struct platform_device *dev = to_platform_device(mmc->dev.parent); |
64e8867ba mfd: tmio_mmc har... |
107 |
struct tc6387xb *tc6387xb = platform_get_drvdata(dev); |
cbdfb4263 mfd: driver for t... |
108 |
|
64e8867ba mfd: tmio_mmc har... |
109 |
clk_disable(tc6387xb->clk32k); |
cbdfb4263 mfd: driver for t... |
110 111 112 |
return 0; } |
4d3792e05 mfd: fix tmio rel... |
113 |
static struct tmio_mmc_data tc6387xb_mmc_data = { |
f0e46cc49 MFD,mmc: tmio_mmc... |
114 |
.hclk = 24000000, |
64e8867ba mfd: tmio_mmc har... |
115 116 |
.set_pwr = tc6387xb_mmc_pwr, .set_clk_div = tc6387xb_mmc_clk_div, |
f0e46cc49 MFD,mmc: tmio_mmc... |
117 |
}; |
64e8867ba mfd: tmio_mmc har... |
118 |
/*--------------------------------------------------------------------------*/ |
cbdfb4263 mfd: driver for t... |
119 120 |
static struct mfd_cell tc6387xb_cells[] = { |
d2432a632 mfd: tc6387 MMC p... |
121 |
[TC6387XB_CELL_MMC] = { |
cbdfb4263 mfd: driver for t... |
122 123 124 |
.name = "tmio-mmc", .enable = tc6387xb_mmc_enable, .disable = tc6387xb_mmc_disable, |
ec71974f2 mmc: Use device p... |
125 126 |
.platform_data = &tc6387xb_mmc_data, .pdata_size = sizeof(tc6387xb_mmc_data), |
cbdfb4263 mfd: driver for t... |
127 128 129 130 |
.num_resources = ARRAY_SIZE(tc6387xb_mmc_resources), .resources = tc6387xb_mmc_resources, }, }; |
288129f35 mfd: Annotate tc6... |
131 |
static int __devinit tc6387xb_probe(struct platform_device *dev) |
cbdfb4263 mfd: driver for t... |
132 |
{ |
7acb706ca mfd: update TMIO ... |
133 |
struct tc6387xb_platform_data *pdata = dev->dev.platform_data; |
64e8867ba mfd: tmio_mmc har... |
134 |
struct resource *iomem, *rscr; |
7acb706ca mfd: update TMIO ... |
135 |
struct clk *clk32k; |
64e8867ba mfd: tmio_mmc har... |
136 |
struct tc6387xb *tc6387xb; |
cbdfb4263 mfd: driver for t... |
137 138 139 140 |
int irq, ret; iomem = platform_get_resource(dev, IORESOURCE_MEM, 0); if (!iomem) { |
7acb706ca mfd: update TMIO ... |
141 |
return -EINVAL; |
cbdfb4263 mfd: driver for t... |
142 |
} |
64e8867ba mfd: tmio_mmc har... |
143 144 145 |
tc6387xb = kzalloc(sizeof *tc6387xb, GFP_KERNEL); if (!tc6387xb) return -ENOMEM; |
cbdfb4263 mfd: driver for t... |
146 147 148 149 |
ret = platform_get_irq(dev, 0); if (ret >= 0) irq = ret; else |
64e8867ba mfd: tmio_mmc har... |
150 |
goto err_no_irq; |
cbdfb4263 mfd: driver for t... |
151 |
|
7acb706ca mfd: update TMIO ... |
152 153 154 |
clk32k = clk_get(&dev->dev, "CLK_CK32K"); if (IS_ERR(clk32k)) { ret = PTR_ERR(clk32k); |
64e8867ba mfd: tmio_mmc har... |
155 156 157 158 159 160 161 162 163 164 165 |
goto err_no_clk; } rscr = &tc6387xb->rscr; rscr->name = "tc6387xb-core"; rscr->start = iomem->start; rscr->end = iomem->start + 0xff; rscr->flags = IORESOURCE_MEM; ret = request_resource(iomem, rscr); if (ret) |
7acb706ca mfd: update TMIO ... |
166 |
goto err_resource; |
64e8867ba mfd: tmio_mmc har... |
167 |
|
28f65c11f treewide: Convert... |
168 |
tc6387xb->scr = ioremap(rscr->start, resource_size(rscr)); |
64e8867ba mfd: tmio_mmc har... |
169 170 171 |
if (!tc6387xb->scr) { ret = -ENOMEM; goto err_ioremap; |
7acb706ca mfd: update TMIO ... |
172 |
} |
64e8867ba mfd: tmio_mmc har... |
173 174 175 |
tc6387xb->clk32k = clk32k; platform_set_drvdata(dev, tc6387xb); |
7acb706ca mfd: update TMIO ... |
176 177 178 |
if (pdata && pdata->enable) pdata->enable(dev); |
cbdfb4263 mfd: driver for t... |
179 180 181 |
printk(KERN_INFO "Toshiba tc6387xb initialised "); |
56bf2bda0 mfd: Fix 7l66 and... |
182 183 |
ret = mfd_add_devices(&dev->dev, dev->id, tc6387xb_cells, ARRAY_SIZE(tc6387xb_cells), iomem, irq); |
cbdfb4263 mfd: driver for t... |
184 185 186 |
if (!ret) return 0; |
08b877b80 mfd: Fix tc6387xb... |
187 |
iounmap(tc6387xb->scr); |
64e8867ba mfd: tmio_mmc har... |
188 189 |
err_ioremap: release_resource(&tc6387xb->rscr); |
cbdfb4263 mfd: driver for t... |
190 |
err_resource: |
64e8867ba mfd: tmio_mmc har... |
191 192 193 194 |
clk_put(clk32k); err_no_clk: err_no_irq: kfree(tc6387xb); |
cbdfb4263 mfd: driver for t... |
195 196 |
return ret; } |
288129f35 mfd: Annotate tc6... |
197 |
static int __devexit tc6387xb_remove(struct platform_device *dev) |
cbdfb4263 mfd: driver for t... |
198 |
{ |
08b877b80 mfd: Fix tc6387xb... |
199 |
struct tc6387xb *tc6387xb = platform_get_drvdata(dev); |
cbdfb4263 mfd: driver for t... |
200 |
|
7acb706ca mfd: update TMIO ... |
201 |
mfd_remove_devices(&dev->dev); |
08b877b80 mfd: Fix tc6387xb... |
202 203 204 205 |
iounmap(tc6387xb->scr); release_resource(&tc6387xb->rscr); clk_disable(tc6387xb->clk32k); clk_put(tc6387xb->clk32k); |
7acb706ca mfd: update TMIO ... |
206 |
platform_set_drvdata(dev, NULL); |
08b877b80 mfd: Fix tc6387xb... |
207 |
kfree(tc6387xb); |
cbdfb4263 mfd: driver for t... |
208 209 210 211 212 213 214 215 216 217 |
return 0; } static struct platform_driver tc6387xb_platform_driver = { .driver = { .name = "tc6387xb", }, .probe = tc6387xb_probe, |
288129f35 mfd: Annotate tc6... |
218 |
.remove = __devexit_p(tc6387xb_remove), |
cbdfb4263 mfd: driver for t... |
219 220 221 |
.suspend = tc6387xb_suspend, .resume = tc6387xb_resume, }; |
65349d60d mfd: Convert MFD ... |
222 |
module_platform_driver(tc6387xb_platform_driver); |
cbdfb4263 mfd: driver for t... |
223 224 225 226 227 |
MODULE_DESCRIPTION("Toshiba TC6387XB core driver"); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Ian Molton"); MODULE_ALIAS("platform:tc6387xb"); |
64e8867ba mfd: tmio_mmc har... |
228 |