26 #include <linux/module.h>
36 static void __iomem *virt_base_2700;
38 #define write_reg(val, reg) do { writel((val), (reg)); } while(0)
44 #define write_reg_dly(val, reg) do { writel((val), reg); udelay(1000); } while(0)
51 #define MAX_PALETTES 16
55 #define MEMORY_OFFSET 0x60000
76 #ifdef CONFIG_FB_MBX_DEBUG
121 static unsigned int mbxfb_get_pixclock(
unsigned int pixclock_ps,
125 unsigned int err = 0;
126 unsigned int min_err = ~0x0;
128 unsigned int best_clk = 0;
129 unsigned int ref_clk = 13000;
130 unsigned int pixclock;
146 for (m = 1; m < 64; m++) {
147 for (n = 2; n < 8; n++) {
148 for (p = 0; p < 8; p++) {
149 clk = (ref_clk *
m) / (n * (1 << p));
150 err = (clk > pixclock) ? (clk - pixclock) :
173 val = (red & 0xf800) | ((green & 0xfc00) >> 5) |
174 ((blue & 0xf800) >> 11);
204 var->
green.length = (var->
green.length == 5) ? 5 : 6;
206 var->
blue.length = 5;
208 var->
blue.offset = 0;
209 var->
green.offset = 5;
210 var->
red.offset = 5 + var->
green.length;
211 var->
transp.offset = (5 + var->
red.offset) & 15;
215 var->
red.offset = 16;
217 var->
green.offset = 8;
218 var->
green.length = 8;
219 var->
blue.offset = 0;
220 var->
blue.length = 8;
225 var->
red.msb_right = 0;
226 var->
green.msb_right = 0;
227 var->
blue.msb_right = 0;
228 var->
transp.msb_right = 0;
233 static int mbxfb_set_par(
struct fb_info *info)
237 ushort hbps, ht, hfps, has;
238 ushort vbps, vt, vfps, vas;
247 if (info->
var.bits_per_pixel == 8) {
254 switch (info->
var.bits_per_pixel) {
256 if (info->
var.green.length == 5)
289 hfps = has + var->
xres;
294 vfps = vas + var->
yres;
315 static int mbxfb_blank(
int blank,
struct fb_info *info)
336 u32 vsctrl, vscadr, vsadr;
337 u32 sssize, spoctrl, shctrl;
341 if (
set->scaled_width==0 ||
set->scaled_height==0)
372 set->Y_stride = ((
set->width) + 0xf ) & ~0xf;
377 set->Y_stride = ((
set->width) + 0xf ) & ~0xf;
383 set->Y_stride = (
set->width*2 + 0xf ) & ~0xf;
387 set->Y_stride = (
set->width*2 + 0xf ) & ~0xf;
391 set->Y_stride = (
set->width*2 + 0xf ) & ~0xf;
395 set->Y_stride = (
set->width*2 + 0xf ) & ~0xf;
410 set->UV_stride = ((
set->width/2) + 0x7 ) & ~0x7;
411 set->U_offset =
set->height *
set->Y_stride;
412 set->V_offset =
set->U_offset +
413 set->height *
set->UV_stride;
415 (0x60000 +
set->mem_offset +
set->U_offset)>>3);
417 (0x60000 +
set->mem_offset +
set->V_offset)>>3);
439 if (
set->scaled_width ==
set->width)
441 if (
set->scaled_height ==
set->height)
472 unsigned long gscadr, vscadr;
494 switch (porder->
top) {
514 unsigned long vscadr, vbbase, vcmsk;
515 unsigned long gscadr, gbbase, gdrctrl;
601 static int mbxfb_ioctl(
struct fb_info *info,
unsigned int cmd,
618 res = mbxfb_setupOverlay(&
setup);
633 return mbxfb_ioctl_planeorder(&porder);
640 return mbxfb_ioctl_alphactl(&alpha);
652 tmp |=
reg.val &
reg.mask;
674 static struct fb_ops mbxfb_ops = {
676 .fb_check_var = mbxfb_check_var,
677 .fb_set_par = mbxfb_set_par,
678 .fb_setcolreg = mbxfb_setcolreg,
682 .fb_blank = mbxfb_blank,
683 .fb_ioctl = mbxfb_ioctl,
716 for ( i = 0; i < 16; i++ ) {
721 static void enable_clocks(
struct fb_info *fbi)
752 unsigned long gsctrl;
753 unsigned long vscadr;
757 switch (fbi->
var.bits_per_pixel) {
759 if (fbi->
var.green.length == 5)
786 unsigned long dsctrl = 0;
862 struct fb_info *fbi = platform_get_drvdata(dev);
872 #define mbxfb_suspend NULL
873 #define mbxfb_resume NULL
877 #ifndef CONFIG_FB_MBX_DEBUG
878 #define mbxfb_debugfs_init(x) do {} while(0)
879 #define mbxfb_debugfs_remove(x) do {} while(0)
882 #define res_size(_r) (((_r)->end - (_r)->start) + 1)
893 pdata = dev->
dev.platform_data;
895 dev_err(&dev->
dev,
"platform data is required\n");
901 dev_err(&dev->
dev,
"framebuffer_alloc failed\n");
926 dev_err(&dev->
dev,
"failed to claim framebuffer memory\n");
935 dev_err(&dev->
dev,
"failed to claim Marathon registers\n");
945 dev_err(&dev->
dev,
"failed to ioremap Marathon registers\n");
954 dev_err(&dev->
dev,
"failed to ioremap frame buffer\n");
961 fbi->
fbops = &mbxfb_ops;
963 fbi->
var = mbxfb_default;
964 fbi->
fix = mbxfb_fix;
967 fbi->
fix.line_length = mbxfb_default.xres_virtual *
968 mbxfb_default.bits_per_pixel / 8;
977 platform_set_drvdata(dev, fbi);
984 enable_controller(fbi);
990 dev_err(&dev->
dev,
"register_framebuffer failed\n");
1011 struct fb_info *fbi = platform_get_drvdata(dev);
1040 .probe = mbxfb_probe,