mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 13:56:20 +00:00
video: fsl_dcu_fb: refactor init functions
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). Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com> Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
This commit is contained in:
parent
75551c8bfc
commit
a6eedb670d
6 changed files with 85 additions and 60 deletions
|
@ -23,7 +23,8 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
|
||||||
return div;
|
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,
|
const char *port,
|
||||||
struct fb_videomode *dcu_fb_videomode)
|
struct fb_videomode *dcu_fb_videomode)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +41,7 @@ int platform_dcu_init(unsigned int xres, unsigned int yres,
|
||||||
printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
|
printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
|
||||||
|
|
||||||
pixel_format = 32;
|
pixel_format = 32;
|
||||||
fsl_dcu_init(xres, yres, pixel_format);
|
fsl_dcu_init(fbinfo, xres, yres, pixel_format);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,9 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
|
||||||
return div;
|
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,
|
const char *port,
|
||||||
struct fb_videomode *dcu_fb_videomode)
|
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);
|
printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
|
||||||
|
|
||||||
pixel_format = 32;
|
pixel_format = 32;
|
||||||
fsl_dcu_init(xres, yres, pixel_format);
|
fsl_dcu_init(fbinfo, xres, yres, pixel_format);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
|
||||||
return div;
|
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,
|
const char *port,
|
||||||
struct fb_videomode *dcu_fb_videomode)
|
struct fb_videomode *dcu_fb_videomode)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +41,7 @@ int platform_dcu_init(unsigned int xres, unsigned int yres,
|
||||||
printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
|
printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
|
||||||
|
|
||||||
pixel_format = 32;
|
pixel_format = 32;
|
||||||
fsl_dcu_init(xres, yres, pixel_format);
|
fsl_dcu_init(fbinfo, xres, yres, pixel_format);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,13 @@ unsigned int dcu_set_pixel_clock(unsigned int pixclock)
|
||||||
return div;
|
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,
|
const char *port,
|
||||||
struct fb_videomode *dcu_fb_videomode)
|
struct fb_videomode *dcu_fb_videomode)
|
||||||
{
|
{
|
||||||
fsl_dcu_init(xres, yres, 32);
|
fsl_dcu_init(fbinfo, xres, yres, 32);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0+
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
/*
|
/*
|
||||||
* Copyright 2014 Freescale Semiconductor, Inc.
|
* Copyright 2014 Freescale Semiconductor, Inc.
|
||||||
|
* Copyright 2019 Toradex AG
|
||||||
*
|
*
|
||||||
* FSL DCU Framebuffer driver
|
* 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;
|
struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
|
||||||
unsigned int bpp = BPP_24_RGB888;
|
unsigned int bpp = BPP_24_RGB888;
|
||||||
|
|
||||||
dcu_write32(®s->ctrldescl[index][0],
|
dcu_write32(®s->ctrldescl[index][0],
|
||||||
DCU_CTRLDESCLN_1_HEIGHT(info.var.yres) |
|
DCU_CTRLDESCLN_1_HEIGHT(fbinfo.var.yres) |
|
||||||
DCU_CTRLDESCLN_1_WIDTH(info.var.xres));
|
DCU_CTRLDESCLN_1_WIDTH(fbinfo.var.xres));
|
||||||
|
|
||||||
dcu_write32(®s->ctrldescl[index][1],
|
dcu_write32(®s->ctrldescl[index][1],
|
||||||
DCU_CTRLDESCLN_2_POSY(0) |
|
DCU_CTRLDESCLN_2_POSY(0) |
|
||||||
DCU_CTRLDESCLN_2_POSX(0));
|
DCU_CTRLDESCLN_2_POSX(0));
|
||||||
|
|
||||||
dcu_write32(®s->ctrldescl[index][2], (unsigned int)info.screen_base);
|
dcu_write32(®s->ctrldescl[index][2],
|
||||||
|
(unsigned int)fbinfo.screen_base);
|
||||||
|
|
||||||
switch (pixel_format) {
|
switch (pixel_format) {
|
||||||
case 16:
|
case 16:
|
||||||
|
@ -294,42 +297,42 @@ static int layer_ctrldesc_init(int index, u32 pixel_format)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fsl_dcu_init(unsigned int xres, unsigned int yres,
|
int fsl_dcu_init(struct fb_info *fbinfo, unsigned int xres,
|
||||||
unsigned int pixel_format)
|
unsigned int yres, unsigned int pixel_format)
|
||||||
{
|
{
|
||||||
struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
|
struct dcu_reg *regs = (struct dcu_reg *)CONFIG_SYS_DCU_ADDR;
|
||||||
unsigned int div, mode;
|
unsigned int div, mode;
|
||||||
|
|
||||||
info.screen_size =
|
fbinfo->screen_size = fbinfo->var.xres * fbinfo->var.yres *
|
||||||
info.var.xres * info.var.yres * (info.var.bits_per_pixel / 8);
|
(fbinfo->var.bits_per_pixel / 8);
|
||||||
|
|
||||||
if (info.screen_size > CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB) {
|
if (fbinfo->screen_size > CONFIG_VIDEO_FSL_DCU_MAX_FB_SIZE_MB) {
|
||||||
info.screen_size = 0;
|
fbinfo->screen_size = 0;
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reserve framebuffer at the end of memory */
|
/* Reserve framebuffer at the end of memory */
|
||||||
gd->fb_base = gd->bd->bi_dram[0].start +
|
gd->fb_base = gd->bd->bi_dram[0].start +
|
||||||
gd->bd->bi_dram[0].size - info.screen_size;
|
gd->bd->bi_dram[0].size - fbinfo->screen_size;
|
||||||
info.screen_base = (char *)gd->fb_base;
|
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();
|
reset_total_layers();
|
||||||
|
|
||||||
dcu_write32(®s->disp_size,
|
dcu_write32(®s->disp_size,
|
||||||
DCU_DISP_SIZE_DELTA_Y(info.var.yres) |
|
DCU_DISP_SIZE_DELTA_Y(fbinfo->var.yres) |
|
||||||
DCU_DISP_SIZE_DELTA_X(info.var.xres / 16));
|
DCU_DISP_SIZE_DELTA_X(fbinfo->var.xres / 16));
|
||||||
|
|
||||||
dcu_write32(®s->hsyn_para,
|
dcu_write32(®s->hsyn_para,
|
||||||
DCU_HSYN_PARA_BP(info.var.left_margin) |
|
DCU_HSYN_PARA_BP(fbinfo->var.left_margin) |
|
||||||
DCU_HSYN_PARA_PW(info.var.hsync_len) |
|
DCU_HSYN_PARA_PW(fbinfo->var.hsync_len) |
|
||||||
DCU_HSYN_PARA_FP(info.var.right_margin));
|
DCU_HSYN_PARA_FP(fbinfo->var.right_margin));
|
||||||
|
|
||||||
dcu_write32(®s->vsyn_para,
|
dcu_write32(®s->vsyn_para,
|
||||||
DCU_VSYN_PARA_BP(info.var.upper_margin) |
|
DCU_VSYN_PARA_BP(fbinfo->var.upper_margin) |
|
||||||
DCU_VSYN_PARA_PW(info.var.vsync_len) |
|
DCU_VSYN_PARA_PW(fbinfo->var.vsync_len) |
|
||||||
DCU_VSYN_PARA_FP(info.var.lower_margin));
|
DCU_VSYN_PARA_FP(fbinfo->var.lower_margin));
|
||||||
|
|
||||||
dcu_write32(®s->synpol,
|
dcu_write32(®s->synpol,
|
||||||
DCU_SYN_POL_INV_PXCK_FALL |
|
DCU_SYN_POL_INV_PXCK_FALL |
|
||||||
|
@ -352,9 +355,9 @@ int fsl_dcu_init(unsigned int xres, unsigned int yres,
|
||||||
mode = dcu_read32(®s->mode);
|
mode = dcu_read32(®s->mode);
|
||||||
dcu_write32(®s->mode, mode | DCU_MODE_NORMAL);
|
dcu_write32(®s->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(®s->div_ratio, (div - 1));
|
dcu_write32(®s->div_ratio, (div - 1));
|
||||||
|
|
||||||
dcu_write32(®s->update_mode, DCU_UPDATE_MODE_READREG);
|
dcu_write32(®s->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;
|
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;
|
const char *options;
|
||||||
unsigned int depth = 0, freq = 0;
|
unsigned int depth = 0, freq = 0;
|
||||||
|
|
||||||
struct fb_videomode *fsl_dcu_mode_db = &fsl_dcu_mode_480_272;
|
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))
|
&options))
|
||||||
return NULL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Find the monitor port, which is a required option */
|
/* Find the monitor port, which is a required option */
|
||||||
if (!options)
|
if (!options)
|
||||||
return NULL;
|
return -EINVAL;
|
||||||
if (strncmp(options, "monitor=", 8) != 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
switch (RESOLUTION(ctfb.winSizeX, ctfb.winSizeY)) {
|
if (strncmp(options, "monitor=", 8) != 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
switch (RESOLUTION(*win_x, *win_y)) {
|
||||||
case RESOLUTION(480, 272):
|
case RESOLUTION(480, 272):
|
||||||
fsl_dcu_mode_db = &fsl_dcu_mode_480_272;
|
fsl_dcu_mode_db = &fsl_dcu_mode_480_272;
|
||||||
break;
|
break;
|
||||||
|
@ -402,25 +407,33 @@ void *video_hw_init(void)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("unsupported resolution %ux%u\n",
|
printf("unsupported resolution %ux%u\n",
|
||||||
ctfb.winSizeX, ctfb.winSizeY);
|
*win_x, *win_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
info.var.xres = fsl_dcu_mode_db->xres;
|
fbinfo->var.xres = fsl_dcu_mode_db->xres;
|
||||||
info.var.yres = fsl_dcu_mode_db->yres;
|
fbinfo->var.yres = fsl_dcu_mode_db->yres;
|
||||||
info.var.bits_per_pixel = 32;
|
fbinfo->var.bits_per_pixel = 32;
|
||||||
info.var.pixclock = fsl_dcu_mode_db->pixclock;
|
fbinfo->var.pixclock = fsl_dcu_mode_db->pixclock;
|
||||||
info.var.left_margin = fsl_dcu_mode_db->left_margin;
|
fbinfo->var.left_margin = fsl_dcu_mode_db->left_margin;
|
||||||
info.var.right_margin = fsl_dcu_mode_db->right_margin;
|
fbinfo->var.right_margin = fsl_dcu_mode_db->right_margin;
|
||||||
info.var.upper_margin = fsl_dcu_mode_db->upper_margin;
|
fbinfo->var.upper_margin = fsl_dcu_mode_db->upper_margin;
|
||||||
info.var.lower_margin = fsl_dcu_mode_db->lower_margin;
|
fbinfo->var.lower_margin = fsl_dcu_mode_db->lower_margin;
|
||||||
info.var.hsync_len = fsl_dcu_mode_db->hsync_len;
|
fbinfo->var.hsync_len = fsl_dcu_mode_db->hsync_len;
|
||||||
info.var.vsync_len = fsl_dcu_mode_db->vsync_len;
|
fbinfo->var.vsync_len = fsl_dcu_mode_db->vsync_len;
|
||||||
info.var.sync = fsl_dcu_mode_db->sync;
|
fbinfo->var.sync = fsl_dcu_mode_db->sync;
|
||||||
info.var.vmode = fsl_dcu_mode_db->vmode;
|
fbinfo->var.vmode = fsl_dcu_mode_db->vmode;
|
||||||
info.fix.line_length = info.var.xres * info.var.bits_per_pixel / 8;
|
fbinfo->fix.line_length = fbinfo->var.xres *
|
||||||
|
fbinfo->var.bits_per_pixel / 8;
|
||||||
|
|
||||||
if (platform_dcu_init(ctfb.winSizeX, ctfb.winSizeY,
|
return platform_dcu_init(fbinfo, *win_x, *win_y,
|
||||||
options + 8, fsl_dcu_mode_db) < 0)
|
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;
|
return NULL;
|
||||||
|
|
||||||
ctfb.frameAdrs = (unsigned int)info.screen_base;
|
ctfb.frameAdrs = (unsigned int)info.screen_base;
|
||||||
|
|
|
@ -6,11 +6,17 @@
|
||||||
*/
|
*/
|
||||||
#include <linux/fb.h>
|
#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);
|
unsigned int pixel_format);
|
||||||
|
|
||||||
int fsl_dcu_fixedfb_setup(void *blob);
|
int fsl_dcu_fixedfb_setup(void *blob);
|
||||||
|
|
||||||
/* Prototypes for external board-specific functions */
|
/* Prototypes for external board-specific functions */
|
||||||
int platform_dcu_init(unsigned int xres, unsigned int yres,
|
int platform_dcu_init(struct fb_info *fbinfo,
|
||||||
const char *port, struct fb_videomode *dcu_fb_videomode);
|
unsigned int xres,
|
||||||
|
unsigned int yres,
|
||||||
|
const char *port,
|
||||||
|
struct fb_videomode *dcu_fb_videomode);
|
||||||
unsigned int dcu_set_pixel_clock(unsigned int pixclock);
|
unsigned int dcu_set_pixel_clock(unsigned int pixclock);
|
||||||
|
|
Loading…
Add table
Reference in a new issue