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 <ma...@denx.de>
Cc: Lukasz Majewski <lu...@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

Reply via email to