Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.20-rc6 705 lines 20 kB view raw
1/* 2 * platinumfb.c -- frame buffer device for the PowerMac 'platinum' display 3 * 4 * Copyright (C) 1998 Franz Sirl 5 * 6 * Frame buffer structure from: 7 * drivers/video/controlfb.c -- frame buffer device for 8 * Apple 'control' display chip. 9 * Copyright (C) 1998 Dan Jacobowitz 10 * 11 * Hardware information from: 12 * platinum.c: Console support for PowerMac "platinum" display adaptor. 13 * Copyright (C) 1996 Paul Mackerras and Mark Abene 14 * 15 * This file is subject to the terms and conditions of the GNU General Public 16 * License. See the file COPYING in the main directory of this archive for 17 * more details. 18 */ 19 20#include <linux/module.h> 21#include <linux/kernel.h> 22#include <linux/errno.h> 23#include <linux/string.h> 24#include <linux/mm.h> 25#include <linux/slab.h> 26#include <linux/vmalloc.h> 27#include <linux/delay.h> 28#include <linux/interrupt.h> 29#include <linux/fb.h> 30#include <linux/init.h> 31#include <linux/pci.h> 32#include <linux/nvram.h> 33#include <asm/io.h> 34#include <asm/prom.h> 35#include <asm/pgtable.h> 36#include <asm/of_device.h> 37#include <asm/of_platform.h> 38 39#include "macmodes.h" 40#include "platinumfb.h" 41 42static int default_vmode = VMODE_NVRAM; 43static int default_cmode = CMODE_NVRAM; 44 45struct fb_info_platinum { 46 struct fb_info *info; 47 48 int vmode, cmode; 49 int xres, yres; 50 int vxres, vyres; 51 int xoffset, yoffset; 52 53 struct { 54 __u8 red, green, blue; 55 } palette[256]; 56 u32 pseudo_palette[17]; 57 58 volatile struct cmap_regs __iomem *cmap_regs; 59 unsigned long cmap_regs_phys; 60 61 volatile struct platinum_regs __iomem *platinum_regs; 62 unsigned long platinum_regs_phys; 63 64 __u8 __iomem *frame_buffer; 65 volatile __u8 __iomem *base_frame_buffer; 66 unsigned long frame_buffer_phys; 67 68 unsigned long total_vram; 69 int clktype; 70 int dactype; 71 72 struct resource rsrc_fb, rsrc_reg; 73}; 74 75/* 76 * Frame buffer device API 77 */ 78 79static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, 80 u_int transp, struct fb_info *info); 81static int platinumfb_blank(int blank_mode, struct fb_info *info); 82static int platinumfb_set_par (struct fb_info *info); 83static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info); 84 85/* 86 * internal functions 87 */ 88 89static inline int platinum_vram_reqd(int video_mode, int color_mode); 90static int read_platinum_sense(struct fb_info_platinum *pinfo); 91static void set_platinum_clock(struct fb_info_platinum *pinfo); 92static void platinum_set_hardware(struct fb_info_platinum *pinfo); 93static int platinum_var_to_par(struct fb_var_screeninfo *var, 94 struct fb_info_platinum *pinfo, 95 int check_only); 96 97/* 98 * Interface used by the world 99 */ 100 101static struct fb_ops platinumfb_ops = { 102 .owner = THIS_MODULE, 103 .fb_check_var = platinumfb_check_var, 104 .fb_set_par = platinumfb_set_par, 105 .fb_setcolreg = platinumfb_setcolreg, 106 .fb_blank = platinumfb_blank, 107 .fb_fillrect = cfb_fillrect, 108 .fb_copyarea = cfb_copyarea, 109 .fb_imageblit = cfb_imageblit, 110}; 111 112/* 113 * Checks a var structure 114 */ 115static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info) 116{ 117 return platinum_var_to_par(var, info->par, 1); 118} 119 120/* 121 * Applies current var to display 122 */ 123static int platinumfb_set_par (struct fb_info *info) 124{ 125 struct fb_info_platinum *pinfo = info->par; 126 struct platinum_regvals *init; 127 int err, offset = 0x20; 128 129 if((err = platinum_var_to_par(&info->var, pinfo, 0))) { 130 printk (KERN_ERR "platinumfb_set_par: error calling" 131 " platinum_var_to_par: %d.\n", err); 132 return err; 133 } 134 135 platinum_set_hardware(pinfo); 136 137 init = platinum_reg_init[pinfo->vmode-1]; 138 139 if ((pinfo->vmode == VMODE_832_624_75) && (pinfo->cmode > CMODE_8)) 140 offset = 0x10; 141 142 info->screen_base = pinfo->frame_buffer + init->fb_offset + offset; 143 info->fix.smem_start = (pinfo->frame_buffer_phys) + init->fb_offset + offset; 144 info->fix.visual = (pinfo->cmode == CMODE_8) ? 145 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; 146 info->fix.line_length = vmode_attrs[pinfo->vmode-1].hres * (1<<pinfo->cmode) 147 + offset; 148 printk("line_length: %x\n", info->fix.line_length); 149 return 0; 150} 151 152static int platinumfb_blank(int blank, struct fb_info *fb) 153{ 154/* 155 * Blank the screen if blank_mode != 0, else unblank. If blank == NULL 156 * then the caller blanks by setting the CLUT (Color Look Up Table) to all 157 * black. Return 0 if blanking succeeded, != 0 if un-/blanking failed due 158 * to e.g. a video mode which doesn't support it. Implements VESA suspend 159 * and powerdown modes on hardware that supports disabling hsync/vsync: 160 * blank_mode == 2: suspend vsync 161 * blank_mode == 3: suspend hsync 162 * blank_mode == 4: powerdown 163 */ 164/* [danj] I think there's something fishy about those constants... */ 165/* 166 struct fb_info_platinum *info = (struct fb_info_platinum *) fb; 167 int ctrl; 168 169 ctrl = ld_le32(&info->platinum_regs->ctrl.r) | 0x33; 170 if (blank) 171 --blank_mode; 172 if (blank & VESA_VSYNC_SUSPEND) 173 ctrl &= ~3; 174 if (blank & VESA_HSYNC_SUSPEND) 175 ctrl &= ~0x30; 176 out_le32(&info->platinum_regs->ctrl.r, ctrl); 177*/ 178/* TODO: Figure out how the heck to powerdown this thing! */ 179 return 0; 180} 181 182static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, 183 u_int transp, struct fb_info *info) 184{ 185 struct fb_info_platinum *pinfo = info->par; 186 volatile struct cmap_regs __iomem *cmap_regs = pinfo->cmap_regs; 187 188 if (regno > 255) 189 return 1; 190 191 red >>= 8; 192 green >>= 8; 193 blue >>= 8; 194 195 pinfo->palette[regno].red = red; 196 pinfo->palette[regno].green = green; 197 pinfo->palette[regno].blue = blue; 198 199 out_8(&cmap_regs->addr, regno); /* tell clut what addr to fill */ 200 out_8(&cmap_regs->lut, red); /* send one color channel at */ 201 out_8(&cmap_regs->lut, green); /* a time... */ 202 out_8(&cmap_regs->lut, blue); 203 204 if (regno < 16) { 205 int i; 206 u32 *pal = info->pseudo_palette; 207 switch (pinfo->cmode) { 208 case CMODE_16: 209 pal[regno] = (regno << 10) | (regno << 5) | regno; 210 break; 211 case CMODE_32: 212 i = (regno << 8) | regno; 213 pal[regno] = (i << 16) | i; 214 break; 215 } 216 } 217 218 return 0; 219} 220 221static inline int platinum_vram_reqd(int video_mode, int color_mode) 222{ 223 return vmode_attrs[video_mode-1].vres * 224 (vmode_attrs[video_mode-1].hres * (1<<color_mode) + 225 ((video_mode == VMODE_832_624_75) && 226 (color_mode > CMODE_8)) ? 0x10 : 0x20) + 0x1000; 227} 228 229#define STORE_D2(a, d) { \ 230 out_8(&cmap_regs->addr, (a+32)); \ 231 out_8(&cmap_regs->d2, (d)); \ 232} 233 234static void set_platinum_clock(struct fb_info_platinum *pinfo) 235{ 236 volatile struct cmap_regs __iomem *cmap_regs = pinfo->cmap_regs; 237 struct platinum_regvals *init; 238 239 init = platinum_reg_init[pinfo->vmode-1]; 240 241 STORE_D2(6, 0xc6); 242 out_8(&cmap_regs->addr,3+32); 243 244 if (in_8(&cmap_regs->d2) == 2) { 245 STORE_D2(7, init->clock_params[pinfo->clktype][0]); 246 STORE_D2(8, init->clock_params[pinfo->clktype][1]); 247 STORE_D2(3, 3); 248 } else { 249 STORE_D2(4, init->clock_params[pinfo->clktype][0]); 250 STORE_D2(5, init->clock_params[pinfo->clktype][1]); 251 STORE_D2(3, 2); 252 } 253 254 __delay(5000); 255 STORE_D2(9, 0xa6); 256} 257 258 259/* Now how about actually saying, Make it so! */ 260/* Some things in here probably don't need to be done each time. */ 261static void platinum_set_hardware(struct fb_info_platinum *pinfo) 262{ 263 volatile struct platinum_regs __iomem *platinum_regs = pinfo->platinum_regs; 264 volatile struct cmap_regs __iomem *cmap_regs = pinfo->cmap_regs; 265 struct platinum_regvals *init; 266 int i; 267 int vmode, cmode; 268 269 vmode = pinfo->vmode; 270 cmode = pinfo->cmode; 271 272 init = platinum_reg_init[vmode - 1]; 273 274 /* Initialize display timing registers */ 275 out_be32(&platinum_regs->reg[24].r, 7); /* turn display off */ 276 277 for (i = 0; i < 26; ++i) 278 out_be32(&platinum_regs->reg[i+32].r, init->regs[i]); 279 280 out_be32(&platinum_regs->reg[26+32].r, (pinfo->total_vram == 0x100000 ? 281 init->offset[cmode] + 4 - cmode : 282 init->offset[cmode])); 283 out_be32(&platinum_regs->reg[16].r, (unsigned) pinfo->frame_buffer_phys+init->fb_offset+0x10); 284 out_be32(&platinum_regs->reg[18].r, init->pitch[cmode]); 285 out_be32(&platinum_regs->reg[19].r, (pinfo->total_vram == 0x100000 ? 286 init->mode[cmode+1] : 287 init->mode[cmode])); 288 out_be32(&platinum_regs->reg[20].r, (pinfo->total_vram == 0x100000 ? 0x11 : 0x1011)); 289 out_be32(&platinum_regs->reg[21].r, 0x100); 290 out_be32(&platinum_regs->reg[22].r, 1); 291 out_be32(&platinum_regs->reg[23].r, 1); 292 out_be32(&platinum_regs->reg[26].r, 0xc00); 293 out_be32(&platinum_regs->reg[27].r, 0x235); 294 /* out_be32(&platinum_regs->reg[27].r, 0x2aa); */ 295 296 STORE_D2(0, (pinfo->total_vram == 0x100000 ? 297 init->dacula_ctrl[cmode] & 0xf : 298 init->dacula_ctrl[cmode])); 299 STORE_D2(1, 4); 300 STORE_D2(2, 0); 301 302 set_platinum_clock(pinfo); 303 304 out_be32(&platinum_regs->reg[24].r, 0); /* turn display on */ 305} 306 307/* 308 * Set misc info vars for this driver 309 */ 310static void __devinit platinum_init_info(struct fb_info *info, struct fb_info_platinum *pinfo) 311{ 312 /* Fill fb_info */ 313 info->fbops = &platinumfb_ops; 314 info->pseudo_palette = pinfo->pseudo_palette; 315 info->flags = FBINFO_DEFAULT; 316 info->screen_base = pinfo->frame_buffer + 0x20; 317 318 fb_alloc_cmap(&info->cmap, 256, 0); 319 320 /* Fill fix common fields */ 321 strcpy(info->fix.id, "platinum"); 322 info->fix.mmio_start = pinfo->platinum_regs_phys; 323 info->fix.mmio_len = 0x1000; 324 info->fix.type = FB_TYPE_PACKED_PIXELS; 325 info->fix.smem_start = pinfo->frame_buffer_phys + 0x20; /* will be updated later */ 326 info->fix.smem_len = pinfo->total_vram - 0x20; 327 info->fix.ywrapstep = 0; 328 info->fix.xpanstep = 0; 329 info->fix.ypanstep = 0; 330 info->fix.type_aux = 0; 331 info->fix.accel = FB_ACCEL_NONE; 332} 333 334 335static int __devinit platinum_init_fb(struct fb_info *info) 336{ 337 struct fb_info_platinum *pinfo = info->par; 338 struct fb_var_screeninfo var; 339 int sense, rc; 340 341 sense = read_platinum_sense(pinfo); 342 printk(KERN_INFO "platinumfb: Monitor sense value = 0x%x, ", sense); 343 if (default_vmode == VMODE_NVRAM) { 344#ifdef CONFIG_NVRAM 345 default_vmode = nvram_read_byte(NV_VMODE); 346 if (default_vmode <= 0 || default_vmode > VMODE_MAX || 347 !platinum_reg_init[default_vmode-1]) 348#endif 349 default_vmode = VMODE_CHOOSE; 350 } 351 if (default_vmode == VMODE_CHOOSE) { 352 default_vmode = mac_map_monitor_sense(sense); 353 } 354 if (default_vmode <= 0 || default_vmode > VMODE_MAX) 355 default_vmode = VMODE_640_480_60; 356#ifdef CONFIG_NVRAM 357 if (default_cmode == CMODE_NVRAM) 358 default_cmode = nvram_read_byte(NV_CMODE); 359#endif 360 if (default_cmode < CMODE_8 || default_cmode > CMODE_32) 361 default_cmode = CMODE_8; 362 /* 363 * Reduce the pixel size if we don't have enough VRAM. 364 */ 365 while(default_cmode > CMODE_8 && 366 platinum_vram_reqd(default_vmode, default_cmode) > pinfo->total_vram) 367 default_cmode--; 368 369 printk("platinumfb: Using video mode %d and color mode %d.\n", default_vmode, default_cmode); 370 371 /* Setup default var */ 372 if (mac_vmode_to_var(default_vmode, default_cmode, &var) < 0) { 373 /* This shouldn't happen! */ 374 printk("mac_vmode_to_var(%d, %d,) failed\n", default_vmode, default_cmode); 375try_again: 376 default_vmode = VMODE_640_480_60; 377 default_cmode = CMODE_8; 378 if (mac_vmode_to_var(default_vmode, default_cmode, &var) < 0) { 379 printk(KERN_ERR "platinumfb: mac_vmode_to_var() failed\n"); 380 return -ENXIO; 381 } 382 } 383 384 /* Initialize info structure */ 385 platinum_init_info(info, pinfo); 386 387 /* Apply default var */ 388 info->var = var; 389 var.activate = FB_ACTIVATE_NOW; 390 rc = fb_set_var(info, &var); 391 if (rc && (default_vmode != VMODE_640_480_60 || default_cmode != CMODE_8)) 392 goto try_again; 393 394 /* Register with fbdev layer */ 395 rc = register_framebuffer(info); 396 if (rc < 0) 397 return rc; 398 399 printk(KERN_INFO "fb%d: Apple Platinum frame buffer device\n", info->node); 400 401 return 0; 402} 403 404/* 405 * Get the monitor sense value. 406 * Note that this can be called before calibrate_delay, 407 * so we can't use udelay. 408 */ 409static int read_platinum_sense(struct fb_info_platinum *info) 410{ 411 volatile struct platinum_regs __iomem *platinum_regs = info->platinum_regs; 412 int sense; 413 414 out_be32(&platinum_regs->reg[23].r, 7); /* turn off drivers */ 415 __delay(2000); 416 sense = (~in_be32(&platinum_regs->reg[23].r) & 7) << 8; 417 418 /* drive each sense line low in turn and collect the other 2 */ 419 out_be32(&platinum_regs->reg[23].r, 3); /* drive A low */ 420 __delay(2000); 421 sense |= (~in_be32(&platinum_regs->reg[23].r) & 3) << 4; 422 out_be32(&platinum_regs->reg[23].r, 5); /* drive B low */ 423 __delay(2000); 424 sense |= (~in_be32(&platinum_regs->reg[23].r) & 4) << 1; 425 sense |= (~in_be32(&platinum_regs->reg[23].r) & 1) << 2; 426 out_be32(&platinum_regs->reg[23].r, 6); /* drive C low */ 427 __delay(2000); 428 sense |= (~in_be32(&platinum_regs->reg[23].r) & 6) >> 1; 429 430 out_be32(&platinum_regs->reg[23].r, 7); /* turn off drivers */ 431 432 return sense; 433} 434 435/* 436 * This routine takes a user-supplied var, and picks the best vmode/cmode from it. 437 * It also updates the var structure to the actual mode data obtained 438 */ 439static int platinum_var_to_par(struct fb_var_screeninfo *var, 440 struct fb_info_platinum *pinfo, 441 int check_only) 442{ 443 int vmode, cmode; 444 445 if (mac_var_to_vmode(var, &vmode, &cmode) != 0) { 446 printk(KERN_ERR "platinum_var_to_par: mac_var_to_vmode unsuccessful.\n"); 447 printk(KERN_ERR "platinum_var_to_par: var->xres = %d\n", var->xres); 448 printk(KERN_ERR "platinum_var_to_par: var->yres = %d\n", var->yres); 449 printk(KERN_ERR "platinum_var_to_par: var->xres_virtual = %d\n", var->xres_virtual); 450 printk(KERN_ERR "platinum_var_to_par: var->yres_virtual = %d\n", var->yres_virtual); 451 printk(KERN_ERR "platinum_var_to_par: var->bits_per_pixel = %d\n", var->bits_per_pixel); 452 printk(KERN_ERR "platinum_var_to_par: var->pixclock = %d\n", var->pixclock); 453 printk(KERN_ERR "platinum_var_to_par: var->vmode = %d\n", var->vmode); 454 return -EINVAL; 455 } 456 457 if (!platinum_reg_init[vmode-1]) { 458 printk(KERN_ERR "platinum_var_to_par, vmode %d not valid.\n", vmode); 459 return -EINVAL; 460 } 461 462 if (platinum_vram_reqd(vmode, cmode) > pinfo->total_vram) { 463 printk(KERN_ERR "platinum_var_to_par, not enough ram for vmode %d, cmode %d.\n", vmode, cmode); 464 return -EINVAL; 465 } 466 467 if (mac_vmode_to_var(vmode, cmode, var)) 468 return -EINVAL; 469 470 if (check_only) 471 return 0; 472 473 pinfo->vmode = vmode; 474 pinfo->cmode = cmode; 475 pinfo->xres = vmode_attrs[vmode-1].hres; 476 pinfo->yres = vmode_attrs[vmode-1].vres; 477 pinfo->xoffset = 0; 478 pinfo->yoffset = 0; 479 pinfo->vxres = pinfo->xres; 480 pinfo->vyres = pinfo->yres; 481 482 return 0; 483} 484 485 486/* 487 * Parse user speficied options (`video=platinumfb:') 488 */ 489static int __init platinumfb_setup(char *options) 490{ 491 char *this_opt; 492 493 if (!options || !*options) 494 return 0; 495 496 while ((this_opt = strsep(&options, ",")) != NULL) { 497 if (!strncmp(this_opt, "vmode:", 6)) { 498 int vmode = simple_strtoul(this_opt+6, NULL, 0); 499 if (vmode > 0 && vmode <= VMODE_MAX) 500 default_vmode = vmode; 501 } else if (!strncmp(this_opt, "cmode:", 6)) { 502 int depth = simple_strtoul(this_opt+6, NULL, 0); 503 switch (depth) { 504 case 0: 505 case 8: 506 default_cmode = CMODE_8; 507 break; 508 case 15: 509 case 16: 510 default_cmode = CMODE_16; 511 break; 512 case 24: 513 case 32: 514 default_cmode = CMODE_32; 515 break; 516 } 517 } 518 } 519 return 0; 520} 521 522#ifdef __powerpc__ 523#define invalidate_cache(addr) \ 524 asm volatile("eieio; dcbf 0,%1" \ 525 : "=m" (*(addr)) : "r" (addr) : "memory"); 526#else 527#define invalidate_cache(addr) 528#endif 529 530static int __devinit platinumfb_probe(struct of_device* odev, 531 const struct of_device_id *match) 532{ 533 struct device_node *dp = odev->node; 534 struct fb_info *info; 535 struct fb_info_platinum *pinfo; 536 volatile __u8 *fbuffer; 537 int bank0, bank1, bank2, bank3, rc; 538 539 printk(KERN_INFO "platinumfb: Found Apple Platinum video hardware\n"); 540 541 info = framebuffer_alloc(sizeof(*pinfo), &odev->dev); 542 if (info == NULL) 543 return -ENOMEM; 544 pinfo = info->par; 545 546 if (of_address_to_resource(dp, 0, &pinfo->rsrc_reg) || 547 of_address_to_resource(dp, 1, &pinfo->rsrc_fb)) { 548 printk(KERN_ERR "platinumfb: Can't get resources\n"); 549 framebuffer_release(info); 550 return -ENXIO; 551 } 552 if (!request_mem_region(pinfo->rsrc_reg.start, 553 pinfo->rsrc_reg.start - 554 pinfo->rsrc_reg.end + 1, 555 "platinumfb registers")) { 556 framebuffer_release(info); 557 return -ENXIO; 558 } 559 if (!request_mem_region(pinfo->rsrc_fb.start, 560 pinfo->rsrc_fb.start 561 - pinfo->rsrc_fb.end + 1, 562 "platinumfb framebuffer")) { 563 release_mem_region(pinfo->rsrc_reg.start, 564 pinfo->rsrc_reg.end - 565 pinfo->rsrc_reg.start + 1); 566 framebuffer_release(info); 567 return -ENXIO; 568 } 569 570 /* frame buffer - map only 4MB */ 571 pinfo->frame_buffer_phys = pinfo->rsrc_fb.start; 572 pinfo->frame_buffer = __ioremap(pinfo->rsrc_fb.start, 0x400000, 573 _PAGE_WRITETHRU); 574 pinfo->base_frame_buffer = pinfo->frame_buffer; 575 576 /* registers */ 577 pinfo->platinum_regs_phys = pinfo->rsrc_reg.start; 578 pinfo->platinum_regs = ioremap(pinfo->rsrc_reg.start, 0x1000); 579 580 pinfo->cmap_regs_phys = 0xf301b000; /* XXX not in prom? */ 581 request_mem_region(pinfo->cmap_regs_phys, 0x1000, "platinumfb cmap"); 582 pinfo->cmap_regs = ioremap(pinfo->cmap_regs_phys, 0x1000); 583 584 /* Grok total video ram */ 585 out_be32(&pinfo->platinum_regs->reg[16].r, (unsigned)pinfo->frame_buffer_phys); 586 out_be32(&pinfo->platinum_regs->reg[20].r, 0x1011); /* select max vram */ 587 out_be32(&pinfo->platinum_regs->reg[24].r, 0); /* switch in vram */ 588 589 fbuffer = pinfo->base_frame_buffer; 590 fbuffer[0x100000] = 0x34; 591 fbuffer[0x100008] = 0x0; 592 invalidate_cache(&fbuffer[0x100000]); 593 fbuffer[0x200000] = 0x56; 594 fbuffer[0x200008] = 0x0; 595 invalidate_cache(&fbuffer[0x200000]); 596 fbuffer[0x300000] = 0x78; 597 fbuffer[0x300008] = 0x0; 598 invalidate_cache(&fbuffer[0x300000]); 599 bank0 = 1; /* builtin 1MB vram, always there */ 600 bank1 = fbuffer[0x100000] == 0x34; 601 bank2 = fbuffer[0x200000] == 0x56; 602 bank3 = fbuffer[0x300000] == 0x78; 603 pinfo->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000; 604 printk(KERN_INFO "platinumfb: Total VRAM = %dMB (%d%d%d%d)\n", (int) (pinfo->total_vram / 1024 / 1024), 605 bank3, bank2, bank1, bank0); 606 607 /* 608 * Try to determine whether we have an old or a new DACula. 609 */ 610 out_8(&pinfo->cmap_regs->addr, 0x40); 611 pinfo->dactype = in_8(&pinfo->cmap_regs->d2); 612 switch (pinfo->dactype) { 613 case 0x3c: 614 pinfo->clktype = 1; 615 printk(KERN_INFO "platinumfb: DACula type 0x3c\n"); 616 break; 617 case 0x84: 618 pinfo->clktype = 0; 619 printk(KERN_INFO "platinumfb: DACula type 0x84\n"); 620 break; 621 default: 622 pinfo->clktype = 0; 623 printk(KERN_INFO "platinumfb: Unknown DACula type: %x\n", pinfo->dactype); 624 break; 625 } 626 dev_set_drvdata(&odev->dev, info); 627 628 rc = platinum_init_fb(info); 629 if (rc != 0) { 630 iounmap(pinfo->frame_buffer); 631 iounmap(pinfo->platinum_regs); 632 iounmap(pinfo->cmap_regs); 633 dev_set_drvdata(&odev->dev, NULL); 634 framebuffer_release(info); 635 } 636 637 return rc; 638} 639 640static int __devexit platinumfb_remove(struct of_device* odev) 641{ 642 struct fb_info *info = dev_get_drvdata(&odev->dev); 643 struct fb_info_platinum *pinfo = info->par; 644 645 unregister_framebuffer (info); 646 647 /* Unmap frame buffer and registers */ 648 release_mem_region(pinfo->rsrc_fb.start, 649 pinfo->rsrc_fb.end - 650 pinfo->rsrc_fb.start + 1); 651 release_mem_region(pinfo->rsrc_reg.start, 652 pinfo->rsrc_reg.end - 653 pinfo->rsrc_reg.start + 1); 654 iounmap(pinfo->frame_buffer); 655 iounmap(pinfo->platinum_regs); 656 release_mem_region(pinfo->cmap_regs_phys, 0x1000); 657 iounmap(pinfo->cmap_regs); 658 659 framebuffer_release(info); 660 661 return 0; 662} 663 664static struct of_device_id platinumfb_match[] = 665{ 666 { 667 .name = "platinum", 668 }, 669 {}, 670}; 671 672static struct of_platform_driver platinum_driver = 673{ 674 .name = "platinumfb", 675 .match_table = platinumfb_match, 676 .probe = platinumfb_probe, 677 .remove = platinumfb_remove, 678}; 679 680static int __init platinumfb_init(void) 681{ 682#ifndef MODULE 683 char *option = NULL; 684 685 if (fb_get_options("platinumfb", &option)) 686 return -ENODEV; 687 platinumfb_setup(option); 688#endif 689 of_register_platform_driver(&platinum_driver); 690 691 return 0; 692} 693 694static void __exit platinumfb_exit(void) 695{ 696 of_unregister_platform_driver(&platinum_driver); 697} 698 699MODULE_LICENSE("GPL"); 700MODULE_DESCRIPTION("framebuffer driver for Apple Platinum video"); 701module_init(platinumfb_init); 702 703#ifdef MODULE 704module_exit(platinumfb_exit); 705#endif