colibri_imx7: add addresses required for distro boot
[oweals/u-boot.git] / cmd / sf.c
index 738ef0e46dc14fde1ae1550b0873a2a818b7abb6..d18f6a888ce48c6ec142e7c658a828668d3c079e 100644 (file)
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -6,18 +6,24 @@
  */
 
 #include <common.h>
+#include <command.h>
 #include <div64.h>
 #include <dm.h>
+#include <flash.h>
+#include <log.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <spi.h>
 #include <spi_flash.h>
+#include <asm/cache.h>
 #include <jffs2/jffs2.h>
 #include <linux/mtd/mtd.h>
 
 #include <asm/io.h>
 #include <dm/device-internal.h>
 
+#include "legacy-mtd-utils.h"
+
 static struct spi_flash *flash;
 
 /*
@@ -77,18 +83,17 @@ static ulong bytes_per_second(unsigned int len, ulong start_ms)
                return 1024 * len / max(get_timer(start_ms), 1UL);
 }
 
-static int do_spi_flash_probe(int argc, char * const argv[])
+static int do_spi_flash_probe(int argc, char *const argv[])
 {
        unsigned int bus = CONFIG_SF_DEFAULT_BUS;
        unsigned int cs = CONFIG_SF_DEFAULT_CS;
+       /* In DM mode, defaults speed and mode will be taken from DT */
        unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
        unsigned int mode = CONFIG_SF_DEFAULT_MODE;
        char *endp;
 #ifdef CONFIG_DM_SPI_FLASH
        struct udevice *new, *bus_dev;
        int ret;
-       /* In DM mode defaults will be taken from DT */
-       speed = 0, mode = 0;
 #else
        struct spi_flash *new;
 #endif
@@ -140,13 +145,10 @@ static int do_spi_flash_probe(int argc, char * const argv[])
 
        new = spi_flash_probe(bus, cs, speed, mode);
        flash = new;
-
        if (!new) {
                printf("Failed to initialize SPI flash at %u:%u\n", bus, cs);
                return 1;
        }
-
-       flash = new;
 #endif
 
        return 0;
@@ -258,7 +260,7 @@ static int spi_flash_update(struct spi_flash *flash, u32 offset,
        return 0;
 }
 
-static int do_spi_flash_read_write(int argc, char * const argv[])
+static int do_spi_flash_read_write(int argc, char *const argv[])
 {
        unsigned long addr;
        void *buf;
@@ -316,7 +318,7 @@ static int do_spi_flash_read_write(int argc, char * const argv[])
        return ret == 0 ? 0 : 1;
 }
 
-static int do_spi_flash_erase(int argc, char * const argv[])
+static int do_spi_flash_erase(int argc, char *const argv[])
 {
        int ret;
        int dev = 0;
@@ -348,7 +350,7 @@ static int do_spi_flash_erase(int argc, char * const argv[])
        return ret == 0 ? 0 : 1;
 }
 
-static int do_spi_protect(int argc, char * const argv[])
+static int do_spi_protect(int argc, char *const argv[])
 {
        int ret = 0;
        loff_t start, len;
@@ -497,7 +499,7 @@ static int spi_flash_test(struct spi_flash *flash, uint8_t *buf, ulong len,
        return 0;
 }
 
-static int do_spi_flash_test(int argc, char * const argv[])
+static int do_spi_flash_test(int argc, char *const argv[])
 {
        unsigned long offset;
        unsigned long len;
@@ -541,8 +543,8 @@ static int do_spi_flash_test(int argc, char * const argv[])
 }
 #endif /* CONFIG_CMD_SF_TEST */
 
-static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int argc,
-                       char * const argv[])
+static int do_spi_flash(struct cmd_tbl *cmdtp, int flag, int argc,
+                       char *const argv[])
 {
        const char *cmd;
        int ret;