31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/errno.h>
34 #include <linux/string.h>
36 #include <linux/tty.h>
37 #include <linux/slab.h>
42 #include <linux/types.h>
44 #include <linux/sched.h>
46 #include <linux/device.h>
56 #include <asm/dma-mapping.h>
65 #define DRIVER_NAME "bf54x-lq043"
68 #define BFIN_LCD_NBR_PALETTE_ENTRIES 256
70 #define EPPI0_18 {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2, P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3, \
71 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7, P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, \
72 P_PPI0_D11, P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15, P_PPI0_D16, P_PPI0_D17, 0}
74 #define EPPI0_24 {P_PPI0_D18, P_PPI0_D19, P_PPI0_D20, P_PPI0_D21, P_PPI0_D22, P_PPI0_D23, 0}
94 static int outp_rgb666;
102 #define DMA_BUS_SIZE 32
125 #define LCD_CLK (8*1000*1000)
128 #define EPPI_HCOUNT LCD_X_RES
131 #define EPPI_VCOUNT LCD_Y_RES
134 #define EPPI_LINE 525
137 #define EPPI_FRAME 286
140 #define EPPI_FS1W_HBL 41
143 #define EPPI_FS1P_AVPL EPPI_LINE
146 #define EPPI_HDELAY 43
149 #define EPPI_FS2W_LVB (EPPI_LINE * 10)
152 #define EPPI_FS2P_LAVF (EPPI_LINE * EPPI_FRAME)
155 #define EPPI_VDELAY 12
157 #define EPPI_CLIP 0xFF00FF00
174 #define EPPI_CONTROL (0x20136E2E | SWAPEN)
176 static inline u16 get_eppi_clkdiv(
u32 target_ppi_clk)
182 return (((sclk / target_ppi_clk) / 2) - 1);
288 spin_lock(&fbi->
lock);
304 spin_unlock(&fbi->
lock);
309 static int bfin_bf54x_fb_release(
struct fb_info *info,
int user)
313 spin_lock(&fbi->
lock);
324 spin_unlock(&fbi->
lock);
335 var->
red.offset = 16;
336 var->
green.offset = 8;
337 var->
blue.offset = 0;
338 var->
red.length = var->
green.length = var->
blue.length = 8;
341 var->
transp.msb_right = 0;
342 var->
red.msb_right = 0;
343 var->
green.msb_right = 0;
344 var->
blue.msb_right = 0;
347 pr_debug(
"%s: depth not supported: %u BPP\n", __func__,
355 pr_debug(
"%s: Resolution not supported: X%u x Y%u \n",
365 pr_debug(
"%s: Memory Limit requested yres_virtual = %u\n",
388 if (info->
var.grayscale) {
390 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
400 red >>= (16 - info->
var.red.length);
401 green >>= (16 - info->
var.green.length);
402 blue >>= (16 - info->
var.blue.length);
404 value = (red << info->
var.red.offset) |
405 (green << info->
var.green.offset) |
406 (blue << info->
var.blue.offset);
416 static struct fb_ops bfin_bf54x_fb_ops = {
418 .fb_open = bfin_bf54x_fb_open,
419 .fb_release = bfin_bf54x_fb_release,
420 .fb_check_var = bfin_bf54x_fb_check_var,
425 .fb_setcolreg = bfin_bf54x_fb_setcolreg,
428 #ifndef NO_BL_SUPPORT
445 static int bfin_lcd_set_power(
struct lcd_device *
dev,
int power)
463 if (!fi || (fi == &bfin_bf54x_fb))
468 static struct lcd_ops bfin_lcd_ops = {
470 .set_power = bfin_lcd_set_power,
471 .get_contrast = bfin_lcd_get_contrast,
472 .set_contrast = bfin_lcd_set_contrast,
473 .check_fb = bfin_lcd_check_fb,
502 #ifndef NO_BL_SUPPORT
513 ": couldn't request CH_EPPI0 DMA\n");
530 platform_set_drvdata(pdev, fbinfo);
538 "no platform data for lcd, cannot attach\n");
544 fbinfo->
fix.type_aux = 0;
545 fbinfo->
fix.xpanstep = 0;
546 fbinfo->
fix.ypanstep = 0;
547 fbinfo->
fix.ywrapstep = 0;
551 fbinfo->
var.nonstd = 0;
555 fbinfo->
var.accel_flags = 0;
558 fbinfo->
fbops = &bfin_bf54x_fb_ops;
562 fbinfo->
var.xres_virtual = info->
mach_info->xres.defval;
564 fbinfo->
var.yres_virtual = info->
mach_info->yres.defval;
565 fbinfo->
var.bits_per_pixel = info->
mach_info->bpp.defval;
567 fbinfo->
var.upper_margin = 0;
568 fbinfo->
var.lower_margin = 0;
569 fbinfo->
var.vsync_len = 0;
571 fbinfo->
var.left_margin = 0;
572 fbinfo->
var.right_margin = 0;
573 fbinfo->
var.hsync_len = 0;
575 fbinfo->
var.red.offset = 16;
576 fbinfo->
var.green.offset = 8;
577 fbinfo->
var.blue.offset = 0;
578 fbinfo->
var.transp.offset = 0;
579 fbinfo->
var.red.length = 8;
580 fbinfo->
var.green.length = 8;
581 fbinfo->
var.blue.length = 8;
582 fbinfo->
var.transp.length = 0;
586 fbinfo->
fix.line_length = fbinfo->
var.xres_virtual *
587 fbinfo->
var.bits_per_pixel / 8;
595 ": couldn't allocate dma buffer.\n");
603 fbinfo->
fbops = &bfin_bf54x_fb_ops;
609 "Fail to allocate pseudo_palette\n");
618 "Fail to allocate colormap (%d entries)\n",
624 if (request_ports(info)) {
637 "PPI ERROR", info) < 0) {
639 ": unable to request PPI ERROR IRQ\n");
646 ": unable to register framebuffer.\n");
650 #ifndef NO_BL_SUPPORT
653 props.max_brightness = 255;
655 &bfin_lq043fb_bl_ops, &props);
656 if (IS_ERR(bl_dev)) {
658 ": unable to register backlight.\n");
684 platform_set_drvdata(pdev,
NULL);
692 struct fb_info *fbinfo = platform_get_drvdata(pdev);
704 #ifndef NO_BL_SUPPORT
721 struct fb_info *fbinfo = platform_get_drvdata(pdev);
732 struct fb_info *fbinfo = platform_get_drvdata(pdev);
751 #define bfin_bf54x_suspend NULL
752 #define bfin_bf54x_resume NULL
756 .probe = bfin_bf54x_probe,
766 static int __init bfin_bf54x_driver_init(
void)
771 static void __exit bfin_bf54x_driver_cleanup(
void)