arm: aspeed: Add UART DMA support
Subsystems (4)
v2 cover arm: aspeed: Add UART DMA support
This patch serias adds the 8250 driver with DMA support for AST26xx UART devices
v2 change:
- re-write UDMA driver based on the DMAEngine framework
- re-write 8250_aspeed driver with DMA support based on the 8250_dma implementation
- remove virtual UART part as there is already a 8250_aspeed_vuart driver
Chia-Wei Wang (5):
dt-bindings: serial: 8250: Add aspeed,ast2600-uart
dt-bindings: dmaengine: Add AST2600 UDMA bindings
dmaengine: aspeed: Add AST2600 UART DMA driver
serial: 8250: Add AST2600 UART driver
ARM: dts: aspeed-g6: Add UDMA node
.../bindings/dma/aspeed,ast2600-udma.yaml | 56 ++ .../devicetree/bindings/serial/8250.yaml | 1 + arch/arm/boot/dts/aspeed-g6.dtsi | 9 + drivers/dma/Kconfig | 9 + drivers/dma/Makefile | 1 + drivers/dma/ast2600-udma.c | 528 ++++++++++++++++++ drivers/tty/serial/8250/8250_aspeed.c | 224 ++++++++ drivers/tty/serial/8250/Kconfig | 8 + drivers/tty/serial/8250/Makefile | 1 + include/dt-bindings/dma/ast2600-udma.h | 40 ++ 10 files changed, 877 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml create mode 100644 drivers/dma/ast2600-udma.c create mode 100644 drivers/tty/serial/8250/8250_aspeed.c create mode 100644 include/dt-bindings/dma/ast2600-udma.h
Signature · 1 line
2.25.1
PATCH v2 1/5 dt-bindings: serial: 8250: Add aspeed,ast2600-uart
Add a compatible string for the NS16550A-compatible UARTs of Aspeed AST2600 SoCs.
--- Documentation/devicetree/bindings/serial/8250.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/serial/8250.yaml +1 -0
@@ -59,6 +59,7 @@ properties: - const: ns16850 - const: aspeed,ast2400-vuart - const: aspeed,ast2500-vuart + - const: aspeed,ast2600-uart - const: intel,xscale-uart - const: mrvl,pxa-uart - const: nuvoton,wpcm450-uart
Signature · 1 line
2.25.1
Re: [PATCH v2 1/5] dt-bindings: serial: 8250: Add aspeed,ast2600-uart
Quoted 8 lines · Chia-Wei Wang
Add a compatible string for the NS16550A-compatible UARTs of Aspeed AST2600 SoCs.
Signed-off-by Chia-Wei Wang <[email protected]>--- Documentation/devicetree/bindings/serial/8250.yaml | 1 + 1 file changed, 1 insertion(+)
PATCH v2 2/5 dt-bindings: dmaengine: Add AST2600 UDMA bindings
In reply to Chia-Wei WangAdd the dmaengine bindings for the UART DMA engine of Aspeed AST2600 SoC.
--- .../bindings/dma/aspeed,ast2600-udma.yaml | 56 +++++++++++++++++++ include/dt-bindings/dma/ast2600-udma.h | 40 +++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml create mode 100644 include/dt-bindings/dma/ast2600-udma.h
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/aspeed,ast2600-udma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Aspeed AST2600 UART DMA controller + +maintainers: + - Chia-Wei Wang <[email protected]> + +description: | + The Aspeed AST2600 UDMA controller provides direct memory access capabilities + for the NS16550A-compatible UART devices inside AST2600 SoCs. UDMA supports 28 + DMA channels and each UART device has its dedicated pair of TX and RX channels. + +allOf: + - $ref: "dma-controller.yaml#" + +properties: + compatible: + const: aspeed,ast2600-udma + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#dma-cells": + const: 1 + + dma-channels: + maximum: 28 + +required: + - compatible + - reg + - interrupts + - "#dma-cells" + - dma-channels + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + udma: dma-controller at 1e79e000 { + compatible = "aspeed,ast2600-udma"; + reg = <0x1e79e000 0x1000>; + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>; + dma-channels = <28>; + #dma-cells = <1>; + }; + +...
include/dt-bindings/dma/ast2600-udma.h new file +40 -0
@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* This header provides macros for Aspeed AST2600 UDMA bindings +* +* Copyright (c) 2023 Aspeed Technology Inc. +*/ + +#ifndef __DT_BINDINGS_DMA_AST2600_UDMA_H__ +#define __DT_BINDINGS_DMA_AST2600_UDMA_H__ + +#define AST2600_UDMA_UART1_TX 0 +#define AST2600_UDMA_UART1_RX 1 +#define AST2600_UDMA_UART2_TX 2 +#define AST2600_UDMA_UART2_RX 3 +#define AST2600_UDMA_UART3_TX 4 +#define AST2600_UDMA_UART3_RX 5 +#define AST2600_UDMA_UART4_TX 6 +#define AST2600_UDMA_UART4_RX 7 +#define AST2600_UDMA_UART6_TX 8 +#define AST2600_UDMA_UART6_RX 9 +#define AST2600_UDMA_UART7_TX 10 +#define AST2600_UDMA_UART7_RX 11 +#define AST2600_UDMA_UART8_TX 12 +#define AST2600_UDMA_UART8_RX 13 +#define AST2600_UDMA_UART9_TX 14 +#define AST2600_UDMA_UART9_RX 15 +#define AST2600_UDMA_UART10_TX 16 +#define AST2600_UDMA_UART10_RX 17 +#define AST2600_UDMA_UART11_TX 18 +#define AST2600_UDMA_UART11_RX 19 +#define AST2600_UDMA_UART12_TX 20 +#define AST2600_UDMA_UART12_RX 21 +#define AST2600_UDMA_UART13_TX 22 +#define AST2600_UDMA_UART13_RX 23 +#define AST2600_UDMA_VUART1_TX 24 +#define AST2600_UDMA_VUART1_RX 25 +#define AST2600_UDMA_VUART2_TX 26 +#define AST2600_UDMA_VUART2_RX 27 + +#endif /* __DT_BINDINGS_DMA_AST2600_UDMA_H__ */
Signature · 1 line
2.25.1
Rob Herring
maintainerRe: [PATCH v2 2/5] dt-bindings: dmaengine: Add AST2600 UDMA bindings
Quoted 18 lines · Chia-Wei Wang
Add the dmaengine bindings for the UART DMA engine of Aspeed AST2600 SoC.
Signed-off-by Chia-Wei Wang <[email protected]>--- .../bindings/dma/aspeed,ast2600-udma.yaml | 56 +++++++++++++++++++ include/dt-bindings/dma/ast2600-udma.h | 40 +++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml create mode 100644 include/dt-bindings/dma/ast2600-udma.hDocumentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +2
-0@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/dma/aspeed,ast2600-udma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Aspeed AST2600 UART DMA controller + +maintainers: + - Chia-Wei Wang <[email protected]> + +description: |
Don't need '|'
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml line 18
Quoted 6 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +6
-0+ The Aspeed AST2600 UDMA controller provides direct memory access capabilities + for the NS16550A-compatible UART devices inside AST2600 SoCs. UDMA supports 28 + DMA channels and each UART device has its dedicated pair of TX and RX channels. + +allOf: + - $ref: "dma-controller.yaml#"
Drop quotes
Quoted 20 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +20
-0+ +properties: + compatible: + const: aspeed,ast2600-udma + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#dma-cells": + const: 1 + + dma-channels: + maximum: 28 + +required: + - compatible + - reg
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml line 48
Quoted 10 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +10
-0+ - interrupts + - "#dma-cells" + - dma-channels + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + udma: dma-controller at 1e79e000 {
Drop unused label.
Quoted 14 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +8
-0+ compatible = "aspeed,ast2600-udma"; + reg = <0x1e79e000 0x1000>; + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>; + dma-channels = <28>; + #dma-cells = <1>; + }; + +...include/dt-bindings/dma/ast2600-udma.h new file +0
-0
include/dt-bindings/dma/ast2600-udma.h line 1
Quoted 1 line
include/dt-bindings/dma/ast2600-udma.h new file +1
-0@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-only */
Headers should be dual licensed.
However, similar to interrupts, we don't normally do defines for DMA request numbers. It's only when we make up the numbering (e.g. clock ids).
Rob
RE: [PATCH v2 2/5] dt-bindings: dmaengine: Add AST2600 UDMA bindings
Quoted 30 lines
From: Rob Herring <[email protected]>
Sent: Saturday, March 18, 2023 5:06 AMQuoted 1 line · Chia-Wei Wang
Add the dmaengine bindings for the UART DMA engine of Aspeed AST2600
SoC.
Quoted 4 lines
Signed-off-by Chia-Wei Wang <[email protected]>--- .../bindings/dma/aspeed,ast2600-udma.yaml | 56+++++++++++++++++++
Quoted 19 lines
include/dt-bindings/dma/ast2600-udma.h | 40 +++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml create mode 100644 include/dt-bindings/dma/ast2600-udma.hdiff --git
a/Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yamlb/Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yamlnew file mode 100644
index 000000000000..f92e06ac9f39Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +5
-0@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/aspeed,ast2600-udma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +
Quoted 8 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml line 12
Quoted 6 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +6
-0+title: Aspeed AST2600 UART DMA controller + +maintainers: + - Chia-Wei Wang <[email protected]> + +description: |Don't need '|'
Will revise in v3 revision.
Quoted 10 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml line 14
Quoted 4 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +3
-0+ The Aspeed AST2600 UDMA controller provides direct memory access + capabilities for the NS16550A-compatible UART devices inside + AST2600 SoCs. UDMA supports 28 DMA channels and each UART devicehas its dedicated pair of TX and RX channels.
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml line 18
Quoted 3 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +3
-0+ +allOf: + - $ref: "dma-controller.yaml#"Drop quotes
Will revise in v3 revision.
Quoted 25 lines
Quoted 25 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +24
-0+ +properties: + compatible: + const: aspeed,ast2600-udma + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#dma-cells": + const: 1 + + dma-channels: + maximum: 28 + +required: + - compatible + - reg + - interrupts + - "#dma-cells" + - dma-channels +
Quoted 8 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml line 48
Quoted 6 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +6
-0+additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + udma: dma-controller at 1e79e000 {Drop unused label.
Will revise in v3 revision.
Quoted 20 lines
Quoted 16 lines
Documentation/devicetree/bindings/dma/aspeed,ast2600-udma.yaml new file +8
-0+ compatible = "aspeed,ast2600-udma"; + reg = <0x1e79e000 0x1000>; + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>; + dma-channels = <28>; + #dma-cells = <1>; + }; + +...include/dt-bindings/dma/ast2600-udma.h new file +0
-0include/dt-bindings/dma/ast2600-udma.h line 1
Quoted 1 line
include/dt-bindings/dma/ast2600-udma.h new file +1
-0@@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ Headers should be dual licensed.
Quoted 3 lines
However, similar to interrupts, we don't normally do defines for DMA request numbers. It's only when we make up the numbering (e.g. clock ids).
Will remove the header file in v3 revision.
Thanks,
Chiawei
PATCH v2 3/5 dmaengine: aspeed: Add AST2600 UART DMA driver
In reply to Chia-Wei WangAspeed AST2600 UART DMA (UDMA) includes 14 channels for the DMA transmission and recevie of each UART devices.
--- drivers/dma/Kconfig | 9 + drivers/dma/Makefile | 1 + drivers/dma/ast2600-udma.c | 528 +++++++++++++++++++++++++++++++++++++ 3 files changed, 538 insertions(+) create mode 100644 drivers/dma/ast2600-udma.c
drivers/dma/Kconfig +9 -0
@@ -748,6 +748,15 @@ config XILINX_ZYNQMP_DPDMA driver provides the dmaengine required by the DisplayPort subsystem display driver. +config ASPEED_AST2600_UDMA + bool "Aspeed AST2600 UDMA support" + depends on ARCH_ASPEED + help + Enable support for Aspeed AST2600 UART DMA. Select this option if you + have a AST2600 SoC integrated system. The driver provides the UART DMA + support with the dmaengine subsystem, which can be leveraged by generic + 8250 serial drivers. + # driver files source "drivers/dma/bestcomm/Kconfig"
drivers/dma/Makefile +1 -0
@@ -81,6 +81,7 @@ obj-$(CONFIG_XGENE_DMA) += xgene-dma.o obj-$(CONFIG_ST_FDMA) += st_fdma.o obj-$(CONFIG_FSL_DPAA2_QDMA) += fsl-dpaa2-qdma/ obj-$(CONFIG_INTEL_LDMA) += lgm/ +obj-$(CONFIG_ASPEED_AST2600_UDMA) += ast2600-udma.o obj-y += mediatek/ obj-y += qcom/
drivers/dma/ast2600-udma.c new file +528 -0
528 lines not on this page · raw message
Signature · 1 line
2.25.1
Rob Herring
maintainerRe: [PATCH v2 3/5] dmaengine: aspeed: Add AST2600 UART DMA driver
Quoted 16 lines · Chia-Wei Wang
Aspeed AST2600 UART DMA (UDMA) includes 14 channels for the DMA transmission and recevie of each UART devices.
Signed-off-by Chia-Wei Wang <[email protected]>--- drivers/dma/Kconfig | 9 + drivers/dma/Makefile | 1 + drivers/dma/ast2600-udma.c | 528 +++++++++++++++++++++++++++++++++++++ 3 files changed, 538 insertions(+) create mode 100644 drivers/dma/ast2600-udma.cdrivers/dma/Kconfig +0
-0
drivers/dma/Kconfig config XILINX_ZYNQMP_DPDMA · line 753
Quoted 6 lines
drivers/dma/Kconfig +3
-0@@ -748,6 +748,15 @@ config XILINX_ZYNQMP_DPDMA driver provides the dmaengine required by the DisplayPort subsystem display driver. +config ASPEED_AST2600_UDMA + bool "Aspeed AST2600 UDMA support" + depends on ARCH_ASPEED
|| COMPILE_TEST
Quoted 33 lines
drivers/dma/Kconfig +6
-0+ help + Enable support for Aspeed AST2600 UART DMA. Select this option if you + have a AST2600 SoC integrated system. The driver provides the UART DMA + support with the dmaengine subsystem, which can be leveraged by generic + 8250 serial drivers. + # driver files source "drivers/dma/bestcomm/Kconfig"drivers/dma/Makefile +1
-0@@ -81,6 +81,7 @@ obj-$(CONFIG_XGENE_DMA) += xgene-dma.o obj-$(CONFIG_ST_FDMA) += st_fdma.o obj-$(CONFIG_FSL_DPAA2_QDMA) += fsl-dpaa2-qdma/ obj-$(CONFIG_INTEL_LDMA) += lgm/ +obj-$(CONFIG_ASPEED_AST2600_UDMA) += ast2600-udma.o obj-y += mediatek/ obj-y += qcom/drivers/dma/ast2600-udma.c new file +6
-0@@ -0,0 +1,528 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) ASPEED Technology Inc. +*/ +#include <linux/delay.h> +#include <linux/bitfield.h>
drivers/dma/ast2600-udma.c line 15
Quoted 10 lines
drivers/dma/ast2600-udma.c new file +9
-0+#include <linux/interrupt.h> +#include <linux/dmaengine.h> +#include <linux/dma-mapping.h> +#include <linux/platform_device.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_dma.h> +#include <linux/of_irq.h> +#include <linux/of_address.h>
You probably don't need these as you should use platform APIs instead.
RE: [PATCH v2 3/5] dmaengine: aspeed: Add AST2600 UART DMA driver
Quoted 24 lines
From: Rob Herring <[email protected]>
Sent: Saturday, March 18, 2023 5:01 AMQuoted 20 lines · Chia-Wei Wang
Aspeed AST2600 UART DMA (UDMA) includes 14 channels for the DMA transmission and recevie of each UART devices.
Signed-off-by Chia-Wei Wang <[email protected]>--- drivers/dma/Kconfig | 9 + drivers/dma/Makefile | 1 + drivers/dma/ast2600-udma.c | 528 +++++++++++++++++++++++++++++++++++++ 3 files changed, 538 insertions(+) create mode 100644 drivers/dma/ast2600-udma.cdrivers/dma/Kconfig index renamed from drivers/dma/Kconfig +0
-0
fb7073fc034f..c35f87dbafd9100644drivers/dma/Kconfig +0
-0@@ -748,6 +748,15 @@ config XILINX_ZYNQMP_DPDMA driver provides the dmaengine required by the DisplayPort subsystem display driver.
Quoted 5 lines
drivers/dma/Kconfig config XILINX_ZYNQMP_DPDMA · line 753
Quoted 3 lines
drivers/dma/Kconfig +3
-0+config ASPEED_AST2600_UDMA + bool "Aspeed AST2600 UDMA support" + depends on ARCH_ASPEED||
COMPILE_TEST
Will add it in v3 revision.
Quoted 44 lines
drivers/dma/Kconfig config XILINX_ZYNQMP_DPDMA · line 755
Quoted 3 lines
drivers/dma/Kconfig +2
-0+ help + Enable support for Aspeed AST2600 UART DMA. Select this option ifyou
drivers/dma/Kconfig config XILINX_ZYNQMP_DPDMA · line 756
Quoted 1 line
drivers/dma/Kconfig +1
-0+ have a AST2600 SoC integrated system. The driver provides the UARTDMA
drivers/dma/Kconfig config XILINX_ZYNQMP_DPDMA · line 757
Quoted 1 line
drivers/dma/Kconfig +1
-0+ support with the dmaengine subsystem, which can be leveraged bygeneric
Quoted 35 lines
drivers/dma/Kconfig +2
-0+ 8250 serial drivers. + # driver files source "drivers/dma/bestcomm/Kconfig"drivers/dma/Makefile index renamed from drivers/dma/Makefile +0
-0
a4fd1ce29510..6cbacebcdcab100644drivers/dma/Makefile +1
-0@@ -81,6 +81,7 @@ obj-$(CONFIG_XGENE_DMA) += xgene-dma.o obj-$(CONFIG_ST_FDMA) += st_fdma.o obj-$(CONFIG_FSL_DPAA2_QDMA) += fsl-dpaa2-qdma/ obj-$(CONFIG_INTEL_LDMA) += lgm/ +obj-$(CONFIG_ASPEED_AST2600_UDMA) += ast2600-udma.o obj-y += mediatek/ obj-y += qcom/drivers/dma/ast2600-udma.c new file +13
-0@@ -0,0 +1,528 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) ASPEED Technology Inc. +*/ +#include <linux/delay.h> +#include <linux/bitfield.h> +#include <linux/interrupt.h> +#include <linux/dmaengine.h> +#include <linux/dma-mapping.h> +#include <linux/platform_device.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_dma.h>
Quoted 4 lines
drivers/dma/ast2600-udma.c line 15
Quoted 2 lines
drivers/dma/ast2600-udma.c new file +2
-0+#include <linux/of_irq.h> +#include <linux/of_address.h> You probably don't need these as you should use platform APIs instead.
Will try re-compilation without these inclusion.
Thanks,
Chiawei
PATCH v2 3/5 dmaengine: aspeed: Add AST2600 UART DMA driver
In reply to Chia-Wei WangOn 14 Mar 2023 10:18:15 +0800 Chia-Wei Wang <[email protected]>
Quoted 2 lines
(quoted diff) +2
-0+static irqreturn_t ast2600_udma_isr(int irq, void *arg) +{
[...]
Quoted 5 lines
drivers/dma/ast2600-udma.c new file +5
-0+/* handle RX interrupt */ + sts =readl (udma->regs +UDMA_RX_INT_STS ); +for_each_set_bit (ch_bit, (unsigned long *)&sts, udma->n_ucs /2 ) { + ch_id = (ch_bit <<1 ) +1 ; + wptr =readl (udma->regs +UDMA_CH_WPTR (ch_id));
drivers/dma/ast2600-udma.c line 389
Quoted 10 lines
drivers/dma/ast2600-udma.c new file +10
-0+ + uc = &udma->ucs[ch_id]; + ud = &uc->ud; + tx = &ud->tx; + + uc->residue = (ud->size & ~UDMA_CH_CTRL_BUFSZ ) - wptr; + +/* handle non-4B-aligned case */ +if (ud->addr &0x3 ) { + p =phys_to_virt (dma_to_phys (uc->chan.device->dev, ud->addr));
This does not work if the dma address has no corresponding struct page.
Quoted 12 lines
drivers/dma/ast2600-udma.c new file +12
-0+memcpy (p, uc->buf, wptr); + } + +ast2600_udma_terminate (&uc->chan); + +dma_cookie_complete (tx); +dma_descriptor_unmap (tx); +dmaengine_desc_get_callback_invoke (tx,NULL ); + } + +return IRQ_HANDLED ; +}
RE: [PATCH v2 3/5] dmaengine: aspeed: Add AST2600 UART DMA driver
Quoted 26 lines
From: Hillf Danton <[email protected]>
Sent: Saturday, March 18, 2023 11:01 AMOn 14 Mar 2023 10:18:15 +0800 Chia-Wei Wang
<[email protected]>Quoted 1 line
+static
irqreturn_tast2600_udma_isr(int irq, void *arg){[...]
Quoted 5 lines
drivers/dma/ast2600-udma.c new file +5
-0+/* handle RX interrupt */ + sts =readl (udma->regs +UDMA_RX_INT_STS ); +for_each_set_bit (ch_bit, (unsigned long *)&sts, udma->n_ucs /2 ) { + ch_id = (ch_bit <<1 ) +1 ; + wptr =readl (udma->regs +UDMA_CH_WPTR (ch_id));drivers/dma/ast2600-udma.c
Quoted 10 lines
drivers/dma/ast2600-udma.c new file +10
-0+ + uc = &udma->ucs[ch_id]; + ud = &uc->ud; + tx = &ud->tx; + + uc->residue = (ud->size & ~UDMA_CH_CTRL_BUFSZ ) - wptr; + +/* handle non-4B-aligned case */ +if (ud->addr &0x3 ) { + p = phys_to_virt(dma_to_phys(uc->chan.device->dev,
ud->addr));
Quoted 1 line
This does not work if the dma address has no corresponding struct page.
Will add the error check for dma_to_phys to prevent further unexpected memory accesses.
Thanks,
Chiawei
Quoted 13 lines
Quoted 13 lines
drivers/dma/ast2600-udma.c new file +12
-0+memcpy (p, uc->buf, wptr); + } + +ast2600_udma_terminate (&uc->chan); + +dma_cookie_complete (tx); +dma_descriptor_unmap (tx); +dmaengine_desc_get_callback_invoke (tx,NULL ); + } + +return IRQ_HANDLED ; +}
PATCH v2 4/5 serial: 8250: Add AST2600 UART driver
In reply to Chia-Wei WangAdd new UART driver with DMA support for Aspeed AST2600 SoCs. The drivers mainly prepare the dma instance based on the 8250_dma implementation to leverage the AST2600 UART DMA (UDMA) engine.
--- drivers/tty/serial/8250/8250_aspeed.c | 224 ++++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 8 + drivers/tty/serial/8250/Makefile | 1 + 3 files changed, 233 insertions(+) create mode 100644 drivers/tty/serial/8250/8250_aspeed.c
drivers/tty/serial/8250/8250_aspeed.c new file +224 -0
@@ -0,0 +1,224 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) ASPEED Technology Inc. +*/ +#include <linux/device.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/serial_8250.h> +#include <linux/serial_reg.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/of_platform.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/reset.h> +#include <linux/dma-mapping.h> +#include <linux/circ_buf.h> +#include <linux/tty_flip.h> +#include <linux/pm_runtime.h> + +#include "8250.h" + +#define DEVICE_NAME "aspeed-uart" + +struct ast8250_data { +int line; +int irq; +u8 __iomem *regs; +struct reset_control *rst; +struct clk *clk; +#ifdef CONFIG_SERIAL_8250_DMA +struct uart_8250_dma dma; +#endif +}; + +#ifdef CONFIG_SERIAL_8250_DMA +static int ast8250_rx_dma (struct uart_8250_port *p); + +static void ast8250_rx_dma_complete (void *param) +{ +struct uart_8250_port *p = param; +struct uart_8250_dma *dma = p->dma; +struct tty_port *tty_port = &p->port.state->port; +struct dma_tx_state state; +int count; + +dmaengine_tx_status (dma->rxchan, dma->rx_cookie, &state); + + count = dma->rx_size - state.residue; + +tty_insert_flip_string (tty_port, dma->rx_buf, count); + p->port.icount.rx += count; + +tty_flip_buffer_push (tty_port); + +ast8250_rx_dma (p); +} + +static int ast8250_rx_dma (struct uart_8250_port *p) +{ +struct uart_8250_dma *dma = p->dma; +struct dma_async_tx_descriptor *tx; + + tx =dmaengine_prep_slave_single (dma->rxchan, dma->rx_addr, + dma->rx_size,DMA_DEV_TO_MEM , +DMA_PREP_INTERRUPT |DMA_CTRL_ACK ); +if (!tx) +return -EBUSY ; + + tx->callback = ast8250_rx_dma_complete; + tx->callback_param = p; + + dma->rx_cookie =dmaengine_submit (tx); + +dma_async_issue_pending (dma->rxchan); + +return 0 ; +} +#endif + +static int ast8250_handle_irq (struct uart_port *port) +{ +return serial8250_handle_irq (port,serial_port_in (port,UART_IIR )); +} + +static int ast8250_startup (struct uart_port *port) +{ +#ifdef CONFIG_SERIAL_8250_DMA +int rc; +struct uart_8250_port *up =up_to_u8250p (port); + + rc =serial8250_do_startup (port); +if (rc) +return rc; + +/* +* The default RX DMA is launched upon rising DR bit. +* +* However, this can result in byte lost if UART FIFO has +* been overruned before the DMA engine gets prepared and +* read the data out. This is especially common when UART +* DMA is used for file transfer. Thus we initiate RX DMA +* as early as possible. +*/ +if (up->dma) +return ast8250_rx_dma (up); + +return 0 ; +#else +return serial8250_do_startup (port); +#endif +} + +static void ast8250_shutdown (struct uart_port *port) +{ +return serial8250_do_shutdown (port); +} + +static int ast8250_probe (struct platform_device *pdev) +{ +int rc; +struct uart_8250_port uart = {}; +struct uart_port *port = &uart.port; +struct device *dev = &pdev->dev; +struct ast8250_data *data; +struct resource *res; + + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + data->irq =platform_get_irq (pdev,0 ); +if (data->irq <0 ) +return data->irq; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (res ==NULL ) { +dev_err (dev,"failed to get register base\n" ); +return -ENODEV ; + } + + data->regs =devm_ioremap (dev, res->start,resource_size (res)); +if (IS_ERR (data->regs)) { +dev_err (dev,"failed to map registers\n" ); +return PTR_ERR (data->regs); + } + + data->clk =devm_clk_get (dev,NULL ); +if (IS_ERR (data->clk)) { +dev_err (dev,"failed to get clocks\n" ); +return -ENODEV ; + } + + rc =clk_prepare_enable (data->clk); +if (rc) { +dev_err (dev,"failed to enable clock\n" ); +return rc; + } + + data->rst =devm_reset_control_get_optional_exclusive (dev,NULL ); +if (!IS_ERR (data->rst)) +reset_control_deassert (data->rst); + +spin_lock_init (&port->lock); + port->dev = dev; + port->type =PORT_16550A ; + port->irq = data->irq; + port->line =of_alias_get_id (dev->of_node,"serial" ); + port->handle_irq = ast8250_handle_irq; + port->mapbase = res->start; + port->mapsize =resource_size (res); + port->membase = data->regs; + port->uartclk =clk_get_rate (data->clk); + port->regshift =2 ; + port->iotype =UPIO_MEM32 ; + port->flags =UPF_FIXED_TYPE |UPF_FIXED_PORT |UPF_SHARE_IRQ ; + port->startup = ast8250_startup; + port->shutdown = ast8250_shutdown; + port->private_data = data; +#ifdef CONFIG_SERIAL_8250_DMA + data->dma.rxconf.src_maxburst =UART_XMIT_SIZE ; + data->dma.txconf.dst_maxburst =UART_XMIT_SIZE ; + uart.dma = &data->dma; +#endif + + data->line =serial8250_register_8250_port (&uart); +if (data->line <0 ) { +dev_err (dev,"failed to register 8250 port\n" ); +return data->line; + } + +platform_set_drvdata (pdev, data); + +return 0 ; +} + +static int ast8250_remove (struct platform_device *pdev) +{ +struct ast8250_data *data =platform_get_drvdata (pdev); + +serial8250_unregister_port (data->line); + +return 0 ; +} + +static const struct of_device_id ast8250_of_match[] = { + { .compatible ="aspeed,ast2600-uart" }, + { }, +}; + +static struct platform_driver ast8250_platform_driver = { + .driver = { + .name =DEVICE_NAME , + .of_match_table = ast8250_of_match, + }, + .probe = ast8250_probe, + .remove = ast8250_remove, +}; + +module_platform_driver (ast8250_platform_driver); + +MODULE_AUTHOR ("Chia-Wei Wang <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Aspeed 8250 UART Driver with DMA support" );
drivers/tty/serial/8250/Kconfig +8 -0
@@ -253,6 +253,14 @@ config SERIAL_8250_ACCENT To compile this driver as a module, choose M here: the module will be called 8250_accent. +config SERIAL_8250_ASPEED + tristate "Aspeed UART" + depends on ARCH_ASPEED && SERIAL_8250 + help + If you have a system using an Aspeed AST26xx SoCs and wish to + make use of its 16550A-compatible UART devices with DMA support, + say Y to this option. If unsure, say N. + config SERIAL_8250_ASPEED_VUART tristate "Aspeed Virtual UART" depends on SERIAL_8250
drivers/tty/serial/8250/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o obj-$(CONFIG_SERIAL_8250_CS) += serial_cs.o obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o obj-$(CONFIG_SERIAL_8250_ASPEED_VUART) += 8250_aspeed_vuart.o +obj-$(CONFIG_SERIAL_8250_ASPEED) += 8250_aspeed.o obj-$(CONFIG_SERIAL_8250_BCM2835AUX) += 8250_bcm2835aux.o obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
Signature · 1 line
2.25.1
PATCH v2 5/5 ARM: dts: aspeed-g6: Add UDMA node
In reply to Chia-Wei WangAdd the device tree node for the UART DMA (UDMA) controller.
--- arch/arm/boot/dts/aspeed-g6.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/boot/dts/aspeed-g6.dtsi +9 -0
@@ -863,6 +863,15 @@ fsim1: fsi at 1e79b100 { clocks = <&syscon ASPEED_CLK_GATE_FSICLK>; status = "disabled"; }; + + udma: dma-controller at 1e79e000 { + compatible = "aspeed,ast2600-udma"; + reg = <0x1e79e000 0x1000>; + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>; + dma-channels = <14>; + #dma-cells = <1>; + status = "disabled"; + }; }; }; };
Signature · 1 line
2.25.1