+// SPDX-License-Identifier: GPL-2.0+
/*
* Command for accessing SPI flash.
*
* Copyright (C) 2008 Atmel Corporation
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
+#include <command.h>
#include <div64.h>
#include <dm.h>
+#include <flash.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;
/*
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
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;
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;
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;
do_div(speed, test->time_ms[stage] * 1024);
bps = speed * 8;
- printf("%d %s: %d ticks, %d KiB/s %d.%03d Mbps\n", stage,
+ printf("%d %s: %u ticks, %d KiB/s %d.%03d Mbps\n", stage,
stage_name[stage], test->time_ms[stage],
(int)speed, bps / 1000, bps % 1000);
}
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;
}
#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;