public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] dfu: dfu_sf: Add support for multiple flashes
@ 2021-09-14  3:27 Marek Vasut
  2021-09-14  9:31 ` Lukasz Majewski
  2021-10-25 22:12 ` Tom Rini
  0 siblings, 2 replies; 7+ messages in thread
From: Marek Vasut @ 2021-09-14  3:27 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Lukasz Majewski

Add dfu_alt_info option which allows specifying multiple SPI flashes
as an alt info. The syntax is as follows:

altname sf bus:cs[:speed[:mode]]

Example:
dfu_alt_info=qspi0 sf 0:0;qspi1 sf 0:1

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Lukasz Majewski <lukma@denx.de>
---
 drivers/dfu/dfu_sf.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index b72493ced86..d246e1b21ff 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -168,22 +168,31 @@ static struct spi_flash *parse_dev(char *devstr)
 int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
 {
 	char *st;
-	char *devstr_bkup = strdup(devstr);
-
-	dfu->data.sf.dev = parse_dev(devstr_bkup);
-	free(devstr_bkup);
-	if (!dfu->data.sf.dev)
-		return -ENODEV;
 
 	dfu->dev_type = DFU_DEV_SF;
 	dfu->max_buf_size = dfu->data.sf.dev->sector_size;
 
 	st = strsep(&s, " ");
 	if (!strcmp(st, "raw")) {
+		char *devstr_bkup = strdup(devstr);
+		dfu->data.sf.dev = parse_dev(devstr_bkup);
+		free(devstr_bkup);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
 		dfu->layout = DFU_RAW_ADDR;
 		dfu->data.sf.start = hextoul(s, &s);
 		s++;
 		dfu->data.sf.size = hextoul(s, &s);
+	} else if (!strcmp(st, "sf")) {
+		st = strsep(&s, " ");
+		dfu->data.sf.dev = parse_dev(st);
+		if (!dfu->data.sf.dev)
+			return -ENODEV;
+
+		dfu->layout = DFU_RAW_ADDR;
+		dfu->data.sf.start = 0;
+		dfu->data.sf.size = dfu->data.sf.dev->size;
 	} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
 		   (!strcmp(st, "part") || !strcmp(st, "partubi"))) {
 		char mtd_id[32];
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-25 22:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-14  3:27 [PATCH] dfu: dfu_sf: Add support for multiple flashes Marek Vasut
2021-09-14  9:31 ` Lukasz Majewski
2021-10-25 22:12 ` Tom Rini
2021-10-25 22:18   ` Marek Vasut
2021-10-25 22:19     ` Tom Rini
2021-10-25 22:21     ` Tom Rini
2021-10-25 22:34       ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox