Skip to contentSkip to conversation

dt-bindings: Add dma-burst-sz property for spi-pxa2xx

PATCH In review Andy Shevchenko 5 participants 10 messages Feb 26, 2019 – Mar 8, 2019

Subsystems (4)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/3 dt-bindings: Add dma-burst-sz property for spi-pxa2xx

Add DMA burst size property to the SPI PXA2xx bindings.

---
 Documentation/devicetree/bindings/spi/spi-pxa2xx.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/spi/spi-pxa2xx.txt +1 -0
index e30e0c2a4bce..3b2e70ba7466 100644
@@ -11,6 +11,7 @@ Required properties:
 Optional properties:
 - cs-gpios: list of GPIO chip selects. See the SPI bus bindings,
   Documentation/devicetree/bindings/spi/spi-bus.txt
+- dma-burst-sz: DMA burst size
 - spi-slave: Empty property indicating the SPI controller is used in slave mode.
 - ready-gpios: GPIO used to signal a SPI master that the FIFO is filled
   and we're ready to service a transfer. Only useful in slave mode.
Signature · 1 line
2.20.1
author reviewer
#1 lore raw

PATCH 2/3 spi: pxa2xx: Introduce dma-burst-sz property support

Some masters may have different DMA burst size than hard coded default. In such case respect the value given by dma-burst-size property.

---
 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(-)
drivers/spi/spi-pxa2xx-dma.c +3 -1
index 2fa7f4b43492..3343fff81c7b 100644
@@ -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);
 
drivers/spi/spi-pxa2xx-pci.c +7 -1
index d3de925892cb..1db1b64cfba8 100644
@@ -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);
drivers/spi/spi-pxa2xx.c +4 -1
index 8dd67d722aae..393e020c757a 100644
@@ -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;
 }
include/linux/spi/pxa2xx_spi.h +1 -0
index b0674e330ef6..154da8cd4781 100644
@@ -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 */
Signature · 1 line
2.20.1
#2 lore raw

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

Quoted 10 lines · Andy Shevchenko

Some masters may have different DMA burst size than hard coded default. In such case respect the value given by dma-burst-size property.

---
  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(-)

...

drivers/spi/spi-pxa2xx.c pxa2xx_spi_init_pdata(struct platform_device *pdev) · line 1571

Quoted 6 lines
drivers/spi/spi-pxa2xx.c +1 -1
@@ -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.

Signature · 1 line
Jarkko
author reviewer
#3 lore raw

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

Quoted 11 lines · Jarkko Nikula
Quoted 10 lines · Andy Shevchenko

Some masters may have different DMA burst size than hard coded default. In such case respect the value given by dma-burst-size property.

---
  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(-)
Quoted 8 lines

...

drivers/spi/spi-pxa2xx.c pxa2xx_spi_init_pdata(struct platform_device *pdev) · line 1570

Quoted 5 lines
drivers/spi/spi-pxa2xx.c +1 -1
@@ -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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on v1 2/3
#4 lore raw

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

In reply to Andy Shevchenko
Quoted 9 lines · Andy Shevchenko
drivers/spi/spi-pxa2xx.c +1 -0
@@ -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);

drivers/spi/spi-pxa2xx.c pxa2xx_spi_init_pdata(struct platform_device *pdev) · line 1571

Quoted 5 lines
drivers/spi/spi-pxa2xx.c +1 -1
@@ -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 :

Cheers.

Signature · 1 line
Robert
#5 lore raw

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

Quoted 10 lines · Robert Jarzmik
Quoted 7 lines · Andy Shevchenko
drivers/spi/spi-pxa2xx.c +1 -0
@@ -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;
 
Quoted 8 lines

drivers/spi/spi-pxa2xx.c pxa2xx_spi_init_pdata(struct platform_device *pdev) · line 1571

Quoted 7 lines
drivers/spi/spi-pxa2xx.c +1 -1
      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.

Quoted 2 lines

Other than this :

Thanks!
Does it applies to v2?

Quoted 5 lines

Cheers.

--
Robert

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author reviewer
#7 lore raw

PATCH 3/3 spi: pxa2xx: Debug print DMA burst and threshold

In reply to Andy Shevchenko

It's useful during debug to see what DMA burst and threshold sizes are.

---
 drivers/spi/spi-pxa2xx.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/spi-pxa2xx.c +3 -0
index 393e020c757a..534460a29432 100644
@@ -1339,6 +1339,9 @@ static int setup(struct spi_device *spi)
 			dev_warn(&spi->dev,
 				 "in setup: DMA burst size reduced to match bits_per_word\n");
 		}
+		dev_dbg(&spi->dev,
+			"in setup: DMA burst and threshold set to %u, %u\n",
+			chip->dma_burst_size, chip->dma_threshold);
 	}
 
 	switch (drv_data->ssp_type) {
Signature · 1 line
2.20.1
maintainer
#8 lore raw
In reply to Andy Shevchenko
Quoted 1 line · Andy Shevchenko

Add DMA burst size property to the SPI PXA2xx bindings.

Shouldn't we be inferring this from the device specific compatible string (or PCI identifier for x86)? That way if there's other quirks needed we don't need any binding changes.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author reviewer
#9 lore raw
Quoted 6 lines · Mark Brown
Quoted 1 line · Andy Shevchenko

Add DMA burst size property to the SPI PXA2xx bindings.

Shouldn't we be inferring this from the device specific compatible string (or PCI identifier for x86)? That way if there's other quirks needed we don't need any binding changes.

Hmm... Yes, we may use PCI ID for that.

Signature · 2 lines
With Best Regards,
Andy Shevchenko