m68knommu: fix MC68328.h defines
[linux-3.10.git] / arch / arm / mach-integrator / impd1.c
index a4bafee..9f82f9d 100644 (file)
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/mm.h>
-
-#include <asm/io.h>
-#include <asm/hardware/icst525.h>
-#include <asm/hardware/amba.h>
-#include <asm/hardware/amba_clcd.h>
-#include <asm/arch/lm.h>
-#include <asm/arch/impd1.h>
+#include <linux/amba/bus.h>
+#include <linux/amba/clcd.h>
+#include <linux/io.h>
+#include <linux/platform_data/clk-integrator.h>
+#include <linux/slab.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);
@@ -36,47 +35,8 @@ MODULE_PARM_DESC(lmid, "logic module stack position");
 
 struct impd1_module {
        void __iomem    *base;
-       struct clk      vcos[2];
 };
 
-static const struct icst525_params impd1_vco_params = {
-       .ref            = 24000,        /* 24 MHz */
-       .vco_max        = 200000,       /* 200 MHz */
-       .vd_min         = 12,
-       .vd_max         = 519,
-       .rd_min         = 3,
-       .rd_max         = 120,
-};
-
-static void impd1_setvco(struct clk *clk, struct icst525_vco vco)
-{
-       struct impd1_module *impd1 = clk->data;
-       int vconr = clk - impd1->vcos;
-       u32 val;
-
-       val = vco.v | (vco.r << 9) | (vco.s << 16);
-
-       writel(0xa05f, impd1->base + IMPD1_LOCK);
-       switch (vconr) {
-       case 0:
-               writel(val, impd1->base + IMPD1_OSC1);
-               break;
-       case 1:
-               writel(val, impd1->base + IMPD1_OSC2);
-               break;
-       }
-       writel(0, impd1->base + IMPD1_LOCK);
-
-#ifdef DEBUG
-       vco.v = val & 0x1ff;
-       vco.r = (val >> 9) & 0x7f;
-       vco.s = (val >> 16) & 7;
-
-       pr_debug("IM-PD1: VCO%d clock is %ld kHz\n",
-                vconr, icst525_khz(&impd1_vco_params, vco));
-#endif
-}
-
 void impd1_tweak_control(struct device *dev, u32 mask, u32 val)
 {
        struct impd1_module *impd1 = dev_get_drvdata(dev);
@@ -121,6 +81,7 @@ static struct clcd_panel vga = {
        .height         = -1,
        .tim2           = TIM2_BCD | TIM2_IPC,
        .cntl           = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
+       .caps           = CLCD_CAP_5551,
        .connector      = IMPD1_CTRL_DISP_VGA,
        .bpp            = 16,
        .grayscale      = 0,
@@ -149,6 +110,7 @@ static struct clcd_panel svga = {
        .tim2           = TIM2_BCD,
        .cntl           = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
        .connector      = IMPD1_CTRL_DISP_VGA,
+       .caps           = CLCD_CAP_5551,
        .bpp            = 16,
        .grayscale      = 0,
 };
@@ -175,6 +137,7 @@ static struct clcd_panel prospector = {
        .height         = -1,
        .tim2           = TIM2_BCD,
        .cntl           = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
+       .caps           = CLCD_CAP_5551,
        .fixedtimings   = 1,
        .connector      = IMPD1_CTRL_DISP_LCD,
        .bpp            = 16,
@@ -206,6 +169,7 @@ static struct clcd_panel ltm10c209 = {
        .height         = -1,
        .tim2           = TIM2_BCD,
        .cntl           = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
+       .caps           = CLCD_CAP_5551,
        .fixedtimings   = 1,
        .connector      = IMPD1_CTRL_DISP_LCD,
        .bpp            = 16,
@@ -279,6 +243,7 @@ static void impd1fb_clcd_remove(struct clcd_fb *fb)
 
 static struct clcd_board impd1_clcd_data = {
        .name           = "IM-PD/1",
+       .caps           = CLCD_CAP_5551 | CLCD_CAP_888,
        .check          = clcdfb_check,
        .decode         = clcdfb_decode,
        .disable        = impd1fb_clcd_disable,
@@ -339,11 +304,6 @@ static struct impd1_device impd1_devs[] = {
        }
 };
 
-static const char *impd1_vconames[2] = {
-       "CLCDCLK",
-       "AUXVCO2",
-};
-
 static int impd1_probe(struct lm_device *dev)
 {
        struct impd1_module *impd1;
@@ -355,12 +315,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,48 +329,26 @@ 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]);
-       }
+       integrator_impd1_clk_init(impd1->base, dev->id);
 
        for (i = 0; i < ARRAY_SIZE(impd1_devs); i++) {
                struct impd1_device *idev = impd1_devs + i;
                struct amba_device *d;
                unsigned long pc_base;
+               char devname[32];
 
                pc_base = dev->resource.start + idev->offset;
-
-               d = kmalloc(sizeof(struct amba_device), GFP_KERNEL);
-               if (!d)
+               snprintf(devname, 32, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
+               d = amba_ahb_device_add_res(&dev->dev, devname, pc_base, SZ_4K,
+                                           dev->irq, dev->irq,
+                                           idev->platform_data, idev->id,
+                                           &dev->resource);
+               if (IS_ERR(d)) {
+                       dev_err(&dev->dev, "unable to register device: %ld\n", PTR_ERR(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);
-
-               d->dev.parent   = &dev->dev;
-               d->res.start    = dev->resource.start + idev->offset;
-               d->res.end      = d->res.start + SZ_4K - 1;
-               d->res.flags    = IORESOURCE_MEM;
-               d->irq[0]       = dev->irq;
-               d->irq[1]       = dev->irq;
-               d->periphid     = idev->id;
-               d->dev.platform_data = idev->platform_data;
-
-               ret = amba_device_register(d, &dev->resource);
-               if (ret) {
-                       printk("unable to register device %s: %d\n",
-                               d->dev.bus_id, ret);
-                       kfree(d);
                }
        }
 
@@ -435,12 +372,9 @@ static int impd1_remove_one(struct device *dev, void *data)
 static void impd1_remove(struct lm_device *dev)
 {
        struct impd1_module *impd1 = lm_get_drvdata(dev);
-       int i;
 
        device_for_each_child(&dev->dev, NULL, impd1_remove_one);
-
-       for (i = 0; i < ARRAY_SIZE(impd1->vcos); i++)
-               clk_unregister(&impd1->vcos[i]);
+       integrator_impd1_clk_exit(dev->id);
 
        lm_set_drvdata(dev, NULL);