Skip to contentSkip to conversation

New driver for the Loongson LS2X APB DMA Controller

PATCH Applied Binbin Zhou 2 participants 4 messages Dec 18, 2023 – Dec 21, 2023

Subsystems (4)
lore
Share & tools
lore

Binbin Zhou

author maintainer
#0 lore raw

v6 cover New driver for the Loongson LS2X APB DMA Controller

Hi all:

This patchset introduces you to the LS2X apbdma controller.

The Loongson LS2X APB DMA controller is available on Loongson-2K chips. It is a single-channel, configurable DMA controller IP core based on the AXI bus, whose main function is to integrate DMA functionality on a chip dedicated to carrying data between memory and peripherals in APB bus (e.g. nand).

Thanks.

----
V6:
patch(2/2):
- Use GFP_NOWAIT as the flag for allocating descriptor memory;
- Drop superfluous init in ls2x_dma_write_cmd().

Thanks to Vinod for the suggestions.

Link to V5:
https://lore.kernel.org/dmaengine/[email protected]/

V5:
patch(2/2):
- Rebase on dmaengine/next;
- Annotate struct ls2x_dma_sg with __counted_by;
- .remove()->.remove_new()
- Drop duplicate assignments in ls2x_dma_chan_init().

Link to V4:
https://lore.kernel.org/all/[email protected]/

V4:
patch(2/2)
- Drop linux/of_device.h;
- Meaningful parameter name for ls2x_dma_fill_desc(): i->sg_index;
- Check the slave config and reject invalid configurations;
- Update data width handle;
- Use generic xlate: of_dma_xlate_by_chan_id().

Link to V3:
https://lore.kernel.org/dmaengine/[email protected]/

V3:
patch(1/2)
- Add clocks property;
- Drop dma-channels property, for we are single-channel dmac.
patch(2/2)
- Add clk support.

Link to V2:
https://lore.kernel.org/dmaengine/[email protected]/

V2:
patch(1/2)
- Minor changes from Conor;
- Add Reviewed-by tag.
patch(2/2)
- Fix build errors from [email protected].

Link to V1:
https://lore.kernel.org/dmaengine/[email protected]/

Binbin Zhou (2):
dt-bindings: dmaengine: Add Loongson LS2X APB DMA controller
dmaengine: ls2x-apb: new driver for the Loongson LS2X APB DMA
controller

 .../bindings/dma/loongson,ls2x-apbdma.yaml    |  62 ++
 MAINTAINERS                                   |   7 +
 drivers/dma/Kconfig                           |  14 +
 drivers/dma/Makefile                          |   1 +
 drivers/dma/ls2x-apb-dma.c                    | 705 ++++++++++++++++++
 5 files changed, 789 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml
 create mode 100644 drivers/dma/ls2x-apb-dma.c
Signature · 1 line
2.39.3
author maintainer
#1 lore raw

PATCH v6 1/2 dt-bindings: dmaengine: Add Loongson LS2X APB DMA controller

Add Loongson LS2X APB DMA controller binding with DT schema format using json-schema.

---
 .../bindings/dma/loongson,ls2x-apbdma.yaml    | 62 +++++++++++++++++++
 MAINTAINERS                                   |  6 ++
 2 files changed, 68 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml
Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml new file +62 -0
new file mode 100644
index 000000000000..6a1b49a49a64
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/loongson,ls2x-apbdma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson LS2X APB DMA controller
+
+description:
+  The Loongson LS2X APB DMA controller is used for transferring data
+  between system memory and the peripherals on the APB bus.
+
+maintainers:
+  - Binbin Zhou <[email protected]>
+
+allOf:
+  - $ref: dma-controller.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: loongson,ls2k1000-apbdma
+      - items:
+          - const: loongson,ls2k0500-apbdma
+          - const: loongson,ls2k1000-apbdma
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  '#dma-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - '#dma-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/loongson,ls2k-clk.h>
+
+    dma-controller@1fe00c00 {
+        compatible = "loongson,ls2k1000-apbdma";
+        reg = <0x1fe00c00 0x8>;
+        interrupt-parent = <&liointc1>;
+        interrupts = <12 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&clk LOONGSON2_APB_CLK>;
+        #dma-cells = <1>;
+    };
+
+...
MAINTAINERS +6 -0
index 788be9ab5b73..55e1be35f9dc 100644
@@ -12504,6 +12504,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
 F:	drivers/gpio/gpio-loongson-64bit.c
 
+LOONGSON LS2X APB DMA DRIVER
+M:	Binbin Zhou <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml
+
 LOONGSON LS2X I2C DRIVER
 M:	Binbin Zhou <[email protected]>
 L:	[email protected]
Signature · 1 line
2.39.3
author maintainer
#2 lore raw

PATCH v6 2/2 dmaengine: ls2x-apb: New driver for the Loongson LS2X APB DMA controller

In reply to Binbin Zhou

The Loongson LS2X APB DMA controller is available on Loongson-2K chips.

It is a single-channel, configurable DMA controller IP core based on the AXI bus, whose main function is to integrate DMA functionality on a chip dedicated to carrying data between memory and peripherals in APB bus (e.g. nand).

---
 MAINTAINERS                |   1 +
 drivers/dma/Kconfig        |  14 +
 drivers/dma/Makefile       |   1 +
 drivers/dma/ls2x-apb-dma.c | 705 +++++++++++++++++++++++++++++++++++++
 4 files changed, 721 insertions(+)
 create mode 100644 drivers/dma/ls2x-apb-dma.c
MAINTAINERS +1 -0
index 55e1be35f9dc..a88cb8266f29 100644
@@ -12509,6 +12509,7 @@ M:	Binbin Zhou <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml
+F:	drivers/dma/ls2x-apb-dma.c
 
 LOONGSON LS2X I2C DRIVER
 M:	Binbin Zhou <[email protected]>
drivers/dma/Kconfig +14 -0
index 70ba506dabab..e928f2ca0f1e 100644
@@ -378,6 +378,20 @@ config LPC18XX_DMAMUX
 	  Enable support for DMA on NXP LPC18xx/43xx platforms
 	  with PL080 and multiplexed DMA request lines.
 
+config LS2X_APB_DMA
+	tristate "Loongson LS2X APB DMA support"
+	depends on LOONGARCH || COMPILE_TEST
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	help
+	  Support for the Loongson LS2X APB DMA controller driver. The
+	  DMA controller is having single DMA channel which can be
+	  configured for different peripherals like audio, nand, sdio
+	  etc which is in APB bus.
+
+	  This DMA controller transfers data from memory to peripheral fifo.
+	  It does not support memory to memory data transfer.
+
 config MCF_EDMA
 	tristate "Freescale eDMA engine support, ColdFire mcf5441x SoCs"
 	depends on M5441x || COMPILE_TEST
drivers/dma/Makefile +1 -0
index 83553a97a010..dfd40d14e408 100644
@@ -48,6 +48,7 @@ obj-$(CONFIG_INTEL_IOATDMA) += ioat/
 obj-y += idxd/
 obj-$(CONFIG_K3_DMA) += k3dma.o
 obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o
+obj-$(CONFIG_LS2X_APB_DMA) += ls2x-apb-dma.o
 obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o
 obj-$(CONFIG_MILBEAUT_XDMAC) += milbeaut-xdmac.o
 obj-$(CONFIG_MMP_PDMA) += mmp_pdma.o
drivers/dma/ls2x-apb-dma.c new file +705 -0

705 lines not on this page · raw message

Signature · 1 line
2.39.3
maintainer Applied
#3 lore raw
In reply to Binbin Zhou
Quoted 9 lines · Binbin Zhou

This patchset introduces you to the LS2X apbdma controller.

The Loongson LS2X APB DMA controller is available on Loongson-2K chips. It is a single-channel, configurable DMA controller IP core based on the AXI bus, whose main function is to integrate DMA functionality on a chip dedicated to carrying data between memory and peripherals in APB bus (e.g. nand).

[...]

Applied, thanks!

[1/2] dt-bindings: dmaengine: Add Loongson LS2X APB DMA controller

      commit: 3b3b5339cdc67e98817d08431f8443b08880084f
[2/2] dmaengine: ls2x-apb: New driver for the Loongson LS2X APB DMA controller
      commit: 71e7d3cb6e55ae2eadcdb178f9243dc18499d369

Best regards,

Signature · 1 line
~Vinod