drm/bridge: tc358768: various fixes on PLL calculation and DSI timings
Subsystems (3)
cover drm/bridge: tc358768: various fixes on PLL calculation and DSI timings
From: Francesco Dolcini <[email protected]>
This series includes multiple fixes on the tc358768 parallel RGB to DSI driver.
With the following changes I am able to have a stable display output using a TI SN65DSI83 (DSI-LVDS bridge) and a 1280 x 800 LVDS display panel and the register values are coherent with Toshiba documentation and configuration spreadsheet, I was not able to test any other display sink.
= DSI Video Mode =
The driver uses the MIPI_DSI_MODE_LPM flag not correctly, because of that no HS Video is sent at all when this flag is set by the DSI slave.
= DSI Timing Parameters =
Multiple DSI timing parameters are not correct and this was leading to black or not stable images on some display output. The new formulas were verified with the datasheet and a configuration spread sheet from Toshiba.
I did split the change in multiple commits, I can squash all of them together if this is considered better for any reason, including bisect-ability.
= PLL computation =
Two issues on the PLL computation, one is a required fix to have the bridge working when the parallel RGB input width is not 24, the second one is just following a prescription from the Toshiba documentation. In my test it was not making any difference.
Francesco Dolcini (9):
drm/bridge: tc358768: always enable HS video mode drm/bridge: tc358768: fix PLL parameters computation drm/bridge: tc358768: fix PLL target frequency drm/bridge: tc358768: fix TCLK_ZEROCNT computation drm/bridge: tc358768: fix TCLK_TRAILCNT computation drm/bridge: tc358768: fix THS_ZEROCNT computation drm/bridge: tc358768: fix TXTAGOCNT computation drm/bridge: tc358768: fix THS_TRAILCNT computation drm/bridge: tc358768: remove unused variable
drivers/gpu/drm/bridge/tc358768.c | 53 +++++++++++++++++-------------- 1 file changed, 30 insertions(+), 23 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/9 drm/bridge: tc358768: always enable HS video mode
From: Francesco Dolcini <[email protected]>
Always enable HS video mode setting the TXMD bit, without this change no video output is present with DSI sinks that are setting MIPI_DSI_MODE_LPM flag (tested with LT8912B DSI-HDMI bridge).
Previously the driver was enabling HS mode only when the DSI sink was not explicitly setting the MIPI_DSI_MODE_LPM, however this is not correct.
The MIPI_DSI_MODE_LPM is supposed to indicate that the sink is willing to receive data in low power mode, however clearing the TC358768_DSI_CONTROL_TXMD bit will make the TC358768 send video in LP mode that is not the intended behavior.
--- drivers/gpu/drm/bridge/tc358768.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/bridge/tc358768.c +1 -2
@@ -866,8 +866,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) val =TC358768_DSI_CONFW_MODE_SET |TC358768_DSI_CONFW_ADDR_DSI_CONTROL ; val |= (dsi_dev->lanes -1 ) <<1 ; -if (!(dsi_dev->mode_flags &MIPI_DSI_MODE_LPM )) - val |=TC358768_DSI_CONTROL_TXMD ; + val |=TC358768_DSI_CONTROL_TXMD ;if (!(mode_flags &MIPI_DSI_CLOCK_NON_CONTINUOUS )) val |=TC358768_DSI_CONTROL_HSCKMD ;
Signature · 1 line
2.25.1
Re: [PATCH v1 1/9] drm/bridge: tc358768: always enable HS video mode
Quoted 37 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
Always enable HS video mode setting the TXMD bit, without this change no video output is present with DSI sinks that are setting
MIPI_DSI_MODE_LPMflag (tested with LT8912B DSI-HDMI bridge).Previously the driver was enabling HS mode only when the DSI sink was not explicitly setting the
MIPI_DSI_MODE_LPM, however this is not correct.The
MIPI_DSI_MODE_LPMis supposed to indicate that the sink is willing to receive data in low power mode, however clearing theTC358768_DSI_CONTROL_TXMDbit will make the TC358768 send video in LP mode that is not the intended behavior.Fixes ff1ca6397b1d ("drm/bridge: Add tc358768 driver")Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/bridge/tc358768.c +1
-3@@ -866,8 +866,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) val =TC358768_DSI_CONFW_MODE_SET |TC358768_DSI_CONFW_ADDR_DSI_CONTROL ; val |= (dsi_dev->lanes -1 ) <<1 ; -if (!(dsi_dev->mode_flags &MIPI_DSI_MODE_LPM )) - val |=TC358768_DSI_CONTROL_TXMD ; + val |=TC358768_DSI_CONTROL_TXMD ;if (!(mode_flags &MIPI_DSI_CLOCK_NON_CONTINUOUS )) val |=TC358768_DSI_CONTROL_HSCKMD ; --
Quoted 2 lines
2.25.1
PATCH 2/9 drm/bridge: tc358768: fix PLL parameters computation
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
According to Toshiba documentation the PLL input clock after the divider should be not less than 4MHz, fix the PLL parameters computation accordingly.
--- drivers/gpu/drm/bridge/tc358768.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/tc358768.c +5 -1
@@ -334,13 +334,17 @@ static int tc358768_calc_pll(struct tc358768_priv *priv,u32 fbd;for (fbd =0 ; fbd <512 ; ++fbd) { -u32 pll, diff; +u32 pll, diff, pll_in; pll = (u32 )div_u64 ((u64 )refclk * (fbd +1 ), divisor);if (pll >= max_pll || pll < min_pll)continue ; + pll_in = (u32 )div_u64 ((u64 )refclk, prd +1 ); +if (pll_in <4000000 ) +continue ; + diff =max (pll, target_pll) -min (pll, target_pll);if (diff < best_diff) {
Signature · 1 line
2.25.1
Re: [PATCH v1 2/9] drm/bridge: tc358768: fix PLL parameters computation
Quoted 37 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
According to Toshiba documentation the PLL input clock after the divider should be not less than 4MHz, fix the PLL parameters computation accordingly.
Fixes ff1ca6397b1d ("drm/bridge: Add tc358768 driver")Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/tc358768.c +5
-2@@ -334,13 +334,17 @@ static int tc358768_calc_pll(struct tc358768_priv *priv,u32 fbd;for (fbd =0 ; fbd <512 ; ++fbd) { -u32 pll, diff; +u32 pll, diff, pll_in; pll = (u32 )div_u64 ((u64 )refclk * (fbd +1 ), divisor);if (pll >= max_pll || pll < min_pll)continue ; + pll_in = (u32 )div_u64 ((u64 )refclk, prd +1 ); +if (pll_in <4000000 ) +continue ; + diff =max (pll, target_pll) -min (pll, target_pll);if (diff < best_diff) { --
Quoted 2 lines
2.25.1
PATCH 3/9 drm/bridge: tc358768: fix PLL target frequency
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
Correctly compute the PLL target frequency, the current formula works correctly only when the input bus width is 24bit, actually to properly compute the PLL target frequency what is relevant is the bits-per-pixel on the DSI link.
No regression expected since the DSI format is currently hard-coded as MIPI_DSI_FMT_RGB888.
--- drivers/gpu/drm/bridge/tc358768.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/tc358768.c +5 -3
@@ -146,6 +146,7 @@ struct tc358768_priv {u32 pd_lines;/* number of Parallel Port Input Data Lines */ u32 dsi_lanes;/* number of DSI Lanes */ +u32 dsi_bpp;/* number of Bits Per Pixel over DSI */ /* Parameters for PLL programming */ u32 fbd;/* PLL feedback divider */
@@ -284,12 +285,12 @@ static void tc358768_hw_disable(struct tc358768_priv *priv)static u32 tc358768_pll_to_pclk (struct tc358768_priv *priv,u32 pll_clk) { -return (u32 )div_u64 ((u64 )pll_clk * priv->dsi_lanes, priv->pd_lines); +return (u32 )div_u64 ((u64 )pll_clk * priv->dsi_lanes, priv->dsi_bpp); }static u32 tc358768_pclk_to_pll (struct tc358768_priv *priv,u32 pclk) { -return (u32 )div_u64 ((u64 )pclk * priv->pd_lines, priv->dsi_lanes); +return (u32 )div_u64 ((u64 )pclk * priv->dsi_bpp, priv->dsi_lanes); } static int tc358768_calc_pll(struct tc358768_priv *priv,
@@ -426,6 +427,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, priv->output.panel = panel; priv->dsi_lanes = dev->lanes; + priv->dsi_bpp =mipi_dsi_pixel_format_to_bpp (dev->format);/* get input ep (port0/endpoint0) */ ret = -EINVAL ;
@@ -437,7 +439,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, }if (ret) - priv->pd_lines =mipi_dsi_pixel_format_to_bpp (dev->format); + priv->pd_lines = priv->dsi_bpp;drm_bridge_add (&priv->bridge);
Signature · 1 line
2.25.1
Re: [PATCH v1 3/9] drm/bridge: tc358768: fix PLL target frequency
Quoted 62 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
Correctly compute the PLL target frequency, the current formula works correctly only when the input bus width is 24bit, actually to properly compute the PLL target frequency what is relevant is the bits-per-pixel on the DSI link.
No regression expected since the DSI format is currently hard-coded as
MIPI_DSI_FMT_RGB888.Fixes ff1ca6397b1d ("drm/bridge: Add tc358768 driver")Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358768.c +5
-4@@ -146,6 +146,7 @@ struct tc358768_priv {u32 pd_lines;/* number of Parallel Port Input Data Lines */ u32 dsi_lanes;/* number of DSI Lanes */ +u32 dsi_bpp;/* number of Bits Per Pixel over DSI */ /* Parameters for PLL programming */ u32 fbd;/* PLL feedback divider */ @@ -284,12 +285,12 @@ static void tc358768_hw_disable(struct tc358768_priv *priv)static u32 tc358768_pll_to_pclk (struct tc358768_priv *priv,u32 pll_clk) { -return (u32 )div_u64 ((u64 )pll_clk * priv->dsi_lanes, priv->pd_lines); +return (u32 )div_u64 ((u64 )pll_clk * priv->dsi_lanes, priv->dsi_bpp); }static u32 tc358768_pclk_to_pll (struct tc358768_priv *priv,u32 pclk) { -return (u32 )div_u64 ((u64 )pclk * priv->pd_lines, priv->dsi_lanes); +return (u32 )div_u64 ((u64 )pclk * priv->dsi_bpp, priv->dsi_lanes); } static int tc358768_calc_pll(struct tc358768_priv *priv,@@ -426,6 +427,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, priv->output.panel = panel; priv->dsi_lanes = dev->lanes; + priv->dsi_bpp =mipi_dsi_pixel_format_to_bpp (dev->format);/* get input ep (port0/endpoint0) */ ret = -EINVAL ;@@ -437,7 +439,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, }if (ret) - priv->pd_lines =mipi_dsi_pixel_format_to_bpp (dev->format); + priv->pd_lines = priv->dsi_bpp;drm_bridge_add (&priv->bridge); --
Quoted 2 lines
2.25.1
PATCH 4/9 drm/bridge: tc358768: fix TCLK_ZEROCNT computation
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
Correct computation of TCLK_ZEROCNT register.
This register must be set to a value that ensure that (TCLK-PREPARECNT + TCLK-ZERO) > 300ns
with the actual value of (TCLK-PREPARECNT + TCLK-ZERO) being
(1 to 2) + (TCLK_ZEROCNT + 1)) x HSByteClkCycle + (PHY output delay)
with PHY output delay being about
(2 to 3) x MIPIBitClk cycle in the BitClk conversion.
--- drivers/gpu/drm/bridge/tc358768.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/tc358768.c +4 -4
@@ -742,10 +742,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)/* 38ns < TCLK_PREPARE < 95ns */ val =tc358768_ns_to_cnt (65 , dsibclk_nsk) -1 ; -/* TCLK_PREPARE > 300ns */ - val2 =tc358768_ns_to_cnt (300 +tc358768_to_ns (3 * ui_nsk), - dsibclk_nsk); - val |= (val2 -tc358768_to_ns (phy_delay_nsk - dsibclk_nsk)) <<8 ; +/* TCLK_PREPARE + TCLK_ZERO > 300ns */ + val2 =tc358768_ns_to_cnt (300 -tc358768_to_ns (2 * ui_nsk), + dsibclk_nsk) -2 ; + val |= val2 <<8 ;dev_dbg (priv->dev,"TCLK_HEADERCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_TCLK_HEADERCNT , val);
Signature · 1 line
2.25.1
Re: [PATCH v1 4/9] drm/bridge: tc358768: fix TCLK_ZEROCNT computation
Quoted 42 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
Correct computation of
TCLK_ZEROCNTregister.This register must be set to a value that ensure that (TCLK-PREPARECNT + TCLK-ZERO) > 300ns
with the actual value of (TCLK-PREPARECNT + TCLK-ZERO) being
(1 to 2) + (
TCLK_ZEROCNT+ 1)) x HSByteClkCycle + (PHY output delay)with PHY output delay being about
(2 to 3) x MIPIBitClk cycle in the BitClk conversion.
Fixes ff1ca6397b1d ("drm/bridge: Add tc358768 driver")Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/bridge/tc358768.c +4
-5@@ -742,10 +742,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)/* 38ns < TCLK_PREPARE < 95ns */ val =tc358768_ns_to_cnt (65 , dsibclk_nsk) -1 ; -/* TCLK_PREPARE > 300ns */ - val2 =tc358768_ns_to_cnt (300 +tc358768_to_ns (3 * ui_nsk), - dsibclk_nsk); - val |= (val2 -tc358768_to_ns (phy_delay_nsk - dsibclk_nsk)) <<8 ; +/* TCLK_PREPARE + TCLK_ZERO > 300ns */ + val2 =tc358768_ns_to_cnt (300 -tc358768_to_ns (2 * ui_nsk), + dsibclk_nsk) -2 ; + val |= val2 <<8 ;dev_dbg (priv->dev,"TCLK_HEADERCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_TCLK_HEADERCNT , val); --
Quoted 2 lines
2.25.1
PATCH 5/9 drm/bridge: tc358768: fix TCLK_TRAILCNT computation
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
Correct computation of TCLK_TRAILCNT register.
The driver does not implement non-continuous clock mode, so the actual value doesn't make a practical difference yet. However this change also ensures that the value does not write to reserved registers bits in case of under/overflow.
This register must be set to a value that ensures that
TCLK-TRAIL > 60ns
and
TEOT <= (105 ns + 12 x UI)
with the actual value of TCLK-TRAIL being
(TCLK_TRAILCNT + (1 to 2)) xHSByteClkCycle +
(2 + (1 to 2)) * HSBYTECLKCycle - (PHY output delay)
with PHY output delay being about
(2 to 3) x MIPIBitClk cycle in the BitClk conversion.
--- drivers/gpu/drm/bridge/tc358768.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/tc358768.c +5 -3
@@ -9,6 +9,7 @@#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/kernel.h> +#include <linux/minmax.h> #include <linux/module.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h>
@@ -638,6 +639,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)struct mipi_dsi_device *dsi_dev = priv->output.dev;unsigned long mode_flags = dsi_dev->mode_flags;u32 val, val2, lptxcnt, hact, data_type; +s32 raw_val;const struct drm_display_mode *mode;u32 dsibclk_nsk, dsiclk_nsk, ui_nsk, phy_delay_nsk;u32 dsiclk, dsibclk, video_start;
@@ -749,9 +751,9 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)dev_dbg (priv->dev,"TCLK_HEADERCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_TCLK_HEADERCNT , val); -/* TCLK_TRAIL > 60ns + 3*UI */ - val =60 +tc358768_to_ns (3 * ui_nsk); - val =tc358768_ns_to_cnt (val, dsibclk_nsk) -5 ; +/* TCLK_TRAIL > 60ns AND TEOT <= 105 ns + 12*UI */ + raw_val =tc358768_ns_to_cnt (60 +tc358768_to_ns (2 * ui_nsk), dsibclk_nsk) -5 ; + val =clamp (raw_val,0 ,127 );dev_dbg (priv->dev,"TCLK_TRAILCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_TCLK_TRAILCNT , val);
Signature · 1 line
2.25.1
Re: [PATCH v1 5/9] drm/bridge: tc358768: fix TCLK_TRAILCNT computation
Quoted 65 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
Correct computation of
TCLK_TRAILCNTregister.The driver does not implement non-continuous clock mode, so the actual value doesn't make a practical difference yet. However this change also ensures that the value does not write to reserved registers bits in case of under/overflow.
This register must be set to a value that ensures that
TCLK-TRAIL > 60ns
and
TEOT <= (105 ns + 12 x UI)with the actual value of TCLK-TRAIL being
(
TCLK_TRAILCNT+ (1 to 2)) xHSByteClkCycle +
(2 + (1 to 2)) * HSBYTECLKCycle - (PHY output delay)with PHY output delay being about
(2 to 3) x MIPIBitClk cycle in the BitClk conversion.
Fixes ff1ca6397b1d ("drm/bridge: Add tc358768 driver")Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358768.c +5
-4@@ -9,6 +9,7 @@#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/kernel.h> +#include <linux/minmax.h> #include <linux/module.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> @@ -638,6 +639,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)struct mipi_dsi_device *dsi_dev = priv->output.dev;unsigned long mode_flags = dsi_dev->mode_flags;u32 val, val2, lptxcnt, hact, data_type; +s32 raw_val;const struct drm_display_mode *mode;u32 dsibclk_nsk, dsiclk_nsk, ui_nsk, phy_delay_nsk;u32 dsiclk, dsibclk, video_start;@@ -749,9 +751,9 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)dev_dbg (priv->dev,"TCLK_HEADERCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_TCLK_HEADERCNT , val); -/* TCLK_TRAIL > 60ns + 3*UI */ - val =60 +tc358768_to_ns (3 * ui_nsk); - val =tc358768_ns_to_cnt (val, dsibclk_nsk) -5 ; +/* TCLK_TRAIL > 60ns AND TEOT <= 105 ns + 12*UI */ + raw_val =tc358768_ns_to_cnt (60 +tc358768_to_ns (2 * ui_nsk), dsibclk_nsk) -5 ; + val =clamp (raw_val,0 ,127 );dev_dbg (priv->dev,"TCLK_TRAILCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_TCLK_TRAILCNT , val); --
Quoted 2 lines
2.25.1
PATCH 6/9 drm/bridge: tc358768: fix THS_ZEROCNT computation
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
Correct computation of THS_ZEROCNT register.
This register must be set to a value that ensure that THS_PREPARE + THS_ZERO > 145ns + 10*UI
with the actual value of (THS_PREPARE + THS_ZERO) being
((1 to 2) + 1 + (TCLK_ZEROCNT + 1) + (3 to 4)) x ByteClk cycle +
+ HSByteClk x (2 + (1 to 2)) + (PHY delay)
with PHY delay being about
(8 + (5 to 6)) x MIPIBitClk cycle in the BitClk conversion.
--- drivers/gpu/drm/bridge/tc358768.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/tc358768.c +4 -3
@@ -760,9 +760,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)/* 40ns + 4*UI < THS_PREPARE < 85ns + 6*UI */ val =50 +tc358768_to_ns (4 * ui_nsk); val =tc358768_ns_to_cnt (val, dsibclk_nsk) -1 ; -/* THS_ZERO > 145ns + 10*UI */ - val2 =tc358768_ns_to_cnt (145 -tc358768_to_ns (ui_nsk), dsibclk_nsk); - val |= (val2 -tc358768_to_ns (phy_delay_nsk)) <<8 ; +/* THS_PREPARE + THS_ZERO > 145ns + 10*UI */ + raw_val =tc358768_ns_to_cnt (145 -tc358768_to_ns (3 * ui_nsk), dsibclk_nsk) -10 ; + val2 =clamp (raw_val,0 ,127 ); + val |= val2 <<8 ;dev_dbg (priv->dev,"THS_HEADERCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_THS_HEADERCNT , val);
Signature · 1 line
2.25.1
Re: [PATCH v1 6/9] drm/bridge: tc358768: fix THS_ZEROCNT computation
Quoted 42 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
Correct computation of
THS_ZEROCNTregister.This register must be set to a value that ensure that
THS_PREPARE+THS_ZERO> 145ns + 10*UIwith the actual value of (
THS_PREPARE+THS_ZERO) being((1 to 2) + 1 + (
TCLK_ZEROCNT+ 1) + (3 to 4)) x ByteClk cycle +
+ HSByteClk x (2 + (1 to 2)) + (PHY delay)with PHY delay being about
(8 + (5 to 6)) x MIPIBitClk cycle in the BitClk conversion.
Fixes ff1ca6397b1d ("drm/bridge: Add tc358768 driver")Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358768.c +4
-4@@ -760,9 +760,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)/* 40ns + 4*UI < THS_PREPARE < 85ns + 6*UI */ val =50 +tc358768_to_ns (4 * ui_nsk); val =tc358768_ns_to_cnt (val, dsibclk_nsk) -1 ; -/* THS_ZERO > 145ns + 10*UI */ - val2 =tc358768_ns_to_cnt (145 -tc358768_to_ns (ui_nsk), dsibclk_nsk); - val |= (val2 -tc358768_to_ns (phy_delay_nsk)) <<8 ; +/* THS_PREPARE + THS_ZERO > 145ns + 10*UI */ + raw_val =tc358768_ns_to_cnt (145 -tc358768_to_ns (3 * ui_nsk), dsibclk_nsk) -10 ; + val2 =clamp (raw_val,0 ,127 ); + val |= val2 <<8 ;dev_dbg (priv->dev,"THS_HEADERCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_THS_HEADERCNT , val); --
Quoted 2 lines
2.25.1
PATCH 7/9 drm/bridge: tc358768: fix TXTAGOCNT computation
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
Correct computation of TXTAGOCNT register.
This register must be set to a value that ensure that the TTA-GO period = (4 x TLPX)
with the actual value of TTA-GO being
4 x (TXTAGOCNT + 1) x (HSByteClk cycle)
--- drivers/gpu/drm/bridge/tc358768.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/tc358768.c +1 -1
@@ -795,7 +795,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)/* TXTAGOCNT[26:16] RXTASURECNT[10:0] */ val =tc358768_to_ns ((lptxcnt +1 ) * dsibclk_nsk *4 ); - val =tc358768_ns_to_cnt (val, dsibclk_nsk) -1 ; + val =tc358768_ns_to_cnt (val, dsibclk_nsk) /4 -1 ; val2 =tc358768_ns_to_cnt (tc358768_to_ns ((lptxcnt +1 ) * dsibclk_nsk), dsibclk_nsk) -2 ; val = val <<16 | val2;
Signature · 1 line
2.25.1
Re: [PATCH v1 7/9] drm/bridge: tc358768: fix TXTAGOCNT computation
Quoted 32 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
Correct computation of TXTAGOCNT register.
This register must be set to a value that ensure that the TTA-GO period = (4 x TLPX)
with the actual value of TTA-GO being
4 x (TXTAGOCNT + 1) x (HSByteClk cycle)
Fixes ff1ca6397b1d ("drm/bridge: Add tc358768 driver")Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/bridge/tc358768.c +1
-2@@ -795,7 +795,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)/* TXTAGOCNT[26:16] RXTASURECNT[10:0] */ val =tc358768_to_ns ((lptxcnt +1 ) * dsibclk_nsk *4 ); - val =tc358768_ns_to_cnt (val, dsibclk_nsk) -1 ; + val =tc358768_ns_to_cnt (val, dsibclk_nsk) /4 -1 ; val2 =tc358768_ns_to_cnt (tc358768_to_ns ((lptxcnt +1 ) * dsibclk_nsk), dsibclk_nsk) -2 ; val = val <<16 | val2; --
Quoted 2 lines
2.25.1
PATCH 8/9 drm/bridge: tc358768: fix THS_TRAILCNT computation
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
Correct computation of THS_TRAILCNT register.
This register must be set to a value that ensure that THS_TRAIL > 60 ns + 4 x UI
andTHS_TRAIL > 8 x UI
andTHS_TRAIL < TEOT
with
TEOT = 105 ns + (12 x UI)
with the actual value of THS_TRAIL being
(1 + THS_TRAILCNT) x ByteClk cycle + ((1 to 2) + 2) xHSBYTECLK cycle +
- (PHY output delay)
with PHY output delay being about
(8 + (5 to 6)) x MIPIBitClk cycle in the BitClk conversion.
--- drivers/gpu/drm/bridge/tc358768.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/tc358768.c +4 -3
@@ -779,9 +779,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)dev_dbg (priv->dev,"TCLK_POSTCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_TCLK_POSTCNT , val); -/* 60ns + 4*UI < THS_PREPARE < 105ns + 12*UI */ - val =tc358768_ns_to_cnt (60 +tc358768_to_ns (15 * ui_nsk), - dsibclk_nsk) -5 ; +/* max(60ns + 4*UI, 8*UI) < THS_TRAILCNT < 105ns + 12*UI */ + raw_val =tc358768_ns_to_cnt (60 +tc358768_to_ns (18 * ui_nsk), + dsibclk_nsk) -4 ; + val =clamp (raw_val,0 ,15 );dev_dbg (priv->dev,"THS_TRAILCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_THS_TRAILCNT , val);
Signature · 1 line
2.25.1
Re: [PATCH v1 8/9] drm/bridge: tc358768: fix THS_TRAILCNT computation
Quoted 48 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
Correct computation of
THS_TRAILCNTregister.This register must be set to a value that ensure that
THS_TRAIL> 60 ns + 4 x UI
andTHS_TRAIL> 8 x UI
andTHS_TRAIL< TEOT
with
TEOT = 105 ns + (12 x UI)with the actual value of
THS_TRAILbeing(1 +
THS_TRAILCNT) x ByteClk cycle + ((1 to 2) + 2) xHSBYTECLK cycle +
- (PHY output delay)with PHY output delay being about
(8 + (5 to 6)) x MIPIBitClk cycle in the BitClk conversion.
Fixes ff1ca6397b1d ("drm/bridge: Add tc358768 driver")Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358768.c +4
-4@@ -779,9 +779,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)dev_dbg (priv->dev,"TCLK_POSTCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_TCLK_POSTCNT , val); -/* 60ns + 4*UI < THS_PREPARE < 105ns + 12*UI */ - val =tc358768_ns_to_cnt (60 +tc358768_to_ns (15 * ui_nsk), - dsibclk_nsk) -5 ; +/* max(60ns + 4*UI, 8*UI) < THS_TRAILCNT < 105ns + 12*UI */ + raw_val =tc358768_ns_to_cnt (60 +tc358768_to_ns (18 * ui_nsk), + dsibclk_nsk) -4 ; + val =clamp (raw_val,0 ,15 );dev_dbg (priv->dev,"THS_TRAILCNT: 0x%x\n" , val);tc358768_write (priv,TC358768_THS_TRAILCNT , val); --
Quoted 2 lines
2.25.1
PATCH 9/9 drm/bridge: tc358768: remove unused variable
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
Remove the unused phy_delay_nsk variable, before it was wrongly used to compute some register value, the fixed computation is no longer using it and therefore can be removed.
--- drivers/gpu/drm/bridge/tc358768.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/tc358768.c +1 -3
@@ -641,7 +641,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)u32 val, val2, lptxcnt, hact, data_type;s32 raw_val;const struct drm_display_mode *mode; -u32 dsibclk_nsk, dsiclk_nsk, ui_nsk, phy_delay_nsk; +u32 dsibclk_nsk, dsiclk_nsk, ui_nsk;u32 dsiclk, dsibclk, video_start;const u32 internal_delay =40 ;int ret, i;
@@ -725,11 +725,9 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) dsibclk); dsiclk_nsk = (u32 )div_u64 ((u64 )1000000000 *TC358768_PRECISION , dsiclk); ui_nsk = dsiclk_nsk /2 ; - phy_delay_nsk = dsibclk_nsk +2 * dsiclk_nsk;dev_dbg (priv->dev,"dsiclk_nsk: %u\n" , dsiclk_nsk);dev_dbg (priv->dev,"ui_nsk: %u\n" , ui_nsk);dev_dbg (priv->dev,"dsibclk_nsk: %u\n" , dsibclk_nsk); -dev_dbg (priv->dev,"phy_delay_nsk: %u\n" , phy_delay_nsk);/* LP11 > 100us for D-PHY Rx Init */ val =tc358768_ns_to_cnt (100 *1000 , dsibclk_nsk) -1 ;
Signature · 1 line
2.25.1
Re: [PATCH v1 9/9] drm/bridge: tc358768: remove unused variable
Quoted 38 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
Remove the unused
phy_delay_nskvariable, before it was wrongly used to compute some register value, the fixed computation is no longer using it and therefore can be removed.Signed-off-by Francesco Dolcini <[email protected]>--- drivers/gpu/drm/bridge/tc358768.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358768.c +1
-4@@ -641,7 +641,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)u32 val, val2, lptxcnt, hact, data_type;s32 raw_val;const struct drm_display_mode *mode; -u32 dsibclk_nsk, dsiclk_nsk, ui_nsk, phy_delay_nsk; +u32 dsibclk_nsk, dsiclk_nsk, ui_nsk;u32 dsiclk, dsibclk, video_start;const u32 internal_delay =40 ;int ret, i;@@ -725,11 +725,9 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) dsibclk); dsiclk_nsk = (u32 )div_u64 ((u64 )1000000000 *TC358768_PRECISION , dsiclk); ui_nsk = dsiclk_nsk /2 ; - phy_delay_nsk = dsibclk_nsk +2 * dsiclk_nsk;dev_dbg (priv->dev,"dsiclk_nsk: %u\n" , dsiclk_nsk);dev_dbg (priv->dev,"ui_nsk: %u\n" , ui_nsk);dev_dbg (priv->dev,"dsibclk_nsk: %u\n" , dsibclk_nsk); -dev_dbg (priv->dev,"phy_delay_nsk: %u\n" , phy_delay_nsk);/* LP11 > 100us for D-PHY Rx Init */ val =tc358768_ns_to_cnt (100 *1000 , dsibclk_nsk) -1 ; --
Quoted 2 lines
2.25.1
From: Robert Foss <[email protected]>
Quoted 10 lines · Francesco Dolcini
From: Francesco Dolcini <[email protected]>
This series includes multiple fixes on the tc358768 parallel RGB to DSI driver.
With the following changes I am able to have a stable display output using a TI SN65DSI83 (DSI-LVDS bridge) and a 1280 x 800 LVDS display panel and the register values are coherent with Toshiba documentation and configuration spreadsheet, I was not able to test any other display sink.
[...]
Applied, thanks!
[1/9] drm/bridge: tc358768: always enable HS video mode
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=ee18698e212b [2/9] drm/bridge: tc358768: fix PLL parameters computation https://cgit.freedesktop.org/drm/drm-misc/commit/?id=ee18698e212b [3/9] drm/bridge: tc358768: fix PLL target frequency https://cgit.freedesktop.org/drm/drm-misc/commit/?id=ee18698e212b [4/9] drm/bridge: tc358768: fix TCLK_ZEROCNT computation https://cgit.freedesktop.org/drm/drm-misc/commit/?id=ee18698e212b [5/9] drm/bridge: tc358768: fix TCLK_TRAILCNT computation https://cgit.freedesktop.org/drm/drm-misc/commit/?id=ee18698e212b [6/9] drm/bridge: tc358768: fix THS_ZEROCNT computation https://cgit.freedesktop.org/drm/drm-misc/commit/?id=77a089328da7 [7/9] drm/bridge: tc358768: fix TXTAGOCNT computation https://cgit.freedesktop.org/drm/drm-misc/commit/?id=3666aad8185a [8/9] drm/bridge: tc358768: fix THS_TRAILCNT computation https://cgit.freedesktop.org/drm/drm-misc/commit/?id=bac7842cd179 [9/9] drm/bridge: tc358768: remove unused variable https://cgit.freedesktop.org/drm/drm-misc/commit/?id=e4a5e4442a80
Rob