11 #include <linux/kernel.h>
12 #include <linux/errno.h>
51 { 0x00010045, 10000 },
52 { 0x00010089, 10791 },
53 { 0x000110E7, 11225 },
54 { 0x00012136, 11430 },
55 { 0x00013207, 12375 },
56 { 0x00012187, 12500 },
57 { 0x00014286, 14063 },
58 { 0x000110E5, 15016 },
59 { 0x00014214, 16250 },
60 { 0x00011105, 17045 },
61 { 0x000131E4, 18563 },
62 { 0x00013183, 18750 },
63 { 0x00014284, 19688 },
64 { 0x00011104, 20400 },
65 { 0x00016363, 23625 },
66 { 0x000031AC, 24923 },
67 { 0x0000215D, 25175 },
68 { 0x00001087, 27000 },
69 { 0x0000216C, 28322 },
70 { 0x0000218D, 28560 },
71 { 0x000010C9, 31200 },
72 { 0x00003147, 31500 },
73 { 0x000010A7, 33032 },
74 { 0x00002159, 35112 },
75 { 0x00004249, 35500 },
76 { 0x00000057, 36000 },
77 { 0x0000219A, 37889 },
78 { 0x00002158, 39168 },
79 { 0x00000045, 40000 },
80 { 0x00000089, 43163 },
81 { 0x000010E7, 44900 },
82 { 0x00002136, 45720 },
83 { 0x00003207, 49500 },
84 { 0x00002187, 50000 },
85 { 0x00004286, 56250 },
86 { 0x000010E5, 60065 },
87 { 0x00004214, 65000 },
88 { 0x00001105, 68179 },
89 { 0x000031E4, 74250 },
90 { 0x00003183, 75000 },
91 { 0x00004284, 78750 },
92 { 0x00001104, 81600 },
93 { 0x00006363, 94500 },
94 { 0x00005303, 97520 },
95 { 0x00002183, 100187 },
96 { 0x00002122, 101420 },
97 { 0x00001081, 108000 },
98 { 0x00006201, 113310 },
99 { 0x00000041, 119650 },
100 { 0x000041A1, 129600 },
101 { 0x00002182, 133500 },
102 { 0x000041B1, 135000 },
103 { 0x00000051, 144000 },
104 { 0x000041E1, 148500 },
105 { 0x000062D1, 157500 },
106 { 0x000031A1, 162000 },
107 { 0x00000061, 169203 },
108 { 0x00004231, 172800 },
109 { 0x00002151, 175500 },
110 { 0x000052E1, 189000 },
111 { 0x00000071, 192000 },
112 { 0x00003201, 198000 },
113 { 0x00004291, 202500 },
114 { 0x00001101, 204750 },
115 { 0x00007481, 218250 },
116 { 0x00004170, 229500 },
117 { 0x00006210, 234000 },
118 { 0x00003140, 251182 },
119 { 0x00006250, 261000 },
120 { 0x000041C0, 278400 },
121 { 0x00005220, 280640 },
122 { 0x00000050, 288000 },
123 { 0x000041E0, 297000 },
124 { 0x00002130, 320207 }
130 u32 dotpll_lo, dotpll_hi;
150 for (i = 0; i < 1000; i++) {
152 if (dotpll_lo & MSR_GLCP_DOTPLL_LOCK)
166 unsigned int diff,
min, best = 0;
167 unsigned int freq,
i;
169 freq = (
unsigned int) (1000000000 / info->
var.pixclock);
171 min =
abs(pll_table[0].freq - freq);
174 diff =
abs(pll_table[i].freq - freq);
181 lx_set_dotpll(pll_table[best].pllval & 0x00017FFF);
184 static void lx_graphics_disable(
struct fb_info *info)
187 unsigned int val, gcfg;
249 static void lx_graphics_enable(
struct fb_info *info)
259 config = read_vp(par,
VP_DCFG);
285 write_fp(par,
FP_PT2, temp);
299 write_vp(par,
VP_DCFG, config);
318 if (!cs5535_has_vsa2()) {
325 val = ((hi & 0xff) << 12) | ((lo & 0xfff00000) >> 20);
327 val -= (lo & 0x000fffff);
352 unsigned int gcfg, dcfg;
353 int hactive, hblankstart, hsyncstart, hsyncend, hblankend, htotal;
354 int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal;
359 lx_graphics_disable(info);
402 if (info->
fix.line_length > 4096)
404 else if (info->
fix.line_length > 2048)
406 else if (info->
fix.line_length > 1024)
411 max = info->
fix.line_length * info->
var.yres;
412 max = (max + 0x3FF) & 0xFFFFFC00;
419 size = info->
var.xres * (info->
var.bits_per_pixel >> 3);
451 switch (info->
var.bits_per_pixel) {
468 hactive = info->
var.xres;
469 hblankstart = hactive;
470 hsyncstart = hblankstart + info->
var.right_margin;
471 hsyncend = hsyncstart + info->
var.hsync_len;
472 hblankend = hsyncend + info->
var.left_margin;
475 vactive = info->
var.yres;
476 vblankstart = vactive;
477 vsyncstart = vblankstart + info->
var.lower_margin;
478 vsyncend = vsyncstart + info->
var.vsync_len;
479 vblankend = vsyncend + info->
var.upper_margin;
484 (hblankstart - 1) | ((hblankend - 1) << 16));
486 (hsyncstart - 1) | ((hsyncend - 1) << 16));
490 (vblankstart - 1) | ((vblankend - 1) << 16));
492 (vsyncstart - 1) | ((vsyncend - 1) << 16));
495 (info->
var.xres - 1) << 16 | (info->
var.yres - 1));
498 lx_graphics_enable(info);
517 val = (red << 8) & 0xff0000;
518 val |= (
green) & 0x00ff00;
519 val |= (blue >> 8) & 0x0000ff;
532 switch (blank_mode) {
534 blank = 0; hsync = 1; vsync = 1;
537 blank = 1; hsync = 1; vsync = 1;
540 blank = 1; hsync = 1; vsync = 0;
543 blank = 1; hsync = 0; vsync = 1;
546 blank = 1; hsync = 0; vsync = 0;
576 fp_pm = read_fp(par,
FP_PM);
581 write_fp(par,
FP_PM, fp_pm);
589 static void lx_save_regs(
struct lxfb_par *par)
621 par->vp_pal[i] = read_vp(par,
VP_PDR);
625 for (i = 0; i <
ARRAY_SIZE(par->hcoeff); i += 2) {
633 for (i = 0; i <
ARRAY_SIZE(par->vcoeff); i++) {
642 static void lx_restore_gfx_proc(
struct lxfb_par *par)
663 write_gp(par, i, par->gp[i]);
668 static void lx_restore_display_ctlr(
struct lxfb_par *par)
708 write_dc(par, i, par->dc[i]);
719 for (i = 0; i <
ARRAY_SIZE(par->hcoeff); i += 2) {
727 for (i = 0; i <
ARRAY_SIZE(par->vcoeff); i++) {
733 static void lx_restore_video_proc(
struct lxfb_par *par)
755 write_vp(par, i, par->vp[i]);
762 write_vp(par,
VP_PDR, par->vp_pal[i]);
768 static void lx_restore_regs(
struct lxfb_par *par)
772 lx_set_dotpll((
u32) (par->msr.dotpll >> 32));
773 lx_restore_gfx_proc(par);
774 lx_restore_display_ctlr(par);
775 lx_restore_video_proc(par);
790 write_fp(par, i, par->fp[i]);
797 if (!(read_fp(par,
FP_PM) &
802 if (!(read_fp(par,
FP_PM) &
818 int lx_powerdown(
struct fb_info *info)
822 if (par->powered_down)
826 lx_graphics_disable(info);
828 par->powered_down = 1;
832 int lx_powerup(
struct fb_info *info)
836 if (!par->powered_down)
839 lx_restore_regs(par);
841 par->powered_down = 0;