Re: [PATCH v2 08/15] spi: dw: update irq setup to use multiple handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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
> 



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux