From nobody Thu Nov 28 22:32:22 2024 Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E7B31C687; Thu, 26 Sep 2024 14:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.194.8.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727359988; cv=none; b=glRT82g6VDTZTuAm2lkf3tlqLNqzSR7HkCQmmDlr6WT038iDhWmJwJoITs8W6pxr9e9phERfTZclZRy86knfDmXsuCnKBstUmqLwq35tUjx0l6HzHEKEy+F1aZzkFeOwo8ZdrBf7xBtpyhxztdfnPld5AvHmdlPZg2tY/Wg1iic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727359988; c=relaxed/simple; bh=dNtQDEMIXSeoVjO6VaJGbMN68UxgpHk7Y8wk54MuGU0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=uZINhfYNlvW1mJkObs1t7NgOJGOxVM7tKs5UqEeOAWvt3UVlOvHmrhFFySjAEFqlpQxHH31wi23xwgIenkkz9J6AdNxZ6WPSuJZJc3MkEu+P/m1KyQ2HO0peL46ZDCRl7VDg9bgU6KcRS1gSTXOk9iRKBWkdC2ub2ejsJyAi8Ys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dolcini.it; spf=pass smtp.mailfrom=dolcini.it; dkim=pass (2048-bit key) header.d=dolcini.it header.i=@dolcini.it header.b=JtbDKFIQ; arc=none smtp.client-ip=217.194.8.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=dolcini.it Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dolcini.it Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dolcini.it header.i=@dolcini.it header.b="JtbDKFIQ" Received: from francesco-nb.pivistrello.it (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id D737A1FA5E; Thu, 26 Sep 2024 16:12:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dolcini.it; s=default; t=1727359974; bh=WppZHrQT1Rzii/cRjg1/sys9dUOQvw27vjIghFpwOKo=; h=From:To:Subject; b=JtbDKFIQ7A+dY2lmKEEZ+uVqqrJ6iY2eL7pXVIWk0kGf9TFuk1wPYbaxvleZLvjPo n8fYAj+o0nNu1sVyNStPHZ1XkVev1N7eqk6TwLmE9fRfyFVwFVhFBs16NtBhtkYDL6 /sT6U1ZYdjjlP51d2c0XOKGneqsqYjD/I9VbdP0VoVNPnMXB9OkgYFXIg19/oz59vH bjE+hhey4jihlgM+7NRWvJ9P6WfDR8D7L5tAACr+g2OKLD20DQ9J5jrA3NZZcn60kR rFCTFqnAs+4EVp6i8iCDoEAmmCDCmNeeXo+ArwqraW1F4OJrNv+6bIysL4xWoPvzIM LMRmytBMkWBlA== From: Francesco Dolcini To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Francesco Dolcini , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v1] drm/bridge: tc358768: Fix DSI command tx Date: Thu, 26 Sep 2024 16:12:46 +0200 Message-Id: <20240926141246.48282-1-francesco@dolcini.it> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Francesco Dolcini 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 Reviewed-by: Neil Armstrong --- drivers/gpu/drm/bridge/tc358768.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc3= 58768.c index 0e8813278a2f..bb1750a3dab0 100644 --- a/drivers/gpu/drm/bridge/tc358768.c +++ b/drivers/gpu/drm/bridge/tc358768.c @@ -125,6 +125,9 @@ #define TC358768_DSI_CONFW_MODE_CLR (6 << 29) #define TC358768_DSI_CONFW_ADDR_DSI_CONTROL (0x3 << 24) =20 +/* TC358768_DSICMD_TX (0x0600) register */ +#define TC358768_DSI_CMDTX_DC_START BIT(0) + static const char * const tc358768_supplies[] =3D { "vddc", "vddmipi", "vddio" }; @@ -229,6 +232,21 @@ static void tc358768_update_bits(struct tc358768_priv = *priv, u32 reg, u32 mask, tc358768_write(priv, reg, tmp); } =20 +static void tc358768_dsicmd_tx(struct tc358768_priv *priv) +{ + u32 val; + + /* start transfer */ + tc358768_write(priv, TC358768_DSICMD_TX, TC358768_DSI_CMDTX_DC_START); + if (priv->error) + return; + + /* wait transfer completion */ + priv->error =3D regmap_read_poll_timeout(priv->regmap, TC358768_DSICMD_TX= , val, + (val & TC358768_DSI_CMDTX_DC_START) =3D=3D 0, + 100, 100000); +} + static int tc358768_sw_reset(struct tc358768_priv *priv) { /* Assert Reset */ @@ -516,8 +534,7 @@ static ssize_t tc358768_dsi_host_transfer(struct mipi_d= si_host *host, } } =20 - /* start transfer */ - tc358768_write(priv, TC358768_DSICMD_TX, 1); + tc358768_dsicmd_tx(priv); =20 ret =3D tc358768_clear_error(priv); if (ret) --=20 2.39.5