Message ID | 20221212180732.79167-9-sudip.mukherjee@sifive.com |
---|---|
State | New |
Headers | show |
Series | Add support for enhanced SPI for Designware SPI controllers | expand |
On Mon, Dec 12, 2022 at 06:07:25PM +0000, Sudip Mukherjee wrote: > The current mem_ops is not using interrupt based transfer so > dw_spi_irq_setup() only has one interrput handler to handle the non > mem_ops transfers. We will use interrupt based transfers in enhanced > spi and so we need a way to specify which irq handler to use. > > Signed-off-by: Sudip Mukherjee <sudip.mukherjee@sifive.com> > --- > drivers/spi/spi-dw-core.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c > index ecab0fbc847c7..f540165245a89 100644 > --- a/drivers/spi/spi-dw-core.c > +++ b/drivers/spi/spi-dw-core.c > @@ -260,7 +260,8 @@ static irqreturn_t dw_spi_irq(int irq, void *dev_id) > if (!irq_status) > return IRQ_NONE; > > - if (!master->cur_msg) { > + if (!master->cur_msg && dws->transfer_handler == > + dw_spi_transfer_handler) { What about replacing this with the (!dws->rx_len && !dws->tx_len) statement? > dw_spi_mask_intr(dws, 0xff); > return IRQ_HANDLED; > } > @@ -380,7 +381,8 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, > } > EXPORT_SYMBOL_NS_GPL(dw_spi_update_config, SPI_DW_CORE); > > -static void dw_spi_irq_setup(struct dw_spi *dws) > +static void dw_spi_irq_setup(struct dw_spi *dws, > + irqreturn_t (*t_handler)(struct dw_spi *)) > { > u16 level; > u8 imask; > @@ -394,7 +396,7 @@ static void dw_spi_irq_setup(struct dw_spi *dws) > dw_writel(dws, DW_SPI_TXFTLR, level); > dw_writel(dws, DW_SPI_RXFTLR, level - 1); > > - dws->transfer_handler = dw_spi_transfer_handler; > + dws->transfer_handler = t_handler; > > imask = DW_SPI_INT_TXEI | DW_SPI_INT_TXOI | > DW_SPI_INT_RXUI | DW_SPI_INT_RXOI | DW_SPI_INT_RXFI; I'd suggest to create a separate dw_spi_enh_irq_setup() method which would unmask only the required IRQs, initialize the threshold level depending on the transfer type and set the dw_spi_enh_transfer_handler() handler. -Serge(y) > @@ -486,7 +488,7 @@ static int dw_spi_transfer_one(struct spi_controller *master, > else if (dws->irq == IRQ_NOTCONNECTED) > return dw_spi_poll_transfer(dws, transfer); > > - dw_spi_irq_setup(dws); > + dw_spi_irq_setup(dws, dw_spi_transfer_handler); > > return 1; > } > -- > 2.30.2 >
diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index ecab0fbc847c7..f540165245a89 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -260,7 +260,8 @@ static irqreturn_t dw_spi_irq(int irq, void *dev_id) if (!irq_status) return IRQ_NONE; - if (!master->cur_msg) { + if (!master->cur_msg && dws->transfer_handler == + dw_spi_transfer_handler) { dw_spi_mask_intr(dws, 0xff); return IRQ_HANDLED; } @@ -380,7 +381,8 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi, } EXPORT_SYMBOL_NS_GPL(dw_spi_update_config, SPI_DW_CORE); -static void dw_spi_irq_setup(struct dw_spi *dws) +static void dw_spi_irq_setup(struct dw_spi *dws, + irqreturn_t (*t_handler)(struct dw_spi *)) { u16 level; u8 imask; @@ -394,7 +396,7 @@ static void dw_spi_irq_setup(struct dw_spi *dws) dw_writel(dws, DW_SPI_TXFTLR, level); dw_writel(dws, DW_SPI_RXFTLR, level - 1); - dws->transfer_handler = dw_spi_transfer_handler; + dws->transfer_handler = t_handler; imask = DW_SPI_INT_TXEI | DW_SPI_INT_TXOI | DW_SPI_INT_RXUI | DW_SPI_INT_RXOI | DW_SPI_INT_RXFI; @@ -486,7 +488,7 @@ static int dw_spi_transfer_one(struct spi_controller *master, else if (dws->irq == IRQ_NOTCONNECTED) return dw_spi_poll_transfer(dws, transfer); - dw_spi_irq_setup(dws); + dw_spi_irq_setup(dws, dw_spi_transfer_handler); return 1; }
The current mem_ops is not using interrupt based transfer so dw_spi_irq_setup() only has one interrput handler to handle the non mem_ops transfers. We will use interrupt based transfers in enhanced spi and so we need a way to specify which irq handler to use. Signed-off-by: Sudip Mukherjee <sudip.mukherjee@sifive.com> --- drivers/spi/spi-dw-core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)