[U-Boot] SPI - cs validity

Hello,
I am trying to understand the logic behind the implementation of SPI interface, and came across a validity routine (for different baords it is about the same):
for Atmel and Davinci for example:
int spi_cs_is_valid(unsigned int bus, unsigned int cs) { return bus == 0 && cs == 0; }
Althout atmel and davinci can have more then one spi port, it seems that they will fail in configuration if bus is different then 0. I wander if any one can solve this issue for me.
Many Thanks,
Ran

Hi,
On Wed, Apr 06, 2011 at 11:22:13, Ran Shalit wrote:
Hello,
I am trying to understand the logic behind the implementation of SPI interface, and came across a validity routine (for different baords it is about the same):
for Atmel and Davinci for example:
int spi_cs_is_valid(unsigned int bus, unsigned int cs) { return bus == 0 && cs == 0; }
Althout atmel and davinci can have more then one spi port, it seems that they will fail in configuration if bus is different then 0. I wander if any one can solve this issue for me.
It seems that currently both atmel & davinci boards supports only 1 spi instance at a time.
In order to support different spi instances, In case of atmel declare SPIx_BASE as required & set CONFIG_DEFAULT_SPI_BUS to required bus In case of davinci set CONFIG_SYS_SPI_BASE to base address of required spi instance
Also, spi_cs_is_valid() function needs to be updated to support different spi instances. spi_cs_is_valid() function is board dependednt.
Hope this helps.
Regards, Gururaja

It seems that currently both atmel & davinci boards supports only 1 spi instance at a time.
In order to support different spi instances, In case of atmel declare SPIx_BASE as required & set CONFIG_DEFAULT_SPI_BUS to required bus In case of davinci set CONFIG_SYS_SPI_BASE to base address of required spi instance
Also, spi_cs_is_valid() function needs to be updated to support different spi instances. spi_cs_is_valid() function is board dependednt.
Hope this helps.
Regards, Gururaja
Hi Gururaja,
It seems that the implementation limit the validity only for bus==0. This means that trying other bus(=spi port ?) will fail even if its not at the same time. In addition to that the CPU's data sheet make no limit.
Best Regards, Ran

Hi,
On Wed, Apr 06, 2011 at 15:02:22, Ran Shalit wrote:
It seems that currently both atmel & davinci boards supports only 1 spi instance at a time.
In order to support different spi instances, In case of atmel declare SPIx_BASE as required & set CONFIG_DEFAULT_SPI_BUS to required bus In case of davinci set CONFIG_SYS_SPI_BASE to base address of required spi instance
Also, spi_cs_is_valid() function needs to be updated to support different spi instances. spi_cs_is_valid() function is board dependednt.
Hope this helps.
Regards, Gururaja
Hi Gururaja,
It seems that the implementation limit the validity only for bus==0. This means that trying other bus(=spi port ?) will fail even if its not at the same time. In addition to that the CPU's data sheet make no limit.
Best Regards, Ran
Don't top post.
Currenly davinci spi driver only allows (bus == 0) to pass which means spi0. So if you want to support other or many spi port at once, then
1. you need to change spi_cs_is_valid() to check for various bus values & 2. validate the bus argument to spi_setup_slave(). may be using a switch as in case of atmel.
from
ds->regs = (struct davinci_spi_regs *)CONFIG_SYS_SPI_BASE;
to
struct davinci_spi_regs *regs;
switch (bus) { case 0: regs = (struct davinci_spi_regs *)CONFIG_SYS_SPI0_BASE; break; case 1: regs = (struct davinci_spi_regs *)CONFIG_SYS_SPI1_BASE; break; ... ... default: return NULL; }
ds->regs = regs;
Regards Gururaja
participants (2)
-
Hebbar, Gururaja
-
Ran Shalit