mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-07-10 13:16:16 +09:00
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>
This commit is contained in:
parent
6ecaee8201
commit
79cb14ab39
|
@ -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,
|
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
|
||||||
unsigned int max_hz, unsigned int mode)
|
unsigned int max_hz, unsigned int mode)
|
||||||
{
|
{
|
||||||
struct mxs_spi_slave *mxs_slave;
|
struct mxs_spi_slave *mxs_slave;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
|
|
||||||
if (bus > 3) {
|
if (!spi_cs_is_valid(bus, cs)) {
|
||||||
printf("MXS SPI: Max bus number is 3\n");
|
printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user