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