Blame view
drivers/video/au1100fb.c
18.7 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 |
/* * BRIEF MODULE DESCRIPTION * Au1100 LCD Driver. * |
3b495f2bb Au1100 FB driver ... |
5 6 7 8 9 |
* Rewritten for 2.6 by Embedded Alley Solutions * <source@embeddedalley.com>, based on submissions by * Karl Lessard <klessard@sunrisetelecom.com> * <c.pellegrin@exadron.com> * |
f77f50ca1 [PATCH] au1100fb:... |
10 |
* PM support added by Rodolfo Giometti <giometti@linux.it> |
ca27ac4cc [PATCH] au1100fb:... |
11 |
* Cursor enable/disable by Rodolfo Giometti <giometti@linux.it> |
f77f50ca1 [PATCH] au1100fb:... |
12 |
* |
1da177e4c Linux-2.6.12-rc2 |
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
* Copyright 2002 MontaVista Software * Author: MontaVista Software, Inc. * ppopov@mvista.com or source@mvista.com * * Copyright 2002 Alchemy Semiconductor * Author: Alchemy Semiconductor * * Based on: * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device * Created 28 Dec 1997 by Geert Uytterhoeven * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ |
1da177e4c Linux-2.6.12-rc2 |
44 45 46 47 48 |
#include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> |
1da177e4c Linux-2.6.12-rc2 |
49 50 |
#include <linux/fb.h> #include <linux/init.h> |
3b495f2bb Au1100 FB driver ... |
51 52 53 |
#include <linux/interrupt.h> #include <linux/ctype.h> #include <linux/dma-mapping.h> |
cacfc8cf4 [PATCH] au1100fb:... |
54 |
#include <linux/platform_device.h> |
5a0e3ad6a include cleanup: ... |
55 |
#include <linux/slab.h> |
1da177e4c Linux-2.6.12-rc2 |
56 |
|
3b495f2bb Au1100 FB driver ... |
57 |
#include <asm/mach-au1x00/au1000.h> |
1da177e4c Linux-2.6.12-rc2 |
58 |
|
3b495f2bb Au1100 FB driver ... |
59 60 61 |
#define DEBUG 0 #include "au1100fb.h" |
1da177e4c Linux-2.6.12-rc2 |
62 |
|
3b495f2bb Au1100 FB driver ... |
63 64 |
#define DRIVER_NAME "au1100fb" #define DRIVER_DESC "LCD controller driver for AU1100 processors" |
1da177e4c Linux-2.6.12-rc2 |
65 |
|
3b495f2bb Au1100 FB driver ... |
66 67 |
#define to_au1100fb_device(_info) \ (_info ? container_of(_info, struct au1100fb_device, info) : NULL); |
1da177e4c Linux-2.6.12-rc2 |
68 |
|
3b495f2bb Au1100 FB driver ... |
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
/* Bitfields format supported by the controller. Note that the order of formats * SHOULD be the same as in the LCD_CONTROL_SBPPF field, so we can retrieve the * right pixel format by doing rgb_bitfields[LCD_CONTROL_SBPPF_XXX >> LCD_CONTROL_SBPPF] */ struct fb_bitfield rgb_bitfields[][4] = { /* Red, Green, Blue, Transp */ { { 10, 6, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 0, 0, 0 } }, { { 11, 5, 0 }, { 5, 6, 0 }, { 0, 5, 0 }, { 0, 0, 0 } }, { { 11, 5, 0 }, { 6, 5, 0 }, { 0, 6, 0 }, { 0, 0, 0 } }, { { 10, 5, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 15, 1, 0 } }, { { 11, 5, 0 }, { 6, 5, 0 }, { 1, 5, 0 }, { 0, 1, 0 } }, /* The last is used to describe 12bpp format */ { { 8, 4, 0 }, { 4, 4, 0 }, { 0, 4, 0 }, { 0, 0, 0 } }, |
1da177e4c Linux-2.6.12-rc2 |
84 |
}; |
362992b19 VIDEO: Au1100fb: ... |
85 |
static struct fb_fix_screeninfo au1100fb_fix __devinitdata = { |
3b495f2bb Au1100 FB driver ... |
86 87 88 89 90 |
.id = "AU1100 FB", .xpanstep = 1, .ypanstep = 1, .type = FB_TYPE_PACKED_PIXELS, .accel = FB_ACCEL_NONE, |
1da177e4c Linux-2.6.12-rc2 |
91 |
}; |
362992b19 VIDEO: Au1100fb: ... |
92 |
static struct fb_var_screeninfo au1100fb_var __devinitdata = { |
3b495f2bb Au1100 FB driver ... |
93 94 95 96 |
.activate = FB_ACTIVATE_NOW, .height = -1, .width = -1, .vmode = FB_VMODE_NONINTERLACED, |
1da177e4c Linux-2.6.12-rc2 |
97 |
}; |
8e92f21ba au1100fb: move au... |
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
/* fb_blank * Blank the screen. Depending on the mode, the screen will be * activated with the backlight color, or desactivated */ static int au1100fb_fb_blank(int blank_mode, struct fb_info *fbi) { struct au1100fb_device *fbdev = to_au1100fb_device(fbi); print_dbg("fb_blank %d %p", blank_mode, fbi); switch (blank_mode) { case VESA_NO_BLANKING: /* Turn on panel */ fbdev->regs->lcd_control |= LCD_CONTROL_GO; #ifdef CONFIG_MIPS_PB1100 |
d121c3f3c fb: fix au1100fb ... |
114 |
if (fbdev->panel_idx == 1) { |
8e92f21ba au1100fb: move au... |
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
au_writew(au_readw(PB1100_G_CONTROL) | (PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD), PB1100_G_CONTROL); } #endif au_sync(); break; case VESA_VSYNC_SUSPEND: case VESA_HSYNC_SUSPEND: case VESA_POWERDOWN: /* Turn off panel */ fbdev->regs->lcd_control &= ~LCD_CONTROL_GO; #ifdef CONFIG_MIPS_PB1100 |
d121c3f3c fb: fix au1100fb ... |
129 |
if (fbdev->panel_idx == 1) { |
8e92f21ba au1100fb: move au... |
130 131 132 133 134 135 136 137 138 139 140 141 142 |
au_writew(au_readw(PB1100_G_CONTROL) & ~(PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD), PB1100_G_CONTROL); } #endif au_sync(); break; default: break; } return 0; } |
3b495f2bb Au1100 FB driver ... |
143 144 145 |
/* * Set hardware with var settings. This will enable the controller with a specific * mode, normally validated with the fb_check_var method |
1da177e4c Linux-2.6.12-rc2 |
146 |
*/ |
3b495f2bb Au1100 FB driver ... |
147 |
int au1100fb_setmode(struct au1100fb_device *fbdev) |
1da177e4c Linux-2.6.12-rc2 |
148 |
{ |
3b495f2bb Au1100 FB driver ... |
149 150 151 |
struct fb_info *info = &fbdev->info; u32 words; int index; |
1da177e4c Linux-2.6.12-rc2 |
152 |
|
3b495f2bb Au1100 FB driver ... |
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
if (!fbdev) return -EINVAL; /* Update var-dependent FB info */ if (panel_is_active(fbdev->panel) || panel_is_color(fbdev->panel)) { if (info->var.bits_per_pixel <= 8) { /* palettized */ info->var.red.offset = 0; info->var.red.length = info->var.bits_per_pixel; info->var.red.msb_right = 0; info->var.green.offset = 0; info->var.green.length = info->var.bits_per_pixel; info->var.green.msb_right = 0; info->var.blue.offset = 0; info->var.blue.length = info->var.bits_per_pixel; info->var.blue.msb_right = 0; info->var.transp.offset = 0; info->var.transp.length = 0; info->var.transp.msb_right = 0; info->fix.visual = FB_VISUAL_PSEUDOCOLOR; info->fix.line_length = info->var.xres_virtual / (8/info->var.bits_per_pixel); } else { /* non-palettized */ index = (fbdev->panel->control_base & LCD_CONTROL_SBPPF_MASK) >> LCD_CONTROL_SBPPF_BIT; info->var.red = rgb_bitfields[index][0]; info->var.green = rgb_bitfields[index][1]; info->var.blue = rgb_bitfields[index][2]; info->var.transp = rgb_bitfields[index][3]; info->fix.visual = FB_VISUAL_TRUECOLOR; info->fix.line_length = info->var.xres_virtual << 1; /* depth=16 */ |
bb39e4197 [PATCH] au1100fb:... |
189 |
} |
3b495f2bb Au1100 FB driver ... |
190 191 192 193 |
} else { /* mono */ info->fix.visual = FB_VISUAL_MONO10; info->fix.line_length = info->var.xres_virtual / 8; |
1da177e4c Linux-2.6.12-rc2 |
194 |
} |
3b495f2bb Au1100 FB driver ... |
195 |
info->screen_size = info->fix.line_length * info->var.yres_virtual; |
fd2d54300 [PATCH] au1100fb:... |
196 197 |
info->var.rotate = ((fbdev->panel->control_base&LCD_CONTROL_SM_MASK) \ >> LCD_CONTROL_SM_BIT) * 90; |
1da177e4c Linux-2.6.12-rc2 |
198 |
|
3b495f2bb Au1100 FB driver ... |
199 |
/* Determine BPP mode and format */ |
fd2d54300 [PATCH] au1100fb:... |
200 |
fbdev->regs->lcd_control = fbdev->panel->control_base; |
3b495f2bb Au1100 FB driver ... |
201 |
fbdev->regs->lcd_horztiming = fbdev->panel->horztiming; |
3b495f2bb Au1100 FB driver ... |
202 |
fbdev->regs->lcd_verttiming = fbdev->panel->verttiming; |
3b495f2bb Au1100 FB driver ... |
203 |
fbdev->regs->lcd_clkcontrol = fbdev->panel->clkcontrol_base; |
bb39e4197 [PATCH] au1100fb:... |
204 205 |
fbdev->regs->lcd_intenable = 0; fbdev->regs->lcd_intstatus = 0; |
3b495f2bb Au1100 FB driver ... |
206 207 208 209 210 211 212 213 214 215 216 217 |
fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(fbdev->fb_phys); if (panel_is_dual(fbdev->panel)) { /* Second panel display seconf half of screen if possible, * otherwise display the same as the first panel */ if (info->var.yres_virtual >= (info->var.yres << 1)) { fbdev->regs->lcd_dmaaddr1 = LCD_DMA_SA_N(fbdev->fb_phys + (info->fix.line_length * (info->var.yres_virtual >> 1))); } else { fbdev->regs->lcd_dmaaddr1 = LCD_DMA_SA_N(fbdev->fb_phys); } |
1da177e4c Linux-2.6.12-rc2 |
218 |
} |
1da177e4c Linux-2.6.12-rc2 |
219 |
|
3b495f2bb Au1100 FB driver ... |
220 221 222 223 224 225 226 227 |
words = info->fix.line_length / sizeof(u32); if (!info->var.rotate || (info->var.rotate == 180)) { words *= info->var.yres_virtual; if (info->var.rotate /* 180 */) { words -= (words % 8); /* should be divisable by 8 */ } } fbdev->regs->lcd_words = LCD_WRD_WRDS_N(words); |
1da177e4c Linux-2.6.12-rc2 |
228 |
|
3b495f2bb Au1100 FB driver ... |
229 230 |
fbdev->regs->lcd_pwmdiv = 0; fbdev->regs->lcd_pwmhi = 0; |
1da177e4c Linux-2.6.12-rc2 |
231 |
|
3b495f2bb Au1100 FB driver ... |
232 233 |
/* Resume controller */ fbdev->regs->lcd_control |= LCD_CONTROL_GO; |
bb39e4197 [PATCH] au1100fb:... |
234 235 |
mdelay(10); au1100fb_fb_blank(VESA_NO_BLANKING, info); |
1da177e4c Linux-2.6.12-rc2 |
236 |
|
3b495f2bb Au1100 FB driver ... |
237 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
238 |
} |
3b495f2bb Au1100 FB driver ... |
239 240 241 242 |
/* fb_setcolreg * Set color in LCD palette. */ int au1100fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fbi) |
1da177e4c Linux-2.6.12-rc2 |
243 |
{ |
c05b7f3d1 [PATCH] au1100fb:... |
244 245 |
struct au1100fb_device *fbdev; u32 *palette; |
3b495f2bb Au1100 FB driver ... |
246 |
u32 value; |
1da177e4c Linux-2.6.12-rc2 |
247 |
|
c05b7f3d1 [PATCH] au1100fb:... |
248 249 |
fbdev = to_au1100fb_device(fbi); palette = fbdev->regs->lcd_pallettebase; |
3b495f2bb Au1100 FB driver ... |
250 251 |
if (regno > (AU1100_LCD_NBR_PALETTE_ENTRIES - 1)) return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
252 |
|
3b495f2bb Au1100 FB driver ... |
253 254 255 256 257 |
if (fbi->var.grayscale) { /* Convert color to grayscale */ red = green = blue = (19595 * red + 38470 * green + 7471 * blue) >> 16; } |
1da177e4c Linux-2.6.12-rc2 |
258 |
|
3b495f2bb Au1100 FB driver ... |
259 260 261 262 |
if (fbi->fix.visual == FB_VISUAL_TRUECOLOR) { /* Place color in the pseudopalette */ if (regno > 16) return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
263 |
|
3b495f2bb Au1100 FB driver ... |
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
palette = (u32*)fbi->pseudo_palette; red >>= (16 - fbi->var.red.length); green >>= (16 - fbi->var.green.length); blue >>= (16 - fbi->var.blue.length); value = (red << fbi->var.red.offset) | (green << fbi->var.green.offset)| (blue << fbi->var.blue.offset); value &= 0xFFFF; } else if (panel_is_active(fbdev->panel)) { /* COLOR TFT PALLETTIZED (use RGB 565) */ value = (red & 0xF800)|((green >> 5) & 0x07E0)|((blue >> 11) & 0x001F); value &= 0xFFFF; } else if (panel_is_color(fbdev->panel)) { /* COLOR STN MODE */ value = (((panel_swap_rgb(fbdev->panel) ? blue : red) >> 12) & 0x000F) | ((green >> 8) & 0x00F0) | (((panel_swap_rgb(fbdev->panel) ? red : blue) >> 4) & 0x0F00); value &= 0xFFF; } else { /* MONOCHROME MODE */ value = (green >> 12) & 0x000F; value &= 0xF; |
1da177e4c Linux-2.6.12-rc2 |
290 |
} |
3b495f2bb Au1100 FB driver ... |
291 |
palette[regno] = value; |
1da177e4c Linux-2.6.12-rc2 |
292 293 |
return 0; } |
3b495f2bb Au1100 FB driver ... |
294 295 296 297 |
/* fb_pan_display * Pan display in x and/or y as specified */ int au1100fb_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi) |
1da177e4c Linux-2.6.12-rc2 |
298 |
{ |
c05b7f3d1 [PATCH] au1100fb:... |
299 |
struct au1100fb_device *fbdev; |
3b495f2bb Au1100 FB driver ... |
300 |
int dy; |
c05b7f3d1 [PATCH] au1100fb:... |
301 |
fbdev = to_au1100fb_device(fbi); |
3b495f2bb Au1100 FB driver ... |
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
print_dbg("fb_pan_display %p %p", var, fbi); if (!var || !fbdev) { return -EINVAL; } if (var->xoffset - fbi->var.xoffset) { /* No support for X panning for now! */ return -EINVAL; } print_dbg("fb_pan_display 2 %p %p", var, fbi); dy = var->yoffset - fbi->var.yoffset; if (dy) { u32 dmaaddr; print_dbg("Panning screen of %d lines", dy); dmaaddr = fbdev->regs->lcd_dmaaddr0; dmaaddr += (fbi->fix.line_length * dy); /* TODO: Wait for current frame to finished */ fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(dmaaddr); if (panel_is_dual(fbdev->panel)) { dmaaddr = fbdev->regs->lcd_dmaaddr1; dmaaddr += (fbi->fix.line_length * dy); fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(dmaaddr); } } print_dbg("fb_pan_display 3 %p %p", var, fbi); return 0; } /* fb_rotate * Rotate the display of this angle. This doesn't seems to be used by the core, * but as our hardware supports it, so why not implementing it... */ void au1100fb_fb_rotate(struct fb_info *fbi, int angle) { struct au1100fb_device *fbdev = to_au1100fb_device(fbi); print_dbg("fb_rotate %p %d", fbi, angle); if (fbdev && (angle > 0) && !(angle % 90)) { fbdev->regs->lcd_control &= ~LCD_CONTROL_GO; fbdev->regs->lcd_control &= ~(LCD_CONTROL_SM_MASK); fbdev->regs->lcd_control |= ((angle/90) << LCD_CONTROL_SM_BIT); fbdev->regs->lcd_control |= LCD_CONTROL_GO; |
1da177e4c Linux-2.6.12-rc2 |
356 357 |
} } |
3b495f2bb Au1100 FB driver ... |
358 359 360 361 |
/* fb_mmap * Map video memory in user space. We don't use the generic fb_mmap method mainly * to allow the use of the TLB streaming flag (CCA=6) */ |
216d526c8 [PATCH] fbdev: Sa... |
362 |
int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) |
1da177e4c Linux-2.6.12-rc2 |
363 |
{ |
c05b7f3d1 [PATCH] au1100fb:... |
364 |
struct au1100fb_device *fbdev; |
1da177e4c Linux-2.6.12-rc2 |
365 366 |
unsigned int len; unsigned long start=0, off; |
1da177e4c Linux-2.6.12-rc2 |
367 |
|
c05b7f3d1 [PATCH] au1100fb:... |
368 |
fbdev = to_au1100fb_device(fbi); |
1da177e4c Linux-2.6.12-rc2 |
369 370 371 |
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) { return -EINVAL; } |
3b495f2bb Au1100 FB driver ... |
372 373 |
start = fbdev->fb_phys & PAGE_MASK; len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len); |
1da177e4c Linux-2.6.12-rc2 |
374 375 376 377 378 379 380 381 382 |
off = vma->vm_pgoff << PAGE_SHIFT; if ((vma->vm_end - vma->vm_start + off) > len) { return -EINVAL; } off += start; vma->vm_pgoff = off >> PAGE_SHIFT; |
3b495f2bb Au1100 FB driver ... |
383 |
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); |
1da177e4c Linux-2.6.12-rc2 |
384 |
pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6 |
1da177e4c Linux-2.6.12-rc2 |
385 |
vma->vm_flags |= VM_IO; |
cacfc8cf4 [PATCH] au1100fb:... |
386 |
if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, |
1da177e4c Linux-2.6.12-rc2 |
387 388 389 390 |
vma->vm_end - vma->vm_start, vma->vm_page_prot)) { return -EAGAIN; } |
1da177e4c Linux-2.6.12-rc2 |
391 392 |
return 0; } |
3b495f2bb Au1100 FB driver ... |
393 |
static struct fb_ops au1100fb_ops = |
1da177e4c Linux-2.6.12-rc2 |
394 |
{ |
3b495f2bb Au1100 FB driver ... |
395 396 397 398 399 400 401 402 403 404 |
.owner = THIS_MODULE, .fb_setcolreg = au1100fb_fb_setcolreg, .fb_blank = au1100fb_fb_blank, .fb_pan_display = au1100fb_fb_pan_display, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_rotate = au1100fb_fb_rotate, .fb_mmap = au1100fb_fb_mmap, }; |
1da177e4c Linux-2.6.12-rc2 |
405 |
|
1da177e4c Linux-2.6.12-rc2 |
406 |
|
3b495f2bb Au1100 FB driver ... |
407 |
/*-------------------------------------------------------------------------*/ |
1da177e4c Linux-2.6.12-rc2 |
408 |
|
d121c3f3c fb: fix au1100fb ... |
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
static int au1100fb_setup(struct au1100fb_device *fbdev) { char *this_opt, *options; int num_panels = ARRAY_SIZE(known_lcd_panels); if (num_panels <= 0) { print_err("No LCD panels supported by driver!"); return -ENODEV; } if (fb_get_options(DRIVER_NAME, &options)) return -ENODEV; if (!options) return -ENODEV; while ((this_opt = strsep(&options, ",")) != NULL) { /* Panel option */ if (!strncmp(this_opt, "panel:", 6)) { int i; this_opt += 6; for (i = 0; i < num_panels; i++) { if (!strncmp(this_opt, known_lcd_panels[i].name, strlen(this_opt))) { fbdev->panel = &known_lcd_panels[i]; fbdev->panel_idx = i; break; } } if (i >= num_panels) { print_warn("Panel '%s' not supported!", this_opt); return -ENODEV; } } /* Unsupported option */ else print_warn("Unsupported option \"%s\"", this_opt); } print_info("Panel=%s", fbdev->panel->name); return 0; } |
1da177e4c Linux-2.6.12-rc2 |
451 |
|
362992b19 VIDEO: Au1100fb: ... |
452 |
static int __devinit au1100fb_drv_probe(struct platform_device *dev) |
1da177e4c Linux-2.6.12-rc2 |
453 |
{ |
3b495f2bb Au1100 FB driver ... |
454 455 456 457 |
struct au1100fb_device *fbdev = NULL; struct resource *regs_res; unsigned long page; u32 sys_clksrc; |
3b495f2bb Au1100 FB driver ... |
458 |
/* Allocate new device private */ |
d121c3f3c fb: fix au1100fb ... |
459 460 |
fbdev = kzalloc(sizeof(struct au1100fb_device), GFP_KERNEL); if (!fbdev) { |
3b495f2bb Au1100 FB driver ... |
461 462 |
print_err("fail to allocate device private record"); return -ENOMEM; |
1da177e4c Linux-2.6.12-rc2 |
463 |
} |
d121c3f3c fb: fix au1100fb ... |
464 465 |
if (au1100fb_setup(fbdev)) goto failed; |
1da177e4c Linux-2.6.12-rc2 |
466 |
|
7a192ec33 platform driver: ... |
467 |
platform_set_drvdata(dev, (void *)fbdev); |
1da177e4c Linux-2.6.12-rc2 |
468 |
|
3b495f2bb Au1100 FB driver ... |
469 |
/* Allocate region for our registers and map them */ |
d121c3f3c fb: fix au1100fb ... |
470 471 |
regs_res = platform_get_resource(dev, IORESOURCE_MEM, 0); if (!regs_res) { |
3b495f2bb Au1100 FB driver ... |
472 473 474 |
print_err("fail to retrieve registers resource"); return -EFAULT; } |
1da177e4c Linux-2.6.12-rc2 |
475 |
|
3b495f2bb Au1100 FB driver ... |
476 |
au1100fb_fix.mmio_start = regs_res->start; |
28f65c11f treewide: Convert... |
477 |
au1100fb_fix.mmio_len = resource_size(regs_res); |
1da177e4c Linux-2.6.12-rc2 |
478 |
|
3b495f2bb Au1100 FB driver ... |
479 480 |
if (!request_mem_region(au1100fb_fix.mmio_start, au1100fb_fix.mmio_len, DRIVER_NAME)) { |
c05b7f3d1 [PATCH] au1100fb:... |
481 |
print_err("fail to lock memory region at 0x%08lx", |
3b495f2bb Au1100 FB driver ... |
482 483 484 |
au1100fb_fix.mmio_start); return -EBUSY; } |
1da177e4c Linux-2.6.12-rc2 |
485 |
|
3b495f2bb Au1100 FB driver ... |
486 |
fbdev->regs = (struct au1100fb_regs*)KSEG1ADDR(au1100fb_fix.mmio_start); |
1da177e4c Linux-2.6.12-rc2 |
487 |
|
3b495f2bb Au1100 FB driver ... |
488 489 |
print_dbg("Register memory map at %p", fbdev->regs); print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len); |
1da177e4c Linux-2.6.12-rc2 |
490 |
|
3b495f2bb Au1100 FB driver ... |
491 492 493 |
/* Allocate the framebuffer to the maximum screen size * nbr of video buffers */ fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres * (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS; |
d121c3f3c fb: fix au1100fb ... |
494 |
fbdev->fb_mem = dma_alloc_coherent(&dev->dev, PAGE_ALIGN(fbdev->fb_len), |
3b495f2bb Au1100 FB driver ... |
495 496 497 498 |
&fbdev->fb_phys, GFP_KERNEL); if (!fbdev->fb_mem) { print_err("fail to allocate frambuffer (size: %dK))", fbdev->fb_len / 1024); |
1da177e4c Linux-2.6.12-rc2 |
499 500 |
return -ENOMEM; } |
3b495f2bb Au1100 FB driver ... |
501 502 503 |
au1100fb_fix.smem_start = fbdev->fb_phys; au1100fb_fix.smem_len = fbdev->fb_len; |
1da177e4c Linux-2.6.12-rc2 |
504 505 506 507 508 |
/* * Set page reserved so that mmap will work. This is necessary * since we'll be remapping normal memory. */ |
3b495f2bb Au1100 FB driver ... |
509 510 |
for (page = (unsigned long)fbdev->fb_mem; page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len); |
1da177e4c Linux-2.6.12-rc2 |
511 |
page += PAGE_SIZE) { |
3b495f2bb Au1100 FB driver ... |
512 |
#if CONFIG_DMA_NONCOHERENT |
d121c3f3c fb: fix au1100fb ... |
513 |
SetPageReserved(virt_to_page(CAC_ADDR((void *)page))); |
3b495f2bb Au1100 FB driver ... |
514 |
#else |
1da177e4c Linux-2.6.12-rc2 |
515 |
SetPageReserved(virt_to_page(page)); |
3b495f2bb Au1100 FB driver ... |
516 |
#endif |
1da177e4c Linux-2.6.12-rc2 |
517 |
} |
3b495f2bb Au1100 FB driver ... |
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
print_dbg("Framebuffer memory map at %p", fbdev->fb_mem); print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024); /* Setup LCD clock to AUX (48 MHz) */ sys_clksrc = au_readl(SYS_CLKSRC) & ~(SYS_CS_ML_MASK | SYS_CS_DL | SYS_CS_CL); au_writel((sys_clksrc | (1 << SYS_CS_ML_BIT)), SYS_CLKSRC); /* load the panel info into the var struct */ au1100fb_var.bits_per_pixel = fbdev->panel->bpp; au1100fb_var.xres = fbdev->panel->xres; au1100fb_var.xres_virtual = au1100fb_var.xres; au1100fb_var.yres = fbdev->panel->yres; au1100fb_var.yres_virtual = au1100fb_var.yres; fbdev->info.screen_base = fbdev->fb_mem; fbdev->info.fbops = &au1100fb_ops; fbdev->info.fix = au1100fb_fix; |
f5610b9c3 [PATCH] Video: fb... |
535 |
if (!(fbdev->info.pseudo_palette = kzalloc(sizeof(u32) * 16, GFP_KERNEL))) { |
3b495f2bb Au1100 FB driver ... |
536 537 |
return -ENOMEM; } |
3b495f2bb Au1100 FB driver ... |
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
if (fb_alloc_cmap(&fbdev->info.cmap, AU1100_LCD_NBR_PALETTE_ENTRIES, 0) < 0) { print_err("Fail to allocate colormap (%d entries)", AU1100_LCD_NBR_PALETTE_ENTRIES); kfree(fbdev->info.pseudo_palette); return -EFAULT; } fbdev->info.var = au1100fb_var; /* Set h/w registers */ au1100fb_setmode(fbdev); /* Register new framebuffer */ if (register_framebuffer(&fbdev->info) < 0) { print_err("cannot register new framebuffer"); goto failed; } return 0; failed: if (fbdev->regs) { release_mem_region(fbdev->regs_phys, fbdev->regs_len); } if (fbdev->fb_mem) { |
d121c3f3c fb: fix au1100fb ... |
564 565 |
dma_free_noncoherent(&dev->dev, fbdev->fb_len, fbdev->fb_mem, fbdev->fb_phys); |
3b495f2bb Au1100 FB driver ... |
566 567 568 569 570 |
} if (fbdev->info.cmap.len != 0) { fb_dealloc_cmap(&fbdev->info.cmap); } kfree(fbdev); |
7a192ec33 platform driver: ... |
571 |
platform_set_drvdata(dev, NULL); |
1da177e4c Linux-2.6.12-rc2 |
572 573 574 |
return 0; } |
7a192ec33 platform driver: ... |
575 |
int au1100fb_drv_remove(struct platform_device *dev) |
3b495f2bb Au1100 FB driver ... |
576 577 578 579 580 |
{ struct au1100fb_device *fbdev = NULL; if (!dev) return -ENODEV; |
7a192ec33 platform driver: ... |
581 |
fbdev = (struct au1100fb_device *) platform_get_drvdata(dev); |
3b495f2bb Au1100 FB driver ... |
582 583 584 585 586 |
#if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO) au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); #endif fbdev->regs->lcd_control &= ~LCD_CONTROL_GO; |
1da177e4c Linux-2.6.12-rc2 |
587 |
|
3b495f2bb Au1100 FB driver ... |
588 589 590 591 |
/* Clean up all probe data */ unregister_framebuffer(&fbdev->info); release_mem_region(fbdev->regs_phys, fbdev->regs_len); |
d121c3f3c fb: fix au1100fb ... |
592 593 |
dma_free_coherent(&dev->dev, PAGE_ALIGN(fbdev->fb_len), fbdev->fb_mem, fbdev->fb_phys); |
3b495f2bb Au1100 FB driver ... |
594 595 596 597 598 599 600 |
fb_dealloc_cmap(&fbdev->info.cmap); kfree(fbdev->info.pseudo_palette); kfree((void*)fbdev); return 0; } |
f77f50ca1 [PATCH] au1100fb:... |
601 602 603 |
#ifdef CONFIG_PM static u32 sys_clksrc; static struct au1100fb_regs fbregs; |
7a192ec33 platform driver: ... |
604 |
int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state) |
3b495f2bb Au1100 FB driver ... |
605 |
{ |
7a192ec33 platform driver: ... |
606 |
struct au1100fb_device *fbdev = platform_get_drvdata(dev); |
f77f50ca1 [PATCH] au1100fb:... |
607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
if (!fbdev) return 0; /* Save the clock source state */ sys_clksrc = au_readl(SYS_CLKSRC); /* Blank the LCD */ au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); /* Stop LCD clocking */ au_writel(sys_clksrc & ~SYS_CS_ML_MASK, SYS_CLKSRC); memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs)); |
3b495f2bb Au1100 FB driver ... |
621 622 |
return 0; } |
7a192ec33 platform driver: ... |
623 |
int au1100fb_drv_resume(struct platform_device *dev) |
1da177e4c Linux-2.6.12-rc2 |
624 |
{ |
7a192ec33 platform driver: ... |
625 |
struct au1100fb_device *fbdev = platform_get_drvdata(dev); |
f77f50ca1 [PATCH] au1100fb:... |
626 627 628 629 630 631 632 633 634 635 636 |
if (!fbdev) return 0; memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs)); /* Restart LCD clocking */ au_writel(sys_clksrc, SYS_CLKSRC); /* Unblank the LCD */ au1100fb_fb_blank(VESA_NO_BLANKING, &fbdev->info); |
3b495f2bb Au1100 FB driver ... |
637 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
638 |
} |
f77f50ca1 [PATCH] au1100fb:... |
639 640 641 642 |
#else #define au1100fb_drv_suspend NULL #define au1100fb_drv_resume NULL #endif |
1da177e4c Linux-2.6.12-rc2 |
643 |
|
7a192ec33 platform driver: ... |
644 645 646 647 648 |
static struct platform_driver au1100fb_driver = { .driver = { .name = "au1100-lcd", .owner = THIS_MODULE, }, |
3b495f2bb Au1100 FB driver ... |
649 650 651 652 653 |
.probe = au1100fb_drv_probe, .remove = au1100fb_drv_remove, .suspend = au1100fb_drv_suspend, .resume = au1100fb_drv_resume, }; |
d121c3f3c fb: fix au1100fb ... |
654 |
static int __init au1100fb_load(void) |
1da177e4c Linux-2.6.12-rc2 |
655 |
{ |
7a192ec33 platform driver: ... |
656 |
return platform_driver_register(&au1100fb_driver); |
1da177e4c Linux-2.6.12-rc2 |
657 |
} |
d121c3f3c fb: fix au1100fb ... |
658 |
static void __exit au1100fb_unload(void) |
1da177e4c Linux-2.6.12-rc2 |
659 |
{ |
7a192ec33 platform driver: ... |
660 |
platform_driver_unregister(&au1100fb_driver); |
1da177e4c Linux-2.6.12-rc2 |
661 |
} |
d121c3f3c fb: fix au1100fb ... |
662 663 |
module_init(au1100fb_load); module_exit(au1100fb_unload); |
3b495f2bb Au1100 FB driver ... |
664 665 666 |
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); |