Commit ffd2e4bb authored by Francesco Dolcini's avatar Francesco Dolcini Committed by Robert Foss

drm/bridge: tc358768: fix PLL target frequency

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: ff1ca639 ("drm/bridge: Add tc358768 driver")
Signed-off-by: default avatarFrancesco Dolcini <francesco.dolcini@toradex.com>
Reviewed-by: default avatarRobert Foss <rfoss@kernel.org>
Signed-off-by: default avatarRobert Foss <rfoss@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230427142934.55435-4-francesco@dolcini.it
parent 6a4020b4
...@@ -147,6 +147,7 @@ struct tc358768_priv { ...@@ -147,6 +147,7 @@ struct tc358768_priv {
u32 pd_lines; /* number of Parallel Port Input Data Lines */ u32 pd_lines; /* number of Parallel Port Input Data Lines */
u32 dsi_lanes; /* number of DSI Lanes */ u32 dsi_lanes; /* number of DSI Lanes */
u32 dsi_bpp; /* number of Bits Per Pixel over DSI */
/* Parameters for PLL programming */ /* Parameters for PLL programming */
u32 fbd; /* PLL feedback divider */ u32 fbd; /* PLL feedback divider */
...@@ -285,12 +286,12 @@ static void tc358768_hw_disable(struct tc358768_priv *priv) ...@@ -285,12 +286,12 @@ static void tc358768_hw_disable(struct tc358768_priv *priv)
static u32 tc358768_pll_to_pclk(struct tc358768_priv *priv, u32 pll_clk) 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) 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, static int tc358768_calc_pll(struct tc358768_priv *priv,
...@@ -427,6 +428,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, ...@@ -427,6 +428,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host,
priv->output.panel = panel; priv->output.panel = panel;
priv->dsi_lanes = dev->lanes; priv->dsi_lanes = dev->lanes;
priv->dsi_bpp = mipi_dsi_pixel_format_to_bpp(dev->format);
/* get input ep (port0/endpoint0) */ /* get input ep (port0/endpoint0) */
ret = -EINVAL; ret = -EINVAL;
...@@ -438,7 +440,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, ...@@ -438,7 +440,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host,
} }
if (ret) if (ret)
priv->pd_lines = mipi_dsi_pixel_format_to_bpp(dev->format); priv->pd_lines = priv->dsi_bpp;
drm_bridge_add(&priv->bridge); drm_bridge_add(&priv->bridge);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment