Commit cf86874b authored by Clark Wang's avatar Clark Wang Committed by Mark Brown

spi: lpspi: Let watermark change with send data length

Configure watermark to change with the length of the sent data.
Support LPSPI sending message shorter than tx/rxfifosize.
Signed-off-by: default avatarClark Wang <xiaoning.wang@nxp.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bcd87317
...@@ -89,6 +89,7 @@ struct fsl_lpspi_data { ...@@ -89,6 +89,7 @@ struct fsl_lpspi_data {
void (*rx)(struct fsl_lpspi_data *); void (*rx)(struct fsl_lpspi_data *);
u32 remain; u32 remain;
u8 watermark;
u8 txfifosize; u8 txfifosize;
u8 rxfifosize; u8 rxfifosize;
...@@ -235,7 +236,7 @@ static void fsl_lpspi_set_watermark(struct fsl_lpspi_data *fsl_lpspi) ...@@ -235,7 +236,7 @@ static void fsl_lpspi_set_watermark(struct fsl_lpspi_data *fsl_lpspi)
{ {
u32 temp; u32 temp;
temp = fsl_lpspi->txfifosize >> 1 | (fsl_lpspi->rxfifosize >> 1) << 16; temp = fsl_lpspi->watermark >> 1 | (fsl_lpspi->watermark >> 1) << 16;
writel(temp, fsl_lpspi->base + IMX7ULP_FCR); writel(temp, fsl_lpspi->base + IMX7ULP_FCR);
...@@ -261,7 +262,8 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi) ...@@ -261,7 +262,8 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
if (prescale == 8 && scldiv >= 256) if (prescale == 8 && scldiv >= 256)
return -EINVAL; return -EINVAL;
writel(scldiv, fsl_lpspi->base + IMX7ULP_CCR); writel(scldiv | (scldiv << 8) | ((scldiv >> 1) << 16),
fsl_lpspi->base + IMX7ULP_CCR);
dev_dbg(fsl_lpspi->dev, "perclk=%d, speed=%d, prescale =%d, scldiv=%d\n", dev_dbg(fsl_lpspi->dev, "perclk=%d, speed=%d, prescale =%d, scldiv=%d\n",
perclk_rate, config.speed_hz, prescale, scldiv); perclk_rate, config.speed_hz, prescale, scldiv);
...@@ -329,6 +331,11 @@ static void fsl_lpspi_setup_transfer(struct spi_device *spi, ...@@ -329,6 +331,11 @@ static void fsl_lpspi_setup_transfer(struct spi_device *spi,
fsl_lpspi->tx = fsl_lpspi_buf_tx_u32; fsl_lpspi->tx = fsl_lpspi_buf_tx_u32;
} }
if (t->len <= fsl_lpspi->txfifosize)
fsl_lpspi->watermark = t->len;
else
fsl_lpspi->watermark = fsl_lpspi->txfifosize;
fsl_lpspi_config(fsl_lpspi); fsl_lpspi_config(fsl_lpspi);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment