diff mbox series

[v1,2/3] spi: pxa2xx: Introduce dma-burst-sz property support

Message ID 20190226092441.49198-2-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/3] dt-bindings: Add dma-burst-sz property for spi-pxa2xx | expand

Commit Message

Andy Shevchenko Feb. 26, 2019, 9:24 a.m. UTC
Some masters may have different DMA burst size than hard coded default.
In such case respect the value given by dma-burst-size property.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-dma.c   | 4 +++-
 drivers/spi/spi-pxa2xx-pci.c   | 8 +++++++-
 drivers/spi/spi-pxa2xx.c       | 5 ++++-
 include/linux/spi/pxa2xx_spi.h | 1 +
 4 files changed, 15 insertions(+), 3 deletions(-)

Comments

Jarkko Nikula Feb. 26, 2019, 11:46 a.m. UTC | #1
On 2/26/19 11:24 AM, Andy Shevchenko wrote:
> Some masters may have different DMA burst size than hard coded default.
> In such case respect the value given by dma-burst-size property.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/spi/spi-pxa2xx-dma.c   | 4 +++-
>   drivers/spi/spi-pxa2xx-pci.c   | 8 +++++++-
>   drivers/spi/spi-pxa2xx.c       | 5 ++++-
>   include/linux/spi/pxa2xx_spi.h | 1 +
>   4 files changed, 15 insertions(+), 3 deletions(-)
...
> @@ -1566,9 +1568,10 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
>   	ssp->pdev = pdev;
>   	ssp->port_id = pxa2xx_spi_get_port_id(adev);
>   
> -	pdata->is_slave = of_property_read_bool(pdev->dev.of_node, "spi-slave");
> +	pdata->is_slave = device_property_read_bool(dev, "spi-slave");

Unrelated change. Not sure is it worth of its own patch.
Andy Shevchenko Feb. 26, 2019, 1:02 p.m. UTC | #2
On Tue, Feb 26, 2019 at 01:46:49PM +0200, Jarkko Nikula wrote:
> On 2/26/19 11:24 AM, Andy Shevchenko wrote:
> > Some masters may have different DMA burst size than hard coded default.
> > In such case respect the value given by dma-burst-size property.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >   drivers/spi/spi-pxa2xx-dma.c   | 4 +++-
> >   drivers/spi/spi-pxa2xx-pci.c   | 8 +++++++-
> >   drivers/spi/spi-pxa2xx.c       | 5 ++++-
> >   include/linux/spi/pxa2xx_spi.h | 1 +
> >   4 files changed, 15 insertions(+), 3 deletions(-)
> ...
> > @@ -1566,9 +1568,10 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
> >   	ssp->pdev = pdev;
> >   	ssp->port_id = pxa2xx_spi_get_port_id(adev);
> > -	pdata->is_slave = of_property_read_bool(pdev->dev.of_node, "spi-slave");
> > +	pdata->is_slave = device_property_read_bool(dev, "spi-slave");
> 
> Unrelated change. Not sure is it worth of its own patch.

Fixed in v2.
Robert Jarzmik March 7, 2019, 7:24 p.m. UTC | #3
Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

> @@ -1512,6 +1513,7 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
>  	const struct acpi_device_id *adev_id = NULL;
>  	const struct pci_device_id *pcidev_id = NULL;
>  	const struct of_device_id *of_id = NULL;
> +	struct device *dev = &pdev->dev;
>  	enum pxa_ssp_type type;
>  
>  	adev = ACPI_COMPANION(&pdev->dev);
> @@ -1566,9 +1568,10 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
>  	ssp->pdev = pdev;
>  	ssp->port_id = pxa2xx_spi_get_port_id(adev);
>  
> -	pdata->is_slave = of_property_read_bool(pdev->dev.of_node, "spi-slave");
> +	pdata->is_slave = device_property_read_bool(dev, "spi-slave");
Isn't this an unrelated change to the introduction of dma-burst-sz ?

Other than this :
Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>

Cheers.
Andy Shevchenko March 8, 2019, 7:07 a.m. UTC | #4
On Thu, Mar 7, 2019 at 9:25 PM Robert Jarzmik <robert.jarzmik@free.fr> wrote:
>
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
>
> > @@ -1512,6 +1513,7 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
> >       const struct acpi_device_id *adev_id = NULL;
> >       const struct pci_device_id *pcidev_id = NULL;
> >       const struct of_device_id *of_id = NULL;
> > +     struct device *dev = &pdev->dev;
> >       enum pxa_ssp_type type;
> >
> >       adev = ACPI_COMPANION(&pdev->dev);
> > @@ -1566,9 +1568,10 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
> >       ssp->pdev = pdev;
> >       ssp->port_id = pxa2xx_spi_get_port_id(adev);
> >
> > -     pdata->is_slave = of_property_read_bool(pdev->dev.of_node, "spi-slave");
> > +     pdata->is_slave = device_property_read_bool(dev, "spi-slave");
> Isn't this an unrelated change to the introduction of dma-burst-sz ?

Yes, Jarkko did same comment.
It's fixed in v2 which was sent several days ago.

> Other than this :
> Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>

Thanks!
Does it applies to v2?

>
> Cheers.
>
> --
> Robert
Andy Shevchenko March 8, 2019, 7:08 a.m. UTC | #5
On Fri, Mar 8, 2019 at 9:07 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Thu, Mar 7, 2019 at 9:25 PM Robert Jarzmik <robert.jarzmik@free.fr> wrote:

> > Other than this :
> > Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>
>
> Thanks!
> Does it applies to v2?

https://www.spinics.net/lists/arm-kernel/msg710155.html
diff mbox series

Patch

diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c
index 2fa7f4b43492..3343fff81c7b 100644
--- a/drivers/spi/spi-pxa2xx-dma.c
+++ b/drivers/spi/spi-pxa2xx-dma.c
@@ -239,13 +239,15 @@  int pxa2xx_spi_set_dma_burst_and_threshold(struct chip_data *chip,
 					   u32 *threshold)
 {
 	struct pxa2xx_spi_chip *chip_info = spi->controller_data;
+	struct driver_data *drv_data = spi_controller_get_devdata(spi->controller);
+	u32 dma_burst_size = drv_data->master_info->dma_burst_size;
 
 	/*
 	 * If the DMA burst size is given in chip_info we use that,
 	 * otherwise we use the default. Also we use the default FIFO
 	 * thresholds for now.
 	 */
-	*burst_code = chip_info ? chip_info->dma_burst_size : 1;
+	*burst_code = chip_info ? chip_info->dma_burst_size : dma_burst_size;
 	*threshold = SSCR1_RxTresh(RX_THRESH_DFLT)
 		   | SSCR1_TxTresh(TX_THRESH_DFLT);
 
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index d3de925892cb..1db1b64cfba8 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -5,9 +5,9 @@ 
  */
 #include <linux/clk-provider.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/spi/pxa2xx_spi.h>
 
 #include <linux/dmaengine.h>
@@ -200,6 +200,7 @@  static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	struct pxa2xx_spi_master spi_pdata;
 	struct ssp_device *ssp;
 	struct pxa_spi_info *c;
+	u32 dma_burst_sz;
 	char buf[40];
 
 	ret = pcim_enable_device(dev);
@@ -217,12 +218,17 @@  static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 			return ret;
 	}
 
+	ret = device_property_read_u32(&dev->dev, "dma-burst-sz", &dma_burst_sz);
+	if (ret)
+		dma_burst_sz = 1;
+
 	memset(&spi_pdata, 0, sizeof(spi_pdata));
 	spi_pdata.num_chipselect = (c->num_chipselect > 0) ? c->num_chipselect : dev->devfn;
 	spi_pdata.dma_filter = c->dma_filter;
 	spi_pdata.tx_param = c->tx_param;
 	spi_pdata.rx_param = c->rx_param;
 	spi_pdata.enable_dma = c->rx_param && c->tx_param;
+	spi_pdata.dma_burst_size = dma_burst_sz;
 
 	ssp = &spi_pdata.ssp;
 	ssp->phys_base = pci_resource_start(dev, 0);
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 8dd67d722aae..393e020c757a 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -24,6 +24,7 @@ 
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/spi/pxa2xx_spi.h>
 #include <linux/spi/spi.h>
 #include <linux/delay.h>
@@ -1512,6 +1513,7 @@  pxa2xx_spi_init_pdata(struct platform_device *pdev)
 	const struct acpi_device_id *adev_id = NULL;
 	const struct pci_device_id *pcidev_id = NULL;
 	const struct of_device_id *of_id = NULL;
+	struct device *dev = &pdev->dev;
 	enum pxa_ssp_type type;
 
 	adev = ACPI_COMPANION(&pdev->dev);
@@ -1566,9 +1568,10 @@  pxa2xx_spi_init_pdata(struct platform_device *pdev)
 	ssp->pdev = pdev;
 	ssp->port_id = pxa2xx_spi_get_port_id(adev);
 
-	pdata->is_slave = of_property_read_bool(pdev->dev.of_node, "spi-slave");
+	pdata->is_slave = device_property_read_bool(dev, "spi-slave");
 	pdata->num_chipselect = 1;
 	pdata->enable_dma = true;
+	pdata->dma_burst_size = 1;
 
 	return pdata;
 }
diff --git a/include/linux/spi/pxa2xx_spi.h b/include/linux/spi/pxa2xx_spi.h
index b0674e330ef6..154da8cd4781 100644
--- a/include/linux/spi/pxa2xx_spi.h
+++ b/include/linux/spi/pxa2xx_spi.h
@@ -25,6 +25,7 @@  struct dma_chan;
 struct pxa2xx_spi_master {
 	u16 num_chipselect;
 	u8 enable_dma;
+	u8 dma_burst_size;
 	bool is_slave;
 
 	/* DMA engine specific config */