mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 15:01:13 +07:00
spi: imx: adjust watermark level according to transfer length
Previously DMA watermark level is configured to fifosize/2, DMA mode can be used only when transfer length can be divided by 'watermark level * bpw', which makes DMA mode not pratical. This patch adjusts watermark level to largest number (no bigger than fifosize/2) which can divide 'tranfer length / bpw' for each transfer. Signed-off-by: Jiada Wang <jiada_wang@mentor.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
fafd679407
commit
66459c5a50
@ -211,7 +211,7 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi,
|
|||||||
struct spi_transfer *transfer)
|
struct spi_transfer *transfer)
|
||||||
{
|
{
|
||||||
struct spi_imx_data *spi_imx = spi_master_get_devdata(master);
|
struct spi_imx_data *spi_imx = spi_master_get_devdata(master);
|
||||||
unsigned int bpw;
|
unsigned int bpw, i;
|
||||||
|
|
||||||
if (!master->dma_rx)
|
if (!master->dma_rx)
|
||||||
return false;
|
return false;
|
||||||
@ -228,11 +228,15 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi,
|
|||||||
if (bpw != 1 && bpw != 2 && bpw != 4)
|
if (bpw != 1 && bpw != 2 && bpw != 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (transfer->len < spi_imx->wml * bpw)
|
for (i = spi_imx_get_fifosize(spi_imx) / 2; i > 0; i--) {
|
||||||
|
if (!(transfer->len % (i * bpw)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (transfer->len % (spi_imx->wml * bpw))
|
spi_imx->wml = i;
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -837,10 +841,6 @@ static int spi_imx_dma_configure(struct spi_master *master,
|
|||||||
struct dma_slave_config rx = {}, tx = {};
|
struct dma_slave_config rx = {}, tx = {};
|
||||||
struct spi_imx_data *spi_imx = spi_master_get_devdata(master);
|
struct spi_imx_data *spi_imx = spi_master_get_devdata(master);
|
||||||
|
|
||||||
if (bytes_per_word == spi_imx->bytes_per_word)
|
|
||||||
/* Same as last time */
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (bytes_per_word) {
|
switch (bytes_per_word) {
|
||||||
case 4:
|
case 4:
|
||||||
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
||||||
|
Loading…
Reference in New Issue
Block a user