From patchwork Thu May 19 11:26:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854806 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 826D6C433F5 for ; Thu, 19 May 2022 11:27:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D140911A291; Thu, 19 May 2022 11:27:09 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2EE8E11A283 for ; Thu, 19 May 2022 11:27:08 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id D71AE83C01; Thu, 19 May 2022 13:27:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959626; bh=3Bg9b8ZoSbkKtq9P3SC7QvBO7phzcdHyJf2WdSpmqCE=; h=From:To:Cc:Subject:Date:From; b=QzJdFq41Oo0TzOuZH/6finJn1TojWaEqujpjkk8ciFPFlhlSp0V1j2z3EtVXk9e/O U6NGLIWja5CRfJelvYTlXRCXt064OhA8nVyoIHcgp7zq1z4LyFqIXV3ycWe/6c48ZN tScx/dvMcQ05OWWfC23JwvOnVf9yCwdRVzRKZlVWW/27U1Iaho73jbXmFFMad8mJaj ZR+1cg4uozTETR2OdIa/krBLwPE66U7b+H5UvPvn+f72soq/iRgLiGfHI72SKRlvtY 5GTeEuye4fwZwJcif7JdBsCFXYObmkrcgJzf9VblwFlQ1SOOBL9dmGHIP9OyyICMaK EP1j5YPpC+t1w== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 01/11] drm: of: Add drm_of_get_data_lanes and drm_of_get_data_lanes_ep Date: Thu, 19 May 2022 13:26:47 +0200 Message-Id: <20220519112657.62283-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , robert.foss@linaro.org, Maxime Ripard , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add helper function to count and sanitize DT "data-lanes" property and return either error or the data-lanes count. This is useful for both DSI and (e)DP "data-lanes" property. The later version of the function is an extra wrapper which handles the endpoint look up by regs, that's what majority of the drivers duplicate too, but not all of them. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/drm_of.c | 61 ++++++++++++++++++++++++++++++++++++++++ include/drm/drm_of.h | 20 +++++++++++++ 2 files changed, 81 insertions(+) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 9a2cfab3a177f..2186f966d2820 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -430,3 +430,64 @@ int drm_of_lvds_get_data_mapping(const struct device_node *port) return -EINVAL; } EXPORT_SYMBOL_GPL(drm_of_lvds_get_data_mapping); + +/** + * drm_of_get_data_lanes - Get DSI/(e)DP data lane count + * @endpoint: DT endpoint node of the DSI/(e)DP source or sink + * @min: minimum supported number of data lanes + * @max: maximum supported number of data lanes + * + * Count DT "data-lanes" property elements and check for validity. + * + * Return: + * * min..max - positive integer count of "data-lanes" elements + * * -ve - the "data-lanes" property is missing or invalid + * * -EINVAL - the "data-lanes" property is unsupported + */ +int drm_of_get_data_lanes(const struct device_node *endpoint, + const unsigned int min, const unsigned int max) +{ + int ret; + + ret = of_property_count_u32_elems(endpoint, "data-lanes"); + if (ret < 0) + return ret; + + if (ret < min || ret > max) + return -EINVAL; + + return ret; +} +EXPORT_SYMBOL_GPL(drm_of_get_data_lanes); + +/** + * drm_of_get_data_lanes_ep - Get DSI/(e)DP data lane count by endpoint + * @port: DT port node of the DSI/(e)DP source or sink + * @port_reg: identifier (value of reg property) of the parent port node + * @reg: identifier (value of reg property) of the endpoint node + * @min: minimum supported number of data lanes + * @max: maximum supported number of data lanes + * + * Count DT "data-lanes" property elements and check for validity. + * This variant uses endpoint specifier. + * + * Return: + * * min..max - positive integer count of "data-lanes" elements + * * -EINVAL - the "data-mapping" property is unsupported + * * -ENODEV - the "data-mapping" property is missing + */ +int drm_of_get_data_lanes_ep(const struct device_node *port, + int port_reg, int reg, + const unsigned int min, + const unsigned int max) +{ + struct device_node *endpoint; + int ret; + + endpoint = of_graph_get_endpoint_by_regs(port, port_reg, reg); + ret = drm_of_get_data_lanes(endpoint, min, max); + of_node_put(endpoint); + + return ret; +} +EXPORT_SYMBOL_GPL(drm_of_get_data_lanes_ep); diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h index 99f79ac8b4cd7..b559c53756196 100644 --- a/include/drm/drm_of.h +++ b/include/drm/drm_of.h @@ -50,6 +50,12 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, const struct device_node *port2); int drm_of_lvds_get_data_mapping(const struct device_node *port); +int drm_of_get_data_lanes(const struct device_node *endpoint, + const unsigned int min, const unsigned int max); +int drm_of_get_data_lanes_ep(const struct device_node *port, + int port_reg, int reg, + const unsigned int min, + const unsigned int max); #else static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev, struct device_node *port) @@ -105,6 +111,20 @@ drm_of_lvds_get_data_mapping(const struct device_node *port) { return -EINVAL; } + +int drm_of_get_data_lanes(const struct device_node *endpoint, + const unsigned int min, const unsigned int max) +{ + return -EINVAL; +} + +int drm_of_get_data_lanes_ep(const struct device_node *port, + int port_reg, int reg + const unsigned int min, + const unsigned int max) +{ + return -EINVAL; +} #endif /* From patchwork Thu May 19 11:26:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854807 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 460B5C433EF for ; Thu, 19 May 2022 11:27:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 03E3111A331; Thu, 19 May 2022 11:27:10 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id E80B511A283 for ; Thu, 19 May 2022 11:27:08 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 5DB5083C1B; Thu, 19 May 2022 13:27:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959626; bh=V1gTv+g9kFa2k3syybq6/EM/VEtVZBqG7UIaR3WR8gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kIOyg4l6EkX5NW+gOCfOYeG4W5w4TACpckkG815zpC618NhDe+EQhwkgGo1SNclV3 zRMqlJ3fneXOWNTtx5KS9BbUOIGmSs0Ad0DiThzZxQDFe2PtDl0t3Jn6X1QPDvfdMF RNZ/inA+QDqPSRH1EW1NA6pnAKBA1l7JasvLPYE7KdKHkmVIziIb2uyBThGBCQkhA0 fkAFyXzoff1tPbhl5WCTRAf2jhQY2zyzSWUxGz3msUKbFcsE/XqsHTf5AxcHjkWZuO k9ZfyXbnje4Hh296cqu6F+HrjQQaqNhXcOBFmrHgI6pOyx0a5PwDb0n7xd506XbDrQ +J4RsfX2oYIiQ== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 02/11] drm/bridge: anx7625: Convert to drm_of_get_data_lanes Date: Thu, 19 May 2022 13:26:48 +0200 Message-Id: <20220519112657.62283-2-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , robert.foss@linaro.org, Maxime Ripard , Andrzej Hajda , Sam Ravnborg , Xin Ji Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg Cc: Xin Ji To: dri-devel@lists.freedesktop.org Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/bridge/analogix/anx7625.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index e92eb4a407452..87d7658b92fac 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -1637,16 +1637,16 @@ static int anx7625_parse_dt(struct device *dev, if (of_property_read_u32(ep0, "bus-type", &bus_type)) bus_type = 0; - mipi_lanes = of_property_count_u32_elems(ep0, "data-lanes"); + mipi_lanes = drm_of_get_data_lanes(ep0, 1, MAX_LANES_SUPPORT); of_node_put(ep0); } if (bus_type == V4L2_FWNODE_BUS_TYPE_PARALLEL) /* bus type is Parallel(DSI) */ pdata->is_dpi = 0; - pdata->mipi_lanes = mipi_lanes; - if (pdata->mipi_lanes > MAX_LANES_SUPPORT || pdata->mipi_lanes <= 0) - pdata->mipi_lanes = MAX_LANES_SUPPORT; + pdata->mipi_lanes = MAX_LANES_SUPPORT; + if (mipi_lanes > 0) + pdata->mipi_lanes = mipi_lanes; if (pdata->is_dpi) DRM_DEV_DEBUG_DRIVER(dev, "found MIPI DPI host node.\n"); From patchwork Thu May 19 11:26:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854808 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 6C3D2C433EF for ; Thu, 19 May 2022 11:27:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57E6711A33C; Thu, 19 May 2022 11:27:10 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7489111A283 for ; Thu, 19 May 2022 11:27:09 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 00F4F83C7B; Thu, 19 May 2022 13:27:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959627; bh=DWSU91R10B1RP+xTZSNZxfwmeVVDyY97geMVkqQDEqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gmvEHsb6Mvkmds/Ih+UuE2xCKmjSZBgtwC2NLQ0SJ+kgchfZjbmYlbKwQ9m7/9Ja1 JnlNBdb8eEjWggGuqSzUHHtGW7OLZHnfON9Y89mttq7QIW/ayLZuEnaJJ7pasdTXk+ ECiVt/DMHIJLm7i7quDlsdJEiwdL0sldCGRrtnbyCdpS0eYE7XkWZW8vlNXbnNMgnN aZbUDfpiButebXicpy9LNmEVH7+LgEc7FCQEnlSTICaow8Rn/eoY9uo530XOzr6zJC 7Q/7rSAh2lhkXa8OUCk71BLgHP8FyiwafTpXT9RlZB7z4BwJ1dzDZb1AxoWqaGiY22 pJ6QsbchZUVhw== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 03/11] drm/bridge: icn6211: Convert to drm_of_get_data_lanes_ep Date: Thu, 19 May 2022 13:26:49 +0200 Message-Id: <20220519112657.62283-3-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Jagan Teki , Maxime Ripard , robert.foss@linaro.org, Laurent Pinchart , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Jagan Teki Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org Reviewed-by: Andrzej Hajda --- drivers/gpu/drm/bridge/chipone-icn6211.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/chipone-icn6211.c b/drivers/gpu/drm/bridge/chipone-icn6211.c index 45bb89ac3fff7..e53a19f721c8c 100644 --- a/drivers/gpu/drm/bridge/chipone-icn6211.c +++ b/drivers/gpu/drm/bridge/chipone-icn6211.c @@ -496,21 +496,18 @@ static int chipone_dsi_attach(struct chipone *icn) { struct mipi_dsi_device *dsi = icn->dsi; struct device *dev = icn->dev; - struct device_node *endpoint; int dsi_lanes, ret; - endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); - dsi_lanes = of_property_count_u32_elems(endpoint, "data-lanes"); - of_node_put(endpoint); + dsi_lanes = drm_of_get_data_lanes_ep(dev->of_node, 0, 0, 1, 4); /* * If the 'data-lanes' property does not exist in DT or is invalid, * default to previously hard-coded behavior, which was 4 data lanes. */ - if (dsi_lanes >= 1 && dsi_lanes <= 4) - icn->dsi->lanes = dsi_lanes; - else + if (dsi_lanes < 0) icn->dsi->lanes = 4; + else + icn->dsi->lanes = dsi_lanes; dsi->format = MIPI_DSI_FMT_RGB888; dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | From patchwork Thu May 19 11:26:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854814 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 E01D8C433F5 for ; Thu, 19 May 2022 11:27:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CCDB11A34B; Thu, 19 May 2022 11:27:17 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD7C811A283 for ; Thu, 19 May 2022 11:27:09 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 9CDBF83C97; Thu, 19 May 2022 13:27:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959628; bh=++IJTNNCnsQ0qwjSQ0d7+hNbdYUsh2L57IXb8YqDLi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3Zop510qMxDDy9nboHkzYIuokKzMhAZT3WK/z0JW9PbZn89jM85JniYrFkK9eydO 28tph1L74+l22y57ykBQTnvuS1gFV+FIXvjbPzCJjVwyADjRoVWNynjbbkz4Fq2UF5 bg+TaU0LjskS5Ko/rFqH3EzYyWGfWrE/7l4SIriTDLye5wh+v7DzuEf4vwqxZWpeP8 DnF83dvtYIy9d5BCxgd35HvzDw1r5enD/8kszmXMANOjzl5K1Uzk6eSvVRJm2e3m/7 e4BHx2pgL7gfqYo9mphJ8dfYgj3ZwLE2rAWi89inWADM9vd/Me4rJrnQa0T5K4kIqM ZzWyPkKv9TQ6Q== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 04/11] drm/bridge: lt8912: Convert to drm_of_get_data_lanes_ep Date: Thu, 19 May 2022 13:26:50 +0200 Message-Id: <20220519112657.62283-4-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , Maxime Ripard , robert.foss@linaro.org, Adrien Grassein , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Adrien Grassein Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/bridge/lontium-lt8912b.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c index c642d1e02b2f8..b9741de70d584 100644 --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c @@ -607,7 +607,6 @@ static int lt8912_parse_dt(struct lt8912 *lt) int ret; int data_lanes; struct device_node *port_node; - struct device_node *endpoint; gp_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(gp_reset)) { @@ -618,16 +617,12 @@ static int lt8912_parse_dt(struct lt8912 *lt) } lt->gp_reset = gp_reset; - endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); - if (!endpoint) - return -ENODEV; - - data_lanes = of_property_count_u32_elems(endpoint, "data-lanes"); - of_node_put(endpoint); + data_lanes = drm_of_get_data_lanes_ep(dev->of_node, 0, -1, 1, 4); if (data_lanes < 0) { dev_err(lt->dev, "%s: Bad data-lanes property\n", __func__); return data_lanes; } + lt->data_lanes = data_lanes; lt->host_node = of_graph_get_remote_node(dev->of_node, 0, -1); From patchwork Thu May 19 11:26:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854816 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 43225C433F5 for ; Thu, 19 May 2022 11:27:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E5B711A35D; Thu, 19 May 2022 11:27:34 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by gabe.freedesktop.org (Postfix) with ESMTPS id 46B2411A283 for ; Thu, 19 May 2022 11:27:10 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 2C62383D0C; Thu, 19 May 2022 13:27:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959628; bh=JH0JqYAAvBj77uUDCjnRNg1Ewf96jtsBIaT2o4x+hoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y7BFLDOQWmTEivbF54PPxAxhtwgIIbZYCBm1SAgJZjqdCgJzpuXMYkBLD2umcx+1I nwX/s6bK9IPCay4KPk3Zjn/lQVl2qHha8Uj8466IliCIFN4QQ4YgNoZJY7k0oHKh8A 0N/I3QRNtBAyxVMdjfyW/F6Bb619kX3bD6QTIyi3O8kJMRxQ/ZzswcpUUg1004rzow xkO0HLnlaZA1nOXpnkA53XSt49AUjMksxsm0GZ7rgKUvWYPFwO5l9fJaUQVhWNv1Mt z0FwWU7VKgTywwyuvDhTuzCb/WSbmLbLDL0WMfnfrN3WpiDXSASgu+iocMUBv1HUKL ZvwEVY11KiVIg== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 05/11] drm/bridge: lt9211: Convert to drm_of_get_data_lanes Date: Thu, 19 May 2022 13:26:51 +0200 Message-Id: <20220519112657.62283-5-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , robert.foss@linaro.org, Maxime Ripard , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/bridge/lontium-lt9211.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9211.c b/drivers/gpu/drm/bridge/lontium-lt9211.c index e92821fbc6393..3e158689f6696 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9211.c +++ b/drivers/gpu/drm/bridge/lontium-lt9211.c @@ -686,7 +686,7 @@ static int lt9211_host_attach(struct lt9211 *ctx) int ret; endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); - dsi_lanes = of_property_count_u32_elems(endpoint, "data-lanes"); + dsi_lanes = drm_of_get_data_lanes(endpoint, 1, 4); host_node = of_graph_get_remote_port_parent(endpoint); host = of_find_mipi_dsi_host_by_node(host_node); of_node_put(host_node); @@ -695,8 +695,8 @@ static int lt9211_host_attach(struct lt9211 *ctx) if (!host) return -EPROBE_DEFER; - if (dsi_lanes < 0 || dsi_lanes > 4) - return -EINVAL; + if (dsi_lanes < 0) + return dsi_lanes; dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) From patchwork Thu May 19 11:26:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854809 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 96B35C433F5 for ; Thu, 19 May 2022 11:27:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EE9411A283; Thu, 19 May 2022 11:27:16 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6AEF11A283 for ; Thu, 19 May 2022 11:27:10 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id B96A383D53; Thu, 19 May 2022 13:27:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959629; bh=QmZEk+g5izPHKUiLkPMFE+Qjakox6HY6gop9qLxzp08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GaQhfAIpWmnKR0zzi4Q44OlTU/Ts67jST8+0Y8XDT9KNDrDVLsRROJiSCg+6T45Ky K6ioPekdU0GaH+5yW6GlL5fY0c6zUSt/rowmkWa6ihBfjPpwYhglTBlEVC09IxZjQi VITV0khP0iEWNpayoDxDSqnSelLMMMW/Duee0swPQ1Mn8yk3mbnmGi7O4VREiiTiSt 1/deEWzj0yQhSOBmsR5GWYsp51jpXkCJi+/CJ7SMnGNCUsBD6BvPqxIWBb9MkGoSxB sbRR61ymD3r7wmKBtJSFpQ4lps7OS/zdpuo6IUvwBSJwC9rvxTrlFeZPpxnv5cd0dP USGqlFljbURqg== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 06/11] drm/bridge: tc358767: Convert to drm_of_get_data_lanes Date: Thu, 19 May 2022 13:26:52 +0200 Message-Id: <20220519112657.62283-6-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , robert.foss@linaro.org, Maxime Ripard , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/bridge/tc358767.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 8e210b1176906..a6990a8c08a8b 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -1892,18 +1892,18 @@ static int tc_mipi_dsi_host_attach(struct tc_data *tc) int dsi_lanes, ret; endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); - dsi_lanes = of_property_count_u32_elems(endpoint, "data-lanes"); + dsi_lanes = drm_of_get_data_lanes(endpoint, 1, 4); host_node = of_graph_get_remote_port_parent(endpoint); host = of_find_mipi_dsi_host_by_node(host_node); of_node_put(host_node); of_node_put(endpoint); - if (dsi_lanes <= 0 || dsi_lanes > 4) - return -EINVAL; - if (!host) return -EPROBE_DEFER; + if (dsi_lanes < 0) + return dsi_lanes; + dsi = mipi_dsi_device_register_full(host, &info); if (IS_ERR(dsi)) return dev_err_probe(dev, PTR_ERR(dsi), From patchwork Thu May 19 11:26:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854811 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 A4341C433F5 for ; Thu, 19 May 2022 11:27:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48C3E11A355; Thu, 19 May 2022 11:27:17 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F2FA11A337 for ; Thu, 19 May 2022 11:27:11 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 5423983D5D; Thu, 19 May 2022 13:27:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959629; bh=0YmsD8CVoRaRzsIvnI9IMKF0twe9PsS20X1VB5h+72s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xdyHyl489t+ThEP90ZZ4A7K4xRngViKZwiMl+DCWnRXgZEuS6PnVRVToz4+kj/j64 EeHsxvaNz23EhLeDODmlaNIY1OHD3Fm8+oGTDgKHERYMPwbsZiPY9yz0iZX22iMFib rG9m6hufZFLT3LGi8hBZDg/iFjvTD32bzO+Ix7dUol3En5Et+LkxVOG9POkEjEW9UH iDCA2mqR3N2SpHIUnBOC3tjv30InD9PbmuPzbc1N/fa97twXaAz3g99tNDp08YnhSF k7g1tHRdGElVsGtHK4yFTF5Whse1nYMb8fAHadLLDnAX5ojsDYHja46iO/NyOnHjdz vs3CmnzCAneQw== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 07/11] drm/bridge: tc358775: Convert to drm_of_get_data_lanes_ep Date: Thu, 19 May 2022 13:26:53 +0200 Message-Id: <20220519112657.62283-7-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , robert.foss@linaro.org, Maxime Ripard , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/bridge/tc358775.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c index 62a7ef352daa5..7abb8ae3df2ff 100644 --- a/drivers/gpu/drm/bridge/tc358775.c +++ b/drivers/gpu/drm/bridge/tc358775.c @@ -530,7 +530,7 @@ static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc) struct device_node *parent; struct device_node *remote; struct property *prop; - int len = 0; + int dsi_lanes, len = 0; /* * To get the data-lanes of dsi, we need to access the dsi0_out of port1 @@ -544,25 +544,15 @@ static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc) of_node_put(endpoint); if (parent) { /* dsi0 port 1 */ - endpoint = of_graph_get_endpoint_by_regs(parent, 1, -1); + dsi_lanes = drm_of_get_data_lanes_ep(parent, 1, -1, 1, 4); of_node_put(parent); - if (endpoint) { - prop = of_find_property(endpoint, "data-lanes", - &len); - of_node_put(endpoint); - if (!prop) { - dev_err(tc->dev, - "failed to find data lane\n"); - return -EPROBE_DEFER; - } - } } } - tc->num_dsi_lanes = len / sizeof(u32); + if (dsi_lanes < 0) + return dsi_lanes; - if (tc->num_dsi_lanes < 1 || tc->num_dsi_lanes > 4) - return -EINVAL; + tc->num_dsi_lanes = dsi_lanes; tc->host_node = of_graph_get_remote_node(np, 0, 0); if (!tc->host_node) From patchwork Thu May 19 11:26:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854813 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 663D3C433FE for ; Thu, 19 May 2022 11:27:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 32E3811A353; Thu, 19 May 2022 11:27:18 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7F8FD11A283 for ; Thu, 19 May 2022 11:27:11 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id DB7C583D7E; Thu, 19 May 2022 13:27:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959630; bh=i0PRdJ8XNIAyTnFCrLSfM4cYGVe5Gqur9PWvKa1raPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HNWFu8IfeYJmMRZPhrsWdDZ5QzufzJbQcNqp2eRZnDG5zqSDrH2uZqv7gSUxjW2ZL cZBuCLAlkH5DBidUdeg/WdWApkUqcvFyAKc/QTSZje8NRCAFQMCZ67Tugmuvd2WADM LCG4Mk4DlnqcfsQzCKkSS5YeoY1b1OZmpZTAapr60IHY6myFvaWBk1rhxORZnxj2X+ Q7WCYwZLAskMdwRoM0+hMM8Oe5VVQvt5AgvBl6WXnn+ViLwXhq2+JLluHOx12xU2Xj r33kTynuBjCeVaLHM5VyP/IBfr+rLipxJ198V6Ya+gD8PXUbo00BZw350FzKLCR7pG EYDe9pC5KcKCg== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 08/11] drm/bridge: ti-sn65dsi83: Convert to drm_of_get_data_lanes Date: Thu, 19 May 2022 13:26:54 +0200 Message-Id: <20220519112657.62283-8-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , robert.foss@linaro.org, Maxime Ripard , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c index f5c1819857665..e3d87e5905c00 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c @@ -628,7 +628,7 @@ static int sn65dsi83_host_attach(struct sn65dsi83 *ctx) int dsi_lanes, ret; endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); - dsi_lanes = of_property_count_u32_elems(endpoint, "data-lanes"); + dsi_lanes = drm_of_get_data_lanes(endpoint, 1, 4); host_node = of_graph_get_remote_port_parent(endpoint); host = of_find_mipi_dsi_host_by_node(host_node); of_node_put(host_node); From patchwork Thu May 19 11:26:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854812 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 44D9CC433EF for ; Thu, 19 May 2022 11:27:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2BE2D11A354; Thu, 19 May 2022 11:27:17 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 250AF11A283 for ; Thu, 19 May 2022 11:27:12 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 659FB83C01; Thu, 19 May 2022 13:27:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959630; bh=Xx7lZ6hlSXuQihMd2KE2mgQgIsELPNfCWhoJlBEhOio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W9/ishY7dFoziCiVFDRmPYN795JrF9Bm8tLY3spQPjlEoOWAAOHcU3XOMZqNb6WKy vADpGfGJi7s4I7Mr7xpucOJUCvSbfxvBrnMjHBpq1lc8CU5TJwoOiqmAlI9uRrGXlt OTNcIUU3Fd13FKQBV8k4FvFUP93yChWqHnxBlw0KM3devVpcl+3QFfaGklTiQfl8jZ Jgz5BPVFihhmQF0O41a5bxcWdTCY7Ja1mwox9AnO+II/2j/I+TlfqTjwmZbO+h7J9d hX0H9PwTGkiJl116vamy0nvnnXn4U7Xkwg9yTsHT0ffVp6aKAjfprPwnTVzQtHMg2L njY9n244J8Olg== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 09/11] drm/bridge: ti-sn65dsi86: Convert to drm_of_get_data_lanes Date: Thu, 19 May 2022 13:26:55 +0200 Message-Id: <20220519112657.62283-9-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , robert.foss@linaro.org, Maxime Ripard , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 8cad662de9bb5..44a330a48d385 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -1142,8 +1142,8 @@ static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata, * mappings that the hardware supports. */ endpoint = of_graph_get_endpoint_by_regs(np, 1, -1); - dp_lanes = of_property_count_u32_elems(endpoint, "data-lanes"); - if (dp_lanes > 0 && dp_lanes <= SN_MAX_DP_LANES) { + dp_lanes = drm_of_get_data_lanes(endpoint, 1, SN_MAX_DP_LANES); + if (dp_lanes > 0) { of_property_read_u32_array(endpoint, "data-lanes", lane_assignments, dp_lanes); of_property_read_u32_array(endpoint, "lane-polarities", From patchwork Thu May 19 11:26:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854810 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 D3D53C433FE for ; Thu, 19 May 2022 11:27:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0BD6211A337; Thu, 19 May 2022 11:27:17 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by gabe.freedesktop.org (Postfix) with ESMTPS id B1A9A11A283 for ; Thu, 19 May 2022 11:27:12 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id EB5B983D84; Thu, 19 May 2022 13:27:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959631; bh=zFlTOrs8mywaH9UdTKqccaviuzG+Wr4zcIdmZXLjUQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGkREYv+1j/tlcCHCcUCoXRR09D7XxMIDvCOBTd0E8PY65movEIRIACCgRYeibUpN mDa9nsfdhMmzi4xuL8nRGRg7zaDzhUu8PvHlj/FlEoWJqY6tn5/cYFtk0sVAnVGfQB O0IJjqvylOyPuqNHskAvb/KYaRiSnG+hX4Zwex+p2/Lt+pqhymjD1YTdlvADC00mnc HLc8xRVRgCCsBy1avwOvJzm5WFqlxNvhML/ktf+nQNas/+3DOvUJ/mnSqplbb99ooQ 8knajzllPytW6v/pGEmVxihk0whJ9lGYWlclHDILOwmU2lt6Mwh364/0de9IvZU2d6 CnciZgwoHKKWQ== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 10/11] drm/bridge: msm: Convert to drm_of_get_data_lanes Date: Thu, 19 May 2022 13:26:56 +0200 Message-Id: <20220519112657.62283-10-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Maxime Ripard , Sean Paul , Abhinav Kumar , robert.foss@linaro.org, Laurent Pinchart , Andrzej Hajda , Dmitry Baryshkov , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Abhinav Kumar Cc: Andrzej Hajda Cc: Dmitry Baryshkov Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Rob Clark Cc: Robert Foss Cc: Sam Ravnborg Cc: Sean Paul To: dri-devel@lists.freedesktop.org Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_parser.c | 6 ++---- drivers/gpu/drm/msm/dsi/dsi_host.c | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index 8f9fed9fdafc4..6ef919cda0f5c 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -102,11 +102,9 @@ static int dp_parser_ctrl_res(struct dp_parser *parser) static int dp_parser_misc(struct dp_parser *parser) { struct device_node *of_node = parser->pdev->dev.of_node; - int len = 0; - const char *data_lane_property = "data-lanes"; + int len; - len = of_property_count_elems_of_size(of_node, - data_lane_property, sizeof(u32)); + len = drm_of_get_data_lanes(of_node, 1, DP_MAX_NUM_DP_LANES); if (len < 0) { DRM_WARN("Invalid property %s, default max DP lanes = %d\n", data_lane_property, DP_MAX_NUM_DP_LANES); diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index a95d5df52653c..a0c7d23cd4939 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -1779,11 +1779,10 @@ static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host, return 0; } - num_lanes = len / sizeof(u32); - - if (num_lanes < 1 || num_lanes > 4) { + num_lanes = drm_of_get_data_lanes(ep, 1, 4); + if (num_lanes < 0) { DRM_DEV_ERROR(dev, "bad number of data lanes\n"); - return -EINVAL; + return num_lanes; } msm_host->num_data_lanes = num_lanes; From patchwork Thu May 19 11:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 12854815 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 53D43C433EF for ; Thu, 19 May 2022 11:27:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C1C811A35B; Thu, 19 May 2022 11:27:30 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 393FC11A283 for ; Thu, 19 May 2022 11:27:13 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 9517083C7B; Thu, 19 May 2022 13:27:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1652959631; bh=yCKLbYkk0W7gF+jW4YsOpZ9MHXZLoImD2Zulfti44Hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UjVmoMHwpxSP9QMFF0l2GRmtaT4XR+oXelLW1mNz8NakCWxCFaANl906duLD95T2Z wo8Dx4mX4b/Z+TdSWZYyMPbIPCfUXQEvEdkJBZXZ4/PCj7X1rdTJOsgTDVzGNzuCOV k+Mini7ibmc1fI/D9pV3EJv1YwdR2ctzsBZrvcR1AkyvSEP/ibDkP/gGXKiml1rxw0 l3c8efOQC7dMIlmqUCs3kRmSqIn40zc0XBXlJ+dGciXBL9Li+G+nvkahM4TUVwbhlg KVwKukNuw+aHUT/Fm+xfNe/DNu0wnmMx+8JGr10/ZQ1cYVtYGkqTImPlUAD0pAy/Un X9bBPGcKqY6gw== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 11/11] drm/bridge: rcar: Convert to drm_of_get_data_lanes_ep Date: Thu, 19 May 2022 13:26:57 +0200 Message-Id: <20220519112657.62283-11-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220519112657.62283-1-marex@denx.de> References: <20220519112657.62283-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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: Marek Vasut , Laurent Pinchart , robert.foss@linaro.org, Maxime Ripard , Andrzej Hajda , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Convert driver to use this new helper to standardize OF "data-lanes" parsing. Signed-off-by: Marek Vasut Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Lucas Stach Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg To: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c index 891bb956fd61b..915c74c0a37fd 100644 --- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c +++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c @@ -683,19 +683,10 @@ static int rcar_mipi_dsi_parse_dt(struct rcar_mipi_dsi *dsi) u32 data_lanes[4]; int ret; - ep = of_graph_get_endpoint_by_regs(dsi->dev->of_node, 1, 0); - if (!ep) { - dev_dbg(dsi->dev, "unconnected port@1\n"); - return -ENODEV; - } - - ret = of_property_read_variable_u32_array(ep, "data-lanes", data_lanes, - 1, 4); - of_node_put(ep); - + ret = drm_of_get_data_lanes_ep(dsi->dev->of_node, 1, 0, 1, 4); if (ret < 0) { dev_err(dsi->dev, "missing or invalid data-lanes property\n"); - return -ENODEV; + return ret; } dsi->num_data_lanes = ret;