Merge branch 'for-3.2-rc' of git://gitorious.org/linux-omap-dss2/linux into fbdev...
[pandora-kernel.git] / drivers / video / da8xx-fb.c
index 217c05f..29577bf 100644 (file)
 /* Clock registers available only on Version 2 */
 #define  LCD_CLK_ENABLE_REG                    0x6c
 #define  LCD_CLK_RESET_REG                     0x70
+#define  LCD_CLK_MAIN_RESET                    BIT(3)
 
 #define LCD_NUM_BUFFERS        2
 
@@ -244,6 +245,10 @@ static inline void lcd_enable_raster(void)
 {
        u32 reg;
 
+       /* Bring LCDC out of reset */
+       if (lcd_revision == LCD_VERSION_2)
+               lcdc_write(0, LCD_CLK_RESET_REG);
+
        reg = lcdc_read(LCD_RASTER_CTRL_REG);
        if (!(reg & LCD_RASTER_ENABLE))
                lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
@@ -257,6 +262,10 @@ static inline void lcd_disable_raster(void)
        reg = lcdc_read(LCD_RASTER_CTRL_REG);
        if (reg & LCD_RASTER_ENABLE)
                lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+
+       if (lcd_revision == LCD_VERSION_2)
+               /* Write 1 to reset LCDC */
+               lcdc_write(LCD_CLK_MAIN_RESET, LCD_CLK_RESET_REG);
 }
 
 static void lcd_blit(int load_mode, struct da8xx_fb_par *par)
@@ -460,18 +469,43 @@ static int lcd_cfg_frame_buffer(struct da8xx_fb_par *par, u32 width, u32 height,
 
        /* Set the Panel Width */
        /* Pixels per line = (PPL + 1)*16 */
-       /*0x3F in bits 4..9 gives max horisontal resolution = 1024 pixels*/
-       width &= 0x3f0;
+       if (lcd_revision == LCD_VERSION_1) {
+               /*
+                * 0x3F in bits 4..9 gives max horizontal resolution = 1024
+                * pixels.
+                */
+               width &= 0x3f0;
+       } else {
+               /*
+                * 0x7F in bits 4..10 gives max horizontal resolution = 2048
+                * pixels.
+                */
+               width &= 0x7f0;
+       }
+
        reg = lcdc_read(LCD_RASTER_TIMING_0_REG);
        reg &= 0xfffffc00;
-       reg |= ((width >> 4) - 1) << 4;
+       if (lcd_revision == LCD_VERSION_1) {
+               reg |= ((width >> 4) - 1) << 4;
+       } else {
+               width = (width >> 4) - 1;
+               reg |= ((width & 0x3f) << 4) | ((width & 0x40) >> 3);
+       }
        lcdc_write(reg, LCD_RASTER_TIMING_0_REG);
 
        /* Set the Panel Height */
+       /* Set bits 9:0 of Lines Per Pixel */
        reg = lcdc_read(LCD_RASTER_TIMING_1_REG);
        reg = ((height - 1) & 0x3ff) | (reg & 0xfffffc00);
        lcdc_write(reg, LCD_RASTER_TIMING_1_REG);
 
+       /* Set bit 10 of Lines Per Pixel */
+       if (lcd_revision == LCD_VERSION_2) {
+               reg = lcdc_read(LCD_RASTER_TIMING_2_REG);
+               reg |= ((height - 1) & 0x400) << 16;
+               lcdc_write(reg, LCD_RASTER_TIMING_2_REG);
+       }
+
        /* Set the Raster Order of the Frame Buffer */
        reg = lcdc_read(LCD_RASTER_CTRL_REG) & ~(1 << 8);
        if (raster_order)
@@ -559,8 +593,12 @@ static void lcd_reset(struct da8xx_fb_par *par)
        lcdc_write(0, LCD_DMA_CTRL_REG);
        lcdc_write(0, LCD_RASTER_CTRL_REG);
 
-       if (lcd_revision == LCD_VERSION_2)
+       if (lcd_revision == LCD_VERSION_2) {
                lcdc_write(0, LCD_INT_ENABLE_SET_REG);
+               /* Write 1 to reset */
+               lcdc_write(LCD_CLK_MAIN_RESET, LCD_CLK_RESET_REG);
+               lcdc_write(0, LCD_CLK_RESET_REG);
+       }
 }
 
 static void lcd_calc_clk_divider(struct da8xx_fb_par *par)