Skip to content

Commit

Permalink
spi: spi-axi-engine: fix write buffer value to register
Browse files Browse the repository at this point in the history
This patch fixes buffer value writes in register. The register width is
equal with the word length. The value written must be the same size so we
must shift 8 bit values and create a value equal to the word length.

Signed-off-by: Mircea Caprioru <[email protected]>
  • Loading branch information
Mircea Caprioru authored and commodo committed Jan 23, 2019
1 parent 8905c17 commit 42d22f4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/spi/spi-axi-spi-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,16 @@ static void spi_engine_write_buff(struct spi_engine *spi_engine,
const uint8_t *buf)
{
void __iomem *addr = spi_engine->base + SPI_ENGINE_REG_SDO_DATA_FIFO;
uint8_t len, i;
uint8_t len, i, word_len;
uint32_t val = 0;

word_len = spi_engine->word_length;
len = DIV_ROUND_DOWN_ULL(word_len, 8);

len = DIV_ROUND_UP(spi_engine->word_length, 8);
for (i = 0; i < len; i++)
writel_relaxed(buf[i], addr);
val |= buf[i] << (word_len - 8 * (i + 1));

writel_relaxed(val, addr);
}

static bool spi_engine_write_tx_fifo(struct spi_engine *spi_engine)
Expand Down

0 comments on commit 42d22f4

Please sign in to comment.