From patchwork Mon Aug 29 18:40:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2324 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 69CCA40F47 for ; Mon, 29 Aug 2022 20:41:38 +0200 (CEST) Received: by mail-pl1-f198.google.com with SMTP id i1-20020a170902cf0100b001730caeec78sf6564418plg.7 for ; Mon, 29 Aug 2022 11:41:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661798497; cv=pass; d=google.com; s=arc-20160816; b=hUXp/jCsM9EKOSOI5bQed6fDb/vNnkOOWfCWRPTPVXuDA3z2r4DjwEWYWuCu04l6yl X3BJ6xzoupRbZJg8lYw5PAvv4rFMx0+mpHJAgWvazrmUyF8yCwxsGpJNADpEW9l2cfcf +YGS0E8P81F6h1zAgQKzk+zJrugweiujG6mSWCORXjuTIdWjDxywhHCcMNGr+y0JRLIY +/c62ugf9VBe/o6zpxc+mGaOShiF+1WeSM+Tag08VP7+/059CMSv564lKCAAcG+pF3zf 522MLqjHlwuhqtcAiJH5KVyAXLkLKL4ehUEesXsQ5UbKBUPh9Bfy4JBAkgIVEETJxQdZ Oz6A== 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=YCw8FhLbgCPenquBcKp2q81dvKPUrQbUKc/hPV4/W5M=; b=iqdp7jk8MtoC1jsE3tRA7CwRh19MDj95FCox78RemPg3/JVVjGw/NNjrmF7BY5+Ijg lp5bC0IkFiwZZAip9Ndd5atWmKvgUSvG4Lz0vOz72uDiTPFI6yimZQ9aX1e6YLnKzoh4 7myWJYql0HbcH8bhHqwBwoTViyAWnIopGbeQQD2WeiatK4FJYyoqRlj2EMuzjwWgEb7c tRWNKSuK13V+DsV4axv2G7thEJRSK0u/JhrJ1v895IgST/cPRLBPZcDDQRpZGlUP8gC1 /NwHhQs8jCM9AdD2DnmLHYuSVYloj2PHPZMCH/FOVUvyHgG1MWL/g1r1G7zz0u+g2ohG m/Dw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MkUC+Ydd; 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; bh=YCw8FhLbgCPenquBcKp2q81dvKPUrQbUKc/hPV4/W5M=; b=g7fWGs2lA6FUvAuuCqilaXjzNM72EXrisd1ytnHNXSZn5ro4YphI0eDFVorGmTcFBi DVBxcbmt1PEHxQUbWjNN+S5CV5PQJgdX2Tsx8iNb/HU8CIqyzSyZCB5/dkMwBMFQvjWT w3JO1rarBRnwbSjEiowgNkU1Pnh8OzF8JisQQ= 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; bh=YCw8FhLbgCPenquBcKp2q81dvKPUrQbUKc/hPV4/W5M=; b=pDZPRDqEod6//X9g6DlvTt2NSExYJHT1zhOy3IH9FDpLVNmfxMOWqqXghfw2r8Udtl mTKYRDjTgzgNPKbjwxgr8DjloWOeeuQGg4HjmGvjK0eyAjF91PY3UTJG3eVu7bOm2slU LTR8NaoH3W5l6NUDps8IGa7d5FjDPVQdQ5apuO8rMRIV4s5tT3daX0SMhRz8JI3FIfkM PsaBVWqtVvVxY04dEe9UIGZomTT37jpxtgM0UNI2qwxVxZ747mpeDPOgHYv7H1vqgp4S 2JkrQ8wnQUOvHjYza/dRqSju99ItBQBGrb/NyMnlVjB9/g7TFc9I7EMnZReKvJd+DPsn ApcA== X-Gm-Message-State: ACgBeo0Tl0bL7COsetGLslZ+WDQAVxIE3KqlpqkpnuZtyLSqYVdLGzga AWf4kZ8dfq5YxiMABYP3V/OnWgCZ X-Google-Smtp-Source: AA6agR67ocdu/4o8PoTh6NCMvMgTLHvmgyMNDvolkNowLte6l6B9xLgfCljHtA1pZT5aMQjCwCF6Zg== X-Received: by 2002:a62:b504:0:b0:538:20ae:bbf2 with SMTP id y4-20020a62b504000000b0053820aebbf2mr8023857pfe.79.1661798497231; Mon, 29 Aug 2022 11:41:37 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:e855:0:b0:41b:f780:ec79 with SMTP id a21-20020a63e855000000b0041bf780ec79ls4855704pgk.1.-pod-prod-gmail; Mon, 29 Aug 2022 11:41:36 -0700 (PDT) X-Received: by 2002:a63:f446:0:b0:42a:a729:18f0 with SMTP id p6-20020a63f446000000b0042aa72918f0mr14745896pgk.589.1661798496340; Mon, 29 Aug 2022 11:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661798496; cv=none; d=google.com; s=arc-20160816; b=dUmdGYj79UZi+9bwbskTlFtnAEkE6f67O6kxJzF+mBUVKW9fHWIF3AE0RbMIU7ueng JzH4FOJybyfzNPh/LNmYPLJ+3srTqo8jOFjNhXfRjFFOHASvF52UFShwN2G9btD/MHbw 0fAj7ta8/CY/jg43Vz75d48PFxOYPznro0MKXcQdbexHfA9jaFztjquVLMrZoQKrjotU SeI4A1EeCIhjiy0brkb4Uf5CuDD7L8sYvP4POqTigf6v5JYaKx07nSK4E9j2Nxp+9h8Y I1o/bE8rx8M9+67q903GF5nIN7wvlm2ShsyTM5rHA+EbCtIvq1AAjBd4CW1nktCfmou2 0oBw== 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=NcL003R2tcMcOwfD3XXeYJO2gKUt8M4GWo/KhiYrw5A=; b=zZ490pKftQJaBDqZZ5d5vh+J06Usr9RCuqcpiytheA6xRunKcMnDmTTAS1XI8mkyki gFCgKNha+DHLiN51+UkA637fywRkijwlZJ7OCMcBeoGd/ZVvLScRcJPHwjOYwgxPb6dU vTLM4m+Y4FAQG6ET3oxwBxM2leaWSJP09H8IovoEqOF4jXK1xlwh72PEM85vhsf37JF0 spMKVXCMHO+JoFT+M3TJAGdfORuZrNnLW6QTmSoX1GOx6aadmhKXgIPwANgNzuCYWaNw eGt7nFUxLlqP3csVv6yUDgRoDvg4W0gs6cF6b6UMvoaqAq+on/JpJEqHtq+BU8XIEa4R jaPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MkUC+Ydd; 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 u15-20020a63140f000000b0042c3cb09a09sor34983pgl.1.2022.08.29.11.41.36 for (Google Transport Security); Mon, 29 Aug 2022 11:41:36 -0700 (PDT) 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:5246:0:b0:42b:e4a5:7252 with SMTP id s6-20020a635246000000b0042be4a57252mr6772119pgl.566.1661798496014; Mon, 29 Aug 2022 11:41:36 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a073:43f7:1644:6259:830d]) by smtp.gmail.com with ESMTPSA id k13-20020aa7998d000000b005385e2e86eesm1619042pfh.18.2022.08.29.11.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 11:41:35 -0700 (PDT) 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 v4 06/12] drm: bridge: samsung-dsim: Handle proper DSI host initialization Date: Tue, 30 Aug 2022 00:10:25 +0530 Message-Id: <20220829184031.1863663-7-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220829184031.1863663-1-jagan@amarulasolutions.com> References: <20220829184031.1863663-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=MkUC+Ydd; 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). 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 c3ed317996ad..b6883a6d4681 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1254,12 +1254,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); @@ -1270,6 +1275,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; } @@ -1289,6 +1296,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, @@ -1464,12 +1475,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) @@ -1654,6 +1662,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 97fdee5ef5df..e15fbfd49efe 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) struct samsung_dsim_transfer { struct list_head list;