]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/video/mxc_ipuv3_fb.c
video: ipu: initialize g_ipu_clk, g_ldb_clk statically
[karo-tx-uboot.git] / drivers / video / mxc_ipuv3_fb.c
index 9b2602922367f718d9ca8b16723ed86c49b80b4b..cd95abab837064a5616649a6b85c4e255062a27b 100644 (file)
@@ -8,29 +8,13 @@
  *
  * (C) Copyright 2004-2011 Freescale Semiconductor, Inc.
  *
- * 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+
  */
 
 /* #define DEBUG */
-// #define DEBUG
 #include <common.h>
 #include <asm/errno.h>
+#include <asm/global_data.h>
 #include <linux/string.h>
 #include <linux/list.h>
 #include <linux/fb.h>
 #include <lcd.h>
 #include <ipu.h>
 #include <video_fb.h>
+#include <mxcfb.h>
+
+#include "ipu_regs.h"
 #include "videomodes.h"
-#include "mxcfb.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern vidinfo_t panel_info;
-
-void *lcd_base;                        /* Start of framebuffer memory  */
-void *lcd_console_address;     /* Start of console buffer      */
-
-int lcd_line_length;
-int lcd_color_fg;
-int lcd_color_bg;
-
-short console_col;
-short console_row;
-
 static int mxcfb_map_video_memory(struct fb_info *fbi);
 static int mxcfb_unmap_video_memory(struct fb_info *fbi);
 
@@ -67,14 +41,6 @@ void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
 {
 }
 
-void lcd_disable(void)
-{
-}
-
-void lcd_panel_disable(void)
-{
-}
-
 static void fb_videomode_to_var(struct fb_var_screeninfo *var,
                         const struct fb_videomode *mode)
 {
@@ -445,10 +411,13 @@ static int mxcfb_map_video_memory(struct fb_info *fbi)
                fbi->fix.smem_len = fbi->var.yres_virtual *
                                    fbi->fix.line_length;
        }
+
+       fbi->fix.smem_len = roundup(fbi->fix.smem_len, ARCH_DMA_MINALIGN);
        if (gd->fb_base)
                fbi->screen_base = (void *)gd->fb_base;
        else
-               fbi->screen_base = malloc(fbi->fix.smem_len);
+               fbi->screen_base = (char *)memalign(ARCH_DMA_MINALIGN,
+                                               fbi->fix.smem_len);
        if (fbi->screen_base == NULL) {
                puts("Unable to allocate framebuffer memory\n");
                fbi->fix.smem_len = 0;
@@ -461,6 +430,8 @@ static int mxcfb_map_video_memory(struct fb_info *fbi)
 
        fbi->screen_size = fbi->fix.smem_len;
 
+       gd->fb_base = fbi->fix.smem_start;
+
        return 0;
 }
 
@@ -521,7 +492,7 @@ static struct fb_info *mxcfb_init_fbinfo(void)
 
 /*
  * Probe routine for the framebuffer driver. It is called during the
- * driver binding process.      The following functions are performed in
+ * driver binding process. The following functions are performed in
  * this routine: Framebuffer initialization, Memory allocation and
  * mapping, Framebuffer registration, IPU initialization.
  *
@@ -570,6 +541,10 @@ static int mxcfb_probe(u32 interface_pix_fmt, struct fb_videomode *mode, int di)
        fbi->fix.smem_len = fbi->var.yres_virtual * fbi->fix.line_length;
 
        mxcfb_check_var(&fbi->var, fbi);
+
+       /* Default Y virtual size is 2x panel size */
+       fbi->var.yres_virtual = fbi->var.yres * 2;
+
        mxcfb_set_fix(fbi);
 
        /* allocate fb first */
@@ -597,36 +572,33 @@ ulong calc_fbsize(void)
                NBITS(panel_info.vl_bpix)) / 8;
 }
 
-int overwrite_console(void)
+void ipuv3_fb_shutdown(void)
 {
-       /* Keep stdout / stderr on serial, our LCD is for splashscreen only */
-       return 1;
-}
-
-#if 0
-void lcd_ctrl_init(void *lcdbase)
-{
-       u32 mem_len = panel_info.vl_col *
-               panel_info.vl_row *
-               NBITS(panel_info.vl_bpix) / 8;
-
-       /*
-        * We rely on lcdbase being a physical address, i.e., either MMU off,
-        * or 1-to-1 mapping. Might want to add some virt2phys here.
-        */
-       if (!lcdbase)
-               return;
-
-       memset(lcdbase, 0, mem_len);
+       int i;
+       struct ipu_stat *stat = (struct ipu_stat *)IPU_STAT;
+
+       for (i = 0; i < ARRAY_SIZE(mxcfb_info); i++) {
+               struct fb_info *fbi = mxcfb_info[i];
+               if (fbi) {
+                       struct mxcfb_info *mxc_fbi = fbi->par;
+                       ipu_disable_channel(mxc_fbi->ipu_ch);
+                       ipu_uninit_channel(mxc_fbi->ipu_ch);
+               }
+       }
+       clk_enable(g_ipu_clk);
+       for (i = 0; i < ARRAY_SIZE(stat->int_stat); i++) {
+               __raw_writel(__raw_readl(&stat->int_stat[i]),
+                            &stat->int_stat[i]);
+       }
+       clk_disable(g_ipu_clk);
 }
-#endif
 
 int ipuv3_fb_init(struct fb_videomode *mode, int di, unsigned int interface_pix_fmt,
                ipu_di_clk_parent_t di_clk_parent, unsigned long di_clk_val, int bpp)
 {
        int ret;
 
-//     default_bpp = bpp;
+       default_bpp = bpp;
 
        ret = ipu_probe(di, di_clk_parent, di_clk_val);
        if (ret) {
@@ -634,8 +606,5 @@ int ipuv3_fb_init(struct fb_videomode *mode, int di, unsigned int interface_pix_
                return ret;
        }
 
-       debug("Framebuffer at %p\n", lcd_base);
-       ret = mxcfb_probe(interface_pix_fmt, mode, di);
-
-       return ret;
+       return mxcfb_probe(interface_pix_fmt, mode, di);
 }