aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2009-02-17 04:06:41 -0500
committerSamuel Ortiz <samuel@sortiz.org>2009-04-04 18:32:20 -0400
commita23a175795cdb202619ac176129b2f0c2a5c9456 (patch)
treed3b03c863d501a107eaefffeb733179b19315327
parent3206450355100eae8e033645318b95bb60f1faff (diff)
mfd: convert DS1WM to use MFD core
This patch converts the DS1WM driver into an MFD cell. It also calculates the bus_shift parameter from the memory resource size. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
-rw-r--r--drivers/w1/masters/ds1wm.c31
-rw-r--r--include/linux/ds1wm.h12
-rw-r--r--include/linux/mfd/ds1wm.h5
3 files changed, 25 insertions, 23 deletions
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index 29e144f81cbe..f1e6b3dd1e43 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -19,7 +19,8 @@
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/ds1wm.h> 22#include <linux/mfd/core.h>
23#include <linux/mfd/ds1wm.h>
23 24
24#include <asm/io.h> 25#include <asm/io.h>
25 26
@@ -89,7 +90,7 @@ struct ds1wm_data {
89 void __iomem *map; 90 void __iomem *map;
90 int bus_shift; /* # of shifts to calc register offsets */ 91 int bus_shift; /* # of shifts to calc register offsets */
91 struct platform_device *pdev; 92 struct platform_device *pdev;
92 struct ds1wm_platform_data *pdata; 93 struct mfd_cell *cell;
93 int irq; 94 int irq;
94 int active_high; 95 int active_high;
95 struct clk *clk; 96 struct clk *clk;
@@ -217,8 +218,8 @@ static void ds1wm_up(struct ds1wm_data *ds1wm_data)
217{ 218{
218 int gclk, divisor; 219 int gclk, divisor;
219 220
220 if (ds1wm_data->pdata->enable) 221 if (ds1wm_data->cell->enable)
221 ds1wm_data->pdata->enable(ds1wm_data->pdev); 222 ds1wm_data->cell->enable(ds1wm_data->pdev);
222 223
223 gclk = clk_get_rate(ds1wm_data->clk); 224 gclk = clk_get_rate(ds1wm_data->clk);
224 clk_enable(ds1wm_data->clk); 225 clk_enable(ds1wm_data->clk);
@@ -244,8 +245,8 @@ static void ds1wm_down(struct ds1wm_data *ds1wm_data)
244 ds1wm_write_register(ds1wm_data, DS1WM_INT_EN, 245 ds1wm_write_register(ds1wm_data, DS1WM_INT_EN,
245 ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0); 246 ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0);
246 247
247 if (ds1wm_data->pdata->disable) 248 if (ds1wm_data->cell->disable)
248 ds1wm_data->pdata->disable(ds1wm_data->pdev); 249 ds1wm_data->cell->disable(ds1wm_data->pdev);
249 250
250 clk_disable(ds1wm_data->clk); 251 clk_disable(ds1wm_data->clk);
251} 252}
@@ -330,13 +331,18 @@ static struct w1_bus_master ds1wm_master = {
330static int ds1wm_probe(struct platform_device *pdev) 331static int ds1wm_probe(struct platform_device *pdev)
331{ 332{
332 struct ds1wm_data *ds1wm_data; 333 struct ds1wm_data *ds1wm_data;
333 struct ds1wm_platform_data *plat; 334 struct ds1wm_driver_data *plat;
334 struct resource *res; 335 struct resource *res;
336 struct mfd_cell *cell;
335 int ret; 337 int ret;
336 338
337 if (!pdev) 339 if (!pdev)
338 return -ENODEV; 340 return -ENODEV;
339 341
342 cell = pdev->dev.platform_data;
343 if (!cell)
344 return -ENODEV;
345
340 ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL); 346 ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL);
341 if (!ds1wm_data) 347 if (!ds1wm_data)
342 return -ENOMEM; 348 return -ENOMEM;
@@ -348,15 +354,18 @@ static int ds1wm_probe(struct platform_device *pdev)
348 ret = -ENXIO; 354 ret = -ENXIO;
349 goto err0; 355 goto err0;
350 } 356 }
351 ds1wm_data->map = ioremap(res->start, res->end - res->start + 1); 357 ds1wm_data->map = ioremap(res->start, resource_size(res));
352 if (!ds1wm_data->map) { 358 if (!ds1wm_data->map) {
353 ret = -ENOMEM; 359 ret = -ENOMEM;
354 goto err0; 360 goto err0;
355 } 361 }
356 plat = pdev->dev.platform_data; 362 plat = cell->driver_data;
357 ds1wm_data->bus_shift = plat->bus_shift; 363
364 /* calculate bus shift from mem resource */
365 ds1wm_data->bus_shift = resource_size(res) >> 3;
366
358 ds1wm_data->pdev = pdev; 367 ds1wm_data->pdev = pdev;
359 ds1wm_data->pdata = plat; 368 ds1wm_data->cell = cell;
360 369
361 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 370 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
362 if (!res) { 371 if (!res) {
diff --git a/include/linux/ds1wm.h b/include/linux/ds1wm.h
deleted file mode 100644
index d3c65e48a2e7..000000000000
--- a/include/linux/ds1wm.h
+++ /dev/null
@@ -1,12 +0,0 @@
1/* platform data for the DS1WM driver */
2
3struct ds1wm_platform_data {
4 int bus_shift; /* number of shifts needed to calculate the
5 * offset between DS1WM registers;
6 * e.g. on h5xxx and h2200 this is 2
7 * (registers aligned to 4-byte boundaries),
8 * while on hx4700 this is 1 */
9 int active_high;
10 void (*enable)(struct platform_device *pdev);
11 void (*disable)(struct platform_device *pdev);
12};
diff --git a/include/linux/mfd/ds1wm.h b/include/linux/mfd/ds1wm.h
new file mode 100644
index 000000000000..d4898ba18207
--- /dev/null
+++ b/include/linux/mfd/ds1wm.h
@@ -0,0 +1,5 @@
1/* MFD cell driver data for the DS1WM driver */
2
3struct ds1wm_driver_data {
4 int active_high;
5};