diff mbox series

[13/17] spi: dw: Initialize paddr in DW SPI MMIO private data

Message ID 20200508132943.9826-14-Sergey.Semin@baikalelectronics.ru (mailing list archive)
State Superseded
Headers show
Series spi: dw: Add generic DW DMA controller support | expand

Commit Message

Serge Semin May 8, 2020, 1:29 p.m. UTC
This field is used only for the DW SPI DMA code initialization, that's
why there were no problems with it being uninitialized in Dw SPI MMIO
driver. Since in a further patch we are going to introduce the DW SPI DMA
support in the MMIO version of the driver, lets set the field with the
physical address of the DW SPI controller registers region.

Co-developed-by: Georgy Vlasov <Georgy.Vlasov@baikalelectronics.ru>
Signed-off-by: Georgy Vlasov <Georgy.Vlasov@baikalelectronics.ru>
Co-developed-by: Ramil Zaripov <Ramil.Zaripov@baikalelectronics.ru>
Signed-off-by: Ramil Zaripov <Ramil.Zaripov@baikalelectronics.ru>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Allison Randal <allison@lohutok.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Gareth Williams <gareth.williams.jx@renesas.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: linux-mips@vger.kernel.org
Cc: devicetree@vger.kernel.org
---
 drivers/spi/spi-dw-mmio.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko May 8, 2020, 7:21 p.m. UTC | #1
On Fri, May 08, 2020 at 04:29:38PM +0300, Serge Semin wrote:
> This field is used only for the DW SPI DMA code initialization, that's
> why there were no problems with it being uninitialized in Dw SPI MMIO
> driver. Since in a further patch we are going to introduce the DW SPI DMA
> support in the MMIO version of the driver, lets set the field with the
> physical address of the DW SPI controller registers region.

...

> -	dws->regs = devm_platform_ioremap_resource(pdev, 0);
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	dws->regs = devm_ioremap_resource(&pdev->dev, mem);

There is a helper
	dws->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);


>  	if (IS_ERR(dws->regs)) {
>  		dev_err(&pdev->dev, "SPI region map failed\n");
>  		return PTR_ERR(dws->regs);
>  	}
> +	dws->paddr = mem->start;
>  
>  	dws->irq = platform_get_irq(pdev, 0);
>  	if (dws->irq < 0)
> -- 
> 2.25.1
>
Serge Semin May 13, 2020, 12:30 p.m. UTC | #2
On Fri, May 08, 2020 at 10:21:44PM +0300, Andy Shevchenko wrote:
> On Fri, May 08, 2020 at 04:29:38PM +0300, Serge Semin wrote:
> > This field is used only for the DW SPI DMA code initialization, that's
> > why there were no problems with it being uninitialized in Dw SPI MMIO
> > driver. Since in a further patch we are going to introduce the DW SPI DMA
> > support in the MMIO version of the driver, lets set the field with the
> > physical address of the DW SPI controller registers region.
> 
> ...
> 
> > -	dws->regs = devm_platform_ioremap_resource(pdev, 0);
> > +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	dws->regs = devm_ioremap_resource(&pdev->dev, mem);
> 

> There is a helper
> 	dws->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);

Oh, good point. It has been just added, in kernel v5.7. v5.6 didn't provide such
a convenient helper. Thanks for the suggestion.

-Sergey

> 
> 
> >  	if (IS_ERR(dws->regs)) {
> >  		dev_err(&pdev->dev, "SPI region map failed\n");
> >  		return PTR_ERR(dws->regs);
> >  	}
> > +	dws->paddr = mem->start;
> >  
> >  	dws->irq = platform_get_irq(pdev, 0);
> >  	if (dws->irq < 0)
> > -- 
> > 2.25.1
> > 
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
>
diff mbox series

Patch

diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index 384a3ab6dc2d..2ff1b700305f 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -136,6 +136,7 @@  static int dw_spi_mmio_probe(struct platform_device *pdev)
 	int (*init_func)(struct platform_device *pdev,
 			 struct dw_spi_mmio *dwsmmio);
 	struct dw_spi_mmio *dwsmmio;
+	struct resource *mem;
 	struct dw_spi *dws;
 	int ret;
 	int num_cs;
@@ -148,11 +149,13 @@  static int dw_spi_mmio_probe(struct platform_device *pdev)
 	dws = &dwsmmio->dws;
 
 	/* Get basic io resource and map it */
-	dws->regs = devm_platform_ioremap_resource(pdev, 0);
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	dws->regs = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(dws->regs)) {
 		dev_err(&pdev->dev, "SPI region map failed\n");
 		return PTR_ERR(dws->regs);
 	}
+	dws->paddr = mem->start;
 
 	dws->irq = platform_get_irq(pdev, 0);
 	if (dws->irq < 0)