include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / arm / mach-integrator / impd1.c
index a85d471..41b1072 100644 (file)
 #include <linux/mm.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
+#include <linux/io.h>
+#include <linux/slab.h>
 
-#include <asm/io.h>
+#include <asm/clkdev.h>
+#include <mach/clkdev.h>
 #include <asm/hardware/icst525.h>
-#include <asm/arch/lm.h>
-#include <asm/arch/impd1.h>
+#include <mach/lm.h>
+#include <mach/impd1.h>
 #include <asm/sizes.h>
 
-#include "clock.h"
-
 static int module_id;
 
 module_param_named(lmid, module_id, int, 0444);
@@ -37,6 +38,7 @@ MODULE_PARM_DESC(lmid, "logic module stack position");
 struct impd1_module {
        void __iomem    *base;
        struct clk      vcos[2];
+       struct clk_lookup *clks[3];
 };
 
 static const struct icst525_params impd1_vco_params = {
@@ -339,9 +341,8 @@ static struct impd1_device impd1_devs[] = {
        }
 };
 
-static const char *impd1_vconames[2] = {
-       "CLCDCLK",
-       "AUXVCO2",
+static struct clk fixed_14745600 = {
+       .rate = 14745600,
 };
 
 static int impd1_probe(struct lm_device *dev)
@@ -355,12 +356,11 @@ static int impd1_probe(struct lm_device *dev)
        if (!request_mem_region(dev->resource.start, SZ_4K, "LM registers"))
                return -EBUSY;
 
-       impd1 = kmalloc(sizeof(struct impd1_module), GFP_KERNEL);
+       impd1 = kzalloc(sizeof(struct impd1_module), GFP_KERNEL);
        if (!impd1) {
                ret = -ENOMEM;
                goto release_lm;
        }
-       memset(impd1, 0, sizeof(struct impd1_module));
 
        impd1->base = ioremap(dev->resource.start, SZ_4K);
        if (!impd1->base) {
@@ -370,18 +370,25 @@ static int impd1_probe(struct lm_device *dev)
 
        lm_set_drvdata(dev, impd1);
 
-       printk("IM-PD1 found at 0x%08lx\n", dev->resource.start);
+       printk("IM-PD1 found at 0x%08lx\n",
+               (unsigned long)dev->resource.start);
 
        for (i = 0; i < ARRAY_SIZE(impd1->vcos); i++) {
                impd1->vcos[i].owner = THIS_MODULE,
-               impd1->vcos[i].name = impd1_vconames[i],
                impd1->vcos[i].params = &impd1_vco_params,
                impd1->vcos[i].data = impd1,
                impd1->vcos[i].setvco = impd1_setvco;
-
-               clk_register(&impd1->vcos[i]);
        }
 
+       impd1->clks[0] = clkdev_alloc(&impd1->vcos[0], NULL, "lm%x:01000",
+                                       dev->id);
+       impd1->clks[1] = clkdev_alloc(&fixed_14745600, NULL, "lm%x:00100",
+                                       dev->id);
+       impd1->clks[2] = clkdev_alloc(&fixed_14745600, NULL, "lm%x:00200",
+                                       dev->id);
+       for (i = 0; i < ARRAY_SIZE(impd1->clks); i++)
+               clkdev_add(impd1->clks[i]);
+
        for (i = 0; i < ARRAY_SIZE(impd1_devs); i++) {
                struct impd1_device *idev = impd1_devs + i;
                struct amba_device *d;
@@ -389,15 +396,11 @@ static int impd1_probe(struct lm_device *dev)
 
                pc_base = dev->resource.start + idev->offset;
 
-               d = kmalloc(sizeof(struct amba_device), GFP_KERNEL);
+               d = kzalloc(sizeof(struct amba_device), GFP_KERNEL);
                if (!d)
                        continue;
 
-               memset(d, 0, sizeof(struct amba_device));
-
-               snprintf(d->dev.bus_id, sizeof(d->dev.bus_id),
-                        "lm%x:%5.5lx", dev->id, idev->offset >> 12);
-
+               dev_set_name(&d->dev, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
                d->dev.parent   = &dev->dev;
                d->res.start    = dev->resource.start + idev->offset;
                d->res.end      = d->res.start + SZ_4K - 1;
@@ -409,8 +412,7 @@ static int impd1_probe(struct lm_device *dev)
 
                ret = amba_device_register(d, &dev->resource);
                if (ret) {
-                       printk("unable to register device %s: %d\n",
-                               d->dev.bus_id, ret);
+                       dev_err(&d->dev, "unable to register device: %d\n", ret);
                        kfree(d);
                }
        }
@@ -439,8 +441,8 @@ static void impd1_remove(struct lm_device *dev)
 
        device_for_each_child(&dev->dev, NULL, impd1_remove_one);
 
-       for (i = 0; i < ARRAY_SIZE(impd1->vcos); i++)
-               clk_unregister(&impd1->vcos[i]);
+       for (i = 0; i < ARRAY_SIZE(impd1->clks); i++)
+               clkdev_drop(impd1->clks[i]);
 
        lm_set_drvdata(dev, NULL);