From patchwork Fri Sep 20 22:49:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988088 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=d3VK6kxW; 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 4X9YM35Xh1z1y34 for ; Sat, 21 Sep 2024 12:37:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7EE7988413; Sat, 21 Sep 2024 04:37:12 +0200 (CEST) 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="d3VK6kxW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD0F48785E; Sat, 21 Sep 2024 00:51:43 +0200 (CEST) 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,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 C0780880D8 for ; Sat, 21 Sep 2024 00:51:40 +0200 (CEST) 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-x431.google.com with SMTP id ffacd0b85a97d-3780c8d689aso1644644f8f.0 for ; Fri, 20 Sep 2024 15:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872700; x=1727477500; 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=av+MX+BpEgVKMHQYpGvG3EAXJTNNvBt8UrXp3tcQ5v8=; b=d3VK6kxWofZGOU9YQhWPvDjR7zPy7PmxK0Jm7mmJn+b48pwzhVBnq++99R7XevrqXd yvJmEOxOcFEWtNvitQF+sXok9KuDaDWOTeHEca7Rg56viGgEFXNESdTHxK1qmG39Gssh YNmSTzUCsl5bXDSMGwAiPnrn4f8T1ShM00YUn+SWIP4LUm/AObd4Rk+Kqk6xdXdVeVZj /AYM4FxIt0xj04YeByXpqdbuoQjEMxS62NClQPw06BGSV6eVnSO6iLrQaGIgWL67l+Ob tisVnJ/kCpLYbuoHTv2qeq9VgqMhvtj9ezy/D/Jp5/YR/PXCT/cFB8LgY+dUu2Yi+8DA SAIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872700; x=1727477500; 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=av+MX+BpEgVKMHQYpGvG3EAXJTNNvBt8UrXp3tcQ5v8=; b=hFVJjXPTd+qF5+p3uKRDOiUJ2+zCdm7ipfcEjHU3JAEy2hk9hAQSlx6pLgJKT7X2w1 NqcsWX6SlKaKZzXF1+zGIYDpeAr8iNgqxMR/GUKeW3k0uwzHxOvft15uhwDmGO8ddh3N XT/9k9fLeIh5yDX2XiPtGSHvJ3bZ6NaXw+fb86hxv89HlAdzowiOA01/6cOi2b8wDDA6 3PsyF+JJmN11xAeJZnn+ZVQI8NLuqAaaNhh7rvULQc4aecrmGVwoPQf/kXtJWjsnksqm iR0UgC8BOmmefNuPi8fIOamF2MEnyIhMvtVD06Hy4Uwfj1u+v3DqA4R6nw8oCqslXerJ beeg== X-Forwarded-Encrypted: i=1; AJvYcCUHVIXT54ytL/5zir/aqgdxG7hJSAdFRbT7wXg4t7ixRnCCXzY7ZT25artESZQz3AyFP+Qd4qQ=@lists.denx.de X-Gm-Message-State: AOJu0YxkGD96m+OFn2OqR+Ozyrd7lOkiz4vj5zvXSaEmVk2sHk4LO29k BlW4WBL7mSyvuhOSP4KoR5diQruJ3nKa9rBhDvo0c2YqBcN+Mh2G X-Google-Smtp-Source: AGHT+IHV25nYcZHpnMngueqKgIhx6qZj2tqTAz5Eix2iOXdpCSd53n6jvYW2let5wCGZqkgZW5/VSg== X-Received: by 2002:adf:f7c3:0:b0:374:c4e2:ee00 with SMTP id ffacd0b85a97d-37a43197e18mr2418814f8f.53.1726872700019; Fri, 20 Sep 2024 15:51:40 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:51:39 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 01/11] led: toggle LED on initial SW blink Date: Sat, 21 Sep 2024 00:49:54 +0200 Message-ID: <20240920225101.2008-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 We currently init the LED OFF when SW blink is triggered when on_state_change() is called. This can be problematic for very short period as the ON/OFF blink might never trigger. Toggle the LED (ON if OFF, OFF if ON) on initial SW blink to handle this corner case and better display a LED blink from the user. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- drivers/led/led_sw_blink.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/led/led_sw_blink.c b/drivers/led/led_sw_blink.c index 9e36edbee47..9d9820720c6 100644 --- a/drivers/led/led_sw_blink.c +++ b/drivers/led/led_sw_blink.c @@ -103,8 +103,16 @@ bool led_sw_on_state_change(struct udevice *dev, enum led_state_t state) return false; if (state == LEDST_BLINK) { + struct led_ops *ops = led_get_ops(dev); + enum led_state_t curr_state = led_get_state(dev); + + curr_state = ops->get_state(dev); + /* toggle led initially */ + ops->set_state(dev, curr_state == LEDST_ON ? LEDST_OFF : + LEDST_ON); /* start blinking on next led_sw_blink() call */ - sw_blink->state = LED_SW_BLINK_ST_OFF; + sw_blink->state = curr_state == LEDST_ON ? LED_SW_BLINK_ST_OFF : + LED_SW_BLINK_ST_ON; return true; } From patchwork Fri Sep 20 22:49:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988089 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=KcVXHRDO; 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 4X9YM83dRkz1y34 for ; Sat, 21 Sep 2024 12:37:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DC860884D2; Sat, 21 Sep 2024 04:37:12 +0200 (CEST) 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="KcVXHRDO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E7A3882EF; Sat, 21 Sep 2024 00:51:46 +0200 (CEST) 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,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 ED686880A5 for ; Sat, 21 Sep 2024 00:51:43 +0200 (CEST) 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-42cb2191107so20447475e9.1 for ; Fri, 20 Sep 2024 15:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872703; x=1727477503; 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=VRN0d6KfaqLDmqpqJCnUxWCRaEWyqozsT4FxZ4aAWj0=; b=KcVXHRDOxsEguD57WYPLpjqDt+BZ4jwmdpjAjhhei+exrgy2Njg1UF+/Nb7c2k5Z0J Wv/GZ5oH/DkaLI/5Qsoi7peIwBC3NKeYGXR0QslW1HApPNux0GpqRFz0pRhirRjpTVK/ rcoVzKs+O6B2kfZZBJgOtsas/dsKHhLCnOI1uRBtzIm1PFp+zzKLTUXiRnc2WYV+9zr/ 2Ncz3DEkaxOhiLy2yaDIVr5h6NBIaXG2ngfzG1pDPaAJTmCd8bQorcsCa9Yy9ZUf9edu FDkZZRR3QSDjzLpRiLnMrIh1A5D14lUCC9RSl5ShYJiB9juRF2lfXA8ar162gKnDDkIg ERZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872703; x=1727477503; 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=VRN0d6KfaqLDmqpqJCnUxWCRaEWyqozsT4FxZ4aAWj0=; b=ZSZl1Giy2dFUQ7zOopvDeKFaSujSdMx6zK5PkDfirIAEjEZaf+85dqPs+6sGty9W6F nGZ4E2PPCzJP/K/jxqp3z7JfuWaI3yAgg61CX3gKI6qSF41j8x/w27yL9/FpYwxUVRnv RS7XgrTL29anRwbIjZBg5mkohaY78Q3foeXSOQAHPJr78hbKdpSQqP7rc7946A7AZQAb KgX12Qf9OHzmEjsHnLhbRJtrmxDjODlHKEoL3ZmnYlwG9iZpy2Y4vw4D93ULApSzkcnV xFn42YIxpeJQ3xejQxSB2wrC0MtgCGeF2G+DDevnqhg7ZytR3/veqioZjvxJNNky9drq Jx2g== X-Forwarded-Encrypted: i=1; AJvYcCVX9qUz/Cv7rqBdg7WYATINoxbdTRatne9bAxJZemlGq5vLF+J88kQ71GGLM6loBK8d+DjD2GQ=@lists.denx.de X-Gm-Message-State: AOJu0YzcPVHWXfTf5CshoBbu8OI2fOGF6V09wOBDnBmeEDCxYhl+/+DJ N15qdwwFKMM9cSaPwWCRX2nlMf/irjkOWysa47oOj1TESbP9E0XQ X-Google-Smtp-Source: AGHT+IEXnIHgmTjiwHQeVGUYhqIeyYgeiCaYkRnfxtmz4m+5ZSX5tBLFmzcaK2D0olGjrTD2jL5JuA== X-Received: by 2002:a5d:4fc4:0:b0:374:c4c4:efa5 with SMTP id ffacd0b85a97d-37a431a6f79mr2349185f8f.53.1726872703128; Fri, 20 Sep 2024 15:51:43 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:51:42 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 02/11] dm: core: implement ofnode_options helpers Date: Sat, 21 Sep 2024 00:49:55 +0200 Message-ID: <20240920225101.2008-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 helpers to read options in /options/u-boot to adapt to the new way to declare options as described in [0]. [0] dtschema/schemas/options/u-boot.yaml Signed-off-by: Christian Marangi --- drivers/core/ofnode.c | 33 +++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 4d563b47a5a..4404c4f4bab 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1734,6 +1734,39 @@ const char *ofnode_conf_read_str(const char *prop_name) return ofnode_read_string(node, prop_name); } +bool ofnode_options_read_bool(const char *prop_name) +{ + ofnode uboot; + + uboot = ofnode_path("/options/u-boot"); + if (!ofnode_valid(uboot)) + return false; + + return ofnode_read_bool(uboot, prop_name); +} + +int ofnode_options_read_int(const char *prop_name, int default_val) +{ + ofnode uboot; + + uboot = ofnode_path("/options/u-boot"); + if (!ofnode_valid(uboot)) + return default_val; + + return ofnode_read_u32_default(uboot, prop_name, default_val); +} + +const char *ofnode_options_read_str(const char *prop_name) +{ + ofnode uboot; + + uboot = ofnode_path("/options/u-boot"); + if (!ofnode_valid(uboot)) + return NULL; + + return ofnode_read_string(uboot, prop_name); +} + 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 5795115c490..0787758926f 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1587,6 +1587,47 @@ int ofnode_conf_read_int(const char *prop_name, int default_val); */ const char *ofnode_conf_read_str(const char *prop_name); +/** + * ofnode_options_read_bool() - Read a boolean value 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 + * Return: true, if it exists, false if not + */ +bool ofnode_options_read_bool(const char *prop_name); + +/** + * ofnode_options_read_int() - Read an integer value from the U-Boot options + * + * This reads a property from the /options/u-boot/ node of the devicetree. + * + * See dtschema/schemas/options/u-boot.yaml in dt-schema project for bindings + * + * @prop_name: property name to look up + * @default_val: default value to return if the property is not found + * Return: integer value, if found, or @default_val if not + */ +int ofnode_options_read_int(const char *prop_name, int default_val); + +/** + * ofnode_options_read_str() - Read a string value 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 + * Return: string value, if found, or NULL if not + */ +const char *ofnode_options_read_str(const char *prop_name); + /** * ofnode_read_bootscript_address() - Read bootscr-address or bootscr-ram-offset * From patchwork Fri Sep 20 22:49:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988090 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=CV2a/L3S; 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 4X9YML0d7Fz1y34 for ; Sat, 21 Sep 2024 12:37:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4EE208855C; Sat, 21 Sep 2024 04:37:13 +0200 (CEST) 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="CV2a/L3S"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B27B487E30; Sat, 21 Sep 2024 00:51:49 +0200 (CEST) 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,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 EE6D78785E for ; Sat, 21 Sep 2024 00:51:46 +0200 (CEST) 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-42cc8782869so22602655e9.2 for ; Fri, 20 Sep 2024 15:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872706; x=1727477506; 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=tOKm760l90Mt+ORMaiEyashhKP3/BOnbIoQ5uWV6QQ8=; b=CV2a/L3SB2K45/RT3kSQnN+Pmcje4QnChC4VfDs1ze7jYMSZuPGK5xlvA0pB6NQ1tk ZsUQAXZJbCOMC/x2Q3shRtZV2eFE9wUBvwSU69N5ChnwuU9GlITnwBB9JJQuOTAQN8Do Y2Tv6t3iYB9u8XB1kiOgU4OUcr0MfqVBaJZAsYRUUEkLQz+dX+pSTx+lN7cP6oUSBVCN BPJlvHqmVr6dMk+60cr7HPCY7WnD4kvn9LuZjIarciep0UwMdlKlOMN9y3RqdXP8OLk7 7+qclj3Ui7LPZW6vtfGegPvEnF9rfkKPXUb5oW6KNqiqxsgUcJW/6STcn9Ioj0ShLxKd FMtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872706; x=1727477506; 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=tOKm760l90Mt+ORMaiEyashhKP3/BOnbIoQ5uWV6QQ8=; b=b/nGM6r2skFvp+53UXIDeNrXamu1ukHSmuKGqnPd6wz4iePUIhPTjJJw0YYwUqtnAB 6qbxRzttsXz7Xe6aECtGdooNmkDnNz9g30G4EilswDzGAKBRROzMJ/9Oco6Li+09iFPQ Ycp0aMa1gbOqZBLMzUrrlU7vqLLy04c3Hhfvjfn51h+JUtXrr83/+/ifxNSkw/InCtWV x8lyUKhoQ2oiGyRoHz7HhSqYLhh/fADMwq4K1B91la4L3U938wTDnGQCBPATigqOlWyX GXBpcZ6ovRSyaahuwQMrmD0hbnMgfvgwA2GViPwZqe+z/KkCfmC2xqTWM6eBCkKVyPKC OVuQ== X-Forwarded-Encrypted: i=1; AJvYcCUarZl7NZ/ZbXdzUgFHMxD9Uo3+wMPXo9U/jYLMp3byzcfcdlPPBf7rxgybzlABoe9lM3JLsGA=@lists.denx.de X-Gm-Message-State: AOJu0YxihRG7U4fIzO580Q6IqDmGemy9aC5k5gDzt7G5JFYz+WwrFxVm M45YrEta7zb33yAWiadjB6s1riMO9sVUPlYqDj2/yFezI1e0CkL2aEGpzT9z X-Google-Smtp-Source: AGHT+IFLgYGmlhfGKfReIW+dChtHiOdC//V1a9T0TyDNmmuTWMnpgOHn0+zIGu+nN/Yc4vI/2OaL2A== X-Received: by 2002:a05:600c:8715:b0:426:66a2:b200 with SMTP id 5b1f17b1804b1-42e7ab3eb57mr31610325e9.0.1726872706165; Fri, 20 Sep 2024 15:51:46 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:51:45 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 03/11] led: implement LED boot API Date: Sat, 21 Sep 2024 00:49:56 +0200 Message-ID: <20240920225101.2008-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 LED boot API to signal correct boot of the system. led_boot_on/off/blink() are introduced to turn ON, OFF and BLINK the designated boot LED. New Kconfig is introduced, CONFIG_LED_BOOT to enable the feature. This makes use of the /options/u-boot property "boot-led" to the define the boot LED. It's also introduced a new /options/u-boot property "boot-led-period" to define the default period when the LED is set to blink mode. If "boot-led-period" is not defined, the value of 250 (ms) is used by default. If CONFIG_LED_BLINK or CONFIG_LED_SW_BLINK is not enabled, led_boot_blink call will fallback to simple LED ON. To cache the data we repurpose the now unused led_uc_priv for storage of global LED uclass info. Signed-off-by: Christian Marangi --- drivers/led/Kconfig | 7 +++ drivers/led/led-uclass.c | 100 +++++++++++++++++++++++++++++++++++++++ include/led.h | 56 +++++++++++++++++++++- 3 files changed, 161 insertions(+), 2 deletions(-) diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index bee74b25751..6149cfa02b8 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -9,6 +9,13 @@ config LED can provide access to board-specific LEDs. Use of the device tree for configuration is encouraged. +config LED_BOOT + bool "Enable LED boot support" + help + Enable LED boot support. + + LED boot is a specific LED assigned to signal boot operation status. + config LED_BCM6328 bool "LED Support for BCM6328" depends on LED && ARCH_BMIPS diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 199d68bc25a..c5b560982b0 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -94,17 +94,101 @@ int led_set_period(struct udevice *dev, int period_ms) return -ENOSYS; } +#ifdef CONFIG_LED_BOOT +int led_boot_on(void) +{ + struct uclass *uc = uclass_find(UCLASS_LED); + struct led_uc_priv *priv; + struct udevice *dev; + + if (!uc) + return -ENOENT; + + priv = uclass_get_priv(uc); + if (!priv->boot_led_dev || + uclass_get_device_tail(priv->boot_led_dev, 0, &dev)) { + printf("Failed to get boot LED %s\n", + priv->boot_led_label); + return -EINVAL; + } + + return led_set_state(dev, LEDST_ON); +} + +int led_boot_off(void) +{ + struct uclass *uc = uclass_find(UCLASS_LED); + struct led_uc_priv *priv; + struct udevice *dev; + + if (!uc) + return -ENOENT; + + priv = uclass_get_priv(uc); + if (!priv->boot_led_dev || + uclass_get_device_tail(priv->boot_led_dev, 0, &dev)) { + printf("Failed to get boot LED %s\n", + priv->boot_led_label); + return -EINVAL; + } + + return led_set_state(dev, LEDST_OFF); +} + +#if defined(CONFIG_LED_BLINK) || defined(CONFIG_LED_SW_BLINK) +int led_boot_blink(void) +{ + struct uclass *uc = uclass_find(UCLASS_LED); + struct led_uc_priv *priv; + struct udevice *dev; + int ret; + + if (!uc) + return -ENOENT; + + priv = uclass_get_priv(uc); + if (!priv->boot_led_dev || + uclass_get_device_tail(priv->boot_led_dev, 0, &dev)) { + printf("Failed to get boot LED %s\n", + priv->boot_led_label); + return -EINVAL; + } + + ret = led_set_period(dev, priv->boot_led_period); + if (ret) { + if (ret != -ENOSYS) + return ret; + + /* fallback to ON with no set_period and no SW_BLINK */ + return led_set_state(dev, LEDST_ON); + } + + return led_set_state(dev, LEDST_BLINK); +} +#endif +#endif + static int led_post_bind(struct udevice *dev) { struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); const char *default_state; +#ifdef CONFIG_LED_BOOT + struct led_uc_priv *priv = uclass_get_priv(dev->uclass); +#endif + 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)); +#ifdef CONFIG_LED_BOOT + /* check if we are binding boot LED and assign it */ + if (!strcmp(priv->boot_led_label, uc_plat->label)) + priv->boot_led_dev = dev; +#endif + uc_plat->default_state = LEDST_COUNT; default_state = dev_read_string(dev, "default-state"); @@ -158,10 +242,26 @@ static int led_post_probe(struct udevice *dev) return ret; } +#ifdef CONFIG_LED_BOOT +static int led_init(struct uclass *uc) +{ + struct led_uc_priv *priv = uclass_get_priv(uc); + + priv->boot_led_label = ofnode_options_read_str("boot-led"); + priv->boot_led_period = ofnode_options_read_int("boot-led-period", 250); + + return 0; +} +#endif + UCLASS_DRIVER(led) = { .id = UCLASS_LED, .name = "led", .per_device_plat_auto = sizeof(struct led_uc_plat), .post_bind = led_post_bind, .post_probe = led_post_probe, +#ifdef CONFIG_LED_BOOT + .init = led_init, + .priv_auto = sizeof(struct led_uc_priv), +#endif }; diff --git a/include/led.h b/include/led.h index 99f93c5ef86..ca495217777 100644 --- a/include/led.h +++ b/include/led.h @@ -9,6 +9,7 @@ #include #include +#include struct udevice; @@ -52,10 +53,16 @@ struct led_uc_plat { /** * struct led_uc_priv - Private data the uclass stores about each device * - * @period_ms: Flash period in milliseconds + * @boot_led_label: Boot LED label + * @boot_led_dev: Boot LED dev + * @boot_led_period: Boot LED blink period */ struct led_uc_priv { - int period_ms; +#ifdef CONFIG_LED_BOOT + const char *boot_led_label; + struct udevice *boot_led_dev; + int boot_led_period; +#endif }; struct led_ops { @@ -141,4 +148,49 @@ int led_sw_set_period(struct udevice *dev, int period_ms); bool led_sw_is_blinking(struct udevice *dev); bool led_sw_on_state_change(struct udevice *dev, enum led_state_t state); +#ifdef CONFIG_LED_BOOT + +/** + * led_boot_on() - turn ON the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +int led_boot_on(void); + +/** + * led_boot_off() - turn OFF the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +int led_boot_off(void); + +#if defined(CONFIG_LED_BLINK) || defined(CONFIG_LED_SW_BLINK) +/** + * led_boot_blink() - turn ON the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +int led_boot_blink(void); + +#else +/* If LED BLINK is not supported/enabled, fallback to LED ON */ +#define led_boot_blink led_boot_on +#endif +#else +static inline int led_boot_on(void) +{ + return -ENOSYS; +} + +static inline int led_boot_off(void) +{ + return -ENOSYS; +} + +static inline int led_boot_blink(void) +{ + return -ENOSYS; +} +#endif + #endif From patchwork Fri Sep 20 22:49:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988091 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=XcZyo6w0; 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 4X9YMX4K8tz1y34 for ; Sat, 21 Sep 2024 12:38:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B428488641; Sat, 21 Sep 2024 04:37:13 +0200 (CEST) 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="XcZyo6w0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 41E488785E; Sat, 21 Sep 2024 00:51:52 +0200 (CEST) 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,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 5189E8785E for ; Sat, 21 Sep 2024 00:51:50 +0200 (CEST) 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-3787f30d892so1525858f8f.0 for ; Fri, 20 Sep 2024 15:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872710; x=1727477510; 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=aSDQmEUlpD2H4DUe5lM8yl+oX9bOA/Q8yS2GRmz3Xpw=; b=XcZyo6w0xKxIs6zS74E/cynXq1/m3rzr2SjLseQx1tqMOe57SZUtsGsebv3Pun15VG qryp6Z7QtfoGhZiHdaVwNpIM4XXx8mIsDYxOQy2a+hSZLBE0+fR7zNnjdzfEsD0x5EKv N/i/5P4fKYwgLQ++LMbn5fVVJ/hrOKnFRkIjigoJkTDUebnKZiLlErkU/VCoYlnWkkDz /8I/GZNc5UzLvbdojS1DoK2a7/4AKn2QAJUBNTS05Rg5kSNwgloqgmiJNFW/PKOigEcx IrwoA0TeVc3oUIlij7j05wu0HiS9RysV3J9PfMr371GPX47rDkCnkHvkwD0yBhlzlgcD JBqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872710; x=1727477510; 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=aSDQmEUlpD2H4DUe5lM8yl+oX9bOA/Q8yS2GRmz3Xpw=; b=qcfIaPwz+ID6hub1diCTpNW5Lpo8tpF6g7cz6TEpBzxXpL283lvNtMP5ZF04xKJt8l 8R7LATtwpmNjgpfPmOuKzvRPMszfrETpXGoHcjs1GubZgLylrKFdWi+3sDW5xsr/Jfio DLpIAHGExVSPx/MmYmrc/Z8hxp3h5Jk02EdgNgJ2GaV5/iKc9WPW+4ITMnWBYgvTJGU0 3sAI8EZDsm/IJShYve8RHFIXasetx8/0QhCrPLI6ie+iTUMx7GHPEevV1dcd7PI/Mlhq DOjFh1p7vYwQuF1YtmRTg8m4riLJWuA3CgTMPDJOcoYB/cdwJ8CAHq74EVi6xcEZbIQl XjWQ== X-Forwarded-Encrypted: i=1; AJvYcCUJJLoC+oBKj84m9YEu3Y57PEnCa56c8H7oyKGOMz50DwNmkwaxgu1sKduS29t7E2JKfJGq6XM=@lists.denx.de X-Gm-Message-State: AOJu0YziT8cMregyn4xA7nxhBcCHTjWcfDhj2fHtkVMygFOkAUU5CyV2 u8t0FKSoZTPbjm0bavhPjHE4gsnwDw4sEVi0wF49QuizuZa8urO5 X-Google-Smtp-Source: AGHT+IG6uf7GpUrY1J/g3OK7QlZm5f8yH+T+93pEDgm/8mxJKJWMirdegbm6IEggEXRvcHk1M6B6qg== X-Received: by 2002:adf:f688:0:b0:36b:c126:fe6d with SMTP id ffacd0b85a97d-37a4227839emr2466851f8f.24.1726872709392; Fri, 20 Sep 2024 15:51:49 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:51:48 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 04/11] common: board_r: rework BOOT LED handling Date: Sat, 21 Sep 2024 00:49:57 +0200 Message-ID: <20240920225101.2008-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 Rework BOOT LED handling. There is currently one legacy implementation for BOOT LED from Status Led API. This work on ancient implementation used by BOOTP by setting the LED to Blink on boot and to turn it OFF when the firmware was correctly received by network. Now that we new LED implementation have support for LED boot, rework this by also set the new BOOT LED to blink and also set it to ON before entering main loop to confirm successful boot. Signed-off-by: Christian Marangi --- common/board_r.c | 28 ++++++++++++++++++++-------- include/status_led.h | 13 +++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index d4ba245ac69..c3f8dd5d4ee 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -459,17 +460,28 @@ static int initr_malloc_bootparams(void) } #endif -#if defined(CONFIG_LED_STATUS) static int initr_status_led(void) { -#if defined(CONFIG_LED_STATUS_BOOT) - status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_BLINKING); -#else status_led_init(); -#endif + + return 0; +} + +static int initr_boot_led_blink(void) +{ + status_led_boot_blink(); + + led_boot_blink(); + + return 0; +} + +static int initr_boot_led_on(void) +{ + led_boot_on(); + return 0; } -#endif #ifdef CONFIG_CMD_NET static int initr_net(void) @@ -713,9 +725,8 @@ static init_fnc_t init_sequence_r[] = { #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K) timer_init, /* initialize timer */ #endif -#if defined(CONFIG_LED_STATUS) initr_status_led, -#endif + initr_boot_led_blink, /* PPC has a udelay(20) here dating from 2002. Why? */ #ifdef CONFIG_BOARD_LATE_INIT board_late_init, @@ -738,6 +749,7 @@ static init_fnc_t init_sequence_r[] = { #if defined(CFG_PRAM) initr_mem, #endif + initr_boot_led_on, run_main_loop, }; diff --git a/include/status_led.h b/include/status_led.h index 6707ab1d29d..1282022253e 100644 --- a/include/status_led.h +++ b/include/status_led.h @@ -39,6 +39,13 @@ void status_led_init(void); void status_led_tick(unsigned long timestamp); void status_led_set(int led, int state); +static inline void status_led_boot_blink(void) +{ +#ifdef CONFIG_LED_STATUS_BOOT_ENABLE + status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_BLINKING); +#endif +} + /***** MVS v1 **********************************************************/ #if (defined(CONFIG_MVS) && CONFIG_MVS < 2) # define STATUS_LED_PAR im_ioport.iop_pdpar @@ -72,6 +79,12 @@ void __led_blink(led_id_t mask, int freq); # include #endif +#else + +static inline void status_led_init(void) { } +static inline void status_led_set(int led, int state) { } +static inline void status_led_boot_blink(void) { } + #endif /* CONFIG_LED_STATUS */ /* From patchwork Fri Sep 20 22:49:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988092 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=ZHaKn6BR; 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 4X9YMl2vjyz1y34 for ; Sat, 21 Sep 2024 12:38:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1E8A088703; Sat, 21 Sep 2024 04:37:14 +0200 (CEST) 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="ZHaKn6BR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51E4987E30; Sat, 21 Sep 2024 00:51:56 +0200 (CEST) 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,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 B76BD880A5 for ; Sat, 21 Sep 2024 00:51:53 +0200 (CEST) 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-378f600e090so1490187f8f.3 for ; Fri, 20 Sep 2024 15:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872713; x=1727477513; 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=O+zHjwIvLfrTJj9POeemFP/0SMsykXjxdjynOoKsQL8=; b=ZHaKn6BRxgUPx/D2mVIARnp5ZqlXTRd29TkJ1flFotCbG3SADg9NGhAA6WS2KH6hA0 xPqWqojixFAvNPm5RPjidjcWuTRoJLciYthtMoBPI2YmAZ7qcxjAGQW56H+6NubyLXcM ZIlhTCz1N7cB6Gp8VuQc+cgrijzSftxIkh3248rNW4Fz6y1jHp9AgiDNzOi/uhbiR1Ay ldBfLC0in69wWXIfpU1PAdZq15IanT5HvbfDSLFD6ZSjJb88pQLOHfbbCYUIzJJ2qzBk rod77tmB8j+6g/zQw9Cydliyla7acEbU1M6pvPpnN6gq6iEueoyIFd3A5eqh/44SOdy/ NDAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872713; x=1727477513; 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=O+zHjwIvLfrTJj9POeemFP/0SMsykXjxdjynOoKsQL8=; b=lU+3+4Apt3pVGW6UA9JEV8wii+sCFTI5Hg546cuSiGKGtd4+vc49u8sQJmfB7Oa7M3 2Tn1YUafwkvGj1KixhURYheKFcVXQrT04KmYhg6d1Q3Sf9oq4onv34Gu+kuH03NFU6ak Bc9q3DVyyyqiuAPNsvGUFptJIdoQhF8/dxdU34o6ny+TV8U9z80DVOTTWDtEUdl/deov tZMakTkS0c0+FmajMk2Bp/w3jdjOxbST4Vf9qyg0ooHoDVDzpoM0wppIZmAzrHupRRN4 a//QJIizjOTxMZuR04iMUskoybxS7JSAGuwPwNc+pX7znx6RopmgWJUIQF7OGwjSgd1Y 2hVQ== X-Forwarded-Encrypted: i=1; AJvYcCWt3LqSVlElK3qIRnLaiAfI4mF8+cdnHNMeK9vZzdpMaAtOoEtLrmbZAne5VDQPB38+2blOYpE=@lists.denx.de X-Gm-Message-State: AOJu0YxmG5fPoPuFTRbr6fqv9h0qZuJxFKN89x2dda/LayYgct1NEesS zBUuxJ1weAxB6/WSfjvx3tb+k2o73UKqQwhy8xQ1Vl5iK9z1IbXL X-Google-Smtp-Source: AGHT+IGQgXd106PdD75AJs6k1hs7QHKOKjaPx0QbjhnuvjIiGnv8Fm01dj74ownYhsfGzgq7tGgONQ== X-Received: by 2002:adf:ae51:0:b0:374:c847:85e with SMTP id ffacd0b85a97d-37a431319e8mr1986777f8f.13.1726872713027; Fri, 20 Sep 2024 15:51:53 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:51:51 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 05/11] led: implement LED activity API Date: Sat, 21 Sep 2024 00:49:58 +0200 Message-ID: <20240920225101.2008-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 LED activity API similar to BOOT LED API. Usual activity might be a file transfer with TFTP, a flash write... User of this API will call led_activity_on/off/blink() to signal these kind of activity. New Kconfig is implemented similar to BOOT LED, LED_ACTIVITY to enable support for it. It's introduced a new /options/u-boot property "activity-led" and "activity-led-period" to define the activity LED label and the default period when the activity LED is set to blink mode. If "activity-led-period" is not defined, the value of 250 (ms) is used by default. If CONFIG_LED_BLINK or CONFIG_LED_SW_BLINK is not enabled, led_boot_blink call will fallback to simple LED ON. Signed-off-by: Christian Marangi --- drivers/led/Kconfig | 8 ++++ drivers/led/led-uclass.c | 94 ++++++++++++++++++++++++++++++++++++++-- include/led.h | 52 ++++++++++++++++++++++ 3 files changed, 151 insertions(+), 3 deletions(-) diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index 6149cfa02b8..f0434f247a4 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -16,6 +16,14 @@ config LED_BOOT LED boot is a specific LED assigned to signal boot operation status. +config LED_ACTIVITY + bool "Enable LED activity support" + help + Enable LED activity support. + + LED activity is a specific LED assigned to signal activity operation + like file trasnfer, flash write/erase... + config LED_BCM6328 bool "LED Support for BCM6328" depends on LED && ARCH_BMIPS diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index c5b560982b0..c87fc7540c7 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -168,12 +168,86 @@ int led_boot_blink(void) #endif #endif +#ifdef CONFIG_LED_ACTIVITY +int led_activity_on(void) +{ + struct uclass *uc = uclass_find(UCLASS_LED); + struct led_uc_priv *priv; + struct udevice *dev; + + if (!uc) + return -ENOENT; + + priv = uclass_get_priv(uc); + if (!priv->activity_led_dev || + uclass_get_device_tail(priv->activity_led_dev, 0, &dev)) { + printf("Failed to get activity LED %s\n", + priv->activity_led_label); + return -EINVAL; + } + + return led_set_state(dev, LEDST_ON); +} + +int led_activity_off(void) +{ + struct uclass *uc = uclass_find(UCLASS_LED); + struct led_uc_priv *priv; + struct udevice *dev; + + if (!uc) + return -ENOENT; + + priv = uclass_get_priv(uc); + if (!priv->activity_led_dev || + uclass_get_device_tail(priv->activity_led_dev, 0, &dev)) { + printf("Failed to get activity LED %s\n", + priv->activity_led_label); + return -EINVAL; + } + + return led_set_state(dev, LEDST_OFF); +} + +#if defined(CONFIG_LED_BLINK) || defined(CONFIG_LED_SW_BLINK) +int led_activity_blink(void) +{ + struct uclass *uc = uclass_find(UCLASS_LED); + struct led_uc_priv *priv; + struct udevice *dev; + int ret; + + if (!uc) + return -ENOENT; + + priv = uclass_get_priv(uc); + if (!priv->activity_led_dev || + uclass_get_device_tail(priv->activity_led_dev, 0, &dev)) { + printf("Failed to get activity LED %s\n", + priv->activity_led_label); + return -EINVAL; + } + + ret = led_set_period(dev, priv->activity_led_period); + if (ret) { + if (ret != -ENOSYS) + return ret; + + /* fallback to ON with no set_period and no SW_BLINK */ + return led_set_state(dev, LEDST_ON); + } + + return led_set_state(dev, LEDST_BLINK); +} +#endif +#endif + static int led_post_bind(struct udevice *dev) { struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); const char *default_state; -#ifdef CONFIG_LED_BOOT +#if defined(CONFIG_LED_BOOT) || defined(CONFIG_LED_ACTIVITY) struct led_uc_priv *priv = uclass_get_priv(dev->uclass); #endif @@ -189,6 +263,12 @@ static int led_post_bind(struct udevice *dev) priv->boot_led_dev = dev; #endif +#ifdef CONFIG_LED_ACTIVITY + /* check if we are binding activity LED and assign it */ + if (!strcmp(priv->activity_led_label, uc_plat->label)) + priv->activity_led_dev = dev; +#endif + uc_plat->default_state = LEDST_COUNT; default_state = dev_read_string(dev, "default-state"); @@ -242,13 +322,21 @@ static int led_post_probe(struct udevice *dev) return ret; } -#ifdef CONFIG_LED_BOOT +#if defined(CONFIG_LED_BOOT) || defined(CONFIG_LED_ACTIVITY) static int led_init(struct uclass *uc) { struct led_uc_priv *priv = uclass_get_priv(uc); +#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); +#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", + 250); +#endif return 0; } @@ -260,7 +348,7 @@ UCLASS_DRIVER(led) = { .per_device_plat_auto = sizeof(struct led_uc_plat), .post_bind = led_post_bind, .post_probe = led_post_probe, -#ifdef CONFIG_LED_BOOT +#if defined(CONFIG_LED_BOOT) || defined(CONFIG_LED_ACTIVITY) .init = led_init, .priv_auto = sizeof(struct led_uc_priv), #endif diff --git a/include/led.h b/include/led.h index ca495217777..bba8c0009ca 100644 --- a/include/led.h +++ b/include/led.h @@ -54,8 +54,11 @@ struct led_uc_plat { * struct led_uc_priv - Private data the uclass stores about each device * * @boot_led_label: Boot LED label + * @activity_led_label: Activity LED label * @boot_led_dev: Boot LED dev + * @activity_led_dev: Activity LED dev * @boot_led_period: Boot LED blink period + * @activity_led_period: Activity LED blink period */ struct led_uc_priv { #ifdef CONFIG_LED_BOOT @@ -63,6 +66,11 @@ struct led_uc_priv { struct udevice *boot_led_dev; int boot_led_period; #endif +#ifdef CONFIG_LED_ACTIVITY + const char *activity_led_label; + struct udevice *activity_led_dev; + int activity_led_period; +#endif }; struct led_ops { @@ -193,4 +201,48 @@ static inline int led_boot_blink(void) } #endif +#ifdef CONFIG_LED_ACTIVITY + +/** + * led_activity_on() - turn ON the designated LED for activity + * + * Return: 0 if OK, -ve on error + */ +int led_activity_on(void); + +/** + * led_activity_off() - turn OFF the designated LED for activity + * + * Return: 0 if OK, -ve on error + */ +int led_activity_off(void); + +#if defined(CONFIG_LED_BLINK) || defined(CONFIG_LED_SW_BLINK) +/** + * led_activity_blink() - turn ON the designated LED for activity + * + * Return: 0 if OK, -ve on error + */ +int led_activity_blink(void); +#else +/* If LED BLINK is not supported/enabled, fallback to LED ON */ +#define led_activity_blink led_activity_on +#endif +#else +static inline int led_activity_on(void) +{ + return -ENOSYS; +} + +static inline int led_activity_off(void) +{ + return -ENOSYS; +} + +static inline int led_activity_blink(void) +{ + return -ENOSYS; +} +#endif + #endif From patchwork Fri Sep 20 22:49:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988093 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=I5fs8OsH; 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 4X9YMx38xYz1y34 for ; Sat, 21 Sep 2024 12:38:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C784887FA; Sat, 21 Sep 2024 04:37:14 +0200 (CEST) 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="I5fs8OsH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF1278839A; Sat, 21 Sep 2024 00:51:58 +0200 (CEST) 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,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 E97F787E30 for ; Sat, 21 Sep 2024 00:51:56 +0200 (CEST) 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-x334.google.com with SMTP id 5b1f17b1804b1-42cb9a0c300so21606485e9.0 for ; Fri, 20 Sep 2024 15:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872716; x=1727477516; 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=NzTOuwtkIiYwClWTiai050AtuXNXIOHo/YChZTv1iL0=; b=I5fs8OsH8PlKWplA4OQZ39lr8j9/bdqbQpGrF6H9Mwpmpgq+gvoHJikkEhbuT3FU7t zP09TSNRoo7qQL0ZUAVkTwYJEtQKnmZRfejij/uvAF4UbcCj1QjFQsYUnqLsiHqH+rUm Z85gQrh7Hm7995HTZIvxv1aCJxB3Uz7GU8s+bSm+GmhgHoymY3p552erWJHVY3nBEmaJ QnMj8jXbpr3iVTKBSHP8AQUIUFfGAYhS+yNyoenrtTp52QPD6N23Hu56oSj2wExLFAk6 NACQuBSG8azk/Xxwz04nsXtQFCxT81wfUqv4DgPfDG1ZppPJB3ld9wFPKw0W9wh62YrQ vzPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872716; x=1727477516; 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=NzTOuwtkIiYwClWTiai050AtuXNXIOHo/YChZTv1iL0=; b=Is3RX5VRwpx/24+bxIjp6G6k33W9zNlVi+yO3+81/Vj7yh/aiXzKkq357Ysv9TB06o avGG86q8jCxnKzkUugG858H7hjMpKRsaGd4M/c5SQgl/RecsNGeuKtfoCi2O+IF96aR2 gAhvQEgmwx7giMvgoQoyJ1QyICgqvzt0iOWXvexQgOi70e+8DtOYTbBU79sJ7lOnIYfn A2YpWakwPq171R0TDnFVtJxP1qmTqboCMlP4snx/i3WB6BUpzhEefiqKy6H+pHExgxib xzjLIWSia723FkZFsNqZyiRqUHT1VKwwDYIG5cszwUZy35dw0rR58JNJAfvKJI6JD62j Acaw== X-Forwarded-Encrypted: i=1; AJvYcCXwNJ6VAu+eSgSAuVqfJ1w6cr2Vzm8kJe+XxcrFV+/vo7HqGke8Z2bjDLJOvF2ZpAyg4Sr5NF4=@lists.denx.de X-Gm-Message-State: AOJu0Ywp+ouWFO8wQVftc1P4MqvTthcLaDECl/JMUZWKV1N4dYjEEmMr pUBcB/i2xLwHEC/i/4Y45+Ow4Y/vN8B+7g55wu54fHDgvNTgcf6Y X-Google-Smtp-Source: AGHT+IHf3OLJOs+beB/+o19pMp1YE+SXh6i63QRbOSnBvbT+aEo7jjUrrgHu7uzqN3YfbgM0oqwYhw== X-Received: by 2002:a05:600c:354a:b0:42c:c1f6:6ded with SMTP id 5b1f17b1804b1-42e7ad9afabmr30326365e9.29.1726872716254; Fri, 20 Sep 2024 15:51:56 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:51:55 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 06/11] tftp: implement support for LED activity Date: Sat, 21 Sep 2024 00:49:59 +0200 Message-ID: <20240920225101.2008-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 support for LED activity. If the feature is enabled, make the defined ACTIVITY LED to signal traffic. Also turn the ACTIVITY LED OFF if a CTRL-C is detected in the main net loop function. Signed-off-by: Christian Marangi --- net/net.c | 4 ++++ net/tftp.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/net/net.c b/net/net.c index d9bc9df643f..94bfde43f85 100644 --- a/net/net.c +++ b/net/net.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -659,6 +660,9 @@ restart: /* Invalidate the last protocol */ eth_set_last_protocol(BOOTP); + /* Turn off activity LED if triggered */ + led_activity_off(); + puts("\nAbort\n"); /* include a debug print as well incase the debug messages are directed to stderr */ diff --git a/net/tftp.c b/net/tftp.c index 2e073183d5a..5cb06d2038b 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -192,6 +193,7 @@ static void new_transfer(void) #ifdef CONFIG_CMD_TFTPPUT tftp_put_final_block_sent = 0; #endif + led_activity_blink(); } #ifdef CONFIG_CMD_TFTPPUT @@ -301,6 +303,9 @@ static void tftp_complete(void) time_start * 1000, "/s"); } puts("\ndone\n"); + + led_activity_off(); + if (!tftp_put_active) efi_set_bootdev("Net", "", tftp_filename, map_sysmem(tftp_load_addr, 0), From patchwork Fri Sep 20 22:50:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988094 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=Q1MSd+my; 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 4X9YN75S5Xz1y34 for ; Sat, 21 Sep 2024 12:38:31 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E0F7688861; Sat, 21 Sep 2024 04:37:14 +0200 (CEST) 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="Q1MSd+my"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D6A387E30; Sat, 21 Sep 2024 00:52:02 +0200 (CEST) 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,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 5653A880D8 for ; Sat, 21 Sep 2024 00:52:00 +0200 (CEST) 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-42cb6f3a5bcso30194285e9.2 for ; Fri, 20 Sep 2024 15:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872720; x=1727477520; 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=SQDC9j9+SaPI7Iw4qgK3DIz0Ik8w7G7qmKL2qNqPaZg=; b=Q1MSd+myO9WJt1//Z2NCzYyzN8O5Vdhv/MniddTzddq3YZwEbwdcJdaWoCV5rTlHSZ ABrtovj7idNVbqwFeIQC/UHa2UdERSJa3o2m8aI9+aHEMTIliwmVqljBm4RHNd0zbHFs rG5miO2ns2yjxFfgBtINhSSHV8TmLf84mLehA6KWG+cphzxM4EzXwhLao12Ls3AP8lKt OVsBhsaIJzuYfQ+1LtAWgSpbahJO+YgZN07s8K8e31aGRaqLxYqImcjiKP+yVrjsUz65 wuz6Mt8YLSBTJk5Zzx+MaKBXdog4vSl4cBixjFzbHJMubwQ67eZtvs4tMj4/rzcgcusJ BedQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872720; x=1727477520; 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=SQDC9j9+SaPI7Iw4qgK3DIz0Ik8w7G7qmKL2qNqPaZg=; b=gKyqVvt6TMb//kwL7zUj3/XNBr/KswGsVRHNpfnv4NZfPeHcMTmv2L8T59IMQOITW/ LYcB2QR242nXPgV53nil0AWW2DGj7bXd0Wv5RPhFoF6ICJWjbcM6IoPWzvTRekSTJlSI gh9NQRcl4V+f7pQ6ktVRbWWB4MZiTBJ9r7koMCMxJwrCANFmNeTmj2Zn/PhwpYVrH1jT yT9HDSxYrorNjAumix3PITnZOqyxAtqHP0fnQMpnymhgkNWTQeV6DbopISFq6oo6cWCR nrV0NeRPEuilJwQeG87BmUoyYLKoo8NBDgy5BGl4TMBtbB3l2Wwm1xF0tkFOpouZscR6 Vb4A== X-Forwarded-Encrypted: i=1; AJvYcCWhAkl7bKHNy+lCawkKWAtnKjsK9j9tu9/niYqfmsklSKIPgwtoGEKBs2JhjF8as7wLOiiFGWI=@lists.denx.de X-Gm-Message-State: AOJu0YwrQDyT4FiqLWemnka1pWmiXYiuYbXFlac4K1e7/kTcQHGuXc77 Yr75bmVZBVhjxvw+uLrD6Q0vYKXlNt+b5Rlqqy5Aj31ir6R5HOer X-Google-Smtp-Source: AGHT+IGnVtIAlPuLwbdWt8hz0NF7l2ZDigSrz5LJAjBqibOGYJr1ETvlVS04zEh//xvXBFPgBe7tCA== X-Received: by 2002:a05:600c:1d12:b0:42c:c401:6d6f with SMTP id 5b1f17b1804b1-42e7ac4b294mr45027065e9.16.1726872719579; Fri, 20 Sep 2024 15:51:59 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:51:58 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 07/11] mtd: implement support for LED activity Date: Sat, 21 Sep 2024 00:50:00 +0200 Message-ID: <20240920225101.2008-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 support for LED activity. If the feature is enabled, make the defined ACTIVITY LED to signal mtd write or erase operations. Signed-off-by: Christian Marangi --- cmd/mtd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/mtd.c b/cmd/mtd.c index 795aaa2b37d..dae90b0e6e4 100644 --- a/cmd/mtd.c +++ b/cmd/mtd.c @@ -10,6 +10,7 @@ #include #include +#include #if CONFIG_IS_ENABLED(CMD_MTD_OTP) #include #endif @@ -558,6 +559,9 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc, while (mtd_block_isbad(mtd, off)) off += mtd->erasesize; + if (!read) + led_activity_blink(); + /* Loop over the pages to do the actual read/write */ while (remaining) { /* Skip the block if it is bad */ @@ -585,6 +589,9 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc, io_op.oobbuf += io_op.oobretlen; } + if (!read) + led_activity_off(); + if (!ret && dump) mtd_dump_device_buf(mtd, start_off, buf, len, woob); @@ -652,6 +659,8 @@ static int do_mtd_erase(struct cmd_tbl *cmdtp, int flag, int argc, erase_op.addr = off; erase_op.len = mtd->erasesize; + led_activity_blink(); + while (len) { if (!scrub) { ret = mtd_block_isbad(mtd, erase_op.addr); @@ -680,6 +689,8 @@ static int do_mtd_erase(struct cmd_tbl *cmdtp, int flag, int argc, erase_op.addr += mtd->erasesize; } + led_activity_off(); + if (ret && ret != -EIO) ret = CMD_RET_FAILURE; else From patchwork Fri Sep 20 22:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988095 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=GQ3ghK+U; 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 4X9YNK24hYz1y34 for ; Sat, 21 Sep 2024 12:38:41 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 47A148891B; Sat, 21 Sep 2024 04:37:15 +0200 (CEST) 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="GQ3ghK+U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B06F187E30; Sat, 21 Sep 2024 00:52:06 +0200 (CEST) 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,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (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 D9BF78785E for ; Sat, 21 Sep 2024 00:52:03 +0200 (CEST) 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-x32c.google.com with SMTP id 5b1f17b1804b1-42cbb08a1a5so22578855e9.3 for ; Fri, 20 Sep 2024 15:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872723; x=1727477523; 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=3z42g+gFzdLZFSr9JS0gJsU8ZEGF1SU5Wl47Lcqd0lQ=; b=GQ3ghK+UkjjSK+JczDOF373x2/LhQ2RptrC5tjVJumyYPKdLTWjF54rGqKZ7v8sw8I 6RK6QUID5piRRt+XED4kFUCsDZLez41/fk2xDNOQmnoITei1oxerLHFK2frnX4kyAVYS LjxRLXRZud8YC4NjlpkkCvxGHYFTFHZmBXZ/uK7pFDBe5Xriry+rqoLMkprCPXT9NbHL gTofEp+ejxwSAUT/ii5pdqsBWy5igKOLvuFPt/iw5XMs38eg1v+PRSMTVPUraztwiUKZ t4KpjeVVslc0SWrCmb5QbLMq/rV+9DpilKC/lunP+/DoNCOtTSkukRSoRaS1XoriRpM3 ev4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872723; x=1727477523; 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=3z42g+gFzdLZFSr9JS0gJsU8ZEGF1SU5Wl47Lcqd0lQ=; b=vwS7t6/RyJd0Eu3RKfleeGNz2lbd3VLthLA1By19t1pxt1LwRrxPXaxBmdJcfwFy+C XkVmnJQmed5F20GpLsXqRI+pc+ogK5nHY6rMPXWZGMclThU8GCDNKSU0X+JNmkPVuP5a tVJJUEreLULzJCgqQCyfa0KnLU3dt3MOsMmyO5qRUGstSLpGnkEM3VLvN6fiJJPgiIfl VH324yiKeRMQwn+bOqR6pPhd/wCfpOJSzqbCLsyjXXnBWsKglEfPAvVOeM2NDjKftD47 OkJN9hb0vPtS4nlktuf7bH4Be732wq7MXeeteOJvcS+5usbGpJi8glH2RoP7z9ntHveJ 1D6w== X-Forwarded-Encrypted: i=1; AJvYcCU+CzLuA1ln1nHeNhVKRpupqyKylTkjOG2/uQ1M6WgVJc9Kqb9gs8nCWJ+BYbIAu2Ta/eRmOP4=@lists.denx.de X-Gm-Message-State: AOJu0YxmPMcyix3G9+EFPauqCJN8BwR/Qlqj4XwKL8cPJZNz0CKJIDfA kdwJ0Xc+/ydS790lbVcWvEuCTNftgtd4+xOctMMw6dH4RG1jb0a8 X-Google-Smtp-Source: AGHT+IEVFmRpG4o+qwxm1Bc0Gn3Nvyloyx5pm1wsgNByBukZ1XAD2k41eIeyUm8Elt6x3rlxgMx5hA== X-Received: by 2002:a5d:4f0a:0:b0:371:8f32:557e with SMTP id ffacd0b85a97d-37a4235a22dmr2647327f8f.39.1726872723175; Fri, 20 Sep 2024 15:52:03 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:52:01 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 08/11] ubi: implement support for LED activity Date: Sat, 21 Sep 2024 00:50:01 +0200 Message-ID: <20240920225101.2008-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 support for LED activity. If the feature is enabled, make the defined ACTIVITY LED to signal ubi write operation. Signed-off-by: Christian Marangi --- cmd/ubi.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/ubi.c b/cmd/ubi.c index 0e62e449327..56d7da82629 100644 --- a/cmd/ubi.c +++ b/cmd/ubi.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -488,10 +489,18 @@ exit: int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size) { + int ret; + + led_activity_blink(); + if (!offset) - return ubi_volume_begin_write(volume, buf, size, size); + ret = ubi_volume_begin_write(volume, buf, size, size); + else + ret = ubi_volume_offset_write(volume, buf, offset, size); - return ubi_volume_offset_write(volume, buf, offset, size); + led_activity_off(); + + return ret; } int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size) From patchwork Fri Sep 20 22:50:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988096 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=LgNiOuLy; 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 4X9YNW2fNCz1y34 for ; Sat, 21 Sep 2024 12:38:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9DC92889AE; Sat, 21 Sep 2024 04:37:15 +0200 (CEST) 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="LgNiOuLy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B495B880D8; Sat, 21 Sep 2024 00:52:08 +0200 (CEST) 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,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (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 61E1A8817C for ; Sat, 21 Sep 2024 00:52:06 +0200 (CEST) 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-x436.google.com with SMTP id ffacd0b85a97d-374c1e5fe79so1695717f8f.1 for ; Fri, 20 Sep 2024 15:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872726; x=1727477526; 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=V5eWNU266He6A+/t13MeJTalkxc3ldDl87xEfT6nr4Q=; b=LgNiOuLyRymjiKPibYU672pm0wpJOdwmxQenv+O45i7J2Oa+qHokBPwA5uHXlE46Ag 1VFqAUhy50A5SSvMWuTwsKpCPfK6wi5JJto+kmUOzV713c8sjPr9ZegUSstkr6ncff6j EqRMdhEc49NrXdIUE3mBI3zumLNrQSM0NVG7d6CS/fU8PLGGVf1g4ZWz6Vybadc7uSY/ FCAUifJqbmANJhk6BtDk9NKBEcJraszsHt23GRHDrFWvzKmcZQyggtQY+UWoQw9vsy9n wZQ/0U1HIsWxiBoKYG6fG75C8Brviaub7dJMzbnnAFEXXLYmnxnUV/nMxz5AJIbELOpU qCLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872726; x=1727477526; 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=V5eWNU266He6A+/t13MeJTalkxc3ldDl87xEfT6nr4Q=; b=f5y0T4LufGqE9yIoQ4al+oqGNk8xW35yLLpUAORJdyLbcqyG9yefLTcddE/yW7cUqG 4EQcAIwLf3Z1Yj5eO0+3jV3Wp8zofm1Cnu79T+WDC+p+myiVwzpO0uHDzmhc7eLjcVzm 7Pdekcr41EAAJd2+5c1onrvfl7ovgMPHAmeuwb/rXk/kwOVyzN8Mxmhf63S+F5WCWuKn p7t/h19/ovxu9CFg+AzSU9dSF9gpKi+dwUxaGQj6sJJEmGf3atxDDdXfGdZX20dZCcYT nR//Kl7eZjNUm+GDGnFNNsdyFsss62Ah/LW5Wj0Qp7NtY2LwdtFPYx1HUKZP7/4Mo7pQ DG1g== X-Forwarded-Encrypted: i=1; AJvYcCXOXRR8g7dGY/4D82C/frAtrCWUv0yaAVBxtT/VNHArvELJsunHa1Lc6+tMCcDYqWUJY7lGov4=@lists.denx.de X-Gm-Message-State: AOJu0Yx+XCKvXQYSGOcnc6ZjaM50v054Ex/hG324+q5DNbjtvZ0mPRkv mpTHMrB5QtVVmSxUWIiw0bF7NQxmvBbf14W3Hz17HvYCN//xFloG X-Google-Smtp-Source: AGHT+IGhT8OYIfp4w43excmVvDy6dfQ218/MP1yeQD1rZHC15fXUjhBFpOEBymqtFdB6psqB9dxLeg== X-Received: by 2002:a5d:68d1:0:b0:374:c287:2af9 with SMTP id ffacd0b85a97d-37a431ad53amr2261672f8f.46.1726872725633; Fri, 20 Sep 2024 15:52:05 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:52:04 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 09/11] doc: introduce led.rst documentation Date: Sat, 21 Sep 2024 00:50:02 +0200 Message-ID: <20240920225101.2008-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 Introduce simple led.rst documentation to document all the additional Kconfig and the current limitation of LED_BLINK and GPIO software blink. Also add missing definition for sw_blink in led_uc_plat struct. Signed-off-by: Christian Marangi --- doc/api/index.rst | 1 + doc/api/led.rst | 10 ++++++++++ include/led.h | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 doc/api/led.rst diff --git a/doc/api/index.rst b/doc/api/index.rst index ec0b8adb2cf..9f7f23f868f 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -14,6 +14,7 @@ U-Boot API documentation event getopt interrupt + led linker_lists lmb logging diff --git a/doc/api/led.rst b/doc/api/led.rst new file mode 100644 index 00000000000..e52e350d1bb --- /dev/null +++ b/doc/api/led.rst @@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +LED +=== + +.. kernel-doc:: include/led.h + :doc: Overview + +.. kernel-doc:: include/led.h + :internal: \ No newline at end of file diff --git a/include/led.h b/include/led.h index bba8c0009ca..a9dd55efd1f 100644 --- a/include/led.h +++ b/include/led.h @@ -11,6 +11,46 @@ #include #include +/** + * DOC: Overview + * + * Generic LED API provided when a supported compatible is defined in DeviceTree. + * + * To enable support for LEDs, enable the `CONFIG_LED` Kconfig option. + * + * The most common implementation is for GPIO-connected LEDs. If using GPIO-connected LEDs, + * enable the `LED_GPIO` Kconfig option. + * + * `LED_BLINK` support requires LED driver support and is therefore optional. If LED blink + * functionality is needed, enable the `LED_BLINK` Kconfig option. If LED driver doesn't + * support HW Blink, SW Blink can be used with the Cyclic framework by enabling the + * CONFIG_LED_SW_BLINK. + * + * Boot and Activity LEDs are also supported. These LEDs can signal various system operations + * during runtime, such as boot initialization, file transfers, and flash write/erase operations. + * + * To enable a Boot LED, enable `CONFIG_LED_BOOT` and define in `/options/u-boot` root node the + * property `boot-led`. This will enable the specified LED to blink and turn ON when + * the bootloader initializes correctly. + * + * To enable an Activity LED, enable `CONFIG_LED_ACTIVITY` and define in `/options/u-boot` root + * node the property `activity-led`. + * This will enable the specified LED to blink and turn ON during file transfers or flash + * write/erase operations. + * + * Both Boot and Activity LEDs provide a simple API to turn the LED ON or OFF: + * `led_boot_on()`, `led_boot_off()`, `led_activity_on()`, and `led_activity_off()`. + * + * Both configurations can optionally define a `boot/activity-led-period` property + * if `CONFIG_LED_BLINK` or `CONFIG_LED_SW_BLINK` is enabled for LED blink operations, which + * is usually used by the Activity LED. If not defined the default value of 250 (ms) is used. + * + * When `CONFIG_LED_BLINK` or `CONFIG_LED_SW_BLINK` is enabled, additional APIs are exposed: + * `led_boot_blink()` and `led_activity_blink()`. Note that if `CONFIG_LED_BLINK` or + * `CONFIG_LED_SW_BLINK` is disabled, these APIs will behave like the `led_boot_on()` and + * `led_activity_on()` APIs, respectively. + */ + struct udevice; enum led_state_t { @@ -41,6 +81,7 @@ struct led_sw_blink { * * @label: LED label * @default_state: LED default state + * @sw_blink: LED software blink struct */ struct led_uc_plat { const char *label; From patchwork Fri Sep 20 22:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988097 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=BKIyW2Xf; 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 4X9YNh6S1Gz1y34 for ; Sat, 21 Sep 2024 12:39:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 090208852D; Sat, 21 Sep 2024 04:37:16 +0200 (CEST) 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="BKIyW2Xf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F820882EF; Sat, 21 Sep 2024 00:52:11 +0200 (CEST) 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,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 99EE187FA7 for ; Sat, 21 Sep 2024 00:52:09 +0200 (CEST) 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-378f90ad32dso1670300f8f.0 for ; Fri, 20 Sep 2024 15:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872729; x=1727477529; 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=LbkXLyOGTi41VAljTp47rnT4xiyBCdUPzU9fqER1OL8=; b=BKIyW2XfTQLnTGrbpbzQCsS+nRwt+KHmGwaVoNhFyM/wDeF2Zsz7VjPQXywMl/v1jW KJPXBlu6MjWTCZoO+Kgw7LuEBJsKV9yPJoTRHYHf4hB3+eIZqWyzFF0cCC2UII3JPNWd Yb7+G8K6+TlNdv+4x/VJ5IyOfBCDr3OxOC0zWf9QnOPndYVSfxLtM3K3Rv2iFqlvabja 2T+uLKAcTLVDY/V8YLSDoWilFmfWENL2j1Dq7XF9XQoAiI7SnjCx4fD/0kihdW7teN3V amtLmQZfYBhCuuBIkyHQOdQPOko9nCFYJMmZgYeVjs1/N2xYZs5Tv+JxjDjndnCCQeSa PyYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872729; x=1727477529; 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=LbkXLyOGTi41VAljTp47rnT4xiyBCdUPzU9fqER1OL8=; b=FyHIXShsVOk3xDEabOvscN6nvGIsmU7vk2lNXBTSuehHhApi3RujmgzWkiYzitFAjE ReJkRKrUDDBdxTu5jdQPKwCxMNR/IGa8YN/YpeU87BP9fY9dPcYggsF7WSr+lEUtZr2B er9d1AMDYHlvYEv577WEv8+YD11107C8FPRxI/Jkr/LmDLnbIW4dq6nRgM30nMd7q/DX lzVjPulzMcw9q7CIHbVrz/qld5NwNWUxna23hNltML1lECqUDHEeIKNFXaL0uSreodcR fgtZLeLzAGcU0mH4jbgNsWungad1DdsICD1FgqzUarlgpaMv11mexPq7jP6PZAX8mgNz QbyQ== X-Forwarded-Encrypted: i=1; AJvYcCUVzE/eg7EhNTYkhjFvmpMhaeG9liU5/TW8/19InTqZk0mvLLSSYGI13VVNcwWkiRmjN2Bfckw=@lists.denx.de X-Gm-Message-State: AOJu0Yx+rvRSqAIPHD3aDn33afG5d7eWTv1ISOxx2nY42zbwJZml0XpR qYAaPLf/6ZDW/hi2OTF7fRRPyv3620pgGAtyp55PWyVpUK92BK5uq9Q6Bu7f X-Google-Smtp-Source: AGHT+IEzvwqpxPMsj3gOPoubEZd16zsBr6AuZp072OFfQqfbBUf65MxFiov8omya7hgcGtk4Xf9RIw== X-Received: by 2002:adf:e2ce:0:b0:374:c1cc:2eb7 with SMTP id ffacd0b85a97d-37a4315e487mr2583127f8f.35.1726872728869; Fri, 20 Sep 2024 15:52:08 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:52:07 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 10/11] test: dm: Add tests for LED boot and activity Date: Sat, 21 Sep 2024 00:50:03 +0200 Message-ID: <20240920225101.2008-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 tests for LED boot and activity feature and add required property in sandbox test DTS. Signed-off-by: Christian Marangi --- arch/sandbox/dts/test.dts | 2 ++ test/dm/led.c | 72 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 5fb5eac862e..25859ad852d 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -101,6 +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"; }; }; diff --git a/test/dm/led.c b/test/dm/led.c index c28fa044f45..4b019c71f3a 100644 --- a/test/dm/led.c +++ b/test/dm/led.c @@ -137,3 +137,75 @@ static int dm_test_led_blink(struct unit_test_state *uts) } DM_TEST(dm_test_led_blink, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); #endif + +/* Test LED boot */ +#ifdef CONFIG_LED_BOOT +static int dm_test_led_boot(struct unit_test_state *uts) +{ + struct udevice *dev + + /* options/u-boot/boot-led is set 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()); + ut_asserteq(LEDST_ON, led_get_state(dev)); + ut_assertok(led_boot_off()); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + + return 0; +} + +/* Test LED boot blink fallback */ +#ifndef CONFIG_LED_BLINK +static int dm_test_led_boot(struct unit_test_state *uts) +{ + struct udevice *dev + + /* options/u-boot/boot-led is set 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()); + ut_asserteq(LEDST_ON, led_get_state(dev)); + ut_assertok(led_boot_off()); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + + return 0; +} +#endif +#endif + +/* Test LED activity */ +#ifdef CONFIG_LED_ACTIVITY +static int dm_test_led_boot(struct unit_test_state *uts) +{ + struct udevice *dev + + /* options/u-boot/activity-led is set 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()); + ut_asserteq(LEDST_ON, led_get_state(dev)); + ut_assertok(led_activity_off()); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + + return 0; +} + +/* Test LED activity blink fallback */ +#ifndef CONFIG_LED_BLINK +static int dm_test_led_boot(struct unit_test_state *uts) +{ + struct udevice *dev + + /* options/u-boot/activity-led is set 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()); + ut_asserteq(LEDST_ON, led_get_state(dev)); + ut_assertok(led_activity_off()); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + + return 0; +} +#endif +#endif From patchwork Fri Sep 20 22:50:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1988098 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=EGDIDAxK; 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 4X9YNw4sFhz1y34 for ; Sat, 21 Sep 2024 12:39:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 61A9D889ED; Sat, 21 Sep 2024 04:37:16 +0200 (CEST) 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="EGDIDAxK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C27E8785E; Sat, 21 Sep 2024 00:52:17 +0200 (CEST) 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,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 5EADC8817C for ; Sat, 21 Sep 2024 00:52:13 +0200 (CEST) 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-42cd46f3a26so21991835e9.2 for ; Fri, 20 Sep 2024 15:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726872733; x=1727477533; 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=pfdHDTvIq+GqLJ7ercfbkhUYg5qQGsJkQO7v7+V8y5M=; b=EGDIDAxK9wwtwgqcHV+5jpUUOr6gJ0ULTFj3lCeYfh1rSGjxWP2Z5xsKXOb4V6jzrc grI4phddgrbkwhbrb2wrg4Ss76POIITNjNsvohdMGWzwaHiOi6XaDmpwBpLlDqqz2x4i kDU+vsnAe+w26G8cmgVn/NbJSjYHUJzX145QeQTc+xwFDpUSyq9Wsk8aLfcNRYQLtqNS H1kX5/x1vCs2u6PQ9JGYNZjSTeh7jcMGTp3pnj7PWBblu7WozGa2kXF8PLl/X5JKnY+Q ekQrjZ7u4oI2/gyHti3Fz4o0iTmAW6gRdfCVVR5m5ulGpO9oW9ESSvZmgz68Qa8eOCTH 2zwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726872733; x=1727477533; 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=pfdHDTvIq+GqLJ7ercfbkhUYg5qQGsJkQO7v7+V8y5M=; b=xSKhwm/UK3ihOwvC64uLKTXINeK2AWr1HKO+hRDC4EpRiu91MIrlr7T993iB6/2miT AXHv4N1w4c9FO2Patr5OMMWhIJYvRsrnzzz0+VIxlEStHXfv6M8SBx08PplvrQr2vOSz HT5ZcvRlhYUUs4Zv9pctvElrDBGjogmIUTQCOIwK4o7++vhiB47q5pcSsn4mx/u7GK6I /MgHNoEqqUN5hqovBCUMAxVCDUqHQFLK5s+3PW0y4P7CoI6V85bapES1v7rfCjg4EG3E tT5lnumRf5Vj3w7s53+pvPXQ9lXiNyJZVh3ubXeusyM6F5AAPTkqluClc5HxaWeDESnl lWUg== X-Forwarded-Encrypted: i=1; AJvYcCXb6F3MQh+DGxp5PA7V0vN4u/nekp2QFpOA+dyO5XizsdwI5V3PGnrKjgi2nmMoEPyFWjWYs/A=@lists.denx.de X-Gm-Message-State: AOJu0YxNO/nqE7sYoOQXHGxA1WhSWpT3hKl/kN5JJFAjwTgmvKl2CBq7 qVbMX+hzEJzuzJSjFw7UYmSIPizRR1diG5NqdMnnNjMlF3HSP6YU X-Google-Smtp-Source: AGHT+IHUKOOfOz1xaGoUmWkBAdR9sS4DhOEdJZEVcGX2QFbLXqs6RIDvhOJ/p7iapEsQOsIf1qSn2Q== X-Received: by 2002:a5d:58e2:0:b0:368:31c7:19dd with SMTP id ffacd0b85a97d-37a4225294dmr2418142f8f.5.1726872732588; Fri, 20 Sep 2024 15:52:12 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-378e73e837csm18850516f8f.27.2024.09.20.15.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 15:52:11 -0700 (PDT) From: Christian Marangi To: Simon Glass , Tom Rini , Joe Hershberger , Ramon Fried , Michal Simek , Ilias Apalodimas , AKASHI Takahiro , Sean Anderson , Christian Marangi , Ashok Reddy Soma , Eddie James , Mattijs Korpershoek , Yang Xiwen , Caleb Connolly , Dario Binacchi , Miquel Raynal , Heinrich Schuchardt , Arseniy Krasnov , Heiko Schocher , Alexey Romanov , Martin Kurbanov , Michael Trimarchi , Rasmus Villemoes , Artur Rojek , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , Marek Vasut , u-boot@lists.denx.de, John Crispin Subject: [PATCH v4 11/11] test: dm: Expand ofnode options test with new helper Date: Sat, 21 Sep 2024 00:50:04 +0200 Message-ID: <20240920225101.2008-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920225101.2008-1-ansuelsmth@gmail.com> References: <20240920225101.2008-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 21 Sep 2024 04:37:11 +0200 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 ofnode options test with new generic helper for bool, int and string. Signed-off-by: Christian Marangi --- arch/sandbox/dts/test.dts | 3 +++ test/dm/ofnode.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 25859ad852d..e5381b56da4 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -103,6 +103,9 @@ bootscr-flash-size = /bits/ 64 <0x2000>; boot-led = "sandbox:green"; activity-led = "sandbox:red"; + testing-bool; + testing-int = <123>; + testing-str = "testing"; }; }; diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 39191d7f52b..7c0adcd596b 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -614,6 +614,15 @@ static int dm_test_ofnode_options(struct unit_test_state *uts) u64 bootscr_address, bootscr_offset; u64 bootscr_flash_offset, bootscr_flash_size; + ut_assert(!ofnode_options_read_bool("missing")); + ut_assert(ofnode_options_read_bool("testing-bool")); + + ut_asserteq(123, ofnode_options_read_int("testing-int", 0)); + ut_asserteq(6, ofnode_options_read_int("missing", 6)); + + ut_assertnull(ofnode_options_read_str("missing")); + ut_asserteq_str("testing", ofnode_options_read_str("testing-str")); + ut_assertok(ofnode_read_bootscript_address(&bootscr_address, &bootscr_offset)); ut_asserteq_64(0, bootscr_address);