Skip to contentSkip to conversation

Convert fsl_dcu_fb to DM_VIDEO

RFC New Igor Opaniuk 3 participants 15 messages Jun 10, 2019 – Jul 29, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Convert fsl_dcu_fb to DM_VIDEO

From: Igor Opaniuk <[email protected]>

This series of patches refactors and extends NXP DCU video driver to be built with DM_VIDEO enabled. DTS files must additionally include 'u-boot,dm-pre-reloc' property in soc and child nodes to enable driver binding to fsl_dcu_fb device.

Current limitations: configuration (display timings etc.) isn't fetched from the DT node. I plan to add this in the next series.

Also enables DM_VIDEO by default for Colibri VF.

Igor Opaniuk (4):
video: fsl_dcu_fb: refactor init functions
video: fsl_dcu_fb: add DM_VIDEO support
ARM: dts: colibri_vf: Add dcu0 node
colibri_vf: enable DM_VIDEO

 arch/arm/dts/vf-colibri-u-boot.dtsi   |   4 +
 arch/arm/dts/vf-colibri.dtsi          |   5 +
 arch/arm/dts/vf.dtsi                  |   6 +
 board/freescale/ls1021aqds/dcu.c      |   6 +-
 board/toradex/colibri_vf/colibri_vf.c |   4 +-
 board/toradex/colibri_vf/dcu.c        |   6 +-
 configs/colibri_vf_defconfig          |   2 +-
 drivers/video/Kconfig                 |   2 +-
 drivers/video/fsl_dcu_fb.c            | 213 ++++++++++++++++++--------
 include/fsl_dcu_fb.h                  |  12 +-
 10 files changed, 187 insertions(+), 73 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

RFC 1/4 video: fsl_dcu_fb: refactor init functions

From: Igor Opaniuk <[email protected]>

Move dcu-related code to fsl_dcu_probe_common, keep in video_hw_init() only legacy video stack (filling GraphicPanel struct etc.).

Add wrappers for all init functions, that will let to provide struct fb_info as an additional param (needed for further moving it from the global scope to driver private data struct in DM converted driver).

---
 board/freescale/ls1021aqds/dcu.c |   6 +-
 board/toradex/colibri_vf/dcu.c   |   6 +-
 drivers/video/fsl_dcu_fb.c       | 107 +++++++++++++++++--------------
 include/fsl_dcu_fb.h             |  12 +++-
 4 files changed, 77 insertions(+), 54 deletions(-)
board/freescale/ls1021aqds/dcu.c +4 -2
index 14855ea1d9..c4eac5e302 100644
@@ -39,7 +39,9 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
 	return div;
 }
 
-int platform_dcu_init(unsigned int xres, unsigned int yres,
+int platform_dcu_init(struct fb_info *fbinfo,
+		      unsigned int xres,
+		      unsigned int yres,
 		      const char *port,
 		      struct fb_videomode *dcu_fb_videomode)
 {
@@ -85,7 +87,7 @@ int platform_dcu_init(unsigned int xres, unsigned int yres,
 	printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
 
 	pixel_format = 32;
-	fsl_dcu_init(xres, yres, pixel_format);
+	fsl_dcu_init(fbinfo, xres, yres, pixel_format);
 
 	return 0;
 }
board/toradex/colibri_vf/dcu.c +4 -2
index c36e90cd22..c688ed79ff 100644
@@ -26,11 +26,13 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
 	return div;
 }
 
-int platform_dcu_init(unsigned int xres, unsigned int yres,
+int platform_dcu_init(struct fb_info *fbinfo,
+		      unsigned int xres,
+		      unsigned int yres,
 		      const char *port,
 		      struct fb_videomode *dcu_fb_videomode)
 {
-	fsl_dcu_init(xres, yres, 32);
+	fsl_dcu_init(fbinfo, xres, yres, 32);
 
 	return 0;
 }
drivers/video/fsl_dcu_fb.c +60 -47

186 lines not on this page · raw message

include/fsl_dcu_fb.h +9 -3
index 2dd5f54c3e..7a5347a924 100644
@@ -6,11 +6,17 @@
  */
 #include <linux/fb.h>
 
-int fsl_dcu_init(unsigned int xres, unsigned int yres,
+int fsl_dcu_init(struct fb_info *fbinfo,
+		 unsigned int xres,
+		 unsigned int yres,
 		 unsigned int pixel_format);
+
 int fsl_dcu_fixedfb_setup(void *blob);
 
 /* Prototypes for external board-specific functions */
-int platform_dcu_init(unsigned int xres, unsigned int yres,
-		      const char *port, struct fb_videomode *dcu_fb_videomode);
+int platform_dcu_init(struct fb_info *fbinfo,
+		      unsigned int xres,
+		      unsigned int yres,
+		      const char *port,
+		      struct fb_videomode *dcu_fb_videomode);
 unsigned int dcu_set_pixel_clock(unsigned int pixclock);
Signature · 1 line
2.17.1
#2 lore raw

RFC 1/4 video: fsl_dcu_fb: refactor init functions

+ Oleksandr, Philippe

Quoted 286 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Move dcu-related code to fsl_dcu_probe_common, keep in video_hw_init() only legacy video stack (filling GraphicPanel struct etc.).

Add wrappers for all init functions, that will let to provide struct fb_info as an additional param (needed for further moving it from the global scope to driver private data struct in DM converted driver).

---
 board/freescale/ls1021aqds/dcu.c |   6 +-
 board/toradex/colibri_vf/dcu.c   |   6 +-
 drivers/video/fsl_dcu_fb.c       | 107 +++++++++++++++++--------------
 include/fsl_dcu_fb.h             |  12 +++-
 4 files changed, 77 insertions(+), 54 deletions(-)
board/freescale/ls1021aqds/dcu.c +4 -2
index 14855ea1d9..c4eac5e302 100644
@@ -39,7 +39,9 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
        return div;
 }
 
-int platform_dcu_init(unsigned int xres, unsigned int yres,
+int platform_dcu_init(struct fb_info *fbinfo,
+                     unsigned int xres,
+                     unsigned int yres,
                      const char *port,
                      struct fb_videomode *dcu_fb_videomode)
 {
@@ -85,7 +87,7 @@ int platform_dcu_init(unsigned int xres, unsigned int yres,
        printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
 
        pixel_format = 32;
-       fsl_dcu_init(xres, yres, pixel_format);
+       fsl_dcu_init(fbinfo, xres, yres, pixel_format);
 
        return 0;
 }
board/toradex/colibri_vf/dcu.c +4 -2
index c36e90cd22..c688ed79ff 100644
@@ -26,11 +26,13 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
        return div;
 }
 
-int platform_dcu_init(unsigned int xres, unsigned int yres,
+int platform_dcu_init(struct fb_info *fbinfo,
+                     unsigned int xres,
+                     unsigned int yres,
                      const char *port,
                      struct fb_videomode *dcu_fb_videomode)
 {
-       fsl_dcu_init(xres, yres, 32);
+       fsl_dcu_init(fbinfo, xres, yres, 32);
 
        return 0;
 }
drivers/video/fsl_dcu_fb.c +60 -47
index 9f6e7f83b0..f789ec597d 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2019 Toradex AG
  *
  * FSL DCU Framebuffer driver
  */
@@ -240,20 +241,22 @@ static void reset_total_layers(void)
        }
 }
 
-static int layer_ctrldesc_init(int index, u32 pixel_format)
+static int layer_ctrldesc_init(struct fb_info fbinfo,
+                              int index, u32 pixel_format)
 {
        struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
        unsigned int bpp = BPP_24_RGB888;
 
        dcu_write32(&regs->ctrldescl[index][0],
-                   DCU_CTRLDESCLN_1_HEIGHT(info.var.yres) |
-                   DCU_CTRLDESCLN_1_WIDTH(info.var.xres));
+                   DCU_CTRLDESCLN_1_HEIGHT(fbinfo.var.yres) |
+                   DCU_CTRLDESCLN_1_WIDTH(fbinfo.var.xres));
 
        dcu_write32(&regs->ctrldescl[index][1],
                    DCU_CTRLDESCLN_2_POSY(0) |
                    DCU_CTRLDESCLN_2_POSX(0));
 
-       dcu_write32(&regs->ctrldescl[index][2], (unsigned int)info.screen_base);
+       dcu_write32(&regs->ctrldescl[index][2],
+                   (unsigned int)fbinfo.screen_base);
 
        switch (pixel_format) {
        case 16:
@@ -294,42 +297,42 @@ static int layer_ctrldesc_init(int index, u32 pixel_format)
        return 0;
 }
 
-int fsl_dcu_init(unsigned int xres, unsigned int yres,
-                unsigned int pixel_format)
+int fsl_dcu_init(struct fb_info *fbinfo, unsigned int xres,
+                unsigned int yres, unsigned int pixel_format)
 {
        struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
        unsigned int div, mode;
 
-       info.screen_size =
-               info.var.xres * info.var.yres * (info.var.bits_per_pixel / 8);
+       fbinfo->screen_size = fbinfo->var.xres * fbinfo->var.yres *
+                            (fbinfo->var.bits_per_pixel / 8);
 
-       if (info.screen_size > CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB) {
-               info.screen_size = 0;
+       if (fbinfo->screen_size > CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB) {
+               fbinfo->screen_size = 0;
                return -ENOMEM;
        }
 
        /* Reserve framebuffer at the end of memory */
        gd->fb_base = gd->bd->bi_dram[0].start +
-                       gd->bd->bi_dram[0].size - info.screen_size;
-       info.screen_base = (char *)gd->fb_base;
+                       gd->bd->bi_dram[0].size - fbinfo->screen_size;
+       fbinfo->screen_base = (char *)gd->fb_base;
 
-       memset(info.screen_base, 0, info.screen_size);
+       memset(fbinfo->screen_base, 0, fbinfo->screen_size);
 
        reset_total_layers();
 
        dcu_write32(&regs->disp_size,
-                   DCU_DISP_SIZE_DELTA_Y(info.var.yres) |
-                   DCU_DISP_SIZE_DELTA_X(info.var.xres / 16));
+                   DCU_DISP_SIZE_DELTA_Y(fbinfo->var.yres) |
+                   DCU_DISP_SIZE_DELTA_X(fbinfo->var.xres / 16));
 
        dcu_write32(&regs->hsyn_para,
-                   DCU_HSYN_PARA_BP(info.var.left_margin) |
-                   DCU_HSYN_PARA_PW(info.var.hsync_len) |
-                   DCU_HSYN_PARA_FP(info.var.right_margin));
+                   DCU_HSYN_PARA_BP(fbinfo->var.left_margin) |
+                   DCU_HSYN_PARA_PW(fbinfo->var.hsync_len) |
+                   DCU_HSYN_PARA_FP(fbinfo->var.right_margin));
 
        dcu_write32(&regs->vsyn_para,
-                   DCU_VSYN_PARA_BP(info.var.upper_margin) |
-                   DCU_VSYN_PARA_PW(info.var.vsync_len) |
-                   DCU_VSYN_PARA_FP(info.var.lower_margin));
+                   DCU_VSYN_PARA_BP(fbinfo->var.upper_margin) |
+                   DCU_VSYN_PARA_PW(fbinfo->var.vsync_len) |
+                   DCU_VSYN_PARA_FP(fbinfo->var.lower_margin));
 
        dcu_write32(&regs->synpol,
                    DCU_SYN_POL_INV_PXCK_FALL |
@@ -352,9 +355,9 @@ int fsl_dcu_init(unsigned int xres, unsigned int yres,
        mode = dcu_read32(&regs->mode);
        dcu_write32(&regs->mode, mode | DCU_MODE_NORMAL);
 
-       layer_ctrldesc_init(0, pixel_format);
+       layer_ctrldesc_init(*fbinfo, 0, pixel_format);
 
-       div = dcu_set_pixel_clock(info.var.pixclock);
+       div = dcu_set_pixel_clock(fbinfo->var.pixclock);
        dcu_write32(&regs->div_ratio, (div - 1));
 
        dcu_write32(&regs->update_mode, DCU_UPDATE_MODE_READREG);
@@ -367,24 +370,26 @@ ulong board_get_usable_ram_top(ulong total_size)
        return gd->ram_top - CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB;
 }
 
-void *video_hw_init(void)
+int fsl_probe_common(struct fb_info *fbinfo, unsigned int *win_x,
+                    unsigned int *win_y)
 {
-       static GraphicDevice ctfb;
        const char *options;
        unsigned int depth = 0, freq = 0;
+
        struct fb_videomode *fsl_dcu_mode_db = &fsl_dcu_mode_480_272;
 
-       if (!video_get_video_mode(&ctfb.winSizeX, &ctfb.winSizeY, &depth, &freq,
+       if (!video_get_video_mode(win_x, win_y, &depth, &freq,
                                  &options))
-               return NULL;
+               return -EINVAL;
 
        /* Find the monitor port, which is a required option */
        if (!options)
-               return NULL;
+               return -EINVAL;
+
        if (strncmp(options, "monitor=", 8) != 0)
-               return NULL;
+               return -EINVAL;
 
-       switch (RESOLUTION(ctfb.winSizeX, ctfb.winSizeY)) {
+       switch (RESOLUTION(*win_x, *win_y)) {
        case RESOLUTION(480, 272):
                fsl_dcu_mode_db = &fsl_dcu_mode_480_272;
                break;
@@ -402,25 +407,33 @@ void *video_hw_init(void)
                break;
        default:
                printf("unsupported resolution %ux%u\n",
-                      ctfb.winSizeX, ctfb.winSizeY);
+                      *win_x, *win_y);
        }
 
-       info.var.xres = fsl_dcu_mode_db->xres;
-       info.var.yres = fsl_dcu_mode_db->yres;
-       info.var.bits_per_pixel = 32;
-       info.var.pixclock = fsl_dcu_mode_db->pixclock;
-       info.var.left_margin = fsl_dcu_mode_db->left_margin;
-       info.var.right_margin = fsl_dcu_mode_db->right_margin;
-       info.var.upper_margin = fsl_dcu_mode_db->upper_margin;
-       info.var.lower_margin = fsl_dcu_mode_db->lower_margin;
-       info.var.hsync_len = fsl_dcu_mode_db->hsync_len;
-       info.var.vsync_len = fsl_dcu_mode_db->vsync_len;
-       info.var.sync = fsl_dcu_mode_db->sync;
-       info.var.vmode = fsl_dcu_mode_db->vmode;
-       info.fix.line_length = info.var.xres * info.var.bits_per_pixel / 8;
-
-       if (platform_dcu_init(ctfb.winSizeX, ctfb.winSizeY,
-                             options + 8, fsl_dcu_mode_db) < 0)
+       fbinfo->var.xres = fsl_dcu_mode_db->xres;
+       fbinfo->var.yres = fsl_dcu_mode_db->yres;
+       fbinfo->var.bits_per_pixel = 32;
+       fbinfo->var.pixclock = fsl_dcu_mode_db->pixclock;
+       fbinfo->var.left_margin = fsl_dcu_mode_db->left_margin;
+       fbinfo->var.right_margin = fsl_dcu_mode_db->right_margin;
+       fbinfo->var.upper_margin = fsl_dcu_mode_db->upper_margin;
+       fbinfo->var.lower_margin = fsl_dcu_mode_db->lower_margin;
+       fbinfo->var.hsync_len = fsl_dcu_mode_db->hsync_len;
+       fbinfo->var.vsync_len = fsl_dcu_mode_db->vsync_len;
+       fbinfo->var.sync = fsl_dcu_mode_db->sync;
+       fbinfo->var.vmode = fsl_dcu_mode_db->vmode;
+       fbinfo->fix.line_length = fbinfo->var.xres *
+                                 fbinfo->var.bits_per_pixel / 8;
+
+       return platform_dcu_init(fbinfo, *win_x, *win_y,
+                                options + 8, fsl_dcu_mode_db);
+}
+
+void *video_hw_init(void)
+{
+       static GraphicDevice ctfb;
+
+       if (fsl_probe_common(&info, &ctfb.winSizeX, &ctfb.winSizeY) < 0)
                return NULL;
 
        ctfb.frameAdrs = (unsigned int)info.screen_base;
include/fsl_dcu_fb.h +9 -4
index 2dd5f54c3e..7a5347a924 100644
@@ -6,11 +6,17 @@
  */
 #include <linux/fb.h>
 
-int fsl_dcu_init(unsigned int xres, unsigned int yres,
+int fsl_dcu_init(struct fb_info *fbinfo,
+                unsigned int xres,
+                unsigned int yres,
                 unsigned int pixel_format);
+
 int fsl_dcu_fixedfb_setup(void *blob);
 
 /* Prototypes for external board-specific functions */
-int platform_dcu_init(unsigned int xres, unsigned int yres,
-                     const char *port, struct fb_videomode *dcu_fb_videomode);
+int platform_dcu_init(struct fb_info *fbinfo,
+                     unsigned int xres,
+                     unsigned int yres,
+                     const char *port,
+                     struct fb_videomode *dcu_fb_videomode);
 unsigned int dcu_set_pixel_clock(unsigned int pixclock);
--

2.17.1

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#3 lore raw

RFC 1/4 video: fsl_dcu_fb: refactor init functions

Quoted 15 lines · Igor Opaniuk

+ Oleksandr, Philippe

Quoted 11 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Move dcu-related code to fsl_dcu_probe_common, keep in video_hw_init() only legacy video stack (filling GraphicPanel struct etc.).

Add wrappers for all init functions, that will let to provide struct fb_info as an additional param (needed for further moving it from the global scope to driver private data struct in DM converted driver).

Quoted 290 lines
Quoted 273 lines
---
 board/freescale/ls1021aqds/dcu.c |   6 +-
 board/toradex/colibri_vf/dcu.c   |   6 +-
 drivers/video/fsl_dcu_fb.c       | 107 +++++++++++++++++--------------
 include/fsl_dcu_fb.h             |  12 +++-
 4 files changed, 77 insertions(+), 54 deletions(-)
board/freescale/ls1021aqds/dcu.c +4 -2
index 14855ea1d9..c4eac5e302 100644
@@ -39,7 +39,9 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
        return div;
 }
 
-int platform_dcu_init(unsigned int xres, unsigned int yres,
+int platform_dcu_init(struct fb_info *fbinfo,
+                     unsigned int xres,
+                     unsigned int yres,
                      const char *port,
                      struct fb_videomode *dcu_fb_videomode)
 {
@@ -85,7 +87,7 @@ int platform_dcu_init(unsigned int xres, unsigned int yres,
        printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
 
        pixel_format = 32;
-       fsl_dcu_init(xres, yres, pixel_format);
+       fsl_dcu_init(fbinfo, xres, yres, pixel_format);
 
        return 0;
 }
board/toradex/colibri_vf/dcu.c +4 -2
index c36e90cd22..c688ed79ff 100644
@@ -26,11 +26,13 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
        return div;
 }
 
-int platform_dcu_init(unsigned int xres, unsigned int yres,
+int platform_dcu_init(struct fb_info *fbinfo,
+                     unsigned int xres,
+                     unsigned int yres,
                      const char *port,
                      struct fb_videomode *dcu_fb_videomode)
 {
-       fsl_dcu_init(xres, yres, 32);
+       fsl_dcu_init(fbinfo, xres, yres, 32);
 
        return 0;
 }
drivers/video/fsl_dcu_fb.c +60 -47
index 9f6e7f83b0..f789ec597d 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2019 Toradex AG
  *
  * FSL DCU Framebuffer driver
  */
@@ -240,20 +241,22 @@ static void reset_total_layers(void)
        }
 }
 
-static int layer_ctrldesc_init(int index, u32 pixel_format)
+static int layer_ctrldesc_init(struct fb_info fbinfo,
+                              int index, u32 pixel_format)
 {
        struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
        unsigned int bpp = BPP_24_RGB888;
 
        dcu_write32(&regs->ctrldescl[index][0],
-                   DCU_CTRLDESCLN_1_HEIGHT(info.var.yres) |
-                   DCU_CTRLDESCLN_1_WIDTH(info.var.xres));
+                   DCU_CTRLDESCLN_1_HEIGHT(fbinfo.var.yres) |
+                   DCU_CTRLDESCLN_1_WIDTH(fbinfo.var.xres));
 
        dcu_write32(&regs->ctrldescl[index][1],
                    DCU_CTRLDESCLN_2_POSY(0) |
                    DCU_CTRLDESCLN_2_POSX(0));
 
-       dcu_write32(&regs->ctrldescl[index][2], (unsigned int)info.screen_base);
+       dcu_write32(&regs->ctrldescl[index][2],
+                   (unsigned int)fbinfo.screen_base);
 
        switch (pixel_format) {
        case 16:
@@ -294,42 +297,42 @@ static int layer_ctrldesc_init(int index, u32 pixel_format)
        return 0;
 }
 
-int fsl_dcu_init(unsigned int xres, unsigned int yres,
-                unsigned int pixel_format)
+int fsl_dcu_init(struct fb_info *fbinfo, unsigned int xres,
+                unsigned int yres, unsigned int pixel_format)
 {
        struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
        unsigned int div, mode;
 
-       info.screen_size =
-               info.var.xres * info.var.yres * (info.var.bits_per_pixel / 8);
+       fbinfo->screen_size = fbinfo->var.xres * fbinfo->var.yres *
+                            (fbinfo->var.bits_per_pixel / 8);
 
-       if (info.screen_size > CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB) {
-               info.screen_size = 0;
+       if (fbinfo->screen_size > CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB) {
+               fbinfo->screen_size = 0;
                return -ENOMEM;
        }
 
        /* Reserve framebuffer at the end of memory */
        gd->fb_base = gd->bd->bi_dram[0].start +
-                       gd->bd->bi_dram[0].size - info.screen_size;
-       info.screen_base = (char *)gd->fb_base;
+                       gd->bd->bi_dram[0].size - fbinfo->screen_size;
+       fbinfo->screen_base = (char *)gd->fb_base;
 
-       memset(info.screen_base, 0, info.screen_size);
+       memset(fbinfo->screen_base, 0, fbinfo->screen_size);
 
        reset_total_layers();
 
        dcu_write32(&regs->disp_size,
-                   DCU_DISP_SIZE_DELTA_Y(info.var.yres) |
-                   DCU_DISP_SIZE_DELTA_X(info.var.xres / 16));
+                   DCU_DISP_SIZE_DELTA_Y(fbinfo->var.yres) |
+                   DCU_DISP_SIZE_DELTA_X(fbinfo->var.xres / 16));
 
        dcu_write32(&regs->hsyn_para,
-                   DCU_HSYN_PARA_BP(info.var.left_margin) |
-                   DCU_HSYN_PARA_PW(info.var.hsync_len) |
-                   DCU_HSYN_PARA_FP(info.var.right_margin));
+                   DCU_HSYN_PARA_BP(fbinfo->var.left_margin) |
+                   DCU_HSYN_PARA_PW(fbinfo->var.hsync_len) |
+                   DCU_HSYN_PARA_FP(fbinfo->var.right_margin));
 
        dcu_write32(&regs->vsyn_para,
-                   DCU_VSYN_PARA_BP(info.var.upper_margin) |
-                   DCU_VSYN_PARA_PW(info.var.vsync_len) |
-                   DCU_VSYN_PARA_FP(info.var.lower_margin));
+                   DCU_VSYN_PARA_BP(fbinfo->var.upper_margin) |
+                   DCU_VSYN_PARA_PW(fbinfo->var.vsync_len) |
+                   DCU_VSYN_PARA_FP(fbinfo->var.lower_margin));
 
        dcu_write32(&regs->synpol,
                    DCU_SYN_POL_INV_PXCK_FALL |
@@ -352,9 +355,9 @@ int fsl_dcu_init(unsigned int xres, unsigned int yres,
        mode = dcu_read32(&regs->mode);
        dcu_write32(&regs->mode, mode | DCU_MODE_NORMAL);
 
-       layer_ctrldesc_init(0, pixel_format);
+       layer_ctrldesc_init(*fbinfo, 0, pixel_format);
 
-       div = dcu_set_pixel_clock(info.var.pixclock);
+       div = dcu_set_pixel_clock(fbinfo->var.pixclock);
        dcu_write32(&regs->div_ratio, (div - 1));
 
        dcu_write32(&regs->update_mode, DCU_UPDATE_MODE_READREG);
@@ -367,24 +370,26 @@ ulong board_get_usable_ram_top(ulong total_size)
        return gd->ram_top - CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB;
 }
 
-void *video_hw_init(void)
+int fsl_probe_common(struct fb_info *fbinfo, unsigned int *win_x,
+                    unsigned int *win_y)
 {
-       static GraphicDevice ctfb;
        const char *options;
        unsigned int depth = 0, freq = 0;
+
        struct fb_videomode *fsl_dcu_mode_db = &fsl_dcu_mode_480_272;
 
-       if (!video_get_video_mode(&ctfb.winSizeX, &ctfb.winSizeY, &depth, &freq,
+       if (!video_get_video_mode(win_x, win_y, &depth, &freq,
                                  &options))
-               return NULL;
+               return -EINVAL;
 
        /* Find the monitor port, which is a required option */
        if (!options)
-               return NULL;
+               return -EINVAL;
+
        if (strncmp(options, "monitor=", 8) != 0)
-               return NULL;
+               return -EINVAL;
 
-       switch (RESOLUTION(ctfb.winSizeX, ctfb.winSizeY)) {
+       switch (RESOLUTION(*win_x, *win_y)) {
        case RESOLUTION(480, 272):
                fsl_dcu_mode_db = &fsl_dcu_mode_480_272;
                break;
@@ -402,25 +407,33 @@ void *video_hw_init(void)
                break;
        default:
                printf("unsupported resolution %ux%u\n",
-                      ctfb.winSizeX, ctfb.winSizeY);
+                      *win_x, *win_y);
        }
 
-       info.var.xres = fsl_dcu_mode_db->xres;
-       info.var.yres = fsl_dcu_mode_db->yres;
-       info.var.bits_per_pixel = 32;
-       info.var.pixclock = fsl_dcu_mode_db->pixclock;
-       info.var.left_margin = fsl_dcu_mode_db->left_margin;
-       info.var.right_margin = fsl_dcu_mode_db->right_margin;
-       info.var.upper_margin = fsl_dcu_mode_db->upper_margin;
-       info.var.lower_margin = fsl_dcu_mode_db->lower_margin;
-       info.var.hsync_len = fsl_dcu_mode_db->hsync_len;
-       info.var.vsync_len = fsl_dcu_mode_db->vsync_len;
-       info.var.sync = fsl_dcu_mode_db->sync;
-       info.var.vmode = fsl_dcu_mode_db->vmode;
-       info.fix.line_length = info.var.xres * info.var.bits_per_pixel / 8;
-
-       if (platform_dcu_init(ctfb.winSizeX, ctfb.winSizeY,
-                             options + 8, fsl_dcu_mode_db) < 0)
+       fbinfo->var.xres = fsl_dcu_mode_db->xres;
+       fbinfo->var.yres = fsl_dcu_mode_db->yres;
+       fbinfo->var.bits_per_pixel = 32;
+       fbinfo->var.pixclock = fsl_dcu_mode_db->pixclock;
+       fbinfo->var.left_margin = fsl_dcu_mode_db->left_margin;
+       fbinfo->var.right_margin = fsl_dcu_mode_db->right_margin;
+       fbinfo->var.upper_margin = fsl_dcu_mode_db->upper_margin;
+       fbinfo->var.lower_margin = fsl_dcu_mode_db->lower_margin;
+       fbinfo->var.hsync_len = fsl_dcu_mode_db->hsync_len;
+       fbinfo->var.vsync_len = fsl_dcu_mode_db->vsync_len;
+       fbinfo->var.sync = fsl_dcu_mode_db->sync;
+       fbinfo->var.vmode = fsl_dcu_mode_db->vmode;
+       fbinfo->fix.line_length = fbinfo->var.xres *
+                                 fbinfo->var.bits_per_pixel / 8;
+
+       return platform_dcu_init(fbinfo, *win_x, *win_y,
+                                options + 8, fsl_dcu_mode_db);
+}
+
+void *video_hw_init(void)
+{
+       static GraphicDevice ctfb;
+
+       if (fsl_probe_common(&info, &ctfb.winSizeX, &ctfb.winSizeY) < 0)
                return NULL;
 
        ctfb.frameAdrs = (unsigned int)info.screen_base;
include/fsl_dcu_fb.h +9 -4
index 2dd5f54c3e..7a5347a924 100644
@@ -6,11 +6,17 @@
  */
 #include <linux/fb.h>
 
-int fsl_dcu_init(unsigned int xres, unsigned int yres,
+int fsl_dcu_init(struct fb_info *fbinfo,
+                unsigned int xres,
+                unsigned int yres,
                 unsigned int pixel_format);
+
 int fsl_dcu_fixedfb_setup(void *blob);
 
 /* Prototypes for external board-specific functions */
-int platform_dcu_init(unsigned int xres, unsigned int yres,
-                     const char *port, struct fb_videomode *dcu_fb_videomode);
+int platform_dcu_init(struct fb_info *fbinfo,
+                     unsigned int xres,
+                     unsigned int yres,
+                     const char *port,
+                     struct fb_videomode *dcu_fb_videomode);
 unsigned int dcu_set_pixel_clock(unsigned int pixclock);
--
Quoted 2 lines

2.17.1

--
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Signature · 6 lines
Best regards
Oleksandr Suvorov

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
4800 (main line)
#4 lore raw

RFC 2/4 video: fsl_dcu_fb: add DM_VIDEO support

In reply to Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Extend the driver to build with DM_VIDEO enabled. DTS files must additionally include 'u-boot,dm-pre-reloc' property in soc and child nodes to enable driver binding to fsl_dcu_fb device.

Currently display timings aren't obtained from DT.

---
 board/toradex/colibri_vf/colibri_vf.c |   4 +-
 drivers/video/Kconfig                 |   2 +-
 drivers/video/fsl_dcu_fb.c            | 112 +++++++++++++++++++++-----
 3 files changed, 97 insertions(+), 21 deletions(-)
board/toradex/colibri_vf/colibri_vf.c +3 -1
index 9d63fbf3bd..dad754b31f 100644
@@ -430,7 +430,9 @@ int checkboard(void)
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, bd_t *bd)
 {
+#ifndef CONFIG_DM_VIDEO
 	int ret = 0;
+#endif
 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
 	static const struct node_info nodes[] = {
 		{ "fsl,vf610-nfc", MTD_DEV_TYPE_NAND, }, /* NAND flash */
@@ -440,7 +442,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 	puts("   Updating MTD partitions...\n");
 	fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
 #endif
-#ifdef CONFIG_VIDEO_FSL_DCU_FB
+#if defined(CONFIG_VIDEO_FSL_DCU_FB) && !defined(CONFIG_DM_VIDEO)
 	ret = fsl_dcu_fixedfb_setup(blob);
 	if (ret)
 		return ret;
drivers/video/Kconfig +1 -1
index c3781b160d..261fa98517 100644
@@ -484,7 +484,7 @@ config VIDEO_IVYBRIDGE_IGD
 
 config VIDEO_FSL_DCU_FB
 	bool "Enable Freescale Display Control Unit"
-	depends on VIDEO
+	depends on VIDEO || DM_VIDEO
 	help
 	 This enables support for Freescale Display Control Unit (DCU4)
 	 module found on Freescale Vybrid and QorIQ family of SoCs.
drivers/video/fsl_dcu_fb.c +93 -19

162 lines not on this page · raw message

Signature · 1 line
2.17.1
#5 lore raw

RFC 2/4 video: fsl_dcu_fb: add DM_VIDEO support

+ Oleksandr, Philippe

Quoted 227 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Extend the driver to build with DM_VIDEO enabled. DTS files must additionally include 'u-boot,dm-pre-reloc' property in soc and child nodes to enable driver binding to fsl_dcu_fb device.

Currently display timings aren't obtained from DT.

---
 board/toradex/colibri_vf/colibri_vf.c |   4 +-
 drivers/video/Kconfig                 |   2 +-
 drivers/video/fsl_dcu_fb.c            | 112 +++++++++++++++++++++-----
 3 files changed, 97 insertions(+), 21 deletions(-)
board/toradex/colibri_vf/colibri_vf.c +3 -1
index 9d63fbf3bd..dad754b31f 100644
@@ -430,7 +430,9 @@ int checkboard(void)
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, bd_t *bd)
 {
+#ifndef CONFIG_DM_VIDEO
        int ret = 0;
+#endif
 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
        static const struct node_info nodes[] = {
                { "fsl,vf610-nfc", MTD_DEV_TYPE_NAND, }, /* NAND flash */
@@ -440,7 +442,7 @@ int ft_board_setup(void *blob, bd_t *bd)
        puts("   Updating MTD partitions...\n");
        fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
 #endif
-#ifdef CONFIG_VIDEO_FSL_DCU_FB
+#if defined(CONFIG_VIDEO_FSL_DCU_FB) && !defined(CONFIG_DM_VIDEO)
        ret = fsl_dcu_fixedfb_setup(blob);
        if (ret)
                return ret;
drivers/video/Kconfig +1 -1
index c3781b160d..261fa98517 100644
@@ -484,7 +484,7 @@ config VIDEO_IVYBRIDGE_IGD
 
 config VIDEO_FSL_DCU_FB
        bool "Enable Freescale Display Control Unit"
-       depends on VIDEO
+       depends on VIDEO || DM_VIDEO
        help
         This enables support for Freescale Display Control Unit (DCU4)
         module found on Freescale Vybrid and QorIQ family of SoCs.
drivers/video/fsl_dcu_fb.c +93 -20
index f789ec597d..add64b85b5 100644
@@ -8,10 +8,12 @@
 
 #include <asm/io.h>
 #include <common.h>
+#include <dm.h>
 #include <fdt_support.h>
 #include <fsl_dcu_fb.h>
 #include <linux/fb.h>
 #include <malloc.h>
+#include <video.h>
 #include <video_fb.h>
 #include "videomodes.h"
 
@@ -219,8 +221,6 @@ struct dcu_reg {
        u32 ctrldescl[DCU_LAYER_MAX_NUM][16];
 };
 
-static struct fb_info info;
-
 static void reset_total_layers(void)
 {
        struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
@@ -302,7 +302,11 @@ int fsl_dcu_init(struct fb_info *fbinfo, unsigned int xres,
 {
        struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
        unsigned int div, mode;
-
+/*
+ * When DM_VIDEO is enabled reservation of framebuffer is done
+ * in advance during bind() call.
+ */
+#if !CONFIG_IS_ENABLED(DM_VIDEO)
        fbinfo->screen_size = fbinfo->var.xres * fbinfo->var.yres *
                             (fbinfo->var.bits_per_pixel / 8);
 
@@ -310,13 +314,13 @@ int fsl_dcu_init(struct fb_info *fbinfo, unsigned int xres,
                fbinfo->screen_size = 0;
                return -ENOMEM;
        }
-
        /* Reserve framebuffer at the end of memory */
        gd->fb_base = gd->bd->bi_dram[0].start +
                        gd->bd->bi_dram[0].size - fbinfo->screen_size;
        fbinfo->screen_base = (char *)gd->fb_base;
 
        memset(fbinfo->screen_base, 0, fbinfo->screen_size);
+#endif
 
        reset_total_layers();
 
@@ -429,6 +433,32 @@ int fsl_probe_common(struct fb_info *fbinfo, unsigned int *win_x,
                                 options + 8, fsl_dcu_mode_db);
 }
 
+#ifndef CONFIG_DM_VIDEO
+static struct fb_info info;
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+int fsl_dcu_fixedfb_setup(void *blob)
+{
+       u64 start, size;
+       int ret;
+
+       start = gd->bd->bi_dram[0].start;
+       size = gd->bd->bi_dram[0].size - info.screen_size;
+
+       /*
+        * Align size on section size (1 MiB).
+        */
+       size &= 0xfff00000;
+       ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
+       if (ret) {
+               eprintf("Cannot setup fb: Error reserving memory\n");
+               return ret;
+       }
+
+       return 0;
+}
+#endif
+
 void *video_hw_init(void)
 {
        static GraphicDevice ctfb;
@@ -448,25 +478,69 @@ void *video_hw_init(void)
        return &ctfb;
 }
 
-#if defined(CONFIG_OF_BOARD_SETUP)
-int fsl_dcu_fixedfb_setup(void *blob)
+#else /* ifndef CONFIG_DM_VIDEO */
+
+static int fsl_dcu_video_probe(struct udevice *dev)
 {
-       u64 start, size;
-       int ret;
+       struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+       struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+       struct fb_info fbinfo = { 0 };
+       unsigned int win_x;
+       unsigned int win_y;
+       u32 fb_start, fb_end;
+       int ret = 0;
+
+       fb_start = plat->base & ~(MMU_SECTION_SIZE - 1);
+       fb_end = plat->base + plat->size;
+       fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
+
+       fbinfo.screen_base = (char *)fb_start;
+       fbinfo.screen_size = plat->size;
+
+       ret = fsl_probe_common(&fbinfo, &win_x, &win_y);
+       if (ret < 0)
+               return ret;
 
-       start = gd->bd->bi_dram[0].start;
-       size = gd->bd->bi_dram[0].size - info.screen_size;
+       uc_priv->bpix = VIDEO_BPP32;
+       uc_priv->xsize = win_x;
+       uc_priv->ysize = win_y;
 
-       /*
-        * Align size on section size (1 MiB).
-        */
-       size &= 0xfff00000;
-       ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
-       if (ret) {
-               eprintf("Cannot setup fb: Error reserving memory\n");
+       /* Enable dcache for the frame buffer */
+       mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
+                                       DCACHE_WRITEBACK);
+       video_set_flush_dcache(dev, true);
+       return ret;
+}
+
+static int fsl_dcu_video_bind(struct udevice *dev)
+{
+       struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+       unsigned int win_x;
+       unsigned int win_y;
+       unsigned int depth = 0, freq = 0;
+       const char *options;
+       int ret = 0;
+
+       ret = video_get_video_mode(&win_x, &win_y, &depth, &freq, &options);
+       if (ret < 0)
                return ret;
-       }
+
+       plat->size = win_x * win_y * 32;
 
        return 0;
 }
-#endif
+
+static const struct udevice_id fsl_dcu_video_ids[] = {
+       { .compatible = "fsl,vf610-dcu" },
+       { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(fsl_dcu_video) = {
+       .name   = "fsl_dcu_video",
+       .id     = UCLASS_VIDEO,
+       .of_match = fsl_dcu_video_ids,
+       .bind   = fsl_dcu_video_bind,
+       .probe  = fsl_dcu_video_probe,
+       .flags  = DM_FLAG_PRE_RELOC,
+};
+#endif /* ifndef CONFIG_DM_VIDEO */
--

2.17.1

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#6 lore raw

RFC 2/4 video: fsl_dcu_fb: add DM_VIDEO support

Quoted 14 lines · Igor Opaniuk

+ Oleksandr, Philippe

Quoted 10 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Extend the driver to build with DM_VIDEO enabled. DTS files must additionally include 'u-boot,dm-pre-reloc' property in soc and child nodes to enable driver binding to fsl_dcu_fb device.

Currently display timings aren't obtained from DT.

Quoted 232 lines
Quoted 215 lines
---
 board/toradex/colibri_vf/colibri_vf.c |   4 +-
 drivers/video/Kconfig                 |   2 +-
 drivers/video/fsl_dcu_fb.c            | 112 +++++++++++++++++++++-----
 3 files changed, 97 insertions(+), 21 deletions(-)
board/toradex/colibri_vf/colibri_vf.c +3 -1
index 9d63fbf3bd..dad754b31f 100644
@@ -430,7 +430,9 @@ int checkboard(void)
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, bd_t *bd)
 {
+#ifndef CONFIG_DM_VIDEO
        int ret = 0;
+#endif
 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
        static const struct node_info nodes[] = {
                { "fsl,vf610-nfc", MTD_DEV_TYPE_NAND, }, /* NAND flash */
@@ -440,7 +442,7 @@ int ft_board_setup(void *blob, bd_t *bd)
        puts("   Updating MTD partitions...\n");
        fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
 #endif
-#ifdef CONFIG_VIDEO_FSL_DCU_FB
+#if defined(CONFIG_VIDEO_FSL_DCU_FB) && !defined(CONFIG_DM_VIDEO)
        ret = fsl_dcu_fixedfb_setup(blob);
        if (ret)
                return ret;
drivers/video/Kconfig +1 -1
index c3781b160d..261fa98517 100644
@@ -484,7 +484,7 @@ config VIDEO_IVYBRIDGE_IGD
 
 config VIDEO_FSL_DCU_FB
        bool "Enable Freescale Display Control Unit"
-       depends on VIDEO
+       depends on VIDEO || DM_VIDEO
        help
         This enables support for Freescale Display Control Unit (DCU4)
         module found on Freescale Vybrid and QorIQ family of SoCs.
drivers/video/fsl_dcu_fb.c +93 -20
index f789ec597d..add64b85b5 100644
@@ -8,10 +8,12 @@
 
 #include <asm/io.h>
 #include <common.h>
+#include <dm.h>
 #include <fdt_support.h>
 #include <fsl_dcu_fb.h>
 #include <linux/fb.h>
 #include <malloc.h>
+#include <video.h>
 #include <video_fb.h>
 #include "videomodes.h"
 
@@ -219,8 +221,6 @@ struct dcu_reg {
        u32 ctrldescl[DCU_LAYER_MAX_NUM][16];
 };
 
-static struct fb_info info;
-
 static void reset_total_layers(void)
 {
        struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
@@ -302,7 +302,11 @@ int fsl_dcu_init(struct fb_info *fbinfo, unsigned int xres,
 {
        struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
        unsigned int div, mode;
-
+/*
+ * When DM_VIDEO is enabled reservation of framebuffer is done
+ * in advance during bind() call.
+ */
+#if !CONFIG_IS_ENABLED(DM_VIDEO)
        fbinfo->screen_size = fbinfo->var.xres * fbinfo->var.yres *
                             (fbinfo->var.bits_per_pixel / 8);
 
@@ -310,13 +314,13 @@ int fsl_dcu_init(struct fb_info *fbinfo, unsigned int xres,
                fbinfo->screen_size = 0;
                return -ENOMEM;
        }
-
        /* Reserve framebuffer at the end of memory */
        gd->fb_base = gd->bd->bi_dram[0].start +
                        gd->bd->bi_dram[0].size - fbinfo->screen_size;
        fbinfo->screen_base = (char *)gd->fb_base;
 
        memset(fbinfo->screen_base, 0, fbinfo->screen_size);
+#endif
 
        reset_total_layers();
 
@@ -429,6 +433,32 @@ int fsl_probe_common(struct fb_info *fbinfo, unsigned int *win_x,
                                 options + 8, fsl_dcu_mode_db);
 }
 
+#ifndef CONFIG_DM_VIDEO
+static struct fb_info info;
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+int fsl_dcu_fixedfb_setup(void *blob)
+{
+       u64 start, size;
+       int ret;
+
+       start = gd->bd->bi_dram[0].start;
+       size = gd->bd->bi_dram[0].size - info.screen_size;
+
+       /*
+        * Align size on section size (1 MiB).
+        */
+       size &= 0xfff00000;
+       ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
+       if (ret) {
+               eprintf("Cannot setup fb: Error reserving memory\n");
+               return ret;
+       }
+
+       return 0;
+}
+#endif
+
 void *video_hw_init(void)
 {
        static GraphicDevice ctfb;
@@ -448,25 +478,69 @@ void *video_hw_init(void)
        return &ctfb;
 }
 
-#if defined(CONFIG_OF_BOARD_SETUP)
-int fsl_dcu_fixedfb_setup(void *blob)
+#else /* ifndef CONFIG_DM_VIDEO */
+
+static int fsl_dcu_video_probe(struct udevice *dev)
 {
-       u64 start, size;
-       int ret;
+       struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+       struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+       struct fb_info fbinfo = { 0 };
+       unsigned int win_x;
+       unsigned int win_y;
+       u32 fb_start, fb_end;
+       int ret = 0;
+
+       fb_start = plat->base & ~(MMU_SECTION_SIZE - 1);
+       fb_end = plat->base + plat->size;
+       fb_end = ALIGN(fb_end, 1 << MMU_SECTION_SHIFT);
+
+       fbinfo.screen_base = (char *)fb_start;
+       fbinfo.screen_size = plat->size;
+
+       ret = fsl_probe_common(&fbinfo, &win_x, &win_y);
+       if (ret < 0)
+               return ret;
 
-       start = gd->bd->bi_dram[0].start;
-       size = gd->bd->bi_dram[0].size - info.screen_size;
+       uc_priv->bpix = VIDEO_BPP32;
+       uc_priv->xsize = win_x;
+       uc_priv->ysize = win_y;
 
-       /*
-        * Align size on section size (1 MiB).
-        */
-       size &= 0xfff00000;
-       ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
-       if (ret) {
-               eprintf("Cannot setup fb: Error reserving memory\n");
+       /* Enable dcache for the frame buffer */
+       mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
+                                       DCACHE_WRITEBACK);
+       video_set_flush_dcache(dev, true);
+       return ret;
+}
+
+static int fsl_dcu_video_bind(struct udevice *dev)
+{
+       struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
+       unsigned int win_x;
+       unsigned int win_y;
+       unsigned int depth = 0, freq = 0;
+       const char *options;
+       int ret = 0;
+
+       ret = video_get_video_mode(&win_x, &win_y, &depth, &freq, &options);
+       if (ret < 0)
                return ret;
-       }
+
+       plat->size = win_x * win_y * 32;
 
        return 0;
 }
-#endif
+
+static const struct udevice_id fsl_dcu_video_ids[] = {
+       { .compatible = "fsl,vf610-dcu" },
+       { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(fsl_dcu_video) = {
+       .name   = "fsl_dcu_video",
+       .id     = UCLASS_VIDEO,
+       .of_match = fsl_dcu_video_ids,
+       .bind   = fsl_dcu_video_bind,
+       .probe  = fsl_dcu_video_probe,
+       .flags  = DM_FLAG_PRE_RELOC,
+};
+#endif /* ifndef CONFIG_DM_VIDEO */
--
Quoted 2 lines

2.17.1

--
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Signature · 6 lines
Best regards
Oleksandr Suvorov

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
4800 (main line)
#7 lore raw

RFC 3/4 ARM: dts: colibri_vf: Add dcu0 node

In reply to Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Add dumb node for NXP Display Control Unit0(DCU), which permits DM_ENABLED converted driver to be probed. Currently no display timings are provided in this node.

---
 arch/arm/dts/vf-colibri-u-boot.dtsi | 4 ++++
 arch/arm/dts/vf-colibri.dtsi        | 5 +++++
 arch/arm/dts/vf.dtsi                | 6 ++++++
 3 files changed, 15 insertions(+)
arch/arm/dts/vf-colibri-u-boot.dtsi +4 -0
index db86739805..2294ee9551 100644
@@ -21,3 +21,7 @@
 &uart0 {
 	u-boot,dm-pre-reloc;
 };
+
+&dcu0 {
+	u-boot,dm-pre-reloc;
+};
arch/arm/dts/vf-colibri.dtsi +5 -0
index 91ca4e4ddd..9de4b28e87 100644
@@ -14,6 +14,7 @@
 
 	aliases {
 		usb0 = &ehci0; /* required for ums */
+		display1 = &dcu0;
 	};
 
 	reg_usbh_vbus: regulator-usbh-vbus {
@@ -241,3 +242,7 @@
 	pinctrl-0 = <&pinctrl_uart0>;
 	status = "okay";
 };
+
+&dcu0 {
+	status = "okay";
+};
arch/arm/dts/vf.dtsi +6 -0
index 5e3b2c5b9d..5f69d0fd6e 100644
@@ -145,6 +145,12 @@
 				#gpio-cells = <2>;
 			};
 
+			dcu0: dcu at 40058000 {
+				compatible = "fsl,vf610-dcu";
+				reg = <0x40058000 0x1200>;
+				status = "disabled";
+			};
+
 			ehci0: ehci at 40034000 {
 				compatible = "fsl,vf610-usb";
 				reg = <0x40034000 0x800>;
Signature · 1 line
2.17.1
#8 lore raw

RFC 3/4 ARM: dts: colibri_vf: Add dcu0 node

+ Oleksandr, Philippe

Quoted 66 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Add dumb node for NXP Display Control Unit0(DCU), which permits DM_ENABLED converted driver to be probed. Currently no display timings are provided in this node.

---
 arch/arm/dts/vf-colibri-u-boot.dtsi | 4 ++++
 arch/arm/dts/vf-colibri.dtsi        | 5 +++++
 arch/arm/dts/vf.dtsi                | 6 ++++++
 3 files changed, 15 insertions(+)
arch/arm/dts/vf-colibri-u-boot.dtsi +4 -0
index db86739805..2294ee9551 100644
@@ -21,3 +21,7 @@
 &uart0 {
        u-boot,dm-pre-reloc;
 };
+
+&dcu0 {
+       u-boot,dm-pre-reloc;
+};
arch/arm/dts/vf-colibri.dtsi +5 -0
index 91ca4e4ddd..9de4b28e87 100644
@@ -14,6 +14,7 @@
 
        aliases {
                usb0 = &ehci0; /* required for ums */
+               display1 = &dcu0;
        };
 
        reg_usbh_vbus: regulator-usbh-vbus {
@@ -241,3 +242,7 @@
        pinctrl-0 = <&pinctrl_uart0>;
        status = "okay";
 };
+
+&dcu0 {
+       status = "okay";
+};
arch/arm/dts/vf.dtsi +6 -1
index 5e3b2c5b9d..5f69d0fd6e 100644
@@ -145,6 +145,12 @@
                                #gpio-cells = <2>;
                        };
 
+                       dcu0: dcu at 40058000 {
+                               compatible = "fsl,vf610-dcu";
+                               reg = <0x40058000 0x1200>;
+                               status = "disabled";
+                       };
+
                        ehci0: ehci at 40034000 {
                                compatible = "fsl,vf610-usb";
                                reg = <0x40034000 0x800>;
--

2.17.1

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#9 lore raw

RFC 3/4 ARM: dts: colibri_vf: Add dcu0 node

Quoted 12 lines · Igor Opaniuk

+ Oleksandr, Philippe

Quoted 8 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Add dumb node for NXP Display Control Unit0(DCU), which permits DM_ENABLED converted driver to be probed. Currently no display timings are provided in this node.

Quoted 73 lines
Quoted 56 lines
---
 arch/arm/dts/vf-colibri-u-boot.dtsi | 4 ++++
 arch/arm/dts/vf-colibri.dtsi        | 5 +++++
 arch/arm/dts/vf.dtsi                | 6 ++++++
 3 files changed, 15 insertions(+)
arch/arm/dts/vf-colibri-u-boot.dtsi +4 -0
index db86739805..2294ee9551 100644
@@ -21,3 +21,7 @@
 &uart0 {
        u-boot,dm-pre-reloc;
 };
+
+&dcu0 {
+       u-boot,dm-pre-reloc;
+};
arch/arm/dts/vf-colibri.dtsi +5 -0
index 91ca4e4ddd..9de4b28e87 100644
@@ -14,6 +14,7 @@
 
        aliases {
                usb0 = &ehci0; /* required for ums */
+               display1 = &dcu0;
        };
 
        reg_usbh_vbus: regulator-usbh-vbus {
@@ -241,3 +242,7 @@
        pinctrl-0 = <&pinctrl_uart0>;
        status = "okay";
 };
+
+&dcu0 {
+       status = "okay";
+};
arch/arm/dts/vf.dtsi +6 -1
index 5e3b2c5b9d..5f69d0fd6e 100644
@@ -145,6 +145,12 @@
                                #gpio-cells = <2>;
                        };
 
+                       dcu0: dcu at 40058000 {
+                               compatible = "fsl,vf610-dcu";
+                               reg = <0x40058000 0x1200>;
+                               status = "disabled";
+                       };
+
                        ehci0: ehci at 40034000 {
                                compatible = "fsl,vf610-usb";
                                reg = <0x40034000 0x800>;
--
Quoted 2 lines

2.17.1

--
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Signature · 6 lines
Best regards
Oleksandr Suvorov

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
4800 (main line)
#10 lore raw

RFC 4/4 colibri_vf: enable DM_VIDEO

In reply to Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Enable DM_VIDEO for Colibri VF.

---
 configs/colibri_vf_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/colibri_vf_defconfig +1 -1
index 3a267bdbc6..445176aa64 100644
@@ -88,7 +88,7 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x4000
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_VIDEO_FSL_DCU_FB=y
-CONFIG_VIDEO=y
+CONFIG_DM_VIDEO=y
 CONFIG_SYS_CONSOLE_FG_COL=0x00
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_FDT_FIXUP_PARTITIONS=y
Signature · 1 line
2.17.1
#11 lore raw

RFC 4/4 colibri_vf: enable DM_VIDEO

+ Oleksandr, Philippe

Quoted 26 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Enable DM_VIDEO for Colibri VF.

---
 configs/colibri_vf_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/colibri_vf_defconfig +1 -2
index 3a267bdbc6..445176aa64 100644
@@ -88,7 +88,7 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x4000
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_VIDEO_FSL_DCU_FB=y
-CONFIG_VIDEO=y
+CONFIG_DM_VIDEO=y
 CONFIG_SYS_CONSOLE_FG_COL=0x00
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_FDT_FIXUP_PARTITIONS=y
--

2.17.1

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#12 lore raw

RFC 4/4 colibri_vf: enable DM_VIDEO

Quoted 10 lines · Igor Opaniuk

+ Oleksandr, Philippe

Quoted 6 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Enable DM_VIDEO for Colibri VF.

Quoted 35 lines
Quoted 18 lines
---
 configs/colibri_vf_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/colibri_vf_defconfig +1 -2
index 3a267bdbc6..445176aa64 100644
@@ -88,7 +88,7 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x4000
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_VIDEO_FSL_DCU_FB=y
-CONFIG_VIDEO=y
+CONFIG_DM_VIDEO=y
 CONFIG_SYS_CONSOLE_FG_COL=0x00
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_FDT_FIXUP_PARTITIONS=y
--
Quoted 2 lines

2.17.1

--
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Signature · 6 lines
Best regards
Oleksandr Suvorov

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
4800 (main line)
#13 lore raw

cover Convert fsl_dcu_fb to DM_VIDEO

In reply to Igor Opaniuk

+ Oleksandr, Philippe

Quoted 35 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

This series of patches refactors and extends NXP DCU video driver to be built with DM_VIDEO enabled. DTS files must additionally include 'u-boot,dm-pre-reloc' property in soc and child nodes to enable driver binding to fsl_dcu_fb device.

Current limitations: configuration (display timings etc.) isn't fetched from the DT node. I plan to add this in the next series.

Also enables DM_VIDEO by default for Colibri VF.

Igor Opaniuk (4):
video: fsl_dcu_fb: refactor init functions
video: fsl_dcu_fb: add DM_VIDEO support
ARM: dts: colibri_vf: Add dcu0 node
colibri_vf: enable DM_VIDEO

 arch/arm/dts/vf-colibri-u-boot.dtsi   |   4 +
 arch/arm/dts/vf-colibri.dtsi          |   5 +
 arch/arm/dts/vf.dtsi                  |   6 +
 board/freescale/ls1021aqds/dcu.c      |   6 +-
 board/toradex/colibri_vf/colibri_vf.c |   4 +-
 board/toradex/colibri_vf/dcu.c        |   6 +-
 configs/colibri_vf_defconfig          |   2 +-
 drivers/video/Kconfig                 |   2 +-
 drivers/video/fsl_dcu_fb.c            | 213 ++++++++++++++++++--------
 include/fsl_dcu_fb.h                  |  12 +-
 10 files changed, 187 insertions(+), 73 deletions(-)

--
2.17.1

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#14 lore raw

cover Convert fsl_dcu_fb to DM_VIDEO

In reply to Igor Opaniuk

On Mon, 10 Jun 2019 14:47:48 +0300
Igor Opaniuk igor.opaniuk at gmail.com wrote:
...

Quoted 9 lines

Also enables DM_VIDEO by default for Colibri VF.

Igor Opaniuk (4):
video: fsl_dcu_fb: refactor init functions
video: fsl_dcu_fb: add DM_VIDEO support
ARM: dts: colibri_vf: Add dcu0 node
colibri_vf: enable DM_VIDEO

Quoted 11 lines
 arch/arm/dts/vf-colibri-u-boot.dtsi   |   4 +
 arch/arm/dts/vf-colibri.dtsi          |   5 +
 arch/arm/dts/vf.dtsi                  |   6 +
 board/freescale/ls1021aqds/dcu.c      |   6 +-
 board/toradex/colibri_vf/colibri_vf.c |   4 +-
 board/toradex/colibri_vf/dcu.c        |   6 +-
 configs/colibri_vf_defconfig          |   2 +-
 drivers/video/Kconfig                 |   2 +-
 drivers/video/fsl_dcu_fb.c            | 213 ++++++++++++++++++--------
 include/fsl_dcu_fb.h                  |  12 +-
 10 files changed, 187 insertions(+), 73 deletions(-)

Series applied to u-boot-video/master, thanks!
Patch 1/4 replaced by [1].

[1] http://patchwork.ozlabs.org/patch/1136894

--
Anatolij