22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/errno.h>
25 #include <linux/string.h>
32 #include <linux/nvram.h>
37 #include <asm/pgtable.h>
81 static int platinumfb_blank(
int blank_mode,
struct fb_info *
info);
82 static int platinumfb_set_par (
struct fb_info *
info);
89 static inline int platinum_vram_reqd(
int video_mode,
int color_mode);
101 static struct fb_ops platinumfb_ops = {
103 .fb_check_var = platinumfb_check_var,
104 .fb_set_par = platinumfb_set_par,
105 .fb_setcolreg = platinumfb_setcolreg,
106 .fb_blank = platinumfb_blank,
117 return platinum_var_to_par(var, info->
par, 1);
123 static int platinumfb_set_par (
struct fb_info *
info)
129 if((err = platinum_var_to_par(&info->
var, pinfo, 0))) {
131 " platinum_var_to_par: %d.\n", err);
135 platinum_set_hardware(pinfo);
137 init = platinum_reg_init[pinfo->
vmode-1];
150 printk(
"line_length: %x\n", info->
fix.line_length);
154 static int platinumfb_blank(
int blank,
struct fb_info *
fb)
209 switch (pinfo->
cmode) {
211 pal[regno] = (regno << 10) | (regno << 5) | regno;
214 i = (regno << 8) | regno;
215 pal[regno] = (i << 16) | i;
223 static inline int platinum_vram_reqd(
int video_mode,
int color_mode)
225 int baseval =
vmode_attrs[video_mode-1].hres * (1<<color_mode);
232 return vmode_attrs[video_mode-1].vres * baseval + 0x1000;
235 #define STORE_D2(a, d) { \
236 out_8(&cmap_regs->addr, (a+32)); \
237 out_8(&cmap_regs->d2, (d)); \
242 volatile struct cmap_regs __iomem *cmap_regs = pinfo->
cmap_regs;
245 init = platinum_reg_init[pinfo->
vmode-1];
250 if (
in_8(&cmap_regs->
d2) == 2) {
275 vmode = pinfo->
vmode;
276 cmode = pinfo->
cmode;
278 init = platinum_reg_init[vmode - 1];
283 for (i = 0; i < 26; ++
i)
287 init->
offset[cmode] + 4 - cmode :
292 init->
mode[cmode+1] :
308 set_platinum_clock(pinfo);
319 info->
fbops = &platinumfb_ops;
329 info->
fix.mmio_len = 0x1000;
333 info->
fix.ywrapstep = 0;
334 info->
fix.xpanstep = 0;
335 info->
fix.ypanstep = 0;
336 info->
fix.type_aux = 0;
347 sense = read_platinum_sense(pinfo);
352 if (default_vmode <= 0 || default_vmode >
VMODE_MAX ||
353 !platinum_reg_init[default_vmode-1])
360 if (default_vmode <= 0 || default_vmode >
VMODE_MAX)
366 if (default_cmode < CMODE_8 || default_cmode >
CMODE_32)
371 while(default_cmode >
CMODE_8 &&
372 platinum_vram_reqd(default_vmode, default_cmode) > pinfo->
total_vram)
375 printk(
"platinumfb: Using video mode %d and color mode %d.\n", default_vmode, default_cmode);
380 printk(
"mac_vmode_to_var(%d, %d,) failed\n", default_vmode, default_cmode);
391 platinum_init_info(info, pinfo);
422 sense = (~
in_be32(&platinum_regs->
reg[23].r) & 7) << 8;
427 sense |= (~
in_be32(&platinum_regs->
reg[23].r) & 3) << 4;
430 sense |= (~
in_be32(&platinum_regs->
reg[23].r) & 4) << 1;
431 sense |= (~
in_be32(&platinum_regs->
reg[23].r) & 1) << 2;
434 sense |= (~
in_be32(&platinum_regs->
reg[23].r) & 6) >> 1;
452 printk(
KERN_ERR "platinum_var_to_par: mac_var_to_vmode unsuccessful.\n");
463 if (!platinum_reg_init[vmode-1]) {
464 printk(
KERN_ERR "platinum_var_to_par, vmode %d not valid.\n", vmode);
468 if (platinum_vram_reqd(vmode, cmode) > pinfo->
total_vram) {
469 printk(
KERN_ERR "platinum_var_to_par, not enough ram for vmode %d, cmode %d.\n", vmode, cmode);
479 pinfo->
vmode = vmode;
480 pinfo->
cmode = cmode;
499 if (!options || !*options)
502 while ((this_opt =
strsep(&options,
",")) !=
NULL) {
503 if (!
strncmp(this_opt,
"vmode:", 6)) {
505 if (vmode > 0 && vmode <= VMODE_MAX)
506 default_vmode = vmode;
507 }
else if (!
strncmp(this_opt,
"cmode:", 6)) {
529 #define invalidate_cache(addr) \
530 asm volatile("eieio; dcbf 0,%1" \
531 : "=m" (*(addr)) : "r" (addr) : "memory");
533 #define invalidate_cache(addr)
541 volatile __u8 *fbuffer;
542 int bank0, bank1, bank2, bank3,
rc;
544 dev_info(&odev->
dev,
"Found Apple Platinum video hardware\n");
548 dev_err(&odev->
dev,
"Failed to allocate fbdev !\n");
559 dev_dbg(&odev->
dev,
" registers : 0x%llx...0x%llx\n",
560 (
unsigned long long)pinfo->
rsrc_reg.start,
561 (
unsigned long long)pinfo->
rsrc_reg.end);
562 dev_dbg(&odev->
dev,
" framebuffer: 0x%llx...0x%llx\n",
563 (
unsigned long long)pinfo->rsrc_fb.start,
564 (
unsigned long long)pinfo->rsrc_fb.end);
570 resource_size(&pinfo->rsrc_fb),
571 "platinumfb framebuffer")) {
597 fbuffer[0x100000] = 0x34;
598 fbuffer[0x100008] = 0x0;
600 fbuffer[0x200000] = 0x56;
601 fbuffer[0x200008] = 0x0;
603 fbuffer[0x300000] = 0x78;
604 fbuffer[0x300008] = 0x0;
607 bank1 = fbuffer[0x100000] == 0x34;
608 bank2 = fbuffer[0x200000] == 0x56;
609 bank3 = fbuffer[0x300000] == 0x78;
610 pinfo->
total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
612 (
unsigned int) (pinfo->
total_vram / 1024 / 1024),
613 bank3, bank2, bank1, bank0);
636 rc = platinum_init_fb(info);
661 resource_size(&pinfo->rsrc_fb));
681 .name =
"platinumfb",
683 .of_match_table = platinumfb_match,
685 .probe = platinumfb_probe,
689 static int __init platinumfb_init(
void)
696 platinumfb_setup(option);
703 static void __exit platinumfb_exit(
void)