Tegra DC improvements
Subsystems (3)
cover Tegra DC improvements
This patch set is dedicated to improvement of video support on T20 and T30 devices. It contains:
- DC driver improvements (T30 support was added into existing T20 DC driver, it was moved into own folder, added support of reading clocks from dts, improved work with panel ops and implemented native 180 degree panel rotation support)
- DSI driver bring up (driver is based on mainline Linux one with minor adjustments, only T30 tested)
- Simple panel driver tweaks (added get_display_timing ops and implemented simple MIPI DSI panels support)
Marcel Ziswiler (1):
tegra: lcd: video: integrate display driver for t30
Svyatoslav Ryhel (10):
video: move tegra dc driver into own folder
video: tegra-dc: get clocks from device tree
video: tegra-dc: request timings from panel driver first
video: tegra-dc: assign regmap directly
video: tegra-dc: add 180 degree panel rotation
video: tegra-dc: add panel_set_backlight call
video: tegra-dc: pass DC regmap to internal devices
video: tegra20: add DSI controller driver
simple_panel: add support for get_display_timing
simple_panel: support simple MIPI DSI panels
arch/arm/dts/tegra30-u-boot.dtsi | 9 +
arch/arm/include/asm/arch-tegra/dc.h | 8 +
arch/arm/include/asm/arch-tegra30/display.h | 28 +
arch/arm/include/asm/arch-tegra30/dsi.h | 197 +++++
arch/arm/include/asm/arch-tegra30/pwm.h | 13 +
drivers/video/Kconfig | 11 +-
drivers/video/Makefile | 2 +-
drivers/video/simple_panel.c | 47 +-
drivers/video/tegra20/Kconfig | 17 +
drivers/video/tegra20/Makefile | 4 +
drivers/video/tegra20/dsi.h | 126 +++
drivers/video/tegra20/mipi-phy.c | 134 +++
drivers/video/tegra20/mipi-phy.h | 48 ++
drivers/video/{tegra.c => tegra20/tegra-dc.c} | 123 ++-
drivers/video/tegra20/tegra-dsi.c | 769 ++++++++++++++++++
15 files changed, 1487 insertions(+), 49 deletions(-)
create mode 100644 arch/arm/include/asm/arch-tegra30/display.h
create mode 100644 arch/arm/include/asm/arch-tegra30/dsi.h
create mode 100644 arch/arm/include/asm/arch-tegra30/pwm.h
create mode 100644 drivers/video/tegra20/Kconfig
create mode 100644 drivers/video/tegra20/Makefile
create mode 100644 drivers/video/tegra20/dsi.h
create mode 100644 drivers/video/tegra20/mipi-phy.c
create mode 100644 drivers/video/tegra20/mipi-phy.h
rename drivers/video/{tegra.c => tegra20/tegra-dc.c} (82%)
create mode 100644 drivers/video/tegra20/tegra-dsi.cSignature · 1 line
2.37.2
PATCH 1/11 tegra: lcd: video: integrate display driver for t30
From: Marcel Ziswiler <[email protected]>
On popular request make the display driver from T20 work on T30 as well. Turned out to be quite straight forward. However a few notes about some things encountered during porting: Of course the T30 device tree was completely missing host1x as well as PWM support but it turns out this can simply be copied from T20. The only trouble compiling the Tegra video driver for T30 had to do with some hard-coded PWM pin muxing for T20 which is quite ugly anyway. On T30 this gets handled by a board specific complete pin muxing table. The older Chromium U-Boot 2011.06 which to my knowledge was the only prior attempt at enabling a display driver for T30 for whatever reason got some clocking stuff mixed up. Turns out at least for a single display controller T20 and T30 can be clocked quite similar. Enjoy.
--- arch/arm/dts/tegra30-u-boot.dtsi | 9 +++++++ arch/arm/include/asm/arch-tegra30/display.h | 28 +++++++++++++++++++++ arch/arm/include/asm/arch-tegra30/pwm.h | 13 ++++++++++ drivers/video/tegra.c | 10 ++++++-- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 arch/arm/include/asm/arch-tegra30/display.h create mode 100644 arch/arm/include/asm/arch-tegra30/pwm.h
arch/arm/dts/tegra30-u-boot.dtsi +9 -0
@@ -1,3 +1,12 @@ #include <config.h> #include "tegra-u-boot.dtsi" + +/ { + host1x@50000000 { + u-boot,dm-pre-reloc; + dc@54200000 { + u-boot,dm-pre-reloc; + }; + }; +};
arch/arm/include/asm/arch-tegra30/display.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* (C) Copyright 2010 +* NVIDIA Corporation <www.nvidia.com> +*/ + +#ifndef __ASM_ARCH_TEGRA_DISPLAY_H +#define __ASM_ARCH_TEGRA_DISPLAY_H + +#include <asm/arch-tegra/dc.h> + +/* This holds information about a window which can be displayed */ +struct disp_ctl_win { +enum win_color_depth_id fmt;/* Color depth/format */ +unsigned int bpp;/* Bits per pixel */ +phys_addr_t phys_addr;/* Physical address in memory */ +unsigned int x;/* Horizontal address offset (bytes) */ +unsigned int y;/* Veritical address offset (bytes) */ +unsigned int w;/* Width of source window */ +unsigned int h;/* Height of source window */ +unsigned int stride;/* Number of bytes per line */ +unsigned int out_x;/* Left edge of output window (col) */ +unsigned int out_y;/* Top edge of output window (row) */ +unsigned int out_w;/* Width of output window in pixels */ +unsigned int out_h;/* Height of output window in pixels */ +}; + +#endif /*__ASM_ARCH_TEGRA_DISPLAY_H*/
arch/arm/include/asm/arch-tegra30/pwm.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Tegra pulse width frequency modulator definitions +* +* Copyright (c) 2011 The Chromium OS Authors. +*/ + +#ifndef __ASM_ARCH_TEGRA30_PWM_H +#define __ASM_ARCH_TEGRA30_PWM_H + +#include <asm/arch-tegra/pwm.h> + +#endif /* __ASM_ARCH_TEGRA30_PWM_H */
drivers/video/tegra.c +8 -2
@@ -40,8 +40,8 @@ struct tegra_lcd_priv {enum {/* Maximum LCD size we support */ -LCD_MAX_WIDTH =1366 , -LCD_MAX_HEIGHT =768 , +LCD_MAX_WIDTH =1920 , +LCD_MAX_HEIGHT =1200 ,LCD_MAX_LOG2_BPP =VIDEO_BPP16 , };
@@ -307,14 +307,19 @@ static int tegra_lcd_probe(struct udevice *dev)int ret;/* Initialize the Tegra display controller */ +#ifdef CONFIG_TEGRA20 funcmux_select (PERIPH_ID_DISP1 ,FUNCMUX_DEFAULT ); +#endif +if (tegra_display_probe (blob, priv, (void *)plat->base)) {printf ("%s: Failed to probe display driver\n" , __func__);return -1 ; } +#ifdef CONFIG_TEGRA20 pinmux_set_func (PMUX_PINGRP_GPU ,PMUX_FUNC_PWM );pinmux_tristate_disable (PMUX_PINGRP_GPU ); +#endif ret =panel_enable_backlight (priv->panel);if (ret) {
@@ -414,6 +419,7 @@ static const struct video_ops tegra_lcd_ops = {static const struct udevice_id tegra_lcd_ids[] = { { .compatible ="nvidia,tegra20-dc" }, + { .compatible ="nvidia,tegra30-dc" }, { } };
Signature · 1 line
2.37.2
PATCH 2/11 video: move tegra dc driver into own folder
In reply to Svyatoslav Ryhel---
drivers/video/Kconfig | 11 ++---------
drivers/video/Makefile | 2 +-
drivers/video/tegra20/Kconfig | 8 ++++++++
drivers/video/tegra20/Makefile | 3 +++
drivers/video/{tegra.c => tegra20/tegra-dc.c} | 0
5 files changed, 14 insertions(+), 10 deletions(-)
create mode 100644 drivers/video/tegra20/Kconfig
create mode 100644 drivers/video/tegra20/Makefile
rename drivers/video/{tegra.c => tegra20/tegra-dc.c} (100%)drivers/video/Kconfig +2 -9
@@ -638,15 +638,6 @@ source "drivers/video/stm32/Kconfig" source "drivers/video/tidss/Kconfig" -config VIDEO_TEGRA20 - bool "Enable LCD support on Tegra20" - depends on OF_CONTROL - help - Tegra20 supports video output to an attached LCD panel as well as - other options such as HDMI. Only the LCD is supported in U-Boot. - This option enables this support which can be used on devices which - have an LCD display connected. - config VIDEO_TEGRA124 bool "Enable video support on Tegra124" help
@@ -657,6 +648,8 @@ config VIDEO_TEGRA124 source "drivers/video/bridge/Kconfig" +source "drivers/video/tegra20/Kconfig" + source "drivers/video/imx/Kconfig" config VIDEO_MXS
drivers/video/Makefile +1 -1
@@ -61,10 +61,10 @@ obj-$(CONFIG_VIDEO_OMAP3) += omap3_dss.o obj-$(CONFIG_VIDEO_DSI_HOST_SANDBOX) += sandbox_dsi_host.o obj-$(CONFIG_VIDEO_SANDBOX_SDL) += sandbox_sdl.o obj-$(CONFIG_VIDEO_SIMPLE) += simplefb.o -obj-$(CONFIG_VIDEO_TEGRA20) += tegra.o obj-$(CONFIG_VIDEO_VESA) += vesa.o obj-$(CONFIG_VIDEO_SEPS525) += seps525.o obj-$(CONFIG_VIDEO_ZYNQMP_DPSUB) += zynqmp_dpsub.o obj-y += bridge/ obj-y += sunxi/ +obj-y += tegra20/
drivers/video/tegra20/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +config VIDEO_TEGRA20 + bool "Enable Display Controller support on Tegra20 and Tegra 30" + depends on OF_CONTROL + help + T20/T30 support video output to an attached LCD panel as well as + other options such as HDMI. Only the LCD is supported in U-Boot. + This option enables this support which can be used on devices which + have an LCD display connected.
drivers/video/tegra20/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_VIDEO_TEGRA20) += tegra-dc.o
drivers/video/tegra20/tegra-dc.c renamed from drivers/video/tegra.c +0 -0
Signature · 1 line
2.37.2
PATCH 3/11 video: tegra-dc: get clocks from device tree
In reply to Svyatoslav RyhelDISP1 clock may use PLLP, PLLC and PLLD as parents. Instead of hardcoding, lets pass clock and its parent from device tree. Default parent is PLLP.
--- drivers/video/tegra20/tegra-dc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
drivers/video/tegra20/tegra-dc.c +23 -8
@@ -36,6 +36,7 @@ struct tegra_lcd_priv {struct disp_ctlr *disp;/* Display controller to use */ fdt_addr_t frame_buffer;/* Address of frame buffer */ unsigned pixel_clock;/* Pixel clock in Hz */ +int dc_clk[2 ];/* Contains clk and its parent */ };enum {
@@ -134,7 +135,7 @@ static int update_display_mode(struct dc_disp_reg *disp,* the display clock (typically 600MHz) to the pixel clock. We round * up or down as requried. */ - rate =clock_get_periph_rate (PERIPH_ID_DISP1 ,CLOCK_ID_CGENERAL ); + rate =clock_get_periph_rate (priv->dc_clk[0 ], priv->dc_clk[1 ]); div = ((rate *2 + priv->pixel_clock /2 ) / priv->pixel_clock) -2 ;debug ("Display clock %lu, divider %lu\n" , rate, div);
@@ -269,20 +270,27 @@ static int tegra_display_probe(const void *blob, struct tegra_lcd_priv *priv, {struct disp_ctl_win window;struct dc_ctlr *dc; +unsigned long rate =clock_get_rate (priv->dc_clk[1 ]); priv->frame_buffer = (u32 )default_lcd_base; dc = (struct dc_ctlr *)priv->disp;/* -* A header file for clock constants was NAKed upstream. -* TODO: Put this into the FDT and fdt_lcd struct when we have clock -* support there +* We halve the rate if DISP1 paret is PLLD, since actual parent +* is plld_out0 which is PLLD divided by 2. */ -clock_start_periph_pll (PERIPH_ID_HOST1X ,CLOCK_ID_PERIPH , -144 *1000000 ); -clock_start_periph_pll (PERIPH_ID_DISP1 ,CLOCK_ID_CGENERAL , -600 *1000000 ); +if (priv->dc_clk[1 ] ==CLOCK_ID_DISPLAY ) + rate /=2 ; + +/* +* HOST1X is init by default at 150MHz with PLLC as parent +*/ +clock_start_periph_pll (PERIPH_ID_HOST1X ,CLOCK_ID_CGENERAL , +150 *1000000 ); +clock_start_periph_pll (priv->dc_clk[0 ], priv->dc_clk[1 ], + rate); +basic_init (&dc->cmd);basic_init_timer (&dc->disp);rgb_enable (&dc->com);
@@ -358,6 +366,13 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)return -EINVAL ; } + ret =clock_decode_pair (dev, priv->dc_clk); +if (ret <0 ) { +debug ("%s: Cannot decode clocks for '%s' (ret = %d)\n" , + __func__, dev->name, ret); +return -EINVAL ; + } + rgb =fdt_subnode_offset (blob, node,"rgb" );if (rgb <0 ) { debug("%s: Cannot find rgb subnode for '%s' (ret=%d)\n",
Signature · 1 line
2.37.2
PATCH 4/11 video: tegra-dc: request timings from panel driver first
In reply to Svyatoslav RyhelCheck if panel driver has display timings and get those. If panel driver does not pass timing, try to find timing under rgb node for backwards compatibility.
--- drivers/video/tegra20/tegra-dc.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/video/tegra20/tegra-dc.c +17 -12
@@ -380,18 +380,6 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)return -EINVAL ; } - ret =fdtdec_decode_display_timing (blob, rgb,0 , &priv->timing); -if (ret) { -debug ("%s: Cannot read display timing for '%s' (ret=%d)\n" , - __func__, dev->name, ret); -return -EINVAL ; - } - timing = &priv->timing; - priv->width = timing->hactive.typ; - priv->height = timing->vactive.typ; - priv->pixel_clock = timing->pixelclock.typ; - priv->log2_bpp =VIDEO_BPP16 ; -/* * Sadly the panel phandle is in an rgb subnode so we cannot use * uclass_get_device_by_phandle().
@@ -401,6 +389,7 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)debug ("%s: Cannot find panel information\n" , __func__);return -EINVAL ; } + ret =uclass_get_device_by_of_offset (UCLASS_PANEL , panel_node, &priv->panel);if (ret) {
@@ -409,6 +398,22 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)return ret; } + ret =panel_get_display_timing (priv->panel, &priv->timing); +if (ret) { + ret =fdtdec_decode_display_timing (blob, rgb,0 , &priv->timing); +if (ret) { +debug ("%s: Cannot read display timing for '%s' (ret=%d)\n" , + __func__, dev->name, ret); +return -EINVAL ; + } + } + + timing = &priv->timing; + priv->width = timing->hactive.typ; + priv->height = timing->vactive.typ; + priv->pixel_clock = timing->pixelclock.typ; + priv->log2_bpp =VIDEO_BPP16 ; +return 0 ; }
Signature · 1 line
2.37.2
PATCH 5/11 video: tegra-dc: assign regmap directly
In reply to Svyatoslav Ryhel--- drivers/video/tegra20/tegra-dc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/video/tegra20/tegra-dc.c +8 -11
@@ -33,7 +33,7 @@ struct tegra_lcd_priv {enum video_log2_bpp log2_bpp;/* colour depth */ struct display_timing timing;struct udevice *panel; -struct disp_ctlr *disp;/* Display controller to use */ +struct dc_ctlr *dc;/* Display controller regmap */ fdt_addr_t frame_buffer;/* Address of frame buffer */ unsigned pixel_clock;/* Pixel clock in Hz */ int dc_clk[2 ];/* Contains clk and its parent */
@@ -269,13 +269,10 @@ static int tegra_display_probe(const void *blob, struct tegra_lcd_priv *priv, void *default_lcd_base) {struct disp_ctl_win window; -struct dc_ctlr *dc;unsigned long rate =clock_get_rate (priv->dc_clk[1 ]); priv->frame_buffer = (u32 )default_lcd_base; - dc = (struct dc_ctlr *)priv->disp; -/* * We halve the rate if DISP1 paret is PLLD, since actual parent * is plld_out0 which is PLLD divided by 2.
@@ -291,17 +288,17 @@ static int tegra_display_probe(const void *blob, struct tegra_lcd_priv *priv,clock_start_periph_pll (priv->dc_clk[0 ], priv->dc_clk[1 ], rate); -basic_init (&dc->cmd); -basic_init_timer (&dc->disp); -rgb_enable (&dc->com); +basic_init (&priv->dc->cmd); +basic_init_timer (&priv->dc->disp); +rgb_enable (&priv->dc->com);if (priv->pixel_clock) -update_display_mode (&dc->disp, priv); +update_display_mode (&priv->dc->disp, priv);if (setup_window (&window, priv))return -1 ; -update_window (dc, &window); +update_window (priv->dc, &window);return 0 ; }
@@ -360,8 +357,8 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)int rgb;int ret; - priv->disp =dev_read_addr_ptr (dev); -if (!priv->disp) { + priv->dc = (struct dc_ctlr *)dev_read_addr_ptr (dev); +if (!priv->dc) {debug ("%s: No display controller address\n" , __func__);return -EINVAL ; }
Signature · 1 line
2.37.2
PATCH 6/11 video: tegra-dc: add 180 degree panel rotation
In reply to Svyatoslav RyhelUnlike 90 and 270 degree rotation, 180 degree rotation is more common and does not require scaling. Implement it for correct grouper support.
--- drivers/video/tegra20/tegra-dc.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/video/tegra20/tegra-dc.c +19 -4
@@ -37,6 +37,7 @@ struct tegra_lcd_priv {fdt_addr_t frame_buffer;/* Address of frame buffer */ unsigned pixel_clock;/* Pixel clock in Hz */ int dc_clk[2 ];/* Contains clk and its parent */ +bool rotation;/* 180 degree panel turn */ };enum {
@@ -46,8 +47,10 @@ enum { LCD_MAX_LOG2_BPP = VIDEO_BPP16, }; -static void update_window (struct dc_ctlr *dc,struct disp_ctl_win *win) +static void update_window (struct tegra_lcd_priv *priv, +struct disp_ctl_win *win) { +struct dc_ctlr *dc = priv->dc;unsigned h_dda, v_dda;unsigned long val;
@@ -88,6 +91,10 @@ static void update_window(struct dc_ctlr *dc, struct disp_ctl_win *win) val =WIN_ENABLE ;if (win->bpp <24 ) val |=COLOR_EXPAND ; + +if (priv->rotation) + val |=H_DIRECTION |V_DIRECTION ; +writel (val, &dc->win.win_opt);writel ((unsigned long )win->phys_addr, &dc->winbuf.start_addr);
@@ -224,8 +231,14 @@ static void rgb_enable(struct dc_com_reg *com)static int setup_window (struct disp_ctl_win *win,struct tegra_lcd_priv *priv) { - win->x =0 ; - win->y =0 ; +if (priv->rotation) { + win->x = priv->width *2 ; + win->y = priv->height; + }else { + win->x =0 ; + win->y =0 ; + } + win->w = priv->width; win->h = priv->height; win->out_x =0 ;
@@ -298,7 +311,7 @@ static int tegra_display_probe(const void *blob, struct tegra_lcd_priv *priv,if (setup_window (&window, priv))return -1 ; -update_window (priv->dc, &window); +update_window (priv, &window);return 0 ; }
@@ -370,6 +383,8 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)return -EINVAL ; } + priv->rotation =dev_read_bool (dev,"nvidia,180-rotation" ); + rgb =fdt_subnode_offset (blob, node,"rgb" );if (rgb <0 ) { debug("%s: Cannot find rgb subnode for '%s' (ret=%d)\n",
Signature · 1 line
2.37.2
PATCH 7/11 video: tegra-dc: add panel_set_backlight call
In reply to Svyatoslav RyhelTegra DC driver does not call panel_set_backlight, which can result in absence of backlight on device. Fix this by calling panel_set_backlight with BACKLIGHT_DEFAULT just after panel_enable_backlight.
--- drivers/video/tegra20/tegra-dc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/video/tegra20/tegra-dc.c +7 -0
@@ -4,6 +4,7 @@*/ #include <common.h> +#include <backlight.h> #include <dm.h> #include <fdtdec.h> #include <log.h>
@@ -345,6 +346,12 @@ static int tegra_lcd_probe(struct udevice *dev)return ret; } + ret =panel_set_backlight (priv->panel,BACKLIGHT_DEFAULT ); +if (ret) { +debug ("%s: Cannot set backlight to default, ret=%d\n" , __func__, ret); +return ret; + } +mmu_set_region_dcache_behaviour (priv->frame_buffer, plat->size,DCACHE_WRITETHROUGH );
Signature · 1 line
2.37.2
PATCH 8/11 video: tegra-dc: pass DC regmap to internal devices
In reply to Svyatoslav RyhelInternal video devices like DSI and HDMI controllers require sending commands into DC register field. To make this available, lets create platform data, which is restricted to pass DC regmap only to pre-defined devices.
--- arch/arm/include/asm/arch-tegra/dc.h | 8 ++++++++ drivers/video/tegra20/tegra-dc.c | 8 ++++++++ 2 files changed, 16 insertions(+)
arch/arm/include/asm/arch-tegra/dc.h +8 -0
@@ -569,4 +569,12 @@ enum {#define DC_N_WINDOWS 5#define DC_REG_SAVE_SPACE (DC_N_WINDOWS + 5) +#define TEGRA_DSI_A "dsi@54300000" +#define TEGRA_DSI_B "dsi@54400000" + +struct tegra_dc_plat { +struct udevice *dev;/* Display controller device */ +struct dc_ctlr *dc;/* Display controller regmap */ +}; +#endif /* __ASM_ARCH_TEGRA_DC_H */
drivers/video/tegra20/tegra-dc.c +8 -0
@@ -417,6 +417,14 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)return ret; } +if (!strcmp (priv->panel->name,TEGRA_DSI_A ) || + !strcmp (priv->panel->name,TEGRA_DSI_B )) { +struct tegra_dc_plat *dc_plat =dev_get_plat (priv->panel); + + dc_plat->dev = dev; + dc_plat->dc = priv->dc; + } + ret =panel_get_display_timing (priv->panel, &priv->timing);if (ret) { ret =fdtdec_decode_display_timing (blob, rgb,0 , &priv->timing);
Signature · 1 line
2.37.2
PATCH 9/11 video: tegra20: add DSI controller driver
In reply to Svyatoslav RyhelAdds support for both DSI outputs found on Tegra. Only very minimal functionality is implemented, so advanced features like ganged mode won't work. Driver is heavily based on mainline Tegra DSI and re-uses much of its features.
Only T30 is supported for now but T20 support can be added if any supported devices will be found.
Driver is wrapped as panel driver since Tegra DC driver supports only panel drivers calls.
--- arch/arm/include/asm/arch-tegra30/dsi.h | 197 ++++++ drivers/video/tegra20/Kconfig | 9 + drivers/video/tegra20/Makefile | 1 + drivers/video/tegra20/dsi.h | 126 ++++ drivers/video/tegra20/mipi-phy.c | 134 +++++ drivers/video/tegra20/mipi-phy.h | 48 ++ drivers/video/tegra20/tegra-dsi.c | 769 ++++++++++++++++++++++++ 7 files changed, 1284 insertions(+) create mode 100644 arch/arm/include/asm/arch-tegra30/dsi.h create mode 100644 drivers/video/tegra20/dsi.h create mode 100644 drivers/video/tegra20/mipi-phy.c create mode 100644 drivers/video/tegra20/mipi-phy.h create mode 100644 drivers/video/tegra20/tegra-dsi.c
arch/arm/include/asm/arch-tegra30/dsi.h new file +197 -0
@@ -0,0 +1,197 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* (C) Copyright 2010 +* NVIDIA Corporation <www.nvidia.com> +*/ + +#ifndef __ASM_ARCH_TEGRA_DSI_H +#define __ASM_ARCH_TEGRA_DSI_H + +#ifndef __ASSEMBLY__ +#include <linux/bitops.h> +#endif + +/* Register definitions for the Tegra display serial interface */ + +/* DSI syncpoint register 0x000 ~ 0x002 */ +struct dsi_syncpt_reg { +/* Address 0x000 ~ 0x002 */ +uint incr_syncpt;/* _INCR_SYNCPT_0 */ +uint incr_syncpt_ctrl;/* _INCR_SYNCPT_CNTRL_0 */ +uint incr_syncpt_err;/* _INCR_SYNCPT_ERROR_0 */ +}; + +/* DSI misc register 0x008 ~ 0x015 */ +struct dsi_misc_reg { +/* Address 0x008 ~ 0x015 */ +uint ctxsw;/* _CTXSW_0 */ +uint dsi_rd_data;/* _DSI_RD_DATA_0 */ +uint dsi_wr_data;/* _DSI_WR_DATA_0 */ +uint dsi_pwr_ctrl;/* _DSI_POWER_CONTROL_0 */ +uint int_enable;/* _INT_ENABLE_0 */ +uint int_status;/* _INT_STATUS_0 */ +uint int_mask;/* _INT_MASK_0 */ +uint host_dsi_ctrl;/* _HOST_DSI_CONTROL_0 */ +uint dsi_ctrl;/* _DSI_CONTROL_0 */ +uint dsi_sol_delay;/* _DSI_SOL_DELAY_0 */ +uint dsi_max_threshold;/* _DSI_MAX_THRESHOLD_0 */ +uint dsi_trigger;/* _DSI_TRIGGER_0 */ +uint dsi_tx_crc;/* _DSI_TX_CRC_0 */ +uint dsi_status;/* _DSI_STATUS_0 */ +}; + +/* DSI init sequence register 0x01a ~ 0x022 */ +struct dsi_init_seq_reg { +/* Address 0x01a ~ 0x022 */ +uint dsi_init_seq_ctrl;/* _DSI_INIT_SEQ_CONTROL_0 */ +uint dsi_init_seq_data_0;/* _DSI_INIT_SEQ_DATA_0_0 */ +uint dsi_init_seq_data_1;/* _DSI_INIT_SEQ_DATA_1_0 */ +uint dsi_init_seq_data_2;/* _DSI_INIT_SEQ_DATA_2_0 */ +uint dsi_init_seq_data_3;/* _DSI_INIT_SEQ_DATA_3_0 */ +uint dsi_init_seq_data_4;/* _DSI_INIT_SEQ_DATA_4_0 */ +uint dsi_init_seq_data_5;/* _DSI_INIT_SEQ_DATA_5_0 */ +uint dsi_init_seq_data_6;/* _DSI_INIT_SEQ_DATA_6_0 */ +uint dsi_init_seq_data_7;/* _DSI_INIT_SEQ_DATA_7_0 */ +}; + +/* DSI packet sequence register 0x023 ~ 0x02e */ +struct dsi_pkt_seq_reg { +/* Address 0x023 ~ 0x02e */ +uint dsi_pkt_seq_0_lo;/* _DSI_PKT_SEQ_0_LO_0 */ +uint dsi_pkt_seq_0_hi;/* _DSI_PKT_SEQ_0_HI_0 */ +uint dsi_pkt_seq_1_lo;/* _DSI_PKT_SEQ_1_LO_0 */ +uint dsi_pkt_seq_1_hi;/* _DSI_PKT_SEQ_1_HI_0 */ +uint dsi_pkt_seq_2_lo;/* _DSI_PKT_SEQ_2_LO_0 */ +uint dsi_pkt_seq_2_hi;/* _DSI_PKT_SEQ_2_HI_0 */ +uint dsi_pkt_seq_3_lo;/* _DSI_PKT_SEQ_3_LO_0 */ +uint dsi_pkt_seq_3_hi;/* _DSI_PKT_SEQ_3_HI_0 */ +uint dsi_pkt_seq_4_lo;/* _DSI_PKT_SEQ_4_LO_0 */ +uint dsi_pkt_seq_4_hi;/* _DSI_PKT_SEQ_4_HI_0 */ +uint dsi_pkt_seq_5_lo;/* _DSI_PKT_SEQ_5_LO_0 */ +uint dsi_pkt_seq_5_hi;/* _DSI_PKT_SEQ_5_HI_0 */ +}; + +/* DSI packet length register 0x033 ~ 0x037 */ +struct dsi_pkt_len_reg { +/* Address 0x033 ~ 0x037 */ +uint dsi_dcs_cmds;/* _DSI_DCS_CMDS_0 */ +uint dsi_pkt_len_0_1;/* _DSI_PKT_LEN_0_1_0 */ +uint dsi_pkt_len_2_3;/* _DSI_PKT_LEN_2_3_0 */ +uint dsi_pkt_len_4_5;/* _DSI_PKT_LEN_4_5_0 */ +uint dsi_pkt_len_6_7;/* _DSI_PKT_LEN_6_7_0 */ +}; + +/* DSI PHY timing register 0x03c ~ 0x03f */ +struct dsi_timing_reg { +/* Address 0x03c ~ 0x03f */ +uint dsi_phy_timing_0;/* _DSI_PHY_TIMING_0_0 */ +uint dsi_phy_timing_1;/* _DSI_PHY_TIMING_1_0 */ +uint dsi_phy_timing_2;/* _DSI_PHY_TIMING_2_0 */ +uint dsi_bta_timing;/* _DSI_BTA_TIMING_0 */ +}; + +/* DSI timeout register 0x044 ~ 0x046 */ +struct dsi_timeout_reg { +/* Address 0x044 ~ 0x046 */ +uint dsi_timeout_0;/* _DSI_TIMEOUT_0_0 */ +uint dsi_timeout_1;/* _DSI_TIMEOUT_1_0 */ +uint dsi_to_tally;/* _DSI_TO_TALLY_0 */ +}; + +/* DSI PAD control register 0x04b ~ 0x04e */ +struct dsi_pad_ctrl_reg { +/* Address 0x04b ~ 0x04e */ +uint pad_ctrl;/* _PAD_CONTROL_0 */ +uint pad_ctrl_cd;/* _PAD_CONTROL_CD_0 */ +uint pad_cd_status;/* _PAD_CD_STATUS_0 */ +uint dsi_vid_mode_control;/* _DSI_VID_MODE_CONTROL_0 */ +}; + +/* Display Serial Interface (DSI_) regs */ +struct dsi_ctlr { +struct dsi_syncpt_reg syncpt;/* SYNCPT register 0x000 ~ 0x002 */ +uint reserved0[5 ];/* reserved_0[5] */ + +struct dsi_misc_reg misc;/* MISC register 0x008 ~ 0x015 */ +uint reserved1[4 ];/* reserved_1[4] */ + +struct dsi_init_seq_reg init;/* INIT register 0x01a ~ 0x022 */ +struct dsi_pkt_seq_reg pkt;/* PKT register 0x023 ~ 0x02e */ +uint reserved2[4 ];/* reserved_2[4] */ + +struct dsi_pkt_len_reg len;/* LEN registers 0x033 ~ 0x037 */ +uint reserved3[4 ];/* reserved_3[4] */ + +struct dsi_timing_reg ptiming;/* TIMING registers 0x03c ~ 0x03f */ +uint reserved4[4 ];/* reserved_4[4] */ + +struct dsi_timeout_reg timeout;/* TIMEOUT registers 0x044 ~ 0x046 */ +uint reserved5[4 ];/* reserved_5[4] */ + +struct dsi_pad_ctrl_reg pad;/* PAD registers 0x04b ~ 0x04e */ +}; + +#define DSI_POWER_CONTROL_ENABLE BIT(0) + +#define DSI_HOST_CONTROL_FIFO_RESET BIT(21) +#define DSI_HOST_CONTROL_CRC_RESET BIT(20) +#define DSI_HOST_CONTROL_TX_TRIG_SOL (0 << 12) +#define DSI_HOST_CONTROL_TX_TRIG_FIFO (1 << 12) +#define DSI_HOST_CONTROL_TX_TRIG_HOST (2 << 12) +#define DSI_HOST_CONTROL_RAW BIT(6) +#define DSI_HOST_CONTROL_HS BIT(5) +#define DSI_HOST_CONTROL_FIFO_SEL BIT(4) +#define DSI_HOST_CONTROL_IMM_BTA BIT(3) +#define DSI_HOST_CONTROL_PKT_BTA BIT(2) +#define DSI_HOST_CONTROL_CS BIT(1) +#define DSI_HOST_CONTROL_ECC BIT(0) + +#define DSI_CONTROL_HS_CLK_CTRL BIT(20) +#define DSI_CONTROL_CHANNEL (c) (((c) & 0x3) << 16) +#define DSI_CONTROL_FORMAT (f) (((f) & 0x3) << 12) +#define DSI_CONTROL_TX_TRIG (x) (((x) & 0x3) << 8) +#define DSI_CONTROL_LANES (n) (((n) & 0x3) << 4) +#define DSI_CONTROL_DCS_ENABLE BIT(3) +#define DSI_CONTROL_SOURCE (s) (((s) & 0x1) << 2) +#define DSI_CONTROL_VIDEO_ENABLE BIT(1) +#define DSI_CONTROL_HOST_ENABLE BIT(0) + +#define DSI_TRIGGER_HOST BIT(1) +#define DSI_TRIGGER_VIDEO BIT(0) + +#define DSI_STATUS_IDLE BIT(10) +#define DSI_STATUS_UNDERFLOW BIT(9) +#define DSI_STATUS_OVERFLOW BIT(8) + +#define DSI_TIMING_FIELD (value, period, hwinc) \ + ((DIV_ROUND_CLOSEST(value, period) - (hwinc)) & 0xff) + +#define DSI_TIMEOUT_LRX (x) (((x) & 0xffff) << 16) +#define DSI_TIMEOUT_HTX (x) (((x) & 0xffff) << 0) +#define DSI_TIMEOUT_PR (x) (((x) & 0xffff) << 16) +#define DSI_TIMEOUT_TA (x) (((x) & 0xffff) << 0) + +#define DSI_TALLY_TA (x) (((x) & 0xff) << 16) +#define DSI_TALLY_LRX (x) (((x) & 0xff) << 8) +#define DSI_TALLY_HTX (x) (((x) & 0xff) << 0) + +#define DSI_PAD_CONTROL_PAD_PULLDN_ENAB (x) (((x) & 0x1) << 28) +#define DSI_PAD_CONTROL_PAD_SLEWUPADJ (x) (((x) & 0x7) << 24) +#define DSI_PAD_CONTROL_PAD_SLEWDNADJ (x) (((x) & 0x7) << 20) +#define DSI_PAD_CONTROL_PAD_PREEMP_EN (x) (((x) & 0x1) << 19) +#define DSI_PAD_CONTROL_PAD_PDIO_CLK (x) (((x) & 0x1) << 18) +#define DSI_PAD_CONTROL_PAD_PDIO (x) (((x) & 0x3) << 16) +#define DSI_PAD_CONTROL_PAD_LPUPADJ (x) (((x) & 0x3) << 14) +#define DSI_PAD_CONTROL_PAD_LPDNADJ (x) (((x) & 0x3) << 12) + +/* +* pixel format as used in the DSI_CONTROL_FORMAT field +*/ +enum tegra_dsi_format { +TEGRA_DSI_FORMAT_16P , +TEGRA_DSI_FORMAT_18NP , +TEGRA_DSI_FORMAT_18P , +TEGRA_DSI_FORMAT_24P , +}; + +#endif /* __ASM_ARCH_TEGRA_DSI_H */
drivers/video/tegra20/Kconfig +9 -0
@@ -6,3 +6,12 @@ config VIDEO_TEGRA20 other options such as HDMI. Only the LCD is supported in U-Boot. This option enables this support which can be used on devices which have an LCD display connected. + +config VIDEO_DSI_TEGRA30 + bool "Enable Tegra 30 DSI support" + depends on PANEL && DM_GPIO + select VIDEO_TEGRA20 + select VIDEO_MIPI_DSI + help + T30 has native support for DSI panels. This option enables support + for such panels which can be used on endeavoru and tf600t.
drivers/video/tegra20/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ obj-$(CONFIG_VIDEO_TEGRA20) += tegra-dc.o +obj-$(CONFIG_VIDEO_DSI_TEGRA30) += tegra-dsi.o mipi-phy.o
drivers/video/tegra20/dsi.h new file +126 -0
126 lines not on this page · raw message
drivers/video/tegra20/mipi-phy.c new file +134 -0
134 lines not on this page · raw message
drivers/video/tegra20/mipi-phy.h new file +48 -0
48 lines not on this page · raw message
drivers/video/tegra20/tegra-dsi.c new file +769 -0
769 lines not on this page · raw message
Signature · 1 line
2.37.2
PATCH 10/11 simple_panel: add support for get_display_timing
In reply to Svyatoslav RyhelSome cases may require passing display timings from panel driver. To handle such cases support parsing device tree panel node for timing subnode.
--- drivers/video/simple_panel.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/video/simple_panel.c +10 -0
@@ -48,6 +48,15 @@ static int simple_panel_set_backlight(struct udevice *dev, int percent)return 0 ; } +static int simple_panel_get_display_timing (struct udevice *dev, +struct display_timing *timings) +{ +const void *blob = gd->fdt_blob; + +return fdtdec_decode_display_timing (blob,dev_of_offset (dev), +0 , timings); +} +static int simple_panel_of_to_plat (struct udevice *dev) {struct simple_panel_priv *priv =dev_get_priv (dev);
@@ -102,6 +111,7 @@ static int simple_panel_probe(struct udevice *dev)static const struct panel_ops simple_panel_ops = { .enable_backlight = simple_panel_enable_backlight, .set_backlight = simple_panel_set_backlight, + .get_display_timing = simple_panel_get_display_timing, };static const struct udevice_id simple_panel_ids[] = {
Signature · 1 line
2.37.2
PATCH 11/11 simple_panel: support simple MIPI DSI panels
In reply to Svyatoslav RyhelRe-use simple panel driver for MIPI DSI panels
which do not require additional DSI commands
for setup.
--- drivers/video/simple_panel.c | 37 ++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/video/simple_panel.c +33 -4
@@ -8,6 +8,7 @@#include <backlight.h> #include <dm.h> #include <log.h> +#include <mipi_dsi.h> #include <panel.h> #include <asm/gpio.h> #include <power/regulator.h>
@@ -18,6 +19,19 @@ struct simple_panel_priv {struct gpio_desc enable; }; +/* List of supported DSI panels */ +enum { +PANEL_NON_DSI , +PANASONIC_VVX10F004B00 , +}; + +static const struct mipi_dsi_panel_plat panasonic_vvx10f004b00 = { + .mode_flags =MIPI_DSI_MODE_VIDEO |MIPI_DSI_MODE_VIDEO_SYNC_PULSE | +MIPI_DSI_CLOCK_NON_CONTINUOUS , + .format =MIPI_DSI_FMT_RGB888 , + .lanes =4 , +}; +static int simple_panel_enable_backlight (struct udevice *dev) {struct simple_panel_priv *priv =dev_get_priv (dev);
@@ -96,6 +110,8 @@ static int simple_panel_of_to_plat(struct udevice *dev)static int simple_panel_probe (struct udevice *dev) {struct simple_panel_priv *priv =dev_get_priv (dev); +struct mipi_dsi_panel_plat *plat =dev_get_plat (dev); +const u32 dsi_data =dev_get_driver_data (dev);int ret;if (IS_ENABLED (CONFIG_DM_REGULATOR ) && priv->reg) {
@@ -105,6 +121,16 @@ static int simple_panel_probe(struct udevice *dev)return ret; } +switch (dsi_data) { +case PANASONIC_VVX10F004B00 : +memcpy (plat, &panasonic_vvx10f004b00, +sizeof (panasonic_vvx10f004b00)); +break ; +case PANEL_NON_DSI : +default : +break ; + } +return 0 ; }
@@ -123,15 +149,18 @@ static const struct udevice_id simple_panel_ids[] = { { .compatible = "lg,lb070wv8" }, { .compatible = "sharp,lq123p1jx31" }, { .compatible = "boe,nv101wxmn51" }, + { .compatible = "panasonic,vvx10f004b00", + .data = PANASONIC_VVX10F004B00 }, { } };U_BOOT_DRIVER (simple_panel) = { - .name ="simple_panel" , - .id =UCLASS_PANEL , - .of_match = simple_panel_ids, - .ops = &simple_panel_ops, + .name ="simple_panel" , + .id =UCLASS_PANEL , + .of_match = simple_panel_ids, + .ops = &simple_panel_ops, .of_to_plat = simple_panel_of_to_plat, .probe = simple_panel_probe, .priv_auto =sizeof (struct simple_panel_priv ), + .plat_auto =sizeof (struct mipi_dsi_panel_plat ), };
Signature · 1 line
2.37.2
Greetings Tom!
I was thinking about what you asked about ACKs/Tested-By/Reviewed-By's.
Before these patches, DC and video support was available only for T20, so the main concern is regressions towards T20. Thierry has no T20 boards at all which is rather unfortunate.
I have made a list of T20 boards which use driver I have patched:
- seaboard
- harmony
- ventana (we tested this patches on TF101 which is almost full ventana copy)
- paz00
- colibri_t20
- tec
- medcom-wide
Maybe someone from the paz00 community will agree to help. Patches are made in a way that no changes into existing setups are needed.
Patchset additionally includes 2 changes to the simple-panel driver. It was written by Simon Glass, so maybe Simon would like to take a look at changes.
P. S. Unfortunately I can not show the full potential of these patches right now, they will shine only once I will submit T30 devices support, which rely on video out as the main output source.
пн, 20 лют. 2023 р. о 11:54 Svyatoslav Ryhel <[email protected]> пише:
Quoted 60 lines
This patch set is dedicated to improvement of video support on T20 and T30 devices. It contains:
- DC driver improvements (T30 support was added into existing T20 DC driver, it was moved into own folder, added support of reading clocks from dts, improved work with panel ops and implemented native 180 degree panel rotation support)
- DSI driver bring up (driver is based on mainline Linux one with minor adjustments, only T30 tested)
- Simple panel driver tweaks (added
get_display_timingops and implemented simple MIPI DSI panels support)Marcel Ziswiler (1):
tegra: lcd: video: integrate display driver for t30Svyatoslav Ryhel (10):
video: move tegra dc driver into own folder
video: tegra-dc: get clocks from device tree
video: tegra-dc: request timings from panel driver first
video: tegra-dc: assign regmap directly
video: tegra-dc: add 180 degree panel rotation
video: tegra-dc: addpanel_set_backlightcall
video: tegra-dc: pass DC regmap to internal devices
video: tegra20: add DSI controller driver
simple_panel: add support forget_display_timing
simple_panel: support simple MIPI DSI panelsarch/arm/dts/tegra30-u-boot.dtsi | 9 + arch/arm/include/asm/arch-tegra/dc.h | 8 + arch/arm/include/asm/arch-tegra30/display.h | 28 + arch/arm/include/asm/arch-tegra30/dsi.h | 197 +++++ arch/arm/include/asm/arch-tegra30/pwm.h | 13 + drivers/video/Kconfig | 11 +- drivers/video/Makefile | 2 +- drivers/video/simple_panel.c | 47 +- drivers/video/tegra20/Kconfig | 17 + drivers/video/tegra20/Makefile | 4 + drivers/video/tegra20/dsi.h | 126 +++ drivers/video/tegra20/mipi-phy.c | 134 +++ drivers/video/tegra20/mipi-phy.h | 48 ++ drivers/video/{tegra.c => tegra20/tegra-dc.c} | 123 ++- drivers/video/tegra20/tegra-dsi.c | 769 ++++++++++++++++++ 15 files changed, 1487 insertions(+), 49 deletions(-) create mode 100644 arch/arm/include/asm/arch-tegra30/display.h create mode 100644 arch/arm/include/asm/arch-tegra30/dsi.h create mode 100644 arch/arm/include/asm/arch-tegra30/pwm.h create mode 100644 drivers/video/tegra20/Kconfig create mode 100644 drivers/video/tegra20/Makefile create mode 100644 drivers/video/tegra20/dsi.h create mode 100644 drivers/video/tegra20/mipi-phy.c create mode 100644 drivers/video/tegra20/mipi-phy.h rename drivers/video/{tegra.c => tegra20/tegra-dc.c} (82%) create mode 100644 drivers/video/tegra20/tegra-dsi.c--
2.37.2