5 * Stefano Babic, DENX Software Engineering, sbabic@denx.de.
7 * Copyright (C) 2008-2009 MontaVista Software Inc.
8 * Copyright (C) 2008-2009 Texas Instruments Inc
10 * Based on the LCD driver for TI Avalanche processors written by
11 * Ajay Singh and Shalom Hai.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option)any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include <linux/list.h>
34 #include <asm/errno.h>
36 #include <asm/arch/hardware.h>
38 #include "videomodes.h"
39 #include <asm/arch/da8xx-fb.h>
41 #define DRIVER_NAME "da8xx_lcdc"
43 /* LCD Status Register */
44 #define LCD_END_OF_FRAME1 (1 << 9)
45 #define LCD_END_OF_FRAME0 (1 << 8)
46 #define LCD_PL_LOAD_DONE (1 << 6)
47 #define LCD_FIFO_UNDERFLOW (1 << 5)
48 #define LCD_SYNC_LOST (1 << 2)
50 /* LCD DMA Control Register */
51 #define LCD_DMA_BURST_SIZE(x) ((x) << 4)
52 #define LCD_DMA_BURST_1 0x0
53 #define LCD_DMA_BURST_2 0x1
54 #define LCD_DMA_BURST_4 0x2
55 #define LCD_DMA_BURST_8 0x3
56 #define LCD_DMA_BURST_16 0x4
57 #define LCD_END_OF_FRAME_INT_ENA (1 << 2)
58 #define LCD_DUAL_FRAME_BUFFER_ENABLE (1 << 0)
60 /* LCD Control Register */
61 #define LCD_CLK_DIVISOR(x) ((x) << 8)
62 #define LCD_RASTER_MODE 0x01
64 /* LCD Raster Control Register */
65 #define LCD_PALETTE_LOAD_MODE(x) ((x) << 20)
66 #define PALETTE_AND_DATA 0x00
67 #define PALETTE_ONLY 0x01
68 #define DATA_ONLY 0x02
70 #define LCD_MONO_8BIT_MODE (1 << 9)
71 #define LCD_RASTER_ORDER (1 << 8)
72 #define LCD_TFT_MODE (1 << 7)
73 #define LCD_UNDERFLOW_INT_ENA (1 << 6)
74 #define LCD_PL_ENABLE (1 << 4)
75 #define LCD_MONOCHROME_MODE (1 << 1)
76 #define LCD_RASTER_ENABLE (1 << 0)
77 #define LCD_TFT_ALT_ENABLE (1 << 23)
78 #define LCD_STN_565_ENABLE (1 << 24)
80 /* LCD Raster Timing 2 Register */
81 #define LCD_AC_BIAS_TRANSITIONS_PER_INT(x) ((x) << 16)
82 #define LCD_AC_BIAS_FREQUENCY(x) ((x) << 8)
83 #define LCD_SYNC_CTRL (1 << 25)
84 #define LCD_SYNC_EDGE (1 << 24)
85 #define LCD_INVERT_PIXEL_CLOCK (1 << 22)
86 #define LCD_INVERT_LINE_CLOCK (1 << 21)
87 #define LCD_INVERT_FRAME_CLOCK (1 << 20)
90 struct da8xx_lcd_regs {
108 u32 dma_frm_buf_base_addr_0;
109 u32 dma_frm_buf_ceiling_addr_0;
110 u32 dma_frm_buf_base_addr_1;
111 u32 dma_frm_buf_ceiling_addr_1;
114 #define LCD_NUM_BUFFERS 1
116 #define WSI_TIMEOUT 50
117 #define PALETTE_SIZE 256
118 #define LEFT_MARGIN 64
119 #define RIGHT_MARGIN 64
120 #define UPPER_MARGIN 32
121 #define LOWER_MARGIN 32
123 #define calc_fbsize() (panel.plnSizeX * panel.plnSizeY * panel.gdfBytesPP)
125 static struct da8xx_lcd_regs *da8xx_fb_reg_base;
127 DECLARE_GLOBAL_DATA_PTR;
130 static GraphicDevice gpanel;
131 static const struct da8xx_panel *lcd_panel;
132 static struct fb_info *da8xx_fb_info;
133 static int bits_x_pixel;
135 static inline unsigned int lcdc_read(u32 *addr)
137 return (unsigned int)readl(addr);
140 static inline void lcdc_write(unsigned int val, u32 *addr)
145 struct da8xx_fb_par {
147 unsigned char *v_palette_base;
148 dma_addr_t vram_phys;
149 unsigned long vram_size;
151 unsigned int dma_start;
152 unsigned int dma_end;
153 struct clk *lcdc_clk;
155 unsigned short pseudo_palette[16];
156 unsigned int palette_sz;
157 unsigned int pxl_clk;
164 /* Variable Screen Information */
165 static struct fb_var_screeninfo da8xx_fb_var = {
173 .pixclock = 46666, /* 46us - AUO display */
175 .left_margin = LEFT_MARGIN,
176 .right_margin = RIGHT_MARGIN,
177 .upper_margin = UPPER_MARGIN,
178 .lower_margin = LOWER_MARGIN,
180 .vmode = FB_VMODE_NONINTERLACED
183 static struct fb_fix_screeninfo da8xx_fb_fix = {
184 .id = "DA8xx FB Drv",
185 .type = FB_TYPE_PACKED_PIXELS,
187 .visual = FB_VISUAL_PSEUDOCOLOR,
191 .accel = FB_ACCEL_NONE
194 static const struct display_panel disp_panel = {
201 static const struct lcd_ctrl_config lcd_cfg = {
211 .invert_line_clock = 1,
212 .invert_frm_clock = 1,
218 /* Enable the Raster Engine of the LCD Controller */
219 static inline void lcd_enable_raster(void)
223 reg = lcdc_read(&da8xx_fb_reg_base->raster_ctrl);
224 if (!(reg & LCD_RASTER_ENABLE))
225 lcdc_write(reg | LCD_RASTER_ENABLE,
226 &da8xx_fb_reg_base->raster_ctrl);
229 /* Disable the Raster Engine of the LCD Controller */
230 static inline void lcd_disable_raster(void)
234 reg = lcdc_read(&da8xx_fb_reg_base->raster_ctrl);
235 if (reg & LCD_RASTER_ENABLE)
236 lcdc_write(reg & ~LCD_RASTER_ENABLE,
237 &da8xx_fb_reg_base->raster_ctrl);
240 static void lcd_blit(int load_mode, struct da8xx_fb_par *par)
247 /* init reg to clear PLM (loading mode) fields */
248 reg_ras = lcdc_read(&da8xx_fb_reg_base->raster_ctrl);
249 reg_ras &= ~(3 << 20);
251 reg_dma = lcdc_read(&da8xx_fb_reg_base->dma_ctrl);
253 if (load_mode == LOAD_DATA) {
254 start = par->dma_start;
257 reg_ras |= LCD_PALETTE_LOAD_MODE(DATA_ONLY);
258 reg_dma |= LCD_END_OF_FRAME_INT_ENA;
260 #if (LCD_NUM_BUFFERS == 2)
261 reg_dma |= LCD_DUAL_FRAME_BUFFER_ENABLE;
262 lcdc_write(start, &da8xx_fb_reg_base->dma_frm_buf_base_addr_0);
263 lcdc_write(end, &da8xx_fb_reg_base->dma_frm_buf_ceiling_addr_0);
264 lcdc_write(start, &da8xx_fb_reg_base->dma_frm_buf_base_addr_1);
265 lcdc_write(end, &da8xx_fb_reg_base->dma_frm_buf_ceiling_addr_1);
267 reg_dma &= ~LCD_DUAL_FRAME_BUFFER_ENABLE;
268 lcdc_write(start, &da8xx_fb_reg_base->dma_frm_buf_base_addr_0);
269 lcdc_write(end, &da8xx_fb_reg_base->dma_frm_buf_ceiling_addr_0);
270 lcdc_write(0, &da8xx_fb_reg_base->dma_frm_buf_base_addr_1);
271 lcdc_write(0, &da8xx_fb_reg_base->dma_frm_buf_ceiling_addr_1);
274 } else if (load_mode == LOAD_PALETTE) {
275 start = par->p_palette_base;
276 end = start + par->palette_sz - 1;
278 reg_ras |= LCD_PALETTE_LOAD_MODE(PALETTE_ONLY);
279 reg_ras |= LCD_PL_ENABLE;
281 lcdc_write(start, &da8xx_fb_reg_base->dma_frm_buf_base_addr_0);
282 lcdc_write(end, &da8xx_fb_reg_base->dma_frm_buf_ceiling_addr_0);
285 lcdc_write(reg_dma, &da8xx_fb_reg_base->dma_ctrl);
286 lcdc_write(reg_ras, &da8xx_fb_reg_base->raster_ctrl);
289 * The Raster enable bit must be set after all other control fields are
295 /* Configure the Burst Size of DMA */
296 static int lcd_cfg_dma(int burst_size)
300 reg = lcdc_read(&da8xx_fb_reg_base->dma_ctrl) & 0x00000001;
301 switch (burst_size) {
303 reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_1);
306 reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_2);
309 reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_4);
312 reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_8);
315 reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_16);
320 lcdc_write(reg, &da8xx_fb_reg_base->dma_ctrl);
325 static void lcd_cfg_ac_bias(int period, int transitions_per_int)
329 /* Set the AC Bias Period and Number of Transisitons per Interrupt */
330 reg = lcdc_read(&da8xx_fb_reg_base->raster_timing_2) & 0xFFF00000;
331 reg |= LCD_AC_BIAS_FREQUENCY(period) |
332 LCD_AC_BIAS_TRANSITIONS_PER_INT(transitions_per_int);
333 lcdc_write(reg, &da8xx_fb_reg_base->raster_timing_2);
336 static void lcd_cfg_horizontal_sync(int back_porch, int pulse_width,
341 reg = lcdc_read(&da8xx_fb_reg_base->raster_timing_0) & 0xf;
342 reg |= ((back_porch & 0xff) << 24)
343 | ((front_porch & 0xff) << 16)
344 | ((pulse_width & 0x3f) << 10);
345 lcdc_write(reg, &da8xx_fb_reg_base->raster_timing_0);
348 static void lcd_cfg_vertical_sync(int back_porch, int pulse_width,
353 reg = lcdc_read(&da8xx_fb_reg_base->raster_timing_1) & 0x3ff;
354 reg |= ((back_porch & 0xff) << 24)
355 | ((front_porch & 0xff) << 16)
356 | ((pulse_width & 0x3f) << 10);
357 lcdc_write(reg, &da8xx_fb_reg_base->raster_timing_1);
360 static int lcd_cfg_display(const struct lcd_ctrl_config *cfg)
364 reg = lcdc_read(&da8xx_fb_reg_base->raster_ctrl) & ~(LCD_TFT_MODE |
366 LCD_MONOCHROME_MODE);
368 switch (cfg->p_disp_panel->panel_shade) {
370 reg |= LCD_MONOCHROME_MODE;
371 if (cfg->mono_8bit_mode)
372 reg |= LCD_MONO_8BIT_MODE;
376 if (cfg->tft_alt_mode)
377 reg |= LCD_TFT_ALT_ENABLE;
381 if (cfg->stn_565_mode)
382 reg |= LCD_STN_565_ENABLE;
389 /* enable additional interrupts here */
390 reg |= LCD_UNDERFLOW_INT_ENA;
392 lcdc_write(reg, &da8xx_fb_reg_base->raster_ctrl);
394 reg = lcdc_read(&da8xx_fb_reg_base->raster_timing_2);
397 reg |= LCD_SYNC_CTRL;
399 reg &= ~LCD_SYNC_CTRL;
402 reg |= LCD_SYNC_EDGE;
404 reg &= ~LCD_SYNC_EDGE;
406 if (cfg->invert_line_clock)
407 reg |= LCD_INVERT_LINE_CLOCK;
409 reg &= ~LCD_INVERT_LINE_CLOCK;
411 if (cfg->invert_frm_clock)
412 reg |= LCD_INVERT_FRAME_CLOCK;
414 reg &= ~LCD_INVERT_FRAME_CLOCK;
416 lcdc_write(reg, &da8xx_fb_reg_base->raster_timing_2);
421 static int lcd_cfg_frame_buffer(struct da8xx_fb_par *par, u32 width, u32 height,
422 u32 bpp, u32 raster_order)
426 /* Set the Panel Width */
427 /* Pixels per line = (PPL + 1)*16 */
428 /*0x3F in bits 4..9 gives max horisontal resolution = 1024 pixels*/
430 reg = lcdc_read(&da8xx_fb_reg_base->raster_timing_0);
432 reg |= ((width >> 4) - 1) << 4;
433 lcdc_write(reg, &da8xx_fb_reg_base->raster_timing_0);
435 /* Set the Panel Height */
436 reg = lcdc_read(&da8xx_fb_reg_base->raster_timing_1);
437 reg = ((height - 1) & 0x3ff) | (reg & 0xfffffc00);
438 lcdc_write(reg, &da8xx_fb_reg_base->raster_timing_1);
440 /* Set the Raster Order of the Frame Buffer */
441 reg = lcdc_read(&da8xx_fb_reg_base->raster_ctrl) & ~(1 << 8);
443 reg |= LCD_RASTER_ORDER;
444 lcdc_write(reg, &da8xx_fb_reg_base->raster_ctrl);
451 par->palette_sz = 16 * 2;
455 par->palette_sz = 256 * 2;
465 static int fb_setcolreg(unsigned regno, unsigned red, unsigned green,
466 unsigned blue, unsigned transp,
467 struct fb_info *info)
469 struct da8xx_fb_par *par = info->par;
470 unsigned short *palette = (unsigned short *) par->v_palette_base;
477 if (info->fix.visual == FB_VISUAL_DIRECTCOLOR)
480 if (info->var.bits_per_pixel == 8) {
485 pal = (red & 0x0f00);
486 pal |= (green & 0x00f0);
487 pal |= (blue & 0x000f);
489 if (palette[regno] != pal) {
491 palette[regno] = pal;
493 } else if ((info->var.bits_per_pixel == 16) && regno < 16) {
494 red >>= (16 - info->var.red.length);
495 red <<= info->var.red.offset;
497 green >>= (16 - info->var.green.length);
498 green <<= info->var.green.offset;
500 blue >>= (16 - info->var.blue.length);
501 blue <<= info->var.blue.offset;
503 par->pseudo_palette[regno] = red | green | blue;
505 if (palette[0] != 0x4000) {
511 /* Update the palette in the h/w as needed. */
513 lcd_blit(LOAD_PALETTE, par);
518 static void lcd_reset(struct da8xx_fb_par *par)
520 /* Disable the Raster if previously Enabled */
521 lcd_disable_raster();
523 /* DMA has to be disabled */
524 lcdc_write(0, &da8xx_fb_reg_base->dma_ctrl);
525 lcdc_write(0, &da8xx_fb_reg_base->raster_ctrl);
528 static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
530 unsigned int lcd_clk, div;
532 /* Get clock from sysclk2 */
533 lcd_clk = clk_get(2);
535 div = lcd_clk / par->pxl_clk;
536 debug("LCD Clock: 0x%x Divider: 0x%x PixClk: 0x%x\n",
537 lcd_clk, div, par->pxl_clk);
539 /* Configure the LCD clock divisor. */
540 lcdc_write(LCD_CLK_DIVISOR(div) |
541 (LCD_RASTER_MODE & 0x1), &da8xx_fb_reg_base->ctrl);
544 static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
545 const struct da8xx_panel *panel)
552 /* Calculate the divider */
553 lcd_calc_clk_divider(par);
555 if (panel->invert_pxl_clk)
556 lcdc_write((lcdc_read(&da8xx_fb_reg_base->raster_timing_2) |
557 LCD_INVERT_PIXEL_CLOCK),
558 &da8xx_fb_reg_base->raster_timing_2);
560 lcdc_write((lcdc_read(&da8xx_fb_reg_base->raster_timing_2) &
561 ~LCD_INVERT_PIXEL_CLOCK),
562 &da8xx_fb_reg_base->raster_timing_2);
564 /* Configure the DMA burst size. */
565 ret = lcd_cfg_dma(cfg->dma_burst_sz);
569 /* Configure the AC bias properties. */
570 lcd_cfg_ac_bias(cfg->ac_bias, cfg->ac_bias_intrpt);
572 /* Configure the vertical and horizontal sync properties. */
573 lcd_cfg_vertical_sync(panel->vbp, panel->vsw, panel->vfp);
574 lcd_cfg_horizontal_sync(panel->hbp, panel->hsw, panel->hfp);
576 /* Configure for disply */
577 ret = lcd_cfg_display(cfg);
581 if (QVGA != cfg->p_disp_panel->panel_type)
584 if (cfg->bpp <= cfg->p_disp_panel->max_bpp &&
585 cfg->bpp >= cfg->p_disp_panel->min_bpp)
588 bpp = cfg->p_disp_panel->max_bpp;
591 ret = lcd_cfg_frame_buffer(par, (unsigned int)panel->width,
592 (unsigned int)panel->height, bpp,
598 lcdc_write((lcdc_read(&da8xx_fb_reg_base->raster_ctrl) & 0xfff00fff) |
599 (cfg->fdd << 12), &da8xx_fb_reg_base->raster_ctrl);
604 static void lcdc_dma_start(void)
606 struct da8xx_fb_par *par = da8xx_fb_info->par;
607 lcdc_write(par->dma_start,
608 &da8xx_fb_reg_base->dma_frm_buf_base_addr_0);
609 lcdc_write(par->dma_end,
610 &da8xx_fb_reg_base->dma_frm_buf_ceiling_addr_0);
612 &da8xx_fb_reg_base->dma_frm_buf_base_addr_1);
614 &da8xx_fb_reg_base->dma_frm_buf_ceiling_addr_1);
617 static u32 lcdc_irq_handler(void)
619 struct da8xx_fb_par *par = da8xx_fb_info->par;
620 u32 stat = lcdc_read(&da8xx_fb_reg_base->stat);
623 if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
624 debug("LCD_SYNC_LOST\n");
625 lcd_disable_raster();
626 lcdc_write(stat, &da8xx_fb_reg_base->stat);
628 return LCD_SYNC_LOST;
629 } else if (stat & LCD_PL_LOAD_DONE) {
630 debug("LCD_PL_LOAD_DONE\n");
632 * Must disable raster before changing state of any control bit.
633 * And also must be disabled before clearing the PL loading
634 * interrupt via the following write to the status register. If
635 * this is done after then one gets multiple PL done interrupts.
637 lcd_disable_raster();
639 lcdc_write(stat, &da8xx_fb_reg_base->stat);
641 /* Disable PL completion inerrupt */
642 reg_ras = lcdc_read(&da8xx_fb_reg_base->raster_ctrl);
643 reg_ras &= ~LCD_PL_ENABLE;
644 lcdc_write(reg_ras, &da8xx_fb_reg_base->raster_ctrl);
646 /* Setup and start data loading mode */
647 lcd_blit(LOAD_DATA, par);
648 return LCD_PL_LOAD_DONE;
650 lcdc_write(stat, &da8xx_fb_reg_base->stat);
652 if (stat & LCD_END_OF_FRAME0)
653 debug("LCD_END_OF_FRAME0\n");
655 lcdc_write(par->dma_start,
656 &da8xx_fb_reg_base->dma_frm_buf_base_addr_0);
657 lcdc_write(par->dma_end,
658 &da8xx_fb_reg_base->dma_frm_buf_ceiling_addr_0);
660 return LCD_END_OF_FRAME0;
665 static u32 wait_for_event(u32 event)
671 ret = lcdc_irq_handler();
673 } while (!(ret & event));
676 printf("%s: event %d not hit\n", __func__, event);
684 void *video_hw_init(void)
686 struct da8xx_fb_par *par;
691 printf("Display not initialized\n");
694 gpanel.winSizeX = lcd_panel->width;
695 gpanel.winSizeY = lcd_panel->height;
696 gpanel.plnSizeX = lcd_panel->width;
697 gpanel.plnSizeY = lcd_panel->height;
699 switch (bits_x_pixel) {
701 gpanel.gdfBytesPP = 4;
702 gpanel.gdfIndex = GDF_32BIT_X888RGB;
705 gpanel.gdfBytesPP = 2;
706 gpanel.gdfIndex = GDF_16BIT_565RGB;
709 gpanel.gdfBytesPP = 1;
710 gpanel.gdfIndex = GDF__8BIT_INDEX;
714 da8xx_fb_reg_base = (struct da8xx_lcd_regs *)DAVINCI_LCD_CNTL_BASE;
716 debug("Resolution: %dx%d %x\n",
721 size = sizeof(struct fb_info) + sizeof(struct da8xx_fb_par);
722 da8xx_fb_info = malloc(size);
723 debug("da8xx_fb_info at %x\n", (unsigned int)da8xx_fb_info);
725 if (!da8xx_fb_info) {
726 printf("Memory allocation failed for fb_info\n");
729 memset(da8xx_fb_info, 0, size);
730 p = (char *)da8xx_fb_info;
731 da8xx_fb_info->par = p + sizeof(struct fb_info);
732 debug("da8xx_par at %x\n", (unsigned int)da8xx_fb_info->par);
734 par = da8xx_fb_info->par;
735 par->pxl_clk = lcd_panel->pxl_clk;
737 if (lcd_init(par, &lcd_cfg, lcd_panel) < 0) {
738 printf("lcd_init failed\n");
742 /* allocate frame buffer */
743 par->vram_size = lcd_panel->width * lcd_panel->height * lcd_cfg.bpp;
744 par->vram_size = par->vram_size * LCD_NUM_BUFFERS / 8;
746 par->vram_virt = malloc(par->vram_size);
748 par->vram_phys = (dma_addr_t) par->vram_virt;
749 debug("Requesting 0x%x bytes for framebuffer at 0x%x\n",
750 (unsigned int)par->vram_size,
751 (unsigned int)par->vram_virt);
752 if (!par->vram_virt) {
753 printf("GLCD: malloc for frame buffer failed\n");
757 gpanel.frameAdrs = (unsigned int)par->vram_virt;
758 da8xx_fb_info->screen_base = (char *) par->vram_virt;
759 da8xx_fb_fix.smem_start = gpanel.frameAdrs;
760 da8xx_fb_fix.smem_len = par->vram_size;
761 da8xx_fb_fix.line_length = (lcd_panel->width * lcd_cfg.bpp) / 8;
763 par->dma_start = par->vram_phys;
764 par->dma_end = par->dma_start + lcd_panel->height *
765 da8xx_fb_fix.line_length - 1;
767 /* allocate palette buffer */
768 par->v_palette_base = malloc(PALETTE_SIZE);
769 if (!par->v_palette_base) {
770 printf("GLCD: malloc for palette buffer failed\n");
771 goto err_release_fb_mem;
773 memset(par->v_palette_base, 0, PALETTE_SIZE);
774 par->p_palette_base = (unsigned int)par->v_palette_base;
777 da8xx_fb_info->var.bits_per_pixel = lcd_cfg.bpp;
779 da8xx_fb_var.xres = lcd_panel->width;
780 da8xx_fb_var.xres_virtual = lcd_panel->width;
782 da8xx_fb_var.yres = lcd_panel->height;
783 da8xx_fb_var.yres_virtual = lcd_panel->height * LCD_NUM_BUFFERS;
785 da8xx_fb_var.grayscale =
786 lcd_cfg.p_disp_panel->panel_shade == MONOCHROME ? 1 : 0;
787 da8xx_fb_var.bits_per_pixel = lcd_cfg.bpp;
789 da8xx_fb_var.hsync_len = lcd_panel->hsw;
790 da8xx_fb_var.vsync_len = lcd_panel->vsw;
792 /* Initialize fbinfo */
793 da8xx_fb_info->flags = FBINFO_FLAG_DEFAULT;
794 da8xx_fb_info->fix = da8xx_fb_fix;
795 da8xx_fb_info->var = da8xx_fb_var;
796 da8xx_fb_info->pseudo_palette = par->pseudo_palette;
797 da8xx_fb_info->fix.visual = (da8xx_fb_info->var.bits_per_pixel <= 8) ?
798 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
800 /* Clear interrupt */
801 memset((void *)par->vram_virt, 0, par->vram_size);
802 lcd_disable_raster();
803 lcdc_write(0xFFFF, &da8xx_fb_reg_base->stat);
804 debug("Palette at 0x%x size %d\n", par->p_palette_base,
808 /* Load a default palette */
809 fb_setcolreg(0, 0, 0, 0, 0xffff, da8xx_fb_info);
811 /* Check that the palette is loaded */
812 wait_for_event(LCD_PL_LOAD_DONE);
814 /* Wait until DMA is working */
815 wait_for_event(LCD_END_OF_FRAME0);
817 return (void *)&gpanel;
820 free(par->vram_virt);
828 void video_set_lut(unsigned int index, /* color number */
829 unsigned char r, /* red */
830 unsigned char g, /* green */
831 unsigned char b /* blue */
838 void da8xx_video_init(const struct da8xx_panel *panel, int bits_pixel)
841 bits_x_pixel = bits_pixel;