dmaengine: Add Loongson Multi-Channel DMA controller support
Subsystems (5)
Binbin Zhou
maintainercover dmaengine: Add Loongson Multi-Channel DMA controller support
Hi all:
This patchset introduces the Loongson multi-channel DMA controller, which is present in the Loongson-2K0300 and Loongson-2K3000 processors.
It is a multi-channel controller that enables data transfers from memory to memory, device to memory, and memory to device, as well as channel prioritization configurable through the channel configuration registers.
Additionally, since multiple distinct types of DMA controllers exist on the Loongson platform, I have attempted to consolidate all Loongson DMA drivers into a new directory named Loongson for easier management.
Thanks.
Binbin
Binbin Zhou (3):
dmaengine: loongson: New directory for Loongson DMA controllers
drivers
dt-bindings: dmaengine: Add Loongson Multi-Channel DMA controller
dmaengine: loongson: New driver for the Loongson Multi-Channel DMA
controller
.../bindings/dma/loongson,ls2k0300-dma.yaml | 78 ++
MAINTAINERS | 6 +-
drivers/dma/Kconfig | 25 +-
drivers/dma/Makefile | 3 +-
drivers/dma/loongson/Kconfig | 38 +
drivers/dma/loongson/Makefile | 4 +
.../dma/{ => loongson}/loongson1-apb-dma.c | 4 +-
drivers/dma/loongson/loongson2-apb-dma-v2.c | 759 ++++++++++++++++++
.../dma/{ => loongson}/loongson2-apb-dma.c | 4 +-
9 files changed, 890 insertions(+), 31 deletions(-)
create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml
create mode 100644 drivers/dma/loongson/Kconfig
create mode 100644 drivers/dma/loongson/Makefile
rename drivers/dma/{ => loongson}/loongson1-apb-dma.c (99%)
create mode 100644 drivers/dma/loongson/loongson2-apb-dma-v2.c
rename drivers/dma/{ => loongson}/loongson2-apb-dma.c (99%)base-commit: 3c8a86ed002ab8fb287ee4ec92f0fd6ac5b291d2
Signature · 1 line
2.47.3
Binbin Zhou
maintainerPATCH 1/3 dmaengine: loongson: New directory for Loongson DMA controllers drivers
Gather the Loongson DMA controllers under drivers/dma/loongson/
---
MAINTAINERS | 2 +-
drivers/dma/Kconfig | 25 ++---------------
drivers/dma/Makefile | 3 +-
drivers/dma/loongson/Kconfig | 28 +++++++++++++++++++
drivers/dma/loongson/Makefile | 3 ++
.../dma/{ => loongson}/loongson1-apb-dma.c | 4 +--
.../dma/{ => loongson}/loongson2-apb-dma.c | 4 +--
7 files changed, 39 insertions(+), 30 deletions(-)
create mode 100644 drivers/dma/loongson/Kconfig
create mode 100644 drivers/dma/loongson/Makefile
rename drivers/dma/{ => loongson}/loongson1-apb-dma.c (99%)
rename drivers/dma/{ => loongson}/loongson2-apb-dma.c (99%)MAINTAINERS +1 -1
@@ -14776,7 +14776,7 @@ M: Binbin Zhou <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml -F: drivers/dma/loongson2-apb-dma.c +F: drivers/dma/loongson/loongson2-apb-dma.c LOONGSON LS2X I2C DRIVER M: Binbin Zhou <[email protected]>
drivers/dma/Kconfig +2 -23
@@ -376,29 +376,6 @@ config K3_DMA Support the DMA engine for Hisilicon K3 platform devices. -config LOONGSON1_APB_DMA - tristate "Loongson1 APB DMA support" - depends on MACH_LOONGSON32 || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - This selects support for the APB DMA controller in Loongson1 SoCs, - which is required by Loongson1 NAND and audio support. - -config LOONGSON2_APB_DMA - tristate "Loongson2 APB DMA support" - depends on LOONGARCH || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - Support for the Loongson2 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 LPC18XX_DMAMUX bool "NXP LPC18xx/43xx DMA MUX for PL080" depends on ARCH_LPC18XX || COMPILE_TEST
@@ -774,6 +751,8 @@ source "drivers/dma/fsl-dpaa2-qdma/Kconfig" source "drivers/dma/lgm/Kconfig" +source "drivers/dma/loongson/Kconfig" + source "drivers/dma/stm32/Kconfig" # clients
drivers/dma/Makefile +1 -2
@@ -49,8 +49,6 @@ obj-$(CONFIG_INTEL_IDMA64) += idma64.o obj-$(CONFIG_INTEL_IOATDMA) += ioat/ obj-y += idxd/ obj-$(CONFIG_K3_DMA) += k3dma.o -obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o -obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o obj-$(CONFIG_LPC32XX_DMAMUX) += lpc32xx-dmamux.o obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o
@@ -88,6 +86,7 @@ obj-$(CONFIG_INTEL_LDMA) += lgm/ obj-y += amd/ obj-y += mediatek/ +obj-y += loongson/ obj-y += qcom/ obj-y += stm32/ obj-y += ti/
drivers/dma/loongson/Kconfig new file +28 -0
@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Loongson DMA controllers drivers +# +if MACH_LOONGSON32 || MACH_LOONGSON64 || COMPILE_TEST + +config LOONGSON1_APB_DMA + tristate "Loongson1 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + This selects support for the APB DMA controller in Loongson1 SoCs, + which is required by Loongson1 NAND and audio support. + +config LOONGSON2_APB_DMA + tristate "Loongson2 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Loongson2 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. + +endif
drivers/dma/loongson/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o +obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o
drivers/dma/loongson/loongson1-apb-dma.c renamed from drivers/dma/loongson1-apb-dma.c +2 -2
@@ -16,8 +16,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Loongson-1 DMA Control Register */ #define LS1X_DMA_CTRL 0x0
drivers/dma/loongson/loongson2-apb-dma.c renamed from drivers/dma/loongson2-apb-dma.c +2 -2
@@ -17,8 +17,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Global Configuration Register */ #define LDMA_ORDER_ERG 0x0
Signature · 1 line
2.47.3
Keguang Zhang
maintainerRe: [PATCH 1/3] dmaengine: loongson: New directory for Loongson DMA controllers drivers
Quoted 4 lines · Binbin Zhou
Gather the Loongson DMA controllers under
drivers/dma/loongson/Signed-off-by Binbin Zhou <[email protected]>
Quoted 12 lines
---
MAINTAINERS | 2 +-
drivers/dma/Kconfig | 25 ++---------------
drivers/dma/Makefile | 3 +-
drivers/dma/loongson/Kconfig | 28 +++++++++++++++++++
drivers/dma/loongson/Makefile | 3 ++
.../dma/{ => loongson}/loongson1-apb-dma.c | 4 +--
.../dma/{ => loongson}/loongson2-apb-dma.c | 4 +--
7 files changed, 39 insertions(+), 30 deletions(-)
create mode 100644 drivers/dma/loongson/Kconfig
create mode 100644 drivers/dma/loongson/Makefile
rename drivers/dma/{ => loongson}/loongson1-apb-dma.c (99%)The file loongson1-apb-dma.c was moved to drivers/dma/loongson/, but the MAINTAINERS entry still refers to the old path.
Quoted 161 lines
rename drivers/dma/{ => loongson}/loongson2-apb-dma.c (99%)MAINTAINERS +1
-1@@ -14776,7 +14776,7 @@ M: Binbin Zhou <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml -F: drivers/dma/loongson2-apb-dma.c +F: drivers/dma/loongson/loongson2-apb-dma.c LOONGSON LS2X I2C DRIVER M: Binbin Zhou <[email protected]>drivers/dma/Kconfig +2
-23@@ -376,29 +376,6 @@ config K3_DMA Support the DMA engine for Hisilicon K3 platform devices. -config LOONGSON1_APB_DMA - tristate "Loongson1 APB DMA support" - depends on MACH_LOONGSON32 || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - This selects support for the APB DMA controller in Loongson1 SoCs, - which is required by Loongson1 NAND and audio support. - -config LOONGSON2_APB_DMA - tristate "Loongson2 APB DMA support" - depends on LOONGARCH || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - Support for the Loongson2 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 LPC18XX_DMAMUX bool "NXP LPC18xx/43xx DMA MUX for PL080" depends on ARCH_LPC18XX || COMPILE_TEST@@ -774,6 +751,8 @@ source "drivers/dma/fsl-dpaa2-qdma/Kconfig" source "drivers/dma/lgm/Kconfig" +source "drivers/dma/loongson/Kconfig" + source "drivers/dma/stm32/Kconfig" # clientsdrivers/dma/Makefile +1
-2@@ -49,8 +49,6 @@ obj-$(CONFIG_INTEL_IDMA64) += idma64.o obj-$(CONFIG_INTEL_IOATDMA) += ioat/ obj-y += idxd/ obj-$(CONFIG_K3_DMA) += k3dma.o -obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o -obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o obj-$(CONFIG_LPC32XX_DMAMUX) += lpc32xx-dmamux.o obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o@@ -88,6 +86,7 @@ obj-$(CONFIG_INTEL_LDMA) += lgm/ obj-y += amd/ obj-y += mediatek/ +obj-y += loongson/ obj-y += qcom/ obj-y += stm32/ obj-y += ti/drivers/dma/loongson/Kconfig new file +28
-0@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Loongson DMA controllers drivers +# +if MACH_LOONGSON32 || MACH_LOONGSON64 || COMPILE_TEST + +config LOONGSON1_APB_DMA + tristate "Loongson1 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + This selects support for the APB DMA controller in Loongson1 SoCs, + which is required by Loongson1 NAND and audio support. + +config LOONGSON2_APB_DMA + tristate "Loongson2 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Loongson2 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. + +endifdrivers/dma/loongson/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o +obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.odrivers/dma/loongson/loongson1-apb-dma.c renamed from drivers/dma/loongson1-apb-dma.c +2
-2@@ -16,8 +16,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Loongson-1 DMA Control Register */ #define LS1X_DMA_CTRL 0x0drivers/dma/loongson/loongson2-apb-dma.c renamed from drivers/dma/loongson2-apb-dma.c +2
-3@@ -17,8 +17,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Global Configuration Register */ #define LDMA_ORDER_ERG 0x0 --2.47.3
Signature · 3 lines
Best regards, Keguang Zhang
Re: [PATCH 1/3] dmaengine: loongson: New directory for Loongson DMA controllers drivers
Hi Keguang:
Quoted 19 lines · Keguang Zhang
Quoted 4 lines · Binbin Zhou
Gather the Loongson DMA controllers under
drivers/dma/loongson/Signed-off-by Binbin Zhou <[email protected]>Quoted 12 lines
--- MAINTAINERS | 2 +- drivers/dma/Kconfig | 25 ++--------------- drivers/dma/Makefile | 3 +- drivers/dma/loongson/Kconfig | 28 +++++++++++++++++++ drivers/dma/loongson/Makefile | 3 ++ .../dma/{ => loongson}/loongson1-apb-dma.c | 4 +-- .../dma/{ => loongson}/loongson2-apb-dma.c | 4 +-- 7 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 drivers/dma/loongson/Kconfig create mode 100644 drivers/dma/loongson/Makefile rename drivers/dma/{ => loongson}/loongson1-apb-dma.c (99%)
Quoted 2 lines
The file
loongson1-apb-dma.cwas moved todrivers/dma/loongson/, but theMAINTAINERSentry still refers to the old path.
In the MAINTAINERS, the loongson1 driver filename is matched using the wildcard *. This move operation appears to have no effect.
As follows:
MIPS/LOONGSON1 ARCHITECTURE
M: Keguang Zhang <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/*/loongson,ls1*.yaml F: arch/mips/boot/dts/loongson/loongson1* F: arch/mips/configs/loongson1_defconfig F: arch/mips/loongson32/ F: drivers/*/*loongson1* F: drivers/mtd/nand/raw/loongson-nand-controller.c F: drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c F: sound/soc/loongson/loongson1_ac97.c
Quoted 168 lines
Quoted 160 lines
rename drivers/dma/{ => loongson}/loongson2-apb-dma.c (99%)MAINTAINERS +1
-1@@ -14776,7 +14776,7 @@ M: Binbin Zhou <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml -F: drivers/dma/loongson2-apb-dma.c +F: drivers/dma/loongson/loongson2-apb-dma.c LOONGSON LS2X I2C DRIVER M: Binbin Zhou <[email protected]>drivers/dma/Kconfig +2
-23@@ -376,29 +376,6 @@ config K3_DMA Support the DMA engine for Hisilicon K3 platform devices. -config LOONGSON1_APB_DMA - tristate "Loongson1 APB DMA support" - depends on MACH_LOONGSON32 || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - This selects support for the APB DMA controller in Loongson1 SoCs, - which is required by Loongson1 NAND and audio support. - -config LOONGSON2_APB_DMA - tristate "Loongson2 APB DMA support" - depends on LOONGARCH || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - Support for the Loongson2 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 LPC18XX_DMAMUX bool "NXP LPC18xx/43xx DMA MUX for PL080" depends on ARCH_LPC18XX || COMPILE_TEST@@ -774,6 +751,8 @@ source "drivers/dma/fsl-dpaa2-qdma/Kconfig" source "drivers/dma/lgm/Kconfig" +source "drivers/dma/loongson/Kconfig" + source "drivers/dma/stm32/Kconfig" # clientsdrivers/dma/Makefile +1
-2@@ -49,8 +49,6 @@ obj-$(CONFIG_INTEL_IDMA64) += idma64.o obj-$(CONFIG_INTEL_IOATDMA) += ioat/ obj-y += idxd/ obj-$(CONFIG_K3_DMA) += k3dma.o -obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o -obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o obj-$(CONFIG_LPC32XX_DMAMUX) += lpc32xx-dmamux.o obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o@@ -88,6 +86,7 @@ obj-$(CONFIG_INTEL_LDMA) += lgm/ obj-y += amd/ obj-y += mediatek/ +obj-y += loongson/ obj-y += qcom/ obj-y += stm32/ obj-y += ti/drivers/dma/loongson/Kconfig new file +28
-0@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Loongson DMA controllers drivers +# +if MACH_LOONGSON32 || MACH_LOONGSON64 || COMPILE_TEST + +config LOONGSON1_APB_DMA + tristate "Loongson1 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + This selects support for the APB DMA controller in Loongson1 SoCs, + which is required by Loongson1 NAND and audio support. + +config LOONGSON2_APB_DMA + tristate "Loongson2 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Loongson2 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. + +endifdrivers/dma/loongson/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o +obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.odrivers/dma/loongson/loongson1-apb-dma.c renamed from drivers/dma/loongson1-apb-dma.c +2
-2@@ -16,8 +16,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Loongson-1 DMA Control Register */ #define LS1X_DMA_CTRL 0x0drivers/dma/loongson/loongson2-apb-dma.c renamed from drivers/dma/loongson2-apb-dma.c +2
-3@@ -17,8 +17,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Global Configuration Register */ #define LDMA_ORDER_ERG 0x0 --Quoted 2 lines
2.47.3
--
Best regards,Keguang Zhang
Signature · 2 lines
Thanks. Binbin
Keguang Zhang
maintainerRe: [PATCH 1/3] dmaengine: loongson: New directory for Loongson DMA controllers drivers
Binbin,
Quoted 32 lines · Binbin Zhou
Hi Keguang:
Quoted 19 lines · Keguang Zhang
Quoted 4 lines · Binbin Zhou
Gather the Loongson DMA controllers under
drivers/dma/loongson/Signed-off-by Binbin Zhou <[email protected]>Quoted 12 lines
--- MAINTAINERS | 2 +- drivers/dma/Kconfig | 25 ++--------------- drivers/dma/Makefile | 3 +- drivers/dma/loongson/Kconfig | 28 +++++++++++++++++++ drivers/dma/loongson/Makefile | 3 ++ .../dma/{ => loongson}/loongson1-apb-dma.c | 4 +-- .../dma/{ => loongson}/loongson2-apb-dma.c | 4 +-- 7 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 drivers/dma/loongson/Kconfig create mode 100644 drivers/dma/loongson/Makefile rename drivers/dma/{ => loongson}/loongson1-apb-dma.c (99%)Quoted 2 lines
The file
loongson1-apb-dma.cwas moved todrivers/dma/loongson/, but theMAINTAINERSentry still refers to the old path.In the
MAINTAINERS, the loongson1 driver filename is matched using the wildcard*. This move operation appears to have no effect.As follows:
MIPS/LOONGSON1 ARCHITECTURE
Quoted 8 lines
M: Keguang Zhang <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/*/loongson,ls1*.yaml F: arch/mips/boot/dts/loongson/loongson1* F: arch/mips/configs/loongson1_defconfig F: arch/mips/loongson32/ F: drivers/*/*loongson1*
I have verified that drivers/*/*loongson1* does not cover drivers/dma/loongson/loongson1-apb-dma.c.
Please consider adding one of the following entries to MAINTAINERS:drivers/dma/loongson/loongson1-apb-dma.c
ordrivers/*/loongson/*loongson1*
Thanks!
Quoted 176 lines
F: drivers/mtd/nand/raw/loongson-nand-controller.c F: drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c F: sound/soc/loongson/loongson1_ac97.cQuoted 167 lines
Quoted 160 lines
rename drivers/dma/{ => loongson}/loongson2-apb-dma.c (99%)MAINTAINERS +1
-1@@ -14776,7 +14776,7 @@ M: Binbin Zhou <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml -F: drivers/dma/loongson2-apb-dma.c +F: drivers/dma/loongson/loongson2-apb-dma.c LOONGSON LS2X I2C DRIVER M: Binbin Zhou <[email protected]>drivers/dma/Kconfig +2
-23@@ -376,29 +376,6 @@ config K3_DMA Support the DMA engine for Hisilicon K3 platform devices. -config LOONGSON1_APB_DMA - tristate "Loongson1 APB DMA support" - depends on MACH_LOONGSON32 || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - This selects support for the APB DMA controller in Loongson1 SoCs, - which is required by Loongson1 NAND and audio support. - -config LOONGSON2_APB_DMA - tristate "Loongson2 APB DMA support" - depends on LOONGARCH || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - Support for the Loongson2 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 LPC18XX_DMAMUX bool "NXP LPC18xx/43xx DMA MUX for PL080" depends on ARCH_LPC18XX || COMPILE_TEST@@ -774,6 +751,8 @@ source "drivers/dma/fsl-dpaa2-qdma/Kconfig" source "drivers/dma/lgm/Kconfig" +source "drivers/dma/loongson/Kconfig" + source "drivers/dma/stm32/Kconfig" # clientsdrivers/dma/Makefile +1
-2@@ -49,8 +49,6 @@ obj-$(CONFIG_INTEL_IDMA64) += idma64.o obj-$(CONFIG_INTEL_IOATDMA) += ioat/ obj-y += idxd/ obj-$(CONFIG_K3_DMA) += k3dma.o -obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o -obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o obj-$(CONFIG_LPC32XX_DMAMUX) += lpc32xx-dmamux.o obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o@@ -88,6 +86,7 @@ obj-$(CONFIG_INTEL_LDMA) += lgm/ obj-y += amd/ obj-y += mediatek/ +obj-y += loongson/ obj-y += qcom/ obj-y += stm32/ obj-y += ti/drivers/dma/loongson/Kconfig new file +28
-0@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Loongson DMA controllers drivers +# +if MACH_LOONGSON32 || MACH_LOONGSON64 || COMPILE_TEST + +config LOONGSON1_APB_DMA + tristate "Loongson1 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + This selects support for the APB DMA controller in Loongson1 SoCs, + which is required by Loongson1 NAND and audio support. + +config LOONGSON2_APB_DMA + tristate "Loongson2 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Loongson2 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. + +endifdrivers/dma/loongson/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o +obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.odrivers/dma/loongson/loongson1-apb-dma.c renamed from drivers/dma/loongson1-apb-dma.c +2
-2@@ -16,8 +16,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Loongson-1 DMA Control Register */ #define LS1X_DMA_CTRL 0x0drivers/dma/loongson/loongson2-apb-dma.c renamed from drivers/dma/loongson2-apb-dma.c +2
-3@@ -17,8 +17,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Global Configuration Register */ #define LDMA_ORDER_ERG 0x0 --Quoted 2 lines
2.47.3
--
Best regards,Quoted 1 line
Keguang Zhang
--
Thanks.
Binbin
Signature · 3 lines
Best regards, Keguang Zhang
Re: [PATCH 1/3] dmaengine: loongson: New directory for Loongson DMA controllers drivers
Quoted 45 lines · Keguang Zhang
Binbin,
Quoted 32 lines · Binbin Zhou
Hi Keguang:
Quoted 19 lines · Keguang Zhang
Quoted 4 lines · Binbin Zhou
Gather the Loongson DMA controllers under
drivers/dma/loongson/Signed-off-by Binbin Zhou <[email protected]>Quoted 12 lines
--- MAINTAINERS | 2 +- drivers/dma/Kconfig | 25 ++--------------- drivers/dma/Makefile | 3 +- drivers/dma/loongson/Kconfig | 28 +++++++++++++++++++ drivers/dma/loongson/Makefile | 3 ++ .../dma/{ => loongson}/loongson1-apb-dma.c | 4 +-- .../dma/{ => loongson}/loongson2-apb-dma.c | 4 +-- 7 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 drivers/dma/loongson/Kconfig create mode 100644 drivers/dma/loongson/Makefile rename drivers/dma/{ => loongson}/loongson1-apb-dma.c (99%)Quoted 2 lines
The file
loongson1-apb-dma.cwas moved todrivers/dma/loongson/, but theMAINTAINERSentry still refers to the old path.In the
MAINTAINERS, the loongson1 driver filename is matched using the wildcard*. This move operation appears to have no effect.As follows:
MIPS/LOONGSON1 ARCHITECTURE
Quoted 8 lines
M: Keguang Zhang <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/*/loongson,ls1*.yaml F: arch/mips/boot/dts/loongson/loongson1* F: arch/mips/configs/loongson1_defconfig F: arch/mips/loongson32/ F: drivers/*/*loongson1*
Quoted 4 lines
I have verified that
drivers/*/*loongson1*does not coverdrivers/dma/loongson/loongson1-apb-dma.c.
Please consider adding one of the following entries toMAINTAINERS:drivers/dma/loongson/loongson1-apb-dma.c
OK. I will add this.
Quoted 188 lines
or
drivers/*/loongson/*loongson1*Thanks!
Quoted 171 lines
F: drivers/mtd/nand/raw/loongson-nand-controller.c F: drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c F: sound/soc/loongson/loongson1_ac97.cQuoted 167 lines
Quoted 160 lines
rename drivers/dma/{ => loongson}/loongson2-apb-dma.c (99%)MAINTAINERS +1
-1@@ -14776,7 +14776,7 @@ M: Binbin Zhou <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml -F: drivers/dma/loongson2-apb-dma.c +F: drivers/dma/loongson/loongson2-apb-dma.c LOONGSON LS2X I2C DRIVER M: Binbin Zhou <[email protected]>drivers/dma/Kconfig +2
-23@@ -376,29 +376,6 @@ config K3_DMA Support the DMA engine for Hisilicon K3 platform devices. -config LOONGSON1_APB_DMA - tristate "Loongson1 APB DMA support" - depends on MACH_LOONGSON32 || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - This selects support for the APB DMA controller in Loongson1 SoCs, - which is required by Loongson1 NAND and audio support. - -config LOONGSON2_APB_DMA - tristate "Loongson2 APB DMA support" - depends on LOONGARCH || COMPILE_TEST - select DMA_ENGINE - select DMA_VIRTUAL_CHANNELS - help - Support for the Loongson2 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 LPC18XX_DMAMUX bool "NXP LPC18xx/43xx DMA MUX for PL080" depends on ARCH_LPC18XX || COMPILE_TEST@@ -774,6 +751,8 @@ source "drivers/dma/fsl-dpaa2-qdma/Kconfig" source "drivers/dma/lgm/Kconfig" +source "drivers/dma/loongson/Kconfig" + source "drivers/dma/stm32/Kconfig" # clientsdrivers/dma/Makefile +1
-2@@ -49,8 +49,6 @@ obj-$(CONFIG_INTEL_IDMA64) += idma64.o obj-$(CONFIG_INTEL_IOATDMA) += ioat/ obj-y += idxd/ obj-$(CONFIG_K3_DMA) += k3dma.o -obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o -obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o obj-$(CONFIG_LPC32XX_DMAMUX) += lpc32xx-dmamux.o obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o@@ -88,6 +86,7 @@ obj-$(CONFIG_INTEL_LDMA) += lgm/ obj-y += amd/ obj-y += mediatek/ +obj-y += loongson/ obj-y += qcom/ obj-y += stm32/ obj-y += ti/drivers/dma/loongson/Kconfig new file +28
-0@@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Loongson DMA controllers drivers +# +if MACH_LOONGSON32 || MACH_LOONGSON64 || COMPILE_TEST + +config LOONGSON1_APB_DMA + tristate "Loongson1 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + This selects support for the APB DMA controller in Loongson1 SoCs, + which is required by Loongson1 NAND and audio support. + +config LOONGSON2_APB_DMA + tristate "Loongson2 APB DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Loongson2 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. + +endifdrivers/dma/loongson/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o +obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.odrivers/dma/loongson/loongson1-apb-dma.c renamed from drivers/dma/loongson1-apb-dma.c +2
-2@@ -16,8 +16,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Loongson-1 DMA Control Register */ #define LS1X_DMA_CTRL 0x0drivers/dma/loongson/loongson2-apb-dma.c renamed from drivers/dma/loongson2-apb-dma.c +2
-3@@ -17,8 +17,8 @@#include <linux/platform_device.h> #include <linux/slab.h> -#include "dmaengine.h" -#include "virt-dma.h" +#include "../dmaengine.h" +#include "../virt-dma.h" /* Global Configuration Register */ #define LDMA_ORDER_ERG 0x0 --Quoted 2 lines
2.47.3
--
Best regards,Quoted 5 lines
Quoted 1 line
Keguang Zhang
--
Thanks.
Binbin--
Best regards,Keguang Zhang
Signature · 2 lines
Thanks. Binbin
Binbin Zhou
maintainerPATCH 2/3 dt-bindings: dmaengine: Add Loongson Multi-Channel DMA controller
In reply to Binbin ZhouThe Loongson-2K0300/Loongson-2K3000 have built-in multi-channel DMA controllers, which are similar except for some of the register offsets and number of channels.
Obviously, this is quite different from the APB DMA controller used in the Loongson-2K0500/Loongson-2K1000, such as the latter being a single-channel DMA controller.
To avoid cluttering a single dt-binding file, add a new yaml file.
--- .../bindings/dma/loongson,ls2k0300-dma.yaml | 78 +++++++++++++++++++ MAINTAINERS | 3 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml
Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml new file +78 -0
@@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/loongson,ls2k0300-dma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Looongson-2 Multi-Channel DMA controller + +description: + The Loongson-2 Multi-Channel 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: + enum: + - loongson,ls2k0300-dma + - loongson,ls2k3000-dma + + reg: + maxItems: 1 + + interrupts: + minItems: 4 + maxItems: 8 + + clocks: + maxItems: 1 + + '#dma-cells': + const: 2 + description: | + DMA request from clients consists of 2 cells: + 1. Channel index + 2. Transfer request factor number, If no transfer factor, use 0. + The number is SoC-specific, and this should be specified with + relation to the device to use the DMA controller. + + dma-channels: + enum: [4, 8] + +required: + - compatible + - reg + - interrupts + - clocks + - '#dma-cells' + - dma-channels + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/clock/loongson,ls2k-clk.h> + + dma-controller@1612c000 { + compatible = "loongson,ls2k0300-dma"; + reg = <0x1612c000 0xff>; + interrupt-parent = <&liointc0>; + interrupts = <23 IRQ_TYPE_LEVEL_HIGH>, + <24 IRQ_TYPE_LEVEL_HIGH>, + <25 IRQ_TYPE_LEVEL_HIGH>, + <26 IRQ_TYPE_LEVEL_HIGH>, + <27 IRQ_TYPE_LEVEL_HIGH>, + <28 IRQ_TYPE_LEVEL_HIGH>, + <29 IRQ_TYPE_LEVEL_HIGH>, + <30 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk LS2K0300_CLK_APB_GATE>; + #dma-cells = <2>; + dma-channels = <8>; + }; +...
MAINTAINERS +2 -1
@@ -14771,10 +14771,11 @@ S: Maintained F: Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml F: drivers/gpio/gpio-loongson-64bit.c -LOONGSON-2 APB DMA DRIVER +LOONGSON-2 DMA DRIVER M: Binbin Zhou <[email protected]> L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml F: drivers/dma/loongson/loongson2-apb-dma.c
Signature · 1 line
2.47.3
Re: [PATCH 2/3] dt-bindings: dmaengine: Add Loongson Multi-Channel DMA controller
Quoted 68 lines · Binbin Zhou
The Loongson-2K0300/Loongson-2K3000 have built-in multi-channel DMA controllers, which are similar except for some of the register offsets and number of channels.
Obviously, this is quite different from the APB DMA controller used in the Loongson-2K0500/Loongson-2K1000, such as the latter being a single-channel DMA controller.
To avoid cluttering a single dt-binding file, add a new yaml file.
Signed-off-by Binbin Zhou <[email protected]>--- .../bindings/dma/loongson,ls2k0300-dma.yaml | 78 +++++++++++++++++++ MAINTAINERS | 3 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yamlDocumentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml new file +45
-0@@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/loongson,ls2k0300-dma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Looongson-2 Multi-Channel DMA controller + +description: + The Loongson-2 Multi-Channel 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: + enum: + - loongson,ls2k0300-dma + - loongson,ls2k3000-dma + + reg: + maxItems: 1 + + interrupts: + minItems: 4 + maxItems: 8 + + clocks: + maxItems: 1 + + '#dma-cells': + const: 2 + description: | + DMA request from clients consists of 2 cells: + 1. Channel index + 2. Transfer request factor number, If no transfer factor, use 0. + The number is SoC-specific, and this should be specified with + relation to the device to use the DMA controller. + + dma-channels: + enum: [4, 8]
Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml line 55
Quoted 10 lines
Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml new file +10
-0+ +required: + - compatible + - reg + - interrupts + - clocks + - '#dma-cells' + - dma-channels + +additionalProperties: false
use
unevaluatedProperties: false
because there are $ref: dma-controller.yaml#
Frank
Quoted 43 lines
Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml new file +23
-0+ +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/clock/loongson,ls2k-clk.h> + + dma-controller@1612c000 { + compatible = "loongson,ls2k0300-dma"; + reg = <0x1612c000 0xff>; + interrupt-parent = <&liointc0>; + interrupts = <23 IRQ_TYPE_LEVEL_HIGH>, + <24 IRQ_TYPE_LEVEL_HIGH>, + <25 IRQ_TYPE_LEVEL_HIGH>, + <26 IRQ_TYPE_LEVEL_HIGH>, + <27 IRQ_TYPE_LEVEL_HIGH>, + <28 IRQ_TYPE_LEVEL_HIGH>, + <29 IRQ_TYPE_LEVEL_HIGH>, + <30 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk LS2K0300_CLK_APB_GATE>; + #dma-cells = <2>; + dma-channels = <8>; + }; +...MAINTAINERS +2
-2@@ -14771,10 +14771,11 @@ S: Maintained F: Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml F: drivers/gpio/gpio-loongson-64bit.c -LOONGSON-2 APB DMA DRIVER +LOONGSON-2 DMA DRIVER M: Binbin Zhou <[email protected]> L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml F: drivers/dma/loongson/loongson2-apb-dma.c --2.47.3
Re: [PATCH 2/3] dt-bindings: dmaengine: Add Loongson Multi-Channel DMA controller
Hi Frank:
Thanks for your reply.
Quoted 75 lines · Frank Li
Quoted 73 lines · Binbin Zhou
The Loongson-2K0300/Loongson-2K3000 have built-in multi-channel DMA controllers, which are similar except for some of the register offsets and number of channels.
Obviously, this is quite different from the APB DMA controller used in the Loongson-2K0500/Loongson-2K1000, such as the latter being a single-channel DMA controller.
To avoid cluttering a single dt-binding file, add a new yaml file.
Signed-off-by Binbin Zhou <[email protected]>--- .../bindings/dma/loongson,ls2k0300-dma.yaml | 78 +++++++++++++++++++ MAINTAINERS | 3 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yamlDocumentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml new file +50
-0@@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/loongson,ls2k0300-dma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Looongson-2 Multi-Channel DMA controller + +description: + The Loongson-2 Multi-Channel 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: + enum: + - loongson,ls2k0300-dma + - loongson,ls2k3000-dma + + reg: + maxItems: 1 + + interrupts: + minItems: 4 + maxItems: 8 + + clocks: + maxItems: 1 + + '#dma-cells': + const: 2 + description: | + DMA request from clients consists of 2 cells: + 1. Channel index + 2. Transfer request factor number, If no transfer factor, use 0. + The number is SoC-specific, and this should be specified with + relation to the device to use the DMA controller. + + dma-channels: + enum: [4, 8] + +required: + - compatible + - reg + - interrupts
Quoted 8 lines
Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml line 55
Quoted 5 lines
Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml new file +5
-0+ - clocks + - '#dma-cells' + - dma-channels + +additionalProperties: falseuse
unevaluatedProperties: false
Yes, that should be it.
Quoted 47 lines
because there are $ref: dma-controller.yaml#
Frank
Quoted 43 lines
Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml new file +23
-0+ +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/clock/loongson,ls2k-clk.h> + + dma-controller@1612c000 { + compatible = "loongson,ls2k0300-dma"; + reg = <0x1612c000 0xff>; + interrupt-parent = <&liointc0>; + interrupts = <23 IRQ_TYPE_LEVEL_HIGH>, + <24 IRQ_TYPE_LEVEL_HIGH>, + <25 IRQ_TYPE_LEVEL_HIGH>, + <26 IRQ_TYPE_LEVEL_HIGH>, + <27 IRQ_TYPE_LEVEL_HIGH>, + <28 IRQ_TYPE_LEVEL_HIGH>, + <29 IRQ_TYPE_LEVEL_HIGH>, + <30 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk LS2K0300_CLK_APB_GATE>; + #dma-cells = <2>; + dma-channels = <8>; + }; +...MAINTAINERS +2
-2@@ -14771,10 +14771,11 @@ S: Maintained F: Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml F: drivers/gpio/gpio-loongson-64bit.c -LOONGSON-2 APB DMA DRIVER +LOONGSON-2 DMA DRIVER M: Binbin Zhou <[email protected]> L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml F: drivers/dma/loongson/loongson2-apb-dma.c --2.47.3
Signature · 2 lines
Thanks. Binbin
Binbin Zhou
maintainerPATCH 3/3 dmaengine: loongson: New driver for the Loongson Multi-Channel DMA controller
In reply to Binbin ZhouThis DMA controller appears in Loongson-2K0300 and Loongson-2K3000.
It is a multi-channel controller that enables data transfers from memory to memory, device to memory, and memory to device, as well as channel prioritization configurable through the channel configuration registers.
In addition, there are slight differences between Loongson-2K0300 and Loongson-2K3000, such as channel register offsets and the number of channels.
--- MAINTAINERS | 1 + drivers/dma/loongson/Kconfig | 10 + drivers/dma/loongson/Makefile | 1 + drivers/dma/loongson/loongson2-apb-dma-v2.c | 759 ++++++++++++++++++++ 4 files changed, 771 insertions(+) create mode 100644 drivers/dma/loongson/loongson2-apb-dma-v2.c
MAINTAINERS +1 -0
@@ -14777,6 +14777,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml +F: drivers/dma/loongson/loongson2-apb-dma-v2.c F: drivers/dma/loongson/loongson2-apb-dma.c LOONGSON LS2X I2C DRIVER
drivers/dma/loongson/Kconfig +10 -0
@@ -25,4 +25,14 @@ config LOONGSON2_APB_DMA This DMA controller transfers data from memory to peripheral fifo. It does not support memory to memory data transfer. +config LOONGSON2_APB_DMA_V2 + tristate "Loongson2 Multi-Channel DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Loongson Multi-Channel DMA controller driver. + It is discovered on the Loongson-2K chip (Loongson-2K0300/Loongson-2K3000), + which has 4/8 channels internally, enabling bidirectional data transfer + between devices and memory. + endif
drivers/dma/loongson/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o +obj-$(CONFIG_LOONGSON2_APB_DMA_V2) += loongson2-apb-dma-v2.o
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +759 -0
759 lines not on this page · raw message
Signature · 1 line
2.47.3
Re: [PATCH 3/3] dmaengine: loongson: New driver for the Loongson Multi-Channel DMA controller
Quoted 65 lines · Binbin Zhou
This DMA controller appears in Loongson-2K0300 and Loongson-2K3000.
It is a multi-channel controller that enables data transfers from memory to memory, device to memory, and memory to device, as well as channel prioritization configurable through the channel configuration registers.
In addition, there are slight differences between Loongson-2K0300 and Loongson-2K3000, such as channel register offsets and the number of channels.
Signed-off-by Binbin Zhou <[email protected]>--- MAINTAINERS | 1 + drivers/dma/loongson/Kconfig | 10 + drivers/dma/loongson/Makefile | 1 + drivers/dma/loongson/loongson2-apb-dma-v2.c | 759 ++++++++++++++++++++ 4 files changed, 771 insertions(+) create mode 100644 drivers/dma/loongson/loongson2-apb-dma-v2.cMAINTAINERS +1
-0@@ -14777,6 +14777,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml +F: drivers/dma/loongson/loongson2-apb-dma-v2.c F: drivers/dma/loongson/loongson2-apb-dma.c LOONGSON LS2X I2C DRIVERdrivers/dma/loongson/Kconfig +10
-0@@ -25,4 +25,14 @@ config LOONGSON2_APB_DMA This DMA controller transfers data from memory to peripheral fifo. It does not support memory to memory data transfer. +config LOONGSON2_APB_DMA_V2 + tristate "Loongson2 Multi-Channel DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Loongson Multi-Channel DMA controller driver. + It is discovered on the Loongson-2K chip (Loongson-2K0300/Loongson-2K3000), + which has 4/8 channels internally, enabling bidirectional data transfer + between devices and memory. + endifdrivers/dma/loongson/Makefile +1
-0@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o +obj-$(CONFIG_LOONGSON2_APB_DMA_V2) += loongson2-apb-dma-v2.odrivers/dma/loongson/loongson2-apb-dma-v2.c new file +0
-0@@ -0,0 +1,759 @@
...
drivers/dma/loongson/loongson2-apb-dma-v2.c line 79
Quoted 7 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +7
-0+ +struct loongson2_mdma_chan_reg { +u32 dma_ccr; +u32 dma_cndtr; +u32 dma_cpar; +u32 dma_cmar; +};
needn't 'dma_' prefix because it is already in loongson2_mdma_chan_reg.
Quoted 6 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +6
-0+ +struct loongson2_mdma_sg_req { +u32 len; +struct loongson2_mdma_chan_reg chan_reg; +}; +
...
drivers/dma/loongson/loongson2-apb-dma-v2.c line 176
Quoted 5 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +5
-0+ +static struct loongson2_mdma_desc *loongson2_mdma_alloc_desc (u32 num_sgs) +{ +return kzalloc (sizeof (struct loongson2_mdma_desc ) + +sizeof (struct loongson2_mdma_sg_req ) * num_sgs,GFP_NOWAIT );
use struct_size()
Quoted 11 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +11
-0+} + +static int loongson2_mdma_slave_config (struct dma_chan *chan,struct dma_slave_config *config) +{ +struct loongson2_mdma_chan *lchan =to_lmdma_chan (chan); + +memcpy (&lchan->dma_sconfig, config,sizeof (*config)); + +return 0 ; +} +
...
Quoted 57 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +57
-0+ +static int loongson2_mdma_probe (struct platform_device *pdev) +{ +const struct loongson2_mdma_config *config; +struct loongson2_mdma_chan *lchan; +struct loongson2_mdma_dev *lddev; +struct device *dev = &pdev->dev; +struct dma_device *ddev; +int nr_chans, i, ret; + + config = (const struct loongson2_mdma_config *)device_get_match_data (dev); +if (!config) +return -EINVAL ; + + ret =device_property_read_u32 (dev,"dma-channels" , &nr_chans); +if (ret || nr_chans > config->max_channels) { +dev_err (dev,"missing or invalid dma-channels property\n" ); + nr_chans = config->max_channels; + } + + lddev =devm_kzalloc (dev,struct_size (lddev, chan, nr_chans),GFP_KERNEL ); +if (!lddev) +return -ENOMEM ; + + lddev->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (lddev->base)) +return PTR_ERR (lddev->base); + +platform_set_drvdata (pdev, lddev); + lddev->nr_channels = nr_chans; + lddev->chan_reg_offset = config->chan_reg_offset; + + lddev->dma_clk =devm_clk_get_optional_enabled (dev,NULL ); +if (IS_ERR (lddev->dma_clk)) +return dev_err_probe (dev,PTR_ERR (lddev->dma_clk),"Failed to get dma clock\n" ); + + ddev = &lddev->ddev; + ddev->dev = dev; + +dma_cap_zero (ddev->cap_mask); +dma_cap_set (DMA_SLAVE , ddev->cap_mask); +dma_cap_set (DMA_PRIVATE , ddev->cap_mask); +dma_cap_set (DMA_CYCLIC , ddev->cap_mask); + + ddev->device_free_chan_resources = loongson2_mdma_free_chan_resources; + ddev->device_config = loongson2_mdma_slave_config; + ddev->device_prep_slave_sg = loongson2_mdma_prep_slave_sg; + ddev->device_prep_dma_cyclic = loongson2_mdma_prep_dma_cyclic; + ddev->device_issue_pending = loongson2_mdma_issue_pending; + ddev->device_synchronize = loongson2_mdma_synchronize; + ddev->device_tx_status = loongson2_mdma_tx_status; + ddev->device_terminate_all = loongson2_mdma_terminate_all; + + ddev->src_addr_widths =LOONGSON2_MDMA_BUSWIDTHS ; + ddev->dst_addr_widths =LOONGSON2_MDMA_BUSWIDTHS ; + ddev->directions =BIT (DMA_DEV_TO_MEM ) |BIT (DMA_MEM_TO_DEV ); +INIT_LIST_HEAD (&ddev->channels);
drivers/dma/loongson/loongson2-apb-dma-v2.c line 688
Quoted 10 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +10
-0+ +for (i =0 ; i < nr_chans; i++) { + lchan = &lddev->chan[i]; + + lchan->id = i; + lchan->vchan.desc_free = loongson2_mdma_desc_free; +vchan_init (&lchan->vchan, ddev); + } + + ret =dma_async_device_register (ddev);
use dmaenginem_async_device_register() to avoid below goto
Frank
Quoted 74 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +71
-1+if (ret) +return ret; + +for (i =0 ; i < nr_chans; i++) { + lchan = &lddev->chan[i]; + + lchan->irq =platform_get_irq (pdev, i); +if (lchan->irq <0 ) { + ret = -EINVAL ; + goto unregister_dmac; + } + + ret =devm_request_irq (dev, lchan->irq, loongson2_mdma_chan_irq,IRQF_SHARED , +dev_name (chan2dev (lchan)), lchan); +if (ret) + goto unregister_dmac; + } + + ret =loongson2_mdma_acpi_controller_register (lddev); +if (ret) + goto unregister_dmac; + + ret =loongson2_mdma_of_controller_register (lddev); +if (ret) + goto unregister_dmac; + +dev_info (dev,"Loongson-2 Multi-Channel DMA Controller driver registered successfully.\n" ); +return 0 ; + +unregister_dmac: +dma_async_device_unregister (ddev); + +return ret; +} + +static void loongson2_mdma_remove (struct platform_device *pdev) +{ +struct loongson2_mdma_dev *lddev =platform_get_drvdata (pdev); + +of_dma_controller_free (pdev->dev.of_node); +dma_async_device_unregister (&lddev->ddev); +} + +static const struct of_device_id loongson2_mdma_of_match[] = { + { .compatible ="loongson,ls2k0300-dma" , .data = &ls2k0300_mdma_config }, + { .compatible ="loongson,ls2k3000-dma" , .data = &ls2k3000_mdma_config }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, loongson2_mdma_of_match); + +static const struct acpi_device_id loongson2_mdma_acpi_match[] = { + {"LOON0014" , .driver_data = (kernel_ulong_t)&ls2k3000_mdma_config }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (acpi, loongson2_mdma_acpi_match); + +static struct platform_driver loongson2_mdma_driver = { + .driver = { + .name ="loongson2-mdma" , + .of_match_table = loongson2_mdma_of_match, + .acpi_match_table = loongson2_mdma_acpi_match, + }, + .probe = loongson2_mdma_probe, + .remove = loongson2_mdma_remove, +}; + +module_platform_driver (loongson2_mdma_driver); + +MODULE_DESCRIPTION ("Looongson-2 Multi-Channel DMA Controller driver" ); +MODULE_AUTHOR ("Loongson Technology Corporation Limited" ); +MODULE_LICENSE ("GPL" ); --2.47.3
Re: [PATCH 3/3] dmaengine: loongson: New driver for the Loongson Multi-Channel DMA controller
Hi Frank:
Thanks for your reply.
Quoted 68 lines · Frank Li
Quoted 65 lines · Binbin Zhou
This DMA controller appears in Loongson-2K0300 and Loongson-2K3000.
It is a multi-channel controller that enables data transfers from memory to memory, device to memory, and memory to device, as well as channel prioritization configurable through the channel configuration registers.
In addition, there are slight differences between Loongson-2K0300 and Loongson-2K3000, such as channel register offsets and the number of channels.
Signed-off-by Binbin Zhou <[email protected]>--- MAINTAINERS | 1 + drivers/dma/loongson/Kconfig | 10 + drivers/dma/loongson/Makefile | 1 + drivers/dma/loongson/loongson2-apb-dma-v2.c | 759 ++++++++++++++++++++ 4 files changed, 771 insertions(+) create mode 100644 drivers/dma/loongson/loongson2-apb-dma-v2.cMAINTAINERS +1
-0@@ -14777,6 +14777,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/dma/loongson,ls2k0300-dma.yaml F: Documentation/devicetree/bindings/dma/loongson,ls2x-apbdma.yaml +F: drivers/dma/loongson/loongson2-apb-dma-v2.c F: drivers/dma/loongson/loongson2-apb-dma.c LOONGSON LS2X I2C DRIVERdrivers/dma/loongson/Kconfig +10
-0@@ -25,4 +25,14 @@ config LOONGSON2_APB_DMA This DMA controller transfers data from memory to peripheral fifo. It does not support memory to memory data transfer. +config LOONGSON2_APB_DMA_V2 + tristate "Loongson2 Multi-Channel DMA support" + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Loongson Multi-Channel DMA controller driver. + It is discovered on the Loongson-2K chip (Loongson-2K0300/Loongson-2K3000), + which has 4/8 channels internally, enabling bidirectional data transfer + between devices and memory. + endifdrivers/dma/loongson/Makefile +1
-0@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_LOONGSON1_APB_DMA) += loongson1-apb-dma.o obj-$(CONFIG_LOONGSON2_APB_DMA) += loongson2-apb-dma.o +obj-$(CONFIG_LOONGSON2_APB_DMA_V2) += loongson2-apb-dma-v2.odrivers/dma/loongson/loongson2-apb-dma-v2.c new file +0
-0@@ -0,0 +1,759 @@...
Quoted 9 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c line 79
Quoted 7 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +7
-0+ +struct loongson2_mdma_chan_reg { +u32 dma_ccr; +u32 dma_cndtr; +u32 dma_cpar; +u32 dma_cmar; +};needn't '
dma_' prefix because it is already inloongson2_mdma_chan_reg.
ok..
Quoted 8 lines
Quoted 7 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +6
-0+ +struct loongson2_mdma_sg_req { +u32 len; +struct loongson2_mdma_chan_reg chan_reg; +}; +...
Quoted 7 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c line 176
Quoted 5 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +5
-0+ +static struct loongson2_mdma_desc *loongson2_mdma_alloc_desc (u32 num_sgs) +{ +return kzalloc (sizeof (struct loongson2_mdma_desc ) + +sizeof (struct loongson2_mdma_sg_req ) * num_sgs,GFP_NOWAIT );use
struct_size()
I see.
Quoted 74 lines
Quoted 12 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +11
-0+} + +static int loongson2_mdma_slave_config (struct dma_chan *chan,struct dma_slave_config *config) +{ +struct loongson2_mdma_chan *lchan =to_lmdma_chan (chan); + +memcpy (&lchan->dma_sconfig, config,sizeof (*config)); + +return 0 ; +} +...
Quoted 61 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +61
-0+ +static int loongson2_mdma_probe (struct platform_device *pdev) +{ +const struct loongson2_mdma_config *config; +struct loongson2_mdma_chan *lchan; +struct loongson2_mdma_dev *lddev; +struct device *dev = &pdev->dev; +struct dma_device *ddev; +int nr_chans, i, ret; + + config = (const struct loongson2_mdma_config *)device_get_match_data (dev); +if (!config) +return -EINVAL ; + + ret =device_property_read_u32 (dev,"dma-channels" , &nr_chans); +if (ret || nr_chans > config->max_channels) { +dev_err (dev,"missing or invalid dma-channels property\n" ); + nr_chans = config->max_channels; + } + + lddev =devm_kzalloc (dev,struct_size (lddev, chan, nr_chans),GFP_KERNEL ); +if (!lddev) +return -ENOMEM ; + + lddev->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (lddev->base)) +return PTR_ERR (lddev->base); + +platform_set_drvdata (pdev, lddev); + lddev->nr_channels = nr_chans; + lddev->chan_reg_offset = config->chan_reg_offset; + + lddev->dma_clk =devm_clk_get_optional_enabled (dev,NULL ); +if (IS_ERR (lddev->dma_clk)) +return dev_err_probe (dev,PTR_ERR (lddev->dma_clk),"Failed to get dma clock\n" ); + + ddev = &lddev->ddev; + ddev->dev = dev; + +dma_cap_zero (ddev->cap_mask); +dma_cap_set (DMA_SLAVE , ddev->cap_mask); +dma_cap_set (DMA_PRIVATE , ddev->cap_mask); +dma_cap_set (DMA_CYCLIC , ddev->cap_mask); + + ddev->device_free_chan_resources = loongson2_mdma_free_chan_resources; + ddev->device_config = loongson2_mdma_slave_config; + ddev->device_prep_slave_sg = loongson2_mdma_prep_slave_sg; + ddev->device_prep_dma_cyclic = loongson2_mdma_prep_dma_cyclic; + ddev->device_issue_pending = loongson2_mdma_issue_pending; + ddev->device_synchronize = loongson2_mdma_synchronize; + ddev->device_tx_status = loongson2_mdma_tx_status; + ddev->device_terminate_all = loongson2_mdma_terminate_all; + + ddev->src_addr_widths =LOONGSON2_MDMA_BUSWIDTHS ; + ddev->dst_addr_widths =LOONGSON2_MDMA_BUSWIDTHS ; + ddev->directions =BIT (DMA_DEV_TO_MEM ) |BIT (DMA_MEM_TO_DEV ); +INIT_LIST_HEAD (&ddev->channels); + +for (i =0 ; i < nr_chans; i++) { + lchan = &lddev->chan[i]; +
Quoted 8 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c line 688
Quoted 6 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +6
-0+ lchan->id = i; + lchan->vchan.desc_free = loongson2_mdma_desc_free; +vchan_init (&lchan->vchan, ddev); + } + + ret =dma_async_device_register (ddev);use
dmaenginem_async_device_register()to avoid below goto
ok...
Quoted 69 lines
Frank
Quoted 66 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +66
-0+if (ret) +return ret; + +for (i =0 ; i < nr_chans; i++) { + lchan = &lddev->chan[i]; + + lchan->irq =platform_get_irq (pdev, i); +if (lchan->irq <0 ) { + ret = -EINVAL ; + goto unregister_dmac; + } + + ret =devm_request_irq (dev, lchan->irq, loongson2_mdma_chan_irq,IRQF_SHARED , +dev_name (chan2dev (lchan)), lchan); +if (ret) + goto unregister_dmac; + } + + ret =loongson2_mdma_acpi_controller_register (lddev); +if (ret) + goto unregister_dmac; + + ret =loongson2_mdma_of_controller_register (lddev); +if (ret) + goto unregister_dmac; + +dev_info (dev,"Loongson-2 Multi-Channel DMA Controller driver registered successfully.\n" ); +return 0 ; + +unregister_dmac: +dma_async_device_unregister (ddev); + +return ret; +} + +static void loongson2_mdma_remove (struct platform_device *pdev) +{ +struct loongson2_mdma_dev *lddev =platform_get_drvdata (pdev); + +of_dma_controller_free (pdev->dev.of_node); +dma_async_device_unregister (&lddev->ddev); +} + +static const struct of_device_id loongson2_mdma_of_match[] = { + { .compatible ="loongson,ls2k0300-dma" , .data = &ls2k0300_mdma_config }, + { .compatible ="loongson,ls2k3000-dma" , .data = &ls2k3000_mdma_config }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, loongson2_mdma_of_match); + +static const struct acpi_device_id loongson2_mdma_acpi_match[] = { + {"LOON0014" , .driver_data = (kernel_ulong_t)&ls2k3000_mdma_config }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (acpi, loongson2_mdma_acpi_match); + +static struct platform_driver loongson2_mdma_driver = { + .driver = { + .name ="loongson2-mdma" , + .of_match_table = loongson2_mdma_of_match, + .acpi_match_table = loongson2_mdma_acpi_match, + }, + .probe = loongson2_mdma_probe, + .remove = loongson2_mdma_remove, +}; +
Quoted 8 lines
Quoted 8 lines
drivers/dma/loongson/loongson2-apb-dma-v2.c new file +5
-1+module_platform_driver (loongson2_mdma_driver); + +MODULE_DESCRIPTION ("Looongson-2 Multi-Channel DMA Controller driver" ); +MODULE_AUTHOR ("Loongson Technology Corporation Limited" ); +MODULE_LICENSE ("GPL" ); --2.47.3
--
Thanks.
Binbin