diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2012-04-23 08:30:49 +0000 |
---|---|---|
committer | Albert ARIBAUD <albert.u.boot@aribaud.net> | 2012-05-15 08:31:35 +0200 |
commit | 79cb14ab39f970b85204ab1b2f796b02bb65335d (patch) | |
tree | 2ebead4ef380ede72e6f8dedff5ddefdee3acd40 /drivers/spi | |
parent | 6ecaee8201ddf7dd574e9331ad4249ec867253b5 (diff) | |
download | u-boot-imx-79cb14ab39f970b85204ab1b2f796b02bb65335d.zip u-boot-imx-79cb14ab39f970b85204ab1b2f796b02bb65335d.tar.gz u-boot-imx-79cb14ab39f970b85204ab1b2f796b02bb65335d.tar.bz2 |
spi: mxs: Introduce spi_cs_is_valid()
Introduce spi_cs_is_valid() for validating spi bus and chip select numbers.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/mxs_spi.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c index 4e6f14e..e7237e7 100644 --- a/drivers/spi/mxs_spi.c +++ b/drivers/spi/mxs_spi.c @@ -51,14 +51,23 @@ void spi_init(void) { } +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + /* MXS SPI: 4 ports and 3 chip selects maximum */ + if (bus > 3 || cs > 2) + return 0; + else + return 1; +} + struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, unsigned int max_hz, unsigned int mode) { struct mxs_spi_slave *mxs_slave; uint32_t addr; - if (bus > 3) { - printf("MXS SPI: Max bus number is 3\n"); + if (!spi_cs_is_valid(bus, cs)) { + printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs); return NULL; } |