Merge https://gitlab.denx.de/u-boot/custodians/u-boot-spi into next
[platform/kernel/u-boot.git] / drivers / video / imx / mxc_ipuv3_fb.c
index cdef84a..587d62f 100644 (file)
@@ -38,8 +38,6 @@ DECLARE_GLOBAL_DATA_PTR;
 static int mxcfb_map_video_memory(struct fb_info *fbi);
 static int mxcfb_unmap_video_memory(struct fb_info *fbi);
 
-/* graphics setup */
-static GraphicDevice panel;
 static struct fb_videomode const *gmode;
 static uint8_t gdisp;
 static uint32_t gpixfmt;
@@ -120,27 +118,6 @@ static uint32_t bpp_to_pixfmt(struct fb_info *fbi)
        return pixfmt;
 }
 
-/*
- * Set fixed framebuffer parameters based on variable settings.
- *
- * @param       info     framebuffer information pointer
- */
-static int mxcfb_set_fix(struct fb_info *info)
-{
-       struct fb_fix_screeninfo *fix = &info->fix;
-       struct fb_var_screeninfo *var = &info->var;
-
-       fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
-
-       fix->type = FB_TYPE_PACKED_PIXELS;
-       fix->accel = FB_ACCEL_NONE;
-       fix->visual = FB_VISUAL_TRUECOLOR;
-       fix->xpanstep = 1;
-       fix->ypanstep = 1;
-
-       return 0;
-}
-
 static int setup_disp_channel1(struct fb_info *fbi)
 {
        ipu_channel_params_t params;
@@ -226,7 +203,6 @@ static int mxcfb_set_par(struct fb_info *fbi)
 
        ipu_disable_channel(mxc_fbi->ipu_ch);
        ipu_uninit_channel(mxc_fbi->ipu_ch);
-       mxcfb_set_fix(fbi);
 
        mem_len = fbi->var.yres_virtual * fbi->fix.line_length;
        if (!fbi->fix.smem_start || (mem_len > fbi->fix.smem_len)) {
@@ -411,12 +387,7 @@ static int mxcfb_map_video_memory(struct fb_info *fbi)
        }
        fbi->fix.smem_len = roundup(fbi->fix.smem_len, ARCH_DMA_MINALIGN);
 
-#if CONFIG_IS_ENABLED(DM_VIDEO)
        fbi->screen_base = (char *)gd->video_bottom;
-#else
-       fbi->screen_base = (char *)memalign(ARCH_DMA_MINALIGN,
-                                           fbi->fix.smem_len);
-#endif
 
        fbi->fix.smem_start = (unsigned long)fbi->screen_base;
        if (fbi->screen_base == 0) {
@@ -430,10 +401,7 @@ static int mxcfb_map_video_memory(struct fb_info *fbi)
                (uint32_t) fbi->fix.smem_start, fbi->fix.smem_len);
 
        fbi->screen_size = fbi->fix.smem_len;
-
-#if CONFIG_IS_ENABLED(VIDEO)
        gd->fb_base = fbi->fix.smem_start;
-#endif
 
        /* Clear the screen */
        memset((char *)fbi->screen_base, 0, fbi->fix.smem_len);
@@ -499,6 +467,8 @@ static struct fb_info *mxcfb_init_fbinfo(void)
        return fbi;
 }
 
+extern struct clk *g_ipu_clk;
+
 /*
  * Probe routine for the framebuffer driver. It is called during the
  * driver binding process. The following functions are performed in
@@ -512,16 +482,14 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
 {
        struct fb_info *fbi;
        struct mxcfb_info *mxcfbi;
-       int ret = 0;
 
        /*
         * Initialize FB structures
         */
        fbi = mxcfb_init_fbinfo();
-       if (!fbi) {
-               ret = -ENOMEM;
-               goto err0;
-       }
+       if (!fbi)
+               return -ENOMEM;
+
        mxcfbi = (struct mxcfb_info *)fbi->par;
 
        if (!g_dp_in_use) {
@@ -534,9 +502,11 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
 
        mxcfbi->ipu_di = disp;
 
+       if (!ipu_clk_enabled())
+               clk_enable(g_ipu_clk);
+
        ipu_disp_set_global_alpha(mxcfbi->ipu_ch, 1, 0x80);
        ipu_disp_set_color_key(mxcfbi->ipu_ch, 0, 0);
-       strcpy(fbi->fix.id, "DISP3 BG");
 
        g_dp_in_use = 1;
 
@@ -547,7 +517,8 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
        mxcfbi->ipu_di_pix_fmt = interface_pix_fmt;
        fb_videomode_to_var(&fbi->var, mode);
        fbi->var.bits_per_pixel = 16;
-       fbi->fix.line_length = fbi->var.xres * (fbi->var.bits_per_pixel / 8);
+       fbi->fix.line_length = fbi->var.xres_virtual *
+                              (fbi->var.bits_per_pixel / 8);
        fbi->fix.smem_len = fbi->var.yres_virtual * fbi->fix.line_length;
 
        mxcfb_check_var(&fbi->var, fbi);
@@ -555,31 +526,17 @@ static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
        /* Default Y virtual size is 2x panel size */
        fbi->var.yres_virtual = fbi->var.yres * 2;
 
-       mxcfb_set_fix(fbi);
-
        /* allocate fb first */
        if (mxcfb_map_video_memory(fbi) < 0)
                return -ENOMEM;
 
        mxcfb_set_par(fbi);
 
-       panel.winSizeX = mode->xres;
-       panel.winSizeY = mode->yres;
-       panel.plnSizeX = mode->xres;
-       panel.plnSizeY = mode->yres;
-
-       panel.frameAdrs = (u32)fbi->screen_base;
-       panel.memSize = fbi->screen_size;
-
-       panel.gdfBytesPP = 2;
-       panel.gdfIndex = GDF_16BIT_565RGB;
-
+#ifdef DEBUG
        ipu_dump_registers();
+#endif
 
        return 0;
-
-err0:
-       return ret;
 }
 
 void ipuv3_fb_shutdown(void)
@@ -604,21 +561,6 @@ void ipuv3_fb_shutdown(void)
        }
 }
 
-void *video_hw_init(void)
-{
-       int ret;
-
-       ret = ipu_probe();
-       if (ret)
-               puts("Error initializing IPU\n");
-
-       ret = mxcfb_probe(gpixfmt, gdisp, gmode);
-       debug("Framebuffer at 0x%x\n", (unsigned int)panel.frameAdrs);
-       gd->fb_base = panel.frameAdrs;
-
-       return (void *)&panel;
-}
-
 int ipuv3_fb_init(struct fb_videomode const *mode,
                  uint8_t disp,
                  uint32_t pixfmt)
@@ -630,7 +572,6 @@ int ipuv3_fb_init(struct fb_videomode const *mode,
        return 0;
 }
 
-#if CONFIG_IS_ENABLED(DM_VIDEO)
 enum {
        /* Maximum display size we support */
        LCD_MAX_WIDTH           = 1920,
@@ -710,8 +651,12 @@ static int ipuv3_video_bind(struct udevice *dev)
 }
 
 static const struct udevice_id ipuv3_video_ids[] = {
+#ifdef CONFIG_ARCH_MX6
        { .compatible = "fsl,imx6q-ipu" },
+#endif
+#ifdef CONFIG_ARCH_MX5
        { .compatible = "fsl,imx53-ipu" },
+#endif
        { }
 };
 
@@ -724,4 +669,3 @@ U_BOOT_DRIVER(ipuv3_video) = {
        .priv_auto_alloc_size = sizeof(struct ipuv3_video_priv),
        .flags  = DM_FLAG_PRE_RELOC,
 };
-#endif /* CONFIG_DM_VIDEO */