From patchwork Sun Nov 10 11:50:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009207 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=JjQX7xId; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XmWHJ66mYz1xyB for ; Sun, 10 Nov 2024 22:51:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77BDA88FCB; Sun, 10 Nov 2024 12:51:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JjQX7xId"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 88B1C890D8; Sun, 10 Nov 2024 12:51:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5A86F88D14 for ; Sun, 10 Nov 2024 12:51:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ansuelsmth@gmail.com Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43159c9f617so27874125e9.2 for ; Sun, 10 Nov 2024 03:51:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731239488; x=1731844288; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lSdHZriWMQtQvHlMMJ3ucXqw3XEqLQhophs0aQjovFc=; b=JjQX7xIdnCmVuItxCqDw6oYsR3DOzuUhS4O/q/48TLGLktZhW+ugU7wyOLBzQOzw+v EdnRDWK2XVSCyEMUkNGdHT48KoUBsTXAKyp4hQt4bRCZsSJ3cyIxvpI93fqPP/6GRSH/ TRbXZ6R3WyrzgNfd0DkgEToK6V9hY7N2bb0IkekF8lwE946jEFgrGvMHWjB903xVJVsl IvD7cxNVc2H+rm+U9xktTYdjAEZcLWzc5bOJLPK3bK0Tua8h0t3D39jW7dIZrFDI0aCR wUm2UTtfY7+h3A/aF7lO3ky+9cseq3kF/aek3cTEFXqOA/gOZGC8B7OfKoENcAxQVuQq cl5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731239488; x=1731844288; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lSdHZriWMQtQvHlMMJ3ucXqw3XEqLQhophs0aQjovFc=; b=Dyqv/8lUV6rQPRsT9C2q3e5WhfdHB07yyfDF0TTkhIl5wPei5pWF2l51dBde0eOS16 EUc7iIAwjqnQEEnSSHqG9HzT5o8KSBkGWNx1BtFahv31pL3QnDHrCkb6kXcaLBZm5dOO oMchlj+VMuXTIOLUZCBpY0TVB4DEWvcZH/r//0FOl6+JNTsrWv7ZQaHvbJobE9nbIWNI m4B0pOu1LmIYzWfLHgpH1TU1iygJiK3KC1NjvwWNM1yazG66oN0kVmIM2NCzwgt7tB6p eFVtnHIAJmJaxNq09vw/7HgwsP96XnduxOqKx5S+Y6jCm3NfMwCc8GgUvax0sDoZmE1U wErw== X-Forwarded-Encrypted: i=1; AJvYcCXG3KawQo1hGw7T8Yk47Bm0CQLc4F+Lq7w0Gq6B/u/tcMQLikpLSUuFrYnaVNoyTD6ci2hWUwU=@lists.denx.de X-Gm-Message-State: AOJu0YyxTbprXDmngq0cQGesKKuGDwoj4kzL6vmQITMiE5HPEBw0rIk3 bbZDnvIpcbJG3v5SA33F5hUsPA5Y4HjBEApadQ0/Ge0zC/Ioa7pO X-Google-Smtp-Source: AGHT+IEAIhCM7yPcaWnC7SCma2PlPVYSqslGipLbRaXSLR0Ci22PJSnyUeiNQnCxJN2brpIiWVyQrw== X-Received: by 2002:a05:600c:6987:b0:426:8884:2c58 with SMTP id 5b1f17b1804b1-432bcafd113mr46999815e9.4.1731239487349; Sun, 10 Nov 2024 03:51:27 -0800 (PST) Received: from localhost.localdomain (93-34-91-161.ip49.fastwebnet.it. [93.34.91.161]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5fb1sm181423745e9.8.2024.11.10.03.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 03:51:26 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sean Anderson , Sughosh Ganu , Caleb Connolly , Mattijs Korpershoek , Patrick Rudolph , Yang Xiwen , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH v2 1/8] dm: core: implement oftree variant of parse_phandle OPs Date: Sun, 10 Nov 2024 12:50:20 +0100 Message-ID: <20241110115054.2555-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com> References: <20241110115054.2555-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement oftree variant of parse_phandle OPs. There is currently a very hidden and laten BUG with parse_phandle OPs that doesn't permit the support of multiple DTS in a system. One usage example if sandbox with the usage of other.dts The BUG is only present on live scenario where of_... OPs are used and it's not present when fdt... OPs are used. This is caused by an assumption made in __of_parse_phandle_with_args, with the of_find_node_by_phandle call that pass the first arg as NULL. This makes of_find_node_by_phandle use the default root node of the system and doesn't permit the usage of alternative tree. This is correct for normal system and also for the linux kernel where it's assumed a single device tree. It's problematic if other device tree needs to be used. To fix this, introduce __of_root_parse_phandle_with_args to define a root device tree for of_find_node_by_phandle. Introduce all the variant OPs for this and in ofnode, the oftree OPs following how it's done for other OPs with similar task. For FDT scenario, ofnode_from_fdtdec_phandle_args is reworked to accept a new variable, node and noffset_to_ofnode is used instead of offset_to_ofnode. This is required to support multiple FDB blob to calculate the correct of_offset of the ofnode. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- drivers/core/of_access.c | 61 ++++++++++++++++++++-------- drivers/core/ofnode.c | 51 ++++++++++++++++++++++-- include/dm/of_access.h | 86 ++++++++++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 66 ++++++++++++++++++++++++++++++ 4 files changed, 244 insertions(+), 20 deletions(-) diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index 77acd766262..b11e36202c1 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -666,11 +666,12 @@ int of_property_read_string_helper(const struct device_node *np, return i <= 0 ? -ENODATA : i; } -static int __of_parse_phandle_with_args(const struct device_node *np, - const char *list_name, - const char *cells_name, - int cell_count, int index, - struct of_phandle_args *out_args) +static int __of_root_parse_phandle_with_args(struct device_node *root, + const struct device_node *np, + const char *list_name, + const char *cells_name, + int cell_count, int index, + struct of_phandle_args *out_args) { const __be32 *list, *list_end; int rc = 0, cur_index = 0; @@ -706,7 +707,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np, * below. */ if (cells_name || cur_index == index) { - node = of_find_node_by_phandle(NULL, phandle); + node = of_find_node_by_phandle(root, phandle); if (!node) { dm_warn("%s: could not find phandle\n", np->full_name); @@ -783,39 +784,65 @@ static int __of_parse_phandle_with_args(const struct device_node *np, return rc; } -struct device_node *of_parse_phandle(const struct device_node *np, - const char *phandle_name, int index) +struct device_node *of_root_parse_phandle(struct device_node *root, + const struct device_node *np, + const char *phandle_name, int index) { struct of_phandle_args args; if (index < 0) return NULL; - if (__of_parse_phandle_with_args(np, phandle_name, NULL, 0, index, - &args)) + if (__of_root_parse_phandle_with_args(root, np, phandle_name, NULL, 0, + index, &args)) return NULL; return args.np; } +int of_root_parse_phandle_with_args(struct device_node *root, + const struct device_node *np, + const char *list_name, const char *cells_name, + int cell_count, int index, + struct of_phandle_args *out_args) +{ + if (index < 0) + return -EINVAL; + + return __of_root_parse_phandle_with_args(root, np, list_name, cells_name, + cell_count, index, out_args); +} + +int of_root_count_phandle_with_args(struct device_node *root, + const struct device_node *np, + const char *list_name, const char *cells_name, + int cell_count) +{ + return __of_root_parse_phandle_with_args(root, np, list_name, cells_name, + cell_count, -1, NULL); +} + +struct device_node *of_parse_phandle(const struct device_node *np, + const char *phandle_name, int index) +{ + return of_root_parse_phandle(NULL, np, phandle_name, index); +} + int of_parse_phandle_with_args(const struct device_node *np, const char *list_name, const char *cells_name, int cell_count, int index, struct of_phandle_args *out_args) { - if (index < 0) - return -EINVAL; - - return __of_parse_phandle_with_args(np, list_name, cells_name, - cell_count, index, out_args); + return of_root_parse_phandle_with_args(NULL, np, list_name, cells_name, + cell_count, index, out_args); } int of_count_phandle_with_args(const struct device_node *np, const char *list_name, const char *cells_name, int cell_count) { - return __of_parse_phandle_with_args(np, list_name, cells_name, - cell_count, -1, NULL); + return of_root_count_phandle_with_args(NULL, np, list_name, cells_name, + cell_count); } static void of_alias_add(struct alias_prop *ap, struct device_node *np, diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 950895e72a9..b9cc9419407 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -879,11 +879,11 @@ int ofnode_read_string_list(ofnode node, const char *property, return count; } -static void ofnode_from_fdtdec_phandle_args(struct fdtdec_phandle_args *in, +static void ofnode_from_fdtdec_phandle_args(ofnode node, struct fdtdec_phandle_args *in, struct ofnode_phandle_args *out) { assert(OF_MAX_PHANDLE_ARGS == MAX_PHANDLE_ARGS); - out->node = offset_to_ofnode(in->node); + out->node = noffset_to_ofnode(node, in->node); out->args_count = in->args_count; memcpy(out->args, in->args, sizeof(out->args)); } @@ -923,7 +923,40 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name, cell_count, index, &args); if (ret) return ret; - ofnode_from_fdtdec_phandle_args(&args, out_args); + ofnode_from_fdtdec_phandle_args(node, &args, out_args); + } + + return 0; +} + +int oftree_parse_phandle_with_args(oftree tree, ofnode node, const char *list_name, + const char *cells_name, int cell_count, + int index, + struct ofnode_phandle_args *out_args) +{ + if (ofnode_is_np(node)) { + struct of_phandle_args args; + int ret; + + ret = of_root_parse_phandle_with_args(tree.np, + ofnode_to_np(node), + list_name, cells_name, + cell_count, index, + &args); + if (ret) + return ret; + ofnode_from_of_phandle_args(&args, out_args); + } else { + struct fdtdec_phandle_args args; + int ret; + + ret = fdtdec_parse_phandle_with_args(tree.fdt, + ofnode_to_offset(node), + list_name, cells_name, + cell_count, index, &args); + if (ret) + return ret; + ofnode_from_fdtdec_phandle_args(node, &args, out_args); } return 0; @@ -941,6 +974,18 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name, cell_count, -1, NULL); } +int oftree_count_phandle_with_args(oftree tree, ofnode node, const char *list_name, + const char *cells_name, int cell_count) +{ + if (ofnode_is_np(node)) + return of_root_count_phandle_with_args(tree.np, ofnode_to_np(node), + list_name, cells_name, cell_count); + else + return fdtdec_parse_phandle_with_args(tree.fdt, + ofnode_to_offset(node), list_name, cells_name, + cell_count, -1, NULL); +} + ofnode ofnode_path(const char *path) { if (of_live_active()) diff --git a/include/dm/of_access.h b/include/dm/of_access.h index de740d44674..44143a5a391 100644 --- a/include/dm/of_access.h +++ b/include/dm/of_access.h @@ -453,6 +453,92 @@ static inline int of_property_count_strings(const struct device_node *np, return of_property_read_string_helper(np, propname, NULL, 0, 0); } +/** + * of_root_parse_phandle - Resolve a phandle property to a device_node pointer + * from a root node + * @root: Pointer to root device tree node (default root node if NULL) + * @np: Pointer to device node holding phandle property + * @phandle_name: Name of property holding a phandle value + * @index: For properties holding a table of phandles, this is the index into + * the table + * + * Return: + * the device_node pointer with refcount incremented. Use + * of_node_put() on it when done. + */ +struct device_node *of_root_parse_phandle(struct device_node *root, + const struct device_node *np, + const char *phandle_name, int index); + +/** + * of_root_parse_phandle_with_args() - Find a node pointed by phandle in a list + * from a root node + * + * @root: pointer to root device tree node (default root node if NULL) + * @np: pointer to a device tree node containing a list + * @list_name: property name that contains a list + * @cells_name: property name that specifies phandles' arguments count + * @cells_count: Cell count to use if @cells_name is NULL + * @index: index of a phandle to parse out + * @out_args: optional pointer to output arguments structure (will be filled) + * Return: + * 0 on success (with @out_args filled out if not NULL), -ENOENT if + * @list_name does not exist, -EINVAL if a phandle was not found, + * @cells_name could not be found, the arguments were truncated or there + * were too many arguments. + * + * This function is useful to parse lists of phandles and their arguments. + * Returns 0 on success and fills out_args, on error returns appropriate + * errno value. + * + * Caller is responsible to call of_node_put() on the returned out_args->np + * pointer. + * + * Example: + * + * .. code-block:: + * + * phandle1: node1 { + * #list-cells = <2>; + * }; + * phandle2: node2 { + * #list-cells = <1>; + * }; + * node3 { + * list = <&phandle1 1 2 &phandle2 3>; + * }; + * + * To get a device_node of the `node2' node you may call this: + * of_root_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args); + */ +int of_root_parse_phandle_with_args(struct device_node *root, + const struct device_node *np, + const char *list_name, const char *cells_name, + int cells_count, int index, + struct of_phandle_args *out_args); + +/** + * of_root_count_phandle_with_args() - Count the number of phandle in a list + * from a root node + * + * @root: pointer to root device tree node (default root node if NULL) + * @np: pointer to a device tree node containing a list + * @list_name: property name that contains a list + * @cells_name: property name that specifies phandles' arguments count + * @cells_count: Cell count to use if @cells_name is NULL + * Return: + * number of phandle found, -ENOENT if @list_name does not exist, + * -EINVAL if a phandle was not found, @cells_name could not be found, + * the arguments were truncated or there were too many arguments. + * + * Returns number of phandle found on success, on error returns appropriate + * errno value. + */ +int of_root_count_phandle_with_args(struct device_node *root, + const struct device_node *np, + const char *list_name, const char *cells_name, + int cells_count); + /** * of_parse_phandle - Resolve a phandle property to a device_node pointer * @np: Pointer to device node holding phandle property diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 0787758926f..7ece68874ae 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -909,6 +909,72 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name, int ofnode_count_phandle_with_args(ofnode node, const char *list_name, const char *cells_name, int cell_count); +/** + * oftree_parse_phandle_with_args() - Find a node pointed by phandle in a list + * from a root node + * + * This function is useful to parse lists of phandles and their arguments. + * Returns 0 on success and fills out_args, on error returns appropriate + * errno value. + * + * Caller is responsible to call of_node_put() on the returned out_args->np + * pointer. + * + * Example: + * + * .. code-block:: + * + * phandle1: node1 { + * #list-cells = <2>; + * }; + * phandle2: node2 { + * #list-cells = <1>; + * }; + * node3 { + * list = <&phandle1 1 2 &phandle2 3>; + * }; + * + * To get a device_node of the `node2' node you may call this: + * oftree_parse_phandle_with_args(node3, "list", "#list-cells", 0, 1, &args); + * + * @tree: device tree to use + * @node: device tree node containing a list + * @list_name: property name that contains a list + * @cells_name: property name that specifies phandles' arguments count + * @cell_count: Cell count to use if @cells_name is NULL + * @index: index of a phandle to parse out + * @out_args: optional pointer to output arguments structure (will be filled) + * Return: + * 0 on success (with @out_args filled out if not NULL), -ENOENT if + * @list_name does not exist, -EINVAL if a phandle was not found, + * @cells_name could not be found, the arguments were truncated or there + * were too many arguments. + */ +int oftree_parse_phandle_with_args(oftree tree, ofnode node, const char *list_name, + const char *cells_name, int cell_count, + int index, + struct ofnode_phandle_args *out_args); + +/** + * oftree_count_phandle_with_args() - Count number of phandle in a list + * from a root node + * + * This function is useful to count phandles into a list. + * Returns number of phandle on success, on error returns appropriate + * errno value. + * + * @tree: device tree to use + * @node: device tree node containing a list + * @list_name: property name that contains a list + * @cells_name: property name that specifies phandles' arguments count + * @cell_count: Cell count to use if @cells_name is NULL + * Return: + * number of phandle on success, -ENOENT if @list_name does not exist, + * -EINVAL if a phandle was not found, @cells_name could not be found. + */ +int oftree_count_phandle_with_args(oftree tree, ofnode node, const char *list_name, + const char *cells_name, int cell_count); + /** * ofnode_path() - find a node by full path * From patchwork Sun Nov 10 11:50:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009208 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ZQeSmBzA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XmWHS0VSCz1xyB for ; Sun, 10 Nov 2024 22:51:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C81DF890D8; Sun, 10 Nov 2024 12:51:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZQeSmBzA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7F81989116; Sun, 10 Nov 2024 12:51:32 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1EC3E890BC for ; Sun, 10 Nov 2024 12:51:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ansuelsmth@gmail.com Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-37d4821e6b4so2594075f8f.3 for ; Sun, 10 Nov 2024 03:51:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731239489; x=1731844289; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JHbUjESrBhGpfCcnCj8/8F3tqxJNGQF3SkkIhOZxPyQ=; b=ZQeSmBzASYcA1IVr7blbZsTs+LyHpAOq79+t8KhqUuTeTdD/IMwhh8ywIt7W7x+8JC 3sDJaP6rGNFiPHgQ1KOkLi5E48t5tAvsEmjTW/5eooy43EzYzxM0l+Zh9D97EAHRrlIV a+1wT4BKqhsilueYDMtrIpF/z0YWjrIhUVZ5yh4+FD/w524w2iQ7jSZ/fYK4Us+RXBjf pJ4mxXimiQc8h5N+TdPNB2jQ/f4ssH/YjpWPD3DQho6L3BQBicG0wmVs9Kj6GnLDjB78 Ep+JCzLCUGGnkB9VIrUr0zYG+ZLCKAJPtJtXsQsOLRqjuG7BFjNZgcYa33YiIuR4HGcK AC+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731239489; x=1731844289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JHbUjESrBhGpfCcnCj8/8F3tqxJNGQF3SkkIhOZxPyQ=; b=VeYPvlkjsOux1rXQhglRl+bOVX6/Kwpepft068Sh9fAVsCmmqFWRa5cIDfni2HDfpn 7LAG7iV2BPPV8TpfBM0OwNvwK9fbSorlmgi0l/UpOZRItBLokZNQLM7mA2f/8mLKCd1I NhR3/bo07d+Q/fVM+8Cw5q+EYmJYaDKOkA/cOq4S/7QKWDZgmlqxThn/A/S1cSHoORiB VfRpgvnzKxWfu2QQsPqqmsbAl7SVhC0IFIU0JC4J8U0MVZgBOVA/vtCXZlKv4c+1MXs5 EE/aewxqA7ejHkAv2eM6lMmwk5Hfem4CL0xKIMdy2peVCYORdClmy0gJ+/Wa+DY9NYZd nOzA== X-Forwarded-Encrypted: i=1; AJvYcCWi+j74FFkhF8YyfAmm876BzodwlrwaO9epfZTtTOS7l5cF+utTylHOXGb+w97JIYY5r29BtBc=@lists.denx.de X-Gm-Message-State: AOJu0Yzp9zTY4P0umLE8R+SxujFp7YZt25WQ/ByjGqhCZNdJy2SZom/k QZ6uJjK41xd8qnIlD70AqXYDnSjKnyQKqEFGhxFGPeF6+uIXzSAk X-Google-Smtp-Source: AGHT+IHVdcZxGO2lMjQSeIDS1ttmWsr9Iuf2s02SLg5YessrnIrv6BBnwFBlN09740Le+bM+gqrPyA== X-Received: by 2002:a5d:5847:0:b0:37d:5405:817b with SMTP id ffacd0b85a97d-381f186724cmr7743333f8f.7.1731239489238; Sun, 10 Nov 2024 03:51:29 -0800 (PST) Received: from localhost.localdomain (93-34-91-161.ip49.fastwebnet.it. [93.34.91.161]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5fb1sm181423745e9.8.2024.11.10.03.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 03:51:28 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sean Anderson , Sughosh Ganu , Caleb Connolly , Mattijs Korpershoek , Patrick Rudolph , Yang Xiwen , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH v2 2/8] test: dm: fix broken dm_test_ofnode_phandle_ot and get_by_phandle_ot Date: Sun, 10 Nov 2024 12:50:21 +0100 Message-ID: <20241110115054.2555-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com> References: <20241110115054.2555-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Fix broken dm_test_ofnode_phandle_ot test. They never actually worked and were passing test by pure luck by having the same phandle index of test.dts that coincicentally had #gpio-cells in the same index node. It was sufficient to add a phandle to test.dts to make the test fail. To correctly test these feature, make use oif the new OPs oftree to parse phandle. For consistency with the dm_test_ofnode_phandle, rework the test and other.dts to use the same property with the other- prefix to every node. Also fix dm_test_ofnode_get_by_phandle_ot by making it more robust and renaming the phandle property to other-phandle. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- arch/sandbox/dts/other.dts | 24 ++++++++++- test/dm/ofnode.c | 83 +++++++++++++++++++++++++++++++------- 2 files changed, 91 insertions(+), 16 deletions(-) diff --git a/arch/sandbox/dts/other.dts b/arch/sandbox/dts/other.dts index 395a7923228..b32158c6569 100644 --- a/arch/sandbox/dts/other.dts +++ b/arch/sandbox/dts/other.dts @@ -8,13 +8,15 @@ /dts-v1/; +#include + / { compatible = "sandbox-other"; #address-cells = <1>; #size-cells = <1>; node { - target = <&target 3 4>; + other-phandle = <&target>; subnode { compatible = "sandbox-other2"; @@ -25,9 +27,27 @@ }; }; + other-a-test { + other-test-gpios = <&other_gpio_a 1>, <&other_gpio_a 4>, + <&other_gpio_b 5 GPIO_ACTIVE_HIGH 3 2 1>, + <0>, <&other_gpio_a 12>; + other-phandle-value = <&other_gpio_c 10>, <0xFFFFFFFF 20>, <&other_gpio_a 30>; + }; + + other_gpio_a: other-gpio-a { + #gpio-cells = <1>; + }; + + other_gpio_b: other-gpio-b { + #gpio-cells = <5>; + }; + + other_gpio_c: other-gpio-c { + #gpio-cells = <2>; + }; + target: target { compatible = "sandbox-other2"; - #gpio-cells = <2>; str-prop = "other"; reg = <0x8000 0x100>; status = "disabled"; diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index ce996567c3c..24b67bbe2b9 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -141,9 +141,16 @@ static int dm_test_ofnode_get_by_phandle_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); ofnode node; + u32 idx; + int ret; - ut_assert(ofnode_valid(oftree_get_by_phandle(oftree_default(), 1))); - node = oftree_get_by_phandle(otree, 1); + node = oftree_path(otree, "/node"); + ut_assert(ofnode_valid(node)); + + ret = ofnode_read_u32(node, "other-phandle", &idx); + ut_assertok(ret); + + node = oftree_get_by_phandle(otree, idx); ut_assert(ofnode_valid(node)); ut_asserteq_str("target", ofnode_get_name(node)); @@ -349,30 +356,78 @@ static int dm_test_ofnode_phandle(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_phandle, UTF_SCAN_PDATA | UTF_SCAN_FDT); -/* test ofnode_count_/parse_phandle_with_args() with 'other' tree */ +/* test oftree_count_/parse_phandle_with_args() with 'other' tree */ static int dm_test_ofnode_phandle_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); struct ofnode_phandle_args args; ofnode node; int ret; + const char prop[] = "other-test-gpios"; + const char cell[] = "#gpio-cells"; + const char prop2[] = "other-phandle-value"; - node = oftree_path(otree, "/node"); + node = oftree_path(otree, "/other-a-test"); + ut_assert(ofnode_valid(node)); - /* Test ofnode_count_phandle_with_args with cell name */ - ret = ofnode_count_phandle_with_args(node, "missing", "#gpio-cells", 0); + /* Test oftree_count_phandle_with_args with cell name */ + ret = oftree_count_phandle_with_args(otree, node, "missing", cell, 0); ut_asserteq(-ENOENT, ret); - ret = ofnode_count_phandle_with_args(node, "target", "#invalid", 0); + ret = oftree_count_phandle_with_args(otree, node, prop, "#invalid", 0); ut_asserteq(-EINVAL, ret); - ret = ofnode_count_phandle_with_args(node, "target", "#gpio-cells", 0); - ut_asserteq(1, ret); + ret = oftree_count_phandle_with_args(otree, node, prop, cell, 0); + ut_asserteq(5, ret); + + /* Test oftree_parse_phandle_with_args with cell name */ + ret = oftree_parse_phandle_with_args(otree, node, "missing", cell, 0, 0, + &args); + ut_asserteq(-ENOENT, ret); + ret = oftree_parse_phandle_with_args(otree, node, prop, "#invalid", 0, 0, + &args); + ut_asserteq(-EINVAL, ret); + ret = oftree_parse_phandle_with_args(otree, node, prop, cell, 0, 0, &args); + ut_assertok(ret); + ut_asserteq(1, args.args_count); + ut_asserteq(1, args.args[0]); + ret = oftree_parse_phandle_with_args(otree, node, prop, cell, 0, 1, &args); + ut_assertok(ret); + ut_asserteq(1, args.args_count); + ut_asserteq(4, args.args[0]); + ret = oftree_parse_phandle_with_args(otree, node, prop, cell, 0, 2, &args); + ut_assertok(ret); + ut_asserteq(5, args.args_count); + ut_asserteq(5, args.args[0]); + ut_asserteq(1, args.args[4]); + ret = oftree_parse_phandle_with_args(otree, node, prop, cell, 0, 3, &args); + ut_asserteq(-ENOENT, ret); + ret = oftree_parse_phandle_with_args(otree, node, prop, cell, 0, 4, &args); + ut_assertok(ret); + ut_asserteq(1, args.args_count); + ut_asserteq(12, args.args[0]); + ret = oftree_parse_phandle_with_args(otree, node, prop, cell, 0, 5, &args); + ut_asserteq(-ENOENT, ret); + + /* Test oftree_count_phandle_with_args with cell count */ + ret = oftree_count_phandle_with_args(otree, node, "missing", NULL, 2); + ut_asserteq(-ENOENT, ret); + ret = oftree_count_phandle_with_args(otree, node, prop2, NULL, 1); + ut_asserteq(3, ret); - ret = ofnode_parse_phandle_with_args(node, "target", "#gpio-cells", 0, - 0, &args); + /* Test oftree_parse_phandle_with_args with cell count */ + ret = oftree_parse_phandle_with_args(otree, node, prop2, NULL, 1, 0, &args); ut_assertok(ret); - ut_asserteq(2, args.args_count); - ut_asserteq(3, args.args[0]); - ut_asserteq(4, args.args[1]); + ut_asserteq(1, ofnode_valid(args.node)); + ut_asserteq(1, args.args_count); + ut_asserteq(10, args.args[0]); + ret = oftree_parse_phandle_with_args(otree, node, prop2, NULL, 1, 1, &args); + ut_asserteq(-EINVAL, ret); + ret = oftree_parse_phandle_with_args(otree, node, prop2, NULL, 1, 2, &args); + ut_assertok(ret); + ut_asserteq(1, ofnode_valid(args.node)); + ut_asserteq(1, args.args_count); + ut_asserteq(30, args.args[0]); + ret = oftree_parse_phandle_with_args(otree, node, prop2, NULL, 1, 3, &args); + ut_asserteq(-ENOENT, ret); return 0; } From patchwork Sun Nov 10 11:50:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009209 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=YQO3ivkU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XmWHd0VvKz1xyB for ; Sun, 10 Nov 2024 22:51:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1C888890C6; Sun, 10 Nov 2024 12:51:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YQO3ivkU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 80D7C8911A; Sun, 10 Nov 2024 12:51:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 94C058908A for ; Sun, 10 Nov 2024 12:51:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ansuelsmth@gmail.com Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-431688d5127so28046855e9.0 for ; Sun, 10 Nov 2024 03:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731239491; x=1731844291; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sNqtkOshP4DGaFGAoBHz+sxnWFsqVVeDprbQTP8aqp4=; b=YQO3ivkUcq3uWUt6Dv55Qtdq+t3wLnX3dCDF0oOA/D18S0zd5rikXoebKelw3GiBRG JL5FHN2avDr1HwDC2AujJI2JJkXqYL5lixqfpyqXfs1Hs3qUtXVkdsOwYwSSlxbQ1VNh EaN3Qx5h6Ktzne4BpFfvm9WuVW0QlLu3Mt1Kg6vaDuj10JMQr3sUpJTDwBFtmRXGBIW5 6bUakzTjh+5V61RhzdjP3bWcUw/Nm6dOLTKbr+8ml/OfLRjJUXXJJujgAaXOMncIIzGB 1CNtGweQ29tcdOyH0uvOLl/wX5wTzxo8SQ8rOXJ5UEhmaaZGLPznjWhPRSWAG+n3bcr8 H5uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731239491; x=1731844291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sNqtkOshP4DGaFGAoBHz+sxnWFsqVVeDprbQTP8aqp4=; b=ez6K8tdQCYRG1F4iYXZq9cCe5mwDpy7Gtw91pEnk70jOpmyX8slJCLGkbIF7CZBQwh mHAUtzxm6rIZLYk0qjz0hVmhi+XpuFMw9UZ176M0YQLLHCqmq+Q/SuIixp+e8/hUw10g 4eRJnDNoE+cSbJvaLsxlktj17kTMSZn+JmIpYYw0VuzhC9pss73MUQkKWDUkgrgg2Xld oFVRfv58Ode7tgjZ9EHcJMpypNfuXCc0LoaWzG3eAJjNQrL4FdAh2m8nFL8fsx7k74nR JOm/6oJ3Xh+t3MYBqPPR7Kz4ouOrqpDq8a5h2L7lGoft5iHIti4w3ZQj8GeH6nLM1J7V kwgw== X-Forwarded-Encrypted: i=1; AJvYcCVuGYNwMMk/cGjWKY0DL8TFPzmiuvGMFyZ6QuDczFGVHwLJY+1hLaLMVScXw5Ch2bqkVfin8KA=@lists.denx.de X-Gm-Message-State: AOJu0YzO8ugJcrpG7F8XQ03PN9yaRF4C1F8YOwSoxFUXsv03+yiDOz41 TW12WOCSXgA2OB5LOG6x496XKhKRyttOjvwrJi2apqeSC4ohTcSz X-Google-Smtp-Source: AGHT+IGbMuLC6pYz/2EYUs6GgGLaqGFVcek1pCj8L+jKSo5LYGpuNr4KmFEXHwn37XAQQ8XjVGdQsw== X-Received: by 2002:a05:600c:8608:b0:431:4c14:abf4 with SMTP id 5b1f17b1804b1-432b7887154mr75786495e9.14.1731239490931; Sun, 10 Nov 2024 03:51:30 -0800 (PST) Received: from localhost.localdomain (93-34-91-161.ip49.fastwebnet.it. [93.34.91.161]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5fb1sm181423745e9.8.2024.11.10.03.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 03:51:30 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sean Anderson , Sughosh Ganu , Caleb Connolly , Mattijs Korpershoek , Patrick Rudolph , Yang Xiwen , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH v2 3/8] dm: core: implement ofnode/tree_parse_phandle() helper Date: Sun, 10 Nov 2024 12:50:22 +0100 Message-ID: <20241110115054.2555-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com> References: <20241110115054.2555-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement ofnode/tree_parse_phandle() helper as an equivalent of of_parse_phandle to handle simple single value phandle. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- drivers/core/ofnode.c | 58 +++++++++++++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 26 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index b9cc9419407..dc6ac069311 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -879,6 +879,64 @@ int ofnode_read_string_list(ofnode node, const char *property, return count; } +ofnode ofnode_parse_phandle(ofnode node, const char *phandle_name, + int index) +{ + ofnode phandle; + + if (ofnode_is_np(node)) { + struct device_node *np; + + np = of_parse_phandle(ofnode_to_np(node), phandle_name, + index); + if (!np) + return ofnode_null(); + + phandle = np_to_ofnode(np); + } else { + struct fdtdec_phandle_args args; + + if (fdtdec_parse_phandle_with_args(ofnode_to_fdt(node), + ofnode_to_offset(node), + phandle_name, NULL, + 0, index, &args)) + return ofnode_null(); + + phandle = offset_to_ofnode(args.node); + } + + return phandle; +} + +ofnode oftree_parse_phandle(oftree tree, ofnode node, const char *phandle_name, + int index) +{ + ofnode phandle; + + if (ofnode_is_np(node)) { + struct device_node *np; + + np = of_root_parse_phandle(tree.np, ofnode_to_np(node), + phandle_name, index); + if (!np) + return ofnode_null(); + + phandle = np_to_ofnode(np); + } else { + struct fdtdec_phandle_args args; + + if (fdtdec_parse_phandle_with_args(tree.fdt, + ofnode_to_offset(node), + phandle_name, NULL, + 0, index, &args)) + return ofnode_null(); + + phandle = noffset_to_ofnode(node, args.node); + } + + return phandle; +} + static void ofnode_from_fdtdec_phandle_args(ofnode node, struct fdtdec_phandle_args *in, struct ofnode_phandle_args *out) { diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 7ece68874ae..eea6b13217c 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -847,6 +847,18 @@ int ofnode_read_string_count(ofnode node, const char *property); int ofnode_read_string_list(ofnode node, const char *property, const char ***listp); +/** + * ofnode_parse_phandle() - Resolve a phandle property to an ofnode + * + * @node: node to check + * @phandle_name: Name of property holding a phandle value + * @index: For properties holding a table of phandles, this is the index into + * the table + * Return: ofnode that the phandle points to or ofnode_null() on error. + */ +ofnode ofnode_parse_phandle(ofnode node, const char *phandle_name, + int index); + /** * ofnode_parse_phandle_with_args() - Find a node pointed by phandle in a list * @@ -909,6 +921,20 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name, int ofnode_count_phandle_with_args(ofnode node, const char *list_name, const char *cells_name, int cell_count); +/** + * oftree_parse_phandle() - Resolve a phandle property to an ofnode + * from a root node + * + * @tree: device tree to use + * @node: node to check + * @phandle_name: Name of property holding a phandle value + * @index: For properties holding a table of phandles, this is the index into + * the table + * Return: ofnode that the phandle points to or ofnode_null() on error. + */ +ofnode oftree_parse_phandle(oftree tree, ofnode node, const char *phandle_name, + int index); + /** * oftree_parse_phandle_with_args() - Find a node pointed by phandle in a list * from a root node From patchwork Sun Nov 10 11:50:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009210 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=hDwHsIF/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XmWHp703wz1xyB for ; Sun, 10 Nov 2024 22:52:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 63402890B1; Sun, 10 Nov 2024 12:51:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hDwHsIF/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 10C728910C; Sun, 10 Nov 2024 12:51:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 11BC58911A for ; Sun, 10 Nov 2024 12:51:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ansuelsmth@gmail.com Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4315e9e9642so29691665e9.0 for ; Sun, 10 Nov 2024 03:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731239493; x=1731844293; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hEVWHcmTEzDceWKrIQy67wAPwlCK5RtA9qzT4iCWfIw=; b=hDwHsIF/3oZ5vsFGyw0ap48iMB/y9sSHKcqd5FqZ33cJFbQZgebgToy0jTmHnGOT4b mZvAgOKPPoQx2gj14AayOlGwrJEA6ARu1FUh2ANRnYEr9vcLLvySU1sqUDqLoOL30wrC sRTS9MSIR7uY1GoRo1idpL2HMT5dzPXElhSTmHZWpg9FhZzp1X1XIPgHNEaY0rDQK94l GMI9qTtW6gzHSXV9VsLiO5Ht6Wa7obM/cVhkC+vOqjEqbItn3dyNHEOhQ0WuGUCeexu9 gAWO3PGZet1M6NprYMW8WC6tQ40oL4RL+d+BznCXH9oOp3Fvb6ukkbfz+79QB0BMNoCy 1kIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731239493; x=1731844293; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hEVWHcmTEzDceWKrIQy67wAPwlCK5RtA9qzT4iCWfIw=; b=H58J9LzVEX4XwmTNqD5DzFAR9iatVLVpXo0234kz++srq7CEtQ/0I3IElgFWuw0GAh tJsphrFZPYI4iCaUiecHOXdgxHq+Aqv1Fostk2Csa/GCRDERAwoJoqqcYbu5lp8U5ILd 3GUWf6mCuweDICA0ieZv1s9zqBo82rcCP3Ua+7AaDYV4RdeNnBrlFi8Drk9MEb/gw2V9 DjmwBlUV4drf1cBo7jsW5cGDbgP/uqm4uryOn1q1+UG6npiFRaiV6DGsel72fTXxyLwM e65vn4k/vFcxVIhSL4pldJmUlyic2eMrGUiT0GgfwlPkQuktAWh4yI1poRp/tUDvF9Et owkQ== X-Forwarded-Encrypted: i=1; AJvYcCX9sj39T3rRnprCap7dEewnwTwP4gU0v/ipi1DowKNO63jVrdmZMnNjSQBjyQBBtjYA1Hjw4yo=@lists.denx.de X-Gm-Message-State: AOJu0YwsJLBbkyLgtr1RAgJYa84AM48fJNXtnYnxSowr2NIzyuuprBXJ NheBfBc0FRA3XJg6iiV/fSDtPK9vXeTR/7cWuXuP0dMSzWQk1lSg X-Google-Smtp-Source: AGHT+IHRoDf84GqMZ/er4P8I/ZwtuiU9PXFTIb9y3CWAvYquB+HZtm/LYsft36q+jyUKcXS7yTlcwA== X-Received: by 2002:a05:6000:1f86:b0:381:cffc:d40b with SMTP id ffacd0b85a97d-381f183f7c7mr7270145f8f.39.1731239493323; Sun, 10 Nov 2024 03:51:33 -0800 (PST) Received: from localhost.localdomain (93-34-91-161.ip49.fastwebnet.it. [93.34.91.161]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5fb1sm181423745e9.8.2024.11.10.03.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 03:51:32 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sean Anderson , Sughosh Ganu , Caleb Connolly , Mattijs Korpershoek , Patrick Rudolph , Yang Xiwen , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH v2 4/8] test: dm: Expand dm_test_ofnode_phandle(_ot) with new ofnode/tree_parse_phandle Date: Sun, 10 Nov 2024 12:50:23 +0100 Message-ID: <20241110115054.2555-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com> References: <20241110115054.2555-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Expand dm_test_ofnode_phandle(_ot) with new ofnode/tree_parse_phandle() op. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- arch/sandbox/dts/other.dts | 7 ++++++ arch/sandbox/dts/test.dts | 7 ++++++ test/dm/ofnode.c | 44 ++++++++++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/arch/sandbox/dts/other.dts b/arch/sandbox/dts/other.dts index b32158c6569..515d6348b3f 100644 --- a/arch/sandbox/dts/other.dts +++ b/arch/sandbox/dts/other.dts @@ -32,6 +32,7 @@ <&other_gpio_b 5 GPIO_ACTIVE_HIGH 3 2 1>, <0>, <&other_gpio_a 12>; other-phandle-value = <&other_gpio_c 10>, <0xFFFFFFFF 20>, <&other_gpio_a 30>; + other-phandle-nodes = <&other_phandle_node_1>, <&other_phandle_node_2>; }; other_gpio_a: other-gpio-a { @@ -46,6 +47,12 @@ #gpio-cells = <2>; }; + other_phandle_node_1: other-phandle-node-1 { + }; + + other_phandle_node_2: other-phandle-node-2 { + }; + target: target { compatible = "sandbox-other2"; str-prop = "other"; diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 3017b33d67b..b8a46463158 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -296,6 +296,12 @@ compatible = "sandbox,dsi-host"; }; + phandle_node_1: phandle-node-1 { + }; + + phandle_node_2: phandle-node-2 { + }; + a-test { reg = <0 1>; compatible = "denx,u-boot-fdt-test"; @@ -334,6 +340,7 @@ interrupts-extended = <&irq 3 0>; acpi,name = "GHIJ"; phandle-value = <&gpio_c 10>, <0xFFFFFFFF 20>, <&gpio_a 30>; + phandle-nodes = <&phandle_node_1>, <&phandle_node_2>; mux-controls = <&muxcontroller0 0>, <&muxcontroller0 1>, <&muxcontroller0 2>, <&muxcontroller0 3>, diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 24b67bbe2b9..cf10e698d9e 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -280,15 +280,16 @@ static int dm_test_ofnode_read_ot(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_read_ot, UTF_SCAN_FDT | UTF_OTHER_FDT); -/* test ofnode_count_/parse_phandle_with_args() */ +/* test ofnode_count_/parse/_phandle_with_args() */ static int dm_test_ofnode_phandle(struct unit_test_state *uts) { struct ofnode_phandle_args args; - ofnode node; + ofnode node, phandle, target; int ret; const char prop[] = "test-gpios"; const char cell[] = "#gpio-cells"; const char prop2[] = "phandle-value"; + const char prop3[] = "phandle-nodes"; node = ofnode_path("/a-test"); ut_assert(ofnode_valid(node)); @@ -352,20 +353,38 @@ static int dm_test_ofnode_phandle(struct unit_test_state *uts) ret = ofnode_parse_phandle_with_args(node, prop2, NULL, 1, 3, &args); ut_asserteq(-ENOENT, ret); + /* Test ofnode_parse_phandle */ + phandle = ofnode_parse_phandle(node, "missing", 0); + ut_assert(ofnode_equal(ofnode_null(), phandle)); + + target = ofnode_path("/phandle-node-1"); + ut_assert(ofnode_valid(target)); + phandle = ofnode_parse_phandle(node, prop3, 0); + ut_assert(ofnode_equal(target, phandle)); + + target = ofnode_path("/phandle-node-2"); + ut_assert(ofnode_valid(target)); + phandle = ofnode_parse_phandle(node, prop3, 1); + ut_assert(ofnode_equal(target, phandle)); + + phandle = ofnode_parse_phandle(node, prop3, 3); + ut_assert(ofnode_equal(ofnode_null(), phandle)); + return 0; } DM_TEST(dm_test_ofnode_phandle, UTF_SCAN_PDATA | UTF_SCAN_FDT); -/* test oftree_count_/parse_phandle_with_args() with 'other' tree */ +/* test oftree_count_/parse/_phandle_with_args() with 'other' tree */ static int dm_test_ofnode_phandle_ot(struct unit_test_state *uts) { oftree otree = get_other_oftree(uts); struct ofnode_phandle_args args; - ofnode node; + ofnode node, phandle, target; int ret; const char prop[] = "other-test-gpios"; const char cell[] = "#gpio-cells"; const char prop2[] = "other-phandle-value"; + const char prop3[] = "other-phandle-nodes"; node = oftree_path(otree, "/other-a-test"); ut_assert(ofnode_valid(node)); @@ -429,6 +448,23 @@ static int dm_test_ofnode_phandle_ot(struct unit_test_state *uts) ret = oftree_parse_phandle_with_args(otree, node, prop2, NULL, 1, 3, &args); ut_asserteq(-ENOENT, ret); + /* Test oftree_parse_phandle */ + phandle = oftree_parse_phandle(otree, node, "missing", 0); + ut_assert(ofnode_equal(ofnode_null(), phandle)); + + target = oftree_path(otree, "/other-phandle-node-1"); + ut_assert(ofnode_valid(target)); + phandle = oftree_parse_phandle(otree, node, prop3, 0); + ut_assert(ofnode_equal(target, phandle)); + + target = oftree_path(otree, "/other-phandle-node-2"); + ut_assert(ofnode_valid(target)); + phandle = oftree_parse_phandle(otree, node, prop3, 1); + ut_assert(ofnode_equal(target, phandle)); + + phandle = oftree_parse_phandle(otree, node, prop3, 3); + ut_assert(ofnode_equal(ofnode_null(), phandle)); + return 0; } DM_TEST(dm_test_ofnode_phandle_ot, UTF_OTHER_FDT); From patchwork Sun Nov 10 11:50:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009211 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=cYV0eGcU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XmWHz6ZJrz1xyB for ; Sun, 10 Nov 2024 22:52:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AB5AA8912B; Sun, 10 Nov 2024 12:51:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cYV0eGcU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9D02789124; Sun, 10 Nov 2024 12:51:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B58DB890BC for ; Sun, 10 Nov 2024 12:51:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ansuelsmth@gmail.com Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4315e9e9642so29691745e9.0 for ; Sun, 10 Nov 2024 03:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731239495; x=1731844295; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0gLwx2sIOhKB4xzx5TISFKWF0q3NnvkTmK8wiWVP/OM=; b=cYV0eGcUqGXEE9jBuI84D49cFG1Aep3TcH/SZ//UX6LLu7+hb/Lh9N63sqxl8UiDUE i7U2cxc7+HJLekgETnsZlUJe7j69c+BZ6U/nLWk9wrDLos3PJoyc8/e1WedUYY1EiDUf lNXrD/oV3FGOFxZCVack/bJ8RnFti7H2nASNV8JmGpDLoPlKvJJlPfwcazx3a9uiyI3U KsobiCYnugoHBvgJPzgKWTkHeTvBlLGlDVbCfSRCeNxnznCaZp0nn8Mtc1/7/jfpzyF+ ycvne6JlaYLg1J1BwwT0PGxxqnPVp6hjyjh/ezyR0+ptt3Db9FW85rcrKTWgcsnABkmZ Idtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731239495; x=1731844295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0gLwx2sIOhKB4xzx5TISFKWF0q3NnvkTmK8wiWVP/OM=; b=g/2OpE8C2+aTW/PGFBEjP3y1g7QStlss+mC/FAFVFimoaNAsWsWS51Re1/951TTXd0 gCE4excSkruNB7nGK3W8k4KbyILnJk4A54NqiddFNT9cjgBM5TTYnFLlYSLWdRq6WHAZ 0y3NF+fIZKaxHciPp6agqTz/HPgeaphJ5xfy2FOoA/TML0eVBtYUve5K8hHQVFKC++cd w+oIfahUT0cGwf9zUfB5INiyJZnSAr5//SKtRbizK70UKt6/RdWMdkTEDq56dasw6cqt jZM8WXy/U2zTqdVV2MVMFmdfRDSem/eRk6LA510qu1J95Rtm7oZAYJOD/vqH0XIpAdbP z1vA== X-Forwarded-Encrypted: i=1; AJvYcCX1+Kzta3RNkcUAvmNcrvFkPeu4+zkaRDwq0IrS30syjLlZkMuslijGq1ZtgRSbmI4zWCMXYcA=@lists.denx.de X-Gm-Message-State: AOJu0Yx1EMr/2bI1JoPNuq86KmHJngorquDeJZp3WbLBj2h13OVPWxcf hWOiG2crKIIMTehReoUiErV6B2xdy9TIr3itKt0Nk1SdKB5usgNy X-Google-Smtp-Source: AGHT+IEP7Jv3Sp8X3wgm1vSgYCnlcn88CDt+OBhGfaHYhyHaQFlkPTppbw2uwMcRhoKOPOJaZPjTgQ== X-Received: by 2002:a05:600c:4f04:b0:431:5194:1687 with SMTP id 5b1f17b1804b1-432b7509722mr79301295e9.18.1731239495056; Sun, 10 Nov 2024 03:51:35 -0800 (PST) Received: from localhost.localdomain (93-34-91-161.ip49.fastwebnet.it. [93.34.91.161]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5fb1sm181423745e9.8.2024.11.10.03.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 03:51:34 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sean Anderson , Sughosh Ganu , Caleb Connolly , Mattijs Korpershoek , Patrick Rudolph , Yang Xiwen , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH v2 5/8] dm: core: implement phandle ofnode_options helper Date: Sun, 10 Nov 2024 12:50:24 +0100 Message-ID: <20241110115054.2555-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com> References: <20241110115054.2555-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement ofnode_options phandle helper to get an ofnode from a phandle option in /options/u-boot. This helper can be useful since new DT yaml usually require to link a phandle of a node instead of referencing it by name or other indirect way. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- drivers/core/ofnode.c | 15 +++++++++++++++ include/dm/ofnode.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index dc6ac069311..c8161827d1c 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1871,6 +1871,21 @@ const char *ofnode_options_read_str(const char *prop_name) return ofnode_read_string(uboot, prop_name); } +int ofnode_options_get_by_phandle(const char *prop_name, ofnode *nodep) +{ + ofnode uboot; + + uboot = ofnode_path("/options/u-boot"); + if (!ofnode_valid(uboot)) + return -EINVAL; + + *nodep = ofnode_parse_phandle(uboot, prop_name, 0); + if (!ofnode_valid(*nodep)) + return -EINVAL; + + return 0; +} + int ofnode_read_bootscript_address(u64 *bootscr_address, u64 *bootscr_offset) { int ret; diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index eea6b13217c..890f0e6cf40 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1720,6 +1720,21 @@ int ofnode_options_read_int(const char *prop_name, int default_val); */ const char *ofnode_options_read_str(const char *prop_name); +/** + * ofnode_options_get_by_phandle() - Get a ofnode from phandle from the U-Boot options + * + * This reads a property from the /options/u-boot/ node of the devicetree. + * + * This only works with the control FDT. + * + * See dtschema/schemas/options/u-boot.yaml in dt-schema project for bindings + * + * @prop_name: property name to look up + * @nodep: pointer to ofnode where node is stored + * Return: 0, if found, or negative error if not + */ +int ofnode_options_get_by_phandle(const char *prop_name, ofnode *nodep); + /** * ofnode_read_bootscript_address() - Read bootscr-address or bootscr-ram-offset * From patchwork Sun Nov 10 11:50:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009212 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=lvO9zXVv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XmWJ95gLmz1xyB for ; Sun, 10 Nov 2024 22:52:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F38E189161; Sun, 10 Nov 2024 12:51:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lvO9zXVv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5552689110; Sun, 10 Nov 2024 12:51:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 715B689116 for ; Sun, 10 Nov 2024 12:51:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ansuelsmth@gmail.com Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43155afca99so25967745e9.1 for ; Sun, 10 Nov 2024 03:51:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731239497; x=1731844297; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Jsi9+1oXtEK7GY9TXIImG9iazLycLcIavQ8/dm+agHI=; b=lvO9zXVvbyGWaeFz+qjnBNU7JFK4m9t+oQshuKZ+W53EgutAWsvVxIuhTLkdiXe/Lk 0fL6HW1nsI238HWgKFrswHdKa7w00fLbPfuzxYCWovhNU/7FDTcxcX70sJTsMlYkt2eN fjJ2BofbWSBEr9fo7CZaFLo010/Uq7dtmzfUHma8R6ijvaaOxKxl5/gMz2Iqw9K8MgZY IGaU6exRPjzmNztra/VZ2NW0ZjsjjXVxQLJEOOzP2vB/BuDIcWSu+70H+VGBLPng5rdl rhlfdapezJcHcuOLXxCixKUYVsBVJycuHe4wlYKbAtplYplslj8rQqzE4dpOJ5XxZX6y Fnow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731239497; x=1731844297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Jsi9+1oXtEK7GY9TXIImG9iazLycLcIavQ8/dm+agHI=; b=QJ83GGVLUaM+530Hw+zq/6N59eERkw0yjUV7MkKDzmiBgqjFKM9z/9eyqB7GzLtb0V 3snwZHxRPaXq7njjlGi6KWwumPiMBTbSJK8UgZKlG/UUX3mPNwgiEjRh/vR0M5QVISxV 8DWpQmcZsKZFVR5w5zNMpOGLucSbVwDpmP0lwDsu9EFdmFQlhzY+rnGBNefQcauedhm8 TLqdoPsW5GL634y8Gb39zHbfRamLuvpNqOlxFpY6oDt5D3IhQN0YI2FxwgMPfm2Xreqi r+UHZr1nGe0xIY1KYluUXrOVMyEA/fJzsCJaShgBk16bf+QnJ7EqU9elmFWvH6t73sYN CP+g== X-Forwarded-Encrypted: i=1; AJvYcCVBNMer3xujvC+p1G9adn3l6cjMJ22u3mByAnUNcOJNUeAigozHdYAToGCGVzWB0v5+cLC2QZA=@lists.denx.de X-Gm-Message-State: AOJu0YxX4i14GyCwLCK+XcL/DVrmdTkDwTqSve0NSSVeMTpAuiAl8e/a fYkxMcYIiS4vyolG+EPat1XKq9hrB8C/intCHsjqBkYOInmTJDcR X-Google-Smtp-Source: AGHT+IHsTaG7rmkj42OgmYAc0fHrIvHMvwu12GCNhhHGO7luXjDsOHGjNixJ2bmJt7PKHE/ysgMksw== X-Received: by 2002:a05:600c:4f4e:b0:431:4a82:97f2 with SMTP id 5b1f17b1804b1-432b6858db8mr83278275e9.6.1731239496793; Sun, 10 Nov 2024 03:51:36 -0800 (PST) Received: from localhost.localdomain (93-34-91-161.ip49.fastwebnet.it. [93.34.91.161]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5fb1sm181423745e9.8.2024.11.10.03.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 03:51:35 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sean Anderson , Sughosh Ganu , Caleb Connolly , Mattijs Korpershoek , Patrick Rudolph , Yang Xiwen , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH v2 6/8] test: dm: Add test for ofnode options phandle helper Date: Sun, 10 Nov 2024 12:50:25 +0100 Message-ID: <20241110115054.2555-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com> References: <20241110115054.2555-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add test for ofnode options phandle helper and add new property in the sandbox test dts. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 1 + test/dm/ofnode.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index b8a46463158..1ffa64a43e2 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -106,6 +106,7 @@ testing-bool; testing-int = <123>; testing-str = "testing"; + testing-phandle = <&phandle_node_1>; }; }; diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index cf10e698d9e..f16b643fa3f 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -704,6 +704,10 @@ static int dm_test_ofnode_options(struct unit_test_state *uts) { u64 bootscr_address, bootscr_offset; u64 bootscr_flash_offset, bootscr_flash_size; + ofnode node, phandle_node, target; + + node = ofnode_path("/options/u-boot"); + ut_assert(ofnode_valid(node)); ut_assert(!ofnode_options_read_bool("missing")); ut_assert(ofnode_options_read_bool("testing-bool")); @@ -714,6 +718,13 @@ static int dm_test_ofnode_options(struct unit_test_state *uts) ut_assertnull(ofnode_options_read_str("missing")); ut_asserteq_str("testing", ofnode_options_read_str("testing-str")); + ut_asserteq(-EINVAL, ofnode_options_get_by_phandle("missing", &phandle_node)); + + target = ofnode_path("/phandle-node-1"); + ut_assert(ofnode_valid(target)); + ut_assertok(ofnode_options_get_by_phandle("testing-phandle", &phandle_node)); + ut_assert(ofnode_equal(target, phandle_node)); + ut_assertok(ofnode_read_bootscript_address(&bootscr_address, &bootscr_offset)); ut_asserteq_64(0, bootscr_address); From patchwork Sun Nov 10 11:50:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009213 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=E8wt9w5Q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XmWJM6dQhz1xyB for ; Sun, 10 Nov 2024 22:52:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 450388916D; Sun, 10 Nov 2024 12:51:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E8wt9w5Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 54A558911A; Sun, 10 Nov 2024 12:51:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6DF4A8908A for ; Sun, 10 Nov 2024 12:51:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ansuelsmth@gmail.com Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4315eac969aso20419955e9.1 for ; Sun, 10 Nov 2024 03:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731239498; x=1731844298; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XA68RAvqKHOo6s9eir7rUFmwOpSSbzu5sM3S9VXrzjU=; b=E8wt9w5QOGzvgwYMfTbSPQW/zeJQhQbuh9gip4hHGz3NDBoJ1Krt04p5wFW6Z8eJI+ M5YnnpC27l/zqy1223uCXcw3ED4mPt2l1mN3n6q32jdRXDt1AOpUidUhGy+M3qE+hOHz ZhOwsTIr+iBgXgrMhiDeXkX0TzaaNB2rzojBdisx9eGIKEYaADc04AYInZPIgMezGvZA QVjFrRjVEEDBfrq0kvXHRBGclRpnEARk4esLA9fhgL31v1ABX50d9huQBGcgB//Lrbas 0AAso0OdGT9pgm/j9Uj+Dl5hDaurQVe0klW9GdkEqroaN7tFkrZRyZ1/4yoivQJeQgj6 oUAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731239498; x=1731844298; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XA68RAvqKHOo6s9eir7rUFmwOpSSbzu5sM3S9VXrzjU=; b=tF4hESkWXvjlpFfYvEXAQUGcdkHDvPmKSd4KWXAV6//evJ+wE1LZLGPLiixm6qNX7J dSvc5a8lIkfVwctWKbgTGDHCe6mCayQkjYvIIkGGRPFjCtq/HW67NbB5oJP9Iwu2SW1S ZweSTuu/deHKPkHe0cUsqEQbBvHNUUWGHhJlCaTnY9H94iwZgxjLCWwIBePhTvtyKfKJ dhPPdMZMUqxZF4wSzZbF62J13b1K3MmAmw5BqOglgxSzIkKyo3ChE5QcDHg6087tP0LG Vqog7ikoAOMs0/xII5imfC3ZlCX+cWmXovPyvqr+Mqq8cbEQp90ElNU/nTvc19WpRpOb KVBQ== X-Forwarded-Encrypted: i=1; AJvYcCU0+JDu0S/aEJrT9O6+a4/Fn1WZMWEXUH7HgNA5ugpAu+vCYgWLAjRTnOSzZUVMxcV4bOhypHA=@lists.denx.de X-Gm-Message-State: AOJu0YxtKzHOfjdzVwm2fiG0brIugVqFHcuqvOv56Ak82Vo0V96a3eph htJZ+AofCD9+WSaMikRbq4beM83/xI5RzV56BQJDo2cJ5B8oZ5/2 X-Google-Smtp-Source: AGHT+IEQHJweLb/HRXjXQIz/3Q3BPoQUcISfVDNUn0YaB8Jz2fp6qeOkA9j6oMkVwCnAJVBC1gqksw== X-Received: by 2002:a05:600c:8608:b0:426:5e32:4857 with SMTP id 5b1f17b1804b1-432b77fe58bmr76947475e9.0.1731239497856; Sun, 10 Nov 2024 03:51:37 -0800 (PST) Received: from localhost.localdomain (93-34-91-161.ip49.fastwebnet.it. [93.34.91.161]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5fb1sm181423745e9.8.2024.11.10.03.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 03:51:37 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sean Anderson , Sughosh Ganu , Caleb Connolly , Mattijs Korpershoek , Patrick Rudolph , Yang Xiwen , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH v2 7/8] led: update LED boot/activity to new property implementation Date: Sun, 10 Nov 2024 12:50:26 +0100 Message-ID: <20241110115054.2555-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com> References: <20241110115054.2555-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Update LED boot/activity to reference by phandle instead of label and add to period property the "-ms" suffix. This is a followup request by dt-schema maintainers that required LED node to be referenced by a phandle to the node instead of indirectly by the LED label and for timevalue to have a suffix. While at it generalize the LED node label parsing since the logic is common for generic LED bind and LED activity/boot. Signed-off-by: Christian Marangi --- drivers/led/led-uclass.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 05e09909b7d..760750568c0 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -232,16 +232,24 @@ int led_activity_blink(void) #endif #endif +static const char *led_get_label(ofnode node) +{ + const char *label; + + label = ofnode_read_string(node, "label"); + if (!label && !ofnode_read_string(node, "compatible")) + label = ofnode_get_name(node); + + return label; +} + static int led_post_bind(struct udevice *dev) { struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); const char *default_state; if (!uc_plat->label) - uc_plat->label = dev_read_string(dev, "label"); - - if (!uc_plat->label && !dev_read_string(dev, "compatible")) - uc_plat->label = ofnode_get_name(dev_ofnode(dev)); + uc_plat->label = led_get_label(dev_ofnode(dev)); uc_plat->default_state = LEDST_COUNT; @@ -300,15 +308,21 @@ static int led_post_probe(struct udevice *dev) static int led_init(struct uclass *uc) { struct led_uc_priv *priv = uclass_get_priv(uc); + ofnode led_node; + int ret; #ifdef CONFIG_LED_BOOT - priv->boot_led_label = ofnode_options_read_str("boot-led"); - priv->boot_led_period = ofnode_options_read_int("boot-led-period", 250); + ret = ofnode_options_get_by_phandle("boot-led", &led_node); + if (!ret) + priv->boot_led_label = led_get_label(led_node); + priv->boot_led_period = ofnode_options_read_int("boot-led-period-ms", 250); #endif #ifdef CONFIG_LED_ACTIVITY - priv->activity_led_label = ofnode_options_read_str("activity-led"); - priv->activity_led_period = ofnode_options_read_int("activity-led-period", + ret = ofnode_options_get_by_phandle("activity-led", &led_node); + if (!ret) + priv->activity_led_label = led_get_label(led_node); + priv->activity_led_period = ofnode_options_read_int("activity-led-period-ms", 250); #endif From patchwork Sun Nov 10 11:50:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009214 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=OMa5UAkW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XmWJZ1BWpz1xyB for ; Sun, 10 Nov 2024 22:52:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8CF1C8910A; Sun, 10 Nov 2024 12:51:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OMa5UAkW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 954AE89170; Sun, 10 Nov 2024 12:51:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A8CA589110 for ; Sun, 10 Nov 2024 12:51:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ansuelsmth@gmail.com Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-43162cf1eaaso45698075e9.0 for ; Sun, 10 Nov 2024 03:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731239499; x=1731844299; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pRU2vygyWXfpZrJcW3c8ojIH7/oPWUzHhkPQ3zdbEh8=; b=OMa5UAkWNYtTpsiZKsZsXOxePOgBivIJYmOKFEK33OrS7ObFYskhhfkjfQ+jtqmtlt zHSnAUBSFxQM0h6Eg0xfuzW3b5TwHEXkH2CfuydKJAqhDs0FDO8WLNOIgYBA2p+VVTNo i7u4B/hQX2LD7YDRwu/oiB7owamzfbg72zGxoBffTrY1MYhe4OYr6aR8QdV+d6i898Lv TJMDnC9XDR8Doe0G6XjstN0SezqsdF8NQp1R7DSJMO9GQLLplp88fBg78Js1FQHnGVmy ntbwElMHWf0x0x3OnB+6lQPpxxe+KbXPcUQMO/bGx5t20O9pno0ROfMfr7CLz760gpJT AE5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731239499; x=1731844299; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pRU2vygyWXfpZrJcW3c8ojIH7/oPWUzHhkPQ3zdbEh8=; b=ezQeskOStJJLnKIjM4XGUyf6+mcLlQ1+vtJLvWhkYMZyhOSz9bXsUh4y2FB38vs+z9 WOI/fcYpevMaTtxnx/NLUzcSuAhmR7QsKUPhXC3fMXuDhjX2mwdKVIxPXW2LsqCpGcgl /zKrKEiqE0LAHhYl22bSwFTrAOsTo/wCd3LHhzHCoV/ZkV4D9jCeEqMIfl5UzvQBA5eV ForhdPbEcYWS1qtju/Xv6cQQRt+Y2xu1jBVzJxKV9W/+sleZg5aEh71mN0lR3LuoLkzN Ckk1mFHQL8e2GTY5vJN/ihwFQkHXo85uFjRQ31t63CSxOncN7r8k4bYR211ltfy65Ugm OxGA== X-Forwarded-Encrypted: i=1; AJvYcCVYM6j9R2hP/lh/bAqNTMSaUnKP/sqGnrG8Xkp4otFWe0bHxZbyiUd8vr8YY1QJF/RKRY7i4N4=@lists.denx.de X-Gm-Message-State: AOJu0Yz6vUHrbHNQ6JHw4p6cNn2DR2x5Y4f5HMFOa+wrzPbg3OZ3UNNA oabxHDNolbaTS9xBcHZh3vxWSgGS5zPhfEMEEOnZjL8asVUENQBZ X-Google-Smtp-Source: AGHT+IESxCEgplpjCVx6t4nD5VDHWCy3sodD4VLxvukjND3QA/LmM2uaOT89WrEggfChiRcPpnu/qw== X-Received: by 2002:a05:600c:4f4a:b0:431:9a26:3cf6 with SMTP id 5b1f17b1804b1-432b74fed4amr101817685e9.4.1731239498929; Sun, 10 Nov 2024 03:51:38 -0800 (PST) Received: from localhost.localdomain (93-34-91-161.ip49.fastwebnet.it. [93.34.91.161]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5fb1sm181423745e9.8.2024.11.10.03.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 03:51:38 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sean Anderson , Sughosh Ganu , Caleb Connolly , Mattijs Korpershoek , Patrick Rudolph , Yang Xiwen , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH v2 8/8] test: dm: Update test for LED activity and boot Date: Sun, 10 Nov 2024 12:50:27 +0100 Message-ID: <20241110115054.2555-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241110115054.2555-1-ansuelsmth@gmail.com> References: <20241110115054.2555-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Update test for LED activity and boot to follow new implementation with property set to the LED node phandle. Also update a copy-paste error in the function name for the activity tests and actually enable the test with the DM_TEST macro. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 8 ++++---- test/dm/led.c | 18 +++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 1ffa64a43e2..e9b3b151e10 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -101,8 +101,8 @@ bootscr-ram-offset = /bits/ 64 <0x12345678>; bootscr-flash-offset = /bits/ 64 <0>; bootscr-flash-size = /bits/ 64 <0x2000>; - boot-led = "sandbox:green"; - activity-led = "sandbox:red"; + boot-led = <&sandbox_led_green>; + activity-led = <&sandbox_led_red>; testing-bool; testing-int = <123>; testing-str = "testing"; @@ -988,12 +988,12 @@ leds { compatible = "gpio-leds"; - iracibble { + sandbox_led_red: iracibble { gpios = <&gpio_a 1 0>; label = "sandbox:red"; }; - martinet { + sandbox_led_green: martinet { gpios = <&gpio_a 2 0>; label = "sandbox:green"; }; diff --git a/test/dm/led.c b/test/dm/led.c index 884f6410b70..e5b86326c3a 100644 --- a/test/dm/led.c +++ b/test/dm/led.c @@ -144,7 +144,7 @@ static int dm_test_led_boot(struct unit_test_state *uts) { struct udevice *dev - /* options/u-boot/boot-led is set to "sandbox:green" */ + /* options/u-boot/boot-led is set to phandle to "sandbox:green" */ ut_assertok(led_get_by_label("sandbox:green", &dev)); ut_asserteq(LEDST_OFF, led_get_state(dev)); ut_assertok(led_boot_on()); @@ -154,14 +154,15 @@ static int dm_test_led_boot(struct unit_test_state *uts) return 0; } +DM_TEST(dm_test_led_boot, UTF_SCAN_PDATA | UTF_SCAN_FDT); /* Test LED boot blink fallback */ #ifndef CONFIG_LED_BLINK -static int dm_test_led_boot(struct unit_test_state *uts) +static int dm_test_led_boot_blink(struct unit_test_state *uts) { struct udevice *dev - /* options/u-boot/boot-led is set to "sandbox:green" */ + /* options/u-boot/boot-led is set to phandle to "sandbox:green" */ ut_assertok(led_get_by_label("sandbox:green", &dev)); ut_asserteq(LEDST_OFF, led_get_state(dev)); ut_assertok(led_boot_blink()); @@ -171,16 +172,17 @@ static int dm_test_led_boot(struct unit_test_state *uts) return 0; } +DM_TEST(dm_test_led_boot_blink, UTF_SCAN_PDATA | UTF_SCAN_FDT); #endif #endif /* Test LED activity */ #ifdef CONFIG_LED_ACTIVITY -static int dm_test_led_boot(struct unit_test_state *uts) +static int dm_test_led_activity(struct unit_test_state *uts) { struct udevice *dev - /* options/u-boot/activity-led is set to "sandbox:red" */ + /* options/u-boot/activity-led is set to phandle to "sandbox:red" */ ut_assertok(led_get_by_label("sandbox:red", &dev)); ut_asserteq(LEDST_OFF, led_get_state(dev)); ut_assertok(led_activity_on()); @@ -190,14 +192,15 @@ static int dm_test_led_boot(struct unit_test_state *uts) return 0; } +DM_TEST(dm_test_led_activity, UTF_SCAN_PDATA | UTF_SCAN_FDT); /* Test LED activity blink fallback */ #ifndef CONFIG_LED_BLINK -static int dm_test_led_boot(struct unit_test_state *uts) +static int dm_test_led_activityt_blink(struct unit_test_state *uts) { struct udevice *dev - /* options/u-boot/activity-led is set to "sandbox:red" */ + /* options/u-boot/activity-led is set to phandle to "sandbox:red" */ ut_assertok(led_get_by_label("sandbox:red", &dev)); ut_asserteq(LEDST_OFF, led_get_state(dev)); ut_assertok(led_activity_blink()); @@ -207,5 +210,6 @@ static int dm_test_led_boot(struct unit_test_state *uts) return 0; } +DM_TEST(dm_test_led_activityt_blink, UTF_SCAN_PDATA | UTF_SCAN_FDT); #endif #endif