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 6/7] mtd: implement support for LED status activity
Date: Wed,  5 Jun 2024 21:21:38 +0200	[thread overview]
Message-ID: <20240605192146.19052-7-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20240605192146.19052-1-ansuelsmth@gmail.com>

Implement support for LED status activity. If the feature is enabled,
make the defined ACTIVITY LED to signal mtd write or erase operations.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 cmd/mtd.c                      | 23 +++++++++++++++++++++++
 drivers/mtd/nand/core.c        |  4 ++++
 drivers/mtd/nand/spi/core.c    |  5 +++++
 drivers/mtd/spi/spi-nor-core.c |  9 +++++++++
 4 files changed, 41 insertions(+)

diff --git a/cmd/mtd.c b/cmd/mtd.c
index 9189f45cabd..aa0a41ac3bb 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -11,6 +11,7 @@
 #include <command.h>
 #include <common.h>
 #include <console.h>
+#include <status_led.h>
 #if CONFIG_IS_ENABLED(CMD_MTD_OTP)
 #include <hexdump.h>
 #endif
@@ -559,6 +560,12 @@ 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_STATUS_ACTIVITY_ENABLE
+	if (!read)
+		status_led_set(CONFIG_LED_STATUS_ACTIVITY,
+			       CONFIG_LED_STATUS_BLINKING);
+#endif
+
 	/* Loop over the pages to do the actual read/write */
 	while (remaining) {
 		/* Skip the block if it is bad */
@@ -586,6 +593,12 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
 		io_op.oobbuf += io_op.oobretlen;
 	}
 
+#ifdef CONFIG_LED_STATUS_ACTIVITY_ENABLE
+	if (!read)
+		status_led_set(CONFIG_LED_STATUS_ACTIVITY,
+			       CONFIG_LED_STATUS_OFF);
+#endif
+
 	if (!ret && dump)
 		mtd_dump_device_buf(mtd, start_off, buf, len, woob);
 
@@ -653,6 +666,11 @@ 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_STATUS_ACTIVITY_ENABLE
+	status_led_set(CONFIG_LED_STATUS_ACTIVITY,
+		       CONFIG_LED_STATUS_ON);
+#endif
+
 	while (len) {
 		if (!scrub) {
 			ret = mtd_block_isbad(mtd, erase_op.addr);
@@ -681,6 +699,11 @@ static int do_mtd_erase(struct cmd_tbl *cmdtp, int flag, int argc,
 		erase_op.addr += mtd->erasesize;
 	}
 
+#ifdef CONFIG_LED_STATUS_ACTIVITY_ENABLE
+	status_led_set(CONFIG_LED_STATUS_ACTIVITY,
+		       CONFIG_LED_STATUS_OFF);
+#endif
+
 	if (ret && ret != -EIO)
 		ret = CMD_RET_FAILURE;
 	else
diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
index f6d9c584f78..631a4c83e04 100644
--- a/drivers/mtd/nand/core.c
+++ b/drivers/mtd/nand/core.c
@@ -18,6 +18,7 @@
 #include <linux/bitops.h>
 #include <linux/mtd/nand.h>
 #include <linux/printk.h>
+#include <status_led.h>
 
 /**
  * nanddev_isbad() - Check if a block is bad
@@ -182,6 +183,9 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo)
 		}
 
 		nanddev_pos_next_eraseblock(nand, &pos);
+#ifdef CONFIG_LED_STATUS_ACTIVITY_ENABLE
+		status_led_activity(CONFIG_LED_STATUS_ACTIVITY);
+#endif
 	}
 
 	return 0;
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 62c28aa422d..86d7ed9e9d0 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -32,6 +32,7 @@
 #include <linux/bug.h>
 #include <linux/mtd/spinand.h>
 #include <linux/printk.h>
+#include <status_led.h>
 #endif
 
 /* SPI NAND index visible in MTD names */
@@ -657,6 +658,10 @@ static int spinand_mtd_write(struct mtd_info *mtd, loff_t to,
 
 		ops->retlen += iter.req.datalen;
 		ops->oobretlen += iter.req.ooblen;
+
+#ifdef CONFIG_LED_STATUS_ACTIVITY_ENABLE
+		status_led_activity(CONFIG_LED_STATUS_ACTIVITY);
+#endif
 	}
 
 #ifndef __UBOOT__
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index f86003ca8c0..1e7436079e9 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -32,6 +32,8 @@
 #include <spi-mem.h>
 #include <spi.h>
 
+#include <status_led.h>
+
 #include "sf_internal.h"
 
 /* Define max times to check status register before we give up. */
@@ -1039,6 +1041,10 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
 		ret = spi_nor_wait_till_ready(nor);
 		if (ret)
 			goto erase_err;
+
+#ifdef CONFIG_LED_STATUS_ACTIVITY_ENABLE
+		status_led_activity(CONFIG_LED_STATUS_ACTIVITY);
+#endif
 	}
 
 	addr_known = false;
@@ -1816,6 +1822,9 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 			goto write_err;
 		*retlen += written;
 		i += written;
+#ifdef CONFIG_LED_STATUS_ACTIVITY_ENABLE
+		status_led_activity(CONFIG_LED_STATUS_ACTIVITY);
+#endif
 	}
 
 write_err:
-- 
2.43.0


  parent reply	other threads:[~2024-06-05 19:41 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 ` [PATCH 4/7] led: status_led: add new activity LED config and functions Christian Marangi
2024-06-06  8:56   ` 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 ` Christian Marangi [this message]
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-7-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