From patchwork Mon Aug 12 10:32:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971528 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=NF1qPiU3; 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 4Wj9pX6bwgz1yYl for ; Mon, 12 Aug 2024 20:33:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B3306886BB; Mon, 12 Aug 2024 12:33:05 +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="NF1qPiU3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8E9287D6B; Mon, 12 Aug 2024 12:33:04 +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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D8B9088680 for ; Mon, 12 Aug 2024 12:33:02 +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-x329.google.com with SMTP id 5b1f17b1804b1-4280b3a7efaso30726225e9.0 for ; Mon, 12 Aug 2024 03:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458782; x=1724063582; 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=7MItkl2Z+Jt8Mvb5HInZTEP3uAkqW6OJugrf2S9IW4A=; b=NF1qPiU37hIJOXt11AYoRty84qEckGe8VkIEbP7bKJjHV5au+eZRpfObLjC+OPZ8Oa CX3zI8KqqqW/qihDGTeZBiOJTpMTTsXF5/Mt9Z6b2ThQtePvvvCnIOGdWDSHF45y1Fd1 1KyB9IN4enbK2GrhyDikV/L1Yb9EFa+OZhVL0sLDCm/wl5M8bJ/sintLm04P29Jd1vjN /wDOlguWY59UqY1h170rY5zIRuQ+OZgXPWyvOmMK3gptj4fJuaBqScdRt528SgjfkB/S 9IC8Ih/ABAk1mliwaCMmcZSdcQJEZRtjBkZ/oSAzTV7V3Hbm3KZe1Sp7QP0N5Z2Pg7UQ 9P6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458782; x=1724063582; 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=7MItkl2Z+Jt8Mvb5HInZTEP3uAkqW6OJugrf2S9IW4A=; b=mFXMIKvgN4rLsTYqztWJCI+CNudJXwnrcgtolE859fy4f7fAMF0ADpcCjBP1IRaHYS FaTx31rRerCnFda1kMQG1x2D8g/GuQ+emQMFQ0EwqXZCgniYCur+Col+JVVDMzUrM3lE Q01sfkhjflKKFWGnk31cLgXrGWiGnBbaaZlSqTBHUruKpq2giqXLTxIf0YMTlVc/Tas9 ZeS05DwPxd+Yca3okR0VCCAGUchFyqRGD701TFaS3FxxlHPqCj71Jp02Vt7AW6wU0Hn5 tVofnlaZaOB5g7pqu9xGhZoIaKKyoO267kuFuzFcTje+t3iE1wC1CHHPHrRpKXaU0xhi 683g== X-Forwarded-Encrypted: i=1; AJvYcCVYzQudqxw+oUp1UHn5pkdHlmwQf2kkFBsW+/gHR8b4Tvj5QGfz8xW7MXIQBUKaz88eCu8kXmCjzQz5uYlBgE1WynWxJA== X-Gm-Message-State: AOJu0YwstVjri+ahuRNfRjwYD59zxuL3VPzgSuCo8UWxGx4F5xZ+vLId qKf9E5kdP2tjRkz+a9k5sON/LYUavb/DAvhXBn0NG5NLprxA1++M X-Google-Smtp-Source: AGHT+IHzPAIHDR8YU0uwHbtPhMhjWpYBL7JJAtXgoJ6ywGPEzFlPBvq74zrkOVdWXZkqzNLoTd97pg== X-Received: by 2002:a05:600c:4e91:b0:428:1799:35e3 with SMTP id 5b1f17b1804b1-429c3a28d5dmr61451465e9.21.1723458781973; Mon, 12 Aug 2024 03:33:01 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:01 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 1/9] led: turn LED ON on initial SW blink Date: Mon, 12 Aug 2024 12:32:43 +0200 Message-ID: <20240812103254.26972-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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. Turn LED 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/led/led_sw_blink.c b/drivers/led/led_sw_blink.c index 9e36edbee47..853278670b9 100644 --- a/drivers/led/led_sw_blink.c +++ b/drivers/led/led_sw_blink.c @@ -103,8 +103,11 @@ 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); + + ops->set_state(dev, LEDST_ON); /* start blinking on next led_sw_blink() call */ - sw_blink->state = LED_SW_BLINK_ST_OFF; + sw_blink->state = LED_SW_BLINK_ST_ON; return true; } From patchwork Mon Aug 12 10:32:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971529 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=S+fd1N8s; 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 4Wj9pb6pY6z1yYl for ; Mon, 12 Aug 2024 20:33:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 346E2887E4; Mon, 12 Aug 2024 12:33:08 +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="S+fd1N8s"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F212488755; Mon, 12 Aug 2024 12:33: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,T_SCC_BODY_TEXT_LINE autolearn=ham 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 08E4787D6B for ; Mon, 12 Aug 2024 12:33:05 +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-429d2d7be1eso2032795e9.1 for ; Mon, 12 Aug 2024 03:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458784; x=1724063584; 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=FZwEhbDpC3QRsL4OcntQ5ExiSIPebNKwOaMYQduXGxg=; b=S+fd1N8saHEGaELbFlK1SnhhKTQX44k5Va5RbIAvNFOAA2hKnPh95dIZitZDAdZJds b3Oij7/zv9FLEY0vSEr0bJ/ygpEmIUH5wskk6RfiWhpAruw+QQKe5bqI23h24T981aJc tWLTO21XtcUi4oZehrkFe27AoATqY/YFAe9CPQuVOhwu9lkFbcNfG93kBqSA+TbtCXlZ XHuEB9yBZ5kqRFR0RCvU3m+6uhPpwLmb7Ih1zrSwy/LeKObv3LKl2zLuORS+vIuPf6EJ 5KtwKhjDMIwX0bm8+yxdFubRARcIbIbH9pIcHO4tGm87ITP2NCaxOFYcO3rxv1G8qFOg l4qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458784; x=1724063584; 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=FZwEhbDpC3QRsL4OcntQ5ExiSIPebNKwOaMYQduXGxg=; b=PK0Ghqy+uyNsaQ8jATQhKJk1MBqUFGWtH7jWISm6PWQF4Kwix9d+ixQ9q6oF1Wt9u9 0jw81jo4dvBCE+DJ58cYopXZiXmiRQ8V/XLBf8GNb0/ZXeUJEX17g7txVkRg3QmWgtz+ xNjH6tjNWnOb/5AK+bLfnjUvVGrXhURD1ycXvwEU1w/175rfL4WUKA+0QOQpa/oqO6bm gmKDGXoG1aDlBO27fxOrG/l5a+rsP/Vhv6ofgRYIA0DkPUhChv3TBirUrOtpJ8s6eXNC blcg0Kykz9dGLopzZ5CHuTGYc6Kn37GJZ0DUYBAt+gbFeQ4MFHBMMeSZeKRCUKx+on63 VPRw== X-Forwarded-Encrypted: i=1; AJvYcCUs8NSfumc6CbkDLMenDDs3agYVw9EH33FZO16JLPmfFHwFD9vdkHGEnvZFEMH2Dz94UvS2kDi1iBavERkvusdTa5n1ng== X-Gm-Message-State: AOJu0YzyG2+EB7vAX+0gqqWKIi3mFcF+SCaSChWBaxY8/PogfuQW+P2f 7aejNdk+/bzq8ZdwbNf+eDFCV/2RsXx+xHEDX58XHMyxPygmiNMo X-Google-Smtp-Source: AGHT+IGuowygy2zLp2ELmjnsaQfN03VuGBXWcU4jJY7own0BVbYWBaWmo0I54m2npP7ECSX9YUZOKA== X-Received: by 2002:a05:600c:358c:b0:424:895c:b84b with SMTP id 5b1f17b1804b1-429c3abd9a7mr76533005e9.4.1723458784046; Mon, 12 Aug 2024 03:33:04 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:03 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 2/9] led: implement led_set_state/period_by_label Date: Mon, 12 Aug 2024 12:32:44 +0200 Message-ID: <20240812103254.26972-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Introduce new API led_set_state/period_by label as a shorthand to set LED state and LED blink period by referencing them by label. This is needed for the upcoming additional API that will declare LED in .confg and reference them by their LED label name. Signed-off-by: Christian Marangi --- drivers/led/led-uclass.c | 28 ++++++++++++++++++++++++++++ include/led.h | 18 ++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 199d68bc25a..b2b96d7d48b 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -65,6 +65,20 @@ int led_set_state(struct udevice *dev, enum led_state_t state) return ops->set_state(dev, state); } +int led_set_state_by_label(const char *label, enum led_state_t state) +{ + struct udevice *dev; + int ret; + + ret = led_get_by_label(label, &dev); + if (ret) { + printf("Failed to get LED by label %s\n", label); + return ret; + } + + return led_set_state(dev, state); +} + enum led_state_t led_get_state(struct udevice *dev) { struct led_ops *ops = led_get_ops(dev); @@ -94,6 +108,20 @@ int led_set_period(struct udevice *dev, int period_ms) return -ENOSYS; } +int led_set_period_by_label(const char *label, int period_ms) +{ + struct udevice *dev; + int ret; + + ret = led_get_by_label(label, &dev); + if (ret) { + printf("Failed to get LED by label %s\n", label); + return ret; + } + + return led_set_period(dev, period_ms); +} + static int led_post_bind(struct udevice *dev) { struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev); diff --git a/include/led.h b/include/led.h index 99f93c5ef86..c1f3380f253 100644 --- a/include/led.h +++ b/include/led.h @@ -111,6 +111,15 @@ int led_get_by_label(const char *label, struct udevice **devp); */ int led_set_state(struct udevice *dev, enum led_state_t state); +/** + * led_set_state_by_label - set the state of an LED referenced by Label + * + * @label: LED label + * @state: LED state to set + * Return: 0 if OK, -ve on error + */ +int led_set_state_by_label(const char *label, enum led_state_t state); + /** * led_get_state() - get the state of an LED * @@ -128,6 +137,15 @@ enum led_state_t led_get_state(struct udevice *dev); */ int led_set_period(struct udevice *dev, int period_ms); +/** + * led_set_period_by_label - set the blink period of an LED referenced by Label + * + * @label: LED label + * @period_ms: LED blink period in milliseconds + * Return: 0 if OK, -ve on error + */ +int led_set_period_by_label(const char *label, int period_ms); + /** * led_bind_generic() - bind children of parent to given driver * From patchwork Mon Aug 12 10:32:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971530 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=U2jze8GM; 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 4Wj9pn2Kdrz1yYl for ; Mon, 12 Aug 2024 20:33:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A24A688747; Mon, 12 Aug 2024 12:33:11 +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="U2jze8GM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8CB0887F19; Mon, 12 Aug 2024 12:33:10 +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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) (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 70EC487D6B for ; Mon, 12 Aug 2024 12:33:07 +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-lf1-x135.google.com with SMTP id 2adb3069b0e04-5314c6dbaa5so3065228e87.2 for ; Mon, 12 Aug 2024 03:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458787; x=1724063587; 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=ozbQb4FB9CmFfyNx71cGb9eR8igJ78Q3C61YyFsXplE=; b=U2jze8GM1DuXwKaTQK9B9m0LCA3nfKPIfpus773vUROjkJ0lGAmfvHoCSe8WjbwNoW x2jt4YwklsUqdTK0GL/a+EmGb3OTxj7Ea15Zt0ZdJzlaCHCbTDSbAAg4c97zcWFUwMXV MgrRVRiDWHEriuMS/x6c0KzF/i2e6GSfK8rm1z8abwkGnnP0B8WML8GWbIt5Ki5E8CqU i5mGuQFcdQJ1tmnMmzRu4zJHHTxM0iMapqFN369HxbWMkueaEK3fiie72MwcjxUROUlg r+hkNz9s74wO0omZ0Rpx5Bpe4qQbhDYyJhVFlbgYPSRENNR/+C3+imLqSG3KH2nr1qRW LeLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458787; x=1724063587; 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=ozbQb4FB9CmFfyNx71cGb9eR8igJ78Q3C61YyFsXplE=; b=ZZzcuiJerS2CJLz2b4FpczgGlups3eSRbm05JcDC8NU2C/5LK9JUuwNzQoWRUepltc PV4Yp9w0lsY8vga+w2fD81PXZgIutiDfjESnPL0ZylpIPOn1E3nq5mphhKYzAAGDJxm/ WjAdKbrrBi7uf1tfGckWO3p+DQwKIPWV9jhSN5D8BqOkpTWDclbMCWTcZK3s8OKnN8Rh nzVxecbf5cmZ+ZzaH+nkQwX8sRElXkV+P8Q8VP5pJ3ZHsXdWNJzlb1Xaz48jXfkAqO5H hD13JRE23OnumAmwbwGQdOQrOXgZ/wp6FaUci3aCx9HmGSx825QCa6ehkcNwFyZCSOyZ rulA== X-Forwarded-Encrypted: i=1; AJvYcCX0dgQ+EvMXqhq+B0uTW340IaLTnifssQUNjqDBn4UTrTULANzqB3BfPQLf6lfUjCZDpTZvWNQ=@lists.denx.de X-Gm-Message-State: AOJu0Yyri/pxGkP68IO9m7H3sNgGbLAH59sLpr6RJ+yhF0GtMSxam7Tc /c6cHud932Kc1Hf18BUFGxHq9H3OT6iLTcOvcu3NACfMXpUVPqxC X-Google-Smtp-Source: AGHT+IHT86ewDNqiICgZVWJ+8DgdQjXT5zulAN9TM3PxdNlaVklxyH14G6Um/+K8c9ZzmXZx5ZUxMA== X-Received: by 2002:a05:6512:4020:b0:52f:cdb0:11da with SMTP id 2adb3069b0e04-530ee995d7amr6397853e87.33.1723458786184; Mon, 12 Aug 2024 03:33:06 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:05 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 3/9] led: implement LED boot API Date: Mon, 12 Aug 2024 12:32:45 +0200 Message-ID: <20240812103254.26972-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement 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 are introduced, CONFIG_LED_BOOT_ENABLE to enable the feature. This makes use of the /config property "u-boot,boot-led" to the define the boot LED. It's also introduced a new /config property "u-boot,boot-led-period" to define the default period when the LED is set to blink mode. If "u-boot,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. Signed-off-by: Christian Marangi --- doc/device-tree-bindings/config.txt | 3 ++ drivers/led/Kconfig | 20 +++++++++ include/led.h | 64 +++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/doc/device-tree-bindings/config.txt b/doc/device-tree-bindings/config.txt index f50c68bbdc3..68edd177040 100644 --- a/doc/device-tree-bindings/config.txt +++ b/doc/device-tree-bindings/config.txt @@ -31,6 +31,9 @@ u-boot,error-led (string) This is used to specify the label for an LED to indicate an error and a successful boot, on supported hardware. +u-boot,boot-led-period (int) + This is used to specify the default period for an LED in blink mode. + bootsecure (int) Indicates that U-Boot should use secure_boot_cmd() to run commands, rather than the normal CLI. This can be used in production images, to diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index bee74b25751..fd9442edaf3 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -9,6 +9,26 @@ config LED can provide access to board-specific LEDs. Use of the device tree for configuration is encouraged. +config LED_BOOT_ENABLE + bool "Enable LED boot support" + help + Enable LED boot support. + + LED boot is a specific LED assigned to signal boot operation status. + +config LED_BOOT_LABEL + string "LED boot label" + depends on LED_BOOT_ENABLE + help + LED label defined in DT to assign for LED boot usage. + +config LED_BOOT_PERIOD + int "LED boot period" + depends on LED_BOOT_ENABLE && (LED_BLINK || LED_SW_BLINK) + default 2 + help + LED boot blink period in ms. + config LED_BCM6328 bool "LED Support for BCM6328" depends on LED && ARCH_BMIPS diff --git a/include/led.h b/include/led.h index c1f3380f253..2d3b89674e2 100644 --- a/include/led.h +++ b/include/led.h @@ -9,6 +9,7 @@ #include #include +#include struct udevice; @@ -159,4 +160,67 @@ 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_ENABLE + +/** + * led_boot_on() - turn ON the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +static inline int led_boot_on(void) +{ + const char *led_name; + + led_name = ofnode_conf_read_str("u-boot,boot-led"); + if (!led_name) + return -ENOENT; + + return led_set_state_by_label(led_name, LEDST_ON); +} + +/** + * led_boot_off() - turn OFF the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +static inline int led_boot_off(void) +{ + const char *led_name; + + led_name = ofnode_conf_read_str("u-boot,boot-led"); + if (!led_name) + return -ENOENT; + + return led_set_state_by_label(CONFIG_LED_BOOT_LABEL, LEDST_OFF); +} + +#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 + */ +static inline int led_boot_blink(void) +{ + const char *led_name; + int led_period, ret; + + led_name = ofnode_conf_read_str("u-boot,boot-led"); + if (!led_name) + return -ENOENT; + + led_period = ofnode_conf_read_int("u-boot,boot-led-period", 250); + + ret = led_set_period_by_label(led_name, led_period); + if (ret) + return ret; + + return led_set_state_by_label(led_name, LEDST_BLINK); +} +#else +/* If LED BLINK is not supported/enabled, fallback to LED ON */ +#define led_boot_blink led_boot_on +#endif +#endif + #endif From patchwork Mon Aug 12 10:32:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971531 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=GeGCt1iu; 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 4Wj9q0006Rz1yYl for ; Mon, 12 Aug 2024 20:33:47 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DDED88755; Mon, 12 Aug 2024 12:33: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="GeGCt1iu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 740858880B; Mon, 12 Aug 2024 12:33:12 +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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 12B028884F for ; Mon, 12 Aug 2024 12:33: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-x430.google.com with SMTP id ffacd0b85a97d-369c609d0c7so2993823f8f.3 for ; Mon, 12 Aug 2024 03:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458788; x=1724063588; 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=F7EzSifg9g5UstZpOxR5pGveBAvWbwJf3eidWqN+PFY=; b=GeGCt1iuCc5jswQrq8b+NaJAeaJMQstHgmfujmXaQg3h+em5NAQv7za1rxto/DHu5Z Z4jVHowYhYHd91e0ppH+hDXJyuQwDh2zLYRJEWh696y7nQlDAg69veAJ/VgPfIWejb+K tSzFErPRy59NHhGvRQojbBJz6HM4WU7jNhh1cnuNZCUyyOqjKYVGk8J/uPjtrbRpPuIs gOp3O4WMEYr2X3mzAZaalaiHlJAvpYhdI2CezrAqQUrL6yDBOrWvW0j/eLG1xMOAt1g2 Whcb/eR3TcfFTI31pJ8tJ6j7Ga1P9p3M6/kBNmW3LmDCsZgSCxh7oti5aLWW2U7v49sB wVVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458788; x=1724063588; 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=F7EzSifg9g5UstZpOxR5pGveBAvWbwJf3eidWqN+PFY=; b=TFH7PG6SUbyKPx6lifVRQhQ+/7gSvB1q17sz6D6TGFLtyeXuy0IQXpIvzzmAdXWvHX WF/XCYMrZUi63ezvHlythUrcHBGho0LDm6UiBUBTaVwFb0gTPHMkHu7pW73eKG3o1Uv5 XEsLo3oaUglCsGTm2Mm2lbyXngpKMTxqV3DlmG12egnumswKoV6ZNlVbos0i7QMpM9B7 IucQp/lpKztXO13WLATzvRu1/01i21dM6b1vfiY91KrEzGRsrRP4JVXs+lZoGOMF3KkY 7rmrhd+h7JExXI5ZQ4Wiq1QbRwvWL7eyEtMvyq036TVOiMQtpfcCzf4cymvi7Vp6Shdc QyaQ== X-Forwarded-Encrypted: i=1; AJvYcCWuhWpFyTVdsGs0Iyq+tcPW+yMsdiHMsPbIEw6C1NwY4Tjxzsh+7hm9dVzvaVvARItRSbGA6zM=@lists.denx.de X-Gm-Message-State: AOJu0YzOcWosWh0vChwn2RmQqZZpYQKIcjilSCnQGLSGEcLa+LigUUFm DtpHspJZfkE4Fqky+8bVOk0HRM39PGiopo3DfODELrjzWvBgCiH1 X-Google-Smtp-Source: AGHT+IFNrxeAyY1fNs+ttpV0wE4YJI+joscAhpjAVcXM3vP8Up0zMwci3NDdDCxl0/7nmBr8AqMaXw== X-Received: by 2002:a05:6000:2a1:b0:368:4c38:a668 with SMTP id ffacd0b85a97d-36d5db7ac57mr9092366f8f.9.1723458788288; Mon, 12 Aug 2024 03:33:08 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:07 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 4/9] common: board_r: rework BOOT LED handling Date: Mon, 12 Aug 2024 12:32:46 +0200 Message-ID: <20240812103254.26972-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Rework BOOT LED handling. There is currently one legacy implementation for BOOT LED from Status Led API. This work on ancient implementation wused 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 | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/common/board_r.c b/common/board_r.c index d4ba245ac69..57957b4e99b 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -462,14 +463,30 @@ static int initr_malloc_bootparams(void) #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(); + + return 0; +} +#endif + +static int initr_boot_led_blink(void) +{ +#ifdef CONFIG_LED_STATUS_BOOT + status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_BLINKING); +#endif +#ifdef CONFIG_LED_BOOT_ENABLE + led_boot_blink(); #endif return 0; } + +static int initr_boot_led_on(void) +{ +#ifdef CONFIG_LED_BOOT_ENABLE + led_boot_on(); #endif + return 0; +} #ifdef CONFIG_CMD_NET static int initr_net(void) @@ -716,6 +733,7 @@ static init_fnc_t init_sequence_r[] = { #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 +756,7 @@ static init_fnc_t init_sequence_r[] = { #if defined(CFG_PRAM) initr_mem, #endif + initr_boot_led_on, run_main_loop, }; From patchwork Mon Aug 12 10:32:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971532 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=LY+e0xJh; 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 4Wj9qC06L7z1yYl for ; Mon, 12 Aug 2024 20:33:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7991988845; Mon, 12 Aug 2024 12:33: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="LY+e0xJh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5720887D6B; Mon, 12 Aug 2024 12:33:13 +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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (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 40A1C87F19 for ; Mon, 12 Aug 2024 12:33:11 +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-x336.google.com with SMTP id 5b1f17b1804b1-4281faefea9so30546535e9.2 for ; Mon, 12 Aug 2024 03:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458791; x=1724063591; 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=uTp4D3gMYy7OE1wuBDKAirYogref0q7WmKNyHnlQe5Y=; b=LY+e0xJh7CRMTuN+UzdFrJndfGqfzIkswpvwTUX3FamhHJhu+A7fo0rNUDxr0cbPPF 41+76RfODo382BMuNvevRwr/FXKcgKhDTSWbXjajuhsEM3gQt5i58VFQin1+MctvIufA KtAChAiDr6e/RtH5BL60s7yP/CTPOwWjXgcI58Lp1l+4DMaFqXkCKSTAL5Vvc2iIsvf2 PglvZKrOI7RyUN9LNbgVMqCHLpT+eoznhuG2HVi4zsXqoPzl9MDE4c7IgdXLt36h7CQT WskBraNhqTuFRP6elRCDs8045XgKXWVHOeTY0DOnvRfL1pbD3Yc2M6rTCMI/Zv4G0H1/ 37AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458791; x=1724063591; 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=uTp4D3gMYy7OE1wuBDKAirYogref0q7WmKNyHnlQe5Y=; b=n0IYMftTi219qeqrSjTgxjRGwXFRrpPE+iGgB6jebSmprETqQLkr0Dl/M4qFV3T5uG Z5jP5cMwFKPruSc8Gz0L11P3PqxhZAjcm2/3fF9JnJJtNGF1ZZ2v/nQe6pRGcJbcMGR+ oDuvnpH1qDLp/7SIhi3GW72Qn4WyWs9yQwGRCr5s/sI5tDf8zB73gh+XYne9P1zI9Mlm vZE1rgHL8H0babPi36qv0GHn4q6TiNdLU9WxQiIKcnFpHmtjQMmknMSp502c+kwKLPfC ojZxLmLNlUUuxe1sScayzOc7PoifVSXNndzXD2A3Jt7/EpoJ3wbQDn3zj8VuK6Yg4pSg 6TRw== X-Forwarded-Encrypted: i=1; AJvYcCUtD+99z5R9IexL6qvYTLQnEbzW3embXL6jPtcn28qi7FVGS0KFIZxECNab+cTy311aiCm4UetgdwsrlWmbv3gK6i4mjw== X-Gm-Message-State: AOJu0YxzOx6RUJ8SR6w7WgLMM8pz6X2woS+9LXSCYFShhp4L1wyig22l eQznnqhsjPGiNbcXjkwbZ4PspKVvky58BkVIDFPloXh8fC9WGETn X-Google-Smtp-Source: AGHT+IGGgEtQeontU6KXiHeq9TbVYldrHDkUhoptQsr9ETIrgQSAK7vRSpk0SnPHsy/TGurfQgkCHA== X-Received: by 2002:a05:600c:4f8f:b0:426:6ea8:5037 with SMTP id 5b1f17b1804b1-429c3a643bdmr60411265e9.37.1723458790428; Mon, 12 Aug 2024 03:33:10 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:10 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 5/9] led: implement LED activity API Date: Mon, 12 Aug 2024 12:32:47 +0200 Message-ID: <20240812103254.26972-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement 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 are implemented similar to BOOT LED, LED_ACTIVITY_ENABLE to enable support for it. It's introduced a new /config property "u-boot,activity-led" and "u-boot,activity-led-period" to define the activity LED label and the default period when the activity LED is set to blink mode. If "u-boot,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 --- doc/device-tree-bindings/config.txt | 4 ++ drivers/led/Kconfig | 21 ++++++++++ include/led.h | 63 +++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/doc/device-tree-bindings/config.txt b/doc/device-tree-bindings/config.txt index 68edd177040..cd9ec88909b 100644 --- a/doc/device-tree-bindings/config.txt +++ b/doc/device-tree-bindings/config.txt @@ -30,8 +30,12 @@ u-boot,boot-led (string) u-boot,error-led (string) This is used to specify the label for an LED to indicate an error and a successful boot, on supported hardware. +u-boot,activity-led (string) + This is used to specify the label for an LED to indicate an activity + if supported by the operation. u-boot,boot-led-period (int) +u-boot,activity-led-period (int) This is used to specify the default period for an LED in blink mode. bootsecure (int) diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index fd9442edaf3..1336f943dab 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -29,6 +29,27 @@ config LED_BOOT_PERIOD help LED boot blink period in ms. +config LED_ACTIVITY_ENABLE + 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_ACTIVITY_LABEL + string "LED activity label" + depends on LED_ACTIVITY_ENABLE + help + LED label defined in DT to assign for LED activity usage. + +config LED_ACTIVITY_PERIOD + int "LED activity period" + depends on LED_ACTIVITY_ENABLE && (LED_BLINK || LED_SW_BLINK) + default 2 + help + LED activity blink period in ms. + config LED_BCM6328 bool "LED Support for BCM6328" depends on LED && ARCH_BMIPS diff --git a/include/led.h b/include/led.h index 2d3b89674e2..6a1471dae85 100644 --- a/include/led.h +++ b/include/led.h @@ -223,4 +223,67 @@ static inline int led_boot_blink(void) #endif #endif +#ifdef CONFIG_LED_ACTIVITY_ENABLE + +/** + * led_activity_on() - turn ON the designated LED for activity + * + * Return: 0 if OK, -ve on error + */ +static inline int led_activity_on(void) +{ + const char *led_name; + + led_name = ofnode_conf_read_str("u-boot,activity-led"); + if (!led_name) + return -ENOENT; + + return led_set_state_by_label(led_name, LEDST_ON); +} + +/** + * led_activity_off() - turn OFF the designated LED for activity + * + * Return: 0 if OK, -ve on error + */ +static inline int led_activity_off(void) +{ + const char *led_name; + + led_name = ofnode_conf_read_str("u-boot,activity-led"); + if (!led_name) + return -ENOENT; + + return led_set_state_by_label(led_name, LEDST_OFF); +} + +#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 + */ +static inline int led_activity_blink(void) +{ + const char *led_name; + int led_period, ret; + + led_name = ofnode_conf_read_str("u-boot,activity-led"); + if (!led_name) + return -ENOENT; + + led_period = ofnode_conf_read_int("u-boot,activity-led-period", 250); + + ret = led_set_period_by_label(led_name, led_period); + if (ret) + return ret; + + return led_set_state_by_label(led_name, LEDST_BLINK); +} +#else +/* If LED BLINK is not supported/enabled, fallback to LED ON */ +#define led_activity_blink led_activity_on +#endif +#endif + #endif From patchwork Mon Aug 12 10:32:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971533 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=OR4IJnI7; 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 4Wj9qP4HQnz1yYl for ; Mon, 12 Aug 2024 20:34:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D728888806; Mon, 12 Aug 2024 12:33:17 +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="OR4IJnI7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9BFE987D6B; Mon, 12 Aug 2024 12:33:16 +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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) (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 90F1387F19 for ; Mon, 12 Aug 2024 12:33: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-lj1-x231.google.com with SMTP id 38308e7fff4ca-2f149845d81so47152311fa.0 for ; Mon, 12 Aug 2024 03:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458793; x=1724063593; 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=c7wvb87HMZERBTWLcE0Zw9te/52TrDk6pCneIGETCws=; b=OR4IJnI7CAuM1DfzHpnsFOlxwOZ1+QOogzQdXC6I4lctLyBgnNnsS4An4POFAiN+xK dA/47QM1yNwMq4GxdTNSZ3wxdfbY1h5Vrj90Xhe6ShXUfpt+91aZrRMPJaTlQAoxVan0 8YeZIn66kNpKGaIG/WCaduAF+yV7wwXGKIOON68y/EYtySsuFtPMi3GRvgou+WazFdnD DTJSJ7NgjmeP/hs1WTeho0flDm0B6stLiPgKDOSRCLMmyywswU1bbGLdUhtlgFNYWQ9C bd82VW4QHZHlXdPgdy88XdQKsJgfpSfpjpUBcoR2B4s6fX5PXrMVnCiH/5Dy6d6rUhYq 5DdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458793; x=1724063593; 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=c7wvb87HMZERBTWLcE0Zw9te/52TrDk6pCneIGETCws=; b=gInmV5WdeawwB/zZJvgTXhKMDcpenRvCz+ySqdOD2Jtof++5DuorPaRjoZgUkrDBSl 0DhoNeoZpAv4pUngGaKwX5GBQj67o58Nq4g5wKlTzgNRqUOHfhczWPxyisW36F2N0VpG 6+bJYRnhZqqD2IKy6Qh8FqnBVCglWoSXufsWiR8SaPdA2Wio3pBUsMHZYTRT169p9cQy gY9Qh+B+tLQpoRLiTRl8VbLa6Hv4B7cm3dQsSCdM9Ho0eldsbGQ/Yhq5ut4gEYg9ZQSk xcdl5sP6+bXQAopM/giceRPfON39eiXWNXGouhIcweLF1b9AD9IPAmZUmIUUFPiDMSQx ootA== X-Forwarded-Encrypted: i=1; AJvYcCUu74O2Clm01bHFmka7fHBXo00gUyzIuAfP9ASql33PAom84Yi/jlvnU7ANw3oNNstaUg5ZCkG5+QFaEBnZ2WXCry+ruw== X-Gm-Message-State: AOJu0Yzip1P1G5/mpYHSvIXzWY/HKBH/K5LKU/9h1ICOgnhnjf9GQMpx QuP1f6PV8c3QmSnFaFC/i3N3vvw7XKBfJ101bctKJ7/jGqzGic6b X-Google-Smtp-Source: AGHT+IEaz1m49SXILOpzD+2eEGLWKzx9wJQ8aSM3RZI0JPoml+RmTbRrU7OEPcrgmuM5Wstx+W9gYg== X-Received: by 2002:a2e:b8c1:0:b0:2ee:974c:596f with SMTP id 38308e7fff4ca-2f1a6c68b39mr65867621fa.28.1723458792454; Mon, 12 Aug 2024 03:33:12 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:12 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 6/9] tftp: implement support for LED activity Date: Mon, 12 Aug 2024 12:32:48 +0200 Message-ID: <20240812103254.26972-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement support for LED activity. If the feature is enabled, make the defined ACTIVITY LED to signal traffic. Signed-off-by: Christian Marangi --- net/tftp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/tftp.c b/net/tftp.c index 2e073183d5a..45c2455336a 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -192,6 +193,9 @@ static void new_transfer(void) #ifdef CONFIG_CMD_TFTPPUT tftp_put_final_block_sent = 0; #endif +#ifdef CONFIG_LED_ACTIVITY_ENABLE + led_activity_blink(); +#endif } #ifdef CONFIG_CMD_TFTPPUT @@ -301,6 +305,9 @@ static void tftp_complete(void) time_start * 1000, "/s"); } puts("\ndone\n"); +#ifdef CONFIG_LED_ACTIVITY_ENABLE + led_activity_off(); +#endif if (!tftp_put_active) efi_set_bootdev("Net", "", tftp_filename, map_sysmem(tftp_load_addr, 0), From patchwork Mon Aug 12 10:32:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971534 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=VR7JgAgs; 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 4Wj9qc0hb0z1ydp for ; Mon, 12 Aug 2024 20:34:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 42FA58885E; Mon, 12 Aug 2024 12:33:18 +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="VR7JgAgs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3452887D6B; Mon, 12 Aug 2024 12:33: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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 46AB088806 for ; Mon, 12 Aug 2024 12:33: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=ansuelsmth@gmail.com Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-426526d30aaso28623385e9.0 for ; Mon, 12 Aug 2024 03:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458795; x=1724063595; 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=YDsR5hsQOVbKzYtajp2w9J7akkZ2dMTxwqymOi6BTj4=; b=VR7JgAgsF18SHI1Q+XduLtaReADRXbofm9qxPk3PELC1sSPVtrU6SQZU/EX+u+iubT sOhLcp5Ry4cXdvaAI7u00fRJg2Pmi2LQeqb30C1KKczb+mlpFkCy4mThtu481DmHjLdT g++qzFNrTA9nmqAJr+8nCcuuXzNqsh5zmv3LnI7f+lbD1lyPRxwyRtBJmds6K3NmtMDr /Mx7tIVt9Fsua6DSmy5HP4iDm7Vw00AmahDh+Fzq8czXrz+3uIUWc0hZMy2Y2S/JgPYA 2OC4QUkd1MC3V2Y1fiB8UAZoz0VrA180+J23VbvrWza1CSUmdEb74twoyLM3RLc78nkk NrCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458795; x=1724063595; 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=YDsR5hsQOVbKzYtajp2w9J7akkZ2dMTxwqymOi6BTj4=; b=ksJ9aMbuGxHvv/kVty/8f1IYR90/Mn2CzlII6MaWBMshy7exCnCLkMRsc5oO3HY63Y JJ/zHjd9d2+3xgAnNgsKZLTfQgpwOoiEA+JfUZ/bqp5XgJ2555GFLPT0mtGDhY8sI2W1 lDXHZScS/VbEzi93QgM9RiblxvecwQNe4dqGQGVDMqB7g61wdSkNjguhkR9/qnDZi0AJ ImPDkQAJSza2oIBfiH06ZdFuzs/TRyfe9zbX5W7iZJOpvTkB4XUomHTELmimDM48jO4D 5BjwjPog3YF/0lSlq5CrUjiBZCTP/AJ9inrEu7TvvpJtJhRSnG+QAzhR9e9cWdATBOGf f2jA== X-Forwarded-Encrypted: i=1; AJvYcCWjdGsPaOhJ17eHBPhntSBxf9PCcfvyqbm3DqUFs6mG0MQ9DuyCE8FaS2xj2yP39rmu7WhdHQrUiu7hE9JLLmVYZVsLdg== X-Gm-Message-State: AOJu0Yz0FpsPQBYhDVMxW7hYPPg+8kUVYptG2PC0KGsMj4eHl0T7HFUU jnYlasnSn0+gwWO0bo/xezC6OnAWs5djVh0SGh4v9DKMOqU1WTwr X-Google-Smtp-Source: AGHT+IFoypDNh3563g0OEyAHjXiPt4MOLTYCsQWAaLl7kjEPEGGiPMZ25FMUGCnhiycRLBoMdJr1og== X-Received: by 2002:a05:600c:4fc6:b0:426:62c6:4341 with SMTP id 5b1f17b1804b1-429c3a29a48mr69993275e9.20.1723458794576; Mon, 12 Aug 2024 03:33:14 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:14 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 7/9] mtd: implement support for LED activity Date: Mon, 12 Aug 2024 12:32:49 +0200 Message-ID: <20240812103254.26972-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmd/mtd.c b/cmd/mtd.c index 795aaa2b37d..ba5ee0d4d71 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,11 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc, while (mtd_block_isbad(mtd, off)) off += mtd->erasesize; +#ifdef CONFIG_LED_ACTIVITY_ENABLE + if (!read) + led_activity_blink(); +#endif + /* Loop over the pages to do the actual read/write */ while (remaining) { /* Skip the block if it is bad */ @@ -585,6 +591,11 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc, io_op.oobbuf += io_op.oobretlen; } +#ifdef CONFIG_LED_ACTIVITY_ENABLE + if (!read) + led_activity_off(); +#endif + if (!ret && dump) mtd_dump_device_buf(mtd, start_off, buf, len, woob); @@ -652,6 +663,10 @@ static int do_mtd_erase(struct cmd_tbl *cmdtp, int flag, int argc, erase_op.addr = off; erase_op.len = mtd->erasesize; +#ifdef CONFIG_LED_ACTIVITY_ENABLE + led_activity_blink(); +#endif + while (len) { if (!scrub) { ret = mtd_block_isbad(mtd, erase_op.addr); @@ -680,6 +695,10 @@ static int do_mtd_erase(struct cmd_tbl *cmdtp, int flag, int argc, erase_op.addr += mtd->erasesize; } +#ifdef CONFIG_LED_ACTIVITY_ENABLE + led_activity_off(); +#endif + if (ret && ret != -EIO) ret = CMD_RET_FAILURE; else From patchwork Mon Aug 12 10:32:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971535 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=KUE3wsCN; 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 4Wj9qp3kKyz1yYl for ; Mon, 12 Aug 2024 20:34:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9EA578885D; Mon, 12 Aug 2024 12:33:20 +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="KUE3wsCN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85E4588883; Mon, 12 Aug 2024 12:33:19 +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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) (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 8E42287F19 for ; Mon, 12 Aug 2024 12:33:17 +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-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2f035ae0fd1so45322621fa.2 for ; Mon, 12 Aug 2024 03:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458797; x=1724063597; 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=sIdfYcgX1Gb6+mMB6ALCPccG2uK9s3uiNEqRh1Rv7gI=; b=KUE3wsCN/hUIYUj88nFWd0J4ZPbDs5HXLpCxADu3Z3wUOyROK9t6p7Ks8p5M00Xnnj /1k5PV+NI/4XxyxLG3SPq9AjQwY2egwSzQmrhNuZPvLNo4Oj9IznpB/mQj0Wunp1CzBX XyWMg90a6Yvqbp2KAovEYHqLhEueyOaJ/qHeUf1P9BzilPONPOLU5ebOdr1BUFSIXMUG R+NAHyBPaioNOjxPEcVqF9egBifrido7WnP4+NKDrIcTEOdgKtxarbJ5f2MXETdTM0xU arEGeHF+Tw4eHsAR8GL2wqcdjK5sTBoogacCjQoxBv8TibX9FYDFilJQvZkai7Kg3TBt 5D9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458797; x=1724063597; 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=sIdfYcgX1Gb6+mMB6ALCPccG2uK9s3uiNEqRh1Rv7gI=; b=QrmEFWKcSNHF1fVoe3AdzATJx8ZtGjWvcE2JvAnhI5alK4zU9PhltYz0RcTX5pZ1VJ MR9rgDR6Eeuxb2VjL6Tfna7pKXIb7EPazGxRUVSvXuGj52OIn5BYSkakFd0yGi2ogte9 vcmkST6iMp3Wm644WQkG4t3bOgcWKxFiwS73UnAKwSq8pwg/9V2qsDxzGlN/xBUmdCeN TCMCImS9OMtzKnZfPJlE+CH+IEVXkwGEixGgAfeupull+MFerUBCUremvIBz/xaiYOqs GVeSi/ougd5afqhlbfZSMy2/G6H23O9MzU8MTvRePsUzWTDBiiwV/7k2reILdqQIFJfJ mbeg== X-Forwarded-Encrypted: i=1; AJvYcCVJygNiKvGCZDEbBsfWeXqilrTXZw59uEjDHW5lVTrAEcotfFZgzc95Td0Emem53Q2ZDzdfz7qqrXskh54tnJtyqA7dxg== X-Gm-Message-State: AOJu0YxhWrayBQAj5tnNddE6TfIpL2ngITDdG6gO2ftxG8fZCJwZ22GS bK0P/yIQxTMnTuPs1CSA/63dk1lNZjh3rGfpmtxM46gC6beRo2T5 X-Google-Smtp-Source: AGHT+IHLahR80ej2T890N6hxqmHCm7tBsOYOb4c7C1xv9mdH+dERl9DQx8izYY51HVk3FDKrQMO9bg== X-Received: by 2002:a2e:a542:0:b0:2ef:29d4:3d97 with SMTP id 38308e7fff4ca-2f1a6d02356mr63246971fa.5.1723458796642; Mon, 12 Aug 2024 03:33:16 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:16 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 8/9] ubi: implement support for LED activity Date: Mon, 12 Aug 2024 12:32:50 +0200 Message-ID: <20240812103254.26972-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Implement 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 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/ubi.c b/cmd/ubi.c index 0e62e449327..6f679eae9c3 100644 --- a/cmd/ubi.c +++ b/cmd/ubi.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -488,10 +489,22 @@ exit: int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size) { + int ret; + +#ifdef CONFIG_LED_ACTIVITY_ENABLE + led_activity_blink(); +#endif + 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); +#ifdef CONFIG_LED_ACTIVITY_ENABLE + led_activity_off(); +#endif + + return ret; } int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size) From patchwork Mon Aug 12 10:32:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1971536 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=eUJaLXtJ; 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 4Wj9r04Cfnz1yYl for ; Mon, 12 Aug 2024 20:34:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0AB29886E7; Mon, 12 Aug 2024 12:33:24 +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="eUJaLXtJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0167888533; Mon, 12 Aug 2024 12:33:23 +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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (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 C4E8E8861A for ; Mon, 12 Aug 2024 12:33:19 +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-x336.google.com with SMTP id 5b1f17b1804b1-4280bbdad3dso31253305e9.0 for ; Mon, 12 Aug 2024 03:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723458799; x=1724063599; 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=Qmou0XV7PQ5ykpqTk04er3tkk7KlBhskbL8qRGM38GE=; b=eUJaLXtJU/bhY8UQTn9kkjnivHPcq7qAONd/u0etfC/w7KeaRubn0AtD/TYE+5sFHf 0L0Ow1hCRosdnqlErhaGAxUNVSoi++DkbUQ1rmPbNohaBPeyW78WM3kaTPkB58tqS9qP WBFMdAUcoDfD9BXpd5vPeD3gigQVFv9K+RY5szLtFEF5kxC5Bbg/FU4keIFFKhybCyoP HEjTr59/9/p3Zz48GoLK+DMDkvx+pp/G+qSWqLpM7aUPhAYz84wIK24jJzd35XbHWy8K f9NgO1cxSxPMM41eh1e6ikrLQDHG1madoVbdti2s4CNE7ntTR2xzDFkp17EB0b5dJGff 5jlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723458799; x=1724063599; 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=Qmou0XV7PQ5ykpqTk04er3tkk7KlBhskbL8qRGM38GE=; b=focMdgqM1zdD/Nj3xu5coSp6Ay33/ONl4fDOO5qGsE03WwZ3yTGqRTPtHcSWhXIhZz XuPgXltffKqCllOXjXK4UScPR4wIqEICWsrZCtLfP6ZR3is/aRaAHf8ZR04qI2b26RvT s+mC3sg5kSTjtKByyn0KIN06IWbDWv9JqK4u0TFVMZM3NjWjKDc4YpXKVhsod6seiNku RIKwz/0iB5uYZ3W/rXu2EtuRzuQP4UWs2utR8RB7aVXyW31RYCZO1O8ha7+8QknPFzLR kAv0EbVnh4OD/d+ODPuFu6Wbm6mG54XQcWhUd4KDwFsYYnJLV3kJQcDBtClK/CmHIk0y f4ag== X-Forwarded-Encrypted: i=1; AJvYcCVtFO7a4EWsck7Rgs+jfaISdQlq9GwHhNu4Gw1h0NEokHfELJI/RiyAc3iRfuvTxNcmmCt2nOT2Fmex04uNOSE86COPUA== X-Gm-Message-State: AOJu0YzHck/1ScK1zYux1StzOCDvAegueMptwtV94nlGZFUZ6pC5y2Jt OJYRuccJlb0XZI9lqbhO5O39W5nINVyOUHGScnR0QIL2yMue/DhW X-Google-Smtp-Source: AGHT+IG9bBm/JCED2GOyOJjdipWSDpEF/ACQFyBD5eL2zJt6hbtzmQEYOEHui6rvKGrVtIagir5c/g== X-Received: by 2002:a05:600c:5248:b0:426:6308:e2f0 with SMTP id 5b1f17b1804b1-429c3a5690bmr58656655e9.26.1723458798970; Mon, 12 Aug 2024 03:33:18 -0700 (PDT) Received: from localhost.localdomain (host-79-52-250-20.retail.telecomitalia.it. [79.52.250.20]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4290c77f078sm186016425e9.37.2024.08.12.03.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 03:33:18 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Simon Glass , Christian Marangi , Heinrich Schuchardt , Miquel Raynal , Arseniy Krasnov , Heiko Schocher , Michael Trimarchi , Martin Kurbanov , Alexey Romanov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Artur Rojek , Rasmus Villemoes , Leo Yu-Chi Liang , Vasileios Amoiridis , Mikhail Kshevetskiy , Michael Polyntsov , Doug Zobel , u-boot@lists.denx.de Subject: [PATCH v3 9/9] doc: introduce led.rst documentation Date: Mon, 12 Aug 2024 12:32:51 +0200 Message-ID: <20240812103254.26972-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812103254.26972-1-ansuelsmth@gmail.com> References: <20240812103254.26972-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Introduce simple led.rst documentation to document all the additional Kconfig and the current limitation of LED_BLINK and GPIO software blink. Signed-off-by: Christian Marangi --- doc/api/index.rst | 1 + doc/api/led.rst | 10 ++++++++++ include/led.h | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 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 6a1471dae85..fe66192eeae 100644 --- a/include/led.h +++ b/include/led.h @@ -11,6 +11,45 @@ #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_ENABLE` and define in `/config` root node the + * property `u-boot,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_ENABLE` and define in `/config` root + * node the property `u-boot,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 `u-boot,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` is disabled, + * these APIs will behave like the `led_boot_on()` and `led_activity_on()` APIs, respectively. + */ + struct udevice; enum led_state_t {