drm/bridge: tc358768: Fix DSI command tx

Wait for the command transmission to be completed in the DSI transfer
function polling for the dc_start bit to go back to idle state after the
transmission is started.

This is documented in the datasheet and failures to do so lead to
commands corruption.

Fixes: ff1ca6397b1d ("drm/bridge: Add tc358768 driver")
Cc: stable@vger.kernel.org
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20240926141246.48282-1-francesco@dolcini.it
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240926141246.48282-1-francesco@dolcini.it

authored by Francesco Dolcini and committed by Neil Armstrong 32c45144 93d1f41a

Changed files
+19 -2
drivers
gpu
drm
bridge
+19 -2
drivers/gpu/drm/bridge/tc358768.c
··· 125 125 #define TC358768_DSI_CONFW_MODE_CLR (6 << 29) 126 126 #define TC358768_DSI_CONFW_ADDR_DSI_CONTROL (0x3 << 24) 127 127 128 + /* TC358768_DSICMD_TX (0x0600) register */ 129 + #define TC358768_DSI_CMDTX_DC_START BIT(0) 130 + 128 131 static const char * const tc358768_supplies[] = { 129 132 "vddc", "vddmipi", "vddio" 130 133 }; ··· 230 227 tmp |= val & mask; 231 228 if (tmp != orig) 232 229 tc358768_write(priv, reg, tmp); 230 + } 231 + 232 + static void tc358768_dsicmd_tx(struct tc358768_priv *priv) 233 + { 234 + u32 val; 235 + 236 + /* start transfer */ 237 + tc358768_write(priv, TC358768_DSICMD_TX, TC358768_DSI_CMDTX_DC_START); 238 + if (priv->error) 239 + return; 240 + 241 + /* wait transfer completion */ 242 + priv->error = regmap_read_poll_timeout(priv->regmap, TC358768_DSICMD_TX, val, 243 + (val & TC358768_DSI_CMDTX_DC_START) == 0, 244 + 100, 100000); 233 245 } 234 246 235 247 static int tc358768_sw_reset(struct tc358768_priv *priv) ··· 534 516 } 535 517 } 536 518 537 - /* start transfer */ 538 - tc358768_write(priv, TC358768_DSICMD_TX, 1); 519 + tc358768_dsicmd_tx(priv); 539 520 540 521 ret = tc358768_clear_error(priv); 541 522 if (ret)