Documentation:spi:fsl-dspi:add DSPI dma transfer support
Subsystems (3)
PATCH 1/3 Documentation:spi:fsl-dspi:add DSPI dma transfer support
From: Chao Fu <[email protected]>
Add bool value use-dma.
The bool will determine whether DSPI use dma channel transfer data in a platform.
Add dmas and dma-names for describing dma channels of DSPI.
--- Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt +9 -0
@@ -11,6 +11,11 @@ Required properties: - spi-num-chipselects : the number of the chipselect signals. - bus-num : the slave chip chipselect signal number. - big-endian : if DSPI modudle is big endian, the bool will be set in node. +- use-dma: the bool decide if use dma method in DSPI transfering. +- dmas: List of DMA specifiers with the controller specific format + as described in the generic DMA client binding. A tx and rx + specifier is required for each chip select. +- dma-names: Should be named "tx" and "rx". Example: dspi0 at 4002c000 {
@@ -26,6 +31,10 @@ dspi0 at 4002c000 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_dspi0_1>; big-endian; + use-dma; + dmas = <&edma0 0 12>, + <&edma0 0 13>; + dma-names = "rx", "tx"; status = "okay"; sflash: at26df081a at 0 {
Signature · 1 line
1.8.4
PATCH 2/3 arm:dts:vf-610:add vybrid DSPI DMA transfer support
From: Chao Fu <[email protected]>
DSPI can transfer data in DMA mode or PIO mode.
The ajudgement of using DMA method(use-dma) will be read from dtb. And add DMA channels info of DSPI.
--- arch/arm/boot/dts/vf610.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/vf610.dtsi +4 -0
@@ -148,6 +148,10 @@ clocks = <&clks VF610_CLK_DSPI0>; clock-names = "dspi"; spi-num-chipselects = <5>; + use-dma; + dmas = <&edma0 0 12>, + <&edma0 0 13>; + dma-names = "rx", "tx"; status = "disabled"; };
Signature · 1 line
1.8.4
PATCH 3/3 spi:fsl-dspi:add dspi dma transfer support
In reply to Chao FuFrom: Chao Fu <[email protected]>
DSPI can transfer data in DMA mode or PIO mode.This patch will add the DMA transfer driver support. Add DMA reference functions and variables to form DMA transfer process.
DSPI DMA mode need work with Freescale eDMA module together.
The software will be changed in two transfer methods as followwing:
DMA PIO
trigger write: dspi_tx_dma dspi_tx_pio
write complete: dspi_dma_tx_complete irq_handle
trigger read: dspi_receive_dma dspi_rx_pio
read complete: dspi_rx_dma none
Remove bitbang:
Add DMA funtions, DSPI module need get cs change information in a spi transfer. According cs change, DSPI will give last data the right flag. Bitbang provide cs change behind the last data in a transfer. DSPI can not deal the last data in every transfer properly, so remove the bitbang in driver.
--- drivers/spi/Kconfig | 1 - drivers/spi/spi-fsl-dspi.c | 425 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 360 insertions(+), 66 deletions(-)
drivers/spi/Kconfig +0 -1
@@ -269,7 +269,6 @@ config SPI_FSL_SPI config SPI_FSL_DSPI tristate "Freescale DSPI controller" - select SPI_BITBANG select REGMAP_MMIO depends on SOC_VF610 || COMPILE_TEST help
drivers/spi/spi-fsl-dspi.c +360 -65
553 lines not on this page · raw message
Signature · 1 line
1.8.4
PATCH 3/3 spi:fsl-dspi:add dspi dma transfer support
Quoted 25 lines · Chao Fu
From: Chao Fu <[email protected]>
DSPI can transfer data in DMA mode or PIO mode.This patch will add the DMA transfer driver support. Add DMA reference functions and variables to form DMA transfer process.
DSPI DMA mode need work with Freescale eDMA module together.The software will be changed in two transfer methods as followwing:
DMA PIO trigger write: dspi_tx_dma dspi_tx_pio write complete: dspi_dma_tx_complete irq_handle trigger read: dspi_receive_dma dspi_rx_pio read complete: dspi_rx_dma noneRemove bitbang:
Add DMA funtions, DSPI module need get cs change information in a spi transfer. According cs change, DSPI will give last data the right flag. Bitbang provide cs change behind the last data in a transfer. DSPI can not deal the last data in every transfer properly, so remove the bitbang in driver.Signed-off-by Chao Fu <[email protected]>--- drivers/spi/Kconfig | 1 - drivers/spi/spi-fsl-dspi.c | 425 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 360 insertions(+), 66 deletions(-)
[...]
drivers/spi/spi-fsl-dspi.c static int dspi_probe(struct platform_device *pdev) · line 825
Quoted 11 lines
drivers/spi/spi-fsl-dspi.c +7
-0@@ -529,10 +816,18 @@ static int dspi_probe(struct platform_device *pdev) }clk_prepare_enable (dspi->clk); + dspi->use_dma =of_property_read_bool (np,"use-dma" ); +if (dspi->use_dma) +if (dspi_request_dma (dspi)) { + dspi->use_dma =0 ; +dev_err (&pdev->dev,"request dma channel fail\n" ); +dspi_release_dma (dspi); + }
Why have the use-dma property at all? You already fall back to PIO mode if the DMAs are not present, so it's clearly not a requirement to use DMA.
Why not always try to request he dmas you need? You already have the fallback logic, the only difference would be changing the dev_err to better describe the situation:
dev_info(&pdev->dev, "No 'tx' and/or 'rx' DMA(s), using PIO mode\n");
Cheers,
Mark.
PATCH 1/3 Documentation:spi:fsl-dspi:add DSPI dma transfer support
In reply to Chao FuQuoted 18 lines · Chao Fu
From: Chao Fu <[email protected]>
Add bool value use-dma.
The bool will determine whether DSPI use dma channel transfer data in a platform.Add dmas and dma-names for describing dma channels of DSPI.
Signed-off-by Chao Fu <[email protected]>--- Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt | 9 +++++++++ 1 file changed, 9 insertions(+)Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt +0
-0
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt Required properties: · line 14
Quoted 4 lines
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt +1
-0@@ -11,6 +11,11 @@ Required properties: - spi-num-chipselects : the number of the chipselect signals. - bus-num : the slave chip chipselect signal number. - big-endian : if DSPI modudle is big endian, the bool will be set in node. +- use-dma: the bool decide if use dma method in DSPI transfering.
Why can the OS not decide this based on the presence of dmas which it can use?
Is there ever a case that there would be dmas present but it would be in the interests of the OS to not use them?
Mark.
Quoted 28 lines
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt +8
-0+- dmas: List of DMA specifiers with the controller specific format + as described in the generic DMA client binding. A tx and rx + specifier is required for each chip select. +- dma-names: Should be named "tx" and "rx". Example: dspi0 at 4002c000 {@@ -26,6 +31,10 @@ dspi0 at 4002c000 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_dspi0_1>; big-endian; + use-dma; + dmas = <&edma0 0 12>, + <&edma0 0 13>; + dma-names = "rx", "tx"; status = "okay"; sflash: at26df081a at 0 {Signature · 8 lines
1.8.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/3 Documentation:spi:fsl-dspi:add DSPI dma transfer support
Quoted 14 lines · Mark Rutland
Quoted 13 lines · Chao Fu
From: Chao Fu <[email protected]>
Add bool value use-dma.
The bool will determine whether DSPI use dma channel transfer data in a platform.Add dmas and dma-names for describing dma channels of DSPI.
Signed-off-by Chao Fu <[email protected]>--- Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
Quoted 12 lines
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt Required properties: · line 14
Quoted 9 lines
Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt +1
-0@@ -11,6 +11,11 @@ Required properties: - spi-num-chipselects : the number of the chipselect signals. - bus-num : the slave chip chipselect signal number. - big-endian : if DSPI modudle is big endian, the bool will be set in node. +- use-dma: the bool decide if use dma method in DSPI transfering.Why can the OS not decide this based on the presence of dmas which it can use?
Yes, OS/driver should decide to use DMA or not, but it shouldn't be based on the presence of 'dmas' property. The DMA is a hardware resource just like IRQ. It should be just there in client device's node as long as the SoC design assigns the channel to the device. The device driver should make the decision when DMA should be used, e.g. big amount data transfer, and when PIO should be used, e.g. small data.
Shawn
Quoted 3 lines
Is there ever a case that there would be dmas present but it would be in the interests of the OS to not use them?
Mark Brown
maintainerPATCH 1/3 Documentation:spi:fsl-dspi:add DSPI dma transfer support
Quoted 7 lines · Shawn Guo
Quoted 4 lines · Mark Rutland
Quoted 1 line
+- use-dma: the bool decide if use dma method in DSPI transfering.
Why can the OS not decide this based on the presence of dmas which it can use?
Quoted 6 lines
Yes, OS/driver should decide to use DMA or not, but it shouldn't be based on the presence of 'dmas' property. The DMA is a hardware resource just like IRQ. It should be just there in client device's node as long as the SoC design assigns the channel to the device. The device driver should make the decision when DMA should be used, e.g. big amount data transfer, and when PIO should be used, e.g. small data.
Right, that's very common - but that decision is usually taken on a per
transfer basis so a DT property would seem odd, especially just a simple
boolean.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140227/898f98b9/attachment.sig>
PATCH 1/3 Documentation:spi:fsl-dspi:add DSPI dma transfer support
Quoted 15 lines · Mark Brown
Quoted 7 lines · Shawn Guo
Quoted 4 lines · Mark Rutland
Quoted 1 line
+- use-dma: the bool decide if use dma method in DSPI transfering.
Why can the OS not decide this based on the presence of dmas which it can use?
Quoted 6 lines
Yes, OS/driver should decide to use DMA or not, but it shouldn't be based on the presence of 'dmas' property. The DMA is a hardware resource just like IRQ. It should be just there in client device's node as long as the SoC design assigns the channel to the device. The device driver should make the decision when DMA should be used, e.g. big amount data transfer, and when PIO should be used, e.g. small data.
Quoted 3 lines
Right, that's very common - but that decision is usually taken on a per transfer basis so a DT property would seem odd, especially just a simple boolean.
Yea, I guess we're on the same page - the decision should be made by the device driver on its own not the device tree.
Shawn