From patchwork Fri Apr 23 16:58:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68093C433B4 for ; Fri, 23 Apr 2021 16:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4800961006 for ; Fri, 23 Apr 2021 16:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243153AbhDWRAT (ORCPT ); Fri, 23 Apr 2021 13:00:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230482AbhDWRAS (ORCPT ); Fri, 23 Apr 2021 13:00:18 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0BD6C061574 for ; Fri, 23 Apr 2021 09:59:41 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id lt13so14569989pjb.1 for ; Fri, 23 Apr 2021 09:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v3L6h1BjunVrmn6xM+A7e9Coz57kAQq9sEX0cijBf6I=; b=P2YIm80Y/ICCG+y+HzolfGLNXCmFgI3A3HuBx6AvFj28507tePNztOilZzFEIvP4EJ AKDvdgT44aEEbjBXK8iZkmiLI1hjnxIYqs7lKUgAOlXm0VgiiteLz94/xpSsRj0OLa+2 C7ojRlXfaNQK3HnacnO27Njjj+GpLy/0HlSQ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v3L6h1BjunVrmn6xM+A7e9Coz57kAQq9sEX0cijBf6I=; b=SQz8yeXXxm40u9aSs2dr2iDYgRUvXAeQUMRNopRceBXTWqSclDQCquvZz2FKnQApaG 80WnHqXZqfMkZL+7InLREbw4SIgePVslfkDFprRzJzQofWhl/FHeYB2nCrNyYKsK23ib RDSasmMao+/RagdHiow4gdnCKJ67UAD46qbBmljAFzUONeBvse8emFxO662ADUsYDdjc 03GI+uoutoKOybN55bsUEOBCCqUF+k83wGrA8sk1BK26D0BvI9WbxU3Ausj9Bkj3hCET f2zORM9szonkVSsJtTwqZAOhWG5sdXkrHBMvffBTaZDab2rilQ0ez8I4rEEV1pvtn+I6 QQQg== X-Gm-Message-State: AOAM531cm7/lG/E8KibcXzDg6gy/5iv5n7PWikRXGEvt6kkeQKMS/DjE KdPF9VaRC6ZX7/81nwbLRkGSlg== X-Google-Smtp-Source: ABdhPJwUVUVBiZpl2STs9t26EmL1yjzkkyP/mrfd3qlMXQIPV2Y6D3kRrmJUXon9H1XxH3F5d1fPZg== X-Received: by 2002:a17:90a:9f02:: with SMTP id n2mr5439030pjp.151.1619197181372; Fri, 23 Apr 2021 09:59:41 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:41 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Laurent Pinchart , Thierry Reding , linux-kernel@vger.kernel.org Subject: [PATCH v5 01/20] drm/panel: panel-simple: Add missing pm_runtime_disable() calls Date: Fri, 23 Apr 2021 09:58:47 -0700 Message-Id: <20210423095743.v5.1.I9e6af2529d6c61e5daf86a15a1211121c5223b9a@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In commit 3235b0f20a0a ("drm/panel: panel-simple: Use runtime pm to avoid excessive unprepare / prepare") we started using pm_runtime, but my patch neglected to add the proper pm_runtime_disable(). Doh! Add them now. Fixes: 3235b0f20a0a ("drm/panel: panel-simple: Use runtime pm to avoid excessive unprepare / prepare") Reported-by: Bjorn Andersson Signed-off-by: Douglas Anderson Reviewed-by: Sean Paul Reviewed-by: Linus Walleij Acked-by: Linus Walleij --- Changes in v5: - Missing pm_runtime_disable() patch new for v5. drivers/gpu/drm/panel/panel-simple.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 6b22872b3281..9746eda6f675 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -797,12 +797,14 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) err = drm_panel_of_backlight(&panel->base); if (err) - goto free_ddc; + goto disable_pm_runtime; drm_panel_add(&panel->base); return 0; +disable_pm_runtime: + pm_runtime_disable(dev); free_ddc: if (panel->ddc) put_device(&panel->ddc->dev); @@ -818,6 +820,7 @@ static int panel_simple_remove(struct device *dev) drm_panel_disable(&panel->base); drm_panel_unprepare(&panel->base); + pm_runtime_disable(dev); if (panel->ddc) put_device(&panel->ddc->dev); From patchwork Fri Apr 23 16:58:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30E39C43462 for ; Fri, 23 Apr 2021 16:59:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E6976113B for ; Fri, 23 Apr 2021 16:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243246AbhDWRAW (ORCPT ); Fri, 23 Apr 2021 13:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231760AbhDWRAT (ORCPT ); Fri, 23 Apr 2021 13:00:19 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06338C061574 for ; Fri, 23 Apr 2021 09:59:43 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id e8-20020a17090a7288b029014e51f5a6baso1522643pjg.2 for ; Fri, 23 Apr 2021 09:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QM0BZwiNar/MLW6Ggc6NlMQGUNWAScAI3/mIAP3ptr0=; b=irB+JrU2iackcgEACIQ0OscJ/FXyLyE1um+HvrhzScYHVx2dHgUlFtLO8R46uAO63D SHLBiXTYC2h/xugoFtfZ62jA2Ntjz5dPTC0ENMlxcFKsU7B6bC+B88hwI4pC9gyjjji3 renI1rsEHXevn+wEFcvde2k/ZIWhbvEZx+yZ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QM0BZwiNar/MLW6Ggc6NlMQGUNWAScAI3/mIAP3ptr0=; b=Cuz2xDjc69D+cz1kGEgLSYX0kgAiCaUB/lK+K74BYyGJA14YbM2wB57ZqISKmW2/lt gKU2mqc9kYj1VHU5jtrtgpHJuw8Do+xtsWwtECBOivp5wqstRhueTC30R7u4RzW2fhDV 76vm8frG618w5ZDnV1fw0a+twgzR8op2w2EaE+/Dk9qqCf9+2s5jGwAydkDYPgsvh4ds WKdiM7MC24EYWpOWr2ojYOOjs6MAS5lqlw6pRK8zUilztlW8YeL1RwXNqOUXn9YvPHpR 25rBGdS3DUGXZOkjpIcrzRU5LvW4Hd6FcoLSO/Tov+PwaAF1Pv2CJdOkP/ogV83bc0px xCuQ== X-Gm-Message-State: AOAM530oYLXZLbuIT+8G+oARHdkAbBExJy0tx68MNVwiUJEk2Myh56yI M+XGGwm4woC3vBsP33HALtfouA== X-Google-Smtp-Source: ABdhPJzVJ/jx8s9fjFDHsEbCzzl/XavVGXH0D3+v/71SRwWnaR18+EbAYmzgrapF9thOnLwoeduh7A== X-Received: by 2002:a17:90a:f3cf:: with SMTP id ha15mr6710040pjb.214.1619197182548; Fri, 23 Apr 2021 09:59:42 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:42 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 02/20] drm/bridge: ti-sn65dsi86: Rename the main driver data structure Date: Fri, 23 Apr 2021 09:58:48 -0700 Message-Id: <20210423095743.v5.2.Ib03e88304a9ea1c503f1b9567be5cbf8b7c5761c@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In preparation for splitting this driver into sub-drivers, let's rename the main data structure so it's clear that it's holding data for the whole device and not just the MIPI-eDP bridge part. This is a no-op change. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/bridge/ti-sn65dsi86.c | 86 +++++++++++++-------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 51db30d573c1..f00ceb9dda29 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -112,7 +112,7 @@ #define SN_LINK_TRAINING_TRIES 10 /** - * struct ti_sn_bridge - Platform data for ti-sn65dsi86 driver. + * struct ti_sn65dsi86 - Platform data for ti-sn65dsi86 driver. * @dev: Pointer to our device. * @regmap: Regmap for accessing i2c. * @aux: Our aux channel. @@ -140,7 +140,7 @@ * lock so concurrent users of our 4 GPIOs don't stomp on * each other's read-modify-write. */ -struct ti_sn_bridge { +struct ti_sn65dsi86 { struct device *dev; struct regmap *regmap; struct drm_dp_aux aux; @@ -180,7 +180,7 @@ static const struct regmap_config ti_sn_bridge_regmap_config = { .cache_type = REGCACHE_NONE, }; -static void ti_sn_bridge_write_u16(struct ti_sn_bridge *pdata, +static void ti_sn_bridge_write_u16(struct ti_sn65dsi86 *pdata, unsigned int reg, u16 val) { regmap_write(pdata->regmap, reg, val & 0xFF); @@ -189,7 +189,7 @@ static void ti_sn_bridge_write_u16(struct ti_sn_bridge *pdata, static int __maybe_unused ti_sn_bridge_resume(struct device *dev) { - struct ti_sn_bridge *pdata = dev_get_drvdata(dev); + struct ti_sn65dsi86 *pdata = dev_get_drvdata(dev); int ret; ret = regulator_bulk_enable(SN_REGULATOR_SUPPLY_NUM, pdata->supplies); @@ -205,7 +205,7 @@ static int __maybe_unused ti_sn_bridge_resume(struct device *dev) static int __maybe_unused ti_sn_bridge_suspend(struct device *dev) { - struct ti_sn_bridge *pdata = dev_get_drvdata(dev); + struct ti_sn65dsi86 *pdata = dev_get_drvdata(dev); int ret; gpiod_set_value(pdata->enable_gpio, 0); @@ -225,7 +225,7 @@ static const struct dev_pm_ops ti_sn_bridge_pm_ops = { static int status_show(struct seq_file *s, void *data) { - struct ti_sn_bridge *pdata = s->private; + struct ti_sn65dsi86 *pdata = s->private; unsigned int reg, val; seq_puts(s, "STATUS REGISTERS:\n"); @@ -245,7 +245,7 @@ static int status_show(struct seq_file *s, void *data) DEFINE_SHOW_ATTRIBUTE(status); -static void ti_sn_debugfs_init(struct ti_sn_bridge *pdata) +static void ti_sn_debugfs_init(struct ti_sn65dsi86 *pdata) { pdata->debugfs = debugfs_create_dir(dev_name(pdata->dev), NULL); @@ -253,22 +253,22 @@ static void ti_sn_debugfs_init(struct ti_sn_bridge *pdata) &status_fops); } -static void ti_sn_debugfs_remove(struct ti_sn_bridge *pdata) +static void ti_sn_debugfs_remove(struct ti_sn65dsi86 *pdata) { debugfs_remove_recursive(pdata->debugfs); pdata->debugfs = NULL; } /* Connector funcs */ -static struct ti_sn_bridge * +static struct ti_sn65dsi86 * connector_to_ti_sn_bridge(struct drm_connector *connector) { - return container_of(connector, struct ti_sn_bridge, connector); + return container_of(connector, struct ti_sn65dsi86, connector); } static int ti_sn_bridge_connector_get_modes(struct drm_connector *connector) { - struct ti_sn_bridge *pdata = connector_to_ti_sn_bridge(connector); + struct ti_sn65dsi86 *pdata = connector_to_ti_sn_bridge(connector); struct edid *edid = pdata->edid; int num, ret; @@ -314,12 +314,12 @@ static const struct drm_connector_funcs ti_sn_bridge_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static struct ti_sn_bridge *bridge_to_ti_sn_bridge(struct drm_bridge *bridge) +static struct ti_sn65dsi86 *bridge_to_ti_sn_bridge(struct drm_bridge *bridge) { - return container_of(bridge, struct ti_sn_bridge, bridge); + return container_of(bridge, struct ti_sn65dsi86, bridge); } -static int ti_sn_bridge_parse_regulators(struct ti_sn_bridge *pdata) +static int ti_sn_bridge_parse_regulators(struct ti_sn65dsi86 *pdata) { unsigned int i; const char * const ti_sn_bridge_supply_names[] = { @@ -337,7 +337,7 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { int ret, val; - struct ti_sn_bridge *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); struct mipi_dsi_host *host; struct mipi_dsi_device *dsi; const struct mipi_dsi_device_info info = { .type = "ti_sn_bridge", @@ -430,7 +430,7 @@ static void ti_sn_bridge_detach(struct drm_bridge *bridge) static void ti_sn_bridge_disable(struct drm_bridge *bridge) { - struct ti_sn_bridge *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); drm_panel_disable(pdata->panel); @@ -442,7 +442,7 @@ static void ti_sn_bridge_disable(struct drm_bridge *bridge) regmap_write(pdata->regmap, SN_PLL_ENABLE_REG, 0); } -static u32 ti_sn_bridge_get_dsi_freq(struct ti_sn_bridge *pdata) +static u32 ti_sn_bridge_get_dsi_freq(struct ti_sn65dsi86 *pdata) { u32 bit_rate_khz, clk_freq_khz; struct drm_display_mode *mode = @@ -473,7 +473,7 @@ static const u32 ti_sn_bridge_dsiclk_lut[] = { 460800000, }; -static void ti_sn_bridge_set_refclk_freq(struct ti_sn_bridge *pdata) +static void ti_sn_bridge_set_refclk_freq(struct ti_sn65dsi86 *pdata) { int i; u32 refclk_rate; @@ -500,7 +500,7 @@ static void ti_sn_bridge_set_refclk_freq(struct ti_sn_bridge *pdata) REFCLK_FREQ(i)); } -static void ti_sn_bridge_set_dsi_rate(struct ti_sn_bridge *pdata) +static void ti_sn_bridge_set_dsi_rate(struct ti_sn65dsi86 *pdata) { unsigned int bit_rate_mhz, clk_freq_mhz; unsigned int val; @@ -518,7 +518,7 @@ static void ti_sn_bridge_set_dsi_rate(struct ti_sn_bridge *pdata) regmap_write(pdata->regmap, SN_DSIA_CLK_FREQ_REG, val); } -static unsigned int ti_sn_bridge_get_bpp(struct ti_sn_bridge *pdata) +static unsigned int ti_sn_bridge_get_bpp(struct ti_sn65dsi86 *pdata) { if (pdata->connector.display_info.bpc <= 6) return 18; @@ -535,7 +535,7 @@ static const unsigned int ti_sn_bridge_dp_rate_lut[] = { 0, 1620, 2160, 2430, 2700, 3240, 4320, 5400 }; -static int ti_sn_bridge_calc_min_dp_rate_idx(struct ti_sn_bridge *pdata) +static int ti_sn_bridge_calc_min_dp_rate_idx(struct ti_sn65dsi86 *pdata) { unsigned int bit_rate_khz, dp_rate_mhz; unsigned int i; @@ -556,7 +556,7 @@ static int ti_sn_bridge_calc_min_dp_rate_idx(struct ti_sn_bridge *pdata) return i; } -static void ti_sn_bridge_read_valid_rates(struct ti_sn_bridge *pdata, +static void ti_sn_bridge_read_valid_rates(struct ti_sn65dsi86 *pdata, bool rate_valid[]) { unsigned int rate_per_200khz; @@ -637,7 +637,7 @@ static void ti_sn_bridge_read_valid_rates(struct ti_sn_bridge *pdata, } } -static void ti_sn_bridge_set_video_timings(struct ti_sn_bridge *pdata) +static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata) { struct drm_display_mode *mode = &pdata->bridge.encoder->crtc->state->adjusted_mode; @@ -676,7 +676,7 @@ static void ti_sn_bridge_set_video_timings(struct ti_sn_bridge *pdata) usleep_range(10000, 10500); /* 10ms delay recommended by spec */ } -static unsigned int ti_sn_get_max_lanes(struct ti_sn_bridge *pdata) +static unsigned int ti_sn_get_max_lanes(struct ti_sn65dsi86 *pdata) { u8 data; int ret; @@ -691,7 +691,7 @@ static unsigned int ti_sn_get_max_lanes(struct ti_sn_bridge *pdata) return data & DP_LANE_COUNT_MASK; } -static int ti_sn_link_training(struct ti_sn_bridge *pdata, int dp_rate_idx, +static int ti_sn_link_training(struct ti_sn65dsi86 *pdata, int dp_rate_idx, const char **last_err_str) { unsigned int val; @@ -751,7 +751,7 @@ static int ti_sn_link_training(struct ti_sn_bridge *pdata, int dp_rate_idx, static void ti_sn_bridge_enable(struct drm_bridge *bridge) { - struct ti_sn_bridge *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); bool rate_valid[ARRAY_SIZE(ti_sn_bridge_dp_rate_lut)] = { }; const char *last_err_str = "No supported DP rate"; int dp_rate_idx; @@ -822,7 +822,7 @@ static void ti_sn_bridge_enable(struct drm_bridge *bridge) static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge) { - struct ti_sn_bridge *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); pm_runtime_get_sync(pdata->dev); @@ -853,7 +853,7 @@ static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge) static void ti_sn_bridge_post_disable(struct drm_bridge *bridge) { - struct ti_sn_bridge *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); drm_panel_unprepare(pdata->panel); @@ -871,15 +871,15 @@ static const struct drm_bridge_funcs ti_sn_bridge_funcs = { .post_disable = ti_sn_bridge_post_disable, }; -static struct ti_sn_bridge *aux_to_ti_sn_bridge(struct drm_dp_aux *aux) +static struct ti_sn65dsi86 *aux_to_ti_sn_bridge(struct drm_dp_aux *aux) { - return container_of(aux, struct ti_sn_bridge, aux); + return container_of(aux, struct ti_sn65dsi86, aux); } static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) { - struct ti_sn_bridge *pdata = aux_to_ti_sn_bridge(aux); + struct ti_sn65dsi86 *pdata = aux_to_ti_sn_bridge(aux); u32 request = msg->request & ~(DP_AUX_I2C_MOT | DP_AUX_I2C_WRITE_STATUS_UPDATE); u32 request_val = AUX_CMD_REQ(msg->request); u8 *buf = msg->buffer; @@ -969,7 +969,7 @@ static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux, return len; } -static int ti_sn_bridge_parse_dsi_host(struct ti_sn_bridge *pdata) +static int ti_sn_bridge_parse_dsi_host(struct ti_sn65dsi86 *pdata) { struct device_node *np = pdata->dev->of_node; @@ -1004,7 +1004,7 @@ static int tn_sn_bridge_of_xlate(struct gpio_chip *chip, static int ti_sn_bridge_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) { - struct ti_sn_bridge *pdata = gpiochip_get_data(chip); + struct ti_sn65dsi86 *pdata = gpiochip_get_data(chip); /* * We already have to keep track of the direction because we use @@ -1018,7 +1018,7 @@ static int ti_sn_bridge_gpio_get_direction(struct gpio_chip *chip, static int ti_sn_bridge_gpio_get(struct gpio_chip *chip, unsigned int offset) { - struct ti_sn_bridge *pdata = gpiochip_get_data(chip); + struct ti_sn65dsi86 *pdata = gpiochip_get_data(chip); unsigned int val; int ret; @@ -1043,7 +1043,7 @@ static int ti_sn_bridge_gpio_get(struct gpio_chip *chip, unsigned int offset) static void ti_sn_bridge_gpio_set(struct gpio_chip *chip, unsigned int offset, int val) { - struct ti_sn_bridge *pdata = gpiochip_get_data(chip); + struct ti_sn65dsi86 *pdata = gpiochip_get_data(chip); int ret; if (!test_bit(offset, pdata->gchip_output)) { @@ -1063,7 +1063,7 @@ static void ti_sn_bridge_gpio_set(struct gpio_chip *chip, unsigned int offset, static int ti_sn_bridge_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) { - struct ti_sn_bridge *pdata = gpiochip_get_data(chip); + struct ti_sn65dsi86 *pdata = gpiochip_get_data(chip); int shift = offset * 2; int ret; @@ -1091,7 +1091,7 @@ static int ti_sn_bridge_gpio_direction_input(struct gpio_chip *chip, static int ti_sn_bridge_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int val) { - struct ti_sn_bridge *pdata = gpiochip_get_data(chip); + struct ti_sn65dsi86 *pdata = gpiochip_get_data(chip); int shift = offset * 2; int ret; @@ -1125,7 +1125,7 @@ static const char * const ti_sn_bridge_gpio_names[SN_NUM_GPIOS] = { "GPIO1", "GPIO2", "GPIO3", "GPIO4" }; -static int ti_sn_setup_gpio_controller(struct ti_sn_bridge *pdata) +static int ti_sn_setup_gpio_controller(struct ti_sn65dsi86 *pdata) { int ret; @@ -1157,14 +1157,14 @@ static int ti_sn_setup_gpio_controller(struct ti_sn_bridge *pdata) #else -static inline int ti_sn_setup_gpio_controller(struct ti_sn_bridge *pdata) +static inline int ti_sn_setup_gpio_controller(struct ti_sn65dsi86 *pdata) { return 0; } #endif -static void ti_sn_bridge_parse_lanes(struct ti_sn_bridge *pdata, +static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata, struct device_node *np) { u32 lane_assignments[SN_MAX_DP_LANES] = { 0, 1, 2, 3 }; @@ -1216,7 +1216,7 @@ static void ti_sn_bridge_parse_lanes(struct ti_sn_bridge *pdata, static int ti_sn_bridge_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct ti_sn_bridge *pdata; + struct ti_sn65dsi86 *pdata; int ret; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { @@ -1224,7 +1224,7 @@ static int ti_sn_bridge_probe(struct i2c_client *client, return -ENODEV; } - pdata = devm_kzalloc(&client->dev, sizeof(struct ti_sn_bridge), + pdata = devm_kzalloc(&client->dev, sizeof(struct ti_sn65dsi86), GFP_KERNEL); if (!pdata) return -ENOMEM; @@ -1298,7 +1298,7 @@ static int ti_sn_bridge_probe(struct i2c_client *client, static int ti_sn_bridge_remove(struct i2c_client *client) { - struct ti_sn_bridge *pdata = i2c_get_clientdata(client); + struct ti_sn65dsi86 *pdata = i2c_get_clientdata(client); if (!pdata) return -EINVAL; From patchwork Fri Apr 23 16:58:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCAC7C43600 for ; Fri, 23 Apr 2021 16:59:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0EF0611AE for ; Fri, 23 Apr 2021 16:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243274AbhDWRAX (ORCPT ); Fri, 23 Apr 2021 13:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243212AbhDWRAU (ORCPT ); Fri, 23 Apr 2021 13:00:20 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2698BC06138C for ; Fri, 23 Apr 2021 09:59:44 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 31so3675211pgn.13 for ; Fri, 23 Apr 2021 09:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AEG5Ctp5HODalQ0QpA3IKiYhU+ejAF34Z/fToe+URy8=; b=TqOn+dU1wJdd8j/ZLF2TsIC419wZB6WKzGlmNHyg0OsIqVCJW0znxMpReAsFj/RO5u 8nSZTryANSCFFQ/2lKTN015bDeMZN0h9khk0N+wLycpqpXPKw29+uZca5CyVIhoRyw5B X1dcTRKFhdTsTuQEPhvBS6Hpkmy8a7HvTjaiQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AEG5Ctp5HODalQ0QpA3IKiYhU+ejAF34Z/fToe+URy8=; b=TcvC27zvjemNxjvlTINY00jCozz/huODtrz2/FlynnhYK/YiOew9jTKfm243EQqTAA eehnHAsLxFjzZP3sMhYfkf9cIrapLl2Wih+sPVpejHHLlwW/OJmvI0gLKho3VcPjov3q p7txaF4OyC2FyWL5mRimnxgVGs6p3tuDNMMcB+CpEhTH+hGQso86WRPfUDcD6h6boWse ZiBsJ3jbEjaBS4LY7q9j9K7A31SFxQx9ffkBbJ6MuY7cUXDlEwVycQJXIGegISR7ycTE 7JCNFe4mdWzlTZXJP/5IhTpyl1rpH1jmKswC/AG748HkjkIaQfFY6Ja/umGemyzFfxri GDEw== X-Gm-Message-State: AOAM5328jow3hRRaNz1gE/uOYFp5GWMQWz78iW83XZEvbpA3jpjV0N/B e1KyFoO/grC1huJov1vnX+WbyA== X-Google-Smtp-Source: ABdhPJyA4WHSbQt5/uM2EtaI50ooukwbSVDI/W7aKRoe/WHORO4xedBgdv2LlSUhtWbGo6O10CU8WA== X-Received: by 2002:a62:878d:0:b029:257:ba2e:b6b2 with SMTP id i135-20020a62878d0000b0290257ba2eb6b2mr4836531pfe.11.1619197183639; Fri, 23 Apr 2021 09:59:43 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:43 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 03/20] drm/bridge: ti-sn65dsi86: More renames in prep for sub-devices Date: Fri, 23 Apr 2021 09:58:49 -0700 Message-Id: <20210423095743.v5.3.I4b28c737933a44548662df42ccd37db89ec739c1@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Like the previous patch ("drm/bridge: ti-sn65dsi86: Rename the main driver data structure") this is just a no-op rename in preparation for splitting the driver up a bit. Here I've attempted to rename functions / structures making sure that anything applicable to the whole chip (instead of just the MIPI to eDP bridge part) included "sn65dsi86" somewhere in the name instead of just "ti_sn_bridge". Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/bridge/ti-sn65dsi86.c | 84 +++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index f00ceb9dda29..57574132e200 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -164,30 +164,30 @@ struct ti_sn65dsi86 { #endif }; -static const struct regmap_range ti_sn_bridge_volatile_ranges[] = { +static const struct regmap_range ti_sn65dsi86_volatile_ranges[] = { { .range_min = 0, .range_max = 0xFF }, }; static const struct regmap_access_table ti_sn_bridge_volatile_table = { - .yes_ranges = ti_sn_bridge_volatile_ranges, - .n_yes_ranges = ARRAY_SIZE(ti_sn_bridge_volatile_ranges), + .yes_ranges = ti_sn65dsi86_volatile_ranges, + .n_yes_ranges = ARRAY_SIZE(ti_sn65dsi86_volatile_ranges), }; -static const struct regmap_config ti_sn_bridge_regmap_config = { +static const struct regmap_config ti_sn65dsi86_regmap_config = { .reg_bits = 8, .val_bits = 8, .volatile_table = &ti_sn_bridge_volatile_table, .cache_type = REGCACHE_NONE, }; -static void ti_sn_bridge_write_u16(struct ti_sn65dsi86 *pdata, +static void ti_sn65dsi86_write_u16(struct ti_sn65dsi86 *pdata, unsigned int reg, u16 val) { regmap_write(pdata->regmap, reg, val & 0xFF); regmap_write(pdata->regmap, reg + 1, val >> 8); } -static int __maybe_unused ti_sn_bridge_resume(struct device *dev) +static int __maybe_unused ti_sn65dsi86_resume(struct device *dev) { struct ti_sn65dsi86 *pdata = dev_get_drvdata(dev); int ret; @@ -203,7 +203,7 @@ static int __maybe_unused ti_sn_bridge_resume(struct device *dev) return ret; } -static int __maybe_unused ti_sn_bridge_suspend(struct device *dev) +static int __maybe_unused ti_sn65dsi86_suspend(struct device *dev) { struct ti_sn65dsi86 *pdata = dev_get_drvdata(dev); int ret; @@ -217,8 +217,8 @@ static int __maybe_unused ti_sn_bridge_suspend(struct device *dev) return ret; } -static const struct dev_pm_ops ti_sn_bridge_pm_ops = { - SET_RUNTIME_PM_OPS(ti_sn_bridge_suspend, ti_sn_bridge_resume, NULL) +static const struct dev_pm_ops ti_sn65dsi86_pm_ops = { + SET_RUNTIME_PM_OPS(ti_sn65dsi86_suspend, ti_sn65dsi86_resume, NULL) SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) }; @@ -245,7 +245,7 @@ static int status_show(struct seq_file *s, void *data) DEFINE_SHOW_ATTRIBUTE(status); -static void ti_sn_debugfs_init(struct ti_sn65dsi86 *pdata) +static void ti_sn65dsi86_debugfs_init(struct ti_sn65dsi86 *pdata) { pdata->debugfs = debugfs_create_dir(dev_name(pdata->dev), NULL); @@ -253,7 +253,7 @@ static void ti_sn_debugfs_init(struct ti_sn65dsi86 *pdata) &status_fops); } -static void ti_sn_debugfs_remove(struct ti_sn65dsi86 *pdata) +static void ti_sn65dsi86_debugfs_remove(struct ti_sn65dsi86 *pdata) { debugfs_remove_recursive(pdata->debugfs); pdata->debugfs = NULL; @@ -261,14 +261,14 @@ static void ti_sn_debugfs_remove(struct ti_sn65dsi86 *pdata) /* Connector funcs */ static struct ti_sn65dsi86 * -connector_to_ti_sn_bridge(struct drm_connector *connector) +connector_to_ti_sn65dsi86(struct drm_connector *connector) { return container_of(connector, struct ti_sn65dsi86, connector); } static int ti_sn_bridge_connector_get_modes(struct drm_connector *connector) { - struct ti_sn65dsi86 *pdata = connector_to_ti_sn_bridge(connector); + struct ti_sn65dsi86 *pdata = connector_to_ti_sn65dsi86(connector); struct edid *edid = pdata->edid; int num, ret; @@ -314,12 +314,12 @@ static const struct drm_connector_funcs ti_sn_bridge_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static struct ti_sn65dsi86 *bridge_to_ti_sn_bridge(struct drm_bridge *bridge) +static struct ti_sn65dsi86 *bridge_to_ti_sn65dsi86(struct drm_bridge *bridge) { return container_of(bridge, struct ti_sn65dsi86, bridge); } -static int ti_sn_bridge_parse_regulators(struct ti_sn65dsi86 *pdata) +static int ti_sn65dsi86_parse_regulators(struct ti_sn65dsi86 *pdata) { unsigned int i; const char * const ti_sn_bridge_supply_names[] = { @@ -337,7 +337,7 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { int ret, val; - struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); struct mipi_dsi_host *host; struct mipi_dsi_device *dsi; const struct mipi_dsi_device_info info = { .type = "ti_sn_bridge", @@ -425,12 +425,12 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, static void ti_sn_bridge_detach(struct drm_bridge *bridge) { - drm_dp_aux_unregister(&bridge_to_ti_sn_bridge(bridge)->aux); + drm_dp_aux_unregister(&bridge_to_ti_sn65dsi86(bridge)->aux); } static void ti_sn_bridge_disable(struct drm_bridge *bridge) { - struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); drm_panel_disable(pdata->panel); @@ -648,9 +648,9 @@ static void ti_sn_bridge_set_video_timings(struct ti_sn65dsi86 *pdata) if (mode->flags & DRM_MODE_FLAG_PVSYNC) vsync_polarity = CHA_VSYNC_POLARITY; - ti_sn_bridge_write_u16(pdata, SN_CHA_ACTIVE_LINE_LENGTH_LOW_REG, + ti_sn65dsi86_write_u16(pdata, SN_CHA_ACTIVE_LINE_LENGTH_LOW_REG, mode->hdisplay); - ti_sn_bridge_write_u16(pdata, SN_CHA_VERTICAL_DISPLAY_SIZE_LOW_REG, + ti_sn65dsi86_write_u16(pdata, SN_CHA_VERTICAL_DISPLAY_SIZE_LOW_REG, mode->vdisplay); regmap_write(pdata->regmap, SN_CHA_HSYNC_PULSE_WIDTH_LOW_REG, (mode->hsync_end - mode->hsync_start) & 0xFF); @@ -751,7 +751,7 @@ static int ti_sn_link_training(struct ti_sn65dsi86 *pdata, int dp_rate_idx, static void ti_sn_bridge_enable(struct drm_bridge *bridge) { - struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); bool rate_valid[ARRAY_SIZE(ti_sn_bridge_dp_rate_lut)] = { }; const char *last_err_str = "No supported DP rate"; int dp_rate_idx; @@ -822,7 +822,7 @@ static void ti_sn_bridge_enable(struct drm_bridge *bridge) static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge) { - struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); pm_runtime_get_sync(pdata->dev); @@ -853,7 +853,7 @@ static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge) static void ti_sn_bridge_post_disable(struct drm_bridge *bridge) { - struct ti_sn65dsi86 *pdata = bridge_to_ti_sn_bridge(bridge); + struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); drm_panel_unprepare(pdata->panel); @@ -871,7 +871,7 @@ static const struct drm_bridge_funcs ti_sn_bridge_funcs = { .post_disable = ti_sn_bridge_post_disable, }; -static struct ti_sn65dsi86 *aux_to_ti_sn_bridge(struct drm_dp_aux *aux) +static struct ti_sn65dsi86 *aux_to_ti_sn65dsi86(struct drm_dp_aux *aux) { return container_of(aux, struct ti_sn65dsi86, aux); } @@ -879,7 +879,7 @@ static struct ti_sn65dsi86 *aux_to_ti_sn_bridge(struct drm_dp_aux *aux) static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) { - struct ti_sn65dsi86 *pdata = aux_to_ti_sn_bridge(aux); + struct ti_sn65dsi86 *pdata = aux_to_ti_sn65dsi86(aux); u32 request = msg->request & ~(DP_AUX_I2C_MOT | DP_AUX_I2C_WRITE_STATUS_UPDATE); u32 request_val = AUX_CMD_REQ(msg->request); u8 *buf = msg->buffer; @@ -1213,7 +1213,7 @@ static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata, pdata->ln_polrs = ln_polrs; } -static int ti_sn_bridge_probe(struct i2c_client *client, +static int ti_sn65dsi86_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ti_sn65dsi86 *pdata; @@ -1230,7 +1230,7 @@ static int ti_sn_bridge_probe(struct i2c_client *client, return -ENOMEM; pdata->regmap = devm_regmap_init_i2c(client, - &ti_sn_bridge_regmap_config); + &ti_sn65dsi86_regmap_config); if (IS_ERR(pdata->regmap)) { DRM_ERROR("regmap i2c init failed\n"); return PTR_ERR(pdata->regmap); @@ -1257,7 +1257,7 @@ static int ti_sn_bridge_probe(struct i2c_client *client, ti_sn_bridge_parse_lanes(pdata, client->dev.of_node); - ret = ti_sn_bridge_parse_regulators(pdata); + ret = ti_sn65dsi86_parse_regulators(pdata); if (ret) { DRM_ERROR("failed to parse regulators\n"); return ret; @@ -1291,12 +1291,12 @@ static int ti_sn_bridge_probe(struct i2c_client *client, drm_bridge_add(&pdata->bridge); - ti_sn_debugfs_init(pdata); + ti_sn65dsi86_debugfs_init(pdata); return 0; } -static int ti_sn_bridge_remove(struct i2c_client *client) +static int ti_sn65dsi86_remove(struct i2c_client *client) { struct ti_sn65dsi86 *pdata = i2c_get_clientdata(client); @@ -1310,7 +1310,7 @@ static int ti_sn_bridge_remove(struct i2c_client *client) kfree(pdata->edid); - ti_sn_debugfs_remove(pdata); + ti_sn65dsi86_debugfs_remove(pdata); drm_bridge_remove(&pdata->bridge); @@ -1321,29 +1321,29 @@ static int ti_sn_bridge_remove(struct i2c_client *client) return 0; } -static struct i2c_device_id ti_sn_bridge_id[] = { +static struct i2c_device_id ti_sn65dsi86_id[] = { { "ti,sn65dsi86", 0}, {}, }; -MODULE_DEVICE_TABLE(i2c, ti_sn_bridge_id); +MODULE_DEVICE_TABLE(i2c, ti_sn65dsi86_id); -static const struct of_device_id ti_sn_bridge_match_table[] = { +static const struct of_device_id ti_sn65dsi86_match_table[] = { {.compatible = "ti,sn65dsi86"}, {}, }; -MODULE_DEVICE_TABLE(of, ti_sn_bridge_match_table); +MODULE_DEVICE_TABLE(of, ti_sn65dsi86_match_table); -static struct i2c_driver ti_sn_bridge_driver = { +static struct i2c_driver ti_sn65dsi86_driver = { .driver = { .name = "ti_sn65dsi86", - .of_match_table = ti_sn_bridge_match_table, - .pm = &ti_sn_bridge_pm_ops, + .of_match_table = ti_sn65dsi86_match_table, + .pm = &ti_sn65dsi86_pm_ops, }, - .probe = ti_sn_bridge_probe, - .remove = ti_sn_bridge_remove, - .id_table = ti_sn_bridge_id, + .probe = ti_sn65dsi86_probe, + .remove = ti_sn65dsi86_remove, + .id_table = ti_sn65dsi86_id, }; -module_i2c_driver(ti_sn_bridge_driver); +module_i2c_driver(ti_sn65dsi86_driver); MODULE_AUTHOR("Sandeep Panda "); MODULE_DESCRIPTION("sn65dsi86 DSI to eDP bridge driver"); From patchwork Fri Apr 23 16:58:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA59DC43470 for ; Fri, 23 Apr 2021 16:59:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC94161006 for ; Fri, 23 Apr 2021 16:59:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243237AbhDWRAZ (ORCPT ); Fri, 23 Apr 2021 13:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243089AbhDWRAV (ORCPT ); Fri, 23 Apr 2021 13:00:21 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06458C06138F for ; Fri, 23 Apr 2021 09:59:45 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id em21-20020a17090b0155b029014e204a81e6so4758575pjb.1 for ; Fri, 23 Apr 2021 09:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xP5DIs1FkSE0BDkM2KIzYkHfQ0hdD3i5eW0X+nUNW+Y=; b=Nui0pXvr5mJQMbnlzuYsHB8sZuXeWkPY3IJOWfaIzTzDi/nK7GX+qeRokQsNKy2fYL j1y6mX12y+CQx8BOw57VkZYhCBu6XhRlhhbJYAlTfbuYaUlcixbob351UBwviRX9wNcv xKZ6ARbbjmm25KQR9dd0/UTv4z2clW3SG0Ocs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xP5DIs1FkSE0BDkM2KIzYkHfQ0hdD3i5eW0X+nUNW+Y=; b=iquxHRhGodTlAAtgkcE9STw/LAkkgPRmGSXQgHqGrTe2tl15DjCWGJJccAb2mVOy6r D816qrDVBwIZEbVU/72YWH0jGj8wkUpoOq5h5R5l+DHs/ZwOvidjY5760H2cB5uBRo4j e8YS9OrO0VWHl2hveS8Ws/OtQxPyrmDQH/uk7vT1mFXZ7ewltXeYvfdLb7swzd/qjSnV 2Ha8hMwJGI0SRiaTCYoF715/eJbsAMnKHsUo5xQDoa2F9qXhG0/h12KYtMm6ATZG959f 9hd5THFVFJ2sicduNI1qHfAfl4MBtFTmyyh81SVIygX9VUQAXaORIt41YclVP8o2i2e4 7hnw== X-Gm-Message-State: AOAM533QXocLSRb00pjjkIudriRHDKRB0/EyYDiFK61OzA6rMxWVKFMe 59u+QTkEXY58O9Jcl5Oppe9DBQ== X-Google-Smtp-Source: ABdhPJxb8n3U3zZOiWMrXechOGFa6o/j6TcVWcBF+GRLB7Z3nK12l4CAlGd+Lw7zqpaW3ocWIOL1DQ== X-Received: by 2002:a17:90a:a395:: with SMTP id x21mr5425317pjp.95.1619197184632; Fri, 23 Apr 2021 09:59:44 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:44 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 04/20] drm/bridge: ti-sn65dsi86: Use devm to do our runtime_disable Date: Fri, 23 Apr 2021 09:58:50 -0700 Message-Id: <20210423095743.v5.4.I1e627eb5f316c0cf6595b120e6e262f5bf890300@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There's no devm_runtime_enable(), but it's easy to use devm_add_action_or_reset() and means we don't need to worry about the disable in our remove() routine or in error paths. No functional changes intended by this change. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- Changes in v5: - Reordered to debugfs change to avoid transient issue drivers/gpu/drm/bridge/ti-sn65dsi86.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 57574132e200..44d8395505f0 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -1213,6 +1213,11 @@ static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata, pdata->ln_polrs = ln_polrs; } +static void ti_sn65dsi86_runtime_disable(void *data) +{ + pm_runtime_disable(data); +} + static int ti_sn65dsi86_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1272,12 +1277,13 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, return ret; pm_runtime_enable(pdata->dev); + ret = devm_add_action_or_reset(pdata->dev, ti_sn65dsi86_runtime_disable, pdata->dev); + if (ret) + return ret; ret = ti_sn_setup_gpio_controller(pdata); - if (ret) { - pm_runtime_disable(pdata->dev); + if (ret) return ret; - } i2c_set_clientdata(client, pdata); @@ -1314,8 +1320,6 @@ static int ti_sn65dsi86_remove(struct i2c_client *client) drm_bridge_remove(&pdata->bridge); - pm_runtime_disable(pdata->dev); - of_node_put(pdata->host_node); return 0; From patchwork Fri Apr 23 16:58:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59F31C43460 for ; Fri, 23 Apr 2021 16:59:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32EB0613BB for ; Fri, 23 Apr 2021 16:59:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243316AbhDWRA0 (ORCPT ); Fri, 23 Apr 2021 13:00:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243278AbhDWRAX (ORCPT ); Fri, 23 Apr 2021 13:00:23 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B7EC061343 for ; Fri, 23 Apr 2021 09:59:46 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id e8-20020a17090a7288b029014e51f5a6baso1522699pjg.2 for ; Fri, 23 Apr 2021 09:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pdcpo4UqRlWs4ocPfX4snuIEGMWz2iUneYKWicWu5Ps=; b=UiXErXemW2Z1PCdM9rdxduLgZdKkZp2cJ5UTIOMhKS/ZBUmVIriOjKreGnp1xfCQs4 vE7OR5LEr7+0PS3EtSxsnORGB1XnMRLhtR/hwozuWTiDGTDzBVc+Z7heZxAXehNhWWu8 mitoDjp0bgrk9G2vLOxRD91XRxARy41wepVMg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pdcpo4UqRlWs4ocPfX4snuIEGMWz2iUneYKWicWu5Ps=; b=MsLPWOPps060ktDakW/v8yqIPSU/dqoa5EjCJwngsVDkkq4caWnLi3gahU1jRv5CSP EF1214aUlK0GDutP5twZP0pvRVsrrz/Jx+1Sxzt+m9YuKNaWNzuXGP8wEdJenDynHG3V h9xWMAhhoYvW8K/8AS5lxV0mv85RPRJyZebH8CGVCw2Y8zv1PxEdArFuXxGbBqAd0nlH fVMMhiRJ3Mj7lS266DTBk8FpwdFppglEl09B6Lr6/nvFhpH17E5EVP+BQqU/7LQs37La jhyHxqpfSRQaF+2GKhV6cJlr7V42CSdLvAyQNjbiyVJ52vfGoXPsiCYBk32Fw0IocjRT o8Rw== X-Gm-Message-State: AOAM531aU77s1sKYtwSGGg2D3l6z/xti9ARDN9/TTe19aw96NgFLt972 xU2Z3FVF7DNqZJHE3+oECc2c6A== X-Google-Smtp-Source: ABdhPJyAWKVmxvEi9reu/EoUqAW7KcB819hFWrr09EJVcKqxEtEvh/AuypvfPYDZ1yx6Fv3YxVpHEQ== X-Received: by 2002:a17:90b:344d:: with SMTP id lj13mr6661098pjb.44.1619197185610; Fri, 23 Apr 2021 09:59:45 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:45 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 05/20] drm/bridge: ti-sn65dsi86: Clean debugfs code Date: Fri, 23 Apr 2021 09:58:51 -0700 Message-Id: <20210423095743.v5.5.I5fe072753290c6a77eda736ebd5778e17b7cb0fb@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's cleanup the debugfs code to: - Check for errors. - Use devm to manage freeing, which also means we don't need to store a pointer in our structure. Signed-off-by: Douglas Anderson --- Bjorn: I left off your tag on this patch since I made changes compared to v4. Can you re-add if it still looks OK? This is now ordered _after_ the pm_runtime patch so I believe the ordering problem you pointed out should be fixed as well? Changes in v5: - Don't print debugfs creation errors. - Handle NULL from debugfs_create_dir() which is documented possible. drivers/gpu/drm/bridge/ti-sn65dsi86.c | 33 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 44d8395505f0..8aa36074aab9 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -118,7 +118,6 @@ * @aux: Our aux channel. * @bridge: Our bridge. * @connector: Our connector. - * @debugfs: Used for managing our debugfs. * @host_node: Remote DSI node. * @dsi: Our MIPI DSI source. * @edid: Detected EDID of eDP panel. @@ -146,7 +145,6 @@ struct ti_sn65dsi86 { struct drm_dp_aux aux; struct drm_bridge bridge; struct drm_connector connector; - struct dentry *debugfs; struct edid *edid; struct device_node *host_node; struct mipi_dsi_device *dsi; @@ -245,18 +243,31 @@ static int status_show(struct seq_file *s, void *data) DEFINE_SHOW_ATTRIBUTE(status); -static void ti_sn65dsi86_debugfs_init(struct ti_sn65dsi86 *pdata) +static void ti_sn65dsi86_debugfs_remove(void *data) { - pdata->debugfs = debugfs_create_dir(dev_name(pdata->dev), NULL); - - debugfs_create_file("status", 0600, pdata->debugfs, pdata, - &status_fops); + debugfs_remove_recursive(data); } -static void ti_sn65dsi86_debugfs_remove(struct ti_sn65dsi86 *pdata) +static void ti_sn65dsi86_debugfs_init(struct ti_sn65dsi86 *pdata) { - debugfs_remove_recursive(pdata->debugfs); - pdata->debugfs = NULL; + struct device *dev = pdata->dev; + struct dentry *debugfs; + int ret; + + debugfs = debugfs_create_dir(dev_name(dev), NULL); + + /* + * We might get an error back if debugfs wasn't enabled in the kernel + * so let's just silently return upon failure. + */ + if (IS_ERR_OR_NULL(debugfs)) + return; + + ret = devm_add_action_or_reset(dev, ti_sn65dsi86_debugfs_remove, debugfs); + if (ret) + return; + + debugfs_create_file("status", 0600, debugfs, pdata, &status_fops); } /* Connector funcs */ @@ -1316,8 +1327,6 @@ static int ti_sn65dsi86_remove(struct i2c_client *client) kfree(pdata->edid); - ti_sn65dsi86_debugfs_remove(pdata); - drm_bridge_remove(&pdata->bridge); of_node_put(pdata->host_node); From patchwork Fri Apr 23 16:58:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF888C43600 for ; Fri, 23 Apr 2021 16:59:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95F29613BB for ; Fri, 23 Apr 2021 16:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243292AbhDWRA3 (ORCPT ); Fri, 23 Apr 2021 13:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243287AbhDWRAZ (ORCPT ); Fri, 23 Apr 2021 13:00:25 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E87AC061345 for ; Fri, 23 Apr 2021 09:59:47 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id o16so11907061plg.5 for ; Fri, 23 Apr 2021 09:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PWSTk8yjg8c/25DOgu081XQS3tOSDuzAXjHB+ct/NxQ=; b=N29k47+cjV+TNWpPVYMflFNf2uGyR+2NC30H/ixMKHLiWu+nyWoke9hNvE5lEOAHA9 9cPbbigqGvYOC7tcPiOxdGfDlunl/1V1Jos/fWqqlvF8XCYHdTgFG2IjIiKr1g+i8mo0 2BB4NjUQfvJwilJeFrHhxB3qJClCjuUNy3zII= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PWSTk8yjg8c/25DOgu081XQS3tOSDuzAXjHB+ct/NxQ=; b=VfU4mHuHIkJhF31F7YblmIO639sHsAN6qS7ceEkekMKLNOYGxtSVBzvHde1jPECZTX PwgYz5uWmh1ls2UlXeL2zKztLOk0nvg2PXqcoPgR1jLBp81f3oGkwWkbmLlB+aFiaPA2 usqGbNAQ/rmRk2Xw1C1Wed99P93dOUozAlf88pdBESnUCbgYPGNE+JzExBKaE7CDm+OK //A3tj1UPsSGim+17Wwsuz3sI/oAP6auyG6/dGaaAzgBSwrjbS0geMvdl44LOtzCAeJ6 795hgFlegzp8mYfSwNO8TLdJpNlKaJqbVIQX0TxZCSlYaywfLxR1Z4og3KAP8c3E7mtR 8ZWg== X-Gm-Message-State: AOAM531cHGMip+i+Gexw5WupGSuJDpWbfoRwgThVHkxLq6lRn7iKqLVX PSHOli7gEaOFC5tPSN+JO5q7xA== X-Google-Smtp-Source: ABdhPJwO0k3uruj4cWw+nLQcqrGKZkyz0aXhJ9udAibha281Xy9iWM1aDlUx1M8xnJ35es7+zxrvbw== X-Received: by 2002:a17:902:361:b029:e9:8392:7abd with SMTP id 88-20020a1709020361b02900e983927abdmr4692725pld.8.1619197186901; Fri, 23 Apr 2021 09:59:46 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:46 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 06/20] drm/bridge: ti-sn65dsi86: Add local var for "dev" to simplify probe Date: Fri, 23 Apr 2021 09:58:52 -0700 Message-Id: <20210423095743.v5.6.I83925d8ca228bdc5f55b17854c90754efc6a470e@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Tiny cleanup for probe so we don't keep having to specify "&client->dev" or "pdata->dev". No functional changes intended. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- Changes in v5: - Rebased atop the pm_runtime patch, which got reordered. drivers/gpu/drm/bridge/ti-sn65dsi86.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 8aa36074aab9..c868193f5b8f 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -1232,6 +1232,7 @@ static void ti_sn65dsi86_runtime_disable(void *data) static int ti_sn65dsi86_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct device *dev = &client->dev; struct ti_sn65dsi86 *pdata; int ret; @@ -1240,8 +1241,7 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, return -ENODEV; } - pdata = devm_kzalloc(&client->dev, sizeof(struct ti_sn65dsi86), - GFP_KERNEL); + pdata = devm_kzalloc(dev, sizeof(struct ti_sn65dsi86), GFP_KERNEL); if (!pdata) return -ENOMEM; @@ -1252,26 +1252,24 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, return PTR_ERR(pdata->regmap); } - pdata->dev = &client->dev; + pdata->dev = dev; - ret = drm_of_find_panel_or_bridge(pdata->dev->of_node, 1, 0, - &pdata->panel, NULL); + ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &pdata->panel, NULL); if (ret) { DRM_ERROR("could not find any panel node\n"); return ret; } - dev_set_drvdata(&client->dev, pdata); + dev_set_drvdata(dev, pdata); - pdata->enable_gpio = devm_gpiod_get(pdata->dev, "enable", - GPIOD_OUT_LOW); + pdata->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(pdata->enable_gpio)) { DRM_ERROR("failed to get enable gpio from DT\n"); ret = PTR_ERR(pdata->enable_gpio); return ret; } - ti_sn_bridge_parse_lanes(pdata, client->dev.of_node); + ti_sn_bridge_parse_lanes(pdata, dev->of_node); ret = ti_sn65dsi86_parse_regulators(pdata); if (ret) { @@ -1279,7 +1277,7 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, return ret; } - pdata->refclk = devm_clk_get_optional(pdata->dev, "refclk"); + pdata->refclk = devm_clk_get_optional(dev, "refclk"); if (IS_ERR(pdata->refclk)) return PTR_ERR(pdata->refclk); @@ -1287,8 +1285,8 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, if (ret) return ret; - pm_runtime_enable(pdata->dev); - ret = devm_add_action_or_reset(pdata->dev, ti_sn65dsi86_runtime_disable, pdata->dev); + pm_runtime_enable(dev); + ret = devm_add_action_or_reset(dev, ti_sn65dsi86_runtime_disable, dev); if (ret) return ret; @@ -1299,12 +1297,12 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, i2c_set_clientdata(client, pdata); pdata->aux.name = "ti-sn65dsi86-aux"; - pdata->aux.dev = pdata->dev; + pdata->aux.dev = dev; pdata->aux.transfer = ti_sn_aux_transfer; drm_dp_aux_init(&pdata->aux); pdata->bridge.funcs = &ti_sn_bridge_funcs; - pdata->bridge.of_node = client->dev.of_node; + pdata->bridge.of_node = dev->of_node; drm_bridge_add(&pdata->bridge); From patchwork Fri Apr 23 16:58:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A055FC4360C for ; Fri, 23 Apr 2021 16:59:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 868E06134F for ; Fri, 23 Apr 2021 16:59:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243334AbhDWRA2 (ORCPT ); Fri, 23 Apr 2021 13:00:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243292AbhDWRAZ (ORCPT ); Fri, 23 Apr 2021 13:00:25 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54CC1C061346 for ; Fri, 23 Apr 2021 09:59:48 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id s20so9679557plr.13 for ; Fri, 23 Apr 2021 09:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=18NetlXwajgnpGQtVunxvSsH/vFYq/mVRN14SJhebag=; b=Ck7dXMTbcXqeGgybSMoVJO8he10e+uD3PDZhu711leqKrmLBpUQUXHTfjVUNGYvep7 wBw9BaFyMxvm+8ABL/EHL06v2KrcsvmFeZig4SsNT9h3vPzTc5qxpJgd5q6+fB1Xb3kK l0QMDHopNz0pzurKAeArFflw0HhvXrjUQQBEk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=18NetlXwajgnpGQtVunxvSsH/vFYq/mVRN14SJhebag=; b=VE10viwOR6boRQnVNMAPZE2ns8ImFWA14lnYdSs8y0F25OzVfwc5bDVptmMPLaUlDu 8o/c73k4dhkUvPE6iH2amLXiqw3lIkNZnzjqBq9oAsnGzv3ZgqtlEHqHqlWFSIaMrhi/ Xtz8kD1E6l40tMikLyoPeCAauCH4p4vNfXusUodlFv5oE7a4yCDE4m1VaYuUALqi8iGX w+nMJhYZyvcAuuAOUF9ZGhuob3bLsz8yFVfBWVT7SfNfksIPrNToNKfnSAe8ryxcSJLF k50H619vymNMbo3YF2ubgS9QPJROIMytRTZivwtc8RMtHzSpPVp99ulrz1mOG6+9hVVD +5Fg== X-Gm-Message-State: AOAM530jexxD/RMbqQvPj2UMPInLi7h1QlGjdqQfUDYwNU3LsWfrbYJz WfH6dUWoDbsKWRLjE9eYu5a9+jypqfscyvKD X-Google-Smtp-Source: ABdhPJwN39XHiMoFkDUGK/jYMlHhuJ0OnCKc4g/vY5QfA/Nq2SW/ZbIYpEoQf3oJgDhOndPFkJpK4Q== X-Received: by 2002:a17:90a:540b:: with SMTP id z11mr5459263pjh.133.1619197187959; Fri, 23 Apr 2021 09:59:47 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:47 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 07/20] drm/bridge: ti-sn65dsi86: Cleanup managing of drvdata Date: Fri, 23 Apr 2021 09:58:53 -0700 Message-Id: <20210423095743.v5.7.If5d4d4e22e97bebcd493b76765c1759527705620@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's: - Set the drvdata as soon as it's allocated. This just sets up a pointer so there's no downside here. - Remove the useless call to i2c_set_clientdata() which is literally the same thing as dev_set_drvdata(). No functional changes intended. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/bridge/ti-sn65dsi86.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index c868193f5b8f..75a41198993f 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -1244,6 +1244,8 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, pdata = devm_kzalloc(dev, sizeof(struct ti_sn65dsi86), GFP_KERNEL); if (!pdata) return -ENOMEM; + dev_set_drvdata(dev, pdata); + pdata->dev = dev; pdata->regmap = devm_regmap_init_i2c(client, &ti_sn65dsi86_regmap_config); @@ -1252,16 +1254,12 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, return PTR_ERR(pdata->regmap); } - pdata->dev = dev; - ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &pdata->panel, NULL); if (ret) { DRM_ERROR("could not find any panel node\n"); return ret; } - dev_set_drvdata(dev, pdata); - pdata->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(pdata->enable_gpio)) { DRM_ERROR("failed to get enable gpio from DT\n"); @@ -1294,8 +1292,6 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, if (ret) return ret; - i2c_set_clientdata(client, pdata); - pdata->aux.name = "ti-sn65dsi86-aux"; pdata->aux.dev = dev; pdata->aux.transfer = ti_sn_aux_transfer; From patchwork Fri Apr 23 16:58:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFD94C433ED for ; Fri, 23 Apr 2021 16:59:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A68A611AE for ; Fri, 23 Apr 2021 16:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243287AbhDWRAa (ORCPT ); Fri, 23 Apr 2021 13:00:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243317AbhDWRA1 (ORCPT ); Fri, 23 Apr 2021 13:00:27 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 760CCC06138D for ; Fri, 23 Apr 2021 09:59:49 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id kb13-20020a17090ae7cdb02901503d67f0beso4785006pjb.0 for ; Fri, 23 Apr 2021 09:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PaR/egwiLTXMp/V4QlaRuOrtKs7oGBmyLwSo5ArZpK0=; b=aZPFRpeDad0DFJAa59kkFQtZwo7+BNKMT+alJcwybBsazT/Cnig/UduYNqNWE2aBwO Q5PbmhrZ+J8XFHjO5n/Wyi1f8hpsSXqw0GsxA0UWOYdcClq24UozbEsrvtKwd+wRDL8Q wnDLDB7nDJGm8ffl4hj74tWRBHMeHj+m+sJbg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PaR/egwiLTXMp/V4QlaRuOrtKs7oGBmyLwSo5ArZpK0=; b=E5Za+5tjpGyJ2Rc2yljeNLGzW8lGHilBaSVSizFdIpUMZ66bGi5Q27JkJQUUCe2AUE I7IhnOeQxsUIDeGdI8xDjOBx5R3dwoqgZ52LVa7xjvQOdyDg8G77SI77Pl69s0yATgnl ZyfFKEOzBgKe/Ae+vFhh7B8E2acjTYBBRa82KslhCEmHBNb4GrwTu037HhGYYe4l3kEI hWtSBIWTPKyiVf1ltTwrYVEfKSidE9/1vjCDxjwCmBw/25yIkOEcLwckJolKdzj+dSep iV/YkDJDzy6mH8MRQtvBnv+F3SS6f+g1aaUTGXdeR//vJpALwAAOzbc9335oX5LDzpp3 BhUg== X-Gm-Message-State: AOAM530fNatZEHgXNnzF6fdegRAie1grx3nNxPZ99TFKJ/NBjM0fAbm7 eQ4BE9BvDWuifBpKd0cMFmRJEQ== X-Google-Smtp-Source: ABdhPJyl4eJ4vKH9OKx0CWgwPTyFJfbmpRq+PZblaJpQI/rjjJLT30UQw8KAqa8Vh6G/JI+s3NBHfw== X-Received: by 2002:a17:902:e289:b029:eb:29e7:beda with SMTP id o9-20020a170902e289b02900eb29e7bedamr4950923plc.78.1619197189070; Fri, 23 Apr 2021 09:59:49 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:48 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 08/20] drm/bridge: ti-sn65dsi86: Move all the chip-related init to the start Date: Fri, 23 Apr 2021 09:58:54 -0700 Message-Id: <20210423095743.v5.8.Ide8ba40feb2e43bc98a11edbb08d696d62dcd83e@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This is just code motion of the probe routine to move all the things that are for the "whole chip" (instead of the GPIO parts or the MIPI-to-eDP parts) together at the start of probe. This is in preparation for breaking the driver into sub-drivers. Since we're using devm for all of the "whole chip" stuff this is actually quite easy now. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/bridge/ti-sn65dsi86.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 75a41198993f..68673f736b23 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -1254,12 +1254,6 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, return PTR_ERR(pdata->regmap); } - ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &pdata->panel, NULL); - if (ret) { - DRM_ERROR("could not find any panel node\n"); - return ret; - } - pdata->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(pdata->enable_gpio)) { DRM_ERROR("failed to get enable gpio from DT\n"); @@ -1267,8 +1261,6 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, return ret; } - ti_sn_bridge_parse_lanes(pdata, dev->of_node); - ret = ti_sn65dsi86_parse_regulators(pdata); if (ret) { DRM_ERROR("failed to parse regulators\n"); @@ -1279,12 +1271,22 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, if (IS_ERR(pdata->refclk)) return PTR_ERR(pdata->refclk); - ret = ti_sn_bridge_parse_dsi_host(pdata); + pm_runtime_enable(dev); + ret = devm_add_action_or_reset(dev, ti_sn65dsi86_runtime_disable, dev); if (ret) return ret; - pm_runtime_enable(dev); - ret = devm_add_action_or_reset(dev, ti_sn65dsi86_runtime_disable, dev); + ti_sn65dsi86_debugfs_init(pdata); + + ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &pdata->panel, NULL); + if (ret) { + DRM_ERROR("could not find any panel node\n"); + return ret; + } + + ti_sn_bridge_parse_lanes(pdata, dev->of_node); + + ret = ti_sn_bridge_parse_dsi_host(pdata); if (ret) return ret; @@ -1302,8 +1304,6 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, drm_bridge_add(&pdata->bridge); - ti_sn65dsi86_debugfs_init(pdata); - return 0; } From patchwork Fri Apr 23 16:58:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 127B1C43603 for ; Fri, 23 Apr 2021 16:59:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBA1F611AE for ; Fri, 23 Apr 2021 16:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243365AbhDWRAb (ORCPT ); Fri, 23 Apr 2021 13:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243324AbhDWRA1 (ORCPT ); Fri, 23 Apr 2021 13:00:27 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC981C06174A for ; Fri, 23 Apr 2021 09:59:50 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id v13so11921812ple.9 for ; Fri, 23 Apr 2021 09:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h0BQt98cg9Cmzb0ViPALeB+8PlK22LbbXMDR3e5Py7w=; b=EHh1L6ZZLLN3kyZ24Iqh3VsuPfebCKg4a0AJ39BFCP3pcHw0c8vHwl+6MBIPCV/aO3 6sDLvBBnpftNhra5Jq5x+ew4v+13y7oVbWKvfcJPMkxtkEuJ2D+kpjce9xvBqdYYCTzf 2+ljvFe4sVngtc/SulDVnIjoUpjPNVJv0orL8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h0BQt98cg9Cmzb0ViPALeB+8PlK22LbbXMDR3e5Py7w=; b=AWcERJvsMpaX9fBsBsp8QcIaK3VfZWsYD+hmZLxwA634UihTt2n5NBcy3AKstO3l3f P2qpel0a1FUm9ZZ3L39S8Axe3lhAKfM3AeflEIybt5G1t+tzUqsAwT8RlobozzmB4dOL i8hQeSemHDlnrYiLgZ4LsUdRxHgle5ZhIrIp4uAus6DFYkFhgGOKuuPqB/AdsBgIT3kn y/BgOwXEt/rNwHmcHL4TZ6o1laKVmX+DTFAcExdIcGRPZl2MkUeW/GWuCQzb/fIfBYdM 8QHvqt5jX1URqumm+6NqG/Oq2QJQsrEPuAvrMYQAUqbV9MKAqGNwCDT21wk9Yd5sLH4g Ux8g== X-Gm-Message-State: AOAM53219+OMflhePlD15lFMkCLv0YUQxxzlEumO9hXJljb5Tui70auX rgkLkM3Wk51fFYs5gtXcFTJD1Q== X-Google-Smtp-Source: ABdhPJxKpa65FeJ2WN5GIGAJlE31Vyr1YzGQAjtTaDIV8yYTuKu6Ch2PrCQz5mo6UGrmPYEYJc6Hqw== X-Received: by 2002:a17:903:2490:b029:e6:faf5:86df with SMTP id p16-20020a1709032490b02900e6faf586dfmr4839937plw.69.1619197190226; Fri, 23 Apr 2021 09:59:50 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:49 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 09/20] drm/bridge: ti-sn65dsi86: Break GPIO and MIPI-to-eDP bridge into sub-drivers Date: Fri, 23 Apr 2021 09:58:55 -0700 Message-Id: <20210423095743.v5.9.I3e68fa38c4ccbdbdf145cad2b01e83a1e5eac302@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's use the newly minted aux bus to break up the driver into sub drivers. We're not doing a full breakup here: all the code is still in the same file and remains largely untouched. The big goal here of using sub-drivers is to allow part of our code to finish probing even if some other code needs to defer. This can solve some chicken-and-egg problems. Specifically: - In commit 48834e6084f1 ("drm/panel-simple: Support hpd-gpios for delaying prepare()") we had to add a bit of a hack to simpel-panel to support HPD showing up late. We can get rid of that hack now since the GPIO part of our driver can finish probing early. - We have a desire to expose our DDC bus to simple-panel (and perhaps to a backlight driver?). That will end up with the same chicken-and-egg problem. A future patch to move this to a sub-driver will fix it. - If/when we support the PWM functionality present in the bridge chip for a backlight we'll end up with another chicken-and-egg problem. If we allow the PWM to be a sub-driver too then it solves this problem. Signed-off-by: Douglas Anderson --- Changes in v5: - Fix module compile problems (Bjorn + kbuild bot) - Remove useless MODULE_DEVICE_TABLE (Bjorn). drivers/gpu/drm/bridge/Kconfig | 1 + drivers/gpu/drm/bridge/ti-sn65dsi86.c | 252 ++++++++++++++++++++------ 2 files changed, 200 insertions(+), 53 deletions(-) diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index d907a91a2ee8..bdec664f27ec 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -275,6 +275,7 @@ config DRM_TI_SN65DSI86 select REGMAP_I2C select DRM_PANEL select DRM_MIPI_DSI + select AUXILIARY_BUS help Texas Instruments SN65DSI86 DSI to eDP Bridge driver diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 68673f736b23..0bd1a1d1453e 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -4,6 +4,7 @@ * datasheet: https://www.ti.com/lit/ds/symlink/sn65dsi86.pdf */ +#include #include #include #include @@ -113,7 +114,10 @@ /** * struct ti_sn65dsi86 - Platform data for ti-sn65dsi86 driver. - * @dev: Pointer to our device. + * @bridge_aux: AUX-bus sub device for MIPI-to-eDP bridge functionality. + * @gpio_aux: AUX-bus sub device for GPIO controller functionality. + * + * @dev: Pointer to the top level (i2c) device. * @regmap: Regmap for accessing i2c. * @aux: Our aux channel. * @bridge: Our bridge. @@ -140,6 +144,9 @@ * each other's read-modify-write. */ struct ti_sn65dsi86 { + struct auxiliary_device bridge_aux; + struct auxiliary_device gpio_aux; + struct device *dev; struct regmap *regmap; struct drm_dp_aux aux; @@ -1136,8 +1143,10 @@ static const char * const ti_sn_bridge_gpio_names[SN_NUM_GPIOS] = { "GPIO1", "GPIO2", "GPIO3", "GPIO4" }; -static int ti_sn_setup_gpio_controller(struct ti_sn65dsi86 *pdata) +static int ti_sn_gpio_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) { + struct ti_sn65dsi86 *pdata = dev_get_drvdata(adev->dev.parent); int ret; /* Only init if someone is going to use us as a GPIO controller */ @@ -1159,20 +1168,41 @@ static int ti_sn_setup_gpio_controller(struct ti_sn65dsi86 *pdata) pdata->gchip.names = ti_sn_bridge_gpio_names; pdata->gchip.ngpio = SN_NUM_GPIOS; pdata->gchip.base = -1; - ret = devm_gpiochip_add_data(pdata->dev, &pdata->gchip, pdata); + ret = devm_gpiochip_add_data(&adev->dev, &pdata->gchip, pdata); if (ret) dev_err(pdata->dev, "can't add gpio chip\n"); return ret; } -#else +static const struct auxiliary_device_id ti_sn_gpio_id_table[] = { + { .name = "ti_sn65dsi86.gpio", }, + {}, +}; -static inline int ti_sn_setup_gpio_controller(struct ti_sn65dsi86 *pdata) +MODULE_DEVICE_TABLE(auxiliary, ti_sn_gpio_id_table); + +static struct auxiliary_driver ti_sn_gpio_driver = { + .name = "gpio", + .probe = ti_sn_gpio_probe, + .id_table = ti_sn_gpio_id_table, +}; + +static int __init ti_sn_gpio_register(void) { - return 0; + return auxiliary_driver_register(&ti_sn_gpio_driver); } +static void __exit ti_sn_gpio_unregister(void) +{ + auxiliary_driver_unregister(&ti_sn_gpio_driver); +} + +#else + +static inline int ti_sn_gpio_register(void) { return 0; } +static inline void ti_sn_gpio_unregister(void) {} + #endif static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata, @@ -1224,11 +1254,124 @@ static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata, pdata->ln_polrs = ln_polrs; } +static int ti_sn_bridge_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct ti_sn65dsi86 *pdata = dev_get_drvdata(adev->dev.parent); + struct device_node *np = pdata->dev->of_node; + int ret; + + ret = drm_of_find_panel_or_bridge(np, 1, 0, &pdata->panel, NULL); + if (ret) { + DRM_ERROR("could not find any panel node\n"); + return ret; + } + + ti_sn_bridge_parse_lanes(pdata, np); + + ret = ti_sn_bridge_parse_dsi_host(pdata); + if (ret) + return ret; + + pdata->aux.name = "ti-sn65dsi86-aux"; + pdata->aux.dev = pdata->dev; + pdata->aux.transfer = ti_sn_aux_transfer; + drm_dp_aux_init(&pdata->aux); + + pdata->bridge.funcs = &ti_sn_bridge_funcs; + pdata->bridge.of_node = np; + + drm_bridge_add(&pdata->bridge); + + return 0; +} + +static void ti_sn_bridge_remove(struct auxiliary_device *adev) +{ + struct ti_sn65dsi86 *pdata = dev_get_drvdata(adev->dev.parent); + + if (!pdata) + return; + + if (pdata->dsi) { + mipi_dsi_detach(pdata->dsi); + mipi_dsi_device_unregister(pdata->dsi); + } + + kfree(pdata->edid); + + drm_bridge_remove(&pdata->bridge); + + of_node_put(pdata->host_node); +} + +static const struct auxiliary_device_id ti_sn_bridge_id_table[] = { + { .name = "ti_sn65dsi86.bridge", }, + {}, +}; + +static struct auxiliary_driver ti_sn_bridge_driver = { + .name = "bridge", + .probe = ti_sn_bridge_probe, + .remove = ti_sn_bridge_remove, + .id_table = ti_sn_bridge_id_table, +}; + static void ti_sn65dsi86_runtime_disable(void *data) { pm_runtime_disable(data); } +static void ti_sn65dsi86_uninit_aux(void *data) +{ + auxiliary_device_uninit(data); +} + +static void ti_sn65dsi86_delete_aux(void *data) +{ + auxiliary_device_delete(data); +} + +/* + * AUX bus docs say that a non-NULL release is mandatory, but it makes no + * sense for the model used here where all of the aux devices are allocated + * in the single shared structure. We'll use this noop as a workaround. + */ +static void ti_sn65dsi86_noop(struct device *dev) {} + +static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata, + struct auxiliary_device *aux, + const char *name) +{ + struct device *dev = pdata->dev; + int ret; + + /* + * NOTE: It would be nice to set the "of_node" of our children to be + * the same "of_node"" that the top-level component has. That doesn't + * work, though, since pinctrl will try (and fail) to reserve the + * pins again. Until that gets sorted out the children will just need + * to look at the of_node of the main device. + */ + + aux->name = name; + aux->dev.parent = dev; + aux->dev.release = ti_sn65dsi86_noop; + ret = auxiliary_device_init(aux); + if (ret) + return ret; + ret = devm_add_action_or_reset(dev, ti_sn65dsi86_uninit_aux, aux); + if (ret) + return ret; + + ret = auxiliary_device_add(aux); + if (ret) + return ret; + ret = devm_add_action_or_reset(dev, ti_sn65dsi86_delete_aux, aux); + + return ret; +} + static int ti_sn65dsi86_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1278,54 +1421,24 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, ti_sn65dsi86_debugfs_init(pdata); - ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &pdata->panel, NULL); - if (ret) { - DRM_ERROR("could not find any panel node\n"); - return ret; - } - - ti_sn_bridge_parse_lanes(pdata, dev->of_node); - - ret = ti_sn_bridge_parse_dsi_host(pdata); - if (ret) - return ret; - - ret = ti_sn_setup_gpio_controller(pdata); - if (ret) - return ret; - - pdata->aux.name = "ti-sn65dsi86-aux"; - pdata->aux.dev = dev; - pdata->aux.transfer = ti_sn_aux_transfer; - drm_dp_aux_init(&pdata->aux); - - pdata->bridge.funcs = &ti_sn_bridge_funcs; - pdata->bridge.of_node = dev->of_node; - - drm_bridge_add(&pdata->bridge); - - return 0; -} - -static int ti_sn65dsi86_remove(struct i2c_client *client) -{ - struct ti_sn65dsi86 *pdata = i2c_get_clientdata(client); - - if (!pdata) - return -EINVAL; + /* + * Break ourselves up into a collection of aux devices. The only real + * motiviation here is to solve the chicken-and-egg problem of probe + * ordering. The bridge wants the panel to be there when it probes. + * The panel wants its HPD GPIO (provided by sn65dsi86 on some boards) + * when it probes. There will soon be other devices (DDC I2C bus, PWM) + * that have the same problem. Having sub-devices allows the some sub + * devices to finish probing even if others return -EPROBE_DEFER and + * gets us around the problems. + */ - if (pdata->dsi) { - mipi_dsi_detach(pdata->dsi); - mipi_dsi_device_unregister(pdata->dsi); + if (IS_ENABLED(CONFIG_OF_GPIO)) { + ret = ti_sn65dsi86_add_aux_device(pdata, &pdata->gpio_aux, "gpio"); + if (ret) + return ret; } - kfree(pdata->edid); - - drm_bridge_remove(&pdata->bridge); - - of_node_put(pdata->host_node); - - return 0; + return ti_sn65dsi86_add_aux_device(pdata, &pdata->bridge_aux, "bridge"); } static struct i2c_device_id ti_sn65dsi86_id[] = { @@ -1347,10 +1460,43 @@ static struct i2c_driver ti_sn65dsi86_driver = { .pm = &ti_sn65dsi86_pm_ops, }, .probe = ti_sn65dsi86_probe, - .remove = ti_sn65dsi86_remove, .id_table = ti_sn65dsi86_id, }; -module_i2c_driver(ti_sn65dsi86_driver); + +static int __init ti_sn65dsi86_init(void) +{ + int ret; + + ret = i2c_add_driver(&ti_sn65dsi86_driver); + if (ret) + return ret; + + ret = ti_sn_gpio_register(); + if (ret) + goto err_main_was_registered; + + ret = auxiliary_driver_register(&ti_sn_bridge_driver); + if (ret) + goto err_gpio_was_registered; + + return 0; + +err_gpio_was_registered: + ti_sn_gpio_unregister(); +err_main_was_registered: + i2c_del_driver(&ti_sn65dsi86_driver); + + return ret; +} +module_init(ti_sn65dsi86_init); + +static void __exit ti_sn65dsi86_exit(void) +{ + auxiliary_driver_unregister(&ti_sn_bridge_driver); + ti_sn_gpio_unregister(); + i2c_del_driver(&ti_sn65dsi86_driver); +} +module_exit(ti_sn65dsi86_exit); MODULE_AUTHOR("Sandeep Panda "); MODULE_DESCRIPTION("sn65dsi86 DSI to eDP bridge driver"); From patchwork Fri Apr 23 16:58:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40444C433B4 for ; Fri, 23 Apr 2021 17:00:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EDE16113B for ; Fri, 23 Apr 2021 17:00:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243443AbhDWRAi (ORCPT ); Fri, 23 Apr 2021 13:00:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243338AbhDWRA2 (ORCPT ); Fri, 23 Apr 2021 13:00:28 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2619C061344 for ; Fri, 23 Apr 2021 09:59:51 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id g1-20020a17090adac1b0290150d07f9402so1502079pjx.5 for ; Fri, 23 Apr 2021 09:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iBUj5kQ7X9fmMOQ4CZ8JChILd2WBNcvTtcV/hSGMVvg=; b=FdxPxbY7ijX71QBS18OIzi0n9sM2odFgKMp717noKgZ2ye6GMt0SW1OvPd/Rehb+6h +GXiaiJfaAVKyM6/PiiioDTEQZ4BDLR2qq0n2pk5tk2gj07eirFILT0zYteJxyt8L1kS wiaJkmwfDd19bvqFN19QAtqryqglfaM4jRHOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iBUj5kQ7X9fmMOQ4CZ8JChILd2WBNcvTtcV/hSGMVvg=; b=llurn0yNVT4afzMIJiksXahP7HjZNSezUWzocmkZ40WvjZNpPloaoF/4Vf2qR1QTxN zave8dIERSYFqLeqtsSSimFanuWjreCmu6I7NI5o6fgnj6M9YQ3BL3r+ZopWSdIEiMSd ZTIGnSM7IOXdJh2/YMMNMLVKqaBJzVyPYhDLtbyzq11PrZcFT2cz9Tiqhhb+d4/J1XZO pS/Qsp91vVVlWIdVeQDbNmhAzoT03sh6pHsef1ugDT8etJqz4COMMFdAxULNn0WFx06J nHMdC/Ua36vjRqQUXXzKBOniLlrovVaMbiA4DCdcIosBdIUKxfLJD9qA5kyL3xP7dAmN 00UA== X-Gm-Message-State: AOAM532LWn7qMa/G25WlM3v+bv7eZwHF7KCz4udz5qJW8bD1HGNft6i/ E1HrNNF3x0d2YwQgdhwNfkaRRQ== X-Google-Smtp-Source: ABdhPJxyF0nN/4vsiL7lk43a0I/qpwpmwLXPqQ05NyVO9W3gD4zw+0dRDftgTSkOcNerASpW3ts8Aw== X-Received: by 2002:a17:90b:2306:: with SMTP id mt6mr5416893pjb.119.1619197191335; Fri, 23 Apr 2021 09:59:51 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:50 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Thierry Reding , linux-kernel@vger.kernel.org Subject: [PATCH v5 10/20] drm/panel: panel-simple: Get rid of hacky HPD chicken-and-egg code Date: Fri, 23 Apr 2021 09:58:56 -0700 Message-Id: <20210423095743.v5.10.I40eeedc23459d1e3fc96fa6cdad775d88c6e706c@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org When I added support for the hpd-gpio to simple-panel in commit 48834e6084f1 ("drm/panel-simple: Support hpd-gpios for delaying prepare()"), I added a special case to handle a circular dependency I was running into on the ti-sn65dsi86 bridge chip. On my board the hpd-gpio is actually provided by the bridge chip. That was causing some circular dependency problems that I had to work around by getting the hpd-gpio late. I've now reorganized the ti-sn65dsi86 bridge chip driver to be a collection of sub-drivers. Now the GPIO part can probe separately and that breaks the chain. Let's get rid of the old code to clean things up. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/panel/panel-simple.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 9746eda6f675..bd208abcbf07 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -366,8 +366,7 @@ static int panel_simple_unprepare(struct drm_panel *panel) return 0; } -static int panel_simple_get_hpd_gpio(struct device *dev, - struct panel_simple *p, bool from_probe) +static int panel_simple_get_hpd_gpio(struct device *dev, struct panel_simple *p) { int err; @@ -375,17 +374,10 @@ static int panel_simple_get_hpd_gpio(struct device *dev, if (IS_ERR(p->hpd_gpio)) { err = PTR_ERR(p->hpd_gpio); - /* - * If we're called from probe we won't consider '-EPROBE_DEFER' - * to be an error--we'll leave the error code in "hpd_gpio". - * When we try to use it we'll try again. This allows for - * circular dependencies where the component providing the - * hpd gpio needs the panel to init before probing. - */ - if (err != -EPROBE_DEFER || !from_probe) { + if (err != -EPROBE_DEFER) dev_err(dev, "failed to get 'hpd' GPIO: %d\n", err); - return err; - } + + return err; } return 0; @@ -416,12 +408,6 @@ static int panel_simple_prepare_once(struct panel_simple *p) msleep(delay); if (p->hpd_gpio) { - if (IS_ERR(p->hpd_gpio)) { - err = panel_simple_get_hpd_gpio(dev, p, false); - if (err) - goto error; - } - if (p->desc->delay.hpd_absent_delay) hpd_wait_us = p->desc->delay.hpd_absent_delay * 1000UL; else @@ -682,7 +668,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd"); if (!panel->no_hpd) { - err = panel_simple_get_hpd_gpio(dev, panel, true); + err = panel_simple_get_hpd_gpio(dev, panel); if (err) return err; } From patchwork Fri Apr 23 16:58:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13D18C43470 for ; Fri, 23 Apr 2021 17:00:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E05386113B for ; Fri, 23 Apr 2021 17:00:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243458AbhDWRAj (ORCPT ); Fri, 23 Apr 2021 13:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243353AbhDWRA3 (ORCPT ); Fri, 23 Apr 2021 13:00:29 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFC79C06138B for ; Fri, 23 Apr 2021 09:59:52 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id s20so9679665plr.13 for ; Fri, 23 Apr 2021 09:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gV3qYwahIARQiQrXn6qcnB2XNtIx8vMB6/KiYYZ2Nu0=; b=ODW8f2PHl6os3mSPPZkE6MzhNedNFfpKM5Cll2rpPJj/CieenT2TJvOrCFLAddwT7H h34InzeviKqXtD5UwhSUPmp7/7PwMZumIXib+w6JAqGZrl+xK93wv3tzjpFrL0kZZIXN DVRIqdDSLKIzD/YTMGLJCvaciUqvedx6Ary0M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gV3qYwahIARQiQrXn6qcnB2XNtIx8vMB6/KiYYZ2Nu0=; b=Y0pMJ7KKLnrYAur6AO9rMUiTbio4nCUqvHuvQwBlY+ZC8GKICN9NvYdRXLYh3eHDik Q0hJeD5kJqbMIbp3y1zOCp2PvrtYay6UaFV/QAZcKTLSK1zZ3gvulMUTGiVis7hRZwAV sTP/p4nKvayH8JJ+pV1fG308u+Qxa7FQ+G2Jt4ygwDo4WopwJAVIU3gBcikXc3C7d9st pNcwxUJqDk16p5xbEaCGJXwg2evXm+fn331Fy02xdl/MT3pO5Q9ruONMUFT3ZA365+Ax GIXg5TjsciEp00mTAjdKkY1oPx6B5DG/toL4Ye4ijlT3uauZS7JPrU1PZvakSfjJIgHB mfmw== X-Gm-Message-State: AOAM531zbWKlJstAAdQXkCom9hwCsOTIoSWmWuQ9lsDsSgYyuQcj9/kp Lm+W4qJfwAZHS89lI56A+L9SUw== X-Google-Smtp-Source: ABdhPJxlBL9L1zQOEo1208W4LdTrk3u3cxg+rADQcsddskPPxY8toqxStFbKWD53qfQjCXP5FGOXDQ== X-Received: by 2002:a17:90a:88e:: with SMTP id v14mr5347003pjc.107.1619197192542; Fri, 23 Apr 2021 09:59:52 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:52 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 11/20] drm/bridge: ti-sn65dsi86: Use pm_runtime autosuspend Date: Fri, 23 Apr 2021 09:58:57 -0700 Message-Id: <20210423095743.v5.11.I4c0b4a87e4dc19e5023b4d0a21bbfa6d9c09ebd8@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's make the bridge use autosuspend with a 500ms delay. This is in preparation for promoting DP AUX transfers to their own sub-driver so that we're not constantly powering up and down the device as we transfer all the chunks. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/bridge/ti-sn65dsi86.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 0bd1a1d1453e..49b76b2ffe25 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -243,7 +243,7 @@ static int status_show(struct seq_file *s, void *data) seq_printf(s, "[0x%02x] = 0x%08x\n", reg, val); } - pm_runtime_put(pdata->dev); + pm_runtime_put_autosuspend(pdata->dev); return 0; } @@ -293,7 +293,7 @@ static int ti_sn_bridge_connector_get_modes(struct drm_connector *connector) if (!edid) { pm_runtime_get_sync(pdata->dev); edid = pdata->edid = drm_get_edid(connector, &pdata->aux.ddc); - pm_runtime_put(pdata->dev); + pm_runtime_put_autosuspend(pdata->dev); } if (edid && drm_edid_is_valid(edid)) { @@ -419,7 +419,7 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, /* check if continuous dsi clock is required or not */ pm_runtime_get_sync(pdata->dev); regmap_read(pdata->regmap, SN_DPPLL_SRC_REG, &val); - pm_runtime_put(pdata->dev); + pm_runtime_put_autosuspend(pdata->dev); if (!(val & DPPLL_CLK_SRC_DSICLK)) dsi->mode_flags |= MIPI_DSI_CLOCK_NON_CONTINUOUS; @@ -1050,7 +1050,7 @@ static int ti_sn_bridge_gpio_get(struct gpio_chip *chip, unsigned int offset) */ pm_runtime_get_sync(pdata->dev); ret = regmap_read(pdata->regmap, SN_GPIO_IO_REG, &val); - pm_runtime_put(pdata->dev); + pm_runtime_put_autosuspend(pdata->dev); if (ret) return ret; @@ -1101,7 +1101,7 @@ static int ti_sn_bridge_gpio_direction_input(struct gpio_chip *chip, * it off and when it comes back it will have lost all state, but * that's OK because the default is input and we're now an input. */ - pm_runtime_put(pdata->dev); + pm_runtime_put_autosuspend(pdata->dev); return 0; } @@ -1127,7 +1127,7 @@ static int ti_sn_bridge_gpio_direction_output(struct gpio_chip *chip, SN_GPIO_MUX_OUTPUT << shift); if (ret) { clear_bit(offset, pdata->gchip_output); - pm_runtime_put(pdata->dev); + pm_runtime_put_autosuspend(pdata->dev); } return ret; @@ -1418,6 +1418,8 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, ret = devm_add_action_or_reset(dev, ti_sn65dsi86_runtime_disable, dev); if (ret) return ret; + pm_runtime_set_autosuspend_delay(pdata->dev, 500); + pm_runtime_use_autosuspend(pdata->dev); ti_sn65dsi86_debugfs_init(pdata); From patchwork Fri Apr 23 16:58:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426892 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F27B5C43603 for ; Fri, 23 Apr 2021 17:00:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB4E8613D5 for ; Fri, 23 Apr 2021 17:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243462AbhDWRAk (ORCPT ); Fri, 23 Apr 2021 13:00:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243363AbhDWRAa (ORCPT ); Fri, 23 Apr 2021 13:00:30 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12205C06138D for ; Fri, 23 Apr 2021 09:59:54 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id p16so21558528plf.12 for ; Fri, 23 Apr 2021 09:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=etZUcTt+rboV/or3vFs74Bup/+mjjab123G8taaBqvc=; b=AjEor4mxpvSaZKgOdrkbk57bk1irf3vHm5XrDZmIsChLFe/TzhYz3WuroEtkAgRkea tRsds8lsuix/DVYetdGQlcKyUiRRSBwZBOFGi78SMogB0CFOgQ+2uKEaxbM84R7y1xMB 5HO1Lwjjcjo63psNcpiAeGBrz7NlAuLp4pl58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=etZUcTt+rboV/or3vFs74Bup/+mjjab123G8taaBqvc=; b=CO6FO2HCCoergs9sANLGvxdtQVQwaA39HLJFMk5Ec/Xc9SMQ5GXBKcsbN733dw1tAw cL6Bs+fO4Py02VQ1RCPdynjEV/gX3UdIzM/GrCZ3TCzB3UcTbKNcUDPHMbhI/hKjPOUg VSd7SRSH0vXeM5VFM6wXZk7l4yGs0cNERgUiwfFWmXU3aEQ1pp/K4uLRdRZMPczopKdM DsyxM2Ftaf7Mvc3aHJSpFP+Bj4iyh+jyYFEmjDe7UHQ700XryaJQLdOLXyl8FEiZXbiu fi6A/J21AAvs4yQ8ZybKfOvxeE0kBu+r46GayRbI12Urga9c9twAL9wuhBXUaBzObD2/ zM0A== X-Gm-Message-State: AOAM53073KbWiYKV6WkTXJmhIsx5eDUDE3eW0z16NZeBECT9ITIWz2zv ObI2Ssd1QhQ86xSdSHaFVzHqNQ== X-Google-Smtp-Source: ABdhPJzqFVde8rjb9eQ+J8WUohhDAgHlL8Rzk3zMwNUD08f5LTwGlvvR+pOz3zdxGZJCJz2+ZLEeeQ== X-Received: by 2002:a17:90a:510d:: with SMTP id t13mr5199699pjh.97.1619197193678; Fri, 23 Apr 2021 09:59:53 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:53 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 12/20] drm/bridge: ti-sn65dsi86: Code motion of refclk management functions Date: Fri, 23 Apr 2021 09:58:58 -0700 Message-Id: <20210423095743.v5.12.I047b8c7c6a3fc60eaca473da7a374f171fb021c2@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org No functional changes--this just makes the diffstat of a future change easier to understand. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/bridge/ti-sn65dsi86.c | 116 +++++++++++++------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 49b76b2ffe25..db367793cdff 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -192,6 +192,64 @@ static void ti_sn65dsi86_write_u16(struct ti_sn65dsi86 *pdata, regmap_write(pdata->regmap, reg + 1, val >> 8); } +static u32 ti_sn_bridge_get_dsi_freq(struct ti_sn65dsi86 *pdata) +{ + u32 bit_rate_khz, clk_freq_khz; + struct drm_display_mode *mode = + &pdata->bridge.encoder->crtc->state->adjusted_mode; + + bit_rate_khz = mode->clock * + mipi_dsi_pixel_format_to_bpp(pdata->dsi->format); + clk_freq_khz = bit_rate_khz / (pdata->dsi->lanes * 2); + + return clk_freq_khz; +} + +/* clk frequencies supported by bridge in Hz in case derived from REFCLK pin */ +static const u32 ti_sn_bridge_refclk_lut[] = { + 12000000, + 19200000, + 26000000, + 27000000, + 38400000, +}; + +/* clk frequencies supported by bridge in Hz in case derived from DACP/N pin */ +static const u32 ti_sn_bridge_dsiclk_lut[] = { + 468000000, + 384000000, + 416000000, + 486000000, + 460800000, +}; + +static void ti_sn_bridge_set_refclk_freq(struct ti_sn65dsi86 *pdata) +{ + int i; + u32 refclk_rate; + const u32 *refclk_lut; + size_t refclk_lut_size; + + if (pdata->refclk) { + refclk_rate = clk_get_rate(pdata->refclk); + refclk_lut = ti_sn_bridge_refclk_lut; + refclk_lut_size = ARRAY_SIZE(ti_sn_bridge_refclk_lut); + clk_prepare_enable(pdata->refclk); + } else { + refclk_rate = ti_sn_bridge_get_dsi_freq(pdata) * 1000; + refclk_lut = ti_sn_bridge_dsiclk_lut; + refclk_lut_size = ARRAY_SIZE(ti_sn_bridge_dsiclk_lut); + } + + /* for i equals to refclk_lut_size means default frequency */ + for (i = 0; i < refclk_lut_size; i++) + if (refclk_lut[i] == refclk_rate) + break; + + regmap_update_bits(pdata->regmap, SN_DPPLL_SRC_REG, REFCLK_FREQ_MASK, + REFCLK_FREQ(i)); +} + static int __maybe_unused ti_sn65dsi86_resume(struct device *dev) { struct ti_sn65dsi86 *pdata = dev_get_drvdata(dev); @@ -460,64 +518,6 @@ static void ti_sn_bridge_disable(struct drm_bridge *bridge) regmap_write(pdata->regmap, SN_PLL_ENABLE_REG, 0); } -static u32 ti_sn_bridge_get_dsi_freq(struct ti_sn65dsi86 *pdata) -{ - u32 bit_rate_khz, clk_freq_khz; - struct drm_display_mode *mode = - &pdata->bridge.encoder->crtc->state->adjusted_mode; - - bit_rate_khz = mode->clock * - mipi_dsi_pixel_format_to_bpp(pdata->dsi->format); - clk_freq_khz = bit_rate_khz / (pdata->dsi->lanes * 2); - - return clk_freq_khz; -} - -/* clk frequencies supported by bridge in Hz in case derived from REFCLK pin */ -static const u32 ti_sn_bridge_refclk_lut[] = { - 12000000, - 19200000, - 26000000, - 27000000, - 38400000, -}; - -/* clk frequencies supported by bridge in Hz in case derived from DACP/N pin */ -static const u32 ti_sn_bridge_dsiclk_lut[] = { - 468000000, - 384000000, - 416000000, - 486000000, - 460800000, -}; - -static void ti_sn_bridge_set_refclk_freq(struct ti_sn65dsi86 *pdata) -{ - int i; - u32 refclk_rate; - const u32 *refclk_lut; - size_t refclk_lut_size; - - if (pdata->refclk) { - refclk_rate = clk_get_rate(pdata->refclk); - refclk_lut = ti_sn_bridge_refclk_lut; - refclk_lut_size = ARRAY_SIZE(ti_sn_bridge_refclk_lut); - clk_prepare_enable(pdata->refclk); - } else { - refclk_rate = ti_sn_bridge_get_dsi_freq(pdata) * 1000; - refclk_lut = ti_sn_bridge_dsiclk_lut; - refclk_lut_size = ARRAY_SIZE(ti_sn_bridge_dsiclk_lut); - } - - /* for i equals to refclk_lut_size means default frequency */ - for (i = 0; i < refclk_lut_size; i++) - if (refclk_lut[i] == refclk_rate) - break; - - regmap_update_bits(pdata->regmap, SN_DPPLL_SRC_REG, REFCLK_FREQ_MASK, - REFCLK_FREQ(i)); -} - static void ti_sn_bridge_set_dsi_rate(struct ti_sn65dsi86 *pdata) { unsigned int bit_rate_mhz, clk_freq_mhz; From patchwork Fri Apr 23 16:58:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B524C43618 for ; Fri, 23 Apr 2021 17:00:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFFC6613C2 for ; Fri, 23 Apr 2021 17:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243368AbhDWRAl (ORCPT ); Fri, 23 Apr 2021 13:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243378AbhDWRAb (ORCPT ); Fri, 23 Apr 2021 13:00:31 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A179C06138F for ; Fri, 23 Apr 2021 09:59:55 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id f11-20020a17090a638bb02901524d3a3d48so1511578pjj.3 for ; Fri, 23 Apr 2021 09:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xQ0wEzOZTNs6sYC6SvDhkGIvxaobiZTQTuExtwn8cKI=; b=MLj+4fuuM1AUOtmza25h2uKA1yYGKJCrNDU9ppC7DxT+aPfaF6REBuJ12pwCC0GB+f mR54qU480jkA5U6pyrMb+hJkWk4cVbnLNzXZuC0kvzRyxjqsFt6/a9Gv4sGcssRyaE68 Bzsoyp0T7j9EBtE3XtFZv+Dl9KEZobZWDDAus= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xQ0wEzOZTNs6sYC6SvDhkGIvxaobiZTQTuExtwn8cKI=; b=c3MpuxaegJBJyFKm4M6UYpBo/Rdrb8a2+NeO1znMXn1BSDqPe5TNT0mT9Ghl4m2+9e uosHJLnhS6NDMshobhAKljgZ1R4J/HfMetxsPadSoCfCROqWgwm4U1cMXQDGMRoYTVCk vBx+qJS3e+MCBBDv/kP1nkbR/QVqCkWpusx6qMCnVLQjXKgOph1a4KiBB9/ICc9JNPw+ 08TRMYEU13tLsA3orEy/U0F3G3p2snmtFfHqwOlNl98AwDiHViR450UboVOVv/KMBhLY 7B1juC/Je2fYIEIXnrO0p00mJsvtIT1K9nX0zeIUb+ZTNlOHGNsxT47/Ewe+e7PkneLl VlVg== X-Gm-Message-State: AOAM530Twxbg3Rj51JHJHPk8Dff9hE8c857khhp/daxjBWB8+4R+uDm0 DHCjN7cYUqG5EgvKCfx6Dfe7Nf59qOsVfsGP X-Google-Smtp-Source: ABdhPJxr9hyYRG1sBkBODzwiObjzKlEg7C6MJG3jpPscH3i2FwYDHjhwZdfgnekf6eAsZWtROfwSqQ== X-Received: by 2002:a17:90b:249:: with SMTP id fz9mr5270075pjb.167.1619197194692; Fri, 23 Apr 2021 09:59:54 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:54 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 13/20] drm/bridge: ti-sn65dsi86: If refclk, DP AUX can happen w/out pre-enable Date: Fri, 23 Apr 2021 09:58:59 -0700 Message-Id: <20210423095743.v5.13.Ie8cf556114953c6e7634564cc0d3ddbd103cb96c@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's reorganize how we init and turn on the reference clock in the code to allow us to turn it on early (even before pre_enable()) so that we can read the EDID early. This is handy for eDP because: - We always assume that a panel is there. - Once we report that a panel is there we get asked to read the EDID. - Pre-enable isn't called until we know what pixel clock we want to use and we're ready to turn everything on. That's _after_ we get asked to read the EDID. NOTE: the above only works out OK if we "refclk" is provided. Though I don't have access to any hardware that uses ti-sn65dsi86 and _doesn't_ provide a "refclk", I believe that we'll have trouble reading the EDID at bootup in that case. Specifically I believe that if there's no "refclk" we need the MIPI source clock to be active before we can successfully read the EDID. My evidence here is that, in testing, I couldn't read the EDID until I turned on the DPPLL in the bridge chip and that the DPPLL needs the input clock to be active. Since this is hard to support, let's punt trying to handle this case if there's no "refclk". In that case we'll enable comms in pre_enable() like we always did. I don't believe there are any users of the ti-sn65dsi86 bridge chip that _don't_ use "refclk". The bridge chip is _very_ inflexible in that mode. The only time I've seen that mode used was for some really early prototype hardware that was thrown in the e-waste bin years ago when we realized how inflexible it was. Even if someone is using the bridge chip without the "refclk" they're in no worse shape than they were before the (fairly recent) commit 58074b08c04a ("drm/bridge: ti-sn65dsi86: Read EDID blob over DDC"). Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/bridge/ti-sn65dsi86.c | 129 +++++++++++++++++++------- 1 file changed, 94 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index db367793cdff..9dc3cd8e17df 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -132,6 +132,8 @@ * @dp_lanes: Count of dp_lanes we're using. * @ln_assign: Value to program to the LN_ASSIGN register. * @ln_polrs: Value for the 4-bit LN_POLRS field of SN_ENH_FRAME_REG. + * @comms_enabled: If true then communication over the aux channel is enabled. + * @comms_mutex: Protects modification of comms_enabled. * * @gchip: If we expose our GPIOs, this is used. * @gchip_output: A cache of whether we've set GPIOs to output. This @@ -162,6 +164,8 @@ struct ti_sn65dsi86 { int dp_lanes; u8 ln_assign; u8 ln_polrs; + bool comms_enabled; + struct mutex comms_mutex; #if defined(CONFIG_OF_GPIO) struct gpio_chip gchip; @@ -250,6 +254,47 @@ static void ti_sn_bridge_set_refclk_freq(struct ti_sn65dsi86 *pdata) REFCLK_FREQ(i)); } +static void ti_sn65dsi86_enable_comms(struct ti_sn65dsi86 *pdata) +{ + mutex_lock(&pdata->comms_mutex); + + /* configure bridge ref_clk */ + ti_sn_bridge_set_refclk_freq(pdata); + + /* + * HPD on this bridge chip is a bit useless. This is an eDP bridge + * so the HPD is an internal signal that's only there to signal that + * the panel is done powering up. ...but the bridge chip debounces + * this signal by between 100 ms and 400 ms (depending on process, + * voltage, and temperate--I measured it at about 200 ms). One + * particular panel asserted HPD 84 ms after it was powered on meaning + * that we saw HPD 284 ms after power on. ...but the same panel said + * that instead of looking at HPD you could just hardcode a delay of + * 200 ms. We'll assume that the panel driver will have the hardcoded + * delay in its prepare and always disable HPD. + * + * If HPD somehow makes sense on some future panel we'll have to + * change this to be conditional on someone specifying that HPD should + * be used. + */ + regmap_update_bits(pdata->regmap, SN_HPD_DISABLE_REG, HPD_DISABLE, + HPD_DISABLE); + + pdata->comms_enabled = true; + + mutex_unlock(&pdata->comms_mutex); +} + +static void ti_sn65dsi86_disable_comms(struct ti_sn65dsi86 *pdata) +{ + mutex_lock(&pdata->comms_mutex); + + pdata->comms_enabled = false; + clk_disable_unprepare(pdata->refclk); + + mutex_unlock(&pdata->comms_mutex); +} + static int __maybe_unused ti_sn65dsi86_resume(struct device *dev) { struct ti_sn65dsi86 *pdata = dev_get_drvdata(dev); @@ -263,6 +308,16 @@ static int __maybe_unused ti_sn65dsi86_resume(struct device *dev) gpiod_set_value(pdata->enable_gpio, 1); + /* + * If we have a reference clock we can enable communication w/ the + * panel (including the aux channel) w/out any need for an input clock + * so we can do it in resume which lets us read the EDID before + * pre_enable(). Without a reference clock we need the MIPI reference + * clock so reading early doesn't work. + */ + if (pdata->refclk) + ti_sn65dsi86_enable_comms(pdata); + return ret; } @@ -271,6 +326,9 @@ static int __maybe_unused ti_sn65dsi86_suspend(struct device *dev) struct ti_sn65dsi86 *pdata = dev_get_drvdata(dev); int ret; + if (pdata->refclk) + ti_sn65dsi86_disable_comms(pdata); + gpiod_set_value(pdata->enable_gpio, 0); ret = regulator_bulk_disable(SN_REGULATOR_SUPPLY_NUM, pdata->supplies); @@ -844,27 +902,8 @@ static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge) pm_runtime_get_sync(pdata->dev); - /* configure bridge ref_clk */ - ti_sn_bridge_set_refclk_freq(pdata); - - /* - * HPD on this bridge chip is a bit useless. This is an eDP bridge - * so the HPD is an internal signal that's only there to signal that - * the panel is done powering up. ...but the bridge chip debounces - * this signal by between 100 ms and 400 ms (depending on process, - * voltage, and temperate--I measured it at about 200 ms). One - * particular panel asserted HPD 84 ms after it was powered on meaning - * that we saw HPD 284 ms after power on. ...but the same panel said - * that instead of looking at HPD you could just hardcode a delay of - * 200 ms. We'll assume that the panel driver will have the hardcoded - * delay in its prepare and always disable HPD. - * - * If HPD somehow makes sense on some future panel we'll have to - * change this to be conditional on someone specifying that HPD should - * be used. - */ - regmap_update_bits(pdata->regmap, SN_HPD_DISABLE_REG, HPD_DISABLE, - HPD_DISABLE); + if (!pdata->refclk) + ti_sn65dsi86_enable_comms(pdata); drm_panel_prepare(pdata->panel); } @@ -875,7 +914,8 @@ static void ti_sn_bridge_post_disable(struct drm_bridge *bridge) drm_panel_unprepare(pdata->panel); - clk_disable_unprepare(pdata->refclk); + if (!pdata->refclk) + ti_sn65dsi86_disable_comms(pdata); pm_runtime_put_sync(pdata->dev); } @@ -909,6 +949,20 @@ static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux, if (len > SN_AUX_MAX_PAYLOAD_BYTES) return -EINVAL; + pm_runtime_get_sync(pdata->dev); + mutex_lock(&pdata->comms_mutex); + + /* + * If someone tries to do a DDC over AUX transaction before pre_enable() + * on a device without a dedicated reference clock then we just can't + * do it. Fail right away. This prevents non-refclk users from reading + * the EDID before enabling the panel but such is life. + */ + if (!pdata->comms_enabled) { + ret = -EIO; + goto exit; + } + switch (request) { case DP_AUX_NATIVE_WRITE: case DP_AUX_I2C_WRITE: @@ -919,7 +973,8 @@ static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux, msg->reply = 0; break; default: - return -EINVAL; + ret = -EINVAL; + goto exit; } BUILD_BUG_ON(sizeof(addr_len) != sizeof(__be32)); @@ -943,11 +998,11 @@ static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux, ret = regmap_read_poll_timeout(pdata->regmap, SN_AUX_CMD_REG, val, !(val & AUX_CMD_SEND), 0, 50 * 1000); if (ret) - return ret; + goto exit; ret = regmap_read(pdata->regmap, SN_AUX_CMD_STATUS_REG, &val); if (ret) - return ret; + goto exit; if (val & AUX_IRQ_STATUS_AUX_RPLY_TOUT) { /* @@ -955,13 +1010,14 @@ static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux, * but it hit a timeout. We ignore defers here because they're * handled in hardware. */ - return -ETIMEDOUT; + ret = -ETIMEDOUT; + goto exit; } if (val & AUX_IRQ_STATUS_AUX_SHORT) { ret = regmap_read(pdata->regmap, SN_AUX_LENGTH_REG, &len); if (ret) - return ret; + goto exit; } else if (val & AUX_IRQ_STATUS_NAT_I2C_FAIL) { switch (request) { case DP_AUX_I2C_WRITE: @@ -973,18 +1029,19 @@ static ssize_t ti_sn_aux_transfer(struct drm_dp_aux *aux, msg->reply |= DP_AUX_NATIVE_REPLY_NACK; break; } - return 0; + len = 0; + goto exit; } - if (request == DP_AUX_NATIVE_WRITE || request == DP_AUX_I2C_WRITE || - len == 0) - return len; + if (request != DP_AUX_NATIVE_WRITE && request != DP_AUX_I2C_WRITE && len != 0) + ret = regmap_bulk_read(pdata->regmap, SN_AUX_RDATA_REG(0), buf, len); - ret = regmap_bulk_read(pdata->regmap, SN_AUX_RDATA_REG(0), buf, len); - if (ret) - return ret; +exit: + mutex_unlock(&pdata->comms_mutex); + pm_runtime_mark_last_busy(pdata->dev); + pm_runtime_put_autosuspend(pdata->dev); - return len; + return ret ? ret : len; } static int ti_sn_bridge_parse_dsi_host(struct ti_sn65dsi86 *pdata) @@ -1390,6 +1447,8 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, dev_set_drvdata(dev, pdata); pdata->dev = dev; + mutex_init(&pdata->comms_mutex); + pdata->regmap = devm_regmap_init_i2c(client, &ti_sn65dsi86_regmap_config); if (IS_ERR(pdata->regmap)) { From patchwork Fri Apr 23 16:59:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 258ABC433ED for ; Fri, 23 Apr 2021 17:00:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 04DA0613C8 for ; Fri, 23 Apr 2021 17:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243402AbhDWRAo (ORCPT ); Fri, 23 Apr 2021 13:00:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243284AbhDWRAd (ORCPT ); Fri, 23 Apr 2021 13:00:33 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 347DBC061346 for ; Fri, 23 Apr 2021 09:59:56 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id g16so21163660pfq.5 for ; Fri, 23 Apr 2021 09:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZAnd1RDpck5SmOX49CHEtjV3qbZz8UtmFtha+wknfZ0=; b=kKWo8sQ6ilXk/Y4dmCCrVzN8dfMgI0ZwWY6/steq/QF36/kkt5rai3jSt0gPUMmACf dD+lC+soN8tY2dY8o6KbFqbozGs6fF7mVxzlW5ZZNdiznBF3kBzjuflTXqUcoHL0zoDb GUpqSc4YHS+fYjypb5PsIsYFnlwaVJXy+o6u8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZAnd1RDpck5SmOX49CHEtjV3qbZz8UtmFtha+wknfZ0=; b=A5uFjEa8HPf29iqQqX4sbkbU5UqAUtmA0eio1lO75g7mFbIzpe3iwbYq+Fa8n+jwJo TLZ7ZBE1jzobWmX0KyG3/ECbeTqIKnEoJDybprAUI6skhWyc3p7S+S/KXyDiowtL4k5T upCHkVs3UxnvExh1W/zY0sXIGj/i+NbhljzR82+2RCLVICwLC5MEb/3twDUESXtLLTiR S1lIqaFG7gxEkzHsAcnBeab0saIq/EXHlfTJsEZlKC8Ok07AxCx2YjqskoB/YMwzQZ9l x+h9m7TeGYG3RARZxC9QNW3uOv6HVa1oEvfHs00KLSwdYOLVx1iIUpliyydnH8CvhHXs bYkw== X-Gm-Message-State: AOAM5307jo/w+h7XlnJCyaT6Kj2i7hSNzQulkKLXAE0jgHEIXGSuxCGY ooVuyNktnUILYB0X++Wd1usKj4PzOTXhWo7k X-Google-Smtp-Source: ABdhPJyWeULqmS6PxRhFCHBDX4nZq82rQ1c3STdu1uO/X2IWS3RDlK0UIbMKbGIsX+IOTC4qKu4RaQ== X-Received: by 2002:a62:1401:0:b029:25a:d41c:fb2e with SMTP id 1-20020a6214010000b029025ad41cfb2emr4933706pfu.51.1619197195721; Fri, 23 Apr 2021 09:59:55 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:55 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 14/20] drm/bridge: ti-sn65dsi86: Promote the AUX channel to its own sub-dev Date: Fri, 23 Apr 2021 09:59:00 -0700 Message-Id: <20210423095743.v5.14.Ie9daa320d907fff73f893f74b898197e399cce59@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org We'd like to be able to expose the DDC-over-AUX channel bus to our panel. This gets into a chicken-and-egg problem because: - The panel wants to get its DDC at probe time. - The ti-sn65dsi86 MIPI-to-eDP bridge code, which provides the DDC bus, wants to get the panel at probe time. By using a sub device we can fully create the AUX channel bits so that the panel can get them. Then the panel can finish probing and the bridge can probe. To accomplish this, we also move registering the AUX channel out of the bridge's attach code and do it right at probe time. We use devm to manage cleanup. NOTE: there's a little bit of a trick here. Though the AUX channel can run without the MIPI-to-eDP bits of the code, the MIPI-to-eDP bits can't run without the AUX channel. We could come up a complicated signaling scheme (have the MIPI-to-eDP bits return EPROBE_DEFER for a while or wait on some sort of completion), but it seems simple enough to just not even bother creating the bridge device until the AUX channel probes. That's what we'll do. Signed-off-by: Douglas Anderson --- Changes in v5: - Fix module compile problems (Bjorn + kbuild bot) - Remove useless MODULE_DEVICE_TABLE (Bjorn). drivers/gpu/drm/bridge/ti-sn65dsi86.c | 87 +++++++++++++++++++++------ 1 file changed, 67 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 9dc3cd8e17df..3539ddf9d109 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -116,6 +116,7 @@ * struct ti_sn65dsi86 - Platform data for ti-sn65dsi86 driver. * @bridge_aux: AUX-bus sub device for MIPI-to-eDP bridge functionality. * @gpio_aux: AUX-bus sub device for GPIO controller functionality. + * @aux_aux: AUX-bus sub device for eDP AUX channel functionality. * * @dev: Pointer to the top level (i2c) device. * @regmap: Regmap for accessing i2c. @@ -148,6 +149,7 @@ struct ti_sn65dsi86 { struct auxiliary_device bridge_aux; struct auxiliary_device gpio_aux; + struct auxiliary_device aux_aux; struct device *dev; struct regmap *regmap; @@ -484,18 +486,12 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, return -EINVAL; } - ret = drm_dp_aux_register(&pdata->aux); - if (ret < 0) { - drm_err(bridge->dev, "Failed to register DP AUX channel: %d\n", ret); - return ret; - } - ret = drm_connector_init(bridge->dev, &pdata->connector, &ti_sn_bridge_connector_funcs, DRM_MODE_CONNECTOR_eDP); if (ret) { DRM_ERROR("Failed to initialize connector with drm\n"); - goto err_conn_init; + return ret; } drm_connector_helper_add(&pdata->connector, @@ -552,8 +548,6 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, mipi_dsi_device_unregister(dsi); err_dsi_host: drm_connector_cleanup(&pdata->connector); -err_conn_init: - drm_dp_aux_unregister(&pdata->aux); return ret; } @@ -1330,11 +1324,6 @@ static int ti_sn_bridge_probe(struct auxiliary_device *adev, if (ret) return ret; - pdata->aux.name = "ti-sn65dsi86-aux"; - pdata->aux.dev = pdata->dev; - pdata->aux.transfer = ti_sn_aux_transfer; - drm_dp_aux_init(&pdata->aux); - pdata->bridge.funcs = &ti_sn_bridge_funcs; pdata->bridge.of_node = np; @@ -1429,6 +1418,50 @@ static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata, return ret; } +static void ti_sn65dsi86_unregister_dp_aux(void *data) +{ + drm_dp_aux_unregister(data); +} + +static int ti_sn_aux_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct ti_sn65dsi86 *pdata = dev_get_drvdata(adev->dev.parent); + int ret; + + pdata->aux.name = "ti-sn65dsi86-aux"; + pdata->aux.dev = pdata->dev; + pdata->aux.transfer = ti_sn_aux_transfer; + drm_dp_aux_init(&pdata->aux); + + ret = drm_dp_aux_register(&pdata->aux); + if (ret < 0) { + drm_err(pdata, "Failed to register DP AUX channel: %d\n", ret); + return ret; + } + ret = devm_add_action_or_reset(&adev->dev, + ti_sn65dsi86_unregister_dp_aux, &pdata->aux); + if (ret) + return ret; + + /* + * The eDP to MIPI bridge parts don't work until the AUX channel is + * setup so we don't add it in the main driver probe, we add it now. + */ + return ti_sn65dsi86_add_aux_device(pdata, &pdata->bridge_aux, "bridge"); +} + +static const struct auxiliary_device_id ti_sn_aux_id_table[] = { + { .name = "ti_sn65dsi86.aux", }, + {}, +}; + +static struct auxiliary_driver ti_sn_aux_driver = { + .name = "aux", + .probe = ti_sn_aux_probe, + .id_table = ti_sn_aux_id_table, +}; + static int ti_sn65dsi86_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1487,10 +1520,11 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, * motiviation here is to solve the chicken-and-egg problem of probe * ordering. The bridge wants the panel to be there when it probes. * The panel wants its HPD GPIO (provided by sn65dsi86 on some boards) - * when it probes. There will soon be other devices (DDC I2C bus, PWM) - * that have the same problem. Having sub-devices allows the some sub - * devices to finish probing even if others return -EPROBE_DEFER and - * gets us around the problems. + * when it probes. The panel and maybe backlight might want the DDC + * bus. Soon the PWM provided by the bridge chip will have the same + * problem. Having sub-devices allows the some sub devices to finish + * probing even if others return -EPROBE_DEFER and gets us around the + * problems. */ if (IS_ENABLED(CONFIG_OF_GPIO)) { @@ -1499,7 +1533,13 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, return ret; } - return ti_sn65dsi86_add_aux_device(pdata, &pdata->bridge_aux, "bridge"); + /* + * NOTE: At the end of the AUX channel probe we'll add the aux device + * for the bridge. This is because the bridge can't be used until the + * AUX channel is there and this is a very simple solution to the + * dependency problem. + */ + return ti_sn65dsi86_add_aux_device(pdata, &pdata->aux_aux, "aux"); } static struct i2c_device_id ti_sn65dsi86_id[] = { @@ -1536,12 +1576,18 @@ static int __init ti_sn65dsi86_init(void) if (ret) goto err_main_was_registered; - ret = auxiliary_driver_register(&ti_sn_bridge_driver); + ret = auxiliary_driver_register(&ti_sn_aux_driver); if (ret) goto err_gpio_was_registered; + ret = auxiliary_driver_register(&ti_sn_bridge_driver); + if (ret) + goto err_aux_was_registered; + return 0; +err_aux_was_registered: + auxiliary_driver_unregister(&ti_sn_aux_driver); err_gpio_was_registered: ti_sn_gpio_unregister(); err_main_was_registered: @@ -1554,6 +1600,7 @@ module_init(ti_sn65dsi86_init); static void __exit ti_sn65dsi86_exit(void) { auxiliary_driver_unregister(&ti_sn_bridge_driver); + auxiliary_driver_unregister(&ti_sn_aux_driver); ti_sn_gpio_unregister(); i2c_del_driver(&ti_sn65dsi86_driver); } From patchwork Fri Apr 23 16:59:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67FEFC4360C for ; Fri, 23 Apr 2021 17:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BD27613BB for ; Fri, 23 Apr 2021 17:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243508AbhDWRAn (ORCPT ); Fri, 23 Apr 2021 13:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243402AbhDWRAe (ORCPT ); Fri, 23 Apr 2021 13:00:34 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5A4C061349 for ; Fri, 23 Apr 2021 09:59:57 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id m11so34471007pfc.11 for ; Fri, 23 Apr 2021 09:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gQpml6LY7Prl7t7mfNrEKr4/YWo6h583YxpHTazji+I=; b=CMfq2qDcrTK2b1SFUCZl8F3ujYtBndOl2TMhPVrj4aH1E2I16NvaQzc19oDJszLfid CxLnqp0WutR5SYYS+P2vhIfJ5ZvXrO3Ohqsd1NUL+oqydpuFunPUrOiefBS12z2zrnRu Ald6Uf3EfWB4GFrknG3RhT9JTBAxtA0heuUEs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gQpml6LY7Prl7t7mfNrEKr4/YWo6h583YxpHTazji+I=; b=V4DNzKRWyhNGzlxqJnYLmbxEjhn7ixnhMxH7zyYdZdRp6vEiGEMZslP55MRi+CAtBQ pfBVJ1xiHdmwBY5AhVGGm+V+LRMr3IPFj0XwwlqSvukUZ0TwgEVYHFkVP/0B38cOidib 0wkwKTSlCINWc3UiqM1jwp4dJHL3DFjiIyrlsB+hZYOqyOkvWrwVJyNqRppNAj03629X HZzZS4swWp50NXnERa3zzeAWd8vBvsuoJIfNDbH8sBtGfNv/Dn3YFGRcKOEPSdBNjl/L jXjs/14dYQ3oz7x5unXabgSolDM4LU+NlHFKnn2SjD936sx0/khcuSnda3i6k+A9rX2o a42g== X-Gm-Message-State: AOAM531xQZGM184Hvd0wgUy0aLmCJ7DIng3RcuKSYG3yZlEFgPcMbrpy JYEdD015SvL/qQSNdjMQGy0yyQ== X-Google-Smtp-Source: ABdhPJzi7ZOtZAGEwKGcjvP+7f7f5ph/mFq4PXS32e6ikwdc72PRbTlZo2MGrZN8aOExRGcMm37eRw== X-Received: by 2002:a62:e80f:0:b029:263:951f:14fb with SMTP id c15-20020a62e80f0000b0290263951f14fbmr4754352pfi.63.1619197196935; Fri, 23 Apr 2021 09:59:56 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:56 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v5 15/20] i2c: i2c-core-of: Fix corner case of finding adapter by node Date: Fri, 23 Apr 2021 09:59:01 -0700 Message-Id: <20210423095743.v5.15.Ib7e3a4af2f3e2cb3bd8e4adbac3bcfc966f27791@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The of_find_i2c_adapter_by_node() could end up failing to find an adapter in certain conditions. Specifically it's possible that of_dev_or_parent_node_match() could end up finding an I2C client in the list and cause bus_find_device() to stop early even though an I2C adapter was present later in the list. Let's move the i2c_verify_adapter() into the predicate function to prevent this. Now we'll properly skip over the I2C client and be able to find the I2C adapter. This issue has always been a potential problem if a single device tree node could represent both an I2C client and an adapter. I believe this is a sane thing to do if, for instance, an I2C-connected DP bridge chip is present. The bridge chip is an I2C client but it can also provide an I2C adapter (DDC tunneled over AUX channel). We don't want to have to create a sub-node just so a panel can link to it with the "ddc-i2c-bus" property. I believe that this problem got worse, however, with commit e814e688413a ("i2c: of: Try to find an I2C adapter matching the parent"). Starting at that commit it would be even easier to accidentally miss finding the adapter. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- This commit is sorta just jammed into the middle of my series. It has no dependencies on the earlier patches in the series and I think it can land independently in the i2c tree. Later patches in the series won't work right without this one, but they won't crash. If we can't find the i2c bus we'll just fall back to the hardcoded panel modes which, at least today, all panels have. I'll also note that part of me wonders if we should actually fix this further to run two passes through everything: first look to see if we find an exact match and only look at the parent pointer if there is no match. I don't currently have a need for that and it's a slightly bigger change, but it seems conceivable that it could affect someone? (no changes since v1) drivers/i2c/i2c-core-of.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 3ed74aa4b44b..de0bf5fce3a2 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -124,6 +124,14 @@ static int of_dev_or_parent_node_match(struct device *dev, const void *data) return 0; } +static int of_i2c_adapter_match(struct device *dev, const void *data) +{ + if (!of_dev_or_parent_node_match(dev, data)) + return 0; + + return !!i2c_verify_adapter(dev); +} + /* must call put_device() when done with returned i2c_client device */ struct i2c_client *of_find_i2c_device_by_node(struct device_node *node) { @@ -146,18 +154,13 @@ EXPORT_SYMBOL(of_find_i2c_device_by_node); struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) { struct device *dev; - struct i2c_adapter *adapter; dev = bus_find_device(&i2c_bus_type, NULL, node, - of_dev_or_parent_node_match); + of_i2c_adapter_match); if (!dev) return NULL; - adapter = i2c_verify_adapter(dev); - if (!adapter) - put_device(dev); - - return adapter; + return to_i2c_adapter(dev); } EXPORT_SYMBOL(of_find_i2c_adapter_by_node); From patchwork Fri Apr 23 16:59:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426890 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E715AC43603 for ; Fri, 23 Apr 2021 17:00:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA493611AE for ; Fri, 23 Apr 2021 17:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243538AbhDWRAr (ORCPT ); Fri, 23 Apr 2021 13:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243282AbhDWRAi (ORCPT ); Fri, 23 Apr 2021 13:00:38 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CA57C06134D for ; Fri, 23 Apr 2021 09:59:58 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id w6so19925467pfc.8 for ; Fri, 23 Apr 2021 09:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bYPxCdxtMKks8nftHI6+ZQaaJJnE9/+IALv4FLgIF54=; b=FvspuRuAWQhP6jQ5s/WPvA91XTFtWFz+QdqQAvdR0ZycpQE1pGtYWhuwDPlrqPY4Ef y68z04/DlCKz2zLgffkrU/DZWpJ2HOc/x1wsBCXKmxXRzdlb1KSt+mdDMDksFGjx0xpi 7NlQq1WUOY+oTayFgiLb9M1V2hgjIAZupsRuY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bYPxCdxtMKks8nftHI6+ZQaaJJnE9/+IALv4FLgIF54=; b=TBnKXPez5Bcs09c5BEVrtid10CcMt7i0jyEkKvgKmeOwl14XF19in/k+h4KjaL+O0O 7tYrCcVldaNpcqaZRO3lmPIwyQfUWShDYbF38ilvQ6L6q1221Rh10iSk5Ieppg7fQC/8 YVjhc1jtYyh9IOjhcw6mmM2GL03Lq3/3xTuIEA8eeMNuiefEukmR52wjLDLtuI51xnMG litjvk719/z8D66aIvtJmb70m7aDCUWtPwM6ir5yVxl+CsOCOBtAuibeORo+MikDMzlq yI/ulsyHx9CI9VYQ8X9OXFYazBVGVuHy5My09p+72mqrJ+etvyfgLhqigYTPPaT48yuG V/TQ== X-Gm-Message-State: AOAM533cWx8DyGrdnArMaFv+SkMq4IGSdVf93mVKyVEfKufpKxzETtfF MOvVZWTXjB6O7Lc56C+aGuZPBA== X-Google-Smtp-Source: ABdhPJyVdUM/1lp2NxOCx1Zx4EFgPXlKhQBOV5qtNjvmUvZ8eSWax5LiJ/ZRUO5ihILkjxoJYoXPQA== X-Received: by 2002:a63:4512:: with SMTP id s18mr4722524pga.275.1619197198125; Fri, 23 Apr 2021 09:59:58 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:57 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Thierry Reding , linux-kernel@vger.kernel.org Subject: [PATCH v5 16/20] drm/panel: panel-simple: Remove extra call: drm_connector_update_edid_property() Date: Fri, 23 Apr 2021 09:59:02 -0700 Message-Id: <20210423095743.v5.16.Icb581b0273d95cc33ca38676c61ae6d7d2e75357@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org As of commit 5186421cbfe2 ("drm: Introduce epoch counter to drm_connector") the drm_get_edid() function calls drm_connector_update_edid_property() for us. There's no reason for us to call it again. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- As Laurent pointed out [1] this is actually a pretty common problem. His suggestion to do this more broadly is a good idea but this series is probably a bit ambitious already so I would suggest that be taken up separately. [1] https://lore.kernel.org/r/YGphgcESWsozCi1y@pendragon.ideasonboard.com (no changes since v1) drivers/gpu/drm/panel/panel-simple.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index bd208abcbf07..4de33c929a59 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -512,7 +512,6 @@ static int panel_simple_get_modes(struct drm_panel *panel, if (p->ddc) { struct edid *edid = drm_get_edid(connector, p->ddc); - drm_connector_update_edid_property(connector, edid); if (edid) { num += drm_add_edid_modes(connector, edid); kfree(edid); From patchwork Fri Apr 23 16:59:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53D1FC43619 for ; Fri, 23 Apr 2021 17:00:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29D996113B for ; Fri, 23 Apr 2021 17:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243548AbhDWRAv (ORCPT ); Fri, 23 Apr 2021 13:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243338AbhDWRAi (ORCPT ); Fri, 23 Apr 2021 13:00:38 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C13F4C061357 for ; Fri, 23 Apr 2021 09:59:59 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id h15so16778376pfv.2 for ; Fri, 23 Apr 2021 09:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2irDBnkqmM3wv0GuRvBUKKKvXT4OqqpqCxXsJUDi0yY=; b=nY3NEiJjTVhYaqtF4JkoIDdonIMHogVty/rQuAsexe9F4i2Uhwz/XdA3pTBItC0bzq O62ca7z8DZ8y/Bjr8vjTyiwT2cmF4NCXYoGPgFaSCni0Y68OlxdULfQFsPTmFEEZP/mK NcMkrdksVuMVbn9LSzJ4n66ujsp1NyKYNVX1M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2irDBnkqmM3wv0GuRvBUKKKvXT4OqqpqCxXsJUDi0yY=; b=n7TDZ4QC8uR9wL/SNMtjiflXG/jz6BMgwV8zGCtYujLlAzQLz/W4x7W5Plor+XQc/K +WdGt9bSJIQ2QShHRaybks1VRcFMwEL/5+JShy3zc4XGhp05DJYPAXxnkDeQ3pibYYwF JksLJMrLluRkaT/FUFHjufsxdYCnVx1OIvbdxMkFzbGELhV/zOxhQdrbKLsfCsqA7He4 w0JkS/qyft1ZVoMAQ+Z2OcA0qW+NbAflQwPhb3MCHQf5qU6NvRtVGZG9zMya/bCS/oZp HENy6CsonogysL+nXAfzTaZX0p2uz1ThccOo4zChp9r37b60e+yKfVsqXuboMnUrNt14 Hqhw== X-Gm-Message-State: AOAM533MHZEDgGx5De6XLe9xJ4updm2t8cDOjMIFzT8mHM9I7jIi/RWP hLz1hBTa86aWKVtzKa1P+f+8Rg== X-Google-Smtp-Source: ABdhPJyNRywKHcTfgakgp2CqXZs7wKXnf4eben+Fiu78mA2c8AJYA0KF0c2Abkct8V8f1il2rA20/Q== X-Received: by 2002:a05:6a00:2bb:b029:25d:92b:bf3b with SMTP id q27-20020a056a0002bbb029025d092bbf3bmr4694708pfs.52.1619197199276; Fri, 23 Apr 2021 09:59:59 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 09:59:58 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Thierry Reding , linux-kernel@vger.kernel.org Subject: [PATCH v5 17/20] drm/panel: panel-simple: Power the panel when reading the EDID Date: Fri, 23 Apr 2021 09:59:03 -0700 Message-Id: <20210423095743.v5.17.Ibd31b8f7c73255d68c5c9f5b611b4bfaa036f727@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org I don't believe that it ever makes sense to read the EDID when a panel is not powered and the powering on of the panel is the job of prepare(). Let's make sure that this happens before we try to read the EDID. We use the pm_runtime functions directly rather than directly calling the normal prepare() function because the pm_runtime functions are definitely refcounted whereas it's less clear if the prepare() one is. NOTE: I'm not 100% sure how EDID reading was working for folks in the past, but I can only assume that it was failing on the initial attempt and then working only later. This patch, presumably, will fix that. If some panel out there really can read the EDID without powering up and it's a big advantage to preserve the old behavior we can add a per-panel flag. It appears that providing the DDC bus to the panel in the past was somewhat uncommon in any case. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson Reviewed-by: Sean Paul --- (no changes since v1) drivers/gpu/drm/panel/panel-simple.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 4de33c929a59..a12dfe8b8d90 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -510,12 +510,18 @@ static int panel_simple_get_modes(struct drm_panel *panel, /* probe EDID if a DDC bus is available */ if (p->ddc) { - struct edid *edid = drm_get_edid(connector, p->ddc); + struct edid *edid; + pm_runtime_get_sync(panel->dev); + + edid = drm_get_edid(connector, p->ddc); if (edid) { num += drm_add_edid_modes(connector, edid); kfree(edid); } + + pm_runtime_mark_last_busy(panel->dev); + pm_runtime_put_autosuspend(panel->dev); } /* add hard-coded panel modes */ From patchwork Fri Apr 23 16:59:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4D86C43600 for ; Fri, 23 Apr 2021 17:00:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEC876113B for ; Fri, 23 Apr 2021 17:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243561AbhDWRAw (ORCPT ); Fri, 23 Apr 2021 13:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243466AbhDWRAl (ORCPT ); Fri, 23 Apr 2021 13:00:41 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B67C06135A for ; Fri, 23 Apr 2021 10:00:00 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id j7so26191045pgi.3 for ; Fri, 23 Apr 2021 10:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vN5od8em+5FKe5XxLDBfqxHA4H7++ijxC9/2y7ssun0=; b=PbMi+Tmz6a3EpvJ9X3Y9FXr95RRXZ4WgYEkkFrYH8DG3I9WXhyCde+nuxI9ZYVJL5m dpxwDpU6JhRXyHgwP6P4TkEmQCsf7BHAh+TtGCZr51NdhdfE7GjjXZtF76870E8VeXbG RSiv0/YdYeqcTbVH9s2F5nMI8pbO99Lz5yBp4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vN5od8em+5FKe5XxLDBfqxHA4H7++ijxC9/2y7ssun0=; b=f5ZAAVh091KArAsmK3w7E+nxJ+N7660z8Qy1cthX1xb9D5R6koCdA4jt3rIiVs1sq0 tOi4O/JFvl6LjOSUkeN5VXo5ml3g83bc6JlTjIg6A1lEtCk67gdsavlNkeFFSQYDHtle LFnFeQoDAsDkaze3+ZFEmTeC+wAp/o+ftRuIQeiO2FGlgIs+UvQ7vxHNoiVfhIqbOhCw UO1A9yw+app1qIBZGF1ZrbhL2Yn7W4saEvUIjkzPuBPa+O8r/17JCU+PHzM/t70driK1 m9MI8yi/1IrsIQ/akBLtrGnDzQXfkaYsZznwq/0aZKNQeNolpBw/2POudNmJwXS/+AkS 6NjQ== X-Gm-Message-State: AOAM533E9q/M8Nevjv9JrWI1ivxmzYAg3DckLGWzOz+7psRt1Yjb+b7H XIjv/YYj2GrIbmcfBpqndtwupQ== X-Google-Smtp-Source: ABdhPJwINQl5crpxyRVfX+jrNNrO5VsTiefR+FBPJxIt4U/f6GB7qHJwNiBie9Tl+LA3r9E8NJRtlg== X-Received: by 2002:a63:f303:: with SMTP id l3mr4753122pgh.263.1619197200372; Fri, 23 Apr 2021 10:00:00 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.09.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 10:00:00 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Thierry Reding , linux-kernel@vger.kernel.org Subject: [PATCH v5 18/20] drm/panel: panel-simple: Cache the EDID as long as we retain power Date: Fri, 23 Apr 2021 09:59:04 -0700 Message-Id: <20210423095743.v5.18.If050957eaa85cf45b10bcf61e6f7fa61c9750ebf@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org It doesn't make sense to go out to the bus and read the EDID over and over again. Let's cache it and throw away the cache when we turn power off from the panel. Autosuspend means that even if there are several calls to read the EDID before we officially turn the power on then we should get good use out of this cache. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson Reviewed-by: Sean Paul --- (no changes since v1) drivers/gpu/drm/panel/panel-simple.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index a12dfe8b8d90..9be050ab372f 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -189,6 +189,8 @@ struct panel_simple { struct gpio_desc *enable_gpio; struct gpio_desc *hpd_gpio; + struct edid *edid; + struct drm_display_mode override_mode; enum drm_panel_orientation orientation; @@ -345,6 +347,9 @@ static int panel_simple_suspend(struct device *dev) regulator_disable(p->supply); p->unprepared_time = ktime_get(); + kfree(p->edid); + p->edid = NULL; + return 0; } @@ -510,15 +515,13 @@ static int panel_simple_get_modes(struct drm_panel *panel, /* probe EDID if a DDC bus is available */ if (p->ddc) { - struct edid *edid; - pm_runtime_get_sync(panel->dev); - edid = drm_get_edid(connector, p->ddc); - if (edid) { - num += drm_add_edid_modes(connector, edid); - kfree(edid); - } + if (!p->edid) + p->edid = drm_get_edid(connector, p->ddc); + + if (p->edid) + num += drm_add_edid_modes(connector, p->edid); pm_runtime_mark_last_busy(panel->dev); pm_runtime_put_autosuspend(panel->dev); From patchwork Fri Apr 23 16:59:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6D84C43611 for ; Fri, 23 Apr 2021 17:00:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBA5A613C9 for ; Fri, 23 Apr 2021 17:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243466AbhDWRBB (ORCPT ); Fri, 23 Apr 2021 13:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243471AbhDWRAl (ORCPT ); Fri, 23 Apr 2021 13:00:41 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8E6C06138C for ; Fri, 23 Apr 2021 10:00:01 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id m11so34471124pfc.11 for ; Fri, 23 Apr 2021 10:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4ccmN7kOFt4vV6tYXQphBKXq8QUp9QP8qMDQTtMZWgc=; b=mZXvU2oI2xqSARjGIIO7jRUdu3n+mLCmWcMcgsEWbTafsweZuS6UDJ2mm6wfMJ06LY xi3py9XoTAi9JlGgELbjAIDc7lIU2+4t09kgNMnrit9xbmaXGU745d7vAijNlJLPC5xK l7Y6BU6/lFwFMyrFRjQBDEN6y0pwiuZCjkuFU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4ccmN7kOFt4vV6tYXQphBKXq8QUp9QP8qMDQTtMZWgc=; b=Esm7P0g+4CiNtLXQwrCjMhA+85Tr5wfOGXljzBTDaliAK4iJJqiPM9lxOYLpCIOwF2 p7ZNLO1iXXqLAmI7frqskbP4ZpHsTH1IIYJ+VXT+GWNncPbk4wwGiP5OjqMbYUTWXk5T 82mOTzgVVTNb9HifAaDsGtmrA+Jx1eBENIXyQ4kHpGlrCrBHCchsjiBGw0EQddXzNqrI vxKpjdermuj5qK4lfGfoiBvoqHSTb4nf21t3fdWIdUEQDO5fDbVe0TKB1+q9/rpK9sw+ UXUdOPDVQlevNiedubkObeoV5jhHHJgmmjWyu8zDk2v1FHZs6ChgqPCf5AQjH4+HGvHU AK9w== X-Gm-Message-State: AOAM533cuRBgK07CICe81mwc7vXBYbUeQ2GKoQOLc2qkvk8W0pOElxVe irm/MCJuaaxPmYs3HoxVeMeZow== X-Google-Smtp-Source: ABdhPJyk8jzpiq6MaxB8UsjZw7IBJENrtzi8fsfu2GjjtKaFZYH2dXT4qQBYIbdKYg2hvlCPx7Bg/Q== X-Received: by 2002:a63:8c4a:: with SMTP id q10mr4737171pgn.106.1619197201481; Fri, 23 Apr 2021 10:00:01 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.10.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 10:00:01 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Daniel Vetter , David Airlie , Robert Foss , linux-kernel@vger.kernel.org Subject: [PATCH v5 19/20] drm/bridge: ti-sn65dsi86: Don't read EDID blob over DDC Date: Fri, 23 Apr 2021 09:59:05 -0700 Message-Id: <20210423095743.v5.19.I9330684c25f65bb318eff57f0616500f83eac3cc@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This is really just a revert of commit 58074b08c04a ("drm/bridge: ti-sn65dsi86: Read EDID blob over DDC"), resolving conflicts. The old code failed to read the EDID properly in a very important case: before the bridge's pre_enable() was called. The way things need to work: 1. Read the EDID. 2. Based on the EDID, decide on video settings and pixel clock. 3. Enable the bridge w/ the desired settings. The way things were working: 1. Try to read the EDID but fail; fall back to hardcoded values. 2. Based on hardcoded values, decide on video settings and pixel clock. 3. Enable the bridge w/ the desired settings. 4. Try again to read the EDID, it works now! 5. Realize that the hardcoded settings weren't quite right. 6. Disable / reenable the bridge w/ the right settings. The reasons for the failures were twofold: a) Since we never ran the bridge chip's pre-enable then we never set the bit to ignore HPD. This meant the bridge chip didn't even _try_ to go out on the bus and communicate with the panel. b) Even if we fixed things to ignore HPD, the EDID still wouldn't read if the panel wasn't on. Instead of reverting the code, we could fix it to set the HPD bit and also power on the panel. However, it also works nicely to just let the panel code read the EDID. Now that we've split the driver up we can expose the DDC AUX channel bus to the panel node. The panel can take charge of reading the EDID. NOTE: in order for things to work, anyone that needs to read the EDID will need to add something that looks like this to their panel in the dts: ddc-i2c-bus = <&sn65dsi86_bridge>; Presumably it's OK to land this without waiting for users to add the dts property since the EDID reading was a bit broken anyway, was "recently" added, and we know we must have the fallback mode to use (since the EDID reading was a bit broken). Suggested-by: Andrzej Hajda Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) drivers/gpu/drm/bridge/ti-sn65dsi86.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 3539ddf9d109..26851119df96 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -125,7 +125,6 @@ * @connector: Our connector. * @host_node: Remote DSI node. * @dsi: Our MIPI DSI source. - * @edid: Detected EDID of eDP panel. * @refclk: Our reference clock. * @panel: Our panel. * @enable_gpio: The GPIO we toggle to enable the bridge. @@ -156,7 +155,6 @@ struct ti_sn65dsi86 { struct drm_dp_aux aux; struct drm_bridge bridge; struct drm_connector connector; - struct edid *edid; struct device_node *host_node; struct mipi_dsi_device *dsi; struct clk *refclk; @@ -405,24 +403,6 @@ connector_to_ti_sn65dsi86(struct drm_connector *connector) static int ti_sn_bridge_connector_get_modes(struct drm_connector *connector) { struct ti_sn65dsi86 *pdata = connector_to_ti_sn65dsi86(connector); - struct edid *edid = pdata->edid; - int num, ret; - - if (!edid) { - pm_runtime_get_sync(pdata->dev); - edid = pdata->edid = drm_get_edid(connector, &pdata->aux.ddc); - pm_runtime_put_autosuspend(pdata->dev); - } - - if (edid && drm_edid_is_valid(edid)) { - ret = drm_connector_update_edid_property(connector, edid); - if (!ret) { - num = drm_add_edid_modes(connector, edid); - if (num) - return num; - } - } - return drm_panel_get_modes(pdata->panel, connector); } @@ -1344,8 +1324,6 @@ static void ti_sn_bridge_remove(struct auxiliary_device *adev) mipi_dsi_device_unregister(pdata->dsi); } - kfree(pdata->edid); - drm_bridge_remove(&pdata->bridge); of_node_put(pdata->host_node); From patchwork Fri Apr 23 16:59:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 426888 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D688C43460 for ; Fri, 23 Apr 2021 17:00:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40AB5613C4 for ; Fri, 23 Apr 2021 17:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243611AbhDWRBN (ORCPT ); Fri, 23 Apr 2021 13:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243523AbhDWRAp (ORCPT ); Fri, 23 Apr 2021 13:00:45 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CED3FC061756 for ; Fri, 23 Apr 2021 10:00:02 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id u14-20020a17090a1f0eb029014e38011b09so1592790pja.5 for ; Fri, 23 Apr 2021 10:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qqRgrq5qTHq8+QQOXrqNOrI+XnC8s9rFcrx/PHqU9kA=; b=X+2LXkR+x2Y6Yo6aK1kTdJ8Rhytwsl31CFMU6k56xp/RuePZ0vzxwrb2UfkLXWGSBq LlAh38K6d3Rlb9ZhLKF9mKVf9rd/crkpvJJ+H9Qkz8Lur52GfMVYXi8zj2XicneHKR7c YdlA2lbc+fQi/b3LKgVfUmJaZh6SjEHuSYkCs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qqRgrq5qTHq8+QQOXrqNOrI+XnC8s9rFcrx/PHqU9kA=; b=gl0vBFhtadoDeBKR84/MzBf+Btc7siQeAJ2HjReh7jpNvj3jBJw0+rGXtrdOXVhos1 BmlcY3kKuh57HcepkNZ4SoDgnZcqykOLgSzgb34UJTSzarFRUfJz20JjSsRI+4bhuM/a DCsSsgFRg+OAT0AiUoTj33H71DbJt0mwILgxVRBFKLWzcRcU91xOM/iFyxSkD7RsRXul YthJdWJCnQI5MbJuwc6qL+2aGuaa98hlZ3cWAuPnaiDyGmIkHBABuUxnvSUFrQd5EOIv WabG0xFCNMLV6fQahzlSoeiLJ/6FzVtC16JrfTkuL0JwtLZr2MT6HxhNKWCNIMzN2doj na4g== X-Gm-Message-State: AOAM533BT7jWV92CbYPclb6gYV3GB548K/I/5f+xEbbQnSH6t2rzZlCg +JMNGes/+iKu8xRyKDmvxsxlyA== X-Google-Smtp-Source: ABdhPJwYRj/bkCBR5feDF1qTXpHaqYVIA63dyfs8jdja9V5hgW3GpI+hcKLSiO/ZUNmI8hVVg+H2gQ== X-Received: by 2002:a17:90a:7d02:: with SMTP id g2mr6649977pjl.153.1619197202494; Fri, 23 Apr 2021 10:00:02 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6d86:663d:71f8:6a11]) by smtp.gmail.com with ESMTPSA id v8sm5123607pfm.128.2021.04.23.10.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 10:00:02 -0700 (PDT) From: Douglas Anderson To: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Wolfram Sang Cc: linux-arm-msm@vger.kernel.org, robdclark@chromium.org, Stanislav Lisovskiy , Stephen Boyd , Steev Klimaszewski , Linus W , Maarten Lankhorst , linux-i2c@vger.kernel.org, Bjorn Andersson , dri-devel@lists.freedesktop.org, Douglas Anderson , Andy Gross , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 20/20] arm64: dts: qcom: Link the panel to the bridge's DDC bus Date: Fri, 23 Apr 2021 09:59:06 -0700 Message-Id: <20210423095743.v5.20.Ibdb7735fb1844561b902252215a69526a14f9abd@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423165906.2504169-1-dianders@chromium.org> References: <20210423165906.2504169-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Adding this link allows the panel code to do things like read the EDID. Signed-off-by: Douglas Anderson Reviewed-by: Bjorn Andersson --- (no changes since v1) arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi index 24d293ef56d7..96e530594509 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi @@ -265,6 +265,7 @@ panel: panel { power-supply = <&pp3300_dx_edp>; backlight = <&backlight>; hpd-gpios = <&sn65dsi86_bridge 2 GPIO_ACTIVE_HIGH>; + ddc-i2c-bus = <&sn65dsi86_bridge>; ports { port {