From patchwork Mon Apr 22 19:18:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95608C4345F for ; Mon, 22 Apr 2024 19:19:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BB5B1121B4; Mon, 22 Apr 2024 19:19:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="U7kkZy04"; dkim-atps=neutral Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id A7E131121B4 for ; Mon, 22 Apr 2024 19:19:23 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5qkfsiav14z/13YCmF9WtxhNZzgVPszO86+CmRUhDZg=; b=U7kkZy04nAeUMoysfji3yq6jhBRqIPxmzTYDkdnFwVBepV4v3h5vj/nRJMMY6jXKQBmzZx Rlne9IAo5VyH6ntxyTFPpZ/A3udCag5m4PViPTbJQET94Ec2KYtAfu8d2bQX69RhlUq4lH XOCO2+UcAbO894J7ouzNYiQfP1y9EIU= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 1/9] drm/bridge: Allow using fwnode API to get the next bridge Date: Tue, 23 Apr 2024 03:18:55 +0800 Message-Id: <20240422191903.255642-2-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, the various display bridge drivers rely on OF infrastructures to works very well, yet there are platforms and/or devices absence of 'OF' support. Such as virtual display drivers, USB display apapters and ACPI based systems etc. Add fwnode based helpers to fill the niche, this allows part of the display bridge drivers to work across systems. As the fwnode API has wider coverage than DT counterpart and the fwnode graphs are compatible with the OF graph, so the provided helpers can be used on all systems in theory. Assumed that the system has valid fwnode graphs established before drm bridge drivers are probed, and there has fwnode assigned to involved drm bridge instance. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/drm_bridge.c | 74 ++++++++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 16 ++++++++ 2 files changed, 90 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 28abe9aa99ca..fc1a314140e7 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -1368,6 +1368,80 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np) EXPORT_SYMBOL(of_drm_find_bridge); #endif +/** + * drm_bridge_find_by_fwnode - Find the bridge corresponding to the fwnode + * + * @fwnode: fwnode for which to find the matching drm_bridge + * + * This function looks up a drm_bridge in the global bridge list, based on + * its associated fwnode. Drivers who want to use this function should has + * fwnode handle assigned to the fwnode member of the struct drm_bridge + * instance. + * + * Returns: + * * A reference to the requested drm_bridge object on success, or + * * %NULL otherwise (object does not exist or the driver of requested + * bridge not probed yet). + */ +struct drm_bridge *drm_bridge_find_by_fwnode(struct fwnode_handle *fwnode) +{ + struct drm_bridge *ret = NULL; + struct drm_bridge *bridge; + + if (!fwnode) + return NULL; + + mutex_lock(&bridge_lock); + + list_for_each_entry(bridge, &bridge_list, list) { + if (bridge->fwnode == fwnode) { + ret = bridge; + break; + } + } + + mutex_unlock(&bridge_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(drm_bridge_find_by_fwnode); + +/** + * drm_bridge_find_next_bridge_by_fwnode - Find the next bridge by fwnode + * @fwnode: fwnode pointer to the current device. + * @port: identifier of the port node of the next bridge is connected. + * + * This function find the next bridge at the current node, it assumed that + * there has valid fwnode graph established. + * + * Returns: + * * A reference to the requested drm_bridge object on success, or + * * -%EINVAL or -%ENODEV if the fwnode graph or OF graph is not complete, or + * * %NULL if object does not exist or the next bridge is not probed yet. + */ +struct drm_bridge * +drm_bridge_find_next_bridge_by_fwnode(struct fwnode_handle *fwnode, u32 port) +{ + struct drm_bridge *bridge; + struct fwnode_handle *ep; + struct fwnode_handle *remote; + + ep = fwnode_graph_get_endpoint_by_id(fwnode, port, 0, 0); + if (!ep) + return ERR_PTR(-EINVAL); + + remote = fwnode_graph_get_remote_port_parent(ep); + fwnode_handle_put(ep); + if (!remote) + return ERR_PTR(-ENODEV); + + bridge = drm_bridge_find_by_fwnode(remote); + fwnode_handle_put(remote); + + return bridge; +} +EXPORT_SYMBOL_GPL(drm_bridge_find_next_bridge_by_fwnode); + MODULE_AUTHOR("Ajay Kumar "); MODULE_DESCRIPTION("DRM bridge infrastructure"); MODULE_LICENSE("GPL and additional rights"); diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 4baca0d9107b..a3f5d12a308c 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -721,6 +722,8 @@ struct drm_bridge { struct list_head chain_node; /** @of_node: device node pointer to the bridge */ struct device_node *of_node; + /** @fwnode: fwnode pointer to the bridge */ + struct fwnode_handle *fwnode; /** @list: to keep track of all added bridges */ struct list_head list; /** @@ -788,6 +791,13 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, struct drm_bridge *previous, enum drm_bridge_attach_flags flags); +static inline void +drm_bridge_set_node(struct drm_bridge *bridge, struct fwnode_handle *fwnode) +{ + bridge->fwnode = fwnode; + bridge->of_node = to_of_node(fwnode); +} + #ifdef CONFIG_OF struct drm_bridge *of_drm_find_bridge(struct device_node *np); #else @@ -797,6 +807,12 @@ static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np) } #endif +struct drm_bridge * +drm_bridge_find_by_fwnode(struct fwnode_handle *fwnode); + +struct drm_bridge * +drm_bridge_find_next_bridge_by_fwnode(struct fwnode_handle *fwnode, u32 port); + /** * drm_bridge_get_next_bridge() - Get the next bridge in the chain * @bridge: bridge object From patchwork Mon Apr 22 19:18:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8C30C4345F for ; Mon, 22 Apr 2024 19:19:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D614D11225C; Mon, 22 Apr 2024 19:19:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="duhA1RQz"; dkim-atps=neutral Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFE1911225C for ; Mon, 22 Apr 2024 19:19:27 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AdzVq0hSo8fS18z5xoeY8+4STJ0X8hxCUiiSMI/5/9M=; b=duhA1RQznC1J8pwivtIZfwp0dvGCXf1fBt5p4kOOd6DxGSSr0yi0YiaF3GxpDFV8SYKRCW xH86JxsMHtCe3To2cUKpvMFzu8R0CpyI+Qmlqifj+5IwsS/aP95n3tIfXwrN165NR7ahOJ ccklRIJwDIW5ymmuB4kVprvVOQ4f8eI= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 2/9] drm/bridge: simple-bridge: Use fwnode API to acquire device properties Date: Tue, 23 Apr 2024 03:18:56 +0800 Message-Id: <20240422191903.255642-3-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make this driver less DT-dependent by calling the freshly created helpers, should be no functional changes for DT based systems. But open the door for otherwise use cases. Even though there is no user emerged yet, this still do no harms. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/simple-bridge.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index 5813a2c4fc5e..3b09bdd5ad4d 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -169,33 +168,32 @@ static const struct drm_bridge_funcs simple_bridge_bridge_funcs = { static int simple_bridge_probe(struct platform_device *pdev) { + struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); struct simple_bridge *sbridge; - struct device_node *remote; + int ret; sbridge = devm_kzalloc(&pdev->dev, sizeof(*sbridge), GFP_KERNEL); if (!sbridge) return -ENOMEM; platform_set_drvdata(pdev, sbridge); - sbridge->info = of_device_get_match_data(&pdev->dev); + sbridge->info = device_get_match_data(&pdev->dev); /* Get the next bridge in the pipeline. */ - remote = of_graph_get_remote_node(pdev->dev.of_node, 1, -1); - if (!remote) - return -EINVAL; - - sbridge->next_bridge = of_drm_find_bridge(remote); - of_node_put(remote); - + sbridge->next_bridge = drm_bridge_find_next_bridge_by_fwnode(fwnode, 1); if (!sbridge->next_bridge) { dev_dbg(&pdev->dev, "Next bridge not found, deferring probe\n"); return -EPROBE_DEFER; + } else if (IS_ERR(sbridge->next_bridge)) { + ret = PTR_ERR(sbridge->next_bridge); + dev_err(&pdev->dev, "Error on finding the next bridge: %d\n", ret); + return ret; } /* Get the regulator and GPIO resources. */ sbridge->vdd = devm_regulator_get_optional(&pdev->dev, "vdd"); if (IS_ERR(sbridge->vdd)) { - int ret = PTR_ERR(sbridge->vdd); + ret = PTR_ERR(sbridge->vdd); if (ret == -EPROBE_DEFER) return -EPROBE_DEFER; sbridge->vdd = NULL; @@ -210,9 +208,9 @@ static int simple_bridge_probe(struct platform_device *pdev) /* Register the bridge. */ sbridge->bridge.funcs = &simple_bridge_bridge_funcs; - sbridge->bridge.of_node = pdev->dev.of_node; sbridge->bridge.timings = sbridge->info->timings; + drm_bridge_set_node(&sbridge->bridge, fwnode); drm_bridge_add(&sbridge->bridge); return 0; From patchwork Mon Apr 22 19:18:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 148A3C4345F for ; Mon, 22 Apr 2024 19:19:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4F4EF11244E; Mon, 22 Apr 2024 19:19:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="uoxEaumF"; dkim-atps=neutral Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id EBF5A11244E for ; Mon, 22 Apr 2024 19:19:32 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VVIjTXds8eAkXzXoUlZ7BHHYR9mhqmmL/UDbaTDw7XI=; b=uoxEaumF/2nv/SOlGcXl4HGPyt5m0zJ7fAzEyUdXrcnr3k+soWy5zu/95/2dmr8Dm/6anR KDkV9SReY+dBQQI6B8YN96/1Jm1/WKbDg5vvdtEQYmjshBYB3/NMy8iagwACPrg9m0wL0X 1LXBQDKD5DebOp5nGttO/oPiQUV6Guk= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 3/9] drm/bridge: simple-bridge: Add platform module alias Date: Tue, 23 Apr 2024 03:18:57 +0800 Message-Id: <20240422191903.255642-4-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Otherwise when compiled as module, this driver will not be probed on non-DT environment. This is a fundamential step to make this driver truely OF-independent. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/simple-bridge.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index 3b09bdd5ad4d..6be271d1394b 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -308,3 +308,4 @@ module_platform_driver(simple_bridge_driver); MODULE_AUTHOR("Maxime Ripard "); MODULE_DESCRIPTION("Simple DRM bridge driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:simple-bridge"); From patchwork Mon Apr 22 19:18:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15065C4345F for ; Mon, 22 Apr 2024 19:19:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64532112D01; Mon, 22 Apr 2024 19:19:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="qSraONwL"; dkim-atps=neutral Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id A4726112852 for ; Mon, 22 Apr 2024 19:19:37 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NDnO3d01ba8EKeTRxUnybEgU0P9s3FIBjxuth5gpvfI=; b=qSraONwLgI3jpDo2bLo4jIdqpNxFtitYRxfs3hBAgtPZa6He9cCjPBxhupTAfY3i7bh52z fMFdtoGleN4jg7SSkerocc9h7ThE56E7QFmHPmCvDdH0l+hlLQiobk95GAXrv0yjUVHTPg uZkLLilua+PVEZ2M/K1md+ubOVEOaF8= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 4/9] drm-bridge: display-connector: Use fwnode API to acquire device properties Date: Tue, 23 Apr 2024 03:18:58 +0800 Message-Id: <20240422191903.255642-5-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make this driver less DT-dependent by using the fwnode helper functions, should be no functional changes for DT based systems. Do the necessary works before it can be truely DT-independent, this patch do no harms even though there is no user yet. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/display-connector.c | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c index ab8e00baf3f1..d80cb7bc59e6 100644 --- a/drivers/gpu/drm/bridge/display-connector.c +++ b/drivers/gpu/drm/bridge/display-connector.c @@ -204,6 +204,7 @@ static int display_connector_get_supply(struct platform_device *pdev, static int display_connector_probe(struct platform_device *pdev) { + struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); struct display_connector *conn; unsigned int type; const char *label = NULL; @@ -215,15 +216,15 @@ static int display_connector_probe(struct platform_device *pdev) platform_set_drvdata(pdev, conn); - type = (uintptr_t)of_device_get_match_data(&pdev->dev); + type = (uintptr_t)device_get_match_data(&pdev->dev); /* Get the exact connector type. */ switch (type) { case DRM_MODE_CONNECTOR_DVII: { bool analog, digital; - analog = of_property_read_bool(pdev->dev.of_node, "analog"); - digital = of_property_read_bool(pdev->dev.of_node, "digital"); + analog = fwnode_property_present(fwnode, "analog"); + digital = fwnode_property_present(fwnode, "digital"); if (analog && !digital) { conn->bridge.type = DRM_MODE_CONNECTOR_DVIA; } else if (!analog && digital) { @@ -240,8 +241,7 @@ static int display_connector_probe(struct platform_device *pdev) case DRM_MODE_CONNECTOR_HDMIA: { const char *hdmi_type; - ret = of_property_read_string(pdev->dev.of_node, "type", - &hdmi_type); + ret = fwnode_property_read_string(fwnode, "type", &hdmi_type); if (ret < 0) { dev_err(&pdev->dev, "HDMI connector with no type\n"); return -EINVAL; @@ -271,7 +271,7 @@ static int display_connector_probe(struct platform_device *pdev) conn->bridge.interlace_allowed = true; /* Get the optional connector label. */ - of_property_read_string(pdev->dev.of_node, "label", &label); + fwnode_property_read_string(fwnode, "label", &label); /* * Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can provide @@ -309,12 +309,12 @@ static int display_connector_probe(struct platform_device *pdev) if (type == DRM_MODE_CONNECTOR_DVII || type == DRM_MODE_CONNECTOR_HDMIA || type == DRM_MODE_CONNECTOR_VGA) { - struct device_node *phandle; + struct fwnode_handle *phandle; - phandle = of_parse_phandle(pdev->dev.of_node, "ddc-i2c-bus", 0); - if (phandle) { - conn->bridge.ddc = of_get_i2c_adapter_by_node(phandle); - of_node_put(phandle); + phandle = fwnode_find_reference(fwnode, "ddc-i2c-bus", 0); + if (!IS_ERR_OR_NULL(phandle)) { + conn->bridge.ddc = i2c_get_adapter_by_fwnode(phandle); + fwnode_handle_put(phandle); if (!conn->bridge.ddc) return -EPROBE_DEFER; } else { @@ -358,7 +358,7 @@ static int display_connector_probe(struct platform_device *pdev) } conn->bridge.funcs = &display_connector_bridge_funcs; - conn->bridge.of_node = pdev->dev.of_node; + drm_bridge_set_node(&conn->bridge, fwnode); if (conn->bridge.ddc) conn->bridge.ops |= DRM_BRIDGE_OP_EDID From patchwork Mon Apr 22 19:18:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EA3FC4345F for ; Mon, 22 Apr 2024 19:19:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 07BAB112D04; Mon, 22 Apr 2024 19:19:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="USB05btD"; dkim-atps=neutral Received: from out-184.mta1.migadu.com (out-184.mta1.migadu.com [95.215.58.184]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B48F112D04 for ; Mon, 22 Apr 2024 19:19:42 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QHcHgLztm1MbyZtiaxxPtZqiLu7TluHYcwMGaSWtFjQ=; b=USB05btDDzI8uOyGmlMplJpq7Qmq3rVj99yphIeUU4pwVOum6BMSyvHrPInoXDYhlLXHJz 9OZRRJHKSnaxeBjiPsIV66BvlpCc4STHECvUy+3tMtflXPtrIPHHpOsDHkpTRWKb5ZT6h+ uwyFbmzadGv5inQLcdNPsZrd3yIeJvw= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 5/9] drm/bridge: display-connector: Add platform module alias Date: Tue, 23 Apr 2024 03:18:59 +0800 Message-Id: <20240422191903.255642-6-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Otherwise when compiled as module, this driver will not be probed on non-DT environment. This is a fundamential step to make this driver truely OF-independent. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/display-connector.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c index d80cb7bc59e6..7d9b4edf4025 100644 --- a/drivers/gpu/drm/bridge/display-connector.c +++ b/drivers/gpu/drm/bridge/display-connector.c @@ -434,3 +434,4 @@ module_platform_driver(display_connector_driver); MODULE_AUTHOR("Laurent Pinchart "); MODULE_DESCRIPTION("Display connector driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:display-connector"); From patchwork Mon Apr 22 19:19:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8051BC4345F for ; Mon, 22 Apr 2024 19:19:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A2652112D06; Mon, 22 Apr 2024 19:19:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="grekojdB"; dkim-atps=neutral Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59A73112D07 for ; Mon, 22 Apr 2024 19:19:47 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813585; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6tEoow3QlZGEbyC23DthOGK7n4k2QNy+D7Afpqn4m4E=; b=grekojdBfk5IRS1AuUtJx9mglk/CpIRleMxyBUxlK5LaySMjdhQaMGbN6vbnhyBdbFTznE RK2njiinQPUzemCRsUx6Pa4vGXlQYvb/9ybEQhBv17JNscdUsW7M9I5td3VipSkIMuzC5a o/ZnnMZ8lZCzvy0oyynUBDOnPvslrII= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 6/9] drm-bridge: sii902x: Use fwnode API to acquire device properties Date: Tue, 23 Apr 2024 03:19:00 +0800 Message-Id: <20240422191903.255642-7-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make this driver less DT-dependent by calling the freshly created helper functions, which reduce boilerplate. Should be no functional changes for DT based systems. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/sii902x.c | 43 +++++++++++--------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c index 8f84e98249c7..04436f318c7f 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -827,20 +827,19 @@ static int sii902x_audio_codec_init(struct sii902x *sii902x, .spdif = 0, .max_i2s_channels = 0, }; + struct fwnode_handle *fwnode = dev_fwnode(dev); u8 lanes[4]; int num_lanes, i; - if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) { + if (!fwnode_property_present(fwnode, "#sound-dai-cells")) { dev_dbg(dev, "%s: No \"#sound-dai-cells\", no audio\n", __func__); return 0; } - num_lanes = of_property_read_variable_u8_array(dev->of_node, - "sil,i2s-data-lanes", - lanes, 1, - ARRAY_SIZE(lanes)); - + num_lanes = fwnode_property_read_u8_array(fwnode, + "sil,i2s-data-lanes", + lanes, ARRAY_SIZE(lanes)); if (num_lanes == -EINVAL) { dev_dbg(dev, "%s: No \"sil,i2s-data-lanes\", use default <0>\n", @@ -1097,13 +1096,13 @@ static int sii902x_init(struct sii902x *sii902x) goto err_unreg_audio; sii902x->bridge.funcs = &sii902x_bridge_funcs; - sii902x->bridge.of_node = dev->of_node; sii902x->bridge.timings = &default_sii902x_timings; sii902x->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID; if (sii902x->i2c->irq > 0) sii902x->bridge.ops |= DRM_BRIDGE_OP_HPD; + drm_bridge_set_node(&sii902x->bridge, dev_fwnode(dev)); drm_bridge_add(&sii902x->bridge); return 0; @@ -1118,7 +1117,6 @@ static int sii902x_init(struct sii902x *sii902x) static int sii902x_probe(struct i2c_client *client) { struct device *dev = &client->dev; - struct device_node *endpoint; struct sii902x *sii902x; static const char * const supplies[] = {"iovcc", "cvcc12"}; int ret; @@ -1147,27 +1145,14 @@ static int sii902x_probe(struct i2c_client *client) return PTR_ERR(sii902x->reset_gpio); } - endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 1, -1); - if (endpoint) { - struct device_node *remote = of_graph_get_remote_port_parent(endpoint); - - of_node_put(endpoint); - if (!remote) { - dev_err(dev, "Endpoint in port@1 unconnected\n"); - return -ENODEV; - } - - if (!of_device_is_available(remote)) { - dev_err(dev, "port@1 remote device is disabled\n"); - of_node_put(remote); - return -ENODEV; - } - - sii902x->next_bridge = of_drm_find_bridge(remote); - of_node_put(remote); - if (!sii902x->next_bridge) - return dev_err_probe(dev, -EPROBE_DEFER, - "Failed to find remote bridge\n"); + sii902x->next_bridge = drm_bridge_find_next_bridge_by_fwnode(dev_fwnode(dev), 1); + if (!sii902x->next_bridge) { + return dev_err_probe(dev, -EPROBE_DEFER, + "Failed to find the next bridge\n"); + } else if (IS_ERR(sii902x->next_bridge)) { + ret = PTR_ERR(sii902x->next_bridge); + dev_err(dev, "Error on find the next bridge: %d\n", ret); + return ret; } mutex_init(&sii902x->mutex); From patchwork Mon Apr 22 19:19:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFD9EC4345F for ; Mon, 22 Apr 2024 19:19:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A9C7112D07; Mon, 22 Apr 2024 19:19:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="tkeZhKjV"; dkim-atps=neutral Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) by gabe.freedesktop.org (Postfix) with ESMTPS id 781D4112D07 for ; Mon, 22 Apr 2024 19:19:52 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gqEhBcfnv9rUbWN96BkVZjg/A8+GnWYlmO3Ge72EuvE=; b=tkeZhKjVLuvfh6Foyzk3MbB2uAvEY5upHeSRQ+blEYlElqGcK63pkFZY0N3cCd3XH2JdF/ huv7OpW7uxnTL+qtFVG+Isu7CoTzn8Exnttl2egWGTj0p3+3+NVSO6UbTvV0MLeRO0z4/u o2sk53FsT3BzwQVRuUBUpra9pTTgNjM= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 7/9] drm-bridge: it66121: Use fwnode API to acquire device properties Date: Tue, 23 Apr 2024 03:19:01 +0800 Message-Id: <20240422191903.255642-8-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make this driver DT-independent by calling the freshly created helpers, which reduce boilerplate and open the door for otherwise use cases. No functional changes for DT based systems. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/ite-it66121.c | 57 +++++++++++++++++----------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c index 925e42f46cd8..688dc1830654 100644 --- a/drivers/gpu/drm/bridge/ite-it66121.c +++ b/drivers/gpu/drm/bridge/ite-it66121.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -1480,7 +1479,7 @@ static int it66121_audio_codec_init(struct it66121_ctx *ctx, struct device *dev) dev_dbg(dev, "%s\n", __func__); - if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) { + if (!fwnode_property_present(dev_fwnode(dev), "#sound-dai-cells")) { dev_info(dev, "No \"#sound-dai-cells\", no audio\n"); return 0; } @@ -1503,13 +1502,36 @@ static const char * const it66121_supplies[] = { "vcn33", "vcn18", "vrf12" }; +static int it66121_read_bus_width(struct fwnode_handle *fwnode, u32 *bus_width) +{ + struct fwnode_handle *endpoint; + u32 val; + int ret; + + endpoint = fwnode_graph_get_endpoint_by_id(fwnode, 0, 0, 0); + if (!endpoint) + return -EINVAL; + + ret = fwnode_property_read_u32(endpoint, "bus-width", &val); + fwnode_handle_put(endpoint); + if (ret) + return ret; + + if (val != 12 && val != 24) + return -EINVAL; + + *bus_width = val; + + return 0; +} + static int it66121_probe(struct i2c_client *client) { u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 }; - struct device_node *ep; int ret; struct it66121_ctx *ctx; struct device *dev = &client->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(dev, "I2C check functionality failed.\n"); @@ -1520,29 +1542,20 @@ static int it66121_probe(struct i2c_client *client) if (!ctx) return -ENOMEM; - ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); - if (!ep) - return -EINVAL; - ctx->dev = dev; ctx->client = client; ctx->info = i2c_get_match_data(client); - of_property_read_u32(ep, "bus-width", &ctx->bus_width); - of_node_put(ep); - - if (ctx->bus_width != 12 && ctx->bus_width != 24) - return -EINVAL; - - ep = of_graph_get_remote_node(dev->of_node, 1, -1); - if (!ep) { - dev_err(ctx->dev, "The endpoint is unconnected\n"); - return -EINVAL; - } + ret = it66121_read_bus_width(fwnode, &ctx->bus_width); + if (ret) + return ret; - ctx->next_bridge = of_drm_find_bridge(ep); - of_node_put(ep); - if (!ctx->next_bridge) { + ctx->next_bridge = drm_bridge_find_next_bridge_by_fwnode(fwnode, 1); + if (IS_ERR(ctx->next_bridge)) { + ret = PTR_ERR(ctx->next_bridge); + dev_err(dev, "Error in founding the next bridge: %d\n", ret); + return ret; + } else if (!ctx->next_bridge) { dev_dbg(ctx->dev, "Next bridge not found, deferring probe\n"); return -EPROBE_DEFER; } @@ -1577,8 +1590,8 @@ static int it66121_probe(struct i2c_client *client) return -ENODEV; } + drm_bridge_set_node(&ctx->bridge, fwnode); ctx->bridge.funcs = &it66121_bridge_funcs; - ctx->bridge.of_node = dev->of_node; ctx->bridge.type = DRM_MODE_CONNECTOR_HDMIA; ctx->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID; if (client->irq > 0) { From patchwork Mon Apr 22 19:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 598C2C4345F for ; Mon, 22 Apr 2024 19:19:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4105112D0A; Mon, 22 Apr 2024 19:19:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="WNQpfCw0"; dkim-atps=neutral Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED6F9112D09 for ; Mon, 22 Apr 2024 19:19:56 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+DZUEgRYcSmSCNpMFRJJvZshOZpL7UP9Hp7JpDo8EBk=; b=WNQpfCw0v1uvB9h2ZJSD+dj+lnnhqUm+1gVbOkZzc2oW2Fkw/rdZBScxAR1DOusgGtnPFm dVZu5KNFE4x6mlu8to6KL6BOeVgK9f0mtO7I431jdViOfu9sYTL8CLfddgRsHXPTPJQM33 Iy2ayO65CrR2X7OmdHhfo8CV+qkNnkQ= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 8/9] drm/bridge: tfp410: Use fwnode API to acquire device properties Date: Tue, 23 Apr 2024 03:19:02 +0800 Message-Id: <20240422191903.255642-9-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make this driver DT-independent by calling the freshly created helpers, which reduce boilerplate and open the door for otherwise use cases. No functional changes for DT based systems. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/ti-tfp410.c | 41 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c index c7bef5c23927..58dc7492844f 100644 --- a/drivers/gpu/drm/bridge/ti-tfp410.c +++ b/drivers/gpu/drm/bridge/ti-tfp410.c @@ -266,8 +266,9 @@ static const struct drm_bridge_timings tfp410_default_timings = { static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) { + struct fwnode_handle *fwnode = dev_fwnode(dvi->dev); struct drm_bridge_timings *timings = &dvi->timings; - struct device_node *ep; + struct fwnode_handle *ep; u32 pclk_sample = 0; u32 bus_width = 24; u32 deskew = 0; @@ -288,14 +289,14 @@ static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) * and EDGE pins. They are specified in DT through endpoint properties * and vendor-specific properties. */ - ep = of_graph_get_endpoint_by_regs(dvi->dev->of_node, 0, 0); + ep = fwnode_graph_get_endpoint_by_id(fwnode, 0, 0, 0); if (!ep) return -EINVAL; /* Get the sampling edge from the endpoint. */ - of_property_read_u32(ep, "pclk-sample", &pclk_sample); - of_property_read_u32(ep, "bus-width", &bus_width); - of_node_put(ep); + fwnode_property_read_u32(ep, "pclk-sample", &pclk_sample); + fwnode_property_read_u32(ep, "bus-width", &bus_width); + fwnode_handle_put(ep); timings->input_bus_flags = DRM_BUS_FLAG_DE_HIGH; @@ -324,7 +325,7 @@ static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) } /* Get the setup and hold time from vendor-specific properties. */ - of_property_read_u32(dvi->dev->of_node, "ti,deskew", &deskew); + fwnode_property_read_u32(fwnode, "ti,deskew", &deskew); if (deskew > 7) return -EINVAL; @@ -336,12 +337,12 @@ static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) static int tfp410_init(struct device *dev, bool i2c) { - struct device_node *node; + struct fwnode_handle *fwnode = dev_fwnode(dev); struct tfp410 *dvi; int ret; - if (!dev->of_node) { - dev_err(dev, "device-tree data is missing\n"); + if (!fwnode) { + dev_err(dev, "firmware data is missing\n"); return -ENXIO; } @@ -352,8 +353,8 @@ static int tfp410_init(struct device *dev, bool i2c) dvi->dev = dev; dev_set_drvdata(dev, dvi); + drm_bridge_set_node(&dvi->bridge, fwnode); dvi->bridge.funcs = &tfp410_bridge_funcs; - dvi->bridge.of_node = dev->of_node; dvi->bridge.timings = &dvi->timings; dvi->bridge.type = DRM_MODE_CONNECTOR_DVID; @@ -362,15 +363,15 @@ static int tfp410_init(struct device *dev, bool i2c) return ret; /* Get the next bridge, connected to port@1. */ - node = of_graph_get_remote_node(dev->of_node, 1, -1); - if (!node) - return -ENODEV; - - dvi->next_bridge = of_drm_find_bridge(node); - of_node_put(node); - - if (!dvi->next_bridge) + dvi->next_bridge = drm_bridge_find_next_bridge_by_fwnode(fwnode, 1); + if (IS_ERR(dvi->next_bridge)) { + ret = PTR_ERR(dvi->next_bridge); + dev_err(dev, "Error in founding the next bridge: %d\n", ret); + return ret; + } else if (!dvi->next_bridge) { + dev_dbg(dev, "Next bridge not found, deferring probe\n"); return -EPROBE_DEFER; + } /* Get the powerdown GPIO. */ dvi->powerdown = devm_gpiod_get_optional(dev, "powerdown", @@ -422,10 +423,10 @@ static struct platform_driver tfp410_platform_driver = { /* There is currently no i2c functionality. */ static int tfp410_i2c_probe(struct i2c_client *client) { + struct fwnode_handle *fwnode = dev_fwnode(&client->dev); int reg; - if (!client->dev.of_node || - of_property_read_u32(client->dev.of_node, "reg", ®)) { + if (!fwnode || fwnode_property_read_u32(fwnode, "reg", ®)) { dev_err(&client->dev, "Can't get i2c reg property from device-tree\n"); return -ENXIO; From patchwork Mon Apr 22 19:19:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13638864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAB84C4345F for ; Mon, 22 Apr 2024 19:20:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 001A0112D0B; Mon, 22 Apr 2024 19:20:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="QsyvjeVu"; dkim-atps=neutral Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) by gabe.freedesktop.org (Postfix) with ESMTPS id 03EE4112D0C for ; Mon, 22 Apr 2024 19:20:01 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713813599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OLQX3xwwNRyCA4F+ralsXdsqs/AGr4cJodEaBXIoFjw=; b=QsyvjeVuiitreg+RWW5zNEO0mARwEUAThwgl8NWlzMIlg+avMtrHDWF02ExkLBvp7UVL+h 08O6IqF3ZbI+8kcabTp/RGkYf71ZiQD2vIiQP73Fge5qR1nmhGqNOhJEDYUu6XSUJeGxIC MpjIkQ/maeZoUe876Jn3UkJNFENHTW0= From: Sui Jingfeng To: Neil Armstrong Cc: Robert Foss , Laurent Pinchart , Andrzej Hajda , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v4 9/9] drm/bridge: tfp410: Add platform module alias Date: Tue, 23 Apr 2024 03:19:03 +0800 Message-Id: <20240422191903.255642-10-sui.jingfeng@linux.dev> In-Reply-To: <20240422191903.255642-1-sui.jingfeng@linux.dev> References: <20240422191903.255642-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Otherwise when compiled as module, this driver will not be probed on non-DT environment. This is a fundamential step to make this driver truely OF-independent. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/ti-tfp410.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c index 58dc7492844f..6a0a0bbe3c6b 100644 --- a/drivers/gpu/drm/bridge/ti-tfp410.c +++ b/drivers/gpu/drm/bridge/ti-tfp410.c @@ -504,3 +504,4 @@ module_exit(tfp410_module_exit); MODULE_AUTHOR("Jyri Sarha "); MODULE_DESCRIPTION("TI TFP410 DVI bridge driver"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:tfp410");