Commit e508cea4 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Mark Brown

spi: fsl-espi: make better use of the RX FIFO

So far an interrupt is triggered whenever there's at least one byte
in the RX FIFO. This results in a unnecessarily high number of
interrupts.
Change this to generate an interrupt if
- RX FIFO is half full (except if all bytes to read fit into the
  RX FIFO anyway)
- end of transfer has been reached

This way the number of interrupts can be significantly reduced.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent db1b049f
...@@ -55,9 +55,10 @@ ...@@ -55,9 +55,10 @@
#define CSMODE_CG(x) ((x) << 3) #define CSMODE_CG(x) ((x) << 3)
#define FSL_ESPI_FIFO_SIZE 32 #define FSL_ESPI_FIFO_SIZE 32
#define FSL_ESPI_RXTHR 15
/* Default mode/csmode for eSPI controller */ /* Default mode/csmode for eSPI controller */
#define SPMODE_INIT_VAL (SPMODE_TXTHR(4) | SPMODE_RXTHR(3)) #define SPMODE_INIT_VAL (SPMODE_TXTHR(4) | SPMODE_RXTHR(FSL_ESPI_RXTHR))
#define CSMODE_INIT_VAL (CSMODE_POL_1 | CSMODE_BEF(0) \ #define CSMODE_INIT_VAL (CSMODE_POL_1 | CSMODE_BEF(0) \
| CSMODE_AFT(0) | CSMODE_CG(1)) | CSMODE_AFT(0) | CSMODE_CG(1))
...@@ -263,6 +264,7 @@ static void fsl_espi_setup_transfer(struct spi_device *spi, ...@@ -263,6 +264,7 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,
static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)
{ {
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
u32 mask;
int ret; int ret;
mpc8xxx_spi->rx_len = t->len; mpc8xxx_spi->rx_len = t->len;
...@@ -277,8 +279,11 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) ...@@ -277,8 +279,11 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)
fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPCOM, fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPCOM,
(SPCOM_CS(spi->chip_select) | SPCOM_TRANLEN(t->len - 1))); (SPCOM_CS(spi->chip_select) | SPCOM_TRANLEN(t->len - 1)));
/* enable rx ints */ /* enable interrupts */
fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPIM, SPIM_RNE); mask = SPIM_DON;
if (mpc8xxx_spi->rx_len > FSL_ESPI_FIFO_SIZE)
mask |= SPIM_RXT;
fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPIM, mask);
/* Prevent filling the fifo from getting interrupted */ /* Prevent filling the fifo from getting interrupted */
spin_lock_irq(&mpc8xxx_spi->lock); spin_lock_irq(&mpc8xxx_spi->lock);
......
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