* [PATCH v13 0/2] add uart DMA function @ 2019-05-23 7:35 Long Cheng 2019-05-23 7:35 ` [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree Long Cheng 2019-05-23 7:35 ` [PATCH 2/2] serial: 8250-mtk: modify uart DMA rx Long Cheng 0 siblings, 2 replies; 8+ messages in thread From: Long Cheng @ 2019-05-23 7:35 UTC (permalink / raw) To: Vinod Koul, Randy Dunlap, Rob Herring, Mark Rutland, Ryder Lee, Sean Wang, Nicolas Boichat, Matthias Brugger Cc: Dan Williams, Greg Kroah-Hartman, Jiri Slaby, Sean Wang, dmaengine, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, linux-serial, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu, Long Cheng In Mediatek SOCs, the uart can support DMA function. Base on DMA engine formwork, we add the DMA code to support uart. And put the code under drivers/dma/mediatek. This series contains document bindings, Kconfig to control the function enable or not, device tree including interrupt and dma device node, the code of UART DMA Changes compared to v12 -rename parameters -remove direction Changes compared to v11 -modify TX/RX -pause function by software Changes compared to v10 -modify DMA tx status function -modify 8250_mtk for DMA rx -add notes to binding Document. Changes compared to v9 -rename dt-bindings file -remove direction from device_config -simplified code Changes compared to v8 -revise missing items Changes compared to v7: -modify apdma uart tx Changes compared to v6: -Correct spelling Changes compared to v5: -move 'requst irqs' to alloc channel -remove tasklet. Changes compared to v4: -modify Kconfig depends on. Changes compared to v3: -fix CONFIG_PM, will cause build fail Changes compared to v2: -remove unimportant parameters -instead of cookie, use APIs of virtual channel. -use of_dma_xlate_by_chan_id. Changes compared to v1: -mian revised file, 8250_mtk_dma.c --parameters renamed for standard --remove atomic operation Long Cheng (2): arm: dts: mt2712: add uart APDMA to device tree serial: 8250-mtk: modify uart DMA rx arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 51 +++++++++++++++++++++++++++++ drivers/tty/serial/8250/8250_mtk.c | 49 +++++++++++---------------- 2 files changed, 71 insertions(+), 29 deletions(-) -- 1.7.9.5 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree 2019-05-23 7:35 [PATCH v13 0/2] add uart DMA function Long Cheng @ 2019-05-23 7:35 ` Long Cheng 2019-05-23 17:04 ` Matthias Brugger 2020-05-16 16:52 ` Matthias Brugger 2019-05-23 7:35 ` [PATCH 2/2] serial: 8250-mtk: modify uart DMA rx Long Cheng 1 sibling, 2 replies; 8+ messages in thread From: Long Cheng @ 2019-05-23 7:35 UTC (permalink / raw) To: Vinod Koul, Randy Dunlap, Rob Herring, Mark Rutland, Ryder Lee, Sean Wang, Nicolas Boichat, Matthias Brugger Cc: Dan Williams, Greg Kroah-Hartman, Jiri Slaby, Sean Wang, dmaengine, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, linux-serial, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu, Long Cheng 1. add uart APDMA controller device node 2. add uart 0/1/2/3/4/5 DMA function Signed-off-by: Long Cheng <long.cheng@mediatek.com> --- arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi index 43307ba..a7a7362 100644 --- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi @@ -300,6 +300,9 @@ interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>; clocks = <&baud_clk>, <&sys_clk>; clock-names = "baud", "bus"; + dmas = <&apdma 10 + &apdma 11>; + dma-names = "tx", "rx"; status = "disabled"; }; @@ -369,6 +372,39 @@ (GIC_CPU_MASK_RAW(0x13) | IRQ_TYPE_LEVEL_HIGH)>; }; + apdma: dma-controller@11000400 { + compatible = "mediatek,mt2712-uart-dma", + "mediatek,mt6577-uart-dma"; + reg = <0 0x11000400 0 0x80>, + <0 0x11000480 0 0x80>, + <0 0x11000500 0 0x80>, + <0 0x11000580 0 0x80>, + <0 0x11000600 0 0x80>, + <0 0x11000680 0 0x80>, + <0 0x11000700 0 0x80>, + <0 0x11000780 0 0x80>, + <0 0x11000800 0 0x80>, + <0 0x11000880 0 0x80>, + <0 0x11000900 0 0x80>, + <0 0x11000980 0 0x80>; + interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 105 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 106 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 107 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 108 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 109 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 110 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 111 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 112 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>, + <GIC_SPI 114 IRQ_TYPE_LEVEL_LOW>; + dma-requests = <12>; + clocks = <&pericfg CLK_PERI_AP_DMA>; + clock-names = "apdma"; + #dma-cells = <1>; + }; + auxadc: adc@11001000 { compatible = "mediatek,mt2712-auxadc"; reg = <0 0x11001000 0 0x1000>; @@ -385,6 +421,9 @@ interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>; clocks = <&baud_clk>, <&sys_clk>; clock-names = "baud", "bus"; + dmas = <&apdma 0 + &apdma 1>; + dma-names = "tx", "rx"; status = "disabled"; }; @@ -395,6 +434,9 @@ interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_LOW>; clocks = <&baud_clk>, <&sys_clk>; clock-names = "baud", "bus"; + dmas = <&apdma 2 + &apdma 3>; + dma-names = "tx", "rx"; status = "disabled"; }; @@ -405,6 +447,9 @@ interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_LOW>; clocks = <&baud_clk>, <&sys_clk>; clock-names = "baud", "bus"; + dmas = <&apdma 4 + &apdma 5>; + dma-names = "tx", "rx"; status = "disabled"; }; @@ -415,6 +460,9 @@ interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_LOW>; clocks = <&baud_clk>, <&sys_clk>; clock-names = "baud", "bus"; + dmas = <&apdma 6 + &apdma 7>; + dma-names = "tx", "rx"; status = "disabled"; }; @@ -629,6 +677,9 @@ interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_LOW>; clocks = <&baud_clk>, <&sys_clk>; clock-names = "baud", "bus"; + dmas = <&apdma 8 + &apdma 9>; + dma-names = "tx", "rx"; status = "disabled"; }; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree 2019-05-23 7:35 ` [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree Long Cheng @ 2019-05-23 17:04 ` Matthias Brugger 2019-05-23 17:08 ` Matthias Brugger 2020-05-16 16:52 ` Matthias Brugger 1 sibling, 1 reply; 8+ messages in thread From: Matthias Brugger @ 2019-05-23 17:04 UTC (permalink / raw) To: Long Cheng, Vinod Koul, Randy Dunlap, Rob Herring, Mark Rutland, Ryder Lee, Sean Wang, Nicolas Boichat Cc: Dan Williams, Greg Kroah-Hartman, Jiri Slaby, Sean Wang, dmaengine, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, linux-serial, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu On 23/05/2019 09:35, Long Cheng wrote: > 1. add uart APDMA controller device node > 2. add uart 0/1/2/3/4/5 DMA function > > Signed-off-by: Long Cheng <long.cheng@mediatek.com> > --- > arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 51 +++++++++++++++++++++++++++++ > 1 file changed, 51 insertions(+) > > diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi > index 43307ba..a7a7362 100644 > --- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi > +++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi > @@ -300,6 +300,9 @@ > interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 10 > + &apdma 11>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -369,6 +372,39 @@ > (GIC_CPU_MASK_RAW(0x13) | IRQ_TYPE_LEVEL_HIGH)>; > }; > > + apdma: dma-controller@11000400 { > + compatible = "mediatek,mt2712-uart-dma", > + "mediatek,mt6577-uart-dma"; I was able to find a binding descpription but no actual driver. drivers/dma/mediatek only has hsdma and cqdma but no apdma driver. Seems there is something missing here. Regards, Matthias > + reg = <0 0x11000400 0 0x80>, > + <0 0x11000480 0 0x80>, > + <0 0x11000500 0 0x80>, > + <0 0x11000580 0 0x80>, > + <0 0x11000600 0 0x80>, > + <0 0x11000680 0 0x80>, > + <0 0x11000700 0 0x80>, > + <0 0x11000780 0 0x80>, > + <0 0x11000800 0 0x80>, > + <0 0x11000880 0 0x80>, > + <0 0x11000900 0 0x80>, > + <0 0x11000980 0 0x80>; > + interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 105 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 106 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 107 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 108 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 109 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 110 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 111 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 112 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 114 IRQ_TYPE_LEVEL_LOW>; > + dma-requests = <12>; > + clocks = <&pericfg CLK_PERI_AP_DMA>; > + clock-names = "apdma"; > + #dma-cells = <1>; > + }; > + > auxadc: adc@11001000 { > compatible = "mediatek,mt2712-auxadc"; > reg = <0 0x11001000 0 0x1000>; > @@ -385,6 +421,9 @@ > interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 0 > + &apdma 1>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -395,6 +434,9 @@ > interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 2 > + &apdma 3>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -405,6 +447,9 @@ > interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 4 > + &apdma 5>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -415,6 +460,9 @@ > interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 6 > + &apdma 7>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -629,6 +677,9 @@ > interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 8 > + &apdma 9>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree 2019-05-23 17:04 ` Matthias Brugger @ 2019-05-23 17:08 ` Matthias Brugger 0 siblings, 0 replies; 8+ messages in thread From: Matthias Brugger @ 2019-05-23 17:08 UTC (permalink / raw) To: Long Cheng, Vinod Koul, Randy Dunlap, Rob Herring, Mark Rutland, Ryder Lee, Sean Wang, Nicolas Boichat Cc: Dan Williams, Greg Kroah-Hartman, Jiri Slaby, Sean Wang, dmaengine, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, linux-serial, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu On 23/05/2019 19:04, Matthias Brugger wrote: > > > On 23/05/2019 09:35, Long Cheng wrote: >> 1. add uart APDMA controller device node >> 2. add uart 0/1/2/3/4/5 DMA function >> >> Signed-off-by: Long Cheng <long.cheng@mediatek.com> >> --- >> arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 51 +++++++++++++++++++++++++++++ >> 1 file changed, 51 insertions(+) >> >> diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi >> index 43307ba..a7a7362 100644 >> --- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi >> +++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi >> @@ -300,6 +300,9 @@ >> interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>; >> clocks = <&baud_clk>, <&sys_clk>; >> clock-names = "baud", "bus"; >> + dmas = <&apdma 10 >> + &apdma 11>; >> + dma-names = "tx", "rx"; >> status = "disabled"; >> }; >> >> @@ -369,6 +372,39 @@ >> (GIC_CPU_MASK_RAW(0x13) | IRQ_TYPE_LEVEL_HIGH)>; >> }; >> >> + apdma: dma-controller@11000400 { >> + compatible = "mediatek,mt2712-uart-dma", >> + "mediatek,mt6577-uart-dma"; > > I was able to find a binding descpription but no actual driver. > drivers/dma/mediatek only has hsdma and cqdma but no apdma driver. > > Seems there is something missing here. > Sorry I just realized that tje driver got merged from v12. Regards, Matthias > Regards, > Matthias > >> + reg = <0 0x11000400 0 0x80>, >> + <0 0x11000480 0 0x80>, >> + <0 0x11000500 0 0x80>, >> + <0 0x11000580 0 0x80>, >> + <0 0x11000600 0 0x80>, >> + <0 0x11000680 0 0x80>, >> + <0 0x11000700 0 0x80>, >> + <0 0x11000780 0 0x80>, >> + <0 0x11000800 0 0x80>, >> + <0 0x11000880 0 0x80>, >> + <0 0x11000900 0 0x80>, >> + <0 0x11000980 0 0x80>; >> + interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 105 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 106 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 107 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 108 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 109 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 110 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 111 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 112 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>, >> + <GIC_SPI 114 IRQ_TYPE_LEVEL_LOW>; >> + dma-requests = <12>; >> + clocks = <&pericfg CLK_PERI_AP_DMA>; >> + clock-names = "apdma"; >> + #dma-cells = <1>; >> + }; >> + >> auxadc: adc@11001000 { >> compatible = "mediatek,mt2712-auxadc"; >> reg = <0 0x11001000 0 0x1000>; >> @@ -385,6 +421,9 @@ >> interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>; >> clocks = <&baud_clk>, <&sys_clk>; >> clock-names = "baud", "bus"; >> + dmas = <&apdma 0 >> + &apdma 1>; >> + dma-names = "tx", "rx"; >> status = "disabled"; >> }; >> >> @@ -395,6 +434,9 @@ >> interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_LOW>; >> clocks = <&baud_clk>, <&sys_clk>; >> clock-names = "baud", "bus"; >> + dmas = <&apdma 2 >> + &apdma 3>; >> + dma-names = "tx", "rx"; >> status = "disabled"; >> }; >> >> @@ -405,6 +447,9 @@ >> interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_LOW>; >> clocks = <&baud_clk>, <&sys_clk>; >> clock-names = "baud", "bus"; >> + dmas = <&apdma 4 >> + &apdma 5>; >> + dma-names = "tx", "rx"; >> status = "disabled"; >> }; >> >> @@ -415,6 +460,9 @@ >> interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_LOW>; >> clocks = <&baud_clk>, <&sys_clk>; >> clock-names = "baud", "bus"; >> + dmas = <&apdma 6 >> + &apdma 7>; >> + dma-names = "tx", "rx"; >> status = "disabled"; >> }; >> >> @@ -629,6 +677,9 @@ >> interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_LOW>; >> clocks = <&baud_clk>, <&sys_clk>; >> clock-names = "baud", "bus"; >> + dmas = <&apdma 8 >> + &apdma 9>; >> + dma-names = "tx", "rx"; >> status = "disabled"; >> }; >> >> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree 2019-05-23 7:35 ` [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree Long Cheng 2019-05-23 17:04 ` Matthias Brugger @ 2020-05-16 16:52 ` Matthias Brugger 1 sibling, 0 replies; 8+ messages in thread From: Matthias Brugger @ 2020-05-16 16:52 UTC (permalink / raw) To: Long Cheng, Vinod Koul, Randy Dunlap, Rob Herring, Mark Rutland, Ryder Lee, Sean Wang, Nicolas Boichat Cc: Dan Williams, Greg Kroah-Hartman, Jiri Slaby, Sean Wang, dmaengine, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, linux-serial, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu On 23/05/2019 09:35, Long Cheng wrote: > 1. add uart APDMA controller device node > 2. add uart 0/1/2/3/4/5 DMA function Due to the fact that 2/2 is not yet applied, please rephrase the commit message and rebase on current mainline kernel. Thanks Matthias > > Signed-off-by: Long Cheng <long.cheng@mediatek.com> > --- > arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 51 +++++++++++++++++++++++++++++ > 1 file changed, 51 insertions(+) > > diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi > index 43307ba..a7a7362 100644 > --- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi > +++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi > @@ -300,6 +300,9 @@ > interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 10 > + &apdma 11>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -369,6 +372,39 @@ > (GIC_CPU_MASK_RAW(0x13) | IRQ_TYPE_LEVEL_HIGH)>; > }; > > + apdma: dma-controller@11000400 { > + compatible = "mediatek,mt2712-uart-dma", > + "mediatek,mt6577-uart-dma"; > + reg = <0 0x11000400 0 0x80>, > + <0 0x11000480 0 0x80>, > + <0 0x11000500 0 0x80>, > + <0 0x11000580 0 0x80>, > + <0 0x11000600 0 0x80>, > + <0 0x11000680 0 0x80>, > + <0 0x11000700 0 0x80>, > + <0 0x11000780 0 0x80>, > + <0 0x11000800 0 0x80>, > + <0 0x11000880 0 0x80>, > + <0 0x11000900 0 0x80>, > + <0 0x11000980 0 0x80>; > + interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 105 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 106 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 107 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 108 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 109 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 110 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 111 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 112 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>, > + <GIC_SPI 114 IRQ_TYPE_LEVEL_LOW>; > + dma-requests = <12>; > + clocks = <&pericfg CLK_PERI_AP_DMA>; > + clock-names = "apdma"; > + #dma-cells = <1>; > + }; > + > auxadc: adc@11001000 { > compatible = "mediatek,mt2712-auxadc"; > reg = <0 0x11001000 0 0x1000>; > @@ -385,6 +421,9 @@ > interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 0 > + &apdma 1>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -395,6 +434,9 @@ > interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 2 > + &apdma 3>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -405,6 +447,9 @@ > interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 4 > + &apdma 5>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -415,6 +460,9 @@ > interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 6 > + &apdma 7>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > @@ -629,6 +677,9 @@ > interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_LOW>; > clocks = <&baud_clk>, <&sys_clk>; > clock-names = "baud", "bus"; > + dmas = <&apdma 8 > + &apdma 9>; > + dma-names = "tx", "rx"; > status = "disabled"; > }; > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] serial: 8250-mtk: modify uart DMA rx 2019-05-23 7:35 [PATCH v13 0/2] add uart DMA function Long Cheng 2019-05-23 7:35 ` [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree Long Cheng @ 2019-05-23 7:35 ` Long Cheng 2019-05-27 6:40 ` Vinod Koul 2019-05-30 9:34 ` Long Cheng 1 sibling, 2 replies; 8+ messages in thread From: Long Cheng @ 2019-05-23 7:35 UTC (permalink / raw) To: Vinod Koul, Randy Dunlap, Rob Herring, Mark Rutland, Ryder Lee, Sean Wang, Nicolas Boichat, Matthias Brugger Cc: Dan Williams, Greg Kroah-Hartman, Jiri Slaby, Sean Wang, dmaengine, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, linux-serial, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu, Long Cheng Modify uart rx and complete for DMA Signed-off-by: Long Cheng <long.cheng@mediatek.com> --- drivers/tty/serial/8250/8250_mtk.c | 49 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c index 417c7c8..f470ded 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -47,7 +47,6 @@ #define MTK_UART_DMA_EN_RX 0x5 #define MTK_UART_ESCAPE_CHAR 0x77 /* Escape char added under sw fc */ -#define MTK_UART_TX_SIZE UART_XMIT_SIZE #define MTK_UART_RX_SIZE 0x8000 #define MTK_UART_TX_TRIGGER 1 #define MTK_UART_RX_TRIGGER MTK_UART_RX_SIZE @@ -89,28 +88,30 @@ static void mtk8250_dma_rx_complete(void *param) struct mtk8250_data *data = up->port.private_data; struct tty_port *tty_port = &up->port.state->port; struct dma_tx_state state; + int copied, total, cnt; unsigned char *ptr; - int copied; - dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr, - dma->rx_size, DMA_FROM_DEVICE); + if (data->rx_status == DMA_RX_SHUTDOWN) + return; dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); + total = dma->rx_size - state.residue; + cnt = total; - if (data->rx_status == DMA_RX_SHUTDOWN) - return; + if ((data->rx_pos + cnt) > dma->rx_size) + cnt = dma->rx_size - data->rx_pos; - if ((data->rx_pos + state.residue) <= dma->rx_size) { - ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); - copied = tty_insert_flip_string(tty_port, ptr, state.residue); - } else { - ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); - copied = tty_insert_flip_string(tty_port, ptr, - dma->rx_size - data->rx_pos); + ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); + copied = tty_insert_flip_string(tty_port, ptr, cnt); + data->rx_pos += cnt; + + if (total > cnt) { ptr = (unsigned char *)(dma->rx_buf); - copied += tty_insert_flip_string(tty_port, ptr, - data->rx_pos + state.residue - dma->rx_size); + cnt = total - cnt; + copied += tty_insert_flip_string(tty_port, ptr, cnt); + data->rx_pos = cnt; } + up->port.icount.rx += copied; tty_flip_buffer_push(tty_port); @@ -121,9 +122,7 @@ static void mtk8250_dma_rx_complete(void *param) static void mtk8250_rx_dma(struct uart_8250_port *up) { struct uart_8250_dma *dma = up->dma; - struct mtk8250_data *data = up->port.private_data; struct dma_async_tx_descriptor *desc; - struct dma_tx_state state; desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr, dma->rx_size, DMA_DEV_TO_MEM, @@ -138,12 +137,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up) dma->rx_cookie = dmaengine_submit(desc); - dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); - data->rx_pos = state.residue; - - dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr, - dma->rx_size, DMA_FROM_DEVICE); - dma_async_issue_pending(dma->rxchan); } @@ -156,13 +149,11 @@ static void mtk8250_dma_enable(struct uart_8250_port *up) if (data->rx_status != DMA_RX_START) return; - dma->rxconf.direction = DMA_DEV_TO_MEM; - dma->rxconf.src_addr_width = dma->rx_size / 1024; - dma->rxconf.src_addr = dma->rx_addr; + dma->rxconf.src_port_window_size = dma->rx_size; + dma->rxconf.src_addr = dma->rx_addr; - dma->txconf.direction = DMA_MEM_TO_DEV; - dma->txconf.dst_addr_width = MTK_UART_TX_SIZE / 1024; - dma->txconf.dst_addr = dma->tx_addr; + dma->txconf.dst_port_window_size = UART_XMIT_SIZE; + dma->txconf.dst_addr = dma->tx_addr; serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] serial: 8250-mtk: modify uart DMA rx 2019-05-23 7:35 ` [PATCH 2/2] serial: 8250-mtk: modify uart DMA rx Long Cheng @ 2019-05-27 6:40 ` Vinod Koul 2019-05-30 9:34 ` Long Cheng 1 sibling, 0 replies; 8+ messages in thread From: Vinod Koul @ 2019-05-27 6:40 UTC (permalink / raw) To: Long Cheng Cc: Randy Dunlap, Rob Herring, Mark Rutland, Ryder Lee, Sean Wang, Nicolas Boichat, Matthias Brugger, Dan Williams, Greg Kroah-Hartman, Jiri Slaby, Sean Wang, dmaengine, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, linux-serial, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu On 23-05-19, 15:35, Long Cheng wrote: > Modify uart rx and complete for DMA Reviewed-by: Vinod Koul <vkoul@kernel.org> -- ~Vinod ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] serial: 8250-mtk: modify uart DMA rx 2019-05-23 7:35 ` [PATCH 2/2] serial: 8250-mtk: modify uart DMA rx Long Cheng 2019-05-27 6:40 ` Vinod Koul @ 2019-05-30 9:34 ` Long Cheng 1 sibling, 0 replies; 8+ messages in thread From: Long Cheng @ 2019-05-30 9:34 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: Vinod Koul, Randy Dunlap, Rob Herring, Mark Rutland, Ryder Lee, Sean Wang, Nicolas Boichat, Matthias Brugger, Dan Williams, Greg Kroah-Hartman, Jiri Slaby, Sean Wang, dmaengine, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, linux-serial, srv_heupstream, Yingjoe Chen, YT Shen, Zhenbao Liu, Long Cheng, Changqi Hu On Thu, 2019-05-23 at 15:35 +0800, Long Cheng wrote: Hi Greg, Just a gentle ping! thanks. > Modify uart rx and complete for DMA > > Signed-off-by: Long Cheng <long.cheng@mediatek.com> > --- > drivers/tty/serial/8250/8250_mtk.c | 49 +++++++++++++++--------------------- > 1 file changed, 20 insertions(+), 29 deletions(-) > > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c > index 417c7c8..f470ded 100644 > --- a/drivers/tty/serial/8250/8250_mtk.c > +++ b/drivers/tty/serial/8250/8250_mtk.c > @@ -47,7 +47,6 @@ > #define MTK_UART_DMA_EN_RX 0x5 > > #define MTK_UART_ESCAPE_CHAR 0x77 /* Escape char added under sw fc */ > -#define MTK_UART_TX_SIZE UART_XMIT_SIZE > #define MTK_UART_RX_SIZE 0x8000 > #define MTK_UART_TX_TRIGGER 1 > #define MTK_UART_RX_TRIGGER MTK_UART_RX_SIZE > @@ -89,28 +88,30 @@ static void mtk8250_dma_rx_complete(void *param) > struct mtk8250_data *data = up->port.private_data; > struct tty_port *tty_port = &up->port.state->port; > struct dma_tx_state state; > + int copied, total, cnt; > unsigned char *ptr; > - int copied; > > - dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr, > - dma->rx_size, DMA_FROM_DEVICE); > + if (data->rx_status == DMA_RX_SHUTDOWN) > + return; > > dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); > + total = dma->rx_size - state.residue; > + cnt = total; > > - if (data->rx_status == DMA_RX_SHUTDOWN) > - return; > + if ((data->rx_pos + cnt) > dma->rx_size) > + cnt = dma->rx_size - data->rx_pos; > > - if ((data->rx_pos + state.residue) <= dma->rx_size) { > - ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); > - copied = tty_insert_flip_string(tty_port, ptr, state.residue); > - } else { > - ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); > - copied = tty_insert_flip_string(tty_port, ptr, > - dma->rx_size - data->rx_pos); > + ptr = (unsigned char *)(data->rx_pos + dma->rx_buf); > + copied = tty_insert_flip_string(tty_port, ptr, cnt); > + data->rx_pos += cnt; > + > + if (total > cnt) { > ptr = (unsigned char *)(dma->rx_buf); > - copied += tty_insert_flip_string(tty_port, ptr, > - data->rx_pos + state.residue - dma->rx_size); > + cnt = total - cnt; > + copied += tty_insert_flip_string(tty_port, ptr, cnt); > + data->rx_pos = cnt; > } > + > up->port.icount.rx += copied; > > tty_flip_buffer_push(tty_port); > @@ -121,9 +122,7 @@ static void mtk8250_dma_rx_complete(void *param) > static void mtk8250_rx_dma(struct uart_8250_port *up) > { > struct uart_8250_dma *dma = up->dma; > - struct mtk8250_data *data = up->port.private_data; > struct dma_async_tx_descriptor *desc; > - struct dma_tx_state state; > > desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr, > dma->rx_size, DMA_DEV_TO_MEM, > @@ -138,12 +137,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up) > > dma->rx_cookie = dmaengine_submit(desc); > > - dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); > - data->rx_pos = state.residue; > - > - dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr, > - dma->rx_size, DMA_FROM_DEVICE); > - > dma_async_issue_pending(dma->rxchan); > } > > @@ -156,13 +149,11 @@ static void mtk8250_dma_enable(struct uart_8250_port *up) > if (data->rx_status != DMA_RX_START) > return; > > - dma->rxconf.direction = DMA_DEV_TO_MEM; > - dma->rxconf.src_addr_width = dma->rx_size / 1024; > - dma->rxconf.src_addr = dma->rx_addr; > + dma->rxconf.src_port_window_size = dma->rx_size; > + dma->rxconf.src_addr = dma->rx_addr; > > - dma->txconf.direction = DMA_MEM_TO_DEV; > - dma->txconf.dst_addr_width = MTK_UART_TX_SIZE / 1024; > - dma->txconf.dst_addr = dma->tx_addr; > + dma->txconf.dst_port_window_size = UART_XMIT_SIZE; > + dma->txconf.dst_addr = dma->tx_addr; > > serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | > UART_FCR_CLEAR_XMIT); ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-05-16 16:52 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-05-23 7:35 [PATCH v13 0/2] add uart DMA function Long Cheng 2019-05-23 7:35 ` [PATCH v13 1/2] arm: dts: mt2712: add uart APDMA to device tree Long Cheng 2019-05-23 17:04 ` Matthias Brugger 2019-05-23 17:08 ` Matthias Brugger 2020-05-16 16:52 ` Matthias Brugger 2019-05-23 7:35 ` [PATCH 2/2] serial: 8250-mtk: modify uart DMA rx Long Cheng 2019-05-27 6:40 ` Vinod Koul 2019-05-30 9:34 ` Long Cheng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).