From patchwork Thu Nov 10 18:38:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2471 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 46AE23F039 for ; Thu, 10 Nov 2022 19:41:01 +0100 (CET) Received: by mail-pj1-f71.google.com with SMTP id v10-20020a17090a7c0a00b00215deac75b4sf1522743pjf.3 for ; Thu, 10 Nov 2022 10:41:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668105660; cv=pass; d=google.com; s=arc-20160816; b=XikXFxptlAaqbQBYYuFW+u9ji/qxO91jfgjhwy4JHLhyZoIKttc/ZIAaoMqY4udqEO xrZJHfRg29O/+61J6U8dt7kshEZUaZD69YvRbNPnyhPXeWhO0ooeWfPBypQDr8fWXasl TVqR6SWpZpH8n/R24IsdpMpahTglSlYtnlUl7SjoogaYX9StZTbVDCV4JcYWO+T8okpk RMmgMfdRvt3GZKh3VPojwwuFx/3OaEwEZax7zlcfKWhUMYina9A8tTLAigfGhegqYY3K /OWazeciyRYc+ZdsgFBAPelFe3sLnDHM3PRDobg66FFjxLn8M1gAIIsFR8lkCKa3uUJL Pbpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Ddhj2Lw8+JJx69VriTDu5Hkner/hTXEXwm5fIg7rPtQ=; b=jjn45NzEyCcHW5HO2i0JCkCNxNLj6i+h5qG5MBfo0fNBjO6tAUArtR3VBFf9dg8v3o brpTUX5lIT2hjr4sTp90jpO0LRRnZ7+zFx0Hh3iK4i6LIpABlPX0nJFPff+tvwYFhDeK kY03KStoPSLradiUyMvWVzT/XHa7tWQ8wi+I9mZwFVXHlK0qiezbvkjzXi83VhvomXA7 3F/4REu2WQqv82EAmbj00OdfVoMqdTnYXO+uClTTgZ1Ye9kttHnmV1+SnVp5z1gAByuD TzG93+YYHbZdPp92Xn55yb4D6JNvGDurVRktS/QC5WAE5X3fYYwcV+QttIWjLgX3V1l4 jJaQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jDmAeelX; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ddhj2Lw8+JJx69VriTDu5Hkner/hTXEXwm5fIg7rPtQ=; b=DILYXz1w3CBEqf1wKInvPszlcN1G3meprKnuWXecUhDdBE84AvpL53Mhr4P3x/riX6 QtLDnwBSoRIBUPYqo1o81bdTPuqkAnTwtQPbyR7p+xVF57fjo7gqVdt+Zz6D0Xh4KvcV x5SrGMbuWvocPwLopAn0wxvlsaAeSTmeg067M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ddhj2Lw8+JJx69VriTDu5Hkner/hTXEXwm5fIg7rPtQ=; b=JhjKfQ8jIct+2ERDYcEhYLNGg2xMo9J5BwG04Vr4zfCshyKVD3iYDTnt6pXk7NeVcR kcm9AC9TMPyvpxC1drvl7za7ecLuVqGqPvDlLsNzz//aTskEkqhsYGzByJFcDO0eankX KIhdvlZeMoU5ynJC1CnpB5mKlNhnFCiEdcdEyA5vZ8VjxYNEyOFxYuKK15SDa0y0MKl6 lP1f5HFbJt8CRRU3nMWij2biHS7s2Ex3jHMkBOJcsrWAqfZxXxLP8SxicLFPCR5pBoyG fjVENydbXErHWUzr2yiuTH4cCpl8JBVzpNpz6HvtEZH+YVhVtc4PxplSd5P6ctSr2iRz 3EhA== X-Gm-Message-State: ACrzQf2ffBrjvg225TVGK4LQkeTR4GybiMwqmbh1aGkUKZYRSAIgGl12 p36KNIDxQ2M2PvldVep3d+3Ay4h1 X-Google-Smtp-Source: AMsMyM6hWjoUWrPOy4aIxO5SIEl+NHN4y7mYMXEKdWSwsMclOxG2cihbwnQ0tCEU2p+x65od5FFbSQ== X-Received: by 2002:a17:90b:4a86:b0:213:5e7f:bf3d with SMTP id lp6-20020a17090b4a8600b002135e7fbf3dmr80579480pjb.209.1668105659983; Thu, 10 Nov 2022 10:40:59 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6a00:2343:b0:56d:1df0:b73d with SMTP id j3-20020a056a00234300b0056d1df0b73dls1512747pfj.2.-pod-prod-gmail; Thu, 10 Nov 2022 10:40:59 -0800 (PST) X-Received: by 2002:a63:cf0c:0:b0:46e:f23a:e9aa with SMTP id j12-20020a63cf0c000000b0046ef23ae9aamr2938027pgg.428.1668105659085; Thu, 10 Nov 2022 10:40:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668105659; cv=none; d=google.com; s=arc-20160816; b=BSqH/1d9KTZ47fQ2nDDUUdIFS4+q3WOK28FRhe37gzHAZP6ClsAF7X491Gsm7HH7PV Hi7IJE08bXdNPxSPqOOk/yM6QcjvzFg3sG7DIrrfkg5aqHI+aar5c1xPfwOjtVcfXatx HAqWwHQard7MqaY+g/O+U8XxxSV2yvzRnQD4x6M6LcJtPhuAS/8ZU5GdBOzORC5up+Kj mCZAfOi04J7XDQjHAogh7Dmy8E+rwPJobWbhXPu5O+KHV8VAse1Bo0OlJTbuLP4UupS5 I6GXflZ3Z7gjsVQc5cOfMgfg8wDSWVfplsnmV3LMwObKzOwGUML+yrtP9T5c0Cd8cpDy 1Ibg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=cVZvXXPZkH3o8/n5mzHi6c1nTPAle34qM4sMhdqWc88=; b=V1KPz+155pZq5OatgoaKjAnulevsmgWPYwTkknvPRpmK+Ql1kiQ4aqfSCxhDpsyG4b n7cqXOAMmEp6nadt7FuKe7lAaXWi7pk7yexMJz+HvNG/h58IWUSbRJ5tcC+UKstl/gKF E0ozdK1yD7XRTEauww5LBA7F7knflhG50Nq+S7DG0IHD72JEEEXL1fSxEgepU0i12ibb ++mlkEg8pRT/HPY6pWjBAeHSsHOX2b8lg6NwUpoNQGOlGMISXvczbAuVsTIsa3B7LpmX QJtz6V16XZ5JbyeRt+jflvAl3pK0otIh7VV+/4/09B9gbw09AMos9xbwtROai8gNYRWp XK3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jDmAeelX; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a9-20020a621a09000000b0056ce347e8f7sor9285235pfa.21.2022.11.10.10.40.59 for (Google Transport Security); Thu, 10 Nov 2022 10:40:59 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a63:5650:0:b0:459:7d5f:293e with SMTP id g16-20020a635650000000b004597d5f293emr2945701pgm.602.1668105658769; Thu, 10 Nov 2022 10:40:58 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a809:b5a4:486a:f07:f67e]) by smtp.gmail.com with ESMTPSA id c2-20020a170903234200b001869efb722csm11635627plh.215.2022.11.10.10.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 10:40:58 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Fancy Fang , Tim Harvey , Michael Nazzareno Trimarchi , Adam Ford , Neil Armstrong , Robert Foss , Laurent Pinchart , Tommaso Merciai , Marek Vasut Cc: Matteo Lisi , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, NXP Linux Team , linux-amarula , Jagan Teki Subject: [PATCH v8 06/14] drm: bridge: samsung-dsim: Handle proper DSI host initialization Date: Fri, 11 Nov 2022 00:08:45 +0530 Message-Id: <20221110183853.3678209-7-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110183853.3678209-1-jagan@amarulasolutions.com> References: <20221110183853.3678209-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jDmAeelX; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , DSI host initialization handling in previous exynos dsi driver has some pitfalls. It initializes the host during host transfer() hook that is indeed not the desired call flow for I2C and any other DSI configured downstream bridges. Host transfer() is usually triggered for downstream DSI panels or bridges and I2C-configured-DSI bridges miss these host initialization as these downstream bridges use bridge operations hooks like pre_enable, and enable in order to initialize or set up the host. This patch is trying to handle the host init handler to satisfy all downstream panels and bridges. Added the DSIM_STATE_REINITIALIZED state flag to ensure that host init is also done on first cmd transfer, this helps existing DSI panels work on exynos platform (form Marek Szyprowski). v8, v7, v6, v5: * none v4: * update init handling to ensure host init done on first cmd transfer v3: * none v2: * check initialized state in samsung_dsim_init v1: * keep DSI init in host transfer Signed-off-by: Marek Szyprowski Signed-off-by: Jagan Teki --- drivers/gpu/drm/bridge/samsung-dsim.c | 25 +++++++++++++++++-------- include/drm/bridge/samsung-dsim.h | 5 +++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index bb1f45fd5a88..ec7e01ae02ea 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1234,12 +1234,17 @@ static void samsung_dsim_disable_irq(struct samsung_dsim *dsi) disable_irq(dsi->irq); } -static int samsung_dsim_init(struct samsung_dsim *dsi) +static int samsung_dsim_init(struct samsung_dsim *dsi, unsigned int flag) { const struct samsung_dsim_driver_data *driver_data = dsi->driver_data; + if (dsi->state & flag) + return 0; + samsung_dsim_reset(dsi); - samsung_dsim_enable_irq(dsi); + + if (!(dsi->state & DSIM_STATE_INITIALIZED)) + samsung_dsim_enable_irq(dsi); if (driver_data->reg_values[RESET_TYPE] == DSIM_FUNCRST) samsung_dsim_enable_lane(dsi, BIT(dsi->lanes) - 1); @@ -1250,6 +1255,8 @@ static int samsung_dsim_init(struct samsung_dsim *dsi) samsung_dsim_set_phy_ctrl(dsi); samsung_dsim_init_link(dsi); + dsi->state |= flag; + return 0; } @@ -1269,6 +1276,10 @@ static void samsung_dsim_atomic_pre_enable(struct drm_bridge *bridge, } dsi->state |= DSIM_STATE_ENABLED; + + ret = samsung_dsim_init(dsi, DSIM_STATE_INITIALIZED); + if (ret) + return; } static void samsung_dsim_atomic_enable(struct drm_bridge *bridge, @@ -1458,12 +1469,9 @@ static ssize_t samsung_dsim_host_transfer(struct mipi_dsi_host *host, if (!(dsi->state & DSIM_STATE_ENABLED)) return -EINVAL; - if (!(dsi->state & DSIM_STATE_INITIALIZED)) { - ret = samsung_dsim_init(dsi); - if (ret) - return ret; - dsi->state |= DSIM_STATE_INITIALIZED; - } + ret = samsung_dsim_init(dsi, DSIM_STATE_REINITIALIZED); + if (ret) + return ret; ret = mipi_dsi_create_packet(&xfer.packet, msg); if (ret < 0) @@ -1653,6 +1661,7 @@ static int __maybe_unused samsung_dsim_suspend(struct device *dev) if (dsi->state & DSIM_STATE_INITIALIZED) { dsi->state &= ~DSIM_STATE_INITIALIZED; + dsi->state &= ~DSIM_STATE_REINITIALIZED; samsung_dsim_disable_clock(dsi); diff --git a/include/drm/bridge/samsung-dsim.h b/include/drm/bridge/samsung-dsim.h index b8132bf8e36f..0c5a905f3de7 100644 --- a/include/drm/bridge/samsung-dsim.h +++ b/include/drm/bridge/samsung-dsim.h @@ -17,8 +17,9 @@ struct samsung_dsim; #define DSIM_STATE_ENABLED BIT(0) #define DSIM_STATE_INITIALIZED BIT(1) -#define DSIM_STATE_CMD_LPM BIT(2) -#define DSIM_STATE_VIDOUT_AVAILABLE BIT(3) +#define DSIM_STATE_REINITIALIZED BIT(2) +#define DSIM_STATE_CMD_LPM BIT(3) +#define DSIM_STATE_VIDOUT_AVAILABLE BIT(4) enum samsung_dsim_type { SAMSUNG_DSIM_TYPE_EXYNOS3250,