From patchwork Mon Jan 22 16:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13525759 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 E9532C47DD9 for ; Mon, 22 Jan 2024 16:33:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 199F510F5ED; Mon, 22 Jan 2024 16:33:04 +0000 (UTC) Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5221810F5ED for ; Mon, 22 Jan 2024 16:33:02 +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=1705941150; 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=/ZyqSCinvSiL4fDcqtQAts8Vz4wSQZ3zHH00t6lYeGc=; b=TfmmHLC0CAWOqzvzLqf1L/MTDspqvJzrDKRUwwMzj7inwa16XjnR2Tc2kGpy8/XOtAxC5y FZ/z5XqynfDN2uwB1h9t1103vC4umTIdhWDG2mMkQerFy1k2CqdwtFg5La3Azbyq64MW9l 5EUs+pR2o4Mq+U2jhmcAvoamKOVYCRY= From: Sui Jingfeng To: David Airlie Subject: [PATCH 1/5] drm/bridge: Add drm_bridge_find_by_fwnode() helper Date: Tue, 23 Jan 2024 00:32:16 +0800 Message-Id: <20240122163220.110788-2-sui.jingfeng@linux.dev> In-Reply-To: <20240122163220.110788-1-sui.jingfeng@linux.dev> References: <20240122163220.110788-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: , Cc: Neil Armstrong , Sui Jingfeng , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Ripard , Daniel Vetter , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Because ACPI based systems only has the fwnode associated, the of_node member of struct device is NULL. To order to move things forward, we add drm_bridge_find_by_fwnode() to extend the support. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/drm_bridge.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index cee3188adf3d..ffd969adc2fb 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -1347,6 +1347,39 @@ 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 associated fwnode + * + * @fwnode: fwnode for which to find the matching drm_bridge + * + * This function looks up a drm_bridge based on its associated fwnode. + * + * RETURNS: + * A reference to the drm_bridge control structure if found, NULL on failure. + */ +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(drm_bridge_find_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 e39da5807ba7..fe3d5f4bf37f 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -720,6 +720,8 @@ struct drm_bridge { struct list_head chain_node; /** @of_node: device node pointer to the bridge */ struct device_node *of_node; + /** @fwnode: associated fwnode supplied by platform firmware */ + struct fwnode_handle *fwnode; /** @list: to keep track of all added bridges */ struct list_head list; /** @@ -796,6 +798,8 @@ 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); + /** * drm_bridge_get_next_bridge() - Get the next bridge in the chain * @bridge: bridge object From patchwork Mon Jan 22 16:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13525760 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 52267C47DD9 for ; Mon, 22 Jan 2024 16:33:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C318610F5F3; Mon, 22 Jan 2024 16:33:08 +0000 (UTC) Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) by gabe.freedesktop.org (Postfix) with ESMTPS id E116910F5F3 for ; Mon, 22 Jan 2024 16:33:05 +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=1705941154; 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=zOQVFSKw3j/viuJ1r9uwPrf0VlEptyybu7p5hJGtU4I=; b=L7/FAapq5/GA78moIR9tbDqaLl+KwawdazCvL79VK9uJYNJjZeHurgVE3jowYQvTiIOyFV GSBgDlmh2QUmpkYssS3+2mBzDVU7Ns2GYjvfvVs9cAaa+EBtpknfHqgWfkkT9sBJFoXNEz wcaIH5I6UVRBIFL9gZo/ycf5uHSXYKw= From: Sui Jingfeng To: David Airlie Subject: [PATCH 2/5] drm/bridge: simple-bridge: Extend match support for non-DT based systems Date: Tue, 23 Jan 2024 00:32:17 +0800 Message-Id: <20240122163220.110788-3-sui.jingfeng@linux.dev> In-Reply-To: <20240122163220.110788-1-sui.jingfeng@linux.dev> References: <20240122163220.110788-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: , Cc: Neil Armstrong , Sui Jingfeng , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Ripard , Daniel Vetter , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Which is intended to be used on non-DT environment, where the simple-bridge platform device is created by either the display controller driver side or platform firmware subsystem. To avoid duplication and to keep consistent, we choose to reuse the OF match tables. Because the potentional user may not has a of_node attached, nor a ACPI match id. If this is the case, a software node string property can be provide to fill the niche. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/simple-bridge.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index cbe8e778d7c7..595f672745b9 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -166,6 +166,24 @@ static const struct drm_bridge_funcs simple_bridge_bridge_funcs = { .disable = simple_bridge_disable, }; +static const void *simple_bridge_get_match_data(const struct device *dev) +{ + const struct of_device_id *matches = dev->driver->of_match_table; + + /* Try to get the match data by software node */ + while (matches) { + if (!matches->compatible[0]) + break; + + if (device_is_compatible(dev, matches->compatible)) + return matches->data; + + matches++; + } + + return NULL; +} + static int simple_bridge_probe(struct platform_device *pdev) { struct simple_bridge *sbridge; @@ -176,7 +194,10 @@ static int simple_bridge_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, sbridge); - sbridge->info = of_device_get_match_data(&pdev->dev); + if (pdev->dev.of_node) + sbridge->info = of_device_get_match_data(&pdev->dev); + else + sbridge->info = simple_bridge_get_match_data(&pdev->dev); /* Get the next bridge in the pipeline. */ remote = of_graph_get_remote_node(pdev->dev.of_node, 1, -1); @@ -309,3 +330,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 Jan 22 16:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13525761 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 8DEC5C47DD9 for ; Mon, 22 Jan 2024 16:33:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CAAE810F5FB; Mon, 22 Jan 2024 16:33:12 +0000 (UTC) Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id C2B4C10F5F4 for ; Mon, 22 Jan 2024 16:33:10 +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=1705941157; 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=npqubJ7Bj7Hp+PXoNaKT0QhmaM+1u+5VldbVzcNqcKI=; b=hRUoIKsMG7O90bNfo9wUm9cKlyUIAfVjI4dIh3/xy6G+8thfA1pGQs/f/I5Oi++EeXrUn9 0XAc430aKgJPelbVcykvQoJGZFSURld61Ju7l2nauidb8/x/9f3JpOpcrLltpKuC7wjU7K tmZ7Z3BqE4EdU1baTkmqgktMCMufG78= From: Sui Jingfeng To: David Airlie Subject: [PATCH 3/5] drm/bridge: simple-bridge: Allow acquiring the next bridge with fwnode API Date: Tue, 23 Jan 2024 00:32:18 +0800 Message-Id: <20240122163220.110788-4-sui.jingfeng@linux.dev> In-Reply-To: <20240122163220.110788-1-sui.jingfeng@linux.dev> References: <20240122163220.110788-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: , Cc: Neil Armstrong , Sui Jingfeng , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Ripard , Daniel Vetter , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Which make it possible to use this driver on non-DT based systems, meanwhile, made no functional changes for DT based systems. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/simple-bridge.c | 51 ++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c index 595f672745b9..cfea5a67cc5b 100644 --- a/drivers/gpu/drm/bridge/simple-bridge.c +++ b/drivers/gpu/drm/bridge/simple-bridge.c @@ -184,6 +184,39 @@ static const void *simple_bridge_get_match_data(const struct device *dev) return NULL; } +static int simple_bridge_get_next_bridge_by_fwnode(struct device *dev, + struct drm_bridge **next_bridge) +{ + struct drm_bridge *bridge; + struct fwnode_handle *ep; + struct fwnode_handle *remote; + + ep = fwnode_graph_get_endpoint_by_id(dev->fwnode, 1, 0, 0); + if (!ep) { + dev_err(dev, "The endpoint is unconnected\n"); + return -EINVAL; + } + + remote = fwnode_graph_get_remote_port_parent(ep); + fwnode_handle_put(ep); + if (!remote) { + dev_err(dev, "No valid remote node\n"); + return -ENODEV; + } + + bridge = drm_bridge_find_by_fwnode(remote); + fwnode_handle_put(remote); + + if (!bridge) { + dev_warn(dev, "Next bridge not found, deferring probe\n"); + return -EPROBE_DEFER; + } + + *next_bridge = bridge; + + return 0; +} + static int simple_bridge_probe(struct platform_device *pdev) { struct simple_bridge *sbridge; @@ -199,14 +232,17 @@ static int simple_bridge_probe(struct platform_device *pdev) else sbridge->info = simple_bridge_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); + if (pdev->dev.of_node) { + /* 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); + } else { + simple_bridge_get_next_bridge_by_fwnode(&pdev->dev, &sbridge->next_bridge); + } if (!sbridge->next_bridge) { dev_dbg(&pdev->dev, "Next bridge not found, deferring probe\n"); return -EPROBE_DEFER; @@ -231,6 +267,7 @@ 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.fwnode = pdev->dev.fwnode; sbridge->bridge.timings = sbridge->info->timings; drm_bridge_add(&sbridge->bridge); From patchwork Mon Jan 22 16:32:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13525757 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 27A76C47DD9 for ; Mon, 22 Jan 2024 16:32:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F09110F5E5; Mon, 22 Jan 2024 16:32:43 +0000 (UTC) Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E2BC10F5E5 for ; Mon, 22 Jan 2024 16:32: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=1705941160; 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=odkYqjzTWVuL5bWOI6DRA1l4DPeGSEAeS9hiMNWXJJ8=; b=GiDxdmtZc1x5dCXVgT4BFw0UWGv7oQkINHwu127uWmaaETnWhpHHIo/Eptolf70gx4Q5RO LKYUO4oHXqhhIEyDvp5Ob2qSK31ThTj/vkp/36T1hretTg9MPqV44tjB4m+J3+kuQnO90l /rbZEF7Yv5M4j9YPHUN4tOY5tj0RrlY= From: Sui Jingfeng To: David Airlie Subject: [PATCH 4/5] drm/bridge: display-connector: Extend match support for non-DT based systems Date: Tue, 23 Jan 2024 00:32:19 +0800 Message-Id: <20240122163220.110788-5-sui.jingfeng@linux.dev> In-Reply-To: <20240122163220.110788-1-sui.jingfeng@linux.dev> References: <20240122163220.110788-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: , Cc: Neil Armstrong , Sui Jingfeng , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Ripard , Daniel Vetter , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On which case the driver is not probed by OF, Instead, a fwnode is associated to the platform device before this driver is probed. The newly added code is intended to be used on non-DT environment. It is assumed that there is a string fwnode property associated with the platform device, the name of the string property is compatible, the value of the string property is used to get platform match data. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/display-connector.c | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c index 08bd5695ddae..eb7e194e7735 100644 --- a/drivers/gpu/drm/bridge/display-connector.c +++ b/drivers/gpu/drm/bridge/display-connector.c @@ -202,6 +202,24 @@ static int display_connector_get_supply(struct platform_device *pdev, return PTR_ERR_OR_ZERO(conn->supply); } +static const void *display_connector_get_match_data(const struct device *dev) +{ + const struct of_device_id *matches = dev->driver->of_match_table; + + /* Try to get the match data by software node */ + while (matches) { + if (!matches->compatible[0]) + break; + + if (device_is_compatible(dev, matches->compatible)) + return matches->data; + + matches++; + } + + return NULL; +} + static int display_connector_probe(struct platform_device *pdev) { struct display_connector *conn; @@ -215,7 +233,10 @@ static int display_connector_probe(struct platform_device *pdev) platform_set_drvdata(pdev, conn); - type = (uintptr_t)of_device_get_match_data(&pdev->dev); + if (pdev->dev.of_node) + type = (uintptr_t)of_device_get_match_data(&pdev->dev); + else + type = (uintptr_t)display_connector_get_match_data(&pdev->dev); /* Get the exact connector type. */ switch (type) { @@ -434,3 +455,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 Jan 22 16:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13525758 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 8EE18C47DAF for ; Mon, 22 Jan 2024 16:32:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD16410F5EA; Mon, 22 Jan 2024 16:32:54 +0000 (UTC) Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5FD9B10F5ED for ; Mon, 22 Jan 2024 16:32:45 +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=1705941163; 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=SaW0Gpay7iBfH7QtKRfcxFikX4DDF/x/sLLBI1Dwvao=; b=IfhvQlpGNlQH5yBLfh+N0DpfnsOJwHsPBE+HPFPkGI36lhsRVKljNc2gz732ufGYS1a8N/ Cp1np5uq5zTMjfcXhxUR5Q8HOnYcgFSem8OOOG6jd0ad3tj35dzAL+Lrj1rEARoUqnLRPB dcCzHGrWbN+29ww2QrD4poINOgtdrAI= From: Sui Jingfeng To: David Airlie Subject: [PATCH 5/5] drm-bridge: display-connector: Switch to use fwnode API Date: Tue, 23 Jan 2024 00:32:20 +0800 Message-Id: <20240122163220.110788-6-sui.jingfeng@linux.dev> In-Reply-To: <20240122163220.110788-1-sui.jingfeng@linux.dev> References: <20240122163220.110788-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: , Cc: Neil Armstrong , Sui Jingfeng , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Maxime Ripard , Daniel Vetter , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sui Jingfeng Because API has wider coverage, it can be used on non-DT systems as well. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/display-connector.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c index eb7e194e7735..2c3e54a458e8 100644 --- a/drivers/gpu/drm/bridge/display-connector.c +++ b/drivers/gpu/drm/bridge/display-connector.c @@ -243,8 +243,8 @@ static int display_connector_probe(struct platform_device *pdev) 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(pdev->dev.fwnode, "analog"); + digital = fwnode_property_present(pdev->dev.fwnode, "digital"); if (analog && !digital) { conn->bridge.type = DRM_MODE_CONNECTOR_DVIA; } else if (!analog && digital) { @@ -261,8 +261,8 @@ 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(pdev->dev.fwnode, "type", + &hdmi_type); if (ret < 0) { dev_err(&pdev->dev, "HDMI connector with no type\n"); return -EINVAL; @@ -292,7 +292,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(pdev->dev.fwnode, "label", &label); /* * Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can provide @@ -330,12 +330,13 @@ 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 *fwnode; - 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); + fwnode = fwnode_find_reference(pdev->dev.fwnode, "ddc-i2c-bus", 0); + if (!IS_ERR_OR_NULL(fwnode)) { + dev_info(&pdev->dev, "has I2C bus property\n"); + conn->bridge.ddc = i2c_get_adapter_by_fwnode(fwnode); + fwnode_handle_put(fwnode); if (!conn->bridge.ddc) return -EPROBE_DEFER; } else { @@ -380,6 +381,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; + conn->bridge.fwnode = pdev->dev.fwnode; if (conn->bridge.ddc) conn->bridge.ops |= DRM_BRIDGE_OP_EDID