mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 14:41:31 +00:00
spi: altera: Clean up the use of variable d
The variable d is used in rather questionable way. Rework the code a bit so it's clearer what it does. Also, rename the variable from d to data to make it's name less mysterious. Finally, change it's data type to uint32_t , since it's accessed as a 32bit number. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Chin Liang See <clsee@altera.com> Cc: Dinh Nguyen <dinguyen@altera.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net> Cc: Pavel Machek <pavel@denx.de> Cc: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com> Acked-by: Pavel Machek <pavel@denx.de> Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
This commit is contained in:
parent
80d7333808
commit
bc76b821f0
1 changed files with 13 additions and 10 deletions
|
@ -126,10 +126,10 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
|
||||||
{
|
{
|
||||||
struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
|
struct altera_spi_slave *altspi = to_altera_spi_slave(slave);
|
||||||
/* assume spi core configured to do 8 bit transfers */
|
/* assume spi core configured to do 8 bit transfers */
|
||||||
uint bytes = bitlen / 8;
|
unsigned int bytes = bitlen / 8;
|
||||||
const uchar *txp = dout;
|
const unsigned char *txp = dout;
|
||||||
uchar *rxp = din;
|
unsigned char *rxp = din;
|
||||||
uint32_t reg, start;
|
uint32_t reg, data, start;
|
||||||
|
|
||||||
debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
|
debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
|
||||||
slave->bus, slave->cs, bitlen, bytes, flags);
|
slave->bus, slave->cs, bitlen, bytes, flags);
|
||||||
|
@ -150,10 +150,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
|
||||||
spi_cs_activate(slave);
|
spi_cs_activate(slave);
|
||||||
|
|
||||||
while (bytes--) {
|
while (bytes--) {
|
||||||
uchar d = txp ? *txp++ : CONFIG_ALTERA_SPI_IDLE_VAL;
|
if (txp)
|
||||||
|
data = *txp++;
|
||||||
|
else
|
||||||
|
data = CONFIG_ALTERA_SPI_IDLE_VAL;
|
||||||
|
|
||||||
debug("%s: tx:%x ", __func__, d);
|
debug("%s: tx:%x ", __func__, data);
|
||||||
writel(d, &altspi->regs->txdata);
|
writel(data, &altspi->regs->txdata);
|
||||||
|
|
||||||
start = get_timer(0);
|
start = get_timer(0);
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -166,11 +169,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d = readl(&altspi->regs->rxdata);
|
data = readl(&altspi->regs->rxdata);
|
||||||
if (rxp)
|
if (rxp)
|
||||||
*rxp++ = d;
|
*rxp++ = data & 0xff;
|
||||||
|
|
||||||
debug("rx:%x\n", d);
|
debug("rx:%x\n", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
Loading…
Add table
Reference in a new issue