Merge tag 'video-for-2019.10-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / drivers / video / imx / mxc_ipuv3_fb.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Porting to u-boot:
4  *
5  * (C) Copyright 2010
6  * Stefano Babic, DENX Software Engineering, sbabic@denx.de
7  *
8  * MX51 Linux framebuffer:
9  *
10  * (C) Copyright 2004-2010 Freescale Semiconductor, Inc.
11  */
12
13 #include <common.h>
14 #include <linux/errno.h>
15 #include <asm/global_data.h>
16 #include <linux/string.h>
17 #include <linux/list.h>
18 #include <linux/fb.h>
19 #include <asm/io.h>
20 #include <asm/mach-imx/video.h>
21 #include <malloc.h>
22 #include <video_fb.h>
23 #include "../videomodes.h"
24 #include "ipu.h"
25 #include "mxcfb.h"
26 #include "ipu_regs.h"
27 #include "display.h"
28 #include <panel.h>
29
30 #include <dm.h>
31 #include <video.h>
32
33 DECLARE_GLOBAL_DATA_PTR;
34
35 static int mxcfb_map_video_memory(struct fb_info *fbi);
36 static int mxcfb_unmap_video_memory(struct fb_info *fbi);
37
38 /* graphics setup */
39 static GraphicDevice panel;
40 static struct fb_videomode const *gmode;
41 static uint8_t gdisp;
42 static uint32_t gpixfmt;
43
44 static void fb_videomode_to_var(struct fb_var_screeninfo *var,
45                          const struct fb_videomode *mode)
46 {
47         var->xres = mode->xres;
48         var->yres = mode->yres;
49         var->xres_virtual = mode->xres;
50         var->yres_virtual = mode->yres;
51         var->xoffset = 0;
52         var->yoffset = 0;
53         var->pixclock = mode->pixclock;
54         var->left_margin = mode->left_margin;
55         var->right_margin = mode->right_margin;
56         var->upper_margin = mode->upper_margin;
57         var->lower_margin = mode->lower_margin;
58         var->hsync_len = mode->hsync_len;
59         var->vsync_len = mode->vsync_len;
60         var->sync = mode->sync;
61         var->vmode = mode->vmode & FB_VMODE_MASK;
62 }
63
64 /*
65  * Structure containing the MXC specific framebuffer information.
66  */
67 struct mxcfb_info {
68         int blank;
69         ipu_channel_t ipu_ch;
70         int ipu_di;
71         u32 ipu_di_pix_fmt;
72         unsigned char overlay;
73         unsigned char alpha_chan_en;
74         dma_addr_t alpha_phy_addr0;
75         dma_addr_t alpha_phy_addr1;
76         void *alpha_virt_addr0;
77         void *alpha_virt_addr1;
78         uint32_t alpha_mem_len;
79         uint32_t cur_ipu_buf;
80         uint32_t cur_ipu_alpha_buf;
81
82         u32 pseudo_palette[16];
83 };
84
85 enum {
86         BOTH_ON,
87         SRC_ON,
88         TGT_ON,
89         BOTH_OFF
90 };
91
92 static unsigned long default_bpp = 16;
93 static unsigned char g_dp_in_use;
94 static struct fb_info *mxcfb_info[3];
95 static int ext_clk_used;
96
97 static uint32_t bpp_to_pixfmt(struct fb_info *fbi)
98 {
99         uint32_t pixfmt = 0;
100
101         debug("bpp_to_pixfmt: %d\n", fbi->var.bits_per_pixel);
102
103         if (fbi->var.nonstd)
104                 return fbi->var.nonstd;
105
106         switch (fbi->var.bits_per_pixel) {
107         case 24:
108                 pixfmt = IPU_PIX_FMT_BGR24;
109                 break;
110         case 32:
111                 pixfmt = IPU_PIX_FMT_BGR32;
112                 break;
113         case 16:
114                 pixfmt = IPU_PIX_FMT_RGB565;
115                 break;
116         }
117         return pixfmt;
118 }
119
120 /*
121  * Set fixed framebuffer parameters based on variable settings.
122  *
123  * @param       info     framebuffer information pointer
124  */
125 static int mxcfb_set_fix(struct fb_info *info)
126 {
127         struct fb_fix_screeninfo *fix = &info->fix;
128         struct fb_var_screeninfo *var = &info->var;
129
130         fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
131
132         fix->type = FB_TYPE_PACKED_PIXELS;
133         fix->accel = FB_ACCEL_NONE;
134         fix->visual = FB_VISUAL_TRUECOLOR;
135         fix->xpanstep = 1;
136         fix->ypanstep = 1;
137
138         return 0;
139 }
140
141 static int setup_disp_channel1(struct fb_info *fbi)
142 {
143         ipu_channel_params_t params;
144         struct mxcfb_info *mxc_fbi = (struct mxcfb_info *)fbi->par;
145
146         memset(&params, 0, sizeof(params));
147         params.mem_dp_bg_sync.di = mxc_fbi->ipu_di;
148
149         debug("%s called\n", __func__);
150         /*
151          * Assuming interlaced means yuv output, below setting also
152          * valid for mem_dc_sync. FG should have the same vmode as BG.
153          */
154         if (fbi->var.vmode & FB_VMODE_INTERLACED) {
155                 params.mem_dp_bg_sync.interlaced = 1;
156                 params.mem_dp_bg_sync.out_pixel_fmt =
157                         IPU_PIX_FMT_YUV444;
158         } else {
159                 if (mxc_fbi->ipu_di_pix_fmt) {
160                         params.mem_dp_bg_sync.out_pixel_fmt =
161                                 mxc_fbi->ipu_di_pix_fmt;
162                 } else {
163                         params.mem_dp_bg_sync.out_pixel_fmt =
164                                 IPU_PIX_FMT_RGB666;
165                 }
166         }
167         params.mem_dp_bg_sync.in_pixel_fmt = bpp_to_pixfmt(fbi);
168         if (mxc_fbi->alpha_chan_en)
169                 params.mem_dp_bg_sync.alpha_chan_en = 1;
170
171         ipu_init_channel(mxc_fbi->ipu_ch, &params);
172
173         return 0;
174 }
175
176 static int setup_disp_channel2(struct fb_info *fbi)
177 {
178         int retval = 0;
179         struct mxcfb_info *mxc_fbi = (struct mxcfb_info *)fbi->par;
180
181         mxc_fbi->cur_ipu_buf = 1;
182         if (mxc_fbi->alpha_chan_en)
183                 mxc_fbi->cur_ipu_alpha_buf = 1;
184
185         fbi->var.xoffset = fbi->var.yoffset = 0;
186
187         debug("%s: %x %d %d %d %lx %lx\n",
188                 __func__,
189                 mxc_fbi->ipu_ch,
190                 fbi->var.xres,
191                 fbi->var.yres,
192                 fbi->fix.line_length,
193                 fbi->fix.smem_start,
194                 fbi->fix.smem_start +
195                 (fbi->fix.line_length * fbi->var.yres));
196
197         retval = ipu_init_channel_buffer(mxc_fbi->ipu_ch, IPU_INPUT_BUFFER,
198                                          bpp_to_pixfmt(fbi),
199                                          fbi->var.xres, fbi->var.yres,
200                                          fbi->fix.line_length,
201                                          fbi->fix.smem_start +
202                                          (fbi->fix.line_length * fbi->var.yres),
203                                          fbi->fix.smem_start,
204                                          0, 0);
205         if (retval)
206                 printf("ipu_init_channel_buffer error %d\n", retval);
207
208         return retval;
209 }
210
211 /*
212  * Set framebuffer parameters and change the operating mode.
213  *
214  * @param       info     framebuffer information pointer
215  */
216 static int mxcfb_set_par(struct fb_info *fbi)
217 {
218         int retval = 0;
219         u32 mem_len;
220         ipu_di_signal_cfg_t sig_cfg;
221         struct mxcfb_info *mxc_fbi = (struct mxcfb_info *)fbi->par;
222         uint32_t out_pixel_fmt;
223
224         ipu_disable_channel(mxc_fbi->ipu_ch);
225         ipu_uninit_channel(mxc_fbi->ipu_ch);
226         mxcfb_set_fix(fbi);
227
228         mem_len = fbi->var.yres_virtual * fbi->fix.line_length;
229         if (!fbi->fix.smem_start || (mem_len > fbi->fix.smem_len)) {
230                 if (fbi->fix.smem_start)
231                         mxcfb_unmap_video_memory(fbi);
232
233                 if (mxcfb_map_video_memory(fbi) < 0)
234                         return -ENOMEM;
235         }
236
237         setup_disp_channel1(fbi);
238
239         memset(&sig_cfg, 0, sizeof(sig_cfg));
240         if (fbi->var.vmode & FB_VMODE_INTERLACED) {
241                 sig_cfg.interlaced = 1;
242                 out_pixel_fmt = IPU_PIX_FMT_YUV444;
243         } else {
244                 if (mxc_fbi->ipu_di_pix_fmt)
245                         out_pixel_fmt = mxc_fbi->ipu_di_pix_fmt;
246                 else
247                         out_pixel_fmt = IPU_PIX_FMT_RGB666;
248         }
249         if (fbi->var.vmode & FB_VMODE_ODD_FLD_FIRST) /* PAL */
250                 sig_cfg.odd_field_first = 1;
251         if ((fbi->var.sync & FB_SYNC_EXT) || ext_clk_used)
252                 sig_cfg.ext_clk = 1;
253         if (fbi->var.sync & FB_SYNC_HOR_HIGH_ACT)
254                 sig_cfg.Hsync_pol = 1;
255         if (fbi->var.sync & FB_SYNC_VERT_HIGH_ACT)
256                 sig_cfg.Vsync_pol = 1;
257         if (!(fbi->var.sync & FB_SYNC_CLK_LAT_FALL))
258                 sig_cfg.clk_pol = 1;
259         if (fbi->var.sync & FB_SYNC_DATA_INVERT)
260                 sig_cfg.data_pol = 1;
261         if (!(fbi->var.sync & FB_SYNC_OE_LOW_ACT))
262                 sig_cfg.enable_pol = 1;
263         if (fbi->var.sync & FB_SYNC_CLK_IDLE_EN)
264                 sig_cfg.clkidle_en = 1;
265
266         debug("pixclock = %lu Hz\n", PICOS2KHZ(fbi->var.pixclock) * 1000UL);
267
268         if (ipu_init_sync_panel(mxc_fbi->ipu_di,
269                                 (PICOS2KHZ(fbi->var.pixclock)) * 1000UL,
270                                 fbi->var.xres, fbi->var.yres,
271                                 out_pixel_fmt,
272                                 fbi->var.left_margin,
273                                 fbi->var.hsync_len,
274                                 fbi->var.right_margin,
275                                 fbi->var.upper_margin,
276                                 fbi->var.vsync_len,
277                                 fbi->var.lower_margin,
278                                 0, sig_cfg) != 0) {
279                 puts("mxcfb: Error initializing panel.\n");
280                 return -EINVAL;
281         }
282
283         retval = setup_disp_channel2(fbi);
284         if (retval)
285                 return retval;
286
287         if (mxc_fbi->blank == FB_BLANK_UNBLANK)
288                 ipu_enable_channel(mxc_fbi->ipu_ch);
289
290         return retval;
291 }
292
293 /*
294  * Check framebuffer variable parameters and adjust to valid values.
295  *
296  * @param       var      framebuffer variable parameters
297  *
298  * @param       info     framebuffer information pointer
299  */
300 static int mxcfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
301 {
302         u32 vtotal;
303         u32 htotal;
304
305         if (var->xres_virtual < var->xres)
306                 var->xres_virtual = var->xres;
307         if (var->yres_virtual < var->yres)
308                 var->yres_virtual = var->yres;
309
310         if ((var->bits_per_pixel != 32) && (var->bits_per_pixel != 24) &&
311             (var->bits_per_pixel != 16) && (var->bits_per_pixel != 8))
312                 var->bits_per_pixel = default_bpp;
313
314         switch (var->bits_per_pixel) {
315         case 8:
316                 var->red.length = 3;
317                 var->red.offset = 5;
318                 var->red.msb_right = 0;
319
320                 var->green.length = 3;
321                 var->green.offset = 2;
322                 var->green.msb_right = 0;
323
324                 var->blue.length = 2;
325                 var->blue.offset = 0;
326                 var->blue.msb_right = 0;
327
328                 var->transp.length = 0;
329                 var->transp.offset = 0;
330                 var->transp.msb_right = 0;
331                 break;
332         case 16:
333                 var->red.length = 5;
334                 var->red.offset = 11;
335                 var->red.msb_right = 0;
336
337                 var->green.length = 6;
338                 var->green.offset = 5;
339                 var->green.msb_right = 0;
340
341                 var->blue.length = 5;
342                 var->blue.offset = 0;
343                 var->blue.msb_right = 0;
344
345                 var->transp.length = 0;
346                 var->transp.offset = 0;
347                 var->transp.msb_right = 0;
348                 break;
349         case 24:
350                 var->red.length = 8;
351                 var->red.offset = 16;
352                 var->red.msb_right = 0;
353
354                 var->green.length = 8;
355                 var->green.offset = 8;
356                 var->green.msb_right = 0;
357
358                 var->blue.length = 8;
359                 var->blue.offset = 0;
360                 var->blue.msb_right = 0;
361
362                 var->transp.length = 0;
363                 var->transp.offset = 0;
364                 var->transp.msb_right = 0;
365                 break;
366         case 32:
367                 var->red.length = 8;
368                 var->red.offset = 16;
369                 var->red.msb_right = 0;
370
371                 var->green.length = 8;
372                 var->green.offset = 8;
373                 var->green.msb_right = 0;
374
375                 var->blue.length = 8;
376                 var->blue.offset = 0;
377                 var->blue.msb_right = 0;
378
379                 var->transp.length = 8;
380                 var->transp.offset = 24;
381                 var->transp.msb_right = 0;
382                 break;
383         }
384
385         if (var->pixclock < 1000) {
386                 htotal = var->xres + var->right_margin + var->hsync_len +
387                     var->left_margin;
388                 vtotal = var->yres + var->lower_margin + var->vsync_len +
389                     var->upper_margin;
390                 var->pixclock = (vtotal * htotal * 6UL) / 100UL;
391                 var->pixclock = KHZ2PICOS(var->pixclock);
392                 printf("pixclock set for 60Hz refresh = %u ps\n",
393                         var->pixclock);
394         }
395
396         var->height = -1;
397         var->width = -1;
398         var->grayscale = 0;
399
400         return 0;
401 }
402
403 static int mxcfb_map_video_memory(struct fb_info *fbi)
404 {
405         if (fbi->fix.smem_len < fbi->var.yres_virtual * fbi->fix.line_length) {
406                 fbi->fix.smem_len = fbi->var.yres_virtual *
407                                     fbi->fix.line_length;
408         }
409         fbi->fix.smem_len = roundup(fbi->fix.smem_len, ARCH_DMA_MINALIGN);
410
411 #if CONFIG_IS_ENABLED(DM_VIDEO)
412         fbi->screen_base = (char *)gd->video_bottom;
413 #else
414         fbi->screen_base = (char *)memalign(ARCH_DMA_MINALIGN,
415                                             fbi->fix.smem_len);
416 #endif
417
418         fbi->fix.smem_start = (unsigned long)fbi->screen_base;
419         if (fbi->screen_base == 0) {
420                 puts("Unable to allocate framebuffer memory\n");
421                 fbi->fix.smem_len = 0;
422                 fbi->fix.smem_start = 0;
423                 return -EBUSY;
424         }
425
426         debug("allocated fb @ paddr=0x%08X, size=%d.\n",
427                 (uint32_t) fbi->fix.smem_start, fbi->fix.smem_len);
428
429         fbi->screen_size = fbi->fix.smem_len;
430
431 #if CONFIG_IS_ENABLED(VIDEO)
432         gd->fb_base = fbi->fix.smem_start;
433 #endif
434
435         /* Clear the screen */
436         memset((char *)fbi->screen_base, 0, fbi->fix.smem_len);
437
438         return 0;
439 }
440
441 static int mxcfb_unmap_video_memory(struct fb_info *fbi)
442 {
443         fbi->screen_base = 0;
444         fbi->fix.smem_start = 0;
445         fbi->fix.smem_len = 0;
446         return 0;
447 }
448
449 /*
450  * Initializes the framebuffer information pointer. After allocating
451  * sufficient memory for the framebuffer structure, the fields are
452  * filled with custom information passed in from the configurable
453  * structures.  This includes information such as bits per pixel,
454  * color maps, screen width/height and RGBA offsets.
455  *
456  * @return      Framebuffer structure initialized with our information
457  */
458 static struct fb_info *mxcfb_init_fbinfo(void)
459 {
460 #define BYTES_PER_LONG 4
461 #define PADDING (BYTES_PER_LONG - (sizeof(struct fb_info) % BYTES_PER_LONG))
462         struct fb_info *fbi;
463         struct mxcfb_info *mxcfbi;
464         char *p;
465         int size = sizeof(struct mxcfb_info) + PADDING +
466                 sizeof(struct fb_info);
467
468         debug("%s: %d %d %d %d\n",
469                 __func__,
470                 PADDING,
471                 size,
472                 sizeof(struct mxcfb_info),
473                 sizeof(struct fb_info));
474         /*
475          * Allocate sufficient memory for the fb structure
476          */
477
478         p = malloc(size);
479         if (!p)
480                 return NULL;
481
482         memset(p, 0, size);
483
484         fbi = (struct fb_info *)p;
485         fbi->par = p + sizeof(struct fb_info) + PADDING;
486
487         mxcfbi = (struct mxcfb_info *)fbi->par;
488         debug("Framebuffer structures at: fbi=0x%x mxcfbi=0x%x\n",
489                 (unsigned int)fbi, (unsigned int)mxcfbi);
490
491         fbi->var.activate = FB_ACTIVATE_NOW;
492
493         fbi->flags = FBINFO_FLAG_DEFAULT;
494         fbi->pseudo_palette = mxcfbi->pseudo_palette;
495
496         return fbi;
497 }
498
499 /*
500  * Probe routine for the framebuffer driver. It is called during the
501  * driver binding process. The following functions are performed in
502  * this routine: Framebuffer initialization, Memory allocation and
503  * mapping, Framebuffer registration, IPU initialization.
504  *
505  * @return      Appropriate error code to the kernel common code
506  */
507 static int mxcfb_probe(u32 interface_pix_fmt, uint8_t disp,
508                         struct fb_videomode const *mode)
509 {
510         struct fb_info *fbi;
511         struct mxcfb_info *mxcfbi;
512         int ret = 0;
513
514         /*
515          * Initialize FB structures
516          */
517         fbi = mxcfb_init_fbinfo();
518         if (!fbi) {
519                 ret = -ENOMEM;
520                 goto err0;
521         }
522         mxcfbi = (struct mxcfb_info *)fbi->par;
523
524         if (!g_dp_in_use) {
525                 mxcfbi->ipu_ch = MEM_BG_SYNC;
526                 mxcfbi->blank = FB_BLANK_UNBLANK;
527         } else {
528                 mxcfbi->ipu_ch = MEM_DC_SYNC;
529                 mxcfbi->blank = FB_BLANK_POWERDOWN;
530         }
531
532         mxcfbi->ipu_di = disp;
533
534         ipu_disp_set_global_alpha(mxcfbi->ipu_ch, 1, 0x80);
535         ipu_disp_set_color_key(mxcfbi->ipu_ch, 0, 0);
536         strcpy(fbi->fix.id, "DISP3 BG");
537
538         g_dp_in_use = 1;
539
540         mxcfb_info[mxcfbi->ipu_di] = fbi;
541
542         /* Need dummy values until real panel is configured */
543
544         mxcfbi->ipu_di_pix_fmt = interface_pix_fmt;
545         fb_videomode_to_var(&fbi->var, mode);
546         fbi->var.bits_per_pixel = 16;
547         fbi->fix.line_length = fbi->var.xres * (fbi->var.bits_per_pixel / 8);
548         fbi->fix.smem_len = fbi->var.yres_virtual * fbi->fix.line_length;
549
550         mxcfb_check_var(&fbi->var, fbi);
551
552         /* Default Y virtual size is 2x panel size */
553         fbi->var.yres_virtual = fbi->var.yres * 2;
554
555         mxcfb_set_fix(fbi);
556
557         /* allocate fb first */
558         if (mxcfb_map_video_memory(fbi) < 0)
559                 return -ENOMEM;
560
561         mxcfb_set_par(fbi);
562
563         panel.winSizeX = mode->xres;
564         panel.winSizeY = mode->yres;
565         panel.plnSizeX = mode->xres;
566         panel.plnSizeY = mode->yres;
567
568         panel.frameAdrs = (u32)fbi->screen_base;
569         panel.memSize = fbi->screen_size;
570
571         panel.gdfBytesPP = 2;
572         panel.gdfIndex = GDF_16BIT_565RGB;
573
574         ipu_dump_registers();
575
576         return 0;
577
578 err0:
579         return ret;
580 }
581
582 void ipuv3_fb_shutdown(void)
583 {
584         int i;
585         struct ipu_stat *stat = (struct ipu_stat *)IPU_STAT;
586
587         if (!ipu_clk_enabled())
588                 return;
589
590         for (i = 0; i < ARRAY_SIZE(mxcfb_info); i++) {
591                 struct fb_info *fbi = mxcfb_info[i];
592                 if (fbi) {
593                         struct mxcfb_info *mxc_fbi = fbi->par;
594                         ipu_disable_channel(mxc_fbi->ipu_ch);
595                         ipu_uninit_channel(mxc_fbi->ipu_ch);
596                 }
597         }
598         for (i = 0; i < ARRAY_SIZE(stat->int_stat); i++) {
599                 __raw_writel(__raw_readl(&stat->int_stat[i]),
600                              &stat->int_stat[i]);
601         }
602 }
603
604 void *video_hw_init(void)
605 {
606         int ret;
607
608         ret = ipu_probe();
609         if (ret)
610                 puts("Error initializing IPU\n");
611
612         ret = mxcfb_probe(gpixfmt, gdisp, gmode);
613         debug("Framebuffer at 0x%x\n", (unsigned int)panel.frameAdrs);
614         gd->fb_base = panel.frameAdrs;
615
616         return (void *)&panel;
617 }
618
619 int ipuv3_fb_init(struct fb_videomode const *mode,
620                   uint8_t disp,
621                   uint32_t pixfmt)
622 {
623         gmode = mode;
624         gdisp = disp;
625         gpixfmt = pixfmt;
626
627         return 0;
628 }
629
630 #if CONFIG_IS_ENABLED(DM_VIDEO)
631 enum {
632         /* Maximum display size we support */
633         LCD_MAX_WIDTH           = 1920,
634         LCD_MAX_HEIGHT          = 1080,
635         LCD_MAX_LOG2_BPP        = VIDEO_BPP16,
636 };
637
638 static int ipuv3_video_probe(struct udevice *dev)
639 {
640         struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
641         struct video_priv *uc_priv = dev_get_uclass_priv(dev);
642 #if defined(CONFIG_DISPLAY)
643         struct udevice *disp_dev;
644 #endif
645         struct udevice *panel_dev;
646         u32 fb_start, fb_end;
647         int ret;
648
649         debug("%s() plat: base 0x%lx, size 0x%x\n",
650               __func__, plat->base, plat->size);
651
652         ret = ipu_probe();
653         if (ret)
654                 return ret;
655
656         ret = ipu_displays_init();
657         if (ret < 0)
658                 return ret;
659
660         ret = mxcfb_probe(gpixfmt, gdisp, gmode);
661         if (ret < 0)
662                 return ret;
663
664 #if defined(CONFIG_DISPLAY)
665         ret = uclass_first_device(UCLASS_DISPLAY, &disp_dev);
666         if (disp_dev) {
667                 ret = display_enable(disp_dev, 16, NULL);
668                 if (ret < 0)
669                         return ret;
670         }
671 #endif
672         ret = uclass_get_device(UCLASS_PANEL, 0, &panel_dev);
673         if (panel_dev)
674                 panel_enable_backlight(panel_dev);
675
676         uc_priv->xsize = gmode->xres;
677         uc_priv->ysize = gmode->yres;
678         uc_priv->bpix = LCD_MAX_LOG2_BPP;
679
680         /* Enable dcache for the frame buffer */
681         fb_start = plat->base & ~(MMU_SECTION_SIZE - 1);
682         fb_end = plat->base + plat->size;
683         fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
684         mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
685                                         DCACHE_WRITEBACK);
686         video_set_flush_dcache(dev, true);
687         gd->fb_base = fb_start;
688
689         return 0;
690 }
691
692 struct ipuv3_video_priv {
693         ulong regs;
694 };
695
696 static int ipuv3_video_bind(struct udevice *dev)
697 {
698         struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
699
700         plat->size = LCD_MAX_WIDTH * LCD_MAX_HEIGHT *
701                      (1 << VIDEO_BPP32) / 8;
702
703         return 0;
704 }
705
706 static const struct udevice_id ipuv3_video_ids[] = {
707         { .compatible = "fsl,imx6q-ipu" },
708         { .compatible = "fsl,imx53-ipu" },
709         { }
710 };
711
712 U_BOOT_DRIVER(ipuv3_video) = {
713         .name   = "ipuv3_video",
714         .id     = UCLASS_VIDEO,
715         .of_match = ipuv3_video_ids,
716         .bind   = ipuv3_video_bind,
717         .probe  = ipuv3_video_probe,
718         .priv_auto_alloc_size = sizeof(struct ipuv3_video_priv),
719         .flags  = DM_FLAG_PRE_RELOC,
720 };
721 #endif /* CONFIG_DM_VIDEO */