dmaengine: Add support for QCOM GSI dma controller
Subsystems (3)
Vinod Koul
maintainerv3 cover dmaengine: Add support for QCOM GSI dma controller
This series adds support for Qcom GSI dma controller found on Qualcomm SoCs. This controller can program the peripheral configuration so we add additional parameters in dma_slave_config for configuring the peripherals like spi and i2c.
Changes in v3:
- Update the i2c tre creation based on testing feedback
Changes in v2:
- Update the binding and drop qcom specific properties
- Move peripheral configuration as a pointer
- Move submit queue for transactions to issue_pending
Vinod Koul (3):
dt-bindings: dmaengine: Document qcom,gpi dma binding
dmaengine: add peripheral configuration
dmaengine: qcom: Add GPI dma driver
.../devicetree/bindings/dma/qcom,gpi.yaml | 86 + drivers/dma/qcom/Kconfig | 12 + drivers/dma/qcom/Makefile | 1 + drivers/dma/qcom/gpi.c | 2295 +++++++++++++++++ include/dt-bindings/dma/qcom-gpi.h | 11 + include/linux/dmaengine.h | 91 + 6 files changed, 2496 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/qcom,gpi.yaml create mode 100644 drivers/dma/qcom/gpi.c create mode 100644 include/dt-bindings/dma/qcom-gpi.h
Signature · 1 line
2.26.2
Vinod Koul
maintainerPATCH v3 1/3 dt-bindings: dmaengine: Document qcom,gpi dma binding
Add devicetree binding documentation for GPI DMA controller implemented on Qualcomm SoCs
--- .../devicetree/bindings/dma/qcom,gpi.yaml | 86 +++++++++++++++++++ include/dt-bindings/dma/qcom-gpi.h | 11 +++ 2 files changed, 97 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/qcom,gpi.yaml create mode 100644 include/dt-bindings/dma/qcom-gpi.h
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +86 -0
@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/qcom,gpi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Technologies Inc GPI DMA controller + +maintainers: + - Vinod Koul <[email protected]> + +description: | + QCOM GPI DMA controller provides DMA capabilities for + peripheral buses such as I2C, UART, and SPI. + +allOf: + - $ref: "dma-controller.yaml#" + +properties: + compatible: + enum: + - qcom,gpi-dma + + reg: + maxItems: 1 + + interrupts: + description: + Interrupt lines for each GPII instance + maxItems: 13 + + "#dma-cells": + const: 3 + description: > + DMA clients must use the format described in dma.txt, giving a phandle + to the DMA controller plus the following 3 integer cells: + - channel: if set to 0xffffffff, any available channel will be allocated + for the client. Otherwise, the exact channel specified will be used. + - seid: serial id of the client as defined in the SoC documentation. + - client: type of the client as defined in dt-bindings/dma/qcom-gpi.h + + iommus: + maxItems: 1 + + dma-channels: + maxItems: 1 + + dma-channel-mask: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - "#dma-cells" + - iommus + - dma-channels + - dma-channel-mask + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/dma/qcom-gpi.h> + gpi_dma0: dma-controller@800000 { + compatible = "qcom,gpi-dma"; + #dma-cells = <3>; + reg = <0x00800000 0x60000>; + iommus = <&apps_smmu 0x0016 0x0>; + dma-channels = <13>; + dma-channel-mask = <0xfa>; + interrupts = <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 247 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 248 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 249 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 250 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 251 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 252 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 253 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 254 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 255 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 256 IRQ_TYPE_LEVEL_HIGH>; + }; + +...
include/dt-bindings/dma/qcom-gpi.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2020, Linaro Ltd. */ + +#ifndef __DT_BINDINGS_DMA_QCOM_GPI_H__ +#define __DT_BINDINGS_DMA_QCOM_GPI_H__ + +#define QCOM_GPI_SPI 1 +#define QCOM_GPI_UART 2 +#define QCOM_GPI_I2C 3 + +#endif /* __DT_BINDINGS_DMA_QCOM_GPI_H__ */
Signature · 1 line
2.26.2
Rob Herring
maintainerRe: [PATCH v3 1/3] dt-bindings: dmaengine: Document qcom,gpi dma binding
Quoted 29 lines · Vinod Koul
Add devicetree binding documentation for GPI DMA controller implemented on Qualcomm SoCs
Signed-off-by Vinod Koul <[email protected]>--- .../devicetree/bindings/dma/qcom,gpi.yaml | 86 +++++++++++++++++++ include/dt-bindings/dma/qcom-gpi.h | 11 +++ 2 files changed, 97 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/qcom,gpi.yaml create mode 100644 include/dt-bindings/dma/qcom-gpi.hDocumentation/devicetree/bindings/dma/qcom,gpi.yaml new file +12
-0@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/qcom,gpi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Technologies Inc GPI DMA controller + +maintainers: + - Vinod Koul <[email protected]> + +description: |
Documentation/devicetree/bindings/dma/qcom,gpi.yaml line 22
Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +10
-0+ QCOM GPI DMA controller provides DMA capabilities for + peripheral buses such as I2C, UART, and SPI. + +allOf: + - $ref: "dma-controller.yaml#" + +properties: + compatible: + enum: + - qcom,gpi-dma
Should be SoC specific.
Documentation/devicetree/bindings/dma/qcom,gpi.yaml line 29
Quoted 7 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +7
-0+ + reg: + maxItems: 1 + + interrupts: + description: + Interrupt lines for each GPII instance
GPII or GPI?
Quoted 7 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +7
-0+ maxItems: 13 + + "#dma-cells": + const: 3 + description: > + DMA clients must use the format described in dma.txt, giving a phandle + to the DMA controller plus the following 3 integer cells:
Documentation/devicetree/bindings/dma/qcom,gpi.yaml line 46
Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +10
-0+ - channel: if set to 0xffffffff, any available channel will be allocated + for the client. Otherwise, the exact channel specified will be used. + - seid: serial id of the client as defined in the SoC documentation. + - client: type of the client as defined in dt-bindings/dma/qcom-gpi.h + + iommus: + maxItems: 1 + + dma-channels: + maxItems: 1
Not an array. Is there a maximum number of channels or 2^32 is valid?
Documentation/devicetree/bindings/dma/qcom,gpi.yaml line 49
Quoted 3 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +3
-0+ + dma-channel-mask: + maxItems: 1
So up to 32 channels?
Quoted 57 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +37
-0+ +required: + - compatible + - reg + - interrupts + - "#dma-cells" + - iommus + - dma-channels + - dma-channel-mask + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/dma/qcom-gpi.h> + gpi_dma0: dma-controller@800000 { + compatible = "qcom,gpi-dma"; + #dma-cells = <3>; + reg = <0x00800000 0x60000>; + iommus = <&apps_smmu 0x0016 0x0>; + dma-channels = <13>; + dma-channel-mask = <0xfa>; + interrupts = <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 247 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 248 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 249 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 250 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 251 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 252 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 253 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 254 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 255 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 256 IRQ_TYPE_LEVEL_HIGH>; + }; + +...include/dt-bindings/dma/qcom-gpi.h new file +11
-0@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2020, Linaro Ltd. */ + +#ifndef __DT_BINDINGS_DMA_QCOM_GPI_H__ +#define __DT_BINDINGS_DMA_QCOM_GPI_H__ + +#define QCOM_GPI_SPI 1 +#define QCOM_GPI_UART 2 +#define QCOM_GPI_I2C 3 + +#endif /* __DT_BINDINGS_DMA_QCOM_GPI_H__ */ Signature · 1 line
2.26.2
Vinod Koul
maintainerRe: [PATCH v3 1/3] dt-bindings: dmaengine: Document qcom,gpi dma binding
Hi Rob,
Quoted 5 lines · Rob Herring
Quoted 5 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +5
-0+description: | + QCOM GPI DMA controller provides DMA capabilities for + peripheral buses such as I2C, UART, and SPI. + +allOf:
Quoted 8 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml line 22
Quoted 6 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +6
-0+ - $ref: "dma-controller.yaml#" + +properties: + compatible: + enum: + - qcom,gpi-dmaShould be SoC specific.
Okay, will add
Quoted 9 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml line 29
Quoted 7 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +7
-0+ + reg: + maxItems: 1 + + interrupts: + description: + Interrupt lines for each GPII instanceGPII or GPI?
Hw uses GPII as "GPI Instance" :) so will update this
Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +11
-0+ maxItems: 13 + + "#dma-cells": + const: 3 + description: > + DMA clients must use the format described in dma.txt, giving a phandle + to the DMA controller plus the following 3 integer cells: + - channel: if set to 0xffffffff, any available channel will be allocated + for the client. Otherwise, the exact channel specified will be used. + - seid: serial id of the client as defined in the SoC documentation. + - client: type of the client as defined in dt-bindings/dma/qcom-gpi.h
Quoted 8 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml line 46
Quoted 6 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +6
-0+ + iommus: + maxItems: 1 + + dma-channels: + maxItems: 1Not an array. Is there a maximum number of channels or 2^32 is valid?
I have not seen any max limit put, but we can be assured that it will not go to 2^32, we can put a reasonable limit ..
Will add maximum :)
Quoted 5 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml line 49
Quoted 3 lines
Documentation/devicetree/bindings/dma/qcom,gpi.yaml new file +3
-0+ + dma-channel-mask: + maxItems: 1So up to 32 channels?
yep!
Signature · 1 line
~Vinod
Vinod Koul
maintainerPATCH v3 2/3 dmaengine: add peripheral configuration
In reply to Vinod KoulSome complex dmaengine controllers have capability to program the peripheral device, so pass on the peripheral configuration as part of dma_slave_config
--- include/linux/dmaengine.h | 91 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+)
include/linux/dmaengine.h +91 -0
@@ -380,6 +380,94 @@ enum dma_slave_buswidth { DMA_SLAVE_BUSWIDTH_64_BYTES = 64, }; +/** +* enum spi_transfer_cmd - spi transfer commands +*/ +enum spi_transfer_cmd { +SPI_TX =1 , +SPI_RX , +SPI_DUPLEX , +}; + +/** +* struct dmaengine_spi_config - spi config for peripheral +* +* @loopback_en: spi loopback enable when set +* @clock_pol: clock polarity +* @data_pol: data polarity +* @pack_en: process tx/rx buffers as packed +* @word_len: spi word length +* @clk_div: source clock divider +* @clk_src: serial clock +* @cmd: spi cmd +* @cs: chip select toggle +*/ +struct dmaengine_spi_config { +u8 loopback_en; +u8 clock_pol; +u8 data_pol; +u8 pack_en; +u8 word_len; +u32 clk_div; +u32 clk_src; +u8 fragmentation; +enum spi_transfer_cmd cmd; +u8 cs; +}; + +enum i2c_op { +I2C_WRITE =1 , +I2C_READ , +}; + +/** +* struct dmaengine_i2c_config - i2c config for peripheral +* +* @pack_enable: process tx/rx buffers as packed +* @cycle_count: clock cycles to be sent +* @high_count: high period of clock +* @low_count: low period of clock +* @clk_div: source clock divider +* @addr: i2c bus address +* @stretch: stretch the clock at eot +* @op: i2c cmd +*/ +struct dmaengine_i2c_config { +u8 pack_enable; +u8 cycle_count; +u8 high_count; +u8 low_count; +u16 clk_div; +u8 addr; +u8 stretch; +enum i2c_op op; +bool multi_msg; +}; + +enum dmaengine_peripheral { +DMAENGINE_PERIPHERAL_SPI =1 , +DMAENGINE_PERIPHERAL_UART =2 , +DMAENGINE_PERIPHERAL_I2C =3 , +DMAENGINE_PERIPHERAL_LAST =DMAENGINE_PERIPHERAL_I2C , +}; + +/** +* struct dmaengine_peripheral_config - peripheral configuration for +* dmaengine peripherals +* +* @peripheral: type of peripheral to DMA to/from +* @set_config: set peripheral config +* @rx_len: receive length for buffer +* @spi: peripheral config for spi +* @i2c: peripheral config for i2c +*/ +struct dmaengine_peripheral_config { +enum dmaengine_peripheral peripheral; +u8 set_config; +u32 rx_len; +struct dmaengine_spi_config spi; +struct dmaengine_i2c_config i2c; +};/** * struct dma_slave_config - dma slave channel runtime config * @direction: whether the data shall go in or out on this slave
@@ -418,6 +506,8 @@ enum dma_slave_buswidth {* @slave_id: Slave requester id. Only valid for slave channels. The dma * slave peripheral will have unique id as dma requester which need to be * pass as slave config. +* @peripheral: peripheral configuration for programming peripheral for +* dmaengine transfer * * This struct is passed in as configuration data to a DMA engine * in order to set up a certain channel for DMA transport at runtime.
@@ -443,6 +533,7 @@ struct dma_slave_config {u32 dst_port_window_size;bool device_fc;unsigned int slave_id; +struct dmaengine_peripheral_config *peripheral; };/**
Signature · 1 line
2.26.2
Re: [PATCH v3 2/3] dmaengine: add peripheral configuration
Quoted 22 lines · Vinod Koul
Some complex dmaengine controllers have capability to program the peripheral device, so pass on the peripheral configuration as part of
dma_slave_configSigned-off-by Vinod Koul <[email protected]>--- include/linux/dmaengine.h | 91 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+)include/linux/dmaengine.h +5
-0@@ -380,6 +380,94 @@ enum dma_slave_buswidth { DMA_SLAVE_BUSWIDTH_64_BYTES = 64, }; +/** +* enum spi_transfer_cmd - spi transfer commands +*/ +enum spi_transfer_cmd { +SPI_TX =1 ,
include/linux/dmaengine.h enum dma_slave_buswidth { · line 397
Quoted 10 lines
include/linux/dmaengine.h +10
-0+SPI_RX , + SPI_DUPLEX, +}; + +/** +* struct dmaengine_spi_config - spi config for peripheral +* +* @loopback_en: spi loopback enable when set +* @clock_pol: clock polarity +* @data_pol: data polarity
*_pol_high ?
include/linux/dmaengine.h enum dma_slave_buswidth { · line 398
Quoted 1 line
include/linux/dmaengine.h +1
-0+* @pack_en: process tx/rx buffers as packed
what does this mean?
include/linux/dmaengine.h enum dma_slave_buswidth { · line 401
Quoted 3 lines
include/linux/dmaengine.h +3
-0+* @word_len: spi word length +* @clk_div: source clock divider +* @clk_src: serial clock
we tend to use common clock framework for clock configuration?
include/linux/dmaengine.h enum dma_slave_buswidth { · line 413
Quoted 12 lines
include/linux/dmaengine.h +12
-0+* @cmd: spi cmd +* @cs: chip select toggle +*/ +struct dmaengine_spi_config { +u8 loopback_en; +u8 clock_pol; +u8 data_pol; +u8 pack_en; +u8 word_len; +u32 clk_div; +u32 clk_src; +u8 fragmentation;
This is not documented and I can not really guess what it is.
include/linux/dmaengine.h enum dma_slave_buswidth { · line 426
Quoted 13 lines
include/linux/dmaengine.h +13
-0+enum spi_transfer_cmd cmd; +u8 cs; +}; + +enum i2c_op { +I2C_WRITE =1 , +I2C_READ , +}; + +/** +* struct dmaengine_i2c_config - i2c config for peripheral +* +* @pack_enable: process tx/rx buffers as packed
Is this the same thing as with the spi?
Quoted 8 lines
include/linux/dmaengine.h +8
-0+* @cycle_count: clock cycles to be sent +* @high_count: high period of clock +* @low_count: low period of clock +* @clk_div: source clock divider +* @addr: i2c bus address +* @stretch: stretch the clock at eot +* @op: i2c cmd +*/
include/linux/dmaengine.h enum dma_slave_buswidth { · line 444
Quoted 10 lines
include/linux/dmaengine.h +10
-0+struct dmaengine_i2c_config { +u8 pack_enable; +u8 cycle_count; +u8 high_count; +u8 low_count; +u16 clk_div; +u8 addr; +u8 stretch; +enum i2c_op op; +bool multi_msg;
Not documented.
Is it indicates multiple-byte read/write or multiple messages?
Quoted 6 lines
include/linux/dmaengine.h +6
-0+}; + +enum dmaengine_peripheral { +DMAENGINE_PERIPHERAL_SPI =1 , +DMAENGINE_PERIPHERAL_UART =2 , +DMAENGINE_PERIPHERAL_I2C =3 ,
include/linux/dmaengine.h enum dma_slave_buswidth { · line 460
Quoted 10 lines
include/linux/dmaengine.h +10
-0+ DMAENGINE_PERIPHERAL_LAST = DMAENGINE_PERIPHERAL_I2C, +}; + +/** +* struct dmaengine_peripheral_config - peripheral configuration for +* dmaengine peripherals +* +* @peripheral: type of peripheral to DMA to/from +* @set_config: set peripheral config +* @rx_len: receive length for buffer
Why is it part of the peripheral config? You get the buffer via prep_slave_sg(). Or is this something else?
The GPI driver uses the rx_len for DMA_MEM_TO_DEV (tx) setup.
include/linux/dmaengine.h enum dma_slave_buswidth { · line 469
Quoted 9 lines
include/linux/dmaengine.h +9
-0+* @spi: peripheral config for spi +* @i2c: peripheral config for i2c +*/ +struct dmaengine_peripheral_config { +enum dmaengine_peripheral peripheral; +u8 set_config; +u32 rx_len; +struct dmaengine_spi_config spi; +struct dmaengine_i2c_config i2c;
I know that you want this to be as generic as much as it is possible, but do we really want to?
GPIv2 will also handle I2S peripheral, other vendor's similar solution would require different sets of parameters unique to their IPs?
How we are going to handle similar setups for DMA which is used for networking, SPI/I2C/I2S/NAND/display/capture, etc?
Imho these settings are really part of the peripheral's domain and not the DMA. It is just a small detail that instead of direct register writes, your setup is using the DMA descriptors to write.
It is similar to what I use as metadata (part of the descriptor belongs and owned by the client driver).
I think it would be better to have:
enum dmaengine_peripheral {
DMAENGINE_PERIPHERAL_GPI_SPI = 1,
DMAENGINE_PERIPHERAL_GPI_UART,
DMAENGINE_PERIPHERAL_GPI_I2C,
DMAENGINE_PERIPHERAL_XYZ_SPI,
DMAENGINE_PERIPHERAL_XYZ_AASRC,
DMAENGINE_PERIPHERAL_ABC_CAM,
...
DMAENGINE_PERIPHERAL_LAST,
};enum dmaengine_peripheral peripheral_type;
void *peripheral_config;
and that's it. The set_config is specific to GPI.
It can be debated where the structs should be defined, in the generic dmaengine.h or in include/linux/dma/ as controller specific (gpi_peripheral.h) or a generic one, like dmaengine_peripheral.h
The SPI/I2C/UART client of yours would pass the GPI specific struct as in any case it has to know what is the DMA it is serviced by.
Quoted 15 lines
include/linux/dmaengine.h +3
-0+};/** * struct dma_slave_config - dma slave channel runtime config * @direction: whether the data shall go in or out on this slave @@ -418,6 +506,8 @@ enum dma_slave_buswidth {* @slave_id: Slave requester id. Only valid for slave channels. The dma * slave peripheral will have unique id as dma requester which need to be * pass as slave config. +* @peripheral: peripheral configuration for programming peripheral for +* dmaengine transfer * * This struct is passed in as configuration data to a DMA engine * in order to set up a certain channel for DMA transport at runtime.
include/linux/dmaengine.h struct dma_slave_config { · line 539
Quoted 7 lines
include/linux/dmaengine.h +1
-0@@ -443,6 +533,7 @@ struct dma_slave_config {u32 dst_port_window_size;bool device_fc;unsigned int slave_id; +struct dmaengine_peripheral_config *peripheral; };/**
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Re: [PATCH v3 2/3] dmaengine: add peripheral configuration
Hi Vinod,
Quoted 28 lines · Peter Ujfalusi
I know that you want this to be as generic as much as it is possible, but do we really want to?
GPIv2 will also handle I2S peripheral, other vendor's similar solution would require different sets of parameters unique to their IPs?How we are going to handle similar setups for DMA which is used for networking, SPI/I2C/I2S/NAND/display/capture, etc?
Imho these settings are really part of the peripheral's domain and not the DMA. It is just a small detail that instead of direct register writes, your setup is using the DMA descriptors to write.
It is similar to what I use as metadata (part of the descriptor belongs and owned by the client driver).I think it would be better to have:
enum dmaengine_peripheral { DMAENGINE_PERIPHERAL_GPI_SPI = 1, DMAENGINE_PERIPHERAL_GPI_UART, DMAENGINE_PERIPHERAL_GPI_I2C, DMAENGINE_PERIPHERAL_XYZ_SPI, DMAENGINE_PERIPHERAL_XYZ_AASRC, DMAENGINE_PERIPHERAL_ABC_CAM, ... DMAENGINE_PERIPHERAL_LAST, };
Quoted 2 lines
enum
dmaengine_peripheralperipheral_type;
void*peripheral_config;
TI have an AASRC (Audio Asynchronous Sample Rate Converted) in j721e and to configure the DMA side (AASRC_PDMA) we need special configuration parameters passed from the AASRC driver to the DMA channel. This peripheral config extension would be perfect for it, but the parameters I would need is not generic in any ways.
The other thing which might need to be considered is to have src/dst pair of this. When we do DMA_DEV_TO_DEV, it would help to figure out which side we should apply which config (if you have the same type of device on both ends with different config?).
Quoted 28 lines
and that's it. The
set_configis specific to GPI.
It can be debated where the structs should be defined, in the genericdmaengine.hor ininclude/linux/dma/as controller specific (gpi_peripheral.h) or a generic one, likedmaengine_peripheral.hThe SPI/I2C/UART client of yours would pass the GPI specific struct as in any case it has to know what is the DMA it is serviced by.
Quoted 20 lines
include/linux/dmaengine.h +4
-0+};/** * struct dma_slave_config - dma slave channel runtime config * @direction: whether the data shall go in or out on this slave @@ -418,6 +506,8 @@ enum dma_slave_buswidth {* @slave_id: Slave requester id. Only valid for slave channels. The dma * slave peripheral will have unique id as dma requester which need to be * pass as slave config. +* @peripheral: peripheral configuration for programming peripheral for +* dmaengine transfer * * This struct is passed in as configuration data to a DMA engine * in order to set up a certain channel for DMA transport at runtime. @@ -443,6 +533,7 @@ struct dma_slave_config {u32 dst_port_window_size;bool device_fc;unsigned int slave_id; +struct dmaengine_peripheral_config *peripheral; };
Quoted 8 lines
Review struct dma_slave_config { · line 539
Quoted 2 lines
(quoted diff) +0
-0/**- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul
maintainerRe: [PATCH v3 2/3] dmaengine: add peripheral configuration
In reply to Peter UjfalusiHi Peter,
Quoted 4 lines · Peter Ujfalusi
Quoted 4 lines
+ * @spi: peripheral config for spi
+ * @i2c: peripheral config for i2c
+ */
+structdmaengine_peripheral_config{
Quoted 8 lines
include/linux/dmaengine.h enum dma_slave_buswidth { · line 469
Quoted 5 lines
include/linux/dmaengine.h +5
-0+enum dmaengine_peripheral peripheral; +u8 set_config; +u32 rx_len; +struct dmaengine_spi_config spi; +struct dmaengine_i2c_config i2c;I know that you want this to be as generic as much as it is possible, but do we really want to?
That is really a good question ;-)
Quoted 1 line
GPIv2 will also handle I2S peripheral, other vendor's similar solution
Not I2S, but yes but additional peripherals is always a question
Quoted 28 lines
would require different sets of parameters unique to their IPs?
How we are going to handle similar setups for DMA which is used for networking, SPI/I2C/I2S/NAND/display/capture, etc?
Imho these settings are really part of the peripheral's domain and not the DMA. It is just a small detail that instead of direct register writes, your setup is using the DMA descriptors to write.
It is similar to what I use as metadata (part of the descriptor belongs and owned by the client driver).I think it would be better to have:
enum dmaengine_peripheral { DMAENGINE_PERIPHERAL_GPI_SPI = 1, DMAENGINE_PERIPHERAL_GPI_UART, DMAENGINE_PERIPHERAL_GPI_I2C, DMAENGINE_PERIPHERAL_XYZ_SPI, DMAENGINE_PERIPHERAL_XYZ_AASRC, DMAENGINE_PERIPHERAL_ABC_CAM, ... DMAENGINE_PERIPHERAL_LAST, };enum
dmaengine_peripheralperipheral_type;
void*peripheral_config;
Quoted 7 lines
and that's it. The
set_configis specific to GPI.
It can be debated where the structs should be defined, in the genericdmaengine.hor ininclude/linux/dma/as controller specific (gpi_peripheral.h) or a generic one, likedmaengine_peripheral.hThe SPI/I2C/UART client of yours would pass the GPI specific struct as in any case it has to know what is the DMA it is serviced by.
If we want to take that approach, I can actually move the whole logic of creating the specific TREs from DMA to clients and they pass on TRE values and driver adds to ring after appending DMA TREs
Question is how should this interface look like? reuse metadata or add a new API which sets the txn specific data (void pointer and size) to the txn..
Signature · 1 line
~Vinod
Re: [PATCH v3 2/3] dmaengine: add peripheral configuration
Hi Vinod,
Quoted 17 lines · Vinod Koul
Hi Peter,
Quoted 4 lines · Peter Ujfalusi
Quoted 4 lines
+ * @spi: peripheral config for spi
+ * @i2c: peripheral config for i2c
+ */
+structdmaengine_peripheral_config{Quoted 8 lines
include/linux/dmaengine.h enum dma_slave_buswidth { · line 469
Quoted 5 lines
include/linux/dmaengine.h +5
-0+enum dmaengine_peripheral peripheral; +u8 set_config; +u32 rx_len; +struct dmaengine_spi_config spi; +struct dmaengine_i2c_config i2c;I know that you want this to be as generic as much as it is possible, but do we really want to?
Quoted 5 lines
That is really a good question ;-)
Quoted 1 line
GPIv2 will also handle I2S peripheral, other vendor's similar solution
Not I2S, but yes but additional peripherals is always a question
Never underestimate the 'creativity'.
Quoted 33 lines
Quoted 33 lines
would require different sets of parameters unique to their IPs?
How we are going to handle similar setups for DMA which is used for networking, SPI/I2C/I2S/NAND/display/capture, etc?
Imho these settings are really part of the peripheral's domain and not the DMA. It is just a small detail that instead of direct register writes, your setup is using the DMA descriptors to write.
It is similar to what I use as metadata (part of the descriptor belongs and owned by the client driver).I think it would be better to have:
enum dmaengine_peripheral { DMAENGINE_PERIPHERAL_GPI_SPI = 1, DMAENGINE_PERIPHERAL_GPI_UART, DMAENGINE_PERIPHERAL_GPI_I2C, DMAENGINE_PERIPHERAL_XYZ_SPI, DMAENGINE_PERIPHERAL_XYZ_AASRC, DMAENGINE_PERIPHERAL_ABC_CAM, ... DMAENGINE_PERIPHERAL_LAST, };enum
dmaengine_peripheralperipheral_type;
void*peripheral_config;and that's it. The
set_configis specific to GPI.
It can be debated where the structs should be defined, in the genericdmaengine.hor ininclude/linux/dma/as controller specific (gpi_peripheral.h) or a generic one, likedmaengine_peripheral.h
Quoted 6 lines
Quoted 2 lines
The SPI/I2C/UART client of yours would pass the GPI specific struct as in any case it has to know what is the DMA it is serviced by.
If we want to take that approach, I can actually move the whole logic of creating the specific TREs from DMA to clients and they pass on TRE values and driver adds to ring after appending DMA TREs
The drawback is that you are tying the driver to a specific DMA with directly giving the TREs. If the TRE (or other method) is used by a newer device you need to work on both sides.
Quoted 3 lines
Question is how should this interface look like? reuse metadata or add a new API which sets the txn specific data (void pointer and size) to the txn..
It depends which is best for the use case.
I see the metadata useful when you need to send different metadata/configuration with each transfer.
It can be also useful when you need it seldom, but for your use case and setup the dma_slave_config extended with
enum dmaengine_peripheral peripheral_type;
void *peripheral_config;
would be a bit more explicit.
I would then deal with the peripheral config in this way:
when the DMA driver's device_config is called, I would take the parameters and set a flag that the config needs to be processed as it has changed.
In the next prep_slave_sg() then I would prepare the TREs with the config and clear the flag that the next transfer does not need the configuration anymore.
In this way each dmaengine_slave_config() will trigger at the next prep_slave_sg time configuration update for the peripheral to be included in the TREs.
The set_config would be internal to the DMA driver, clients just need to update the configuration when they need to and everything is taken care of.
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul
maintainerRe: [PATCH v3 2/3] dmaengine: add peripheral configuration
Hi Peter,
Quoted 19 lines · Peter Ujfalusi
It depends which is best for the use case.
I see the metadata useful when you need to send different metadata/configuration with each transfer.
It can be also useful when you need it seldom, but for your use case and setup thedma_slave_configextended withenum
dmaengine_peripheralperipheral_type;
void*peripheral_config;would be a bit more explicit.
I would then deal with the peripheral config in this way:
when the DMA driver'sdevice_configis called, I would take the parameters and set a flag that the config needs to be processed as it has changed.
In the nextprep_slave_sg()then I would prepare the TREs with the config and clear the flag that the next transfer does not need the configuration anymore.
Quoted 5 lines
In this way each
dmaengine_slave_config()will trigger at the nextprep_slave_sgtime configuration update for the peripheral to be included in the TREs.
Theset_configwould be internal to the DMA driver, clients just need to update the configuration when they need to and everything is taken care of.
Ok I am going to drop the dmaengine_peripheral and make peripheral_config as as you proposed.
So will add following to dma_slave_config:
void *peripheral_config;
Driver can define the config they would like and use.
We can eventually look at common implementations and try to unify once we have more users
Signature · 1 line
~Vinod
Re: [PATCH v3 2/3] dmaengine: add peripheral configuration
Hi Vinod,
Quoted 32 lines · Vinod Koul
Hi Peter,
Quoted 19 lines · Peter Ujfalusi
It depends which is best for the use case.
I see the metadata useful when you need to send different metadata/configuration with each transfer.
It can be also useful when you need it seldom, but for your use case and setup thedma_slave_configextended withenum
dmaengine_peripheralperipheral_type;
void*peripheral_config;would be a bit more explicit.
I would then deal with the peripheral config in this way:
when the DMA driver'sdevice_configis called, I would take the parameters and set a flag that the config needs to be processed as it has changed.
In the nextprep_slave_sg()then I would prepare the TREs with the config and clear the flag that the next transfer does not need the configuration anymore.Quoted 5 lines
In this way each
dmaengine_slave_config()will trigger at the nextprep_slave_sgtime configuration update for the peripheral to be included in the TREs.
Theset_configwould be internal to the DMA driver, clients just need to update the configuration when they need to and everything is taken care of.Ok I am going to drop the
dmaengine_peripheraland makeperipheral_configas as you proposed.
Quoted 7 lines
So will add following to
dma_slave_config:void *peripheral_config;Driver can define the config they would like and use.
We can eventually look at common implementations and try to unify once we have more users
Sound good to me!
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul
maintainerPATCH v3 3/3 dmaengine: qcom: Add GPI dma driver
In reply to Vinod KoulThis controller provides DMAengine capabilities for a variety of peripheral buses such as I2C, UART, and SPI. By using GPI dmaengine driver, bus drivers can use a standardize interface that is protocol independent to transfer data between memory and peripheral.
--- drivers/dma/qcom/Kconfig | 12 + drivers/dma/qcom/Makefile | 1 + drivers/dma/qcom/gpi.c | 2295 +++++++++++++++++++++++++++++++++++++ 3 files changed, 2308 insertions(+) create mode 100644 drivers/dma/qcom/gpi.c
drivers/dma/qcom/Kconfig +12 -0
@@ -8,6 +8,18 @@ config QCOM_BAM_DMA Enable support for the QCOM BAM DMA controller. This controller provides DMA capabilities for a variety of on-chip devices. +config QCOM_GPI_DMA + tristate "Qualcomm Technologies GPI DMA support" + depends on ARCH_QCOM + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Enable support for the QCOM GPI DMA controller. This controller + provides DMA capabilities for a variety of peripheral buses such + as I2C, UART, and SPI. By using GPI dmaengine driver, bus drivers + can use a standardize interface that is protocol independent to + transfer data between DDR and peripheral. + config QCOM_HIDMA_MGMT tristate "Qualcomm Technologies HIDMA Management support" select DMA_ENGINE
drivers/dma/qcom/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o +obj-$(CONFIG_QCOM_GPI_DMA) += gpi.o obj-$(CONFIG_QCOM_HIDMA_MGMT) += hdma_mgmt.o hdma_mgmt-objs := hidma_mgmt.o hidma_mgmt_sys.o obj-$(CONFIG_QCOM_HIDMA) += hdma.o
drivers/dma/qcom/gpi.c new file +2295 -0
2,295 lines not on this page · raw message
Signature · 1 line
2.26.2