From 4966b5b61a4034ed4b9ec0d4de3fe384edddbb3a Mon Sep 17 00:00:00 2001 From: "Ye.Li" Date: Thu, 12 Jun 2014 17:10:32 +0800 Subject: [PATCH] ENGR00315894-70 iMX6SX:Video Update MXS LCDIF driver Add a new interface "mxs_lcd_panel_setup" to setup fb parameters and specifies the LCDIF controller for multiple controllers of iMX6SX. Pass fb parameters via "videomode" env remains work if the new interface is not called before video initialization. Modify LCDIF clock interface "mxs_set_lcdclk" to support multiple LCDIF controllers on iMX6SX. Signed-off-by: Ye.Li Signed-off-by: Peng Fan (cherry picked from commit d7f49b9378547c3a57b96bcdb907fc44616beb3d) (cherry picked from commit e1343191b9de227c582847e7eeb5ce9238be0754) (cherry picked from commit 9632ebeccc34d663e21bd19f2fe62de51947296e) Signed-off-by: Ye Li (cherry picked from commit 948c5c95e87a47bb3a80c8e67b67fe70e1e4a569) --- arch/arm/cpu/arm926ejs/mxs/clock.c | 2 + drivers/video/mxsfb.c | 71 +++++++++++++++++++++++++----- include/mxsfb.h | 27 ++++++++++++ 3 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 include/mxsfb.h diff --git a/arch/arm/cpu/arm926ejs/mxs/clock.c b/arch/arm/cpu/arm926ejs/mxs/clock.c index 43d044d917..51f47bbfc8 100644 --- a/arch/arm/cpu/arm926ejs/mxs/clock.c +++ b/arch/arm/cpu/arm926ejs/mxs/clock.c @@ -7,6 +7,8 @@ * * Based on code from LTIB: * Copyright (C) 2010 Freescale Semiconductor, Inc. + * Copyright (C) 2010-2014 Freescale Semiconductor, Inc. + * */ #include diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c index 02fde05908..b9b25090e7 100644 --- a/drivers/video/mxsfb.c +++ b/drivers/video/mxsfb.c @@ -3,6 +3,8 @@ * Freescale i.MX23/i.MX28 LCDIF driver * * Copyright (C) 2011-2013 Marek Vasut + * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. + * */ #include #include @@ -17,6 +19,11 @@ #include #include "videomodes.h" +#include +#include +#include +#include + #define PS2KHZ(ps) (1000000000UL / (ps)) @@ -34,6 +41,31 @@ __weak void mxsfb_system_setup(void) { } +static int setup; +static struct fb_videomode fbmode; +static int depth; + +int mxs_lcd_panel_setup(struct fb_videomode mode, int bpp, + uint32_t base_addr) +{ + fbmode = mode; + depth = bpp; + panel.isaBase = base_addr; + + setup = 1; + + return 0; +} + +void mxs_lcd_get_panel(struct display_panel *dispanel) +{ + dispanel->width = fbmode.xres; + dispanel->height = fbmode.yres; + dispanel->reg_base = panel.isaBase; + dispanel->gdfindex = panel.gdfIndex; + dispanel->gdfbytespp = panel.gdfBytesPP; +} + /* * ARIES M28EVK: * setenv videomode @@ -49,12 +81,12 @@ __weak void mxsfb_system_setup(void) static void mxs_lcd_init(GraphicDevice *panel, struct ctfb_res_modes *mode, int bpp) { - struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE; + struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)(panel->isaBase); uint32_t word_len = 0, bus_width = 0; uint8_t valid_data = 0; /* Kick in the LCDIF clock */ - mxs_set_lcdclk(MXS_LCDIF_BASE, PS2KHZ(mode->pixclock)); + mxs_set_lcdclk(panel->isaBase, PS2KHZ(mode->pixclock)); /* Restart the LCDIF block */ mxs_reset_block(®s->hw_lcdif_ctrl_reg); @@ -132,7 +164,7 @@ static void mxs_lcd_init(GraphicDevice *panel, void lcdif_power_down(void) { - struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE; + struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)(panel.isaBase); int timeout = 1000000; if (!panel.frameAdrs) @@ -159,19 +191,37 @@ void *video_hw_init(void) puts("Video: "); - /* Suck display configuration from "videomode" variable */ - penv = env_get("videomode"); - if (!penv) { - puts("MXSFB: 'videomode' variable not set!\n"); - return NULL; + if (!setup) { + + /* Suck display configuration from "videomode" variable */ + penv = env_get("videomode"); + if (!penv) { + printf("MXSFB: 'videomode' variable not set!\n"); + return NULL; + } + + bpp = video_get_params(&mode, penv); + panel.isaBase = MXS_LCDIF_BASE; + } else { + mode.xres = fbmode.xres; + mode.yres = fbmode.yres; + mode.pixclock = fbmode.pixclock; + mode.left_margin = fbmode.left_margin; + mode.right_margin = fbmode.right_margin; + mode.upper_margin = fbmode.upper_margin; + mode.lower_margin = fbmode.lower_margin; + mode.hsync_len = fbmode.hsync_len; + mode.vsync_len = fbmode.vsync_len; + mode.sync = fbmode.sync; + mode.vmode = fbmode.vmode; + bpp = depth; } - bpp = video_get_params(&mode, penv); - /* fill in Graphic device struct */ sprintf(panel.modeIdent, "%dx%dx%d", mode.xres, mode.yres, bpp); + panel.winSizeX = mode.xres; panel.winSizeY = mode.yres; panel.plnSizeX = mode.xres; @@ -198,6 +248,7 @@ void *video_hw_init(void) panel.memSize = mode.xres * mode.yres * panel.gdfBytesPP; + /* Allocate framebuffer */ fb = memalign(ARCH_DMA_MINALIGN, roundup(panel.memSize, ARCH_DMA_MINALIGN)); diff --git a/include/mxsfb.h b/include/mxsfb.h new file mode 100644 index 0000000000..85f24aa286 --- /dev/null +++ b/include/mxsfb.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2014-2016 Freescale Semiconductor, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __MXSFB_H__ +#define __MXSFB_H__ + +#include + +#ifdef CONFIG_VIDEO_MXS +struct display_panel { + unsigned int reg_base; + unsigned int width; + unsigned int height; + unsigned int gdfindex; + unsigned int gdfbytespp; +}; + +void mxs_lcd_get_panel(struct display_panel *panel); +void lcdif_power_down(void); +int mxs_lcd_panel_setup(struct fb_videomode mode, int bpp, + uint32_t base_addr); +#endif + +#endif /* __MXSFB_H__ */ -- 2.17.1