Skip to content

Commit 74629c4

Browse files
Marek Vasutsuperna9999
authored andcommitted
drm: bridge: samsung-dsim: Implement support for clock/data polarity swap
Implement support for DSI clock and data lane DN/DP polarity swap by means of decoding 'lane-polarities' DT property. The controller does support DN/DP swap of clock lane and all data lanes, the controller does not support polarity swap of individual data lane bundles, add a check which verifies all data lanes have the same polarity. This has been validated on an imx8mm board that actually has the MIPI DSI clock lanes inverted. Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Fabio Estevam <festevam@denx.de> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230514114625.98372-2-festevam@gmail.com
1 parent ec7743c commit 74629c4

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

drivers/gpu/drm/bridge/samsung-dsim.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@
183183
#define DSIM_AFC_CTL(x) (((x) & 0x7) << 5)
184184

185185
/* DSIM_PLLCTRL */
186+
#define DSIM_PLL_DPDNSWAP_CLK (1 << 25)
187+
#define DSIM_PLL_DPDNSWAP_DAT (1 << 24)
186188
#define DSIM_FREQ_BAND(x) ((x) << 24)
187189
#define DSIM_PLL_EN BIT(23)
188190
#define DSIM_PLL_P(x, offset) ((x) << (offset))
@@ -622,6 +624,11 @@ static unsigned long samsung_dsim_set_pll(struct samsung_dsim *dsi,
622624
reg |= DSIM_FREQ_BAND(band);
623625
}
624626

627+
if (dsi->swap_dn_dp_clk)
628+
reg |= DSIM_PLL_DPDNSWAP_CLK;
629+
if (dsi->swap_dn_dp_data)
630+
reg |= DSIM_PLL_DPDNSWAP_DAT;
631+
625632
samsung_dsim_write(dsi, DSIM_PLLCTRL_REG, reg);
626633

627634
timeout = 1000;
@@ -1696,7 +1703,9 @@ static int samsung_dsim_parse_dt(struct samsung_dsim *dsi)
16961703
{
16971704
struct device *dev = dsi->dev;
16981705
struct device_node *node = dev->of_node;
1699-
int ret;
1706+
u32 lane_polarities[5] = { 0 };
1707+
struct device_node *endpoint;
1708+
int i, nr_lanes, ret;
17001709

17011710
ret = samsung_dsim_of_read_u32(node, "samsung,pll-clock-frequency",
17021711
&dsi->pll_clk_rate);
@@ -1713,6 +1722,22 @@ static int samsung_dsim_parse_dt(struct samsung_dsim *dsi)
17131722
if (ret < 0)
17141723
return ret;
17151724

1725+
endpoint = of_graph_get_endpoint_by_regs(node, 1, -1);
1726+
nr_lanes = of_property_count_u32_elems(endpoint, "data-lanes");
1727+
if (nr_lanes > 0 && nr_lanes <= 4) {
1728+
/* Polarity 0 is clock lane, 1..4 are data lanes. */
1729+
of_property_read_u32_array(endpoint, "lane-polarities",
1730+
lane_polarities, nr_lanes + 1);
1731+
for (i = 1; i <= nr_lanes; i++) {
1732+
if (lane_polarities[1] != lane_polarities[i])
1733+
DRM_DEV_ERROR(dsi->dev, "Data lanes polarities do not match");
1734+
}
1735+
if (lane_polarities[0])
1736+
dsi->swap_dn_dp_clk = true;
1737+
if (lane_polarities[1])
1738+
dsi->swap_dn_dp_data = true;
1739+
}
1740+
17161741
return 0;
17171742
}
17181743

include/drm/bridge/samsung-dsim.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ struct samsung_dsim {
9595
u32 mode_flags;
9696
u32 format;
9797

98+
bool swap_dn_dp_clk;
99+
bool swap_dn_dp_data;
98100
int state;
99101
struct drm_property *brightness;
100102
struct completion completed;

0 commit comments

Comments
 (0)