U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Tom Rini <trini@konsulko.com>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Vignesh R <vigneshr@ti.com>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Arseniy Krasnov <avkrasnov@salutedevices.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Simon Glass <sjg@chromium.org>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Dmitry Dunaev <dunaev@tecon.ru>,
	Devarsh Thakkar <devarsht@ti.com>, Bin Meng <bmeng.cn@gmail.com>,
	Eugene Uriev <eugeneuriev@gmail.com>,
	Nikhil M Jain <n-jain1@ti.com>,
	Shiji Yang <yangshiji66@outlook.com>,
	Raymond Mao <raymond.mao@linaro.org>,
	Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
	Doug Zobel <douglas.zobel@climate.com>,
	William Zhang <william.zhang@broadcom.com>,
	Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
	Igor Prusov <ivprusov@salutedevices.com>,
	Bruce Suen <bruce_suen@163.com>,
	Takahiro Kuwano <Takahiro.Kuwano@infineon.com>,
	Pratyush Yadav <p.yadav@ti.com>,
	Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>,
	Vaishnav Achath <vaishnav.a@ti.com>,
	AKASHI Takahiro <akashi.tkhro@gmail.com>,
	u-boot@lists.denx.de
Subject: [PATCH 4/7] led: status_led: add new activity LED config and functions
Date: Wed,  5 Jun 2024 21:21:36 +0200	[thread overview]
Message-ID: <20240605192146.19052-5-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20240605192146.19052-1-ansuelsmth@gmail.com>

Add a new activity LED config and additional functions to implement a
simple software blink feature to signal activity of any kind.

Usual activity might be a file transfer with TFTP, a flash write...

Driver will call status_led_activity on each activity and LED will be
toggled based on the defined FREQ config value.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/led/Kconfig       | 15 +++++++++++++++
 drivers/misc/status_led.c | 25 ++++++++++++++++++++-----
 include/status_led.h      |  1 +
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index 6c4f02d71f2..8eaa74bdd27 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -359,6 +359,21 @@ config LED_STATUS_BOOT
 
 endif # LED_STATUS_BOOT_ENABLE
 
+config LED_STATUS_ACTIVITY_ENABLE
+	bool "Enable BOOT LED"
+	help
+	  Enable to turn an LED on when the board is doing some
+	  activity (flash write, file download).
+
+if LED_STATUS_ACTIVITY_ENABLE
+
+config LED_STATUS_ACTIVITY
+	int "LED to light when the board is doing some activity"
+	help
+	  Valid enabled LED device number.
+
+endif # LED_STATUS_ACTIVITY_ENABLE
+
 config LED_STATUS_RED_ENABLE
 	bool "Enable red LED"
 	help
diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c
index 93bfb410662..9490e1d7341 100644
--- a/drivers/misc/status_led.c
+++ b/drivers/misc/status_led.c
@@ -82,6 +82,14 @@ void status_led_init(void)
 	status_led_init_done = 1;
 }
 
+static void status_led_sw_blink(led_dev_t *ld)
+{
+	if (++ld->cnt >= ld->period) {
+		__led_toggle(ld->mask);
+		ld->cnt -= ld->period;
+	}
+}
+
 void status_led_tick(ulong timestamp)
 {
 	led_dev_t *ld;
@@ -95,11 +103,7 @@ void status_led_tick(ulong timestamp)
 		if (ld->state != CONFIG_LED_STATUS_BLINKING)
 			continue;
 
-		if (++ld->cnt >= ld->period) {
-			__led_toggle (ld->mask);
-			ld->cnt -= ld->period;
-		}
-
+		status_led_sw_blink(ld);
 	}
 }
 
@@ -140,3 +144,14 @@ void status_led_toggle(int led)
 
 	__led_toggle(ld->mask);
 }
+
+void status_led_activity(int led)
+{
+	led_dev_t *ld;
+
+	ld = status_get_led_dev(led);
+	if (!ld)
+		return;
+
+	status_led_sw_blink(ld);
+}
diff --git a/include/status_led.h b/include/status_led.h
index fe0c84fb4b4..037bad159c2 100644
--- a/include/status_led.h
+++ b/include/status_led.h
@@ -39,6 +39,7 @@ void status_led_init(void);
 void status_led_tick(unsigned long timestamp);
 void status_led_set(int led, int state);
 void status_led_toggle(int led);
+void status_led_activity(int led);
 
 /*****  MVS v1  **********************************************************/
 #if (defined(CONFIG_MVS) && CONFIG_MVS < 2)
-- 
2.43.0


  parent reply	other threads:[~2024-06-05 19:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05 19:21 [PATCH 0/7] misc: introduce STATUS LED activity function Christian Marangi
2024-06-05 19:21 ` [PATCH 1/7] misc: gpio_led: fix broken coloured LED status functions Christian Marangi
2024-06-05 19:21 ` [PATCH 2/7] led: status_led: add support for white LED colour Christian Marangi
2024-06-05 19:21 ` [PATCH 3/7] led: status_led: add function to toggle a status LED Christian Marangi
2024-06-05 19:21 ` Christian Marangi [this message]
2024-06-06  8:56   ` [PATCH 4/7] led: status_led: add new activity LED config and functions neil.armstrong
2024-06-05 19:21 ` [PATCH 5/7] tftp: implement support for LED status activity Christian Marangi
2024-06-06  8:22   ` Peter Robinson
2024-06-06  8:44     ` Christian Marangi
2024-06-05 19:21 ` [PATCH 6/7] mtd: " Christian Marangi
2024-06-05 19:21 ` [PATCH 7/7] ubi: " Christian Marangi
2024-06-05 20:23 ` [PATCH 0/7] misc: introduce STATUS LED activity function Tom Rini
2024-06-05 20:33   ` Christian Marangi
2024-06-06  9:12 ` Quentin Schulz
2024-06-06  9:52   ` Christian Marangi
2024-06-06 10:55     ` Quentin Schulz
2024-06-06 11:52       ` Christian Marangi
2024-06-06 13:32         ` Quentin Schulz
2024-06-06 14:48           ` Christian Marangi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240605192146.19052-5-ansuelsmth@gmail.com \
    --to=ansuelsmth@gmail.com \
    --cc=Takahiro.Kuwano@infineon.com \
    --cc=akashi.tkhro@gmail.com \
    --cc=avkrasnov@salutedevices.com \
    --cc=bmeng.cn@gmail.com \
    --cc=bruce_suen@163.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=devarsht@ti.com \
    --cc=douglas.zobel@climate.com \
    --cc=dunaev@tecon.ru \
    --cc=eugeneuriev@gmail.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=ivprusov@salutedevices.com \
    --cc=jagan@amarulasolutions.com \
    --cc=joe.hershberger@ni.com \
    --cc=michael@amarulasolutions.com \
    --cc=mikhail.kshevetskiy@iopsys.eu \
    --cc=miquel.raynal@bootlin.com \
    --cc=n-jain1@ti.com \
    --cc=p.yadav@ti.com \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=raymond.mao@linaro.org \
    --cc=rfried.dev@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=vaishnav.a@ti.com \
    --cc=venkatesh.abbarapu@amd.com \
    --cc=vigneshr@ti.com \
    --cc=william.zhang@broadcom.com \
    --cc=xypron.glpk@gmx.de \
    --cc=yangshiji66@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox