From nobody Sat Feb 7 23:12:17 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBF5113AC4 for ; Mon, 11 Mar 2024 08:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147500; cv=none; b=CVROZIBPPE6Bz94qSooEel3mknPebb9tLtuVILBriiHhrqcXLVXMqWoTsUx0Ge2Nw9PSr+otT5aek7DTTGy6QkZXdGS2/sPcuFDXFK60NHhOoyu904N0pBnmGgwNW9DUMrHpulk9uZBAWK6lPubXtM59dbVQOcA6fIPElktxCbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147500; c=relaxed/simple; bh=ddcyhwSvJwXB7FYvSYBSmbL0XpSvnL9leNwj9qrhD8o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h5nS1Gxjg2iCEgzcCfxw1Sk9LIRv81cX/c8fRP7esm1N00GXvvugRtd9BMRSCsDdj3GY9lfrKCWm2YFqNABnfsE8pG4XHbuXtOWEaHS46IZ8l40GmgCdNYC1CcjrUFiL94keiONmBVT5ehg6Kwu873g66qARmWaGbQebzpwToR8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=mDOFhb/y; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="mDOFhb/y" 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=1710147495; 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=ACbuVzqDGeY5B8aCLo+ycEpWur4XOQkFda8KsYe8re8=; b=mDOFhb/yw0YS3Ov2WeSr5X2tbx1OeqfTi2ChwZG6hVJkDe1Y6dHnlkgV2jMsRtt9eYSzEJ WOV922L0kD/7C4rj7Tpbmpjd6CiPFXdE1uPdyMGyLM923hkkK/oPTYVDP7lxdsYjMjSxfq +WPpEThoM1RvRsfRKpYmecZHLPZfJmk= From: Sui Jingfeng To: Andrzej Hajda Cc: Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v3 1/5] drm/bridge: Allow using fwnode API to get the next bridge Date: Mon, 11 Mar 2024 16:56:55 +0800 Message-Id: <20240311085659.244043-2-sui.jingfeng@linux.dev> In-Reply-To: <20240311085659.244043-1-sui.jingfeng@linux.dev> References: <20240311085659.244043-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Currently, the various drm bridge drivers relay 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 drm display bridge drivers to work across systems. As the fwnode based API has wider coverage than DT 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 the drm bridge driver is probed, and there is a fwnode assigned to the instance of specific drm bridge driver. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/drm_bridge.c | 72 ++++++++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 16 ++++++++ 2 files changed, 88 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 28abe9aa99ca..ffc6162e2517 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -1368,6 +1368,78 @@ struct drm_bridge *of_drm_find_bridge(struct device_= node *np) EXPORT_SYMBOL(of_drm_find_bridge); #endif =20 +/** + * 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. + * + * Return: + * A reference to the drm_bridge if found, return NULL otherwise. + */ +struct drm_bridge *drm_bridge_find_by_fwnode(struct fwnode_handle *fwnode) +{ + struct drm_bridge *ret =3D NULL; + struct drm_bridge *bridge; + + if (!fwnode) + return NULL; + + mutex_lock(&bridge_lock); + + list_for_each_entry(bridge, &bridge_list, list) { + if (bridge->fwnode =3D=3D fwnode) { + ret =3D 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 + * that there has valid fwnode graph established. + * + * Return: + * A reference to the drm_bridge if found. + * %NULL if not found or the next bridge is not finish probe yet. + * A negative error code otherwise. + */ +struct drm_bridge * +drm_bridge_find_next_bridge_by_fwnode(struct fwnode_handle *fwnode, u32 po= rt) +{ + struct drm_bridge *bridge; + struct fwnode_handle *ep; + struct fwnode_handle *remote; + + ep =3D fwnode_graph_get_endpoint_by_id(fwnode, port, 0, 0); + if (!ep) + return ERR_PTR(-EINVAL); + + remote =3D fwnode_graph_get_remote_port_parent(ep); + fwnode_handle_put(ep); + if (!remote) + return ERR_PTR(-ENODEV); + + bridge =3D 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 3606e1a7f965..d4c95afdd662 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -26,6 +26,7 @@ #include #include #include +#include =20 #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, str= uct drm_bridge *bridge, struct drm_bridge *previous, enum drm_bridge_attach_flags flags); =20 +static inline void +drm_bridge_set_node(struct drm_bridge *bridge, struct fwnode_handle *fwnod= e) +{ + bridge->fwnode =3D fwnode; + bridge->of_node =3D 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(st= ruct device_node *np) } #endif =20 +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 po= rt); + /** * drm_bridge_get_next_bridge() - Get the next bridge in the chain * @bridge: bridge object --=20 2.34.1 From nobody Sat Feb 7 23:12:17 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3632118B15 for ; Mon, 11 Mar 2024 08:58:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147506; cv=none; b=YDhlduS2B0Yd/jvtEPWlFAQVKyM6vNfrfXmnNSVcOoaVOppFf3kj/Ri7MQi+6/91lfgrboojZ8yTcRW1rd5a9S5oW1Y61t23C9UnxXJD+SdCRXfrLTyE+eL+gkUu7/foQyzA8yTzS98Z50N2b/fEVNqgf3RudJm+WdVM5AafjLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147506; c=relaxed/simple; bh=g2uyYKP3fTMNqz1inMg+JCYrTWQJzGEy4xF64bwHe0Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sA3CBo8UiKWayNGCPWSumWvkTBq+B3e6leVn2DtddnWGYL+GQGUAh/Ah9G1GsItcDopIxu9uX8WJuBclvczQuygEZWz7F+NkgkuQSh8IuqJjFo7brOb5+dNzD820FoEm0eipKxklLItP7grDZ3daaJxsYKUbnjRHYzGsnWJwDXk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Ywxh3D3S; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Ywxh3D3S" 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=1710147503; 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=Ywxh3D3SbrIHx8AEv7gkKxSf5+SpuEuijnz6eh4LyUC/DpETfJQ2PqNRZK5hpW4G+2gp2d cMpUqMBV16jezAgqshRIwG7EJiTvGdCgMlwVkKHQZgzxitnpjeaJYKXhsByZCQJg8ODzsf niiBVJt6/TS1cdn8urUBCRGpIq2Ng6Q= From: Sui Jingfeng To: Andrzej Hajda Cc: Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v3 2/5] drm/bridge: simple-bridge: Use fwnode API to acquire device properties Date: Mon, 11 Mar 2024 16:56:56 +0800 Message-Id: <20240311085659.244043-3-sui.jingfeng@linux.dev> In-Reply-To: <20240311085659.244043-1-sui.jingfeng@linux.dev> References: <20240311085659.244043-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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/bridg= e/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 =20 @@ -169,33 +168,32 @@ static const struct drm_bridge_funcs simple_bridge_br= idge_funcs =3D { =20 static int simple_bridge_probe(struct platform_device *pdev) { + struct fwnode_handle *fwnode =3D dev_fwnode(&pdev->dev); struct simple_bridge *sbridge; - struct device_node *remote; + int ret; =20 sbridge =3D devm_kzalloc(&pdev->dev, sizeof(*sbridge), GFP_KERNEL); if (!sbridge) return -ENOMEM; platform_set_drvdata(pdev, sbridge); =20 - sbridge->info =3D of_device_get_match_data(&pdev->dev); + sbridge->info =3D device_get_match_data(&pdev->dev); =20 /* Get the next bridge in the pipeline. */ - remote =3D of_graph_get_remote_node(pdev->dev.of_node, 1, -1); - if (!remote) - return -EINVAL; - - sbridge->next_bridge =3D of_drm_find_bridge(remote); - of_node_put(remote); - + sbridge->next_bridge =3D 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 =3D PTR_ERR(sbridge->next_bridge); + dev_err(&pdev->dev, "Error on finding the next bridge: %d\n", ret); + return ret; } =20 /* Get the regulator and GPIO resources. */ sbridge->vdd =3D devm_regulator_get_optional(&pdev->dev, "vdd"); if (IS_ERR(sbridge->vdd)) { - int ret =3D PTR_ERR(sbridge->vdd); + ret =3D PTR_ERR(sbridge->vdd); if (ret =3D=3D -EPROBE_DEFER) return -EPROBE_DEFER; sbridge->vdd =3D NULL; @@ -210,9 +208,9 @@ static int simple_bridge_probe(struct platform_device *= pdev) =20 /* Register the bridge. */ sbridge->bridge.funcs =3D &simple_bridge_bridge_funcs; - sbridge->bridge.of_node =3D pdev->dev.of_node; sbridge->bridge.timings =3D sbridge->info->timings; =20 + drm_bridge_set_node(&sbridge->bridge, fwnode); drm_bridge_add(&sbridge->bridge); =20 return 0; --=20 2.34.1 From nobody Sat Feb 7 23:12:17 2026 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF61521115 for ; Mon, 11 Mar 2024 08:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147511; cv=none; b=WELiWew3jZ7n1pLa447z5kPzxKm/DBExsvYtpP7Jf0VHiYhgMe7R86u4zYwmHVmt2cUjYEQJjoKrswoAj26QU4K2/lEgpQFgr/mMeVDVCjq0ODuNhWZsU5cdV/kacD2Fwq/xHyAatijUYtKcunfmy394lWSxiiFJ/aQyHyy4wGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147511; c=relaxed/simple; bh=vq9XBTBjoQZnocYnQAqv25NSvH4VWo7Rsys2n+nDlxE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SXsdyPPN2N4lYX6bx8jkiStBtydpY0L35gVj9Qz/M0Ti7L/W1NcrOajRzQMN8fP7Ju2mdmw7H/4AdS7jHlpGULiMrM6Z+KieiJ30mwz5XJmt0W0m0ZxzPMuknV7+JoZtbhQAuBt79Y21aiKgLIo7jCgPG+TjOGIJZ2UlvJEOJsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=o7SpAZM2; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="o7SpAZM2" 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=1710147507; 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=Aep+0Bx5dDl+omojFo37hiW07MeWApSc10wBdc6QHoM=; b=o7SpAZM20vIWA1feEu6Qmid7aZHNi34FMD0eBo819WVjEfZDH/7z2Ki4n50utYq2lw4Bw4 JV0JLLp48M/TehOzS2WavoDaWfiba0/hR8DhKnL/D4fBdHWbr3sggprk2UWWBapGe1UanY 6moYpT4qpUqeOh6JOqSTAh//Ko7PJSk= From: Sui Jingfeng To: Andrzej Hajda Cc: Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v3 3/5] drm-bridge: display-connector: Use fwnode API to acquire device properties Date: Mon, 11 Mar 2024 16:56:57 +0800 Message-Id: <20240311085659.244043-4-sui.jingfeng@linux.dev> In-Reply-To: <20240311085659.244043-1-sui.jingfeng@linux.dev> References: <20240311085659.244043-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Make this driver less DT-dependent by using the fwnode helper function, should be no functional changes for DT based systems. Do the necessary works before it can be truely subsystem independent, even though there is no user yet, this still do no harms. 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/b= ridge/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, =20 static int display_connector_probe(struct platform_device *pdev) { + struct fwnode_handle *fwnode =3D dev_fwnode(&pdev->dev); struct display_connector *conn; unsigned int type; const char *label =3D NULL; @@ -215,15 +216,15 @@ static int display_connector_probe(struct platform_de= vice *pdev) =20 platform_set_drvdata(pdev, conn); =20 - type =3D (uintptr_t)of_device_get_match_data(&pdev->dev); + type =3D (uintptr_t)device_get_match_data(&pdev->dev); =20 /* Get the exact connector type. */ switch (type) { case DRM_MODE_CONNECTOR_DVII: { bool analog, digital; =20 - analog =3D of_property_read_bool(pdev->dev.of_node, "analog"); - digital =3D of_property_read_bool(pdev->dev.of_node, "digital"); + analog =3D fwnode_property_present(fwnode, "analog"); + digital =3D fwnode_property_present(fwnode, "digital"); if (analog && !digital) { conn->bridge.type =3D DRM_MODE_CONNECTOR_DVIA; } else if (!analog && digital) { @@ -240,8 +241,7 @@ static int display_connector_probe(struct platform_devi= ce *pdev) case DRM_MODE_CONNECTOR_HDMIA: { const char *hdmi_type; =20 - ret =3D of_property_read_string(pdev->dev.of_node, "type", - &hdmi_type); + ret =3D 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_devi= ce *pdev) conn->bridge.interlace_allowed =3D true; =20 /* Get the optional connector label. */ - of_property_read_string(pdev->dev.of_node, "label", &label); + fwnode_property_read_string(fwnode, "label", &label); =20 /* * Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can prov= ide @@ -309,12 +309,12 @@ static int display_connector_probe(struct platform_de= vice *pdev) if (type =3D=3D DRM_MODE_CONNECTOR_DVII || type =3D=3D DRM_MODE_CONNECTOR_HDMIA || type =3D=3D DRM_MODE_CONNECTOR_VGA) { - struct device_node *phandle; + struct fwnode_handle *phandle; =20 - phandle =3D of_parse_phandle(pdev->dev.of_node, "ddc-i2c-bus", 0); - if (phandle) { - conn->bridge.ddc =3D of_get_i2c_adapter_by_node(phandle); - of_node_put(phandle); + phandle =3D fwnode_find_reference(fwnode, "ddc-i2c-bus", 0); + if (!IS_ERR_OR_NULL(phandle)) { + conn->bridge.ddc =3D 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_devi= ce *pdev) } =20 conn->bridge.funcs =3D &display_connector_bridge_funcs; - conn->bridge.of_node =3D pdev->dev.of_node; + drm_bridge_set_node(&conn->bridge, fwnode); =20 if (conn->bridge.ddc) conn->bridge.ops |=3D DRM_BRIDGE_OP_EDID --=20 2.34.1 From nobody Sat Feb 7 23:12:17 2026 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13E522B9C3 for ; Mon, 11 Mar 2024 08:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147519; cv=none; b=HW+Kr9XlHUgzUtdoEJ2VQU0g/ygXP6wxF3Rs0G1eqTnBySL/6+MKwPDMem700b4z4T8EkyfKYw7gP/d0VJ1l7LnmZIZD5Nv3d29IpMYZTaEeY3a+bphJlnd7EO3gdCS54W/1r2MFV0nUmI47H+yYixGTmzgishUy2sfXPiiWdYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147519; c=relaxed/simple; bh=pXovRMjeL4ByE/vpL205Xui8tHsOBRVHXcsA1vI1bRo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j7ZaXiwW3iPOd9+WebCDo2R6Ds5K9mszTNYmRIbeMJeLnp0DRoop7TPR8uQ6XXSkn+JdCuTF2ern3ZXJzzTAQtQ8nt6EoUZWB1rsIJoa3rAKP5246IvgZWKzuYEruY1gv10o7nwyKcZReN7Hlg17Dg+RatJ0hc7LGurHEXVGMrE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Q1a9WOJM; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Q1a9WOJM" 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=1710147516; 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=qpFxJ3SaUbuEjaQuODo+eOlkZ4g0ImTCeEIwDGa1hhA=; b=Q1a9WOJMkc6IbEnTNssVw0C/c+fyjJxbDseLI6wW8C0ScFVC3LHPQL2pRsybyFCO6kZuG3 mUGJoDd7l3sI18d1hohdqwH/upk833TzmPftgrcXzlvbljTiJu3tledqhM1kfpd9bVQ4pZ 4Zw9aruiMISUP9qQVBd/TUtAGUtFeXw= From: Sui Jingfeng To: Andrzej Hajda Cc: Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v3 4/5] drm-bridge: it66121: Use fwnode API to acquire device properties Date: Mon, 11 Mar 2024 16:56:58 +0800 Message-Id: <20240311085659.244043-5-sui.jingfeng@linux.dev> In-Reply-To: <20240311085659.244043-1-sui.jingfeng@linux.dev> References: <20240311085659.244043-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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. In fact, we reduce boilerplate across drm bridge drivers. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/ite-it66121.c | 63 +++++++++++++++------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/= ite-it66121.c index 1c3433b5e366..a04d755fed4c 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_ct= x *ctx, struct device *dev) =20 dev_dbg(dev, "%s\n", __func__); =20 - 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[] =3D { "vcn33", "vcn18", "vrf12" }; =20 +static int it66121_read_bus_width(struct fwnode_handle *fwnode, u32 *bus_w= idth) +{ + struct fwnode_handle *endpoint; + u32 val; + int ret; + + endpoint =3D fwnode_graph_get_endpoint_by_id(fwnode, 0, 0, 0); + if (!endpoint) + return -EINVAL; + + ret =3D fwnode_property_read_u32(endpoint, "bus-width", &val); + fwnode_handle_put(endpoint); + if (ret) + return ret; + + if (val !=3D 12 && val !=3D 24) + return -EINVAL; + + *bus_width =3D val; + + return 0; +} + static int it66121_probe(struct i2c_client *client) { u32 revision_id, vendor_ids[2] =3D { 0 }, device_ids[2] =3D { 0 }; - struct device_node *ep; int ret; struct it66121_ctx *ctx; struct device *dev =3D &client->dev; + struct fwnode_handle *fwnode =3D dev_fwnode(dev); =20 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(dev, "I2C check functionality failed.\n"); @@ -1520,35 +1542,20 @@ static int it66121_probe(struct i2c_client *client) if (!ctx) return -ENOMEM; =20 - ep =3D of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); - if (!ep) - return -EINVAL; - ctx->dev =3D dev; ctx->client =3D client; ctx->info =3D i2c_get_match_data(client); =20 - of_property_read_u32(ep, "bus-width", &ctx->bus_width); - of_node_put(ep); - - if (ctx->bus_width !=3D 12 && ctx->bus_width !=3D 24) - return -EINVAL; - - ep =3D of_graph_get_remote_node(dev->of_node, 1, -1); - if (!ep) { - dev_err(ctx->dev, "The endpoint is unconnected\n"); - return -EINVAL; - } - - if (!of_device_is_available(ep)) { - of_node_put(ep); - dev_err(ctx->dev, "The remote device is disabled\n"); - return -ENODEV; - } + ret =3D it66121_read_bus_width(fwnode, &ctx->bus_width); + if (ret) + return ret; =20 - ctx->next_bridge =3D of_drm_find_bridge(ep); - of_node_put(ep); - if (!ctx->next_bridge) { + ctx->next_bridge =3D drm_bridge_find_next_bridge_by_fwnode(fwnode, 1); + if (IS_ERR(ctx->next_bridge)) { + ret =3D 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; } @@ -1584,9 +1591,9 @@ static int it66121_probe(struct i2c_client *client) } =20 ctx->bridge.funcs =3D &it66121_bridge_funcs; - ctx->bridge.of_node =3D dev->of_node; ctx->bridge.type =3D DRM_MODE_CONNECTOR_HDMIA; ctx->bridge.ops =3D DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDG= E_OP_HPD; + drm_bridge_set_node(&ctx->bridge, fwnode); =20 ret =3D devm_request_threaded_irq(dev, client->irq, NULL, it66121_irq_thr= eaded_handler, IRQF_ONESHOT, dev_name(dev), ctx); --=20 2.34.1 From nobody Sat Feb 7 23:12:17 2026 Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC57A2C698 for ; Mon, 11 Mar 2024 08:58:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147532; cv=none; b=fscVPxSdPIvXXKpbANnRUcFQamgFhD/T40gY3UnN8AZQ25umTwlRJMxLiLP5JRGd8wbMLi4oVutmqgzEvccmAslhPnzXEEsNKbhE/ZeI27R0f0CYecxYSlYgrQnYTLvzMPeOiuq85NzYyygO1T/DRy/rDlYKdVq86Pq83OhOwOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710147532; c=relaxed/simple; bh=uIYem1WXZzLeY24d0KPKig4Iq9ugwXSAUFZYuajJkic=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MS4S4Ez7DVWNmGvg7/FxqzyGr3vXPrga77niMwqHDuXzgSVbHuTadgp5MfkDIpOk0Tl7/WJ4+mtiFYKKtY1iXEI+Cnl3XGEoXxlhLb0Qg4qmQIqpe+82L/yZ7JG9HqJISJRZ200RdAfzpxaRi9luWiyAGgwIWp02nj/QSdWLH78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=H5W5gdBz; arc=none smtp.client-ip=91.218.175.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="H5W5gdBz" 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=1710147529; 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=4b98mQ6/x2oKxbObSJohHOWilmFrNjMixYwuxRZhnBI=; b=H5W5gdBzclG7JRWEXS3Qd7t87sa1RvPbJpMA4lC5CaIbf4KeVaTIEaqi1lI+z7RUwzM4CH sZkJ/4Z6PWcCGgsMCrE/ePEGWLRyzO1LOMXRDVRPLU5Kog9VZyNK0pNFXY9RkE20n5myrJ haXbdXiLI0HtZ9DTuSWbQKAUrxQjkaA= From: Sui Jingfeng To: Andrzej Hajda Cc: Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Phong LE , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v3 5/5] drm-bridge: sii902x: Use fwnode API to acquire device properties Date: Mon, 11 Mar 2024 16:56:59 +0800 Message-Id: <20240311085659.244043-6-sui.jingfeng@linux.dev> In-Reply-To: <20240311085659.244043-1-sui.jingfeng@linux.dev> References: <20240311085659.244043-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Make this driver less DT-dependent by calling the freshly created helpers and other manually improve. Should be no functional changes for DT based systems, but do helps to reduce boilerplate. 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/sii9= 02x.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 *s= ii902x, .spdif =3D 0, .max_i2s_channels =3D 0, }; + struct fwnode_handle *fwnode =3D dev_fwnode(dev); u8 lanes[4]; int num_lanes, i; =20 - 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; } =20 - num_lanes =3D of_property_read_variable_u8_array(dev->of_node, - "sil,i2s-data-lanes", - lanes, 1, - ARRAY_SIZE(lanes)); - + num_lanes =3D fwnode_property_read_u8_array(fwnode, + "sil,i2s-data-lanes", + lanes, ARRAY_SIZE(lanes)); if (num_lanes =3D=3D -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; =20 sii902x->bridge.funcs =3D &sii902x_bridge_funcs; - sii902x->bridge.of_node =3D dev->of_node; sii902x->bridge.timings =3D &default_sii902x_timings; sii902x->bridge.ops =3D DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID; =20 if (sii902x->i2c->irq > 0) sii902x->bridge.ops |=3D DRM_BRIDGE_OP_HPD; =20 + drm_bridge_set_node(&sii902x->bridge, dev_fwnode(dev)); drm_bridge_add(&sii902x->bridge); =20 return 0; @@ -1118,7 +1117,6 @@ static int sii902x_init(struct sii902x *sii902x) static int sii902x_probe(struct i2c_client *client) { struct device *dev =3D &client->dev; - struct device_node *endpoint; struct sii902x *sii902x; static const char * const supplies[] =3D {"iovcc", "cvcc12"}; int ret; @@ -1147,27 +1145,14 @@ static int sii902x_probe(struct i2c_client *client) return PTR_ERR(sii902x->reset_gpio); } =20 - endpoint =3D of_graph_get_endpoint_by_regs(dev->of_node, 1, -1); - if (endpoint) { - struct device_node *remote =3D 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 =3D 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 =3D 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 =3D PTR_ERR(sii902x->next_bridge); + dev_err(dev, "Error on find the next bridge: %d\n", ret); + return ret; } =20 mutex_init(&sii902x->mutex); --=20 2.34.1