From patchwork Mon Jun 24 21:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951815 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=K4Ejwluo; 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 4W7M4T3yYrz20Z9 for ; Tue, 25 Jun 2024 07:47:05 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C10C988418; Mon, 24 Jun 2024 23:46:39 +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="K4Ejwluo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 93DCD87B1A; Mon, 24 Jun 2024 23:46:38 +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-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (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 9083088119 for ; Mon, 24 Jun 2024 23:46:36 +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-ej1-x62c.google.com with SMTP id a640c23a62f3a-a62ef52e837so587060166b.3 for ; Mon, 24 Jun 2024 14:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265596; x=1719870396; 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=Lwn27umt7Ia1pnQO+R9k1S/p3TzisyCSqEQ9iSKDuUo=; b=K4EjwluoR4NBy70wvAHQLPZ8Bh6oMhcYnxZrzUj4HpPyWRenXJLTLYz/HRvKJdGS4C v3JSctt0Tunk02e5vtMFShtL4NRnq6lv+KwnBJ+8FHwN85t9HQ8aWpzc0fR8QHUw1nOq HCgEgIF6h68U/pmIGPxcUQd4PvOOC5b2Og9+uflJcOER4dvUp3aGCk6RXwZqoni5W9U9 MCkdxbDW486w3cxnVP7pCXxvG2Koz8smWGs3nhHRnVPYAbIJzTyBDDy6zU34/9jLWbOl KYI6rzqTxBaLt/3TSsvV/JTfbqHOeaXfZ9MkbjGsdSrLFzjUdVNv02gcCmAYTEPx9rt3 ve+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265596; x=1719870396; 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=Lwn27umt7Ia1pnQO+R9k1S/p3TzisyCSqEQ9iSKDuUo=; b=VzyZbbf7K15jzMc7gHdh+8evqC8K8poNasAis3Hs47fLIkP4vss6fNKYmwBSz5JyC4 CPvIf31ZWfIOiZmK47MaiOTFqiwKl1OEQ1ZTeRvlWI1W9uckdfUrFn4swuj+gMWf4dlC GyUJYVZujtX3T5w0ezfjSwAJxnQpmiLqkgLx4JgtMYz+PD/X45t4R9J1CrOp+47Mqsvl ChtQGcqQv9hY/xa+TntlSjUWw1XLaFYdZIhL4+06TPl1fm4+6qkd/aP5eQA4YUERMf73 yE2o/rFR862GRtacziww+oqVmk1h9jVtUcBgbJdzR3YmRW5/+lTm0Tae+RkXS5VIbOxC dm5w== X-Forwarded-Encrypted: i=1; AJvYcCU0ODHKiWTsxQTd1uCh6zXOxjOynIswq+wHdYcwkesUl8jhPWUvyKLRX7qeyziSPpSad4GHt2u96+JBCpUTFPsYuo22YA== X-Gm-Message-State: AOJu0YwH44Ps+xFKkYWvYp+4qVtDemPJywNdjLxNYgrGNSb6VuPdcEsZ ozSuKG4Ms3feEb33SoT626CKS+oYsCuANbYDTNzKX/93G1zeA+Qu X-Google-Smtp-Source: AGHT+IHliy9X/co+Ru+cZp1q5pqHv+Z7aSFf42QJT9y45ztOpZouKHtArtmgo/fNKr1LDWMx4S6KLg== X-Received: by 2002:a50:bac3:0:b0:57c:7471:a0dd with SMTP id 4fb4d7f45d1cf-57d4a2815a6mr5274051a12.12.1719265595460; Mon, 24 Jun 2024 14:46:35 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:35 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 1/9] led: led_gpio: add support for SW Blink Date: Mon, 24 Jun 2024 23:46:11 +0200 Message-ID: <20240624214626.24336-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add support for GPIO-connected LEDs to make use of Cyclic API to simulate Blink by software. A new Kconfig is introduced to enable this, CONFIG_LED_GPIO_SW_BLINK. Signed-off-by: Christian Marangi --- drivers/led/Kconfig | 9 +++++++ drivers/led/led_gpio.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index 9837960198d..13d6eb40cea 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -91,6 +91,15 @@ config LED_GPIO The GPIO driver must used driver model. LEDs are configured using the device tree. +config LED_GPIO_SW_BLINK + bool "LED support for GPIO software blink" + depends on LED_GPIO + select CYCLIC + select LED_BLINK + help + Enable support for GPIO-connected LEDs to make use of Cyclic API + to simulate LED blink by software. + config SPL_LED_GPIO bool "LED support for GPIO-connected LEDs in SPL" depends on SPL_LED && SPL_DM_GPIO diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c index ce22fb49f2a..20a6c149e4a 100644 --- a/drivers/led/led_gpio.c +++ b/drivers/led/led_gpio.c @@ -4,6 +4,7 @@ * Written by Simon Glass */ +#include #include #include #include @@ -13,13 +14,60 @@ struct led_gpio_priv { struct gpio_desc gpio; +#ifdef CONFIG_LED_GPIO_SW_BLINK + bool sw_blink; + struct cyclic_info cyclic; +#endif }; +#ifdef CONFIG_LED_GPIO_SW_BLINK +static void gpio_led_toggle(struct cyclic_info *ctx) +{ + struct led_gpio_priv *priv = container_of(ctx, struct led_gpio_priv, cyclic); + struct gpio_desc *gpio = &priv->gpio; + int state; + + state = dm_gpio_get_value(gpio); + if (state < 0) { + printf("Error getting value for GPIO %d\n", + gpio->offset); + return; + } + + dm_gpio_set_value(gpio, !state); +} + +static int gpio_led_set_period(struct udevice *dev, int period_ms) +{ + struct led_gpio_priv *priv = dev_get_priv(dev); + char cyclic_name[16]; + + if (priv->sw_blink) + cyclic_unregister(&priv->cyclic); + + snprintf(cyclic_name, sizeof(cyclic_name), + "gpio_cyclic%u", priv->gpio.offset); + cyclic_register(&priv->cyclic, gpio_led_toggle, + period_ms * 500, cyclic_name); + + /* Init the LED on */ + dm_gpio_set_value(&priv->gpio, LEDST_ON); + + priv->sw_blink = true; + return 0; +} +#endif + static int gpio_led_set_state(struct udevice *dev, enum led_state_t state) { struct led_gpio_priv *priv = dev_get_priv(dev); int ret; +#ifdef CONFIG_LED_GPIO_SW_BLINK + if (priv->sw_blink) + cyclic_unregister(&priv->cyclic); +#endif + if (!dm_gpio_is_valid(&priv->gpio)) return -EREMOTEIO; switch (state) { @@ -50,6 +98,11 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev) if (ret < 0) return ret; +#ifdef CONFIG_LED_GPIO_SW_BLINK + if (priv->sw_blink) + return LEDST_BLINK; +#endif + return ret ? LEDST_ON : LEDST_OFF; } @@ -84,6 +137,9 @@ static int led_gpio_bind(struct udevice *parent) static const struct led_ops gpio_led_ops = { .set_state = gpio_led_set_state, .get_state = gpio_led_get_state, +#ifdef CONFIG_LED_GPIO_SW_BLINK + .set_period = gpio_led_set_period, +#endif }; U_BOOT_DRIVER(led_gpio) = { From patchwork Mon Jun 24 21:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951816 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=ilg1XRRx; 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 4W7M4c4xS2z20Z9 for ; Tue, 25 Jun 2024 07:47:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 31FC988481; Mon, 24 Jun 2024 23:46: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=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="ilg1XRRx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A80D888412; Mon, 24 Jun 2024 23:46:39 +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-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 B17C6882DC for ; Mon, 24 Jun 2024 23:46:37 +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-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-57d203d4682so5795309a12.0 for ; Mon, 24 Jun 2024 14:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265597; x=1719870397; 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=nBkr1XCfMuJlQSMMcwjBGGwlw9SBwzqro/e6vXMYw3o=; b=ilg1XRRx1rdF8nujzTd/GztOyCKb3r97VHDsZGdDbQLM+pIsMrMq0rmkXwcamc2bpE FZ2dMpE2AnJbZQAaDpvi6Pa1WmEYbOEceRcQC+55e4DBmOjb1MRIb4APef6NflybqVFT 0d2UEq72HmDp8do55FImu5/0BDthNYW16QGayO1jHssGyL8GU7lMqRiELSyGZW6zakNA 1+Sbsbm4SxyGKeSKgN+FpogDtY3+tVG0rcp+eAcvdOhlTyEp8oyx6aGTKc/HLj6QdE8Z +httFNWk9YaZ11qgCspcCUsBn/R6J+pWJSS3vlYRgp2Q8GjRhSq0kSRPCap/W2QBlDVX RDUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265597; x=1719870397; 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=nBkr1XCfMuJlQSMMcwjBGGwlw9SBwzqro/e6vXMYw3o=; b=hNsCSlSljm66w1Q3/FIhnzD0LhR1VfZPxkL+iLY1DlboKBIQdwkOZtGH4TjIs4nD5W dJxb+Ac4rr1j/iJt2x31yV0I6Zv778vuBenKxk2J9zDYmPYCm+eaWhK1eRbZM5bSUy54 Sa7tG35XOl5TUGz8VGpIG5Xs8kYper7+qJk9J1CTd1xmhmf8/hwFu95JXoYfLmrO05ss GgOkVs+GRx916LPD8Nq+RjyVZAWKptZfbZj4QYj7CKRoz7FBSejkFz5yHxDKZHbSZoMO BwG2MSPppXyNFoVfvVc9bQz5G8HE0KMTupXKqS+vESZTDvWx5gVHc+qDsF6Sn9x/5XbX n8tw== X-Forwarded-Encrypted: i=1; AJvYcCXK98v9kLjOdl2cILaPnpT5W5dBmmOwtR4cGhla6oMI0PHZy0J9TMZWKitxGVDeLnTCD5Osam7FYyaGcclJB9wxXknNlQ== X-Gm-Message-State: AOJu0YzfRrLUn5v6RJDyoUNw0XMcWHdT8CFleKHu93ElTFoqepJfe/0N 96LB2b/aBKiWFgemPAZoiPv++HVC6KieLZndouWk+XPG4o4bVfET X-Google-Smtp-Source: AGHT+IFN8KXr+WUDPaZEuGllMibkBn3E4kmf4L/aPd1/iNbYGGzuOPtHXieUfHG2oT6Jbngn0xxxRg== X-Received: by 2002:a50:d698:0:b0:57c:ff94:c817 with SMTP id 4fb4d7f45d1cf-57d45791fb8mr3385031a12.16.1719265596852; Mon, 24 Jun 2024 14:46:36 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:36 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 2/9] led: implement led_set_state/paeriod_by_label Date: Mon, 24 Jun 2024 23:46:12 +0200 Message-ID: <20240624214626.24336-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-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 f37bf6a1550..d1e9916bb33 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -61,6 +61,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); @@ -81,6 +95,20 @@ int led_set_period(struct udevice *dev, int period_ms) return ops->set_period(dev, period_ms); } + +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); +} #endif static int led_post_bind(struct udevice *dev) diff --git a/include/led.h b/include/led.h index a6353166289..71dd7a28d93 100644 --- a/include/led.h +++ b/include/led.h @@ -93,6 +93,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 * @@ -110,6 +119,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 Jun 24 21:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951817 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=anRiUYSF; 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 4W7M4q5cvXz20Z9 for ; Tue, 25 Jun 2024 07:47:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9B4FC884E5; Mon, 24 Jun 2024 23:46: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=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="anRiUYSF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ED6CC884E5; Mon, 24 Jun 2024 23:46:40 +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-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 057A0883CD for ; Mon, 24 Jun 2024 23:46:39 +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-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-57cc1c00b97so4600341a12.0 for ; Mon, 24 Jun 2024 14:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265598; x=1719870398; 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=NZ4kWG3twGxCVLj6uKain/qVjrWftO9nQKi4a5+SpF4=; b=anRiUYSFAPzHjPxzbY0xWziX9h1OMOiMqG/CXiSyapdbrqTBCxKT3HLxmPh/wXvBR5 DniLOZOKAb5MsQXEYZ92PysvPPf54d0BBfVdbswmU7lH9OQUEuj7UEYe9kUdd/eu+MWc vcqsHkSJOpeANUS9gllhb6RE5hM7oHfvwUf9pzn1fE+nivkiy7LVbZL7FeKq5t5md1PV AkdXM80rSpBauz2lv4V9/UTkzuW6BN+eVo91UPa9nvE5bwrynk6uPx6F2kDkNuxzLig7 Nkn6kPecT4Zji1i2VB4zG7TnNpbmTP+/iyPxVTO1xN2XGoZdal6Vx6FwUcKt2wA65TaM gKOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265598; x=1719870398; 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=NZ4kWG3twGxCVLj6uKain/qVjrWftO9nQKi4a5+SpF4=; b=lQ3DPAEvZT92nu+Wkczjc+vc48sod63g3ymicNeWt/iVjr0+Jt0cf8DoeVAwSvXDp+ +8fSBKo0Ftlhsxd31asVaF90SPA7X66rgrLi4IhUiPGQPxPShgbudxwsuYinPJO1MB3P sqoUUoB1RpJLYZ6H10wWiepWkjdHWUIZta8Mae2iGN6nxkxsayU8TxBKRxMam1d6TJbv Vt/lNZ99Ym0mArwHjxT1zD9OgdkSFS7y10zMQLCCXcamz+8Kb0gWB5OTOCKTtZTb5QW6 ugdiRAULra+Iq1ZPMnrTR2DacrciDXg57upNIXU+ZLwQnce3e8rXiyWA8TFr8ctX8FqK YjRg== X-Forwarded-Encrypted: i=1; AJvYcCXyyO6IEEWy0PSLZIHOzJ2H47FMWERay+nkuZ4uE7ddqY5DtBHekbzZuGTASjE+IwSboNCeO5NvgHxg/0MRZgwQXiRtpA== X-Gm-Message-State: AOJu0YxCWTJluIfaoYb6L5kkESGxxRoGZRj2IK51ZZmzoub+8siKGTMf UaxLRjpkp8TFo+6o9gS8Ow6bebn8oy3k+jrNtDAzGMAF9QAWhbD+ X-Google-Smtp-Source: AGHT+IHHv84Ii2PuRGJEvNTxys8Ts0KdYhyYGmOt0DcpTJl4tIHLwu49dHxyvP8aFcukDUPKg3cEaw== X-Received: by 2002:a05:6402:26ce:b0:57d:544d:16e with SMTP id 4fb4d7f45d1cf-57d544d01f6mr3262043a12.31.1719265598233; Mon, 24 Jun 2024 14:46:38 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:37 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 3/9] led: implement LED boot API Date: Mon, 24 Jun 2024 23:46:13 +0200 Message-ID: <20240624214626.24336-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-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, CONFIG_LED_BOOT_LABEL to declare the LED label in DT to reference the LED for BOOT usage and CONFIG_LED_BOOT_PERIOD to declare the blinking period. If CONFIG_LED_BLINK is not enabled, led_boot_blink call will fallback to simple LED ON. Signed-off-by: Christian Marangi --- drivers/led/Kconfig | 22 ++++++++++++++++++++++ include/led.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index 13d6eb40cea..0506a33b6ee 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -9,6 +9,28 @@ 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 + default 2 + help + LED boot blink period in ms. + + Value is normalized per CONFIG_SYS_HZ. + config LED_BCM6328 bool "LED Support for BCM6328" depends on LED && ARCH_BMIPS diff --git a/include/led.h b/include/led.h index 71dd7a28d93..479c6d17c5b 100644 --- a/include/led.h +++ b/include/led.h @@ -136,4 +136,44 @@ int led_set_period_by_label(const char *label, int period_ms); */ int led_bind_generic(struct udevice *parent, const char *driver_name); +#ifdef CONFIG_LED_BOOT_ENABLE + +#define LED_BOOT_PERIOD CONFIG_SYS_HZ / CONFIG_LED_BOOT_PERIOD + +/** + * led_boot_on() - turn ON the designated LED for booting + * + * Return: 0 if OK, -ve on error + */ +static inline int led_boot_on(void) +{ + return led_set_state_by_label(CONFIG_LED_BOOT_LABEL, 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) +{ + return led_set_state_by_label(CONFIG_LED_BOOT_LABEL, LEDST_OFF); +} + +#ifdef CONFIG_LED_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) +{ + return led_set_period_by_label(CONFIG_LED_BOOT_LABEL, LED_BOOT_PERIOD); +} +#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 Jun 24 21:46:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951818 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=lgK4Happ; 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 4W7M542bxjz20Z9 for ; Tue, 25 Jun 2024 07:47:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 119898855B; Mon, 24 Jun 2024 23:46:44 +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="lgK4Happ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2DD7988119; Mon, 24 Jun 2024 23:46:42 +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-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 37F608848D for ; Mon, 24 Jun 2024 23:46: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-ej1-x62f.google.com with SMTP id a640c23a62f3a-a6fe7a0cb58so128870566b.1 for ; Mon, 24 Jun 2024 14:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265599; x=1719870399; 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=dJX5RhwWGDdrpnAtg3eu17Ph2P7mi53gQC+5L1tt27k=; b=lgK4HappRtr0Ut2EM3yk6ygaAVFEohw3py2wQ70yhpzg7jGDf/Velu7mWSzZLOlCBm Nae7XYNTTnslY/Nc0MtQDwYHGmppA+XdasPHeLwYfd23KqDDFYTlUPcu+5nrHhtDf+PS 7FeiN+YRUrPvnzkSP+lu/D7bYbrFxVAKblWeCyxTFrejvTSY2ohed6lCt1DoG3UbffLh s9IB/1ZhHroeTbu63tH2d2BJrPZVa+x45ml/x+6X5eKTtxNZUguycofAPC4Qyy9B3AkT U8pRamXWXpO9SvH4YmjmzwKCQIRJfLdvp/qy8UY2/oBYGmhzGvwnlqyq/hrVId15zjlj X0xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265599; x=1719870399; 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=dJX5RhwWGDdrpnAtg3eu17Ph2P7mi53gQC+5L1tt27k=; b=jhNN200izAKXpFUrW5mKand0HItUybC7s0DahaamK/22cCuUBr6qkvQn8EAITiIBzk KtDpbSLMCTf/UNtEHbwi7nw/OCheV6UByzOvDKORRcr2Dphg4k7moqxM0uXEILxGdW0E 7gTS1Xhzoak16ikxcJGWUcpUHnIDKs0gOqEYt5zSJO9a1i7kjPk3PHRR/BD2UDV42oKV 8iRANEFTo6MFkDbDxs4dPaZFGVnMH4NvDpsH9R7bM5ix9pKTKwjIrEk5SvWkM7Lc9N1J xmTCnQgoAgc3690u6Q1v0DW3vOqpnK3JrllC8zW6qtRQcJateWDeVsDlQVkb/KVjf2H2 SHeA== X-Forwarded-Encrypted: i=1; AJvYcCURD3PJpPf6fxOEcqpehr3fHrxpPny+O3DN2fY5Ou+wvwza+tyc7t9ddzIafMAbzSL0w2eAdNS6+KReOprX9rSMmrsfoQ== X-Gm-Message-State: AOJu0YwZCGwumumvEzmXX7joFNvGNDuxmQ/qae6rZV5D5EdkwSIPh1SW K0xq5eDZBNH8JgUmH7snAf5zbY2mmVpu8oqe7+SUTdPSHdtOJP/W X-Google-Smtp-Source: AGHT+IHP+xrYkg/sI01AXS7y7/pLdm63OKm7HbjGsqzgfPTofGPtbK3T57nWn/UF3MY333xr8vTWyA== X-Received: by 2002:a50:d653:0:b0:57d:3b8:85e6 with SMTP id 4fb4d7f45d1cf-57d4bddfba2mr4257717a12.39.1719265599562; Mon, 24 Jun 2024 14:46:39 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:39 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 4/9] common: board_r: rework BOOT LED handling Date: Mon, 24 Jun 2024 23:46:14 +0200 Message-ID: <20240624214626.24336-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-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 c823cd262f1..6a4dacdea88 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -463,14 +464,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) @@ -717,6 +734,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, @@ -739,6 +757,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 Jun 24 21:46:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951819 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=hdzkEctt; 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 4W7M5G0yT9z20Z9 for ; Tue, 25 Jun 2024 07:47:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6FF9A883CD; Mon, 24 Jun 2024 23:46: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=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="hdzkEctt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A147F88548; Mon, 24 Jun 2024 23:46: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=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (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 A6921883DE for ; Mon, 24 Jun 2024 23:46:41 +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-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-57d0699fd02so2516069a12.0 for ; Mon, 24 Jun 2024 14:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265601; x=1719870401; 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=hFdiYLPFmEwefSVTZoSBcmSl62d4EleDoiEDFT53tAI=; b=hdzkEcttjAAuDxTWOMwkwB/I7WKxvNRXKREoudcC0k1WxuugPrpyI03qOCGCUZvxXY G9YEUZn+jcYXDIqQe8TEFj6KABTwOaiLq4+vVpkkArlU1wh8Kxj4dIj4TPWK8jZ4smlB 2EJEv43BDgDY+BjEccyE/zdxmzK65xgdHQsRTiZhOkIqUOsKG4s7dMc0YAKCvBqe0eBV ErynwQeC1hpGQ1yakVU1X41ojHpmn02661wZ/vNLkjYL8QkFms+flzZi1cCGi80dc3Nl qLCCtKRLcnCXngih5OxVCOKrXZPQVkgduoFva2wnajU8vZ6SSQJVKBp1NSBzF+eiB+8I N1ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265601; x=1719870401; 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=hFdiYLPFmEwefSVTZoSBcmSl62d4EleDoiEDFT53tAI=; b=Fm3ShTn1a6DQe+fe9qJQawxXNZ8yIQ+KLRf9hoMsEp6rtI5ffvFp0hsuiC+ohfV8ri +YQ0wxooqrQ5MaT1u47eIbI+bBt8w+fWXeCmGG4RM5/hppNPQ3ttF5TvKGytPgZ/eWDf aJAYmwGnhF0GJJlGR08A5hb7Rfl3sVWY6bpp0aNNRDWQWdykX/rm80L8t+w9R3vajIUZ 3vfEOgHiSsAtxIyzg7mY/lnPevoGeEVGoUNM6YWD/SRPP08MqgdqEgrWjQqsYoymHAfU 6mOOTeDSTLgSkVPrujVLtZLOiwOnhXHYfE8FwoMJ8Eaw5S2MokRYsLEviM6jN3q5yaig VaHw== X-Forwarded-Encrypted: i=1; AJvYcCWMPRGS4gwvzf1T0srYKXucd04v0tVCOKVQF3UcYUwpbxcKOou96/UiuIdV6WJ62Od4Ag6ZPtfkiwwfsVdBvBR9x6A1lw== X-Gm-Message-State: AOJu0YyWaqsUKIlytL0GA2rzNBKbVxAMhrxqTdoLoTYwyue72e/L5KmK dfzWBK+f0KnQ0kJBiVYjPoEJWIxuaoZkH5pMCQ7cTVOTsBG/2V9+ X-Google-Smtp-Source: AGHT+IG3Z19HNcmsa1dP7Nq2xSpAhMpcpPfrziA4788/WcyGFoC/dV8Uly3aXu01Zs9YXDiyFZ7s4g== X-Received: by 2002:a50:d50c:0:b0:57d:579:3ca2 with SMTP id 4fb4d7f45d1cf-57d70069df6mr840732a12.30.1719265600908; Mon, 24 Jun 2024 14:46: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 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:40 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 5/9] led: implement LED activity API Date: Mon, 24 Jun 2024 23:46:15 +0200 Message-ID: <20240624214626.24336-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-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, LED_ACTIVITY_LABEL to assign the LED in DT for activity usage and LED_ACTIVITY_PERIOD to set the blinking period. Signed-off-by: Christian Marangi --- drivers/led/Kconfig | 23 +++++++++++++++++++++++ include/led.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index 0506a33b6ee..f53e5fb5bd3 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -31,6 +31,29 @@ config LED_BOOT_PERIOD Value is normalized per CONFIG_SYS_HZ. +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 + default 2 + help + LED activity blink period in ms. + + Value is normalized per CONFIG_SYS_HZ. + config LED_BCM6328 bool "LED Support for BCM6328" depends on LED && ARCH_BMIPS diff --git a/include/led.h b/include/led.h index 479c6d17c5b..409397e1df9 100644 --- a/include/led.h +++ b/include/led.h @@ -176,4 +176,44 @@ static inline int led_boot_blink(void) #endif #endif +#ifdef CONFIG_LED_ACTIVITY_ENABLE + +#define LED_ACTIVITY_PERIOD CONFIG_SYS_HZ / CONFIG_LED_ACTIVITY_PERIOD + +/** + * led_activity_on() - turn ON the designated LED for activity + * + * Return: 0 if OK, -ve on error + */ +static inline int led_activity_on(void) +{ + return led_set_state_by_label(CONFIG_LED_ACTIVITY_LABEL, 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) +{ + return led_set_state_by_label(CONFIG_LED_ACTIVITY_LABEL, LEDST_OFF); +} + +#ifdef CONFIG_LED_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) +{ + return led_set_period_by_label(CONFIG_LED_ACTIVITY_LABEL, LED_BOOT_PERIOD); +} +#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 Jun 24 21:46:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951820 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=QN79LKwg; 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 4W7M5T3sgJz20Z9 for ; Tue, 25 Jun 2024 07:47:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D47DD88548; Mon, 24 Jun 2024 23:46: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=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="QN79LKwg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D53088856B; Mon, 24 Jun 2024 23:46:44 +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-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 E937C88119 for ; Mon, 24 Jun 2024 23:46:42 +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-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-57d203d4682so5795376a12.0 for ; Mon, 24 Jun 2024 14:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265602; x=1719870402; 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=TbWCl3JKt5osSAvU/qnIkSMhub8oYfz5yRddNUQP0tY=; b=QN79LKwgSpqFRawbky4lSXwWwm9FF822YkSR36gQzzH9a4JghK3Nd0vaWpP6xVXXR8 FGnF5utY2pSk3c+zUN0sCvcl1IP2owNdxPTG5fJfgLbPlyWG2Fj4G9jQTcC9aUUT4Mox d2HRGAyRGifLPZiosB4bUqGf+gPVuXzqG07xnCZ4D1ucaVGGmjNW8Q6RWaGHs/ndUeYl Ow4WwoIXRrVnrMyacadQWKbSPT/pcLD7iGL3PqozSycRFkp2ooPLtxrNt/tAnDNoGMoy 2Pk4FqqMW+aDsR7K9tWd9MHevmLJP5bp/qQMf5Q7URVomv5YmR3JRWsLalJWrU53R828 5FRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265602; x=1719870402; 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=TbWCl3JKt5osSAvU/qnIkSMhub8oYfz5yRddNUQP0tY=; b=avOMpWTBHQUx6/mj8sRKs3xUby/lEko97qKvoPw8qutYOyOe6VuocQtEs8dQ60pFhN 1ri3iEDVl0zxDcMsqOOZXHYvaLYPSf/rOlsh16nS677hvOVy9DZKRa3txmkLgcgeTLIQ O+z+6+kiDL2QXztLiV9gwxaCJtNQCGin0AhRYBPyRxCzWMbXNB8+zahhPbbhpyj0Etzm MqudmbUyiZIicLqv33pyPXyZUU/Z3S+Xc6VmhwnoetvxH6muJZ8JlFS7KJPaNVXLgVoe F12ccepF4/jGX69qc5FK4T1SIbtsBJLvwDnnWOWkmnLhVtI3bYU/YIbsSfq1A/E1pOZf e42g== X-Forwarded-Encrypted: i=1; AJvYcCWJqvgSLepEALJxqLqkqFrznW0qzM6suX57aOvMI/UUK4wQCTrpQ+mCjTxTsrwRxrjOb7mNCvj26ZV9DVJOrIDGfIwAOw== X-Gm-Message-State: AOJu0YxIIFOykMGuTpVRPCZU1UDIdl+eAdXovS4fUixNEijoOfPoPcTn vDFzUfcMROnNtUP+TMwilfhDoAhn4BK4YgwuxKBnNue3EpB0YPI9 X-Google-Smtp-Source: AGHT+IFKx/VEyeM+qOoyvgdtHELXDV2BakmXeFk3IvpmKxrK+rKK4LjO2Gtoj7+8B0HoAf3CW1oisw== X-Received: by 2002:a50:ab1b:0:b0:57d:524:8818 with SMTP id 4fb4d7f45d1cf-57d457a1497mr4504598a12.20.1719265602299; Mon, 24 Jun 2024 14:46:42 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:42 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 6/9] tftp: implement support for LED activity Date: Mon, 24 Jun 2024 23:46:16 +0200 Message-ID: <20240624214626.24336-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-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 6b16bdcbe4c..1d6609342a9 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 Jun 24 21:46:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951821 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=f6ML0wso; 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 4W7M5g3x9sz20Z9 for ; Tue, 25 Jun 2024 07:48:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4467F883DE; Mon, 24 Jun 2024 23:46:49 +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="f6ML0wso"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4CF32883AD; Mon, 24 Jun 2024 23:46: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-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) (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 4848388568 for ; Mon, 24 Jun 2024 23:46:44 +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-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-57cc30eaf0aso2787007a12.2 for ; Mon, 24 Jun 2024 14:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265604; x=1719870404; 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=cp4QGkKRJQZKBYprVTIXWZslmqe9jjml8oA/1n4BPRU=; b=f6ML0wsoQ2fGgszCHr+XPVkklQDTJCVjARJ7kJgiZG5wdYnXgedI+SUwDsYGexKsdS DQVzqYHFqZW7bTNEGyVB+RMeO6KlY0ZucZbxjupJ8h2oMBNbU5SIFkCIILsOBxwR2I5b BaV+qY5NtoajqoRmLOxFCElxUQZx/NOWn7dHeH5u3PFELuIMTBwWbbCEum7kasoqiqRP alWRcdsG6/+ZkSW5H3eIHSD0oY5Zx/CUC65+E3FWzoMR2xXhqU71uAPOW9QStU4l5seo EPxnZSFc7ocwlg3wmzZtyftzIVa2tZ3vHxjDCOnaC6a3pisqGNl3eHOeb2XOF9EhRO88 +GgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265604; x=1719870404; 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=cp4QGkKRJQZKBYprVTIXWZslmqe9jjml8oA/1n4BPRU=; b=wX+/MT8tEXMfoSYZvKdvg9DseZjgDsRcdMsX/YBGUOXmD00PpL4JrMmeQXKDRghOMt QL++uPFcv0dDgHJ1laGgP9WrBz7zLnnrAKpwqiG4XMMbkCyO6GfXIHnGdu6fvF/rCgGQ WZTb2HEAiNIB9AMG03+E8+OzYBzQgYVRxymXkYxwxCbTmlawpymccpPcEuOs362kEhcn rGT4zDuuhr61D89MKQgyw10YoxpMEefaljtktbaeg1VkHh3ZT0HkH36hMUS13IWeD/pJ bhrO0+e+hBYN5CPrlkKn7Yye8L6lU0a3gdnKNC27Tonssbox1Wq8fDhYaLVu+cEkHuoY OjVg== X-Forwarded-Encrypted: i=1; AJvYcCXj4CtLmNwNYMS9cD4cNxRMsgyzxrxBisLjbhpnkvJd++DPqTUw9MW0scEcOIt/CRHs9kZTsAbw2ocCn98ukhJSAS1z4g== X-Gm-Message-State: AOJu0YxFx5oLZYAvA+ZdelveMsryqbDZlMGcdIPt7ePdmjJrz1/8J01M 0nzJandpAccJY0LrlQJ4NON2AO+RaRogm6HvvyYru2RCL7iPpGcP X-Google-Smtp-Source: AGHT+IHBGuFlOJNKUphRiwWZLAHQ44eqm2RGewrf0BArtpJG/mvRI96r0swiM6Y0LOO1qFFVwaNpcw== X-Received: by 2002:a50:d55b:0:b0:57d:669:caf2 with SMTP id 4fb4d7f45d1cf-57d4bd9705amr4128259a12.25.1719265603653; Mon, 24 Jun 2024 14:46: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 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:43 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 7/9] mtd: implement support for LED activity Date: Mon, 24 Jun 2024 23:46:17 +0200 Message-ID: <20240624214626.24336-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-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 Jun 24 21:46:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951822 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=h9rBp0hj; 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 4W7M5s5l3Sz20Z9 for ; Tue, 25 Jun 2024 07:48:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A29718854E; Mon, 24 Jun 2024 23:46:49 +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="h9rBp0hj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 870AB883FA; Mon, 24 Jun 2024 23:46:47 +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-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 9C2F4883DE for ; Mon, 24 Jun 2024 23:46:45 +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-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-57d1679ee83so5041566a12.2 for ; Mon, 24 Jun 2024 14:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265605; x=1719870405; 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=AIU53hSikLVwOMMuoG7NRsRB4FSSbFj6q5GKvhgjA0s=; b=h9rBp0hjYCiMHvn7GoVcgGSy9ObPwYZWTVq2BVWU59bT0dg6r8pfF+g9T0IFJZta2A uqZg3hh5PAZ/z7f4gvvCkbJ1sXpGgMN0bwFYN3xtIUCuYVWFCI28u1MeEmqR4SIAZsq8 9VByINH7baXLI6GON0PcW3EPa+/YTIbquERPx8h7d3zxgN55+zSrITEY1t3bxUKJF65J TajDSUjkTv5WaPzy6wQKCVAWVGWVdHlMln30U+2J+1tvUjFpOoGS6HEyhXW8H8VgK/S9 S4q4sFIiwN7g9wFWo9XiuRWD8J2g0jQ2/J6SxuluJUUArMwp+0vV9aF7CqQ9C+msmyvm 0ACQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265605; x=1719870405; 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=AIU53hSikLVwOMMuoG7NRsRB4FSSbFj6q5GKvhgjA0s=; b=d8zRRv/VextMpq4JUsxFquvL4YPHLhJl5Ja84VZRolAOG9HbNwabdCO6/k9daqSM+W tRlRJ6cQfdSkSDgfK3d9YIF1AmDJ6kxm+y1fbN0ZCB9ZcYcU/AR926/Y4qK30aMzg9WA 9QUAUVwSWaOMUfGc/7b3cZYWpVIavZtwiozUa6AE9aR4mk0xe03bYZAV9kinvR5gCTHO adwYZCKxfISr6g6Zkawvf5Eg50kfFU2/lgY81OYF3q2S5bnAfgfcLUGWMmcTP63sUJ38 XGb/bUcMGJHUIZUuZVKW+0dAmad1uEOtUXRAwyAMRiXN+V0HnM79d0Dvjy52QvjCGZBH NP1w== X-Forwarded-Encrypted: i=1; AJvYcCWIJTZw+KPvQgsVoUh64ss5Wyb3NzLkjCKmfr/VsFDpOaB1n8cKljzpbQCmuKbLwMDTXE4r0A4TZtSK568Q1Q0a88QDTw== X-Gm-Message-State: AOJu0Yxekh8nI37jgNsjKJLkLvm+PPVf/quZqdF24RK5Z8/z727AvbiE r5zeKSEJFn/VIsC6c83WC8Si0oJSuNu70B+vjjkr7DFhYDjWWrQ+ X-Google-Smtp-Source: AGHT+IHqv9oH+a9vkvc+cDxlUsrY7ns3Qi/eaffm/B7Ey5+S3GMOg50Y9EslZswbeDeXmh53srOnxw== X-Received: by 2002:a50:d50c:0:b0:578:676e:324 with SMTP id 4fb4d7f45d1cf-57d45791fc4mr4007615a12.17.1719265604953; Mon, 24 Jun 2024 14:46:44 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:44 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 8/9] ubi: implement support for LED activity Date: Mon, 24 Jun 2024 23:46:18 +0200 Message-ID: <20240624214626.24336-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/ubi.c b/cmd/ubi.c index 8c1b5df0572..984be3da4af 100644 --- a/cmd/ubi.c +++ b/cmd/ubi.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -416,7 +417,19 @@ int ubi_volume_begin_write(char *volume, void *buf, size_t size, int ubi_volume_write(char *volume, void *buf, size_t size) { - return ubi_volume_begin_write(volume, buf, size, size); + int ret; + +#ifdef CONFIG_LED_ACTIVITY_ENABLE + led_activity_blink(); +#endif + + ret = ubi_volume_begin_write(volume, buf, size, size); + +#ifdef CONFIG_LED_ACTIVITY_ENABLE + led_activity_off(); +#endif + + return ret; } int ubi_volume_read(char *volume, char *buf, size_t size) From patchwork Mon Jun 24 21:46:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1951823 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=aiwHBggv; 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 4W7M642BRDz20Z9 for ; Tue, 25 Jun 2024 07:48:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0BEDA88576; Mon, 24 Jun 2024 23:46: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=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="aiwHBggv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E743D88119; Mon, 24 Jun 2024 23:46:48 +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-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (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 00F808856B for ; Mon, 24 Jun 2024 23:46:47 +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-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-57d07673185so4515053a12.1 for ; Mon, 24 Jun 2024 14:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719265606; x=1719870406; 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=dS4FLeyjqAXWjQ9DvKgAMPqYWa0no/rNxLNm3N6TAYY=; b=aiwHBggvhYORCXBaOYuElyUhU/AOaSHqxq8fnGiIjyC7l0HZSJtZG5IufBNLoL4Bvs oEbItox1LsGA75sur57IvKC+bpY46t9R1YWkK8JFsZauMztuNOF+9SEscPfSxhBC2c0J D4WMcNAgWKfhxa+VqwtgkIBlvN1uBk6MAtOOiFn/q9thlxRlrjEjwG5uP5KLYKaAlbd/ Tau6lUFbCpFliNGuMbAOUgUetkfta1tKeDXHFSX1MLDKAtHJuGt+eCYEwaMKyGIFY8lx ZgIAkvd48FvER4rfBpHK5YxjchKgjzZVb1LBNFMRjnonrsY1+amS+avF20FYWTanzLfw gr/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719265606; x=1719870406; 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=dS4FLeyjqAXWjQ9DvKgAMPqYWa0no/rNxLNm3N6TAYY=; b=VVh5k0pYrdfD8gEOs1QCoSNkxraicvcYVJhy2GvUn3g0B+97n60F6dDDTbN4HHpKYZ fv2aNLeSypQvCZ5pUzmGG80I5DCgiZ9aRfW57j5HOzg4QTDl12s1R57jSNHSwHfpcOYH gJaRZLbC7I3/psz2HMm1fP86cLRECRjY6nFhfCOwlIAxQ23KNz6Gll9NsCYwZagfkCkJ lHuuNsgWhFsQ/cZMRJZGHwd+7TMCM2iCc5ZCIvRuLcLpJRPP43sSohUF8dhkdpY/np4U TfL7Als2HdUSyK9koZzTcwWjZmZ9M305CcFAa5f0AwydRwZPvAsLLmjeX0eXsmURZk5R vSGg== X-Forwarded-Encrypted: i=1; AJvYcCVLeXrbBrR/tt7weJGq3YoQ1Xz8gzJXmvjx9PTPZTvxSvPvTqp629ODxry8Y3BnN+QXrpvCdvtGhr0KFGNfTrxe6z/iBQ== X-Gm-Message-State: AOJu0YyWhCVcYAT59iY+hZOcQCyEkKjxgv4iKuUFQQAqO61BD6PwTA4y 2fvMJqacEZ/US3a2vUwpV4CZhbBLpH5GE7g856MvtDSnaZmft81M X-Google-Smtp-Source: AGHT+IG0dpKD6R99TqAIUIWQJKUx1EhDaaTpWkG8faImZqNsgz2LRPx9Pg19qTRRY5i4GU67yxPaXg== X-Received: by 2002:a50:cd93:0:b0:57a:2fe7:6699 with SMTP id 4fb4d7f45d1cf-57d4a281750mr4432462a12.14.1719265606327; Mon, 24 Jun 2024 14:46: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 4fb4d7f45d1cf-57d303d7b1bsm5100588a12.11.2024.06.24.14.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 14:46:46 -0700 (PDT) From: Christian Marangi To: Tom Rini , Joe Hershberger , Ramon Fried , Dario Binacchi , Miquel Raynal , Christian Marangi , Simon Glass , Heinrich Schuchardt , Arseniy Krasnov , Dmitry Dunaev , Marek Vasut , Sean Anderson , Bin Meng , Nikhil M Jain , Shiji Yang , Leo Yu-Chi Liang , Rasmus Villemoes , Doug Zobel , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH 9/9] doc: introduce led.rst documentation Date: Mon, 24 Jun 2024 23:46:19 +0200 Message-ID: <20240624214626.24336-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240624214626.24336-1-ansuelsmth@gmail.com> References: <20240624214626.24336-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 | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 doc/api/led.rst diff --git a/doc/api/index.rst b/doc/api/index.rst index 51b2013af36..6f11b94eac3 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -13,6 +13,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 409397e1df9..4dac54338e4 100644 --- a/include/led.h +++ b/include/led.h @@ -7,6 +7,44 @@ #ifndef __LED_H #define __LED_H +/** + * 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. + * + * GPIO-connected LEDs can simulate blinking via software using the Cyclic API. To utilize this, + * enable `CONFIG_LED_GPIO_SW_BLINK`. This will also select `CONFIG_LED_BLINK` and `CONFIG_CYCLIC`. + * + * 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 `CONFIG_LED_BOOT_LABEL`. 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 + * `CONFIG_LED_ACTIVITY_LABEL`. + * 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 `_PERIOD` option if `CONFIG_LED_BLINK` is enabled + * for LED blink operations, which is usually used by the Activity LED. + * + * When `CONFIG_LED_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 {