Convert mxsfb to DM_VIDEO
cover Convert mxsfb to DM_VIDEO
From: Igor Opaniuk <[email protected]>
This series of patches refactors and extends NXP mxsfb video driver to be 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 mxsfb device.
Also enables DM_VIDEO by default for Colibri iMX7 eMMC edition.
Igor Opaniuk (6):
video: mxsfb: change mxs_lcd_init signature
video: mxsfb: reorder includes
video: mxsfb: refactor video_hw_init()
video: mxsfb: add DM_VIDEO support
ARM: dts: colibri_imx7: Add lcdif node
colibri_imx7_emmc: enable DM_VIDEO
arch/arm/dts/imx7-colibri-emmc.dts | 2 + arch/arm/dts/imx7-colibri.dtsi | 28 ++++ arch/arm/mach-imx/cpu.c | 2 +- arch/arm/mach-imx/mx7/soc.c | 2 +- configs/colibri_imx7_emmc_defconfig | 2 +- drivers/video/mxsfb.c | 219 +++++++++++++++++++++++----- include/configs/colibri_imx7.h | 2 +- 7 files changed, 213 insertions(+), 44 deletions(-)
Signature · 1 line
2.17.1
RFC 1/6 video: mxsfb: change mxs_lcd_init signature
From: Igor Opaniuk <[email protected]>
Provide directly framebuffer address instead of pointer to GraphicDevice struct, which will let to re-use this function in DM_VIDEO configurations.
--- drivers/video/mxsfb.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/video/mxsfb.c +4 -5
@@ -46,8 +46,7 @@ __weak void mxsfb_system_setup(void)* le:89,ri:164,up:23,lo:10,hs:10,vs:10,sync:0,vmode:0 */ -static void mxs_lcd_init (GraphicDevice *panel, -struct ctfb_res_modes *mode,int bpp) +static void mxs_lcd_init (u32 fb_addr,struct ctfb_res_modes *mode,int bpp) {struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE ;uint32_t word_len =0 , bus_width =0 ;
@@ -112,8 +111,8 @@ static void mxs_lcd_init(GraphicDevice *panel,writel ((0 <<LCDIF_VDCTRL4_DOTCLK_DLY_SEL_OFFSET ) | mode->xres, ®s->hw_lcdif_vdctrl4); -writel (panel->frameAdrs, ®s->hw_lcdif_cur_buf); -writel (panel->frameAdrs, ®s->hw_lcdif_next_buf); +writel (fb_addr, ®s->hw_lcdif_cur_buf); +writel (fb_addr, ®s->hw_lcdif_next_buf);/* Flush FIFO first */ writel (LCDIF_CTRL1_FIFO_CLEAR , ®s->hw_lcdif_ctrl1_set);
@@ -214,7 +213,7 @@ void *video_hw_init(void)printf ("%s\n" , panel.modeIdent);/* Start framebuffer */ -mxs_lcd_init (&panel, &mode, bpp); +mxs_lcd_init (panel.frameAdrs, &mode, bpp);#ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM /*
Signature · 1 line
2.17.1
RFC 2/6 video: mxsfb: reorder includes
In reply to Igor OpaniukFrom: Igor Opaniuk <[email protected]>
Follow alphabetical order of includes, which simplifies detecting duplicate includes etc.
--- drivers/video/mxsfb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/video/mxsfb.c +3 -4
@@ -5,16 +5,15 @@* Copyright (C) 2011-2013 Marek Vasut <[email protected]> */ #include <common.h> +#include <linux/errno.h> #include <malloc.h> #include <video_fb.h> -#include <asm/arch/imx-regs.h> #include <asm/arch/clock.h> +#include <asm/arch/imx-regs.h> #include <asm/arch/sys_proto.h> -#include <linux/errno.h> -#include <asm/io.h> -#include <asm/mach-imx/dma.h> +#include <asm/io.h> #include "videomodes.h"
Signature · 1 line
2.17.1
RFC 3/6 video: mxsfb: refactor video_hw_init()
In reply to Igor OpaniukFrom: Igor Opaniuk <[email protected]>
Refactor video_hw_init() function, and introduce an independent function for the common procedure of initialization.
Currently video_hw_init() is only in charge of parsing configuration from env("videomode") and filling struct GraphicPanel, and new mxs_probe_common() does hw specific initialization (invocation of mxs_lcd_init() etc.)
--- drivers/video/mxsfb.c | 68 ++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 27 deletions(-)
drivers/video/mxsfb.c +41 -27
@@ -128,6 +128,37 @@ static void mxs_lcd_init(u32 fb_addr, struct ctfb_res_modes *mode, int bpp)writel (LCDIF_CTRL_RUN , ®s->hw_lcdif_ctrl_set); } +static int mxs_probe_common (struct ctfb_res_modes *mode,int bpp,void *fb) +{ +/* Start framebuffer */ +mxs_lcd_init ((u32 )fb, mode, bpp); + +#ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM +/* +* If the LCD runs in system mode, the LCD refresh has to be triggered +* manually by setting the RUN bit in HW_LCDIF_CTRL register. To avoid +* having to set this bit manually after every single change in the +* framebuffer memory, we set up specially crafted circular DMA, which +* sets the RUN bit, then waits until it gets cleared and repeats this +* infinitelly. This way, we get smooth continuous updates of the LCD. +*/ +struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE ; + +memset (&desc,0 ,sizeof (struct mxs_dma_desc )); + desc.address = (dma_addr_t)&desc; + desc.cmd.data =MXS_DMA_DESC_COMMAND_NO_DMAXFER |MXS_DMA_DESC_CHAIN | +MXS_DMA_DESC_WAIT4END | + (1 <<MXS_DMA_DESC_PIO_WORDS_OFFSET ); + desc.cmd.pio_words[0 ] =readl (®s->hw_lcdif_ctrl) |LCDIF_CTRL_RUN ; + desc.cmd.next = (uint32_t )&desc.cmd; + +/* Execute the DMA chain. */ +mxs_dma_circ_start (MXS_DMA_CHANNEL_AHB_APBH_LCDIF , &desc); +#endif + +return 0 ; +} +void lcdif_power_down (void ) {struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE ;
@@ -151,8 +182,9 @@ void lcdif_power_down(void)void *video_hw_init (void ) {int bpp =-1 ; +int ret =0 ;char *penv; -void *fb; +void *fb =NULL ;struct ctfb_res_modes mode;puts ("Video: " );
@@ -167,8 +199,7 @@ void *video_hw_init(void) bpp =video_get_params (&mode, penv);/* fill in Graphic device struct */ -sprintf (panel.modeIdent,"%dx%dx%d" , - mode.xres, mode.yres, bpp); +sprintf (panel.modeIdent,"%dx%dx%d" , mode.xres, mode.yres, bpp); panel.winSizeX = mode.xres; panel.winSizeY = mode.yres;
@@ -211,31 +242,14 @@ void *video_hw_init(void)printf ("%s\n" , panel.modeIdent); -/* Start framebuffer */ -mxs_lcd_init (panel.frameAdrs, &mode, bpp); - -#ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM -/* -* If the LCD runs in system mode, the LCD refresh has to be triggered -* manually by setting the RUN bit in HW_LCDIF_CTRL register. To avoid -* having to set this bit manually after every single change in the -* framebuffer memory, we set up specially crafted circular DMA, which -* sets the RUN bit, then waits until it gets cleared and repeats this -* infinitelly. This way, we get smooth continuous updates of the LCD. -*/ -struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE ; + ret =mxs_probe_common (&mode, bpp, fb); +if (ret) + goto dealloc_fb; -memset (&desc,0 ,sizeof (struct mxs_dma_desc )); - desc.address = (dma_addr_t)&desc; - desc.cmd.data =MXS_DMA_DESC_COMMAND_NO_DMAXFER |MXS_DMA_DESC_CHAIN | -MXS_DMA_DESC_WAIT4END | - (1 <<MXS_DMA_DESC_PIO_WORDS_OFFSET ); - desc.cmd.pio_words[0 ] =readl (®s->hw_lcdif_ctrl) |LCDIF_CTRL_RUN ; - desc.cmd.next = (uint32_t )&desc.cmd; +return (void *)&panel; -/* Execute the DMA chain. */ -mxs_dma_circ_start (MXS_DMA_CHANNEL_AHB_APBH_LCDIF , &desc); -#endif +dealloc_fb: +free (fb); -return (void *)&panel; +return NULL ; }
Signature · 1 line
2.17.1
RFC 4/6 video: mxsfb: add DM_VIDEO support
In reply to Igor OpaniukFrom: 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 mxsfb device.
--- arch/arm/mach-imx/cpu.c | 2 +- arch/arm/mach-imx/mx7/soc.c | 2 +- drivers/video/mxsfb.c | 145 +++++++++++++++++++++++++++++++-- include/configs/colibri_imx7.h | 2 +- 4 files changed, 139 insertions(+), 12 deletions(-)
arch/arm/mach-imx/cpu.c +1 -1
@@ -298,7 +298,7 @@ void arch_preboot_os(void)/* disable video before launching O/S */ ipuv3_fb_shutdown ();#endif -#if defined(CONFIG_VIDEO_MXS ) +#if defined(CONFIG_VIDEO_MXS ) && !defined(CONFIG_DM_VIDEO )lcdif_power_down ();#endif }
arch/arm/mach-imx/mx7/soc.c +1 -1
@@ -369,7 +369,7 @@ void s_init(void)void reset_misc (void ) {#ifndef CONFIG_SPL_BUILD -#ifdef CONFIG_VIDEO_MXS +#if defined(CONFIG_VIDEO_MXS ) && !defined(CONFIG_DM_VIDEO )lcdif_power_down ();#endif #endif
drivers/video/mxsfb.c +136 -9
194 lines not on this page · raw message
include/configs/colibri_imx7.h +1 -1
@@ -225,7 +225,7 @@#define CONFIG_SYS_DFU_DATA_BUF_SIZE SZ_16M#define DFU_DEFAULT_POLL_TIMEOUT 300 -#ifdef CONFIG_VIDEO +#if defined(CONFIG_VIDEO ) || defined(CONFIG_DM_VIDEO )#define CONFIG_VIDEO_MXS #define CONFIG_VIDEO_LOGO #define CONFIG_SPLASH_SCREEN
Signature · 1 line
2.17.1
RFC 5/6 ARM: dts: colibri_imx7: Add lcdif node
In reply to Igor OpaniukFrom: Igor Opaniuk <[email protected]>
Extend lcdif DT node with proper display-timings for mxsfb driver.
--- arch/arm/dts/imx7-colibri-emmc.dts | 2 ++ arch/arm/dts/imx7-colibri.dtsi | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
arch/arm/dts/imx7-colibri-emmc.dts +2 -0
@@ -11,8 +11,10 @@ compatible = "toradex,imx7d-colibri-emmc", "fsl,imx7d"; aliases { + u-boot,dm-pre-reloc; mmc0 = &usdhc3; mmc1 = &usdhc1; + display1 = &lcdif; }; chosen {
arch/arm/dts/imx7-colibri.dtsi +28 -0
@@ -111,3 +111,31 @@ >; }; }; + +&lcdif { + u-boot,dm-pre-reloc; + status = "okay"; + + display-timings { + native-mode = <&timing_vga>; + + /* Standard VGA timing */ + timing_vga: 640x480 { + u-boot,dm-pre-reloc; + clock-frequency = <25175000>; + hactive = <640>; + vactive = <480>; + hback-porch = <48>; + hfront-porch = <16>; + vback-porch = <33>; + vfront-porch = <10>; + hsync-len = <96>; + vsync-len = <2>; + + de-active = <1>; + hsync-active = <0>; + vsync-active = <0>; + pixelclk-active = <0>; + }; + }; +};
Signature · 1 line
2.17.1
Fabio Estevam
reviewerRFC 5/6 ARM: dts: colibri_imx7: Add lcdif node
Hi Igor,
Quoted 14 lines · Igor Opaniuk
+&lcdif {
arch/arm/dts/imx7-colibri.dtsi +13
-0+ u-boot,dm-pre-reloc; + status = "okay"; + + display-timings { + native-mode = <&timing_vga>; + + /* Standard VGA timing */ + timing_vga: 640x480 { + u-boot,dm-pre-reloc; + clock-frequency = <25175000>; + hactive = <640>; + vactive = <480>; + hback-porch = <48>;
arch/arm/dts/imx7-colibri.dtsi
Quoted 10 lines
arch/arm/dts/imx7-colibri.dtsi +10
-0+ hfront-porch = <16>; + vback-porch = <33>; + vfront-porch = <10>; + hsync-len = <96>; + vsync-len = <2>; + + de-active = <1>; + hsync-active = <0>; + vsync-active = <0>; + pixelclk-active = <0>
This is the deprecated style mxsfb fbdev binding.
In the kernel we no longer use this style as documented in Documentation/devicetree/bindings/display/mxsfb.txt
If we follow this route in U-Boot then we will diverge from the kernel recommended bindings.
RFC 5/6 ARM: dts: colibri_imx7: Add lcdif node
Hi Fabio,
Quoted 32 lines · Fabio Estevam
Hi Igor,
Quoted 14 lines · Igor Opaniuk
+&lcdif {
arch/arm/dts/imx7-colibri.dtsi +13
-0+ u-boot,dm-pre-reloc; + status = "okay"; + + display-timings { + native-mode = <&timing_vga>; + + /* Standard VGA timing */ + timing_vga: 640x480 { + u-boot,dm-pre-reloc; + clock-frequency = <25175000>; + hactive = <640>; + vactive = <480>; + hback-porch = <48>;arch/arm/dts/imx7-colibri.dtsi
Quoted 10 lines
arch/arm/dts/imx7-colibri.dtsi +10
-0+ hfront-porch = <16>; + vback-porch = <33>; + vfront-porch = <10>; + hsync-len = <96>; + vsync-len = <2>; + + de-active = <1>; + hsync-active = <0>; + vsync-active = <0>; + pixelclk-active = <0>This is the deprecated style mxsfb fbdev binding.
Quoted 5 lines
In the kernel we no longer use this style as documented in
Documentation/devicetree/bindings/display/mxsfb.txtIf we follow this route in U-Boot then we will diverge from the kernel recommended bindings.
Initially I copy-pasted the whole DT node "as it is" from the linux kernel dts, but found out that existing
DT wrapper for parsing display timings (ofnode_decode_display_timing())) isn't able to parse it properly, so I just changed it to conform the same structure as similar nodes in other DTS files.
Thanks for letting me know, probably ofnode_decode_display_timing() implementation should
be adjusted as well.
Regards,
Igor
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
RFC 5/6 ARM: dts: colibri_imx7: Add lcdif node
Hi Fabio,
Quoted 49 lines · Igor Opaniuk
Hi Fabio,
Quoted 32 lines · Fabio Estevam
Hi Igor,
Quoted 14 lines · Igor Opaniuk
+&lcdif {
arch/arm/dts/imx7-colibri.dtsi +13
-0+ u-boot,dm-pre-reloc; + status = "okay"; + + display-timings { + native-mode = <&timing_vga>; + + /* Standard VGA timing */ + timing_vga: 640x480 { + u-boot,dm-pre-reloc; + clock-frequency = <25175000>; + hactive = <640>; + vactive = <480>; + hback-porch = <48>;arch/arm/dts/imx7-colibri.dtsi
Quoted 10 lines
arch/arm/dts/imx7-colibri.dtsi +10
-0+ hfront-porch = <16>; + vback-porch = <33>; + vfront-porch = <10>; + hsync-len = <96>; + vsync-len = <2>; + + de-active = <1>; + hsync-active = <0>; + vsync-active = <0>; + pixelclk-active = <0>This is the deprecated style mxsfb fbdev binding.
Quoted 5 lines
In the kernel we no longer use this style as documented in
Documentation/devicetree/bindings/display/mxsfb.txtIf we follow this route in U-Boot then we will diverge from the kernel recommended bindings.
Initially I copy-pasted the whole DT node "as it is" from the linux kernel dts, but found out that existing
DT wrapper for parsing display timings (ofnode_decode_display_timing())) isn't able to parse it properly, so I just changed it to conform the same structure as similar nodes in other DTS files.
Quoted 3 lines
Thanks for letting me know, probably
ofnode_decode_display_timing()implementation should
be adjusted as well.
Nevermind, I've double-checked ofnode_decode_display_timing() implementation and all instances of display-timings nodes, it definitely should be able parse the same structure as defined in the Linux devicetree bindings.
Probably I just messed up with something.
Quoted 14 lines
Regards,
Igor--
Best regards - Freundliche Grüsse - Meilleures salutationsIgor Opaniuk
mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
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
RFC 6/6 colibri_imx7_emmc: enable DM_VIDEO
In reply to Igor OpaniukFrom: Igor Opaniuk <[email protected]>
Enable DM_VIDEO for Colibri iMX7 eMMC version.
--- configs/colibri_imx7_emmc_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configs/colibri_imx7_emmc_defconfig +1 -1
@@ -63,6 +63,6 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x1b67 CONFIG_USB_GADGET_PRODUCT_NUM=0x4000 CONFIG_CI_UDC=y CONFIG_USB_GADGET_DOWNLOAD=y -CONFIG_VIDEO=y +CONFIG_DM_VIDEO=y CONFIG_FAT_WRITE=y CONFIG_OF_LIBFDT_OVERLAY=y
Signature · 1 line
2.17.1
cover Convert mxsfb to DM_VIDEO
In reply to Igor OpaniukOn Tue, 4 Jun 2019 00:05:55 +0300
Igor Opaniuk igor.opaniuk at gmail.com wrote:
...
Quoted 8 lines
Igor Opaniuk (6):
video: mxsfb: changemxs_lcd_initsignature
video: mxsfb: reorder includes
video: mxsfb: refactorvideo_hw_init()
video: mxsfb: addDM_VIDEOsupport
ARM: dts:colibri_imx7: Add lcdif node
colibri_imx7_emmc: enableDM_VIDEO
Quoted 8 lines
arch/arm/dts/imx7-colibri-emmc.dts | 2 + arch/arm/dts/imx7-colibri.dtsi | 28 ++++ arch/arm/mach-imx/cpu.c | 2 +- arch/arm/mach-imx/mx7/soc.c | 2 +- configs/colibri_imx7_emmc_defconfig | 2 +- drivers/video/mxsfb.c | 219 +++++++++++++++++++++++----- include/configs/colibri_imx7.h | 2 +- 7 files changed, 213 insertions(+), 44 deletions(-)
Series applied to u-boot-video/master, thanks!
--
Anatolij