]> git.sur5r.net Git - u-boot/blobdiff - drivers/video/mxsfb.c
dm: core: Update of_read_fmap_entry() for livetree
[u-boot] / drivers / video / mxsfb.c
index c55cb44ffd64dcc23e395421d41e78270ed118e7..02fde0590829a098d8af87b1af886f7b2e6787a9 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Freescale i.MX23/i.MX28 LCDIF driver
  *
  * Copyright (C) 2011-2013 Marek Vasut <marex@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
 #include <malloc.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <asm/io.h>
 
+#include <asm/mach-imx/dma.h>
+
 #include "videomodes.h"
 
 #define        PS2KHZ(ps)      (1000000000UL / (ps))
 
 static GraphicDevice panel;
+struct mxs_dma_desc desc;
 
 /**
  * mxsfb_system_setup() - Fine-tune LCDIF configuration
@@ -33,7 +35,7 @@ __weak void mxsfb_system_setup(void)
 }
 
 /*
- * DENX M28EVK:
+ * ARIES M28EVK:
  * setenv videomode
  * video=ctfb:x:800,y:480,depth:18,mode:0,pclk:30066,
  *       le:0,ri:256,up:0,lo:45,hs:1,vs:1,sync:100663296,vmode:0
@@ -52,7 +54,7 @@ static void mxs_lcd_init(GraphicDevice *panel,
        uint8_t valid_data = 0;
 
        /* Kick in the LCDIF clock */
-       mxs_set_lcdclk(PS2KHZ(mode->pixclock));
+       mxs_set_lcdclk(MXS_LCDIF_BASE, PS2KHZ(mode->pixclock));
 
        /* Restart the LCDIF block */
        mxs_reset_block(&regs->hw_lcdif_ctrl_reg);
@@ -128,6 +130,26 @@ static void mxs_lcd_init(GraphicDevice *panel,
        writel(LCDIF_CTRL_RUN, &regs->hw_lcdif_ctrl_set);
 }
 
+void lcdif_power_down(void)
+{
+       struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
+       int timeout = 1000000;
+
+       if (!panel.frameAdrs)
+               return;
+
+       writel(panel.frameAdrs, &regs->hw_lcdif_cur_buf_reg);
+       writel(panel.frameAdrs, &regs->hw_lcdif_next_buf_reg);
+       writel(LCDIF_CTRL1_VSYNC_EDGE_IRQ, &regs->hw_lcdif_ctrl1_clr);
+       while (--timeout) {
+               if (readl(&regs->hw_lcdif_ctrl1_reg) &
+                   LCDIF_CTRL1_VSYNC_EDGE_IRQ)
+                       break;
+               udelay(1);
+       }
+       mxs_reset_block((struct mxs_register_32 *)&regs->hw_lcdif_ctrl_reg);
+}
+
 void *video_hw_init(void)
 {
        int bpp = -1;
@@ -138,7 +160,7 @@ void *video_hw_init(void)
        puts("Video: ");
 
        /* Suck display configuration from "videomode" variable */
-       penv = getenv("videomode");
+       penv = env_get("videomode");
        if (!penv) {
                puts("MXSFB: 'videomode' variable not set!\n");
                return NULL;
@@ -194,5 +216,28 @@ void *video_hw_init(void)
        /* Start framebuffer */
        mxs_lcd_init(&panel, &mode, bpp);
 
+#ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM
+       /*
+        * If the LCD runs in system mode, the LCD refresh has to be triggered
+        * manually by setting the RUN bit in HW_LCDIF_CTRL register. To avoid
+        * having to set this bit manually after every single change in the
+        * framebuffer memory, we set up specially crafted circular DMA, which
+        * sets the RUN bit, then waits until it gets cleared and repeats this
+        * infinitelly. This way, we get smooth continuous updates of the LCD.
+        */
+       struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
+
+       memset(&desc, 0, sizeof(struct mxs_dma_desc));
+       desc.address = (dma_addr_t)&desc;
+       desc.cmd.data = MXS_DMA_DESC_COMMAND_NO_DMAXFER | MXS_DMA_DESC_CHAIN |
+                       MXS_DMA_DESC_WAIT4END |
+                       (1 << MXS_DMA_DESC_PIO_WORDS_OFFSET);
+       desc.cmd.pio_words[0] = readl(&regs->hw_lcdif_ctrl) | LCDIF_CTRL_RUN;
+       desc.cmd.next = (uint32_t)&desc.cmd;
+
+       /* Execute the DMA chain. */
+       mxs_dma_circ_start(MXS_DMA_CHANNEL_AHB_APBH_LCDIF, &desc);
+#endif
+
        return (void *)&panel;
 }