[U-Boot] [PATCH 0/2] SPI flash enhancements: allow default bus and chip-selects

Patch 1 modifies the 'sf' command to allow a default bus and chip-select to be specified by board headers. This allows a bare 'sf' probe command: U-Boot> sf probe instead of the more cumbersome usage when a GPIO is tacked onto the chip-select. Otherwise, this command-line would be needed to specify GP3:19 on SabreLite: U-Boot> sf probe 0x5300
Patch 2 provides a description of usage and configuration of CONFIG_CMD_SF.
Signed-off-by: Eric Nelson eric.nelson@boundarydevices.com

This patch allows a board configuration file to provide default bus and chip-selects for SPI flash so that first argument to the 'sf' command is optional.
On boards that use the mxc_spi driver and a GPIO for chip select, this allows a much simpler command line: U-Boot> sf probe instead of U-Boot> sf probe 0x5300 Signed-off-by: Eric Nelson eric.nelson@boundarydevices.com --- common/cmd_sf.c | 37 +++++++++++++++++++++---------------- 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"

Works fine.
Matthias
Tested-by: Matthias Fuchs matthias.fuchs@esd.eu
On 30.01.2012 21:02, Eric Nelson wrote:
This patch allows a board configuration file to provide default bus and chip-selects for SPI flash so that first argument to the 'sf' command is optional.
On boards that use the mxc_spi driver and a GPIO for chip select, this allows a much simpler command line: U-Boot> sf probe instead of U-Boot> sf probe 0x5300 Signed-off-by: Eric Nelson eric.nelson@boundarydevices.com
common/cmd_sf.c | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-)

Signed-off-by: Eric Nelson eric.nelson@boundarydevices.com --- README | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/README b/README index 9d713e8..4dbebcb 100644 --- a/README +++ b/README @@ -809,6 +809,7 @@ The following options need to be configured: (requires CONFIG_CMD_I2C) CONFIG_CMD_SETGETDCR Support for DCR Register access (4xx only) + CONFIG_CMD_SF * Read/write/erase SPI NOR flash CONFIG_CMD_SHA1SUM print sha1 memory digest (requires CONFIG_CMD_MEMORY) CONFIG_CMD_SOURCE "source" command Support @@ -2191,6 +2192,25 @@ The following options need to be configured: allows to read/write in Dataflash via the standard commands cp, md...
+- Serial Flash support + CONFIG_CMD_SF + + Defining this option enables SPI flash commands + 'sf probe/read/write/erase/update'. + + Usage requires an initial 'probe' to define the serial + flash parameters, followed by read/write/erase/update + commands. + + The following defaults may be provided by the platform + to handle the common case when only a single serial + flash is present on the system. + + CONFIG_SF_DEFAULT_BUS Bus identifier + CONFIG_SF_DEFAULT_CS Chip-select + CONFIG_SF_DEFAULT_MODE (see include/spi.h) + CONFIG_SF_DEFAULT_SPEED in Hz + - SystemACE Support: CONFIG_SYSTEMACE

On Monday 30 January 2012 15:02:24 Eric Nelson wrote:
Patch 1 modifies the 'sf' command to allow a default bus and chip-select to be specified by board headers. This allows a bare 'sf' probe command: U-Boot> sf probe instead of the more cumbersome usage when a GPIO is tacked onto the chip-select. Otherwise, this command-line would be needed to specify GP3:19 on SabreLite: U-Boot> sf probe 0x5300
Patch 2 provides a description of usage and configuration of CONFIG_CMD_SF.
thanks, i'll merge both into my sf branch and then push to wolfgang for next merge window (if he doesn't pick things up directly himself) -mike

On 01/31/2012 08:16 AM, Mike Frysinger wrote:
On Monday 30 January 2012 15:02:24 Eric Nelson wrote:
Patch 1 modifies the 'sf' command to allow a default bus and chip-select to be specified by board headers. This allows a bare 'sf' probe command: U-Boot> sf probe instead of the more cumbersome usage when a GPIO is tacked onto the chip-select. Otherwise, this command-line would be needed to specify GP3:19 on SabreLite: U-Boot> sf probe 0x5300
Patch 2 provides a description of usage and configuration of CONFIG_CMD_SF.
thanks, i'll merge both into my sf branch and then push to wolfgang for next merge window (if he doesn't pick things up directly himself) -mike
Thanks Mike

On 31.01.2012 16:16, Mike Frysinger wrote:
On Monday 30 January 2012 15:02:24 Eric Nelson wrote:
Patch 1 modifies the 'sf' command to allow a default bus and chip-select to be specified by board headers. This allows a bare 'sf' probe command: U-Boot> sf probe instead of the more cumbersome usage when a GPIO is tacked onto the chip-select. Otherwise, this command-line would be needed to specify GP3:19 on SabreLite: U-Boot> sf probe 0x5300
Patch 2 provides a description of usage and configuration of CONFIG_CMD_SF.
thanks, i'll merge both into my sf branch and then push to wolfgang for next merge window (if he doesn't pick things up directly himself)
As we had the first version of the initial patch series already at the list while the last merge window was still open, I was hoping for a chance to get this into v2012.03 ;)
Anyway, many thanks and best regards
Dirk

On Tuesday 31 January 2012 11:21:29 Dirk Behme wrote:
On 31.01.2012 16:16, Mike Frysinger wrote:
On Monday 30 January 2012 15:02:24 Eric Nelson wrote:
Patch 1 modifies the 'sf' command to allow a default bus and chip-select
to be specified by board headers. This allows a bare 'sf' probe command: U-Boot> sf probe
instead of the more cumbersome usage when a GPIO is tacked onto the chip-select. Otherwise, this command-line would be needed
to specify GP3:19 on SabreLite: U-Boot> sf probe 0x5300
Patch 2 provides a description of usage and configuration of CONFIG_CMD_SF.
thanks, i'll merge both into my sf branch and then push to wolfgang for next merge window (if he doesn't pick things up directly himself)
As we had the first version of the initial patch series already at the list while the last merge window was still open, I was hoping for a chance to get this into v2012.03 ;)
i'm fine with pushing them through this merge window. i tend to just try and avoid any back&forths with Wolfgang in case it missed the merge window. less hassle that way. -mike
participants (4)
-
Dirk Behme
-
Eric Nelson
-
Matthias Fuchs
-
Mike Frysinger