From patchwork Sat Oct 1 08:06:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 12996437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96CEDC433F5 for ; Sat, 1 Oct 2022 08:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HQF86K06i2kxcvqfq0U5/y7VD9YOTqxT7XdORKyqH9M=; b=bRp6gWp8ZNQQOi OwrHWyCn3FupK7tKaabQoH/r2kTUReRIdPmrnnrAQKjWziS1beqzoAJHJi6x7XkoUH5FZ0Deq5ztg tKW91FVZ+5MRCF/xPNAxhq4LxI9527aLFyLMozGKJGkQLqAhAx1EPu3CL4uYQr1igkcw3dVIBRWj3 iN9nybqPdBaTP8NjnodQ3+qzNeNP1bICgh1nza3I84uQ7p+/zWPMzEXqeEsT9rkIqL4UrMJKejsZc qOsZAQOI8a9Z5rxedsVnpWHLG+QDXRiERenNkWBO0trYfNpMSDg3jm53dU6843DX9jy/WCJ+1kwFK 00J70ZEAyEIqAp5YfbWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeXXw-00Df2J-Sn; Sat, 01 Oct 2022 08:08:29 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeXXt-00Df0u-Fh for linux-arm-kernel@lists.infradead.org; Sat, 01 Oct 2022 08:08:26 +0000 Received: by mail-pg1-x52e.google.com with SMTP id s206so5943735pgs.3 for ; Sat, 01 Oct 2022 01:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Ke/kHSIUtl4EAJQ/hjOQA71nefBPkPlcvo1GhHET9E8=; b=YE7cv58N9RW4OIyM4jXxEGd5pB/yhJBnKPT2iilRqtyLVs3ajOGpJbSnDdQNhcN0ha zw12nEDF52P8edMqEgBLo/lytT4aE2iqPNOPCF6k7Ut4BVbShI8ViLQj6uF0X6xTC/Nc rSUM6jL8/Uxa72RAohk4QcF8EDYOf0CWTpiRg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Ke/kHSIUtl4EAJQ/hjOQA71nefBPkPlcvo1GhHET9E8=; b=Whs2D3QoopdFDKZyK/SiArZUqrpr5HrVAlY4hwqbha0Dr2FhL2h9SknRvnFX+A5Nfr N9BKHqOzK2Ejelz+GnUnriorPxvSg+XGWnBtTDbK9oHDQmwkvqo8rhs4yab6SaBFQcTr k8KrXrWZzvnvMxWbzWgTgo2pc49cT+VQJGBNuNNo7E1gX6kwyRtP46kCEz40UOBSrLGc prSLgLRiS7M9ztUL5/RJGMg/7f45tgWMQp8EIQoBmc+QIpAGBio9eSkxcEMZ7nFs/ZCx hrTv/PN280OeWizvof6U04rbQth78pn3d61LvqYJ1Q8VprbreZral6IOXTdEGEuXmWgr 0/QA== X-Gm-Message-State: ACrzQf2fu0Kv7TrFezzOkrHmVriWjp/WkwhzFnZiYXkCXd8jjTP1FM6O s2qMc6V8AXm/Dsk0x7r1U7yb7A== X-Google-Smtp-Source: AMsMyM6JwRvi+Ewzv0hDAvXHAw9i9EWDyl03ectNydcJIUPmzlbehB8fAz+xeesUswLt08bzxqLnmg== X-Received: by 2002:a63:33cf:0:b0:439:f026:aab2 with SMTP id z198-20020a6333cf000000b00439f026aab2mr10713031pgz.86.1664611704758; Sat, 01 Oct 2022 01:08:24 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a073:7254:4392:bc7c:c69]) by smtp.gmail.com with ESMTPSA id c194-20020a624ecb000000b005409c9d2d41sm3167041pfb.62.2022.10.01.01.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 01:08:24 -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 v6 04/10] drm: bridge: samsung-dsim: Handle proper DSI host initialization Date: Sat, 1 Oct 2022 13:36:44 +0530 Message-Id: <20221001080650.1007043-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221001080650.1007043-1-jagan@amarulasolutions.com> References: <20221001080650.1007043-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221001_010825_550871_2F9900C7 X-CRM114-Status: GOOD ( 18.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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). 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 2ba909ec5239..0636440e4420 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,