dm: x86: video: Add a driver-model driver for ivybridge graphics
[oweals/u-boot.git] / drivers / video / atmel_hlcdfb.c
index b10ca4b67719b33368b540ef941e4e09ffd8349f..960b474b76b863aa9cc59c9c8158631e88860c48 100644 (file)
@@ -3,23 +3,7 @@
  *
  * Copyright (C) 2012 Atmel Corporation
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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 program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <lcd.h>
 #include <atmel_hlcdc.h>
 
-int lcd_line_length;
-int lcd_color_fg;
-int lcd_color_bg;
-
-void *lcd_base;                                /* Start of framebuffer memory  */
-void *lcd_console_address;             /* Start of console buffer      */
-
-short console_col;
-short console_row;
+#if defined(CONFIG_LCD_LOGO)
+#include <bmp_logo.h>
+#endif
 
 /* configurable parameters */
 #define ATMEL_LCDC_CVAL_DEFAULT                0xc8
@@ -63,6 +41,15 @@ void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
                panel_info.mmio + ATMEL_LCDC_LUT(regno));
 }
 
+ushort *configuration_get_cmap(void)
+{
+#if defined(CONFIG_LCD_LOGO)
+       return bmp_logo_palette;
+#else
+       return NULL;
+#endif
+}
+
 void lcd_ctrl_init(void *lcdbase)
 {
        unsigned long value;
@@ -154,12 +141,12 @@ void lcd_ctrl_init(void *lcdbase)
        value |= LCDC_LCDCFG1_HSPW(panel_info.vl_hsync_len - 1);
        lcdc_writel(&regs->lcdc_lcdcfg1, value);
 
-       value = LCDC_LCDCFG2_VBPW(panel_info.vl_lower_margin);
-       value |= LCDC_LCDCFG2_VFPW(panel_info.vl_upper_margin - 1);
+       value = LCDC_LCDCFG2_VBPW(panel_info.vl_upper_margin);
+       value |= LCDC_LCDCFG2_VFPW(panel_info.vl_lower_margin - 1);
        lcdc_writel(&regs->lcdc_lcdcfg2, value);
 
-       value = LCDC_LCDCFG3_HBPW(panel_info.vl_right_margin - 1);
-       value |= LCDC_LCDCFG3_HFPW(panel_info.vl_left_margin - 1);
+       value = LCDC_LCDCFG3_HBPW(panel_info.vl_left_margin - 1);
+       value |= LCDC_LCDCFG3_HFPW(panel_info.vl_right_margin - 1);
        lcdc_writel(&regs->lcdc_lcdcfg3, value);
 
        /* Display size */
@@ -175,6 +162,10 @@ void lcd_ctrl_init(void *lcdbase)
                lcdc_writel(&regs->lcdc_basecfg1,
                        LCDC_BASECFG1_RGBMODE_16BPP_RGB_565);
                break;
+       case 32:
+               lcdc_writel(&regs->lcdc_basecfg1,
+                       LCDC_BASECFG1_RGBMODE_24BPP_RGB_888);
+               break;
        default:
                BUG();
                break;
@@ -197,6 +188,9 @@ void lcd_ctrl_init(void *lcdbase)
                        | LCDC_BASECTRL_DMAIEN | LCDC_BASECTRL_DFETCH;
        desc->next = (u32)desc;
 
+       /* Flush the DMA descriptor if we enabled dcache */
+       flush_dcache_range((u32)desc, (u32)desc + sizeof(*desc));
+
        lcdc_writel(&regs->lcdc_baseaddr, desc->address);
        lcdc_writel(&regs->lcdc_basectrl, desc->control);
        lcdc_writel(&regs->lcdc_basenext, desc->next);
@@ -220,4 +214,7 @@ void lcd_ctrl_init(void *lcdbase)
        lcdc_writel(&regs->lcdc_lcden, value | LCDC_LCDEN_PWMEN);
        while (!(lcdc_readl(&regs->lcdc_lcdsr) & LCDC_LCDSR_PWMSTS))
                udelay(1);
+
+       /* Enable flushing if we enabled dcache */
+       lcd_set_flush_dcache(1);
 }