From patchwork Sat Nov 9 18:00: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: 2009108 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=K3HCik4b; 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 4Xm3XM49Mzz1xyp for ; Sun, 10 Nov 2024 05:01:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1D3618926A; Sat, 9 Nov 2024 19:01:14 +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="K3HCik4b"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8941389145; Sat, 9 Nov 2024 19:01:13 +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-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 F3AC689221 for ; Sat, 9 Nov 2024 19:01:10 +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-x435.google.com with SMTP id ffacd0b85a97d-37d4a5ecc44so2079476f8f.2 for ; Sat, 09 Nov 2024 10:01:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731175270; x=1731780070; 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=RNiV7CYUJQ9IVOJHSUNF5Hahqyb+2SCbGk6R9hQHDJ0=; b=K3HCik4b4belMozxOCj0gv9vMcQ4wVBs7LKhPS5MYuKQYaFiDDd/Youkk3IFwyx43a FdMY+GRnBWOxlzar1uXW+uE/BrOpHAwDz0YLZHss4e+QUbl26VmYJ3VyS5XZD0/sAVHv TGnN7bmVYlu9LnkKIQ3KMRZWTBwJ/r0mXLtSpHjYgSEe6hWQgsLyRRW8+g7boCrQwopw Lt/186lfMCs1ZvDM/J/sN7hAJbjYCOcj/A7OtlmbgAC0S8dSgYhb+QE4MLapF+Ncgb1Q 0ZZiAXRP7WCp7peAF059djpc9mEnB0c/TOEt7beaNmxvmU43MXnBXRTBKSHIAqE/zCV8 dITw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731175270; x=1731780070; 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=RNiV7CYUJQ9IVOJHSUNF5Hahqyb+2SCbGk6R9hQHDJ0=; b=FNsPvsFOPbs7QEr7TTsEEf3Eounu0LwyJXYMI2PjPGv/94ME32A4HPBGwoowdbzvyb mQbpiZV+qHsa9ol8AFYF2hMwzDgi9e6ghge7ZH3aKD3IHS9tFWBWbOciCVzIWqa8Da7W 3UmAeDfC3kRmTewZCR8SPuwbNKg8xXowC3AvrDeBLtvT0P2IaaGcobkWvp9qZEuHnajf 4si7HctTaGaaQWxowCX6cicLuOAqGzzPug7tLAQcjBJ7uQkReF+UWY9KoCQw0+LdBZf/ ezPUhYcQTGKeWDSf3SD7xt/VZYHJozLuwv4FXa2p51hP418Aij+yq1xM6kKX6pSZEc6B ciMg== X-Forwarded-Encrypted: i=1; AJvYcCU4MuYVk2X2QVCtAZKYXnxTVOqWIU4G8bWwVLZJ464claVSe793Btdi74y4gStjVyWfddNIxqA=@lists.denx.de X-Gm-Message-State: AOJu0Yw0f3D2pUB/+J4VPllabVRmP6qejChT1Dt4VruA/sFaOmMiplrf YESDQQLntFpFK5BMd6Wy23pCI2MJtZ0KKTz28hw43o7suayi2W6N X-Google-Smtp-Source: AGHT+IHazYYPN710J70vHuYqNr5cDNq/Sa/WbszOyOPgz75C7YSnXHmZnTLVC1kcRNqWBEhIDMsBxA== X-Received: by 2002:a5d:6da8:0:b0:37c:d2ac:dd7d with SMTP id ffacd0b85a97d-381f1872f17mr5873036f8f.30.1731175270018; Sat, 09 Nov 2024 10:01:10 -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-432aa73a2d8sm146095025e9.41.2024.11.09.10.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 10:01:09 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sughosh Ganu , Sean Anderson , Julien Masson , Patrick Rudolph , Yang Xiwen , Mattijs Korpershoek , Caleb Connolly , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH 1/8] dm: core: implement oftree variant of parse_phandle OPs Date: Sat, 9 Nov 2024 19:00:26 +0100 Message-ID: <20241109180038.10344-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com> References: <20241109180038.10344-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. Signed-off-by: Christian Marangi --- drivers/core/of_access.c | 61 ++++++++++++++++++++-------- drivers/core/ofnode.c | 45 +++++++++++++++++++++ include/dm/of_access.h | 86 ++++++++++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 66 ++++++++++++++++++++++++++++++ 4 files changed, 241 insertions(+), 17 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..a2136f61b7d 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -929,6 +929,39 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name, 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(&args, out_args); + } + + return 0; +} + int ofnode_count_phandle_with_args(ofnode node, const char *list_name, const char *cells_name, int cell_count) { @@ -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 Sat Nov 9 18:00: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: 2009109 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=X6FjRdQz; 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 4Xm3XX1m7Vz1xyp for ; Sun, 10 Nov 2024 05:01:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 78BC78920B; Sat, 9 Nov 2024 19:01:17 +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="X6FjRdQz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 21B8289232; Sat, 9 Nov 2024 19:01:14 +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-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 191BA89043 for ; Sat, 9 Nov 2024 19:01:12 +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-x335.google.com with SMTP id 5b1f17b1804b1-43159c9f617so25131025e9.2 for ; Sat, 09 Nov 2024 10:01:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731175271; x=1731780071; 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=Oe+mSRWmszNTJyXM2MHyLWm07qc4gVk0kuOSPQO53WY=; b=X6FjRdQzFlX5tb5om75C8qhl1QvIJM6ny58TooaUIcHL5/VoI5X0IFQ0sYMeh5azs3 aMu8gCLVtmuFOVHBNbd9wvBT5K2wePAEdSVDtuHAM9fDZQCZcFsr/UOkQeWjD4klU+CQ 1vAnRvJzsgmbMYk4V7F83QbRxGH1XudXD5GOyJg7GDtn6/EjekyOFMeHc3qUSLFYz1+n WKKGuJUUUVj+hnaTdWtAiJqGerTULvR/lxXV4Jv8nxSFJkV6qvKhkXYQxtwTaEMBeYTY 008CrNH4XISquwpDPXws2wEyyEzjMHYwDSfJ9+BiExx7AdRwXGBu+ERHyzmhN5vahAo3 f0Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731175271; x=1731780071; 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=Oe+mSRWmszNTJyXM2MHyLWm07qc4gVk0kuOSPQO53WY=; b=TLbiR8BOosSE1zbaErEba9N0OKvBp+KI5/DJ2zG10mUPVIgKzwMioDuLrOFUO810pu bb4VUoYPpASy2l27v1YvcJccQOpoo04Gj70pAdDMG/omq2fnzUNEzWxF58ba8J5o0alk t5k1yEHtSboziqLe+JE/2C3zxqnsfAOUn3uSx16GwvyY8G0ynOccjhTuNIGmSLGt9u+C aLIpyDkRruN8MHMg3tMtDohCKiW9el6IJj9x3yracIGwXGQIrztfCBTwTteLERp7iFEL nvXxv62ZptJcQpi4QzWXZFW6AuHpy6G1bChLkCoBS6H65WN3z4ND1E3d39BqD+cuVVic OC6g== X-Forwarded-Encrypted: i=1; AJvYcCX7x9Q7IN8dbi6GH+ik1DKrAOzcatd0qar55LYwcJ63H/qkiNkS6rZe4eMYLMkxxUnUP1bo8K4=@lists.denx.de X-Gm-Message-State: AOJu0Yw8xvUuFxsLvZUB9c3b+DpgiFrwUjqFXuj9TLJcBoJHOU4ymBE1 dPAwPy8KUVslSFiED/veyib7IMNGz2fFyyvcPpgarLxvw7sBVhAW X-Google-Smtp-Source: AGHT+IFnLNDNlNH6DAqNYzhdvFnUtTHswpMYTWyw/+Bj/ubtYsjDecjkBMekaFa2Ga1Er7BYfJGRMA== X-Received: by 2002:a05:6000:2d11:b0:381:f443:21e9 with SMTP id ffacd0b85a97d-381f4432614mr3674668f8f.0.1731175271296; Sat, 09 Nov 2024 10:01:11 -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-432aa73a2d8sm146095025e9.41.2024.11.09.10.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 10:01:10 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sughosh Ganu , Sean Anderson , Julien Masson , Patrick Rudolph , Yang Xiwen , Mattijs Korpershoek , Caleb Connolly , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH 2/8] test: dm: fix broken dm_test_ofnode_phandle_ot Date: Sat, 9 Nov 2024 19:00:27 +0100 Message-ID: <20241109180038.10344-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com> References: <20241109180038.10344-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. Signed-off-by: Christian Marangi --- arch/sandbox/dts/other.dts | 26 +++++++++++--- test/dm/ofnode.c | 72 +++++++++++++++++++++++++++++++------- 2 files changed, 82 insertions(+), 16 deletions(-) diff --git a/arch/sandbox/dts/other.dts b/arch/sandbox/dts/other.dts index 395a7923228..110063fa1c6 100644 --- a/arch/sandbox/dts/other.dts +++ b/arch/sandbox/dts/other.dts @@ -8,14 +8,14 @@ /dts-v1/; +#include + / { compatible = "sandbox-other"; #address-cells = <1>; #size-cells = <1>; node { - target = <&target 3 4>; - subnode { compatible = "sandbox-other2"; str-prop = "other"; @@ -25,10 +25,28 @@ }; }; + 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..5e36a228395 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -349,30 +349,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); - ret = ofnode_parse_phandle_with_args(node, "target", "#gpio-cells", 0, - 0, &args); + /* 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(2, args.args_count); - ut_asserteq(3, args.args[0]); - ut_asserteq(4, args.args[1]); + 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); + + /* 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(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 Sat Nov 9 18:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009110 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=NNPwdDVr; 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 4Xm3Xh52shz1xyp for ; Sun, 10 Nov 2024 05:01:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CC49E89274; Sat, 9 Nov 2024 19:01:17 +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="NNPwdDVr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 646C389048; Sat, 9 Nov 2024 19:01:17 +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-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (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 EBE4B89145 for ; Sat, 9 Nov 2024 19:01:13 +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-x32f.google.com with SMTP id 5b1f17b1804b1-4315eac969aso18522105e9.1 for ; Sat, 09 Nov 2024 10:01:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731175273; x=1731780073; 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=SZ+ot6RXhVf2YFVz3WJwnDv+QHsTg1lURx7UI1iVHl8=; b=NNPwdDVrh34y9V1H1wt5yr9ifB1eRLupuvxxRS1LOXaNS9gkWpNlXZWv4Nsbo15Fgm rfzc/d5QTOf7fv6Wp73owWmNXj3FfQEyyCetk5XBtX6EVfDTRdIKCkhMfSepp/f00/0I 22YneZm1VZxI4hla0rvZurXLksaujPigY+Dq2RvEUxeQFx68TjqsG8ZCiyxOZXgI3iF+ l0L9Q4onKEVizr4Q3dxOcWisAzHhjYNn6glxuvjVAFGUD7NZLtC/D9G618/oQoi4FNMb O3dYRF5UQ89d/TC0n/+rvo2abw/NhptRzYnOmIiW1v0TqA9u9CW//ToZwMoeZXOtNPdD dpNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731175273; x=1731780073; 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=SZ+ot6RXhVf2YFVz3WJwnDv+QHsTg1lURx7UI1iVHl8=; b=k4sqj+d2YmXf4Z29SZwJJh3YAX1+OmSgPUaExMOgE2YlKVShCt9jMMtdoW6jMRx/Fz kr2A3Hp40DABJDqMRSPvDNjRLK3ESYWfu11Xi4orrAV3G5ASV4v/pEWO+pju5DBwXCbA MJvZ7YloOu0GOmB/ZHpivC2FUzVE6OKXJ0gF7t4BTwI0kKlV73uN+JaZvh8+Cp4IL99S Q19D31JisrXX8gO0iLnQsurHtjw30dT3tgOfVKX5j/ce69sulodrUABjFJoRYdtGXznE PoKNDo1xllzxKc3UU1+DMY+cXf10gyS3X7aTKAeTXI5gszKCL+ORfW+bnF9DdCxhYikY iBPA== X-Forwarded-Encrypted: i=1; AJvYcCVjXxIH/9UqgZTFluPH8qH9/eW29Ne3R52bkE7Alkb/UKdk/lbg61fDFlMGWJ62FtEfDMGlR7Y=@lists.denx.de X-Gm-Message-State: AOJu0YyI/GlYggQaPoWwYRA1A3ckofv+Dc5SptcVY5rr4XAOzR2+YXbT +opXtkfkYnYmH5aXX+x35eGYJaBVUZF7SXz5xWk4FDEnF8SfmpuN X-Google-Smtp-Source: AGHT+IFLQ1jvsIn8BkcEVUlwqPsnqEAv/e/OpWiAM1k5lDPp7CEWWX/sqtH2CIKizq2xzjhb2N7drQ== X-Received: by 2002:a05:600c:3b11:b0:431:416e:2603 with SMTP id 5b1f17b1804b1-432b684f334mr70101675e9.3.1731175273125; Sat, 09 Nov 2024 10:01:13 -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-432aa73a2d8sm146095025e9.41.2024.11.09.10.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 10:01:12 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sughosh Ganu , Sean Anderson , Julien Masson , Patrick Rudolph , Yang Xiwen , Mattijs Korpershoek , Caleb Connolly , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH 3/8] dm: core: implement ofnode/tree_parse_phandle() helper Date: Sat, 9 Nov 2024 19:00:28 +0100 Message-ID: <20241109180038.10344-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com> References: <20241109180038.10344-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 --- 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 a2136f61b7d..774b428c43f 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 = offset_to_ofnode(args.node); + } + + return phandle; +} + static void ofnode_from_fdtdec_phandle_args(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 Sat Nov 9 18:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009111 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=MDXvrJkY; 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 4Xm3Xt21Hxz1xyp for ; Sun, 10 Nov 2024 05:01:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3BC1489221; Sat, 9 Nov 2024 19:01:20 +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="MDXvrJkY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D2A8A8922D; Sat, 9 Nov 2024 19:01:18 +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-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 570C6892CD for ; Sat, 9 Nov 2024 19:01:16 +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-x330.google.com with SMTP id 5b1f17b1804b1-4316e9f4a40so27369625e9.2 for ; Sat, 09 Nov 2024 10:01:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731175276; x=1731780076; 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=0I1mybIdFpOKZF3x127Qh19DI3I90HbPEpXw4hxphcA=; b=MDXvrJkYzBiURU9Nsi8dPxguMgB5zV7jvhuYsMZvuaLmCpLIROSm2PPHLEwkTBNbMV DSmAgDqoPitjj8JO1w7oXyIxkRZ+DWbPXmC7L90vs6i+6VCvhMquoRVWAYhazYFGNiY2 Ql13gJ9GLkjOO352dyAbvwp24UVYIpl54rRYiSDndY9/Y2dZD0K5SyqQkLLDp3hom5wX tpCUW4qxcbP/iQx+Qj7M6TRvqGWN/VucWVSA0lY00BXY75VokIDTBlelfxDD0OqdG+eE 9BDHkv0u4it/23P9JzzwlrGkSIWyjMTiMyKrBTpxvX4N3kITkqyTp8ievVikU15HX4Uy bM/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731175276; x=1731780076; 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=0I1mybIdFpOKZF3x127Qh19DI3I90HbPEpXw4hxphcA=; b=e6qFJS8oce+pwB7L77HEGspSXOhhTj76duSyj8IEo8PKtxvt2r0ohynQnEr3marcHd +5HWADC1KBlK7RFs9r9AL/2O4nC+tIfU4o+OyjS18hyRtTkRKlt6yl9e6jp0Q7SMUroM +Oq2K03btT91P7mEqetaTmcO/YYwEuOsgd1izUsdY6G9Rfw7NYF69ULD/mphiBELhhss z1dEB4E/j67RrOoQI0FOPaD417TUtxmuwo7QwMSSPIVeUiIPf8gCtE7HW4E4q85x/wbE K8uxtNxRwbNH+XsCm7aWY4I8wIUDwi7LytI7ZEQ1/k7cJSBRzngvT9rAzAAmqkaMi8jX w0ag== X-Forwarded-Encrypted: i=1; AJvYcCUUvUkulT8OI67lOxuCZOftpFWIo75R2Uwt3cWpTaIwwqBToKhGq7nOuXnkGPheCS+Mojwbmxs=@lists.denx.de X-Gm-Message-State: AOJu0YwFg2jE7Tl+PVelhQ04/GVxu4P92xVTNZiGVOfj605U8tYlteXy /PWqYfqsF+07YPczMqg0g8khwOU+SSBqD43cDtJzDptXXZ2zfNNc X-Google-Smtp-Source: AGHT+IFEg8/+llLZX8SMCYRZj+HJl60mst4T9dsFuIr4UkO/cQ1YM3ZAhtg+8PPclN0P/2WGsX5mRQ== X-Received: by 2002:a05:600c:870d:b0:431:4fa0:2e0b with SMTP id 5b1f17b1804b1-432b7519708mr56192675e9.28.1731175275432; Sat, 09 Nov 2024 10:01:15 -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-432aa73a2d8sm146095025e9.41.2024.11.09.10.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 10:01:14 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sughosh Ganu , Sean Anderson , Julien Masson , Patrick Rudolph , Yang Xiwen , Mattijs Korpershoek , Caleb Connolly , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH 4/8] test: dm: Expand dm_test_ofnode_phandle(_ot) with new ofnode/tree_parse_phandle Date: Sat, 9 Nov 2024 19:00:29 +0100 Message-ID: <20241109180038.10344-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com> References: <20241109180038.10344-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 --- 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 110063fa1c6..226226e3020 100644 --- a/arch/sandbox/dts/other.dts +++ b/arch/sandbox/dts/other.dts @@ -30,6 +30,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 { @@ -44,6 +45,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"; 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 5e36a228395..c05de1c54ca 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -273,15 +273,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)); @@ -345,20 +346,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)); @@ -422,6 +441,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 Sat Nov 9 18:00:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009112 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=Wd8DlQjK; 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 4Xm3Y41sMpz1xyp for ; Sun, 10 Nov 2024 05:02:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8ECCD89232; Sat, 9 Nov 2024 19:01:22 +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="Wd8DlQjK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C323D8921A; Sat, 9 Nov 2024 19:01:20 +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-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 D89A88930E for ; Sat, 9 Nov 2024 19:01:17 +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-431ac30d379so27431465e9.1 for ; Sat, 09 Nov 2024 10:01:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731175277; x=1731780077; 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=TkNJV6j4tv5OhZYy5NCEzsQ83VSVdI0VffpugCcxGvs=; b=Wd8DlQjKhD0AgeDbgEg+pndGxWCnpl+XBYF1naT2Nkm889limdCv4hdojEHprDgrUB S5D+rI38cdINeLsmBE6JxNONVIvV5vhrDuLfSoQ5mVBIx6oBWtKy/UZJRgJdDxUUyEfx rFF+41xrHFm1/JbR510dblZexvd3OmCshVpyMlFrvsV11YMlJLVIvyB6c7R+5OzumZ3j 91tFYjeuna+ZOJXJeccQwUWWS3SAMc8iSOhEacFP5e4cXJ1i025ZxCN+gnFiRFwlMwtN 4koksQ5B0wkkBsMQMoenOjn6du57kReINT7lS0l1NbJJ8uY1aHZrnGWfgmMmyCmlbQ/7 Ov0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731175277; x=1731780077; 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=TkNJV6j4tv5OhZYy5NCEzsQ83VSVdI0VffpugCcxGvs=; b=fV4HyRxVg/6xZ1qm6wGrPhpN2Jqm0VYWTg8uRdFFcP22UFsnly1yCCfDeGqcImqqdg 3szOzjb8soReGJ0mqA21vVTV3qYHXmd5CVBLujEs1L/TRhkQjyZ2N9XFdx1o6qZ5jmjo d+tlcObgmG8m0jeLyGLTrKlTQzrx7Ay9yVwTQzCVVj6Sjnqx+Y9Q8+vyrWzQyUliWwzy veySyu82zXORlXuI2rMu7KCyuWXjGNRLaqLDyBru0nUqh7KpypabN21dzGFdZ4w6yXub RS+732WLZHAn8KN5Ot/a/UmH+Ukl3Fg6r33o9WJSRLORBWMrClXOJ8z5K7cUG5RSxFUy Jtog== X-Forwarded-Encrypted: i=1; AJvYcCU/gQbV4zM0fylWqLyIWpPq+ekoBNo9x7tTT21BrhS5Uy3vkxQEEKTQYaDMjcTZHXXfCzhIOe8=@lists.denx.de X-Gm-Message-State: AOJu0YxWwetU561JoA+tORxkaiRY9/QlFfBqxYn4fQtxJk7OYCHRJ5dv P5J0w/4YpW3POO4WDMM/9LpD39e+I+f3VUwwAG2VnH/d7/nRJJo2 X-Google-Smtp-Source: AGHT+IFOdUmXkkwsSE+vFyrkLZIA08p6mL2cRBceXdT8ZtAd9qOqm1fykI5J9Wo31Tm7VCqgbIWW4w== X-Received: by 2002:a05:600c:3d0b:b0:42c:af2a:dcf4 with SMTP id 5b1f17b1804b1-432b75196e5mr58077795e9.27.1731175277198; Sat, 09 Nov 2024 10:01:17 -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-432aa73a2d8sm146095025e9.41.2024.11.09.10.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 10:01:16 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sughosh Ganu , Sean Anderson , Julien Masson , Patrick Rudolph , Yang Xiwen , Mattijs Korpershoek , Caleb Connolly , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH 5/8] dm: core: implement phandle ofnode_options helper Date: Sat, 9 Nov 2024 19:00:30 +0100 Message-ID: <20241109180038.10344-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com> References: <20241109180038.10344-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 --- 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 774b428c43f..3a96bf4f0c5 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 Sat Nov 9 18:00:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009113 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=ReGvoHdT; 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 4Xm3YH000Jz1xyr for ; Sun, 10 Nov 2024 05:02:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EED74892FB; Sat, 9 Nov 2024 19:01:22 +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="ReGvoHdT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 81976892D5; Sat, 9 Nov 2024 19:01:21 +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-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 1A26889232 for ; Sat, 9 Nov 2024 19:01:19 +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-x330.google.com with SMTP id 5b1f17b1804b1-43169902057so26275135e9.0 for ; Sat, 09 Nov 2024 10:01:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731175278; x=1731780078; 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=imxB9txU9E4kpeIEzTUjt2FpC+8k1rlSRr9nRX2IoYw=; b=ReGvoHdT8Ehmm+xjJsukCTI7jVavobaHFL/nubFMsLFrkv4rh3spQKSR4XZVvql9mz s9dpAzakQFQINjpo6pcfyaw+T4Kcc+2CJpMY68hM/HxamgPEedb+kwXSV7mVeCwnGVRL QTnaKLSxaqbsOfkmaLvJrRCoCtCL1cuq2XJHxoKLE1npYXBhSDCMeO/6xcuc0XV5Py8s AexovlHTsjLMOBCvZZLPHwjBeOIkPPVkM19KMAANqE05aBG+yNhVK3bDHBiJa0F0NV0P bJ0NRZSdhq//eBWbyMg+6r52zcgRt6Lbs9ajz4DI8BVuNLl+uADawi5cd7Eibf9/mGM/ AHXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731175278; x=1731780078; 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=imxB9txU9E4kpeIEzTUjt2FpC+8k1rlSRr9nRX2IoYw=; b=Aech3IfA0rtDjE1rVmxoocmtACgipxBV6awjRQrMQZNB6mkDtFwkQ2fzX2YYN/nw1N s/X+oQdOb9z7el4Vz+JI8G1hg+KE28jWV48VmhylDC1Lz6GWbDm2bM+w0Cvq+qu2FFBO +qCt63F+r9YaTBZL5PJ1wSMQ6oGCAZBNkMauhq0wW+unC72Y2Opu7h/+NRSulGBu7mhm Rx3FKdN1venDCrwhbINQJqwEk+vGRqKIItxsSp2ux6/0XYl0nPF7YHA8Jy7yYO8nFcCw Pi01z9JcAwVtbYZvDdFI5TKkphZhtOTz46FFWtfMpxFQRx/QVxSC6a5i7tVHvocXvpp9 e4iA== X-Forwarded-Encrypted: i=1; AJvYcCUbLzCxk5tF1GiJ+3weHpTClHucQVYdNO7na04kJJoYlOj/QcRdoMfzfoQtE5qHbHtx9h8Iits=@lists.denx.de X-Gm-Message-State: AOJu0YwcvYGQQdVhr7gIhyNA5GSjMmwobwmcDhznsMJcjdbl1Ylm+/nj LLvgfR0TDrl4BJ05GGQ0WoiyJE8ugveIqMxam4U16ojYFyxTpjYB X-Google-Smtp-Source: AGHT+IHBQqcSHyfMjGInwjwCa3xyYXu+RH5tzvHzZ9fa8g0O7ULjBAvZLILS95sL17f94GQMNg8HZQ== X-Received: by 2002:a05:600c:1f93:b0:42c:a89e:b0e6 with SMTP id 5b1f17b1804b1-432b7501c60mr58342845e9.11.1731175278399; Sat, 09 Nov 2024 10:01:18 -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-432aa73a2d8sm146095025e9.41.2024.11.09.10.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 10:01:18 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sughosh Ganu , Sean Anderson , Julien Masson , Patrick Rudolph , Yang Xiwen , Mattijs Korpershoek , Caleb Connolly , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH 6/8] test: dm: Add test for ofnode options phandle helper Date: Sat, 9 Nov 2024 19:00:31 +0100 Message-ID: <20241109180038.10344-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com> References: <20241109180038.10344-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 --- 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 c05de1c54ca..0c9d856b97a 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -697,6 +697,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")); @@ -707,6 +711,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 Sat Nov 9 18:00:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009114 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=Bh5OY+eV; 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 4Xm3YW5LhTz1xyp for ; Sun, 10 Nov 2024 05:02:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 528A789293; Sat, 9 Nov 2024 19:01:24 +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="Bh5OY+eV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 110058921A; Sat, 9 Nov 2024 19:01:23 +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-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (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 1B76E8922D for ; Sat, 9 Nov 2024 19:01:21 +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-x42a.google.com with SMTP id ffacd0b85a97d-37d55f0cf85so2134098f8f.3 for ; Sat, 09 Nov 2024 10:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731175280; x=1731780080; 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=Bh5OY+eVzH/HaHlCj7HrEEmlf7PS/u/EJcfkbhynzbt44vCVfDN6xTk9D67RxbUkCp VbhDjlZwL6cdyvRaRMH6TUjitoQoOp0ETvRr9SO7HtRBiGPKIY1Vwnm8KUy+Q7XqnvIj RUvQX1hfClbP822XWvmOjYw7s1WMz2/jp5hWgQTMN8b9o5gbVaNKs33Jq7FISzN0lyjy EPIXEezZHcZjiP/hCOd48UdqWSlgGtkjlyE/iWhZO6HGD/pBClK6Rz1Uli4Rk2v+fQrA qRZdaWv5hs3MYKB9d+Y4Y5JirI0Ool3TGzjGSEc+TfHSybb3FPAS5pSzY7+ac7rHXKWx oQDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731175280; x=1731780080; 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=ajUhfVnS5DI2hwqG2grftG+yTooKiCJrs6g9MgxqL6t7S8JQrOwTbN/NpU+koubViU kuHj4+wkb6TltuEcN86eSWu4JKnCqn6EVdySJaqvraXh7HbETRviB+Uc9wM7cb/uLQoj dROLdh4n1YvaAuHPdQzT56Zd1i9TCvwl5Dx9XI6qikjGYKa/AcOiEpqj3hLRcVWdwzhN HmpXHdH9adSC8VRKOoZ4o2/FW5zgzo11tIZ/IB3onwso8uasZaMmBMjHib5lWRZhNXBl ixyHyzjZ7N4gUDUjERuxUOtU1558gzfPyFcJbhmqL+3bbUZp/iXHa04sd/WJ0rqvlo1T tOng== X-Forwarded-Encrypted: i=1; AJvYcCXGl71cKQdTtPNZwywjdkCtDs3nVrSEo3hd1ZGTaUGiQcpwE55wPiUnqCJkJGkzjYFGKbVlj5k=@lists.denx.de X-Gm-Message-State: AOJu0YxZMI9XefqsnCVs6IzM0mlGnLcaLe0/yvPEQGrcD+LeMc/iGmtl oTPfWbun5e8TJp+mB7JI2e5GTehrTO/Lu+tCB5l7k6ScrCsXott1 X-Google-Smtp-Source: AGHT+IEsNwbHThxbAUrlZdtMgkft2OgaCppjSARiZQvYBiZ7TsDt+UyfbyOlWew+DUiXSSGh5/F8YQ== X-Received: by 2002:a5d:5f4f:0:b0:37c:d1b6:a261 with SMTP id ffacd0b85a97d-381f18487f2mr6261391f8f.59.1731175280339; Sat, 09 Nov 2024 10:01:20 -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-432aa73a2d8sm146095025e9.41.2024.11.09.10.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 10:01:19 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sughosh Ganu , Sean Anderson , Julien Masson , Patrick Rudolph , Yang Xiwen , Mattijs Korpershoek , Caleb Connolly , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH 7/8] led: update LED boot/activity to new property implementation Date: Sat, 9 Nov 2024 19:00:32 +0100 Message-ID: <20241109180038.10344-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com> References: <20241109180038.10344-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 Sat Nov 9 18:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 2009115 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=ZpFm+6+U; 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 4Xm3Ym4y1vz1xyp for ; Sun, 10 Nov 2024 05:02:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAEB18931D; Sat, 9 Nov 2024 19:01:26 +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="ZpFm+6+U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B510589313; Sat, 9 Nov 2024 19:01:24 +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-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 C03A9892D5 for ; Sat, 9 Nov 2024 19:01:22 +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-x330.google.com with SMTP id 5b1f17b1804b1-431481433bdso28000395e9.3 for ; Sat, 09 Nov 2024 10:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731175282; x=1731780082; 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=ZpFm+6+UarbhydSkiHIklRrsQS9keucEjNPPk4S+FS9EvcCOXQcv8nx2DZaMzGtTLF IdBsgwfxe7OhEYvCPQbefeMYwRDwzT7CFsodGwqsd9uRDsR7tYjxNrCDpY8FvP58LiX6 l8JQ+z2J5njJPkA9GDGgHHkT/SmBfmljdFcPQQ9SsKxYqbcIE3ws5rDBWQmcsJvBxBGS hfCHENTm3Z2FcJ7oKnl/5r3OaIzHB9Zp7r87fKYNvJamcmc+BAlc4Nmxc4luI/i/8SPf elN++rgRht7cvrqNWKv4iZRphR0XyKwMByCfa77KkwKXhOdC0ZR26VFPLz27WfoSua5M +bxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731175282; x=1731780082; 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=KkBPrkRvCKnuQEJwi+diHzDlOSWQcwNMBpYb190LnDXHEDY6W2evJGMvjo2AmZbG9l OQpDdcrq0SHPGhThpv8YwlGUFIqGAIXKFDP2zRCoVXfe47wAiKTPDonTVSL9ZNmnL6P4 IsU/xvWil8De0pKVOTi1geEQJPOqgLkr/brvNO5Kq6+ujjrfGv54MNPqWQ2kGYMBwkIn aiBsY4ZdYEGi2jcNHKg8JTDVSiuarKZbfgkZy4/SOxKedmUtHDOLqt5Bjo7OxkifRT+A lsXWBaQfzEYkGS2tvzAII/u9IdjWSalCHoxIq5IVvIYDaGQx9a12GE2hlUjH/LZVvpnU Za2Q== X-Forwarded-Encrypted: i=1; AJvYcCXx29BfK9NfjUVn2EN8jdCdELtyqpI3U/OiYxic5jdZypQ3XNmnkgPy49iaV3f0fslkvct1AzA=@lists.denx.de X-Gm-Message-State: AOJu0Yz0DB3Z0qjW/KLAgzAjQyFqPRJ7el9PlxA0MR0vIBvGgjVRwdAJ zLYJ2H8775aOAQXIlDv4yHflucr3jWC22N6lIvqPPKzSnlvjT3Hg X-Google-Smtp-Source: AGHT+IGv6Pzu8HKBDJlh/Z/VbIBX7NEQIJO6kp7detPDyzaGp1F9H0oSzyq4feSAG9c2YZZHc/G8zA== X-Received: by 2002:a05:6000:690:b0:381:b1b4:8ba1 with SMTP id ffacd0b85a97d-381f1830117mr6270655f8f.39.1731175282161; Sat, 09 Nov 2024 10:01:22 -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-432aa73a2d8sm146095025e9.41.2024.11.09.10.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Nov 2024 10:01:21 -0800 (PST) From: Christian Marangi To: Simon Glass , Tom Rini , Christian Marangi , Sughosh Ganu , Sean Anderson , Julien Masson , Patrick Rudolph , Yang Xiwen , Mattijs Korpershoek , Caleb Connolly , Mikhail Kshevetskiy , Rasmus Villemoes , Marek Vasut , Michael Polyntsov , u-boot@lists.denx.de Subject: [PATCH 8/8] test: dm: Update test for LED activity and boot Date: Sat, 9 Nov 2024 19:00:33 +0100 Message-ID: <20241109180038.10344-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com> References: <20241109180038.10344-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 --- 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