Skip to content

Commit

Permalink
spi: cadence-quadspi: Fix dummy cycle calculation when buswidth > 1
Browse files Browse the repository at this point in the history
SPI MEM deals with dummy bytes but the controller deals with dummy
cycles. Multiplying bytes by 8 is correct if the dummy phase uses 1S
mode since 1 byte will be sent in 8 cycles. But if the dummy phase uses
4S mode then 1 byte will be sent in 2 cycles.

To correctly translate dummy bytes to dummy cycles, the dummy buswidth
also needs to be taken into account. Divide 8 by the buswidth to get the
correct multiplier for getting the number of cycles.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20201222184425.7028-5-p.yadav@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Pratyush Yadav authored and Mark Brown committed Jan 6, 2021
1 parent 888d517 commit 7512eaf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/spi/spi-cadence-quadspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static unsigned int cqspi_calc_dummy(const struct spi_mem_op *op)
{
unsigned int dummy_clk;

dummy_clk = op->dummy.nbytes * 8;
dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth);

return dummy_clk;
}
Expand Down

0 comments on commit 7512eaf

Please sign in to comment.