summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2012-02-13 23:15:25 +0100
committerWolfgang Denk <wd@denx.de>2012-02-13 23:15:25 +0100
commite9d44b35beb45869863f3ca6929089d9df4df3e5 (patch)
tree4382c3c41c944e23dc846393e52275b63d302ba3 /common
parent06576b2efcf3d67797437488e90e989b8b48c9f2 (diff)
parentf61ec45eb5ad819520396f91385ef3855059c1dd (diff)
downloadu-boot-imx-e9d44b35beb45869863f3ca6929089d9df4df3e5.zip
u-boot-imx-e9d44b35beb45869863f3ca6929089d9df4df3e5.tar.gz
u-boot-imx-e9d44b35beb45869863f3ca6929089d9df4df3e5.tar.bz2
Merge branch 'sf' of git://git.denx.de/u-boot-blackfin
* 'sf' of git://git.denx.de/u-boot-blackfin: README: Add description of SPI Flash (SF) command configuration sf command: allow default bus and chip selects sf: eeprom_m95xxx: set a sane default timeout sf: eeprom_m95xxx: fix up style
Diffstat (limited to 'common')
-rw-r--r--common/cmd_sf.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 612fd18..98e4162 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -17,6 +17,12 @@
#ifndef CONFIG_SF_DEFAULT_MODE
# define CONFIG_SF_DEFAULT_MODE SPI_MODE_3
#endif
+#ifndef CONFIG_SF_DEFAULT_CS
+# define CONFIG_SF_DEFAULT_CS 0
+#endif
+#ifndef CONFIG_SF_DEFAULT_BUS
+# define CONFIG_SF_DEFAULT_BUS 0
+#endif
static struct spi_flash *flash;
@@ -63,27 +69,26 @@ static int sf_parse_len_arg(char *arg, ulong *len)
static int do_spi_flash_probe(int argc, char * const argv[])
{
- unsigned int bus = 0;
- unsigned int cs;
+ unsigned int bus = CONFIG_SF_DEFAULT_BUS;
+ unsigned int cs = CONFIG_SF_DEFAULT_CS;
unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
unsigned int mode = CONFIG_SF_DEFAULT_MODE;
char *endp;
struct spi_flash *new;
- if (argc < 2)
- return -1;
-
- cs = simple_strtoul(argv[1], &endp, 0);
- if (*argv[1] == 0 || (*endp != 0 && *endp != ':'))
- return -1;
- if (*endp == ':') {
- if (endp[1] == 0)
- return -1;
-
- bus = cs;
- cs = simple_strtoul(endp + 1, &endp, 0);
- if (*endp != 0)
+ if (argc >= 2) {
+ cs = simple_strtoul(argv[1], &endp, 0);
+ if (*argv[1] == 0 || (*endp != 0 && *endp != ':'))
return -1;
+ if (*endp == ':') {
+ if (endp[1] == 0)
+ return -1;
+
+ bus = cs;
+ cs = simple_strtoul(endp + 1, &endp, 0);
+ if (*endp != 0)
+ return -1;
+ }
}
if (argc >= 3) {
@@ -299,7 +304,7 @@ usage:
U_BOOT_CMD(
sf, 5, 1, do_spi_flash,
"SPI flash sub-system",
- "probe [bus:]cs [hz] [mode] - init flash device on given SPI bus\n"
+ "probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus\n"
" and chip select\n"
"sf read addr offset len - read `len' bytes starting at\n"
" `offset' to memory at `addr'\n"