1 /* 2 * Geode LX framebuffer driver. 3 * 4 * Copyright (C) 2007 Advanced Micro Devices, Inc. 5 * Built from gxfb (which is Copyright (C) 2006 Arcom Control Systems Ltd.) 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the 9 * Free Software Foundation; either version 2 of the License, or (at your 10 * option) any later version. 11 */ 12 13 #include <linux/module.h> 14 #include <linux/kernel.h> 15 #include <linux/errno.h> 16 #include <linux/string.h> 17 #include <linux/console.h> 18 #include <linux/mm.h> 19 #include <linux/suspend.h> 20 #include <linux/delay.h> 21 #include <linux/fb.h> 22 #include <linux/init.h> 23 #include <linux/pci.h> 24 #include <linux/uaccess.h> 25 26 #include <asm/olpc.h> 27 28 #include "lxfb.h" 29 30 static char *mode_option; 31 static int noclear, nopanel, nocrt; 32 static int vram; 33 static int vt_switch; 34 35 /* Most of these modes are sorted in ascending order, but 36 * since the first entry in this table is the "default" mode, 37 * we try to make it something sane - 640x480-60 is sane 38 */ 39 40 static struct fb_videomode geode_modedb[] = { 41 /* 640x480-60 */ 42 { NULL, 60, 640, 480, 39682, 48, 8, 25, 2, 88, 2, 43 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 44 FB_VMODE_NONINTERLACED, 0 }, 45 /* 640x400-70 */ 46 { NULL, 70, 640, 400, 39770, 40, 8, 28, 5, 96, 2, 47 FB_SYNC_HOR_HIGH_ACT, 48 FB_VMODE_NONINTERLACED, 0 }, 49 /* 640x480-70 */ 50 { NULL, 70, 640, 480, 35014, 88, 24, 15, 2, 64, 3, 51 0, FB_VMODE_NONINTERLACED, 0 }, 52 /* 640x480-72 */ 53 { NULL, 72, 640, 480, 32102, 120, 16, 20, 1, 40, 3, 54 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 55 FB_VMODE_NONINTERLACED, 0 }, 56 /* 640x480-75 */ 57 { NULL, 75, 640, 480, 31746, 120, 16, 16, 1, 64, 3, 58 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 59 FB_VMODE_NONINTERLACED, 0 }, 60 /* 640x480-85 */ 61 { NULL, 85, 640, 480, 27780, 80, 56, 25, 1, 56, 3, 62 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 63 FB_VMODE_NONINTERLACED, 0 }, 64 /* 640x480-90 */ 65 { NULL, 90, 640, 480, 26392, 96, 32, 22, 1, 64, 3, 66 0, FB_VMODE_NONINTERLACED, 0 }, 67 /* 640x480-100 */ 68 { NULL, 100, 640, 480, 23167, 104, 40, 25, 1, 64, 3, 69 0, FB_VMODE_NONINTERLACED, 0 }, 70 /* 640x480-60 */ 71 { NULL, 60, 640, 480, 39682, 48, 16, 25, 10, 88, 2, 72 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 73 FB_VMODE_NONINTERLACED, 0 }, 74 /* 800x600-56 */ 75 { NULL, 56, 800, 600, 27901, 128, 24, 22, 1, 72, 2, 76 0, FB_VMODE_NONINTERLACED, 0 }, 77 /* 800x600-60 */ 78 { NULL, 60, 800, 600, 25131, 72, 32, 23, 1, 136, 4, 79 0, FB_VMODE_NONINTERLACED, 0 }, 80 /* 800x600-70 */ 81 { NULL, 70, 800, 600, 21873, 120, 40, 21, 4, 80, 3, 82 0, FB_VMODE_NONINTERLACED, 0 }, 83 /* 800x600-72 */ 84 { NULL, 72, 800, 600, 20052, 64, 56, 23, 37, 120, 6, 85 0, FB_VMODE_NONINTERLACED, 0 }, 86 /* 800x600-75 */ 87 { NULL, 75, 800, 600, 20202, 160, 16, 21, 1, 80, 3, 88 0, FB_VMODE_NONINTERLACED, 0 }, 89 /* 800x600-85 */ 90 { NULL, 85, 800, 600, 17790, 152, 32, 27, 1, 64, 3, 91 0, FB_VMODE_NONINTERLACED, 0 }, 92 /* 800x600-90 */ 93 { NULL, 90, 800, 600, 16648, 128, 40, 28, 1, 88, 3, 94 0, FB_VMODE_NONINTERLACED, 0 }, 95 /* 800x600-100 */ 96 { NULL, 100, 800, 600, 14667, 136, 48, 27, 1, 88, 3, 97 0, FB_VMODE_NONINTERLACED, 0 }, 98 /* 800x600-60 */ 99 { NULL, 60, 800, 600, 25131, 88, 40, 23, 1, 128, 4, 100 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 101 FB_VMODE_NONINTERLACED, 0 }, 102 /* 1024x768-60 */ 103 { NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6, 104 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 105 FB_VMODE_NONINTERLACED, 0 }, 106 /* 1024x768-70 */ 107 { NULL, 70, 1024, 768, 13346, 144, 24, 29, 3, 136, 6, 108 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 109 FB_VMODE_NONINTERLACED, 0 }, 110 /* 1024x768-72 */ 111 { NULL, 72, 1024, 768, 12702, 168, 56, 29, 4, 112, 3, 112 0, FB_VMODE_NONINTERLACED, 0 }, 113 /* 1024x768-75 */ 114 { NULL, 75, 1024, 768, 12703, 176, 16, 28, 1, 96, 3, 115 0, FB_VMODE_NONINTERLACED, 0 }, 116 /* 1024x768-85 */ 117 { NULL, 85, 1024, 768, 10581, 208, 48, 36, 1, 96, 3, 118 0, FB_VMODE_NONINTERLACED, 0 }, 119 /* 1024x768-90 */ 120 { NULL, 90, 1024, 768, 9981, 176, 64, 37, 1, 112, 3, 121 0, FB_VMODE_NONINTERLACED, 0 }, 122 /* 1024x768-100 */ 123 { NULL, 100, 1024, 768, 8825, 184, 72, 42, 1, 112, 3, 124 0, FB_VMODE_NONINTERLACED, 0 }, 125 /* 1024x768-60 */ 126 { NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6, 127 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 128 FB_VMODE_NONINTERLACED, 0 }, 129 /* 1152x864-60 */ 130 { NULL, 60, 1152, 864, 12251, 184, 64, 27, 1, 120, 3, 131 0, FB_VMODE_NONINTERLACED, 0 }, 132 /* 1152x864-70 */ 133 { NULL, 70, 1152, 864, 10254, 192, 72, 32, 8, 120, 3, 134 0, FB_VMODE_NONINTERLACED, 0 }, 135 /* 1152x864-72 */ 136 { NULL, 72, 1152, 864, 9866, 200, 72, 33, 7, 128, 3, 137 0, FB_VMODE_NONINTERLACED, 0 }, 138 /* 1152x864-75 */ 139 { NULL, 75, 1152, 864, 9259, 256, 64, 32, 1, 128, 3, 140 0, FB_VMODE_NONINTERLACED, 0 }, 141 /* 1152x864-85 */ 142 { NULL, 85, 1152, 864, 8357, 200, 72, 37, 3, 128, 3, 143 0, FB_VMODE_NONINTERLACED, 0 }, 144 /* 1152x864-90 */ 145 { NULL, 90, 1152, 864, 7719, 208, 80, 42, 9, 128, 3, 146 0, FB_VMODE_NONINTERLACED, 0 }, 147 /* 1152x864-100 */ 148 { NULL, 100, 1152, 864, 6947, 208, 80, 48, 3, 128, 3, 149 0, FB_VMODE_NONINTERLACED, 0 }, 150 /* 1152x864-60 */ 151 { NULL, 60, 1152, 864, 12251, 184, 64, 27, 1, 120, 3, 152 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 153 FB_VMODE_NONINTERLACED, 0 }, 154 /* 1280x1024-60 */ 155 { NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3, 156 0, FB_VMODE_NONINTERLACED, 0 }, 157 /* 1280x1024-70 */ 158 { NULL, 70, 1280, 1024, 7719, 224, 88, 38, 6, 136, 3, 159 0, FB_VMODE_NONINTERLACED, 0 }, 160 /* 1280x1024-72 */ 161 { NULL, 72, 1280, 1024, 7490, 224, 88, 39, 7, 136, 3, 162 0, FB_VMODE_NONINTERLACED, 0 }, 163 /* 1280x1024-75 */ 164 { NULL, 75, 1280, 1024, 7409, 248, 16, 38, 1, 144, 3, 165 0, FB_VMODE_NONINTERLACED, 0 }, 166 /* 1280x1024-85 */ 167 { NULL, 85, 1280, 1024, 6351, 224, 64, 44, 1, 160, 3, 168 0, FB_VMODE_NONINTERLACED, 0 }, 169 /* 1280x1024-90 */ 170 { NULL, 90, 1280, 1024, 5791, 240, 96, 51, 12, 144, 3, 171 0, FB_VMODE_NONINTERLACED, 0 }, 172 /* 1280x1024-100 */ 173 { NULL, 100, 1280, 1024, 5212, 240, 96, 57, 6, 144, 3, 174 0, FB_VMODE_NONINTERLACED, 0 }, 175 /* 1280x1024-60 */ 176 { NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3, 177 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 178 FB_VMODE_NONINTERLACED, 0 }, 179 /* 1600x1200-60 */ 180 { NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3, 181 0, FB_VMODE_NONINTERLACED, 0 }, 182 /* 1600x1200-70 */ 183 { NULL, 70, 1600, 1200, 5291, 304, 64, 46, 1, 192, 3, 184 0, FB_VMODE_NONINTERLACED, 0 }, 185 /* 1600x1200-72 */ 186 { NULL, 72, 1600, 1200, 5053, 288, 112, 47, 13, 176, 3, 187 0, FB_VMODE_NONINTERLACED, 0 }, 188 /* 1600x1200-75 */ 189 { NULL, 75, 1600, 1200, 4938, 304, 64, 46, 1, 192, 3, 190 0, FB_VMODE_NONINTERLACED, 0 }, 191 /* 1600x1200-85 */ 192 { NULL, 85, 1600, 1200, 4357, 304, 64, 46, 1, 192, 3, 193 0, FB_VMODE_NONINTERLACED, 0 }, 194 /* 1600x1200-90 */ 195 { NULL, 90, 1600, 1200, 3981, 304, 128, 60, 1, 176, 3, 196 0, FB_VMODE_NONINTERLACED, 0 }, 197 /* 1600x1200-100 */ 198 { NULL, 100, 1600, 1200, 3563, 304, 128, 67, 1, 176, 3, 199 0, FB_VMODE_NONINTERLACED, 0 }, 200 /* 1600x1200-60 */ 201 { NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3, 202 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 203 FB_VMODE_NONINTERLACED, 0 }, 204 /* 1920x1440-60 */ 205 { NULL, 60, 1920, 1440, 4273, 344, 128, 56, 1, 208, 3, 206 0, FB_VMODE_NONINTERLACED, 0 }, 207 /* 1920x1440-70 */ 208 { NULL, 70, 1920, 1440, 3593, 360, 152, 55, 8, 208, 3, 209 0, FB_VMODE_NONINTERLACED, 0 }, 210 /* 1920x1440-72 */ 211 { NULL, 72, 1920, 1440, 3472, 360, 152, 68, 4, 208, 3, 212 0, FB_VMODE_NONINTERLACED, 0 }, 213 /* 1920x1440-75 */ 214 { NULL, 75, 1920, 1440, 3367, 352, 144, 56, 1, 224, 3, 215 0, FB_VMODE_NONINTERLACED, 0 }, 216 /* 1920x1440-85 */ 217 { NULL, 85, 1920, 1440, 2929, 368, 152, 68, 1, 216, 3, 218 0, FB_VMODE_NONINTERLACED, 0 }, 219 }; 220 221 static struct fb_videomode olpc_dcon_modedb[] = { 222 /* The only mode the DCON has is 1200x900 */ 223 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3, 224 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 225 FB_VMODE_NONINTERLACED, 0 } 226 }; 227 228 static void get_modedb(struct fb_videomode **modedb, unsigned int *size) 229 { 230 if (olpc_has_dcon()) { 231 *modedb = (struct fb_videomode *) olpc_dcon_modedb; 232 *size = ARRAY_SIZE(olpc_dcon_modedb); 233 } else { 234 *modedb = (struct fb_videomode *) geode_modedb; 235 *size = ARRAY_SIZE(geode_modedb); 236 } 237 } 238 239 static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 240 { 241 if (var->xres > 1920 || var->yres > 1440) 242 return -EINVAL; 243 244 if (var->bits_per_pixel == 32) { 245 var->red.offset = 16; var->red.length = 8; 246 var->green.offset = 8; var->green.length = 8; 247 var->blue.offset = 0; var->blue.length = 8; 248 } else if (var->bits_per_pixel == 16) { 249 var->red.offset = 11; var->red.length = 5; 250 var->green.offset = 5; var->green.length = 6; 251 var->blue.offset = 0; var->blue.length = 5; 252 } else if (var->bits_per_pixel == 8) { 253 var->red.offset = 0; var->red.length = 8; 254 var->green.offset = 0; var->green.length = 8; 255 var->blue.offset = 0; var->blue.length = 8; 256 } else 257 return -EINVAL; 258 259 var->transp.offset = 0; var->transp.length = 0; 260 261 /* Enough video memory? */ 262 if ((lx_get_pitch(var->xres, var->bits_per_pixel) * var->yres) 263 > info->fix.smem_len) 264 return -EINVAL; 265 266 return 0; 267 } 268 269 static int lxfb_set_par(struct fb_info *info) 270 { 271 if (info->var.bits_per_pixel > 8) 272 info->fix.visual = FB_VISUAL_TRUECOLOR; 273 else 274 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 275 276 info->fix.line_length = lx_get_pitch(info->var.xres, 277 info->var.bits_per_pixel); 278 279 lx_set_mode(info); 280 return 0; 281 } 282 283 static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf) 284 { 285 chan &= 0xffff; 286 chan >>= 16 - bf->length; 287 return chan << bf->offset; 288 } 289 290 static int lxfb_setcolreg(unsigned regno, unsigned red, unsigned green, 291 unsigned blue, unsigned transp, 292 struct fb_info *info) 293 { 294 if (info->var.grayscale) { 295 /* grayscale = 0.30*R + 0.59*G + 0.11*B */ 296 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; 297 } 298 299 /* Truecolor has hardware independent palette */ 300 if (info->fix.visual == FB_VISUAL_TRUECOLOR) { 301 u32 *pal = info->pseudo_palette; 302 u32 v; 303 304 if (regno >= 16) 305 return -EINVAL; 306 307 v = chan_to_field(red, &info->var.red); 308 v |= chan_to_field(green, &info->var.green); 309 v |= chan_to_field(blue, &info->var.blue); 310 311 pal[regno] = v; 312 } else { 313 if (regno >= 256) 314 return -EINVAL; 315 316 lx_set_palette_reg(info, regno, red, green, blue); 317 } 318 319 return 0; 320 } 321 322 static int lxfb_blank(int blank_mode, struct fb_info *info) 323 { 324 return lx_blank_display(info, blank_mode); 325 } 326 327 328 static int lxfb_map_video_memory(struct fb_info *info, struct pci_dev *dev) 329 { 330 struct lxfb_par *par = info->par; 331 int ret; 332 333 ret = pci_enable_device(dev); 334 335 if (ret) 336 return ret; 337 338 ret = pci_request_region(dev, 0, "lxfb-framebuffer"); 339 340 if (ret) 341 return ret; 342 343 ret = pci_request_region(dev, 1, "lxfb-gp"); 344 345 if (ret) 346 return ret; 347 348 ret = pci_request_region(dev, 2, "lxfb-vg"); 349 350 if (ret) 351 return ret; 352 353 ret = pci_request_region(dev, 3, "lxfb-vp"); 354 355 if (ret) 356 return ret; 357 358 info->fix.smem_start = pci_resource_start(dev, 0); 359 info->fix.smem_len = vram ? vram : lx_framebuffer_size(); 360 361 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); 362 363 ret = -ENOMEM; 364 365 if (info->screen_base == NULL) 366 return ret; 367 368 par->gp_regs = pci_ioremap_bar(dev, 1); 369 370 if (par->gp_regs == NULL) 371 return ret; 372 373 par->dc_regs = pci_ioremap_bar(dev, 2); 374 375 if (par->dc_regs == NULL) 376 return ret; 377 378 par->vp_regs = pci_ioremap_bar(dev, 3); 379 380 if (par->vp_regs == NULL) 381 return ret; 382 383 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK); 384 write_dc(par, DC_GLIU0_MEM_OFFSET, info->fix.smem_start & 0xFF000000); 385 write_dc(par, DC_UNLOCK, DC_UNLOCK_LOCK); 386 387 dev_info(&dev->dev, "%d KB of video memory at 0x%lx\n", 388 info->fix.smem_len / 1024, info->fix.smem_start); 389 390 return 0; 391 } 392 393 static struct fb_ops lxfb_ops = { 394 .owner = THIS_MODULE, 395 .fb_check_var = lxfb_check_var, 396 .fb_set_par = lxfb_set_par, 397 .fb_setcolreg = lxfb_setcolreg, 398 .fb_blank = lxfb_blank, 399 /* No HW acceleration for now. */ 400 .fb_fillrect = cfb_fillrect, 401 .fb_copyarea = cfb_copyarea, 402 .fb_imageblit = cfb_imageblit, 403 }; 404 405 static struct fb_info *lxfb_init_fbinfo(struct device *dev) 406 { 407 struct lxfb_par *par; 408 struct fb_info *info; 409 410 /* Alloc enough space for the pseudo palette. */ 411 info = framebuffer_alloc(sizeof(struct lxfb_par) + sizeof(u32) * 16, 412 dev); 413 if (!info) 414 return NULL; 415 416 par = info->par; 417 418 strcpy(info->fix.id, "Geode LX"); 419 420 info->fix.type = FB_TYPE_PACKED_PIXELS; 421 info->fix.type_aux = 0; 422 info->fix.xpanstep = 0; 423 info->fix.ypanstep = 0; 424 info->fix.ywrapstep = 0; 425 info->fix.accel = FB_ACCEL_NONE; 426 427 info->var.nonstd = 0; 428 info->var.activate = FB_ACTIVATE_NOW; 429 info->var.height = -1; 430 info->var.width = -1; 431 info->var.accel_flags = 0; 432 info->var.vmode = FB_VMODE_NONINTERLACED; 433 434 info->fbops = &lxfb_ops; 435 info->flags = FBINFO_DEFAULT; 436 info->node = -1; 437 438 info->pseudo_palette = (void *)par + sizeof(struct lxfb_par); 439 440 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 441 framebuffer_release(info); 442 return NULL; 443 } 444 445 info->var.grayscale = 0; 446 447 return info; 448 } 449 450 #ifdef CONFIG_PM 451 static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state) 452 { 453 struct fb_info *info = pci_get_drvdata(pdev); 454 455 if (state.event == PM_EVENT_SUSPEND) { 456 console_lock(); 457 lx_powerdown(info); 458 fb_set_suspend(info, 1); 459 console_unlock(); 460 } 461 462 /* there's no point in setting PCI states; we emulate PCI, so 463 * we don't end up getting power savings anyways */ 464 465 return 0; 466 } 467 468 static int lxfb_resume(struct pci_dev *pdev) 469 { 470 struct fb_info *info = pci_get_drvdata(pdev); 471 int ret; 472 473 console_lock(); 474 ret = lx_powerup(info); 475 if (ret) { 476 printk(KERN_ERR "lxfb: power up failed!\n"); 477 return ret; 478 } 479 480 fb_set_suspend(info, 0); 481 console_unlock(); 482 return 0; 483 } 484 #else 485 #define lxfb_suspend NULL 486 #define lxfb_resume NULL 487 #endif 488 489 static int lxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) 490 { 491 struct lxfb_par *par; 492 struct fb_info *info; 493 int ret; 494 495 struct fb_videomode *modedb_ptr; 496 unsigned int modedb_size; 497 498 info = lxfb_init_fbinfo(&pdev->dev); 499 500 if (info == NULL) 501 return -ENOMEM; 502 503 par = info->par; 504 505 ret = lxfb_map_video_memory(info, pdev); 506 507 if (ret < 0) { 508 dev_err(&pdev->dev, 509 "failed to map frame buffer or controller registers\n"); 510 goto err; 511 } 512 513 /* Set up the desired outputs */ 514 515 par->output = 0; 516 par->output |= (nopanel) ? 0 : OUTPUT_PANEL; 517 par->output |= (nocrt) ? 0 : OUTPUT_CRT; 518 519 /* Set up the mode database */ 520 521 get_modedb(&modedb_ptr, &modedb_size); 522 ret = fb_find_mode(&info->var, info, mode_option, 523 modedb_ptr, modedb_size, NULL, 16); 524 525 if (ret == 0 || ret == 4) { 526 dev_err(&pdev->dev, "could not find valid video mode\n"); 527 ret = -EINVAL; 528 goto err; 529 } 530 531 /* Clear the screen of garbage, unless noclear was specified, 532 * in which case we assume the user knows what he is doing */ 533 534 if (!noclear) 535 memset_io(info->screen_base, 0, info->fix.smem_len); 536 537 /* Set the mode */ 538 539 lxfb_check_var(&info->var, info); 540 lxfb_set_par(info); 541 542 pm_set_vt_switch(vt_switch); 543 544 if (register_framebuffer(info) < 0) { 545 ret = -EINVAL; 546 goto err; 547 } 548 pci_set_drvdata(pdev, info); 549 fb_info(info, "%s frame buffer device\n", info->fix.id); 550 551 return 0; 552 553 err: 554 if (info->screen_base) { 555 iounmap(info->screen_base); 556 pci_release_region(pdev, 0); 557 } 558 if (par->gp_regs) { 559 iounmap(par->gp_regs); 560 pci_release_region(pdev, 1); 561 } 562 if (par->dc_regs) { 563 iounmap(par->dc_regs); 564 pci_release_region(pdev, 2); 565 } 566 if (par->vp_regs) { 567 iounmap(par->vp_regs); 568 pci_release_region(pdev, 3); 569 } 570 571 fb_dealloc_cmap(&info->cmap); 572 framebuffer_release(info); 573 574 return ret; 575 } 576 577 static void lxfb_remove(struct pci_dev *pdev) 578 { 579 struct fb_info *info = pci_get_drvdata(pdev); 580 struct lxfb_par *par = info->par; 581 582 unregister_framebuffer(info); 583 584 iounmap(info->screen_base); 585 pci_release_region(pdev, 0); 586 587 iounmap(par->gp_regs); 588 pci_release_region(pdev, 1); 589 590 iounmap(par->dc_regs); 591 pci_release_region(pdev, 2); 592 593 iounmap(par->vp_regs); 594 pci_release_region(pdev, 3); 595 596 fb_dealloc_cmap(&info->cmap); 597 framebuffer_release(info); 598 } 599 600 static struct pci_device_id lxfb_id_table[] = { 601 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_VIDEO) }, 602 { 0, } 603 }; 604 605 MODULE_DEVICE_TABLE(pci, lxfb_id_table); 606 607 static struct pci_driver lxfb_driver = { 608 .name = "lxfb", 609 .id_table = lxfb_id_table, 610 .probe = lxfb_probe, 611 .remove = lxfb_remove, 612 .suspend = lxfb_suspend, 613 .resume = lxfb_resume, 614 }; 615 616 #ifndef MODULE 617 static int __init lxfb_setup(char *options) 618 { 619 char *opt; 620 621 if (!options || !*options) 622 return 0; 623 624 while ((opt = strsep(&options, ",")) != NULL) { 625 if (!*opt) 626 continue; 627 628 if (!strcmp(opt, "noclear")) 629 noclear = 1; 630 else if (!strcmp(opt, "nopanel")) 631 nopanel = 1; 632 else if (!strcmp(opt, "nocrt")) 633 nocrt = 1; 634 else 635 mode_option = opt; 636 } 637 638 return 0; 639 } 640 #endif 641 642 static int __init lxfb_init(void) 643 { 644 #ifndef MODULE 645 char *option = NULL; 646 647 if (fb_get_options("lxfb", &option)) 648 return -ENODEV; 649 650 lxfb_setup(option); 651 #endif 652 return pci_register_driver(&lxfb_driver); 653 } 654 static void __exit lxfb_cleanup(void) 655 { 656 pci_unregister_driver(&lxfb_driver); 657 } 658 659 module_init(lxfb_init); 660 module_exit(lxfb_cleanup); 661 662 module_param(mode_option, charp, 0); 663 MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])"); 664 665 module_param(vram, int, 0); 666 MODULE_PARM_DESC(vram, "video memory size"); 667 668 module_param(vt_switch, int, 0); 669 MODULE_PARM_DESC(vt_switch, "enable VT switch during suspend/resume"); 670 671 MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode LX"); 672 MODULE_LICENSE("GPL"); 673