From patchwork Fri Sep 10 10:12:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 509233 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,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 11D36C433EF for ; Fri, 10 Sep 2021 10:14:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0E5761186 for ; Fri, 10 Sep 2021 10:14:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232408AbhIJKPW (ORCPT ); Fri, 10 Sep 2021 06:15:22 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:53051 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232747AbhIJKPJ (ORCPT ); Fri, 10 Sep 2021 06:15:09 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id E5D382B013E6; Fri, 10 Sep 2021 06:13:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 10 Sep 2021 06:13:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=10+tjkzC+mYma 4yPEcpt+NjCwb1ACX57ylS/TuAaTks=; b=qe+NnVP9M8tDM/7ywGi6UdOyiPXSX 0FSpcx+zilCydaHR0GYoebC51HjRZv7lzB6UHLrFAwuCFMH9fOrZqt6I0pGDGK7J hK0UeY6Tau1MMk88Jl3yAKu3iRXLzAt6BgFPRE639h/4j9bZoqLoofkPNqP+RU15 FjTksnJYXZoVCa1NiJ8uJpXRmrtkFLT7zfw5wUr9uT628vO+Lsq6MH7701lG6cqP w3iNeCGHGYJi1RXPZrQCiIpg+gbp4c9w+8anSAeVdtgXwhcwSmGLfDHlOBNPQlPR Jq6CQOlUEKGcR554262/KwlLOj01+pTY4RIWYXYlSK5GQWJl3FSmlt4VQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=10+tjkzC+mYma4yPEcpt+NjCwb1ACX57ylS/TuAaTks=; b=SZjcAyT9 ccpBEemGWdkhaYNDMSHrlT2FqaF7MUS8poSq4yU+DuxSHfqzBWUx+mb3+atR6R89 LWk95sAJqu7AsKJXRgpkByKBbwLU3lWPuenKVrXKh1dp+aW6hxbV0gFQj7I6ulyL 86TfAvoQ4y9wbaYBfCeb8yMuJdniRIdfrBPCloh+z9vwc/JGYnSvwg0qKNOZEfbN Ba50D6OpNDtPX4mXm7pIH0vgY53u0UBnaLMlD2GRarGYlrCzYnDI0wsjjeTlcIm0 Y1LzKfIWn4qI85QHuxK/V/vTIUCvkU3LB0CrVYzlLHBoH4exRFklL1mwNRwFwmQl dW1NF1CI8lJ75w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeguddgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 Sep 2021 06:13:54 -0400 (EDT) From: Maxime Ripard To: Andrzej Hajda , Sam Ravnborg , Daniel Vetter , David Airlie , Jonas Karlman , Laurent Pinchart , Thierry Reding , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Neil Armstrong , Robert Foss , Jernej Skrabec Cc: Sean Paul , freedreno@lists.freedesktop.org, Kyungmin Park , linux-kernel@vger.kernel.org, Xinliang Liu , Seung-Woo Kim , Tian Tao , Inki Dae , linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, Rob Clark , dri-devel@lists.freedesktop.org, John Stultz , Chen Feng , Xinwei Kong , Joonyoung Shim Subject: [PATCH v4 16/24] drm/bridge: ps8640: Register and attach our DSI device at probe Date: Fri, 10 Sep 2021 12:12:10 +0200 Message-Id: <20210910101218.1632297-17-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210910101218.1632297-1-maxime@cerno.tech> References: <20210910101218.1632297-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In order to avoid any probe ordering issue, the best practice is to move the secondary MIPI-DSI device registration and attachment to the MIPI-DSI host at probe time. Let's do this. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/parade-ps8640.c | 97 +++++++++++++++----------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c index c943045f3370..8d161b6cdbb2 100644 --- a/drivers/gpu/drm/bridge/parade-ps8640.c +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -215,52 +215,10 @@ static int ps8640_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { struct ps8640 *ps_bridge = bridge_to_ps8640(bridge); - struct device *dev = &ps_bridge->page[0]->dev; - struct device_node *in_ep, *dsi_node; - struct mipi_dsi_device *dsi; - struct mipi_dsi_host *host; - int ret; - const struct mipi_dsi_device_info info = { .type = "ps8640", - .channel = 0, - .node = NULL, - }; if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) return -EINVAL; - /* port@0 is ps8640 dsi input port */ - in_ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); - if (!in_ep) - return -ENODEV; - - dsi_node = of_graph_get_remote_port_parent(in_ep); - of_node_put(in_ep); - if (!dsi_node) - return -ENODEV; - - host = of_find_mipi_dsi_host_by_node(dsi_node); - of_node_put(dsi_node); - if (!host) - return -ENODEV; - - dsi = devm_mipi_dsi_device_register_full(dev, host, &info); - if (IS_ERR(dsi)) { - dev_err(dev, "failed to create dsi device\n"); - ret = PTR_ERR(dsi); - return ret; - } - - ps_bridge->dsi = dsi; - - dsi->host = host; - dsi->mode_flags = MIPI_DSI_MODE_VIDEO | - MIPI_DSI_MODE_VIDEO_SYNC_PULSE; - dsi->format = MIPI_DSI_FMT_RGB888; - dsi->lanes = NUM_MIPI_LANES; - ret = devm_mipi_dsi_attach(dev, dsi); - if (ret) - return ret; - /* Attach the panel-bridge to the dsi bridge */ return drm_bridge_attach(bridge->encoder, ps_bridge->panel_bridge, &ps_bridge->bridge, flags); @@ -307,6 +265,53 @@ static const struct drm_bridge_funcs ps8640_bridge_funcs = { .pre_enable = ps8640_pre_enable, }; +static int ps8640_bridge_host_attach(struct device *dev, struct ps8640 *ps_bridge) +{ + struct device_node *in_ep, *dsi_node; + struct mipi_dsi_device *dsi; + struct mipi_dsi_host *host; + int ret; + const struct mipi_dsi_device_info info = { .type = "ps8640", + .channel = 0, + .node = NULL, + }; + + /* port@0 is ps8640 dsi input port */ + in_ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); + if (!in_ep) + return -ENODEV; + + dsi_node = of_graph_get_remote_port_parent(in_ep); + of_node_put(in_ep); + if (!dsi_node) + return -ENODEV; + + host = of_find_mipi_dsi_host_by_node(dsi_node); + of_node_put(dsi_node); + if (!host) + return -EPROBE_DEFER; + + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); + if (IS_ERR(dsi)) { + dev_err(dev, "failed to create dsi device\n"); + return PTR_ERR(dsi); + } + + ps_bridge->dsi = dsi; + + dsi->host = host; + dsi->mode_flags = MIPI_DSI_MODE_VIDEO | + MIPI_DSI_MODE_VIDEO_SYNC_PULSE; + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->lanes = NUM_MIPI_LANES; + + ret = devm_mipi_dsi_attach(dev, dsi); + if (ret) + return ret; + + return 0; +} + static int ps8640_probe(struct i2c_client *client) { struct device *dev = &client->dev; @@ -373,7 +378,15 @@ static int ps8640_probe(struct i2c_client *client) drm_bridge_add(&ps_bridge->bridge); + ret = ps8640_bridge_host_attach(dev, ps_bridge); + if (ret) + goto err_bridge_remove; + return 0; + +err_bridge_remove: + drm_bridge_remove(&ps_bridge->bridge); + return ret; } static int ps8640_remove(struct i2c_client *client)