lxfb: set the H- and V-SYNC polarity of the flatpanel output
[safe/jmp/linux-2.6] / drivers / video / geode / lxfb_ops.c
index 7abc439..bc35a95 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/fb.h>
 #include <linux/uaccess.h>
 #include <linux/delay.h>
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 
 #include "lxfb.h"
 
@@ -63,54 +63,32 @@ static const struct {
   { 0x00014284,  19688 },
   { 0x00011104,  20400 },
   { 0x00016363,  23625 },
-  { 0x00015303,  24380 },
   { 0x000031AC,  24923 },
   { 0x0000215D,  25175 },
   { 0x00001087,  27000 },
   { 0x0000216C,  28322 },
   { 0x0000218D,  28560 },
-  { 0x00010041,  29913 },
   { 0x000010C9,  31200 },
   { 0x00003147,  31500 },
-  { 0x000141A1,  32400 },
   { 0x000010A7,  33032 },
-  { 0x00012182,  33375 },
-  { 0x000141B1,  33750 },
   { 0x00002159,  35112 },
   { 0x00004249,  35500 },
   { 0x00000057,  36000 },
-  { 0x000141E1,  37125 },
   { 0x0000219A,  37889 },
   { 0x00002158,  39168 },
   { 0x00000045,  40000 },
-  { 0x000131A1,  40500 },
-  { 0x00010061,  42301 },
   { 0x00000089,  43163 },
-  { 0x00012151,  43875 },
   { 0x000010E7,  44900 },
   { 0x00002136,  45720 },
-  { 0x000152E1,  47250 },
-  { 0x00010071,  48000 },
   { 0x00003207,  49500 },
   { 0x00002187,  50000 },
-  { 0x00014291,  50625 },
-  { 0x00011101,  51188 },
-  { 0x00017481,  54563 },
   { 0x00004286,  56250 },
-  { 0x00014170,  57375 },
-  { 0x00016210,  58500 },
   { 0x000010E5,  60065 },
-  { 0x00013140,  62796 },
   { 0x00004214,  65000 },
-  { 0x00016250,  65250 },
   { 0x00001105,  68179 },
-  { 0x000141C0,  69600 },
-  { 0x00015220,  70160 },
-  { 0x00010050,  72000 },
   { 0x000031E4,  74250 },
   { 0x00003183,  75000 },
   { 0x00004284,  78750 },
-  { 0x00012130,  80052 },
   { 0x00001104,  81600 },
   { 0x00006363,  94500 },
   { 0x00005303,  97520 },
@@ -296,7 +274,15 @@ static void lx_graphics_enable(struct fb_info *info)
                u32 msrlo, msrhi;
 
                write_fp(par, FP_PT1, 0);
-               write_fp(par, FP_PT2, FP_PT2_SCRC);
+               temp = FP_PT2_SCRC;
+
+               if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
+                       temp |= FP_PT2_HSP;
+
+               if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
+                       temp |= FP_PT2_VSP;
+
+               write_fp(par, FP_PT2, temp);
                write_fp(par, FP_DFC, FP_DFC_BC);
 
                msrlo = MSR_LX_MSR_PADSEL_TFT_SEL_LOW;
@@ -329,14 +315,30 @@ unsigned int lx_framebuffer_size(void)
 {
        unsigned int val;
 
+       if (!cs5535_has_vsa2()) {
+               uint32_t hi, lo;
+
+               /* The number of pages is (PMAX - PMIN)+1 */
+               rdmsr(MSR_GLIU_P2D_RO0, lo, hi);
+
+               /* PMAX */
+               val = ((hi & 0xff) << 12) | ((lo & 0xfff00000) >> 20);
+               /* PMIN */
+               val -= (lo & 0x000fffff);
+               val += 1;
+
+               /* The page size is 4k */
+               return (val << 12);
+       }
+
        /* The frame buffer size is reported by a VSM in VSA II */
        /* Virtual Register Class    = 0x02                     */
        /* VG_MEM_SIZE (1MB units)   = 0x00                     */
 
-       outw(0xFC53, 0xAC1C);
-       outw(0x0200, 0xAC1C);
+       outw(VSA_VR_UNLOCK, VSA_VRC_INDEX);
+       outw(VSA_VR_MEM_SIZE, VSA_VRC_INDEX);
 
-       val = (unsigned int)(inw(0xAC1E)) & 0xFE;
+       val = (unsigned int)(inw(VSA_VRC_DATA)) & 0xFE;
        return (val << 20);
 }
 
@@ -523,7 +525,7 @@ void lx_set_palette_reg(struct fb_info *info, unsigned regno,
 int lx_blank_display(struct fb_info *info, int blank_mode)
 {
        struct lxfb_par *par = info->par;
-       u32 dcfg, fp_pm;
+       u32 dcfg, misc, fp_pm;
        int blank, hsync, vsync;
 
        /* CRT power saving modes. */
@@ -548,15 +550,26 @@ int lx_blank_display(struct fb_info *info, int blank_mode)
        }
 
        dcfg = read_vp(par, VP_DCFG);
-       dcfg &= ~(VP_DCFG_DAC_BL_EN | VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN);
+       dcfg &= ~(VP_DCFG_DAC_BL_EN | VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN |
+                       VP_DCFG_CRT_EN);
        if (!blank)
-               dcfg |= VP_DCFG_DAC_BL_EN;
+               dcfg |= VP_DCFG_DAC_BL_EN | VP_DCFG_CRT_EN;
        if (hsync)
                dcfg |= VP_DCFG_HSYNC_EN;
        if (vsync)
                dcfg |= VP_DCFG_VSYNC_EN;
+
        write_vp(par, VP_DCFG, dcfg);
 
+       misc = read_vp(par, VP_MISC);
+
+       if (vsync && hsync)
+               misc &= ~VP_MISC_DACPWRDN;
+       else
+               misc |= VP_MISC_DACPWRDN;
+
+       write_vp(par, VP_MISC, misc);
+
        /* Power on/off flat panel */
 
        if (par->output & OUTPUT_PANEL) {