ARM: integrator: switch Integrator platforms to use consolidated CLCD
[pandora-kernel.git] / arch / arm / mach-integrator / integrator_cp.c
index 85e48a5..9c02037 100644 (file)
@@ -42,6 +42,8 @@
 
 #include <asm/hardware/timer-sp.h>
 
+#include <plat/clcd.h>
+
 #include "common.h"
 
 #define INTCP_PA_FLASH_BASE            0x24000000
@@ -146,61 +148,61 @@ static void __init intcp_map_io(void)
 #define sic_writel     __raw_writel
 #define sic_readl      __raw_readl
 
-static void cic_mask_irq(unsigned int irq)
+static void cic_mask_irq(struct irq_data *d)
 {
-       irq -= IRQ_CIC_START;
+       unsigned int irq = d->irq - IRQ_CIC_START;
        cic_writel(1 << irq, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR);
 }
 
-static void cic_unmask_irq(unsigned int irq)
+static void cic_unmask_irq(struct irq_data *d)
 {
-       irq -= IRQ_CIC_START;
+       unsigned int irq = d->irq - IRQ_CIC_START;
        cic_writel(1 << irq, INTCP_VA_CIC_BASE + IRQ_ENABLE_SET);
 }
 
 static struct irq_chip cic_chip = {
-       .name   = "CIC",
-       .ack    = cic_mask_irq,
-       .mask   = cic_mask_irq,
-       .unmask = cic_unmask_irq,
+       .name           = "CIC",
+       .irq_ack        = cic_mask_irq,
+       .irq_mask       = cic_mask_irq,
+       .irq_unmask     = cic_unmask_irq,
 };
 
-static void pic_mask_irq(unsigned int irq)
+static void pic_mask_irq(struct irq_data *d)
 {
-       irq -= IRQ_PIC_START;
+       unsigned int irq = d->irq - IRQ_PIC_START;
        pic_writel(1 << irq, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR);
 }
 
-static void pic_unmask_irq(unsigned int irq)
+static void pic_unmask_irq(struct irq_data *d)
 {
-       irq -= IRQ_PIC_START;
+       unsigned int irq = d->irq - IRQ_PIC_START;
        pic_writel(1 << irq, INTCP_VA_PIC_BASE + IRQ_ENABLE_SET);
 }
 
 static struct irq_chip pic_chip = {
-       .name   = "PIC",
-       .ack    = pic_mask_irq,
-       .mask   = pic_mask_irq,
-       .unmask = pic_unmask_irq,
+       .name           = "PIC",
+       .irq_ack        = pic_mask_irq,
+       .irq_mask       = pic_mask_irq,
+       .irq_unmask     = pic_unmask_irq,
 };
 
-static void sic_mask_irq(unsigned int irq)
+static void sic_mask_irq(struct irq_data *d)
 {
-       irq -= IRQ_SIC_START;
+       unsigned int irq = d->irq - IRQ_SIC_START;
        sic_writel(1 << irq, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR);
 }
 
-static void sic_unmask_irq(unsigned int irq)
+static void sic_unmask_irq(struct irq_data *d)
 {
-       irq -= IRQ_SIC_START;
+       unsigned int irq = d->irq - IRQ_SIC_START;
        sic_writel(1 << irq, INTCP_VA_SIC_BASE + IRQ_ENABLE_SET);
 }
 
 static struct irq_chip sic_chip = {
-       .name   = "SIC",
-       .ack    = sic_mask_irq,
-       .mask   = sic_mask_irq,
-       .unmask = sic_unmask_irq,
+       .name           = "SIC",
+       .irq_ack        = sic_mask_irq,
+       .irq_mask       = sic_mask_irq,
+       .irq_unmask     = sic_unmask_irq,
 };
 
 static void
@@ -449,43 +451,21 @@ static struct amba_device aaci_device = {
 /*
  * CLCD support
  */
-static struct clcd_panel vga = {
-       .mode           = {
-               .name           = "VGA",
-               .refresh        = 60,
-               .xres           = 640,
-               .yres           = 480,
-               .pixclock       = 39721,
-               .left_margin    = 40,
-               .right_margin   = 24,
-               .upper_margin   = 32,
-               .lower_margin   = 11,
-               .hsync_len      = 96,
-               .vsync_len      = 2,
-               .sync           = 0,
-               .vmode          = FB_VMODE_NONINTERLACED,
-       },
-       .width          = -1,
-       .height         = -1,
-       .tim2           = TIM2_BCD | TIM2_IPC,
-       .cntl           = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
-       .bpp            = 16,
-       .grayscale      = 0,
-};
-
 /*
  * Ensure VGA is selected.
  */
 static void cp_clcd_enable(struct clcd_fb *fb)
 {
-       u32 val;
+       struct fb_var_screeninfo *var = &fb->fb.var;
+       u32 val = CM_CTRL_STATIC1 | CM_CTRL_STATIC2;
 
-       if (fb->fb.var.bits_per_pixel <= 8)
-               val = CM_CTRL_LCDMUXSEL_VGA_8421BPP;
+       if (var->bits_per_pixel <= 8 ||
+           (var->bits_per_pixel == 16 && var->green.length == 5))
+               /* Pseudocolor, RGB555, BGR555 */
+               val |= CM_CTRL_LCDMUXSEL_VGA555_TFT555;
        else if (fb->fb.var.bits_per_pixel <= 16)
-               val = CM_CTRL_LCDMUXSEL_VGA_16BPP
-                       | CM_CTRL_LCDEN0 | CM_CTRL_LCDEN1
-                       | CM_CTRL_STATIC1 | CM_CTRL_STATIC2;
+               /* truecolor RGB565 */
+               val |= CM_CTRL_LCDMUXSEL_VGA565_TFT555;
        else
                val = 0; /* no idea for this, don't trust the docs */
 
@@ -498,49 +478,24 @@ static void cp_clcd_enable(struct clcd_fb *fb)
                   CM_CTRL_n24BITEN, val);
 }
 
-static unsigned long framesize = SZ_1M;
-
 static int cp_clcd_setup(struct clcd_fb *fb)
 {
-       dma_addr_t dma;
-
-       fb->panel = &vga;
-
-       fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
-                                                   &dma, GFP_KERNEL);
-       if (!fb->fb.screen_base) {
-               printk(KERN_ERR "CLCD: unable to map framebuffer\n");
-               return -ENOMEM;
-       }
+       fb->panel = versatile_clcd_get_panel("VGA");
+       if (!fb->panel)
+               return -EINVAL;
 
-       fb->fb.fix.smem_start   = dma;
-       fb->fb.fix.smem_len     = framesize;
-
-       return 0;
-}
-
-static int cp_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
-{
-       return dma_mmap_writecombine(&fb->dev->dev, vma,
-                                    fb->fb.screen_base,
-                                    fb->fb.fix.smem_start,
-                                    fb->fb.fix.smem_len);
-}
-
-static void cp_clcd_remove(struct clcd_fb *fb)
-{
-       dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
-                             fb->fb.screen_base, fb->fb.fix.smem_start);
+       return versatile_clcd_setup_dma(fb, SZ_1M);
 }
 
 static struct clcd_board clcd_data = {
        .name           = "Integrator/CP",
+       .caps           = CLCD_CAP_5551 | CLCD_CAP_RGB565 | CLCD_CAP_888,
        .check          = clcdfb_check,
        .decode         = clcdfb_decode,
        .enable         = cp_clcd_enable,
        .setup          = cp_clcd_setup,
-       .mmap           = cp_clcd_mmap,
-       .remove         = cp_clcd_remove,
+       .mmap           = versatile_clcd_mmap_dma,
+       .remove         = versatile_clcd_remove_dma,
 };
 
 static struct amba_device clcd_device = {