44 #include <linux/module.h>
45 #include <linux/kernel.h>
46 #include <linux/errno.h>
47 #include <linux/string.h>
52 #include <linux/ctype.h>
55 #include <linux/slab.h>
63 #define DRIVER_NAME "au1100fb"
64 #define DRIVER_DESC "LCD controller driver for AU1100 processors"
66 #define to_au1100fb_device(_info) \
67 (_info ? container_of(_info, struct au1100fb_device, info) : NULL);
76 { { 10, 6, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 0, 0, 0 } },
77 { { 11, 5, 0 }, { 5, 6, 0 }, { 0, 5, 0 }, { 0, 0, 0 } },
78 { { 11, 5, 0 }, { 6, 5, 0 }, { 0, 6, 0 }, { 0, 0, 0 } },
79 { { 10, 5, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 15, 1, 0 } },
80 { { 11, 5, 0 }, { 6, 5, 0 }, { 1, 5, 0 }, { 0, 1, 0 } },
83 { { 8, 4, 0 }, { 4, 4, 0 }, { 0, 4, 0 }, { 0, 0, 0 } },
105 static int au1100fb_fb_blank(
int blank_mode,
struct fb_info *fbi)
109 print_dbg(
"fb_blank %d %p", blank_mode, fbi);
111 switch (blank_mode) {
116 #ifdef CONFIG_MIPS_PB1100
118 au_writew(au_readw(PB1100_G_CONTROL)
119 | (PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
131 #ifdef CONFIG_MIPS_PB1100
133 au_writew(au_readw(PB1100_G_CONTROL)
134 & ~(PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
162 if (info->
var.bits_per_pixel <= 8) {
164 info->
var.red.offset = 0;
165 info->
var.red.length = info->
var.bits_per_pixel;
166 info->
var.red.msb_right = 0;
168 info->
var.green.offset = 0;
169 info->
var.green.length = info->
var.bits_per_pixel;
170 info->
var.green.msb_right = 0;
172 info->
var.blue.offset = 0;
173 info->
var.blue.length = info->
var.bits_per_pixel;
174 info->
var.blue.msb_right = 0;
176 info->
var.transp.offset = 0;
177 info->
var.transp.length = 0;
178 info->
var.transp.msb_right = 0;
181 info->
fix.line_length = info->
var.xres_virtual /
182 (8/info->
var.bits_per_pixel);
186 info->
var.red = rgb_bitfields[
index][0];
187 info->
var.green = rgb_bitfields[
index][1];
188 info->
var.blue = rgb_bitfields[
index][2];
189 info->
var.transp = rgb_bitfields[
index][3];
192 info->
fix.line_length = info->
var.xres_virtual << 1;
197 info->
fix.line_length = info->
var.xres_virtual / 8;
205 fbdev->
regs->lcd_control = fbdev->
panel->control_base;
206 fbdev->
regs->lcd_horztiming = fbdev->
panel->horztiming;
207 fbdev->
regs->lcd_verttiming = fbdev->
panel->verttiming;
208 fbdev->
regs->lcd_clkcontrol = fbdev->
panel->clkcontrol_base;
209 fbdev->
regs->lcd_intenable = 0;
210 fbdev->
regs->lcd_intstatus = 0;
216 if (info->
var.yres_virtual >= (info->
var.yres << 1)) {
218 (info->
fix.line_length *
219 (info->
var.yres_virtual >> 1)));
225 words = info->
fix.line_length /
sizeof(
u32);
226 if (!info->
var.rotate || (info->
var.rotate == 180)) {
227 words *= info->
var.yres_virtual;
228 if (info->
var.rotate ) {
229 words -= (words % 8);
234 fbdev->
regs->lcd_pwmdiv = 0;
235 fbdev->
regs->lcd_pwmhi = 0;
255 palette = fbdev->
regs->lcd_pallettebase;
260 if (fbi->
var.grayscale) {
263 (19595 * red + 38470 * green + 7471 *
blue) >> 16;
273 red >>= (16 - fbi->
var.red.length);
274 green >>= (16 - fbi->
var.green.length);
275 blue >>= (16 - fbi->
var.blue.length);
277 value = (red << fbi->
var.red.offset) |
278 (green << fbi->
var.green.offset)|
279 (blue << fbi->
var.blue.offset);
284 value = (red & 0xF800)|((green >> 5) & 0x07E0)|((blue >> 11) & 0x001F);
290 ((green >> 8) & 0x00F0) |
295 value = (green >> 12) & 0x000F;
299 palette[regno] =
value;
314 print_dbg(
"fb_pan_display %p %p", var, fbi);
316 if (!var || !fbdev) {
325 print_dbg(
"fb_pan_display 2 %p %p", var, fbi);
331 print_dbg(
"Panning screen of %d lines", dy);
333 dmaaddr = fbdev->
regs->lcd_dmaaddr0;
334 dmaaddr += (fbi->
fix.line_length * dy);
340 dmaaddr = fbdev->
regs->lcd_dmaaddr1;
341 dmaaddr += (fbi->
fix.line_length * dy);
345 print_dbg(
"fb_pan_display 3 %p %p", var, fbi);
358 print_dbg(
"fb_rotate %p %d", fbi, angle);
360 if (fbdev && (angle > 0) && !(angle % 90)) {
379 unsigned long start=0, off;
413 static struct fb_ops au1100fb_ops =
417 .fb_blank = au1100fb_fb_blank,
432 int num_panels =
ARRAY_SIZE(known_lcd_panels);
434 if (num_panels <= 0) {
435 print_err(
"No LCD panels supported by driver!");
444 while ((this_opt =
strsep(&options,
",")) !=
NULL) {
446 if (!
strncmp(this_opt,
"panel:", 6)) {
449 for (i = 0; i < num_panels; i++) {
452 fbdev->
panel = &known_lcd_panels[
i];
457 if (i >= num_panels) {
458 print_warn(
"Panel '%s' not supported!", this_opt);
464 print_warn(
"Unsupported option \"%s\"", this_opt);
483 print_err(
"fail to allocate device private record");
487 if (au1100fb_setup(fbdev))
490 platform_set_drvdata(dev, (
void *)fbdev);
495 print_err(
"fail to retrieve registers resource");
499 au1100fb_fix.mmio_start = regs_res->
start;
500 au1100fb_fix.mmio_len = resource_size(regs_res);
503 au1100fb_fix.mmio_start,
504 au1100fb_fix.mmio_len,
506 print_err(
"fail to lock memory region at 0x%08lx",
507 au1100fb_fix.mmio_start);
524 print_err(
"fail to allocate frambuffer (size: %dK))",
529 au1100fb_fix.smem_start = fbdev->
fb_phys;
530 au1100fb_fix.smem_len = fbdev->
fb_len;
536 for (page = (
unsigned long)fbdev->
fb_mem;
539 #ifdef CONFIG_DMA_NONCOHERENT
554 au1100fb_var.bits_per_pixel = fbdev->
panel->bpp;
555 au1100fb_var.xres = fbdev->
panel->xres;
556 au1100fb_var.xres_virtual = au1100fb_var.xres;
557 au1100fb_var.yres = fbdev->
panel->yres;
558 au1100fb_var.yres_virtual = au1100fb_var.yres;
561 fbdev->
info.fbops = &au1100fb_ops;
562 fbdev->
info.fix = au1100fb_fix;
564 fbdev->
info.pseudo_palette =
566 if (!fbdev->
info.pseudo_palette)
570 print_err(
"Fail to allocate colormap (%d entries)",
575 fbdev->
info.var = au1100fb_var;
582 print_err(
"cannot register new framebuffer");
593 if (fbdev->
info.cmap.len != 0) {
596 platform_set_drvdata(dev,
NULL);
610 #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO)
624 static u32 sys_clksrc;
666 #define au1100fb_drv_suspend NULL
667 #define au1100fb_drv_resume NULL
672 .name =
"au1100-lcd",
675 .probe = au1100fb_drv_probe,
681 static int __init au1100fb_load(
void)
686 static void __exit au1100fb_unload(
void)