[U-Boot] [PATCH] SPI: cmd_spi.c: add option to specify bus and mode

Mike Frysinger vapier at gentoo.org
Mon Aug 9 19:05:33 CEST 2010


On Mon, Aug 9, 2010 at 12:21 PM, Reinhard Meyer wrote:
> @@ -107,15 +119,13 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>                return 1;
>        }
>
> -       /* FIXME: Make these parameters run-time configurable */
> -       slave = spi_setup_slave(CONFIG_DEFAULT_SPI_BUS, device, 1000000,
> -                       CONFIG_DEFAULT_SPI_MODE);
> +       slave = spi_setup_slave(bus, cs, 1000000, mode);
>        if (!slave) {
> -               printf("Invalid device %d, giving up.\n", device);
> +               printf("Invalid bus %d cs %d, giving up.\n", bus, cs);

i would use the simple naming convention like so:
    printf("Invalid device %d:%d\n", bus, cs);

>  U_BOOT_CMD(
>        sspi,   5,      1,      do_spi,
>        "SPI utility commands",
> -       "<device> <bit_len> <dout> - Send <bit_len> bits from <dout> out the SPI\n"
> -       "<device>  - Identifies the chip select of the device\n"
> +       "<cs> <bit_len> <dout> - Send <bit_len> bits from <dout> out the SPI\n"
> +       "<bus>:<cs>[.<mode>] - extended form\n"
> +       "<bus>     - Identifies the SPI bus of the device\n"
> +       "<cs>      - Identifies the chip select of the device\n"
> +       "<mode>    - Identifies the SPI mode to use for the transfer\n"
>        "<bit_len> - Number of bits to send (base 10)\n"
>        "<dout>    - Hexadecimal string that gets sent"

this usage string no longer makes sense.  how about:
"[<bus>:]<cs>[.<mode>] <bit_len> <dout> - Send <bit_len> bits from
<dout> out the SPI\n"
-mike


More information about the U-Boot mailing list