Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'dmaengine-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine

Pull dmaengine updates from Vinod Koul:
"New controller support and updates to drivers.

New support:
- Qualcomm SM6115 and QCM2290 dmaengine support
- at_xdma support for microchip,sam9x7 controller

Updates:
- idxd updates for wq simplification and ats knob updates
- fsl edma updates for v3 support
- Xilinx AXI4-Stream control support
- Yaml conversion for bcm dma binding"

* tag 'dmaengine-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: (53 commits)
dmaengine: fsl-edma: integrate v3 support
dt-bindings: fsl-dma: fsl-edma: add edma3 compatible string
dmaengine: fsl-edma: move tcd into struct fsl_dma_chan
dmaengine: fsl-edma: refactor chan_name setup and safety
dmaengine: fsl-edma: move clearing of register interrupt into setup_irq function
dmaengine: fsl-edma: refactor using devm_clk_get_enabled
dmaengine: fsl-edma: simply ATTR_DSIZE and ATTR_SSIZE by using ffs()
dmaengine: fsl-edma: move common IRQ handler to common.c
dmaengine: fsl-edma: Remove enum edma_version
dmaengine: fsl-edma: transition from bool fields to bitmask flags in drvdata
dmaengine: fsl-edma: clean up EXPORT_SYMBOL_GPL in fsl-edma-common.c
dmaengine: fsl-edma: fix build error when arch is s390
dmaengine: idxd: Fix issues with PRS disable sysfs knob
dmaengine: idxd: Allow ATS disable update only for configurable devices
dmaengine: xilinx_dma: Program interrupt delay timeout
dmaengine: xilinx_dma: Use tasklet_hi_schedule for timing critical usecase
dmaengine: xilinx_dma: Freeup active list based on descriptor completion bit
dmaengine: xilinx_dma: Increase AXI DMA transaction segment count
dmaengine: xilinx_dma: Pass AXI4-Stream control words to dma client
dt-bindings: dmaengine: xilinx_dma: Add xlnx,irq-delay property
...

+1000 -2873
+1 -1
Documentation/ABI/stable/sysfs-driver-dma-idxd
··· 84 84 Date: Oct 27, 2020 85 85 KernelVersion: 5.11.0 86 86 Contact: dmaengine@vger.kernel.org 87 - Description: To indicate if PASID (process address space identifier) is 87 + Description: To indicate if user PASID (process address space identifier) is 88 88 enabled or not for this device. 89 89 90 90 What: /sys/bus/dsa/devices/dsa<m>/state
+2 -1
Documentation/devicetree/bindings/dma/atmel-xdma.txt
··· 3 3 * XDMA Controller 4 4 Required properties: 5 5 - compatible: Should be "atmel,sama5d4-dma", "microchip,sam9x60-dma" or 6 - "microchip,sama7g5-dma". 6 + "microchip,sama7g5-dma" or 7 + "microchip,sam9x7-dma", "atmel,sama5d4-dma". 7 8 - reg: Should contain DMA registers location and length. 8 9 - interrupts: Should contain DMA interrupt. 9 10 - #dma-cells: Must be <1>, used to represent the number of integer cells in
-83
Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.txt
··· 1 - * BCM2835 DMA controller 2 - 3 - The BCM2835 DMA controller has 16 channels in total. 4 - Only the lower 13 channels have an associated IRQ. 5 - Some arbitrary channels are used by the firmware 6 - (1,3,6,7 in the current firmware version). 7 - The channels 0,2 and 3 have special functionality 8 - and should not be used by the driver. 9 - 10 - Required properties: 11 - - compatible: Should be "brcm,bcm2835-dma". 12 - - reg: Should contain DMA registers location and length. 13 - - interrupts: Should contain the DMA interrupts associated 14 - to the DMA channels in ascending order. 15 - - interrupt-names: Should contain the names of the interrupt 16 - in the form "dmaXX". 17 - Use "dma-shared-all" for the common interrupt line 18 - that is shared by all dma channels. 19 - - #dma-cells: Must be <1>, the cell in the dmas property of the 20 - client device represents the DREQ number. 21 - - brcm,dma-channel-mask: Bit mask representing the channels 22 - not used by the firmware in ascending order, 23 - i.e. first channel corresponds to LSB. 24 - 25 - Example: 26 - 27 - dma: dma@7e007000 { 28 - compatible = "brcm,bcm2835-dma"; 29 - reg = <0x7e007000 0xf00>; 30 - interrupts = <1 16>, 31 - <1 17>, 32 - <1 18>, 33 - <1 19>, 34 - <1 20>, 35 - <1 21>, 36 - <1 22>, 37 - <1 23>, 38 - <1 24>, 39 - <1 25>, 40 - <1 26>, 41 - /* dma channel 11-14 share one irq */ 42 - <1 27>, 43 - <1 27>, 44 - <1 27>, 45 - <1 27>, 46 - /* unused shared irq for all channels */ 47 - <1 28>; 48 - interrupt-names = "dma0", 49 - "dma1", 50 - "dma2", 51 - "dma3", 52 - "dma4", 53 - "dma5", 54 - "dma6", 55 - "dma7", 56 - "dma8", 57 - "dma9", 58 - "dma10", 59 - "dma11", 60 - "dma12", 61 - "dma13", 62 - "dma14", 63 - "dma-shared-all"; 64 - 65 - #dma-cells = <1>; 66 - brcm,dma-channel-mask = <0x7f35>; 67 - }; 68 - 69 - 70 - DMA clients connected to the BCM2835 DMA controller must use the format 71 - described in the dma.txt file, using a two-cell specifier for each channel. 72 - 73 - Example: 74 - 75 - bcm2835_i2s: i2s@7e203000 { 76 - compatible = "brcm,bcm2835-i2s"; 77 - reg = < 0x7e203000 0x24>; 78 - clocks = <&clocks BCM2835_CLOCK_PCM>; 79 - 80 - dmas = <&dma 2>, 81 - <&dma 3>; 82 - dma-names = "tx", "rx"; 83 - };
+102
Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/dma/brcm,bcm2835-dma.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: BCM2835 DMA controller 8 + 9 + maintainers: 10 + - Nicolas Saenz Julienne <nsaenz@kernel.org> 11 + 12 + description: 13 + The BCM2835 DMA controller has 16 channels in total. Only the lower 14 + 13 channels have an associated IRQ. Some arbitrary channels are used by the 15 + VideoCore firmware (1,3,6,7 in the current firmware version). The channels 16 + 0, 2 and 3 have special functionality and should not be used by the driver. 17 + 18 + allOf: 19 + - $ref: dma-controller.yaml# 20 + 21 + properties: 22 + compatible: 23 + const: brcm,bcm2835-dma 24 + 25 + reg: 26 + maxItems: 1 27 + 28 + interrupts: 29 + description: 30 + Should contain the DMA interrupts associated to the DMA channels in 31 + ascending order. 32 + minItems: 1 33 + maxItems: 16 34 + 35 + interrupt-names: 36 + minItems: 1 37 + maxItems: 16 38 + 39 + '#dma-cells': 40 + description: The single cell represents the DREQ number. 41 + const: 1 42 + 43 + brcm,dma-channel-mask: 44 + $ref: /schemas/types.yaml#/definitions/uint32 45 + description: 46 + Bitmask of available DMA channels in ascending order that are 47 + not reserved by firmware and are available to the 48 + kernel. i.e. first channel corresponds to LSB. 49 + 50 + unevaluatedProperties: false 51 + 52 + required: 53 + - compatible 54 + - reg 55 + - interrupts 56 + - "#dma-cells" 57 + - brcm,dma-channel-mask 58 + 59 + examples: 60 + - | 61 + dma-controller@7e007000 { 62 + compatible = "brcm,bcm2835-dma"; 63 + reg = <0x7e007000 0xf00>; 64 + interrupts = <1 16>, 65 + <1 17>, 66 + <1 18>, 67 + <1 19>, 68 + <1 20>, 69 + <1 21>, 70 + <1 22>, 71 + <1 23>, 72 + <1 24>, 73 + <1 25>, 74 + <1 26>, 75 + /* dma channel 11-14 share one irq */ 76 + <1 27>, 77 + <1 27>, 78 + <1 27>, 79 + <1 27>, 80 + /* unused shared irq for all channels */ 81 + <1 28>; 82 + interrupt-names = "dma0", 83 + "dma1", 84 + "dma2", 85 + "dma3", 86 + "dma4", 87 + "dma5", 88 + "dma6", 89 + "dma7", 90 + "dma8", 91 + "dma9", 92 + "dma10", 93 + "dma11", 94 + "dma12", 95 + "dma13", 96 + "dma14", 97 + "dma-shared-all"; 98 + #dma-cells = <1>; 99 + brcm,dma-channel-mask = <0x7f35>; 100 + }; 101 + 102 + ...
+99 -7
Documentation/devicetree/bindings/dma/fsl,edma.yaml
··· 21 21 - enum: 22 22 - fsl,vf610-edma 23 23 - fsl,imx7ulp-edma 24 + - fsl,imx8qm-adma 25 + - fsl,imx8qm-edma 26 + - fsl,imx93-edma3 27 + - fsl,imx93-edma4 24 28 - items: 25 29 - const: fsl,ls1028a-edma 26 30 - const: fsl,vf610-edma 27 31 28 32 reg: 29 - minItems: 2 33 + minItems: 1 30 34 maxItems: 3 31 35 32 36 interrupts: 33 - minItems: 2 34 - maxItems: 17 37 + minItems: 1 38 + maxItems: 64 35 39 36 40 interrupt-names: 37 - minItems: 2 38 - maxItems: 17 41 + minItems: 1 42 + maxItems: 64 39 43 40 44 "#dma-cells": 41 - const: 2 45 + enum: 46 + - 2 47 + - 3 42 48 43 49 dma-channels: 44 - const: 32 50 + minItems: 1 51 + maxItems: 64 45 52 46 53 clocks: 54 + minItems: 1 47 55 maxItems: 2 48 56 49 57 clock-names: 58 + minItems: 1 50 59 maxItems: 2 51 60 52 61 big-endian: ··· 78 69 properties: 79 70 compatible: 80 71 contains: 72 + enum: 73 + - fsl,imx8qm-adma 74 + - fsl,imx8qm-edma 75 + - fsl,imx93-edma3 76 + - fsl,imx93-edma4 77 + then: 78 + properties: 79 + "#dma-cells": 80 + const: 3 81 + # It is not necessary to write the interrupt name for each channel. 82 + # instead, you can simply maintain the sequential IRQ numbers as 83 + # defined for the DMA channels. 84 + interrupt-names: false 85 + clock-names: 86 + items: 87 + - const: dma 88 + clocks: 89 + maxItems: 1 90 + 91 + - if: 92 + properties: 93 + compatible: 94 + contains: 81 95 const: fsl,vf610-edma 82 96 then: 83 97 properties: 98 + clocks: 99 + minItems: 2 84 100 clock-names: 85 101 items: 86 102 - const: dmamux0 87 103 - const: dmamux1 88 104 interrupts: 105 + minItems: 2 89 106 maxItems: 2 90 107 interrupt-names: 91 108 items: 92 109 - const: edma-tx 93 110 - const: edma-err 94 111 reg: 112 + minItems: 2 95 113 maxItems: 3 114 + "#dma-cells": 115 + const: 2 116 + dma-channels: 117 + const: 32 96 118 97 119 - if: 98 120 properties: ··· 132 92 const: fsl,imx7ulp-edma 133 93 then: 134 94 properties: 95 + clock: 96 + minItems: 2 135 97 clock-names: 136 98 items: 137 99 - const: dma 138 100 - const: dmamux0 139 101 interrupts: 102 + minItems: 2 140 103 maxItems: 17 141 104 reg: 105 + minItems: 2 142 106 maxItems: 2 107 + "#dma-cells": 108 + const: 2 109 + dma-channels: 110 + const: 32 143 111 144 112 unevaluatedProperties: false 145 113 ··· 200 152 <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>; 201 153 clock-names = "dma", "dmamux0"; 202 154 clocks = <&pcc2 IMX7ULP_CLK_DMA1>, <&pcc2 IMX7ULP_CLK_DMA_MUX1>; 155 + }; 156 + 157 + - | 158 + #include <dt-bindings/interrupt-controller/arm-gic.h> 159 + #include <dt-bindings/clock/imx93-clock.h> 160 + 161 + dma-controller@44000000 { 162 + compatible = "fsl,imx93-edma3"; 163 + reg = <0x44000000 0x200000>; 164 + #dma-cells = <3>; 165 + dma-channels = <31>; 166 + interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>, 167 + <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>, 168 + <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>, 169 + <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>, 170 + <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>, 171 + <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, 172 + <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, 173 + <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, 174 + <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>, 175 + <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>, 176 + <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>, 177 + <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>, 178 + <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>, 179 + <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>, 180 + <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>, 181 + <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>, 182 + <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>, 183 + <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>, 184 + <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>, 185 + <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>, 186 + <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>, 187 + <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>, 188 + <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>, 189 + <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>, 190 + <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>, 191 + <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>, 192 + <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>, 193 + <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>, 194 + <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>, 195 + <GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>, 196 + <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>; 197 + clocks = <&clk IMX93_CLK_EDMA1_GATE>; 198 + clock-names = "dma"; 203 199 };
+23 -8
Documentation/devicetree/bindings/dma/qcom,bam-dma.yaml
··· 15 15 16 16 properties: 17 17 compatible: 18 - enum: 19 - # APQ8064, IPQ8064 and MSM8960 20 - - qcom,bam-v1.3.0 21 - # MSM8974, APQ8074 and APQ8084 22 - - qcom,bam-v1.4.0 23 - # MSM8916 and SDM845 24 - - qcom,bam-v1.7.0 18 + oneOf: 19 + - enum: 20 + # APQ8064, IPQ8064 and MSM8960 21 + - qcom,bam-v1.3.0 22 + # MSM8974, APQ8074 and APQ8084 23 + - qcom,bam-v1.4.0 24 + # MSM8916, SDM630 25 + - qcom,bam-v1.7.0 26 + - items: 27 + - enum: 28 + # SDM845, SM6115, SM8150, SM8250 and QCM2290 29 + - qcom,bam-v1.7.4 30 + - const: qcom,bam-v1.7.0 25 31 26 32 clocks: 27 33 maxItems: 1 ··· 44 38 45 39 iommus: 46 40 minItems: 1 47 - maxItems: 4 41 + maxItems: 6 48 42 49 43 num-channels: 50 44 $ref: /schemas/types.yaml#/definitions/uint32 ··· 86 80 - interrupts 87 81 - qcom,ee 88 82 - reg 83 + 84 + anyOf: 85 + - required: 86 + - qcom,powered-remotely 87 + - required: 88 + - qcom,controlled-remotely 89 + - required: 90 + - clocks 91 + - clock-names 89 92 90 93 additionalProperties: false 91 94
+6
Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt
··· 49 49 register as configured in h/w. Takes values {8...26}. If the property 50 50 is missing or invalid then the default value 23 is used. This is the 51 51 maximum value that is supported by all IP versions. 52 + 53 + Optional properties for AXI DMA: 54 + - xlnx,axistream-connected: Tells whether DMA is connected to AXI stream IP. 55 + - xlnx,irq-delay: Tells the interrupt delay timeout value. Valid range is from 56 + 0-255. Setting this value to zero disables the delay timer interrupt. 57 + 1 timeout interval = 125 * clock period of SG clock. 52 58 Optional properties for VDMA: 53 59 - xlnx,flush-fsync: Tells which channel to Flush on Frame sync. 54 60 It takes following values:
+1 -20
drivers/dma/Kconfig
··· 474 474 Support the MXS DMA engine. This engine including APBH-DMA 475 475 and APBX-DMA is integrated into some Freescale chips. 476 476 477 - config MX3_IPU 478 - bool "MX3x Image Processing Unit support" 479 - depends on ARCH_MXC 480 - select DMA_ENGINE 481 - default y 482 - help 483 - If you plan to use the Image Processing unit in the i.MX3x, say 484 - Y here. If unsure, select Y. 485 - 486 - config MX3_IPU_IRQS 487 - int "Number of dynamically mapped interrupts for IPU" 488 - depends on MX3_IPU 489 - range 2 137 490 - default 4 491 - help 492 - Out of 137 interrupt sources on i.MX31 IPU only very few are used. 493 - To avoid bloating the irq_desc[] array we allocate a sufficient 494 - number of IRQ slots and map them dynamically to specific sources. 495 - 496 477 config NBPFAXI_DMA 497 478 tristate "Renesas Type-AXI NBPF DMA support" 498 479 select DMA_ENGINE ··· 680 699 681 700 config XILINX_DMA 682 701 tristate "Xilinx AXI DMAS Engine" 683 - depends on (ARCH_ZYNQ || MICROBLAZE || ARM64) 702 + depends on HAS_IOMEM 684 703 select DMA_ENGINE 685 704 help 686 705 Enable support for Xilinx AXI VDMA Soft IP.
+4 -3
drivers/dma/Makefile
··· 32 32 obj-$(CONFIG_DW_EDMA) += dw-edma/ 33 33 obj-$(CONFIG_EP93XX_DMA) += ep93xx_dma.o 34 34 obj-$(CONFIG_FSL_DMA) += fsldma.o 35 - obj-$(CONFIG_FSL_EDMA) += fsl-edma.o fsl-edma-common.o 36 - obj-$(CONFIG_MCF_EDMA) += mcf-edma.o fsl-edma-common.o 35 + fsl-edma-objs := fsl-edma-main.o fsl-edma-common.o 36 + obj-$(CONFIG_FSL_EDMA) += fsl-edma.o 37 + mcf-edma-objs := mcf-edma-main.o fsl-edma-common.o 38 + obj-$(CONFIG_MCF_EDMA) += mcf-edma.o 37 39 obj-$(CONFIG_FSL_QDMA) += fsl-qdma.o 38 40 obj-$(CONFIG_FSL_RAID) += fsl_raid.o 39 41 obj-$(CONFIG_HISI_DMA) += hisi_dma.o ··· 57 55 obj-$(CONFIG_MV_XOR) += mv_xor.o 58 56 obj-$(CONFIG_MV_XOR_V2) += mv_xor_v2.o 59 57 obj-$(CONFIG_MXS_DMA) += mxs-dma.o 60 - obj-$(CONFIG_MX3_IPU) += ipu/ 61 58 obj-$(CONFIG_NBPFAXI_DMA) += nbpfaxi.o 62 59 obj-$(CONFIG_OWL_DMA) += owl-dma.o 63 60 obj-$(CONFIG_PCH_DMA) += pch_dma.o
+2 -1
drivers/dma/apple-admac.c
··· 10 10 #include <linux/device.h> 11 11 #include <linux/init.h> 12 12 #include <linux/module.h> 13 - #include <linux/of_device.h> 13 + #include <linux/of.h> 14 14 #include <linux/of_dma.h> 15 + #include <linux/platform_device.h> 15 16 #include <linux/reset.h> 16 17 #include <linux/spinlock.h> 17 18 #include <linux/interrupt.h>
+1 -1
drivers/dma/at_hdmac.c
··· 20 20 #include <linux/module.h> 21 21 #include <linux/of.h> 22 22 #include <linux/overflow.h> 23 - #include <linux/of_device.h> 23 + #include <linux/of_platform.h> 24 24 #include <linux/of_dma.h> 25 25 #include <linux/platform_device.h> 26 26 #include <linux/slab.h>
+3 -1
drivers/dma/bcm-sba-raid.c
··· 35 35 #include <linux/mailbox_client.h> 36 36 #include <linux/mailbox/brcm-message.h> 37 37 #include <linux/module.h> 38 - #include <linux/of_device.h> 38 + #include <linux/of.h> 39 + #include <linux/of_platform.h> 40 + #include <linux/platform_device.h> 39 41 #include <linux/slab.h> 40 42 #include <linux/raid/pq.h> 41 43
+1 -2
drivers/dma/bestcomm/bestcomm.c
··· 14 14 #include <linux/slab.h> 15 15 #include <linux/of.h> 16 16 #include <linux/of_address.h> 17 - #include <linux/of_device.h> 18 17 #include <linux/of_irq.h> 19 - #include <linux/of_platform.h> 18 + #include <linux/platform_device.h> 20 19 #include <asm/io.h> 21 20 #include <asm/irq.h> 22 21 #include <asm/mpc52xx.h>
-1
drivers/dma/dma-jz4780.c
··· 13 13 #include <linux/interrupt.h> 14 14 #include <linux/module.h> 15 15 #include <linux/of.h> 16 - #include <linux/of_device.h> 17 16 #include <linux/of_dma.h> 18 17 #include <linux/platform_device.h> 19 18 #include <linux/slab.h>
+19 -61
drivers/dma/dmaengine.c
··· 1147 1147 1148 1148 device->owner = device->dev->driver->owner; 1149 1149 1150 - if (dma_has_cap(DMA_MEMCPY, device->cap_mask) && !device->device_prep_dma_memcpy) { 1151 - dev_err(device->dev, 1152 - "Device claims capability %s, but op is not defined\n", 1153 - "DMA_MEMCPY"); 1154 - return -EIO; 1155 - } 1150 + #define CHECK_CAP(_name, _type) \ 1151 + { \ 1152 + if (dma_has_cap(_type, device->cap_mask) && !device->device_prep_##_name) { \ 1153 + dev_err(device->dev, \ 1154 + "Device claims capability %s, but op is not defined\n", \ 1155 + __stringify(_type)); \ 1156 + return -EIO; \ 1157 + } \ 1158 + } 1156 1159 1157 - if (dma_has_cap(DMA_XOR, device->cap_mask) && !device->device_prep_dma_xor) { 1158 - dev_err(device->dev, 1159 - "Device claims capability %s, but op is not defined\n", 1160 - "DMA_XOR"); 1161 - return -EIO; 1162 - } 1160 + CHECK_CAP(dma_memcpy, DMA_MEMCPY); 1161 + CHECK_CAP(dma_xor, DMA_XOR); 1162 + CHECK_CAP(dma_xor_val, DMA_XOR_VAL); 1163 + CHECK_CAP(dma_pq, DMA_PQ); 1164 + CHECK_CAP(dma_pq_val, DMA_PQ_VAL); 1165 + CHECK_CAP(dma_memset, DMA_MEMSET); 1166 + CHECK_CAP(dma_interrupt, DMA_INTERRUPT); 1167 + CHECK_CAP(dma_cyclic, DMA_CYCLIC); 1168 + CHECK_CAP(interleaved_dma, DMA_INTERLEAVE); 1163 1169 1164 - if (dma_has_cap(DMA_XOR_VAL, device->cap_mask) && !device->device_prep_dma_xor_val) { 1165 - dev_err(device->dev, 1166 - "Device claims capability %s, but op is not defined\n", 1167 - "DMA_XOR_VAL"); 1168 - return -EIO; 1169 - } 1170 - 1171 - if (dma_has_cap(DMA_PQ, device->cap_mask) && !device->device_prep_dma_pq) { 1172 - dev_err(device->dev, 1173 - "Device claims capability %s, but op is not defined\n", 1174 - "DMA_PQ"); 1175 - return -EIO; 1176 - } 1177 - 1178 - if (dma_has_cap(DMA_PQ_VAL, device->cap_mask) && !device->device_prep_dma_pq_val) { 1179 - dev_err(device->dev, 1180 - "Device claims capability %s, but op is not defined\n", 1181 - "DMA_PQ_VAL"); 1182 - return -EIO; 1183 - } 1184 - 1185 - if (dma_has_cap(DMA_MEMSET, device->cap_mask) && !device->device_prep_dma_memset) { 1186 - dev_err(device->dev, 1187 - "Device claims capability %s, but op is not defined\n", 1188 - "DMA_MEMSET"); 1189 - return -EIO; 1190 - } 1191 - 1192 - if (dma_has_cap(DMA_INTERRUPT, device->cap_mask) && !device->device_prep_dma_interrupt) { 1193 - dev_err(device->dev, 1194 - "Device claims capability %s, but op is not defined\n", 1195 - "DMA_INTERRUPT"); 1196 - return -EIO; 1197 - } 1198 - 1199 - if (dma_has_cap(DMA_CYCLIC, device->cap_mask) && !device->device_prep_dma_cyclic) { 1200 - dev_err(device->dev, 1201 - "Device claims capability %s, but op is not defined\n", 1202 - "DMA_CYCLIC"); 1203 - return -EIO; 1204 - } 1205 - 1206 - if (dma_has_cap(DMA_INTERLEAVE, device->cap_mask) && !device->device_prep_interleaved_dma) { 1207 - dev_err(device->dev, 1208 - "Device claims capability %s, but op is not defined\n", 1209 - "DMA_INTERLEAVE"); 1210 - return -EIO; 1211 - } 1212 - 1170 + #undef CHECK_CAP 1213 1171 1214 1172 if (!device->device_tx_status) { 1215 1173 dev_err(device->dev, "Device tx_status is not defined\n");
-1
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
··· 21 21 #include <linux/kernel.h> 22 22 #include <linux/module.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_device.h> 25 24 #include <linux/of_dma.h> 26 25 #include <linux/platform_device.h> 27 26 #include <linux/pm_runtime.h>
+3 -1
drivers/dma/dw/rzn1-dmamux.c
··· 5 5 * Based on TI crossbar driver written by Peter Ujfalusi <peter.ujfalusi@ti.com> 6 6 */ 7 7 #include <linux/bitops.h> 8 - #include <linux/of_device.h> 8 + #include <linux/of.h> 9 9 #include <linux/of_dma.h> 10 + #include <linux/of_platform.h> 11 + #include <linux/platform_device.h> 10 12 #include <linux/slab.h> 11 13 #include <linux/soc/renesas/r9a06g032-sysctrl.h> 12 14 #include <linux/types.h>
+1 -3
drivers/dma/ep93xx_dma.c
··· 1320 1320 struct ep93xx_dma_platform_data *pdata = dev_get_platdata(&pdev->dev); 1321 1321 struct ep93xx_dma_engine *edma; 1322 1322 struct dma_device *dma_dev; 1323 - size_t edma_size; 1324 1323 int ret, i; 1325 1324 1326 - edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan); 1327 - edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL); 1325 + edma = kzalloc(struct_size(edma, channels, pdata->num_channels), GFP_KERNEL); 1328 1326 if (!edma) 1329 1327 return -ENOMEM; 1330 1328
+209 -96
drivers/dma/fsl-edma-common.c
··· 7 7 #include <linux/module.h> 8 8 #include <linux/slab.h> 9 9 #include <linux/dma-mapping.h> 10 + #include <linux/pm_runtime.h> 11 + #include <linux/pm_domain.h> 10 12 11 13 #include "fsl-edma-common.h" 12 14 ··· 42 40 #define EDMA64_ERRH 0x28 43 41 #define EDMA64_ERRL 0x2c 44 42 45 - #define EDMA_TCD 0x1000 43 + void fsl_edma_tx_chan_handler(struct fsl_edma_chan *fsl_chan) 44 + { 45 + spin_lock(&fsl_chan->vchan.lock); 46 + 47 + if (!fsl_chan->edesc) { 48 + /* terminate_all called before */ 49 + spin_unlock(&fsl_chan->vchan.lock); 50 + return; 51 + } 52 + 53 + if (!fsl_chan->edesc->iscyclic) { 54 + list_del(&fsl_chan->edesc->vdesc.node); 55 + vchan_cookie_complete(&fsl_chan->edesc->vdesc); 56 + fsl_chan->edesc = NULL; 57 + fsl_chan->status = DMA_COMPLETE; 58 + fsl_chan->idle = true; 59 + } else { 60 + vchan_cyclic_callback(&fsl_chan->edesc->vdesc); 61 + } 62 + 63 + if (!fsl_chan->edesc) 64 + fsl_edma_xfer_desc(fsl_chan); 65 + 66 + spin_unlock(&fsl_chan->vchan.lock); 67 + } 68 + 69 + static void fsl_edma3_enable_request(struct fsl_edma_chan *fsl_chan) 70 + { 71 + u32 val, flags; 72 + 73 + flags = fsl_edma_drvflags(fsl_chan); 74 + val = edma_readl_chreg(fsl_chan, ch_sbr); 75 + /* Remote/local swapped wrongly on iMX8 QM Audio edma */ 76 + if (flags & FSL_EDMA_DRV_QUIRK_SWAPPED) { 77 + if (!fsl_chan->is_rxchan) 78 + val |= EDMA_V3_CH_SBR_RD; 79 + else 80 + val |= EDMA_V3_CH_SBR_WR; 81 + } else { 82 + if (fsl_chan->is_rxchan) 83 + val |= EDMA_V3_CH_SBR_RD; 84 + else 85 + val |= EDMA_V3_CH_SBR_WR; 86 + } 87 + 88 + if (fsl_chan->is_remote) 89 + val &= ~(EDMA_V3_CH_SBR_RD | EDMA_V3_CH_SBR_WR); 90 + 91 + edma_writel_chreg(fsl_chan, val, ch_sbr); 92 + 93 + if (flags & FSL_EDMA_DRV_HAS_CHMUX) 94 + edma_writel_chreg(fsl_chan, fsl_chan->srcid, ch_mux); 95 + 96 + val = edma_readl_chreg(fsl_chan, ch_csr); 97 + val |= EDMA_V3_CH_CSR_ERQ; 98 + edma_writel_chreg(fsl_chan, val, ch_csr); 99 + } 46 100 47 101 static void fsl_edma_enable_request(struct fsl_edma_chan *fsl_chan) 48 102 { 49 103 struct edma_regs *regs = &fsl_chan->edma->regs; 50 104 u32 ch = fsl_chan->vchan.chan.chan_id; 51 105 52 - if (fsl_chan->edma->drvdata->version == v1) { 106 + if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_SPLIT_REG) 107 + return fsl_edma3_enable_request(fsl_chan); 108 + 109 + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_WRAP_IO) { 53 110 edma_writeb(fsl_chan->edma, EDMA_SEEI_SEEI(ch), regs->seei); 54 111 edma_writeb(fsl_chan->edma, ch, regs->serq); 55 112 } else { ··· 120 59 } 121 60 } 122 61 62 + static void fsl_edma3_disable_request(struct fsl_edma_chan *fsl_chan) 63 + { 64 + u32 val = edma_readl_chreg(fsl_chan, ch_csr); 65 + u32 flags; 66 + 67 + flags = fsl_edma_drvflags(fsl_chan); 68 + 69 + if (flags & FSL_EDMA_DRV_HAS_CHMUX) 70 + edma_writel_chreg(fsl_chan, 0, ch_mux); 71 + 72 + val &= ~EDMA_V3_CH_CSR_ERQ; 73 + edma_writel_chreg(fsl_chan, val, ch_csr); 74 + } 75 + 123 76 void fsl_edma_disable_request(struct fsl_edma_chan *fsl_chan) 124 77 { 125 78 struct edma_regs *regs = &fsl_chan->edma->regs; 126 79 u32 ch = fsl_chan->vchan.chan.chan_id; 127 80 128 - if (fsl_chan->edma->drvdata->version == v1) { 81 + if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_SPLIT_REG) 82 + return fsl_edma3_disable_request(fsl_chan); 83 + 84 + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_WRAP_IO) { 129 85 edma_writeb(fsl_chan->edma, ch, regs->cerq); 130 86 edma_writeb(fsl_chan->edma, EDMA_CEEI_CEEI(ch), regs->ceei); 131 87 } else { ··· 153 75 iowrite8(EDMA_CEEI_CEEI(ch), regs->ceei); 154 76 } 155 77 } 156 - EXPORT_SYMBOL_GPL(fsl_edma_disable_request); 157 78 158 79 static void mux_configure8(struct fsl_edma_chan *fsl_chan, void __iomem *addr, 159 80 u32 off, u32 slot, bool enable) ··· 189 112 int endian_diff[4] = {3, 1, -1, -3}; 190 113 u32 dmamux_nr = fsl_chan->edma->drvdata->dmamuxs; 191 114 115 + if (!dmamux_nr) 116 + return; 117 + 192 118 chans_per_mux = fsl_chan->edma->n_chans / dmamux_nr; 193 119 ch_off = fsl_chan->vchan.chan.chan_id % chans_per_mux; 194 120 195 - if (fsl_chan->edma->drvdata->mux_swap) 121 + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_MUX_SWAP) 196 122 ch_off += endian_diff[ch_off % 4]; 197 123 198 124 muxaddr = fsl_chan->edma->muxbase[ch / chans_per_mux]; 199 125 slot = EDMAMUX_CHCFG_SOURCE(slot); 200 126 201 - if (fsl_chan->edma->drvdata->version == v3) 127 + if (fsl_chan->edma->drvdata->flags & FSL_EDMA_DRV_CONFIG32) 202 128 mux_configure32(fsl_chan, muxaddr, ch_off, slot, enable); 203 129 else 204 130 mux_configure8(fsl_chan, muxaddr, ch_off, slot, enable); 205 131 } 206 - EXPORT_SYMBOL_GPL(fsl_edma_chan_mux); 207 132 208 133 static unsigned int fsl_edma_get_tcd_attr(enum dma_slave_buswidth addr_width) 209 134 { 210 - switch (addr_width) { 211 - case 1: 212 - return EDMA_TCD_ATTR_SSIZE_8BIT | EDMA_TCD_ATTR_DSIZE_8BIT; 213 - case 2: 214 - return EDMA_TCD_ATTR_SSIZE_16BIT | EDMA_TCD_ATTR_DSIZE_16BIT; 215 - case 4: 216 - return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT; 217 - case 8: 218 - return EDMA_TCD_ATTR_SSIZE_64BIT | EDMA_TCD_ATTR_DSIZE_64BIT; 219 - default: 220 - return EDMA_TCD_ATTR_SSIZE_32BIT | EDMA_TCD_ATTR_DSIZE_32BIT; 221 - } 135 + u32 val; 136 + 137 + if (addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED) 138 + addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 139 + 140 + val = ffs(addr_width) - 1; 141 + return val | (val << 8); 222 142 } 223 143 224 144 void fsl_edma_free_desc(struct virt_dma_desc *vdesc) ··· 229 155 fsl_desc->tcd[i].ptcd); 230 156 kfree(fsl_desc); 231 157 } 232 - EXPORT_SYMBOL_GPL(fsl_edma_free_desc); 233 158 234 159 int fsl_edma_terminate_all(struct dma_chan *chan) 235 160 { ··· 243 170 vchan_get_all_descriptors(&fsl_chan->vchan, &head); 244 171 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags); 245 172 vchan_dma_desc_free_list(&fsl_chan->vchan, &head); 173 + 174 + if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_PD) 175 + pm_runtime_allow(fsl_chan->pd_dev); 176 + 246 177 return 0; 247 178 } 248 - EXPORT_SYMBOL_GPL(fsl_edma_terminate_all); 249 179 250 180 int fsl_edma_pause(struct dma_chan *chan) 251 181 { ··· 264 188 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags); 265 189 return 0; 266 190 } 267 - EXPORT_SYMBOL_GPL(fsl_edma_pause); 268 191 269 192 int fsl_edma_resume(struct dma_chan *chan) 270 193 { ··· 279 204 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags); 280 205 return 0; 281 206 } 282 - EXPORT_SYMBOL_GPL(fsl_edma_resume); 283 207 284 208 static void fsl_edma_unprep_slave_dma(struct fsl_edma_chan *fsl_chan) 285 209 { ··· 339 265 340 266 return 0; 341 267 } 342 - EXPORT_SYMBOL_GPL(fsl_edma_slave_config); 343 268 344 269 static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan, 345 270 struct virt_dma_desc *vdesc, bool in_progress) 346 271 { 347 272 struct fsl_edma_desc *edesc = fsl_chan->edesc; 348 - struct edma_regs *regs = &fsl_chan->edma->regs; 349 - u32 ch = fsl_chan->vchan.chan.chan_id; 350 273 enum dma_transfer_direction dir = edesc->dirn; 351 274 dma_addr_t cur_addr, dma_addr; 352 275 size_t len, size; 276 + u32 nbytes = 0; 353 277 int i; 354 278 355 279 /* calculate the total size in this desc */ 356 - for (len = i = 0; i < fsl_chan->edesc->n_tcds; i++) 357 - len += le32_to_cpu(edesc->tcd[i].vtcd->nbytes) 358 - * le16_to_cpu(edesc->tcd[i].vtcd->biter); 280 + for (len = i = 0; i < fsl_chan->edesc->n_tcds; i++) { 281 + nbytes = le32_to_cpu(edesc->tcd[i].vtcd->nbytes); 282 + if (nbytes & (EDMA_V3_TCD_NBYTES_DMLOE | EDMA_V3_TCD_NBYTES_SMLOE)) 283 + nbytes = EDMA_V3_TCD_NBYTES_MLOFF_NBYTES(nbytes); 284 + len += nbytes * le16_to_cpu(edesc->tcd[i].vtcd->biter); 285 + } 359 286 360 287 if (!in_progress) 361 288 return len; 362 289 363 290 if (dir == DMA_MEM_TO_DEV) 364 - cur_addr = edma_readl(fsl_chan->edma, &regs->tcd[ch].saddr); 291 + cur_addr = edma_read_tcdreg(fsl_chan, saddr); 365 292 else 366 - cur_addr = edma_readl(fsl_chan->edma, &regs->tcd[ch].daddr); 293 + cur_addr = edma_read_tcdreg(fsl_chan, daddr); 367 294 368 295 /* figure out the finished and calculate the residue */ 369 296 for (i = 0; i < fsl_chan->edesc->n_tcds; i++) { 370 - size = le32_to_cpu(edesc->tcd[i].vtcd->nbytes) 371 - * le16_to_cpu(edesc->tcd[i].vtcd->biter); 297 + nbytes = le32_to_cpu(edesc->tcd[i].vtcd->nbytes); 298 + if (nbytes & (EDMA_V3_TCD_NBYTES_DMLOE | EDMA_V3_TCD_NBYTES_SMLOE)) 299 + nbytes = EDMA_V3_TCD_NBYTES_MLOFF_NBYTES(nbytes); 300 + 301 + size = nbytes * le16_to_cpu(edesc->tcd[i].vtcd->biter); 302 + 372 303 if (dir == DMA_MEM_TO_DEV) 373 304 dma_addr = le32_to_cpu(edesc->tcd[i].vtcd->saddr); 374 305 else ··· 419 340 420 341 return fsl_chan->status; 421 342 } 422 - EXPORT_SYMBOL_GPL(fsl_edma_tx_status); 423 343 424 344 static void fsl_edma_set_tcd_regs(struct fsl_edma_chan *fsl_chan, 425 345 struct fsl_edma_hw_tcd *tcd) 426 346 { 427 - struct fsl_edma_engine *edma = fsl_chan->edma; 428 - struct edma_regs *regs = &fsl_chan->edma->regs; 429 - u32 ch = fsl_chan->vchan.chan.chan_id; 430 347 u16 csr = 0; 431 348 432 349 /* ··· 431 356 * big- or little-endian obeying the eDMA engine model endian, 432 357 * and this is performed from specific edma_write functions 433 358 */ 434 - edma_writew(edma, 0, &regs->tcd[ch].csr); 359 + edma_write_tcdreg(fsl_chan, 0, csr); 435 360 436 - edma_writel(edma, (s32)tcd->saddr, &regs->tcd[ch].saddr); 437 - edma_writel(edma, (s32)tcd->daddr, &regs->tcd[ch].daddr); 361 + edma_write_tcdreg(fsl_chan, tcd->saddr, saddr); 362 + edma_write_tcdreg(fsl_chan, tcd->daddr, daddr); 438 363 439 - edma_writew(edma, (s16)tcd->attr, &regs->tcd[ch].attr); 440 - edma_writew(edma, tcd->soff, &regs->tcd[ch].soff); 364 + edma_write_tcdreg(fsl_chan, tcd->attr, attr); 365 + edma_write_tcdreg(fsl_chan, tcd->soff, soff); 441 366 442 - edma_writel(edma, (s32)tcd->nbytes, &regs->tcd[ch].nbytes); 443 - edma_writel(edma, (s32)tcd->slast, &regs->tcd[ch].slast); 367 + edma_write_tcdreg(fsl_chan, tcd->nbytes, nbytes); 368 + edma_write_tcdreg(fsl_chan, tcd->slast, slast); 444 369 445 - edma_writew(edma, (s16)tcd->citer, &regs->tcd[ch].citer); 446 - edma_writew(edma, (s16)tcd->biter, &regs->tcd[ch].biter); 447 - edma_writew(edma, (s16)tcd->doff, &regs->tcd[ch].doff); 370 + edma_write_tcdreg(fsl_chan, tcd->citer, citer); 371 + edma_write_tcdreg(fsl_chan, tcd->biter, biter); 372 + edma_write_tcdreg(fsl_chan, tcd->doff, doff); 448 373 449 - edma_writel(edma, (s32)tcd->dlast_sga, 450 - &regs->tcd[ch].dlast_sga); 374 + edma_write_tcdreg(fsl_chan, tcd->dlast_sga, dlast_sga); 451 375 452 376 if (fsl_chan->is_sw) { 453 377 csr = le16_to_cpu(tcd->csr); ··· 454 380 tcd->csr = cpu_to_le16(csr); 455 381 } 456 382 457 - edma_writew(edma, (s16)tcd->csr, &regs->tcd[ch].csr); 383 + edma_write_tcdreg(fsl_chan, tcd->csr, csr); 458 384 } 459 385 460 386 static inline 461 - void fsl_edma_fill_tcd(struct fsl_edma_hw_tcd *tcd, u32 src, u32 dst, 387 + void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan, 388 + struct fsl_edma_hw_tcd *tcd, u32 src, u32 dst, 462 389 u16 attr, u16 soff, u32 nbytes, u32 slast, u16 citer, 463 390 u16 biter, u16 doff, u32 dlast_sga, bool major_int, 464 391 bool disable_req, bool enable_sg) 465 392 { 393 + struct dma_slave_config *cfg = &fsl_chan->cfg; 466 394 u16 csr = 0; 395 + u32 burst; 467 396 468 397 /* 469 398 * eDMA hardware SGs require the TCDs to be stored in little ··· 480 403 tcd->attr = cpu_to_le16(attr); 481 404 482 405 tcd->soff = cpu_to_le16(soff); 406 + 407 + if (fsl_chan->is_multi_fifo) { 408 + /* set mloff to support multiple fifo */ 409 + burst = cfg->direction == DMA_DEV_TO_MEM ? 410 + cfg->src_addr_width : cfg->dst_addr_width; 411 + nbytes |= EDMA_V3_TCD_NBYTES_MLOFF(-(burst * 4)); 412 + /* enable DMLOE/SMLOE */ 413 + if (cfg->direction == DMA_MEM_TO_DEV) { 414 + nbytes |= EDMA_V3_TCD_NBYTES_DMLOE; 415 + nbytes &= ~EDMA_V3_TCD_NBYTES_SMLOE; 416 + } else { 417 + nbytes |= EDMA_V3_TCD_NBYTES_SMLOE; 418 + nbytes &= ~EDMA_V3_TCD_NBYTES_DMLOE; 419 + } 420 + } 483 421 484 422 tcd->nbytes = cpu_to_le32(nbytes); 485 423 tcd->slast = cpu_to_le32(slast); ··· 513 421 514 422 if (enable_sg) 515 423 csr |= EDMA_TCD_CSR_E_SG; 424 + 425 + if (fsl_chan->is_rxchan) 426 + csr |= EDMA_TCD_CSR_ACTIVE; 427 + 428 + if (fsl_chan->is_sw) 429 + csr |= EDMA_TCD_CSR_START; 516 430 517 431 tcd->csr = cpu_to_le16(csr); 518 432 } ··· 559 461 struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan); 560 462 struct fsl_edma_desc *fsl_desc; 561 463 dma_addr_t dma_buf_next; 464 + bool major_int = true; 562 465 int sg_len, i; 563 466 u32 src_addr, dst_addr, last_sg, nbytes; 564 467 u16 soff, doff, iter; ··· 603 504 src_addr = dma_buf_next; 604 505 dst_addr = fsl_chan->dma_dev_addr; 605 506 soff = fsl_chan->cfg.dst_addr_width; 606 - doff = 0; 607 - } else { 507 + doff = fsl_chan->is_multi_fifo ? 4 : 0; 508 + } else if (direction == DMA_DEV_TO_MEM) { 608 509 src_addr = fsl_chan->dma_dev_addr; 609 510 dst_addr = dma_buf_next; 610 - soff = 0; 511 + soff = fsl_chan->is_multi_fifo ? 4 : 0; 611 512 doff = fsl_chan->cfg.src_addr_width; 513 + } else { 514 + /* DMA_DEV_TO_DEV */ 515 + src_addr = fsl_chan->cfg.src_addr; 516 + dst_addr = fsl_chan->cfg.dst_addr; 517 + soff = doff = 0; 518 + major_int = false; 612 519 } 613 520 614 - fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr, dst_addr, 521 + fsl_edma_fill_tcd(fsl_chan, fsl_desc->tcd[i].vtcd, src_addr, dst_addr, 615 522 fsl_chan->attr, soff, nbytes, 0, iter, 616 - iter, doff, last_sg, true, false, true); 523 + iter, doff, last_sg, major_int, false, true); 617 524 dma_buf_next += period_len; 618 525 } 619 526 620 527 return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); 621 528 } 622 - EXPORT_SYMBOL_GPL(fsl_edma_prep_dma_cyclic); 623 529 624 530 struct dma_async_tx_descriptor *fsl_edma_prep_slave_sg( 625 531 struct dma_chan *chan, struct scatterlist *sgl, ··· 668 564 dst_addr = fsl_chan->dma_dev_addr; 669 565 soff = fsl_chan->cfg.dst_addr_width; 670 566 doff = 0; 671 - } else { 567 + } else if (direction == DMA_DEV_TO_MEM) { 672 568 src_addr = fsl_chan->dma_dev_addr; 673 569 dst_addr = sg_dma_address(sg); 674 570 soff = 0; 675 571 doff = fsl_chan->cfg.src_addr_width; 572 + } else { 573 + /* DMA_DEV_TO_DEV */ 574 + src_addr = fsl_chan->cfg.src_addr; 575 + dst_addr = fsl_chan->cfg.dst_addr; 576 + soff = 0; 577 + doff = 0; 676 578 } 677 579 580 + /* 581 + * Choose the suitable burst length if sg_dma_len is not 582 + * multiple of burst length so that the whole transfer length is 583 + * multiple of minor loop(burst length). 584 + */ 585 + if (sg_dma_len(sg) % nbytes) { 586 + u32 width = (direction == DMA_DEV_TO_MEM) ? doff : soff; 587 + u32 burst = (direction == DMA_DEV_TO_MEM) ? 588 + fsl_chan->cfg.src_maxburst : 589 + fsl_chan->cfg.dst_maxburst; 590 + int j; 591 + 592 + for (j = burst; j > 1; j--) { 593 + if (!(sg_dma_len(sg) % (j * width))) { 594 + nbytes = j * width; 595 + break; 596 + } 597 + } 598 + /* Set burst size as 1 if there's no suitable one */ 599 + if (j == 1) 600 + nbytes = width; 601 + } 678 602 iter = sg_dma_len(sg) / nbytes; 679 603 if (i < sg_len - 1) { 680 604 last_sg = fsl_desc->tcd[(i + 1)].ptcd; 681 - fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr, 605 + fsl_edma_fill_tcd(fsl_chan, fsl_desc->tcd[i].vtcd, src_addr, 682 606 dst_addr, fsl_chan->attr, soff, 683 607 nbytes, 0, iter, iter, doff, last_sg, 684 608 false, false, true); 685 609 } else { 686 610 last_sg = 0; 687 - fsl_edma_fill_tcd(fsl_desc->tcd[i].vtcd, src_addr, 611 + fsl_edma_fill_tcd(fsl_chan, fsl_desc->tcd[i].vtcd, src_addr, 688 612 dst_addr, fsl_chan->attr, soff, 689 613 nbytes, 0, iter, iter, doff, last_sg, 690 614 true, true, false); ··· 721 589 722 590 return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); 723 591 } 724 - EXPORT_SYMBOL_GPL(fsl_edma_prep_slave_sg); 725 592 726 593 struct dma_async_tx_descriptor *fsl_edma_prep_memcpy(struct dma_chan *chan, 727 594 dma_addr_t dma_dst, dma_addr_t dma_src, ··· 737 606 fsl_chan->is_sw = true; 738 607 739 608 /* To match with copy_align and max_seg_size so 1 tcd is enough */ 740 - fsl_edma_fill_tcd(fsl_desc->tcd[0].vtcd, dma_src, dma_dst, 741 - EDMA_TCD_ATTR_SSIZE_32BYTE | EDMA_TCD_ATTR_DSIZE_32BYTE, 609 + fsl_edma_fill_tcd(fsl_chan, fsl_desc->tcd[0].vtcd, dma_src, dma_dst, 610 + fsl_edma_get_tcd_attr(DMA_SLAVE_BUSWIDTH_32_BYTES), 742 611 32, len, 0, 1, 1, 32, 0, true, true, false); 743 612 744 613 return vchan_tx_prep(&fsl_chan->vchan, &fsl_desc->vdesc, flags); 745 614 } 746 - EXPORT_SYMBOL_GPL(fsl_edma_prep_memcpy); 747 615 748 616 void fsl_edma_xfer_desc(struct fsl_edma_chan *fsl_chan) 749 617 { ··· 759 629 fsl_chan->status = DMA_IN_PROGRESS; 760 630 fsl_chan->idle = false; 761 631 } 762 - EXPORT_SYMBOL_GPL(fsl_edma_xfer_desc); 763 632 764 633 void fsl_edma_issue_pending(struct dma_chan *chan) 765 634 { ··· 778 649 779 650 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags); 780 651 } 781 - EXPORT_SYMBOL_GPL(fsl_edma_issue_pending); 782 652 783 653 int fsl_edma_alloc_chan_resources(struct dma_chan *chan) 784 654 { ··· 788 660 32, 0); 789 661 return 0; 790 662 } 791 - EXPORT_SYMBOL_GPL(fsl_edma_alloc_chan_resources); 792 663 793 664 void fsl_edma_free_chan_resources(struct dma_chan *chan) 794 665 { ··· 810 683 fsl_chan->tcd_pool = NULL; 811 684 fsl_chan->is_sw = false; 812 685 } 813 - EXPORT_SYMBOL_GPL(fsl_edma_free_chan_resources); 814 686 815 687 void fsl_edma_cleanup_vchan(struct dma_device *dmadev) 816 688 { ··· 821 695 tasklet_kill(&chan->vchan.task); 822 696 } 823 697 } 824 - EXPORT_SYMBOL_GPL(fsl_edma_cleanup_vchan); 825 698 826 699 /* 827 - * On the 32 channels Vybrid/mpc577x edma version (here called "v1"), 828 - * register offsets are different compared to ColdFire mcf5441x 64 channels 829 - * edma (here called "v2"). 700 + * On the 32 channels Vybrid/mpc577x edma version, register offsets are 701 + * different compared to ColdFire mcf5441x 64 channels edma. 830 702 * 831 703 * This function sets up register offsets as per proper declared version 832 704 * so must be called in xxx_edma_probe() just after setting the ··· 832 708 */ 833 709 void fsl_edma_setup_regs(struct fsl_edma_engine *edma) 834 710 { 711 + bool is64 = !!(edma->drvdata->flags & FSL_EDMA_DRV_EDMA64); 712 + 835 713 edma->regs.cr = edma->membase + EDMA_CR; 836 714 edma->regs.es = edma->membase + EDMA_ES; 837 715 edma->regs.erql = edma->membase + EDMA_ERQ; 838 716 edma->regs.eeil = edma->membase + EDMA_EEI; 839 717 840 - edma->regs.serq = edma->membase + ((edma->drvdata->version == v2) ? 841 - EDMA64_SERQ : EDMA_SERQ); 842 - edma->regs.cerq = edma->membase + ((edma->drvdata->version == v2) ? 843 - EDMA64_CERQ : EDMA_CERQ); 844 - edma->regs.seei = edma->membase + ((edma->drvdata->version == v2) ? 845 - EDMA64_SEEI : EDMA_SEEI); 846 - edma->regs.ceei = edma->membase + ((edma->drvdata->version == v2) ? 847 - EDMA64_CEEI : EDMA_CEEI); 848 - edma->regs.cint = edma->membase + ((edma->drvdata->version == v2) ? 849 - EDMA64_CINT : EDMA_CINT); 850 - edma->regs.cerr = edma->membase + ((edma->drvdata->version == v2) ? 851 - EDMA64_CERR : EDMA_CERR); 852 - edma->regs.ssrt = edma->membase + ((edma->drvdata->version == v2) ? 853 - EDMA64_SSRT : EDMA_SSRT); 854 - edma->regs.cdne = edma->membase + ((edma->drvdata->version == v2) ? 855 - EDMA64_CDNE : EDMA_CDNE); 856 - edma->regs.intl = edma->membase + ((edma->drvdata->version == v2) ? 857 - EDMA64_INTL : EDMA_INTR); 858 - edma->regs.errl = edma->membase + ((edma->drvdata->version == v2) ? 859 - EDMA64_ERRL : EDMA_ERR); 718 + edma->regs.serq = edma->membase + (is64 ? EDMA64_SERQ : EDMA_SERQ); 719 + edma->regs.cerq = edma->membase + (is64 ? EDMA64_CERQ : EDMA_CERQ); 720 + edma->regs.seei = edma->membase + (is64 ? EDMA64_SEEI : EDMA_SEEI); 721 + edma->regs.ceei = edma->membase + (is64 ? EDMA64_CEEI : EDMA_CEEI); 722 + edma->regs.cint = edma->membase + (is64 ? EDMA64_CINT : EDMA_CINT); 723 + edma->regs.cerr = edma->membase + (is64 ? EDMA64_CERR : EDMA_CERR); 724 + edma->regs.ssrt = edma->membase + (is64 ? EDMA64_SSRT : EDMA_SSRT); 725 + edma->regs.cdne = edma->membase + (is64 ? EDMA64_CDNE : EDMA_CDNE); 726 + edma->regs.intl = edma->membase + (is64 ? EDMA64_INTL : EDMA_INTR); 727 + edma->regs.errl = edma->membase + (is64 ? EDMA64_ERRL : EDMA_ERR); 860 728 861 - if (edma->drvdata->version == v2) { 729 + if (is64) { 862 730 edma->regs.erqh = edma->membase + EDMA64_ERQH; 863 731 edma->regs.eeih = edma->membase + EDMA64_EEIH; 864 732 edma->regs.errh = edma->membase + EDMA64_ERRH; 865 733 edma->regs.inth = edma->membase + EDMA64_INTH; 866 734 } 867 - 868 - edma->regs.tcd = edma->membase + EDMA_TCD; 869 735 } 870 - EXPORT_SYMBOL_GPL(fsl_edma_setup_regs); 871 736 872 737 MODULE_LICENSE("GPL v2");
+106 -21
drivers/dma/fsl-edma-common.h
··· 29 29 #define EDMA_TCD_ATTR_DMOD(x) (((x) & GENMASK(4, 0)) << 3) 30 30 #define EDMA_TCD_ATTR_SSIZE(x) (((x) & GENMASK(2, 0)) << 8) 31 31 #define EDMA_TCD_ATTR_SMOD(x) (((x) & GENMASK(4, 0)) << 11) 32 - #define EDMA_TCD_ATTR_DSIZE_8BIT 0 33 - #define EDMA_TCD_ATTR_DSIZE_16BIT BIT(0) 34 - #define EDMA_TCD_ATTR_DSIZE_32BIT BIT(1) 35 - #define EDMA_TCD_ATTR_DSIZE_64BIT (BIT(0) | BIT(1)) 36 - #define EDMA_TCD_ATTR_DSIZE_32BYTE (BIT(2) | BIT(0)) 37 - #define EDMA_TCD_ATTR_SSIZE_8BIT 0 38 - #define EDMA_TCD_ATTR_SSIZE_16BIT (EDMA_TCD_ATTR_DSIZE_16BIT << 8) 39 - #define EDMA_TCD_ATTR_SSIZE_32BIT (EDMA_TCD_ATTR_DSIZE_32BIT << 8) 40 - #define EDMA_TCD_ATTR_SSIZE_64BIT (EDMA_TCD_ATTR_DSIZE_64BIT << 8) 41 - #define EDMA_TCD_ATTR_SSIZE_32BYTE (EDMA_TCD_ATTR_DSIZE_32BYTE << 8) 42 32 43 33 #define EDMA_TCD_CITER_CITER(x) ((x) & GENMASK(14, 0)) 44 34 #define EDMA_TCD_BITER_BITER(x) ((x) & GENMASK(14, 0)) ··· 42 52 #define EDMA_TCD_CSR_ACTIVE BIT(6) 43 53 #define EDMA_TCD_CSR_DONE BIT(7) 44 54 55 + #define EDMA_V3_TCD_NBYTES_MLOFF_NBYTES(x) ((x) & GENMASK(9, 0)) 56 + #define EDMA_V3_TCD_NBYTES_MLOFF(x) (x << 10) 57 + #define EDMA_V3_TCD_NBYTES_DMLOE (1 << 30) 58 + #define EDMA_V3_TCD_NBYTES_SMLOE (1 << 31) 59 + 45 60 #define EDMAMUX_CHCFG_DIS 0x0 46 61 #define EDMAMUX_CHCFG_ENBL 0x80 47 62 #define EDMAMUX_CHCFG_SOURCE(n) ((n) & 0x3F) 48 63 49 64 #define DMAMUX_NR 2 50 65 66 + #define EDMA_TCD 0x1000 67 + 51 68 #define FSL_EDMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ 52 69 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ 53 70 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) | \ 54 71 BIT(DMA_SLAVE_BUSWIDTH_8_BYTES)) 72 + 73 + #define EDMA_V3_CH_SBR_RD BIT(22) 74 + #define EDMA_V3_CH_SBR_WR BIT(21) 75 + #define EDMA_V3_CH_CSR_ERQ BIT(0) 76 + #define EDMA_V3_CH_CSR_EARQ BIT(1) 77 + #define EDMA_V3_CH_CSR_EEI BIT(2) 78 + #define EDMA_V3_CH_CSR_DONE BIT(30) 79 + #define EDMA_V3_CH_CSR_ACTIVE BIT(31) 80 + 55 81 enum fsl_edma_pm_state { 56 82 RUNNING = 0, 57 83 SUSPENDED, ··· 86 80 __le16 csr; 87 81 __le16 biter; 88 82 }; 83 + 84 + struct fsl_edma3_ch_reg { 85 + __le32 ch_csr; 86 + __le32 ch_es; 87 + __le32 ch_int; 88 + __le32 ch_sbr; 89 + __le32 ch_pri; 90 + __le32 ch_mux; 91 + __le32 ch_mattr; /* edma4, reserved for edma3 */ 92 + __le32 ch_reserved; 93 + struct fsl_edma_hw_tcd tcd; 94 + } __packed; 89 95 90 96 /* 91 97 * These are iomem pointers, for both v32 and v64. ··· 121 103 void __iomem *intl; 122 104 void __iomem *errh; 123 105 void __iomem *errl; 124 - struct fsl_edma_hw_tcd __iomem *tcd; 125 106 }; 126 107 127 108 struct fsl_edma_sw_tcd { ··· 143 126 dma_addr_t dma_dev_addr; 144 127 u32 dma_dev_size; 145 128 enum dma_data_direction dma_dir; 146 - char chan_name[16]; 129 + char chan_name[32]; 130 + struct fsl_edma_hw_tcd __iomem *tcd; 131 + u32 real_count; 132 + struct work_struct issue_worker; 133 + struct platform_device *pdev; 134 + struct device *pd_dev; 135 + u32 srcid; 136 + struct clk *clk; 137 + int priority; 138 + int hw_chanid; 139 + int txirq; 140 + bool is_rxchan; 141 + bool is_remote; 142 + bool is_multi_fifo; 147 143 }; 148 144 149 145 struct fsl_edma_desc { ··· 168 138 struct fsl_edma_sw_tcd tcd[]; 169 139 }; 170 140 171 - enum edma_version { 172 - v1, /* 32ch, Vybrid, mpc57x, etc */ 173 - v2, /* 64ch Coldfire */ 174 - v3, /* 32ch, i.mx7ulp */ 175 - }; 141 + #define FSL_EDMA_DRV_HAS_DMACLK BIT(0) 142 + #define FSL_EDMA_DRV_MUX_SWAP BIT(1) 143 + #define FSL_EDMA_DRV_CONFIG32 BIT(2) 144 + #define FSL_EDMA_DRV_WRAP_IO BIT(3) 145 + #define FSL_EDMA_DRV_EDMA64 BIT(4) 146 + #define FSL_EDMA_DRV_HAS_PD BIT(5) 147 + #define FSL_EDMA_DRV_HAS_CHCLK BIT(6) 148 + #define FSL_EDMA_DRV_HAS_CHMUX BIT(7) 149 + /* imx8 QM audio edma remote local swapped */ 150 + #define FSL_EDMA_DRV_QUIRK_SWAPPED BIT(8) 151 + /* control and status register is in tcd address space, edma3 reg layout */ 152 + #define FSL_EDMA_DRV_SPLIT_REG BIT(9) 153 + #define FSL_EDMA_DRV_BUS_8BYTE BIT(10) 154 + #define FSL_EDMA_DRV_DEV_TO_DEV BIT(11) 155 + #define FSL_EDMA_DRV_ALIGN_64BYTE BIT(12) 156 + 157 + #define FSL_EDMA_DRV_EDMA3 (FSL_EDMA_DRV_SPLIT_REG | \ 158 + FSL_EDMA_DRV_BUS_8BYTE | \ 159 + FSL_EDMA_DRV_DEV_TO_DEV | \ 160 + FSL_EDMA_DRV_ALIGN_64BYTE) 176 161 177 162 struct fsl_edma_drvdata { 178 - enum edma_version version; 179 - u32 dmamuxs; 180 - bool has_dmaclk; 181 - bool mux_swap; 163 + u32 dmamuxs; /* only used before v3 */ 164 + u32 chreg_off; 165 + u32 chreg_space_sz; 166 + u32 flags; 182 167 int (*setup_irq)(struct platform_device *pdev, 183 168 struct fsl_edma_engine *fsl_edma); 184 169 }; ··· 204 159 void __iomem *muxbase[DMAMUX_NR]; 205 160 struct clk *muxclk[DMAMUX_NR]; 206 161 struct clk *dmaclk; 162 + struct clk *chclk; 207 163 struct mutex fsl_edma_mutex; 208 164 const struct fsl_edma_drvdata *drvdata; 209 165 u32 n_chans; ··· 212 166 int errirq; 213 167 bool big_endian; 214 168 struct edma_regs regs; 169 + u64 chan_masked; 215 170 struct fsl_edma_chan chans[]; 216 171 }; 172 + 173 + #define edma_read_tcdreg(chan, __name) \ 174 + (sizeof(chan->tcd->__name) == sizeof(u32) ? \ 175 + edma_readl(chan->edma, &chan->tcd->__name) : \ 176 + edma_readw(chan->edma, &chan->tcd->__name)) 177 + 178 + #define edma_write_tcdreg(chan, val, __name) \ 179 + (sizeof(chan->tcd->__name) == sizeof(u32) ? \ 180 + edma_writel(chan->edma, (u32 __force)val, &chan->tcd->__name) : \ 181 + edma_writew(chan->edma, (u16 __force)val, &chan->tcd->__name)) 182 + 183 + #define edma_readl_chreg(chan, __name) \ 184 + edma_readl(chan->edma, \ 185 + (void __iomem *)&(container_of(chan->tcd, struct fsl_edma3_ch_reg, tcd)->__name)) 186 + 187 + #define edma_writel_chreg(chan, val, __name) \ 188 + edma_writel(chan->edma, val, \ 189 + (void __iomem *)&(container_of(chan->tcd, struct fsl_edma3_ch_reg, tcd)->__name)) 217 190 218 191 /* 219 192 * R/W functions for big- or little-endian registers: ··· 246 181 return ioread32be(addr); 247 182 else 248 183 return ioread32(addr); 184 + } 185 + 186 + static inline u16 edma_readw(struct fsl_edma_engine *edma, void __iomem *addr) 187 + { 188 + if (edma->big_endian) 189 + return ioread16be(addr); 190 + else 191 + return ioread16(addr); 249 192 } 250 193 251 194 static inline void edma_writeb(struct fsl_edma_engine *edma, ··· 290 217 return container_of(chan, struct fsl_edma_chan, vchan.chan); 291 218 } 292 219 220 + static inline u32 fsl_edma_drvflags(struct fsl_edma_chan *fsl_chan) 221 + { 222 + return fsl_chan->edma->drvdata->flags; 223 + } 224 + 293 225 static inline struct fsl_edma_desc *to_fsl_edma_desc(struct virt_dma_desc *vd) 294 226 { 295 227 return container_of(vd, struct fsl_edma_desc, vdesc); 296 228 } 297 229 230 + static inline void fsl_edma_err_chan_handler(struct fsl_edma_chan *fsl_chan) 231 + { 232 + fsl_chan->status = DMA_ERROR; 233 + fsl_chan->idle = true; 234 + } 235 + 236 + void fsl_edma_tx_chan_handler(struct fsl_edma_chan *fsl_chan); 298 237 void fsl_edma_disable_request(struct fsl_edma_chan *fsl_chan); 299 238 void fsl_edma_chan_mux(struct fsl_edma_chan *fsl_chan, 300 239 unsigned int slot, bool enable);
+257 -64
drivers/dma/fsl-edma.c drivers/dma/fsl-edma-main.c
··· 18 18 #include <linux/of_irq.h> 19 19 #include <linux/of_dma.h> 20 20 #include <linux/dma-mapping.h> 21 + #include <linux/pm_runtime.h> 22 + #include <linux/pm_domain.h> 21 23 22 24 #include "fsl-edma-common.h" 25 + 26 + #define ARGS_RX BIT(0) 27 + #define ARGS_REMOTE BIT(1) 28 + #define ARGS_MULTI_FIFO BIT(2) 23 29 24 30 static void fsl_edma_synchronize(struct dma_chan *chan) 25 31 { ··· 39 33 struct fsl_edma_engine *fsl_edma = dev_id; 40 34 unsigned int intr, ch; 41 35 struct edma_regs *regs = &fsl_edma->regs; 42 - struct fsl_edma_chan *fsl_chan; 43 36 44 37 intr = edma_readl(fsl_edma, regs->intl); 45 38 if (!intr) ··· 47 42 for (ch = 0; ch < fsl_edma->n_chans; ch++) { 48 43 if (intr & (0x1 << ch)) { 49 44 edma_writeb(fsl_edma, EDMA_CINT_CINT(ch), regs->cint); 50 - 51 - fsl_chan = &fsl_edma->chans[ch]; 52 - 53 - spin_lock(&fsl_chan->vchan.lock); 54 - 55 - if (!fsl_chan->edesc) { 56 - /* terminate_all called before */ 57 - spin_unlock(&fsl_chan->vchan.lock); 58 - continue; 59 - } 60 - 61 - if (!fsl_chan->edesc->iscyclic) { 62 - list_del(&fsl_chan->edesc->vdesc.node); 63 - vchan_cookie_complete(&fsl_chan->edesc->vdesc); 64 - fsl_chan->edesc = NULL; 65 - fsl_chan->status = DMA_COMPLETE; 66 - fsl_chan->idle = true; 67 - } else { 68 - vchan_cyclic_callback(&fsl_chan->edesc->vdesc); 69 - } 70 - 71 - if (!fsl_chan->edesc) 72 - fsl_edma_xfer_desc(fsl_chan); 73 - 74 - spin_unlock(&fsl_chan->vchan.lock); 45 + fsl_edma_tx_chan_handler(&fsl_edma->chans[ch]); 75 46 } 76 47 } 48 + return IRQ_HANDLED; 49 + } 50 + 51 + static irqreturn_t fsl_edma3_tx_handler(int irq, void *dev_id) 52 + { 53 + struct fsl_edma_chan *fsl_chan = dev_id; 54 + unsigned int intr; 55 + 56 + intr = edma_readl_chreg(fsl_chan, ch_int); 57 + if (!intr) 58 + return IRQ_HANDLED; 59 + 60 + edma_writel_chreg(fsl_chan, 1, ch_int); 61 + 62 + fsl_edma_tx_chan_handler(fsl_chan); 63 + 77 64 return IRQ_HANDLED; 78 65 } 79 66 ··· 83 86 if (err & (0x1 << ch)) { 84 87 fsl_edma_disable_request(&fsl_edma->chans[ch]); 85 88 edma_writeb(fsl_edma, EDMA_CERR_CERR(ch), regs->cerr); 86 - fsl_edma->chans[ch].status = DMA_ERROR; 87 - fsl_edma->chans[ch].idle = true; 89 + fsl_edma_err_chan_handler(&fsl_edma->chans[ch]); 88 90 } 89 91 } 90 92 return IRQ_HANDLED; ··· 130 134 return NULL; 131 135 } 132 136 137 + static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec, 138 + struct of_dma *ofdma) 139 + { 140 + struct fsl_edma_engine *fsl_edma = ofdma->of_dma_data; 141 + struct dma_chan *chan, *_chan; 142 + struct fsl_edma_chan *fsl_chan; 143 + bool b_chmux; 144 + int i; 145 + 146 + if (dma_spec->args_count != 3) 147 + return NULL; 148 + 149 + b_chmux = !!(fsl_edma->drvdata->flags & FSL_EDMA_DRV_HAS_CHMUX); 150 + 151 + mutex_lock(&fsl_edma->fsl_edma_mutex); 152 + list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, 153 + device_node) { 154 + 155 + if (chan->client_count) 156 + continue; 157 + 158 + fsl_chan = to_fsl_edma_chan(chan); 159 + i = fsl_chan - fsl_edma->chans; 160 + 161 + chan = dma_get_slave_channel(chan); 162 + chan->device->privatecnt++; 163 + fsl_chan->priority = dma_spec->args[1]; 164 + fsl_chan->is_rxchan = dma_spec->args[2] & ARGS_RX; 165 + fsl_chan->is_remote = dma_spec->args[2] & ARGS_REMOTE; 166 + fsl_chan->is_multi_fifo = dma_spec->args[2] & ARGS_MULTI_FIFO; 167 + 168 + if (!b_chmux && i == dma_spec->args[0]) { 169 + mutex_unlock(&fsl_edma->fsl_edma_mutex); 170 + return chan; 171 + } else if (b_chmux && !fsl_chan->srcid) { 172 + /* if controller support channel mux, choose a free channel */ 173 + fsl_chan->srcid = dma_spec->args[0]; 174 + mutex_unlock(&fsl_edma->fsl_edma_mutex); 175 + return chan; 176 + } 177 + } 178 + mutex_unlock(&fsl_edma->fsl_edma_mutex); 179 + return NULL; 180 + } 181 + 133 182 static int 134 183 fsl_edma_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) 135 184 { 136 185 int ret; 186 + 187 + edma_writel(fsl_edma, ~0, fsl_edma->regs.intl); 137 188 138 189 fsl_edma->txirq = platform_get_irq_byname(pdev, "edma-tx"); 139 190 if (fsl_edma->txirq < 0) ··· 216 173 return 0; 217 174 } 218 175 176 + static int fsl_edma3_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) 177 + { 178 + int ret; 179 + int i; 180 + 181 + for (i = 0; i < fsl_edma->n_chans; i++) { 182 + 183 + struct fsl_edma_chan *fsl_chan = &fsl_edma->chans[i]; 184 + 185 + if (fsl_edma->chan_masked & BIT(i)) 186 + continue; 187 + 188 + /* request channel irq */ 189 + fsl_chan->txirq = platform_get_irq(pdev, i); 190 + if (fsl_chan->txirq < 0) { 191 + dev_err(&pdev->dev, "Can't get chan %d's irq.\n", i); 192 + return -EINVAL; 193 + } 194 + 195 + ret = devm_request_irq(&pdev->dev, fsl_chan->txirq, 196 + fsl_edma3_tx_handler, IRQF_SHARED, 197 + fsl_chan->chan_name, fsl_chan); 198 + if (ret) { 199 + dev_err(&pdev->dev, "Can't register chan%d's IRQ.\n", i); 200 + return -EINVAL; 201 + } 202 + } 203 + 204 + return 0; 205 + } 206 + 219 207 static int 220 208 fsl_edma2_irq_init(struct platform_device *pdev, 221 209 struct fsl_edma_engine *fsl_edma) 222 210 { 223 211 int i, ret, irq; 224 212 int count; 213 + 214 + edma_writel(fsl_edma, ~0, fsl_edma->regs.intl); 225 215 226 216 count = platform_irq_count(pdev); 227 217 dev_dbg(&pdev->dev, "%s Found %d interrupts\r\n", __func__, count); ··· 272 196 irq = platform_get_irq(pdev, i); 273 197 if (irq < 0) 274 198 return -ENXIO; 275 - 276 - sprintf(fsl_edma->chans[i].chan_name, "eDMA2-CH%02d", i); 277 199 278 200 /* The last IRQ is for eDMA err */ 279 201 if (i == count - 1) ··· 310 236 } 311 237 312 238 static struct fsl_edma_drvdata vf610_data = { 313 - .version = v1, 314 239 .dmamuxs = DMAMUX_NR, 240 + .flags = FSL_EDMA_DRV_WRAP_IO, 241 + .chreg_off = EDMA_TCD, 242 + .chreg_space_sz = sizeof(struct fsl_edma_hw_tcd), 315 243 .setup_irq = fsl_edma_irq_init, 316 244 }; 317 245 318 246 static struct fsl_edma_drvdata ls1028a_data = { 319 - .version = v1, 320 247 .dmamuxs = DMAMUX_NR, 321 - .mux_swap = true, 248 + .flags = FSL_EDMA_DRV_MUX_SWAP | FSL_EDMA_DRV_WRAP_IO, 249 + .chreg_off = EDMA_TCD, 250 + .chreg_space_sz = sizeof(struct fsl_edma_hw_tcd), 322 251 .setup_irq = fsl_edma_irq_init, 323 252 }; 324 253 325 254 static struct fsl_edma_drvdata imx7ulp_data = { 326 - .version = v3, 327 255 .dmamuxs = 1, 328 - .has_dmaclk = true, 256 + .chreg_off = EDMA_TCD, 257 + .chreg_space_sz = sizeof(struct fsl_edma_hw_tcd), 258 + .flags = FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_CONFIG32, 329 259 .setup_irq = fsl_edma2_irq_init, 260 + }; 261 + 262 + static struct fsl_edma_drvdata imx8qm_data = { 263 + .flags = FSL_EDMA_DRV_HAS_PD | FSL_EDMA_DRV_EDMA3, 264 + .chreg_space_sz = 0x10000, 265 + .chreg_off = 0x10000, 266 + .setup_irq = fsl_edma3_irq_init, 267 + }; 268 + 269 + static struct fsl_edma_drvdata imx8qm_audio_data = { 270 + .flags = FSL_EDMA_DRV_QUIRK_SWAPPED | FSL_EDMA_DRV_HAS_PD | FSL_EDMA_DRV_EDMA3, 271 + .chreg_space_sz = 0x10000, 272 + .chreg_off = 0x10000, 273 + .setup_irq = fsl_edma3_irq_init, 274 + }; 275 + 276 + static struct fsl_edma_drvdata imx93_data3 = { 277 + .flags = FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_EDMA3, 278 + .chreg_space_sz = 0x10000, 279 + .chreg_off = 0x10000, 280 + .setup_irq = fsl_edma3_irq_init, 281 + }; 282 + 283 + static struct fsl_edma_drvdata imx93_data4 = { 284 + .flags = FSL_EDMA_DRV_HAS_CHMUX | FSL_EDMA_DRV_HAS_DMACLK | FSL_EDMA_DRV_EDMA3, 285 + .chreg_space_sz = 0x8000, 286 + .chreg_off = 0x10000, 287 + .setup_irq = fsl_edma3_irq_init, 330 288 }; 331 289 332 290 static const struct of_device_id fsl_edma_dt_ids[] = { 333 291 { .compatible = "fsl,vf610-edma", .data = &vf610_data}, 334 292 { .compatible = "fsl,ls1028a-edma", .data = &ls1028a_data}, 335 293 { .compatible = "fsl,imx7ulp-edma", .data = &imx7ulp_data}, 294 + { .compatible = "fsl,imx8qm-edma", .data = &imx8qm_data}, 295 + { .compatible = "fsl,imx8qm-adma", .data = &imx8qm_audio_data}, 296 + { .compatible = "fsl,imx93-edma3", .data = &imx93_data3}, 297 + { .compatible = "fsl,imx93-edma4", .data = &imx93_data4}, 336 298 { /* sentinel */ } 337 299 }; 338 300 MODULE_DEVICE_TABLE(of, fsl_edma_dt_ids); 301 + 302 + static int fsl_edma3_attach_pd(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma) 303 + { 304 + struct fsl_edma_chan *fsl_chan; 305 + struct device_link *link; 306 + struct device *pd_chan; 307 + struct device *dev; 308 + int i; 309 + 310 + dev = &pdev->dev; 311 + 312 + for (i = 0; i < fsl_edma->n_chans; i++) { 313 + if (fsl_edma->chan_masked & BIT(i)) 314 + continue; 315 + 316 + fsl_chan = &fsl_edma->chans[i]; 317 + 318 + pd_chan = dev_pm_domain_attach_by_id(dev, i); 319 + if (IS_ERR_OR_NULL(pd_chan)) { 320 + dev_err(dev, "Failed attach pd %d\n", i); 321 + return -EINVAL; 322 + } 323 + 324 + link = device_link_add(dev, pd_chan, DL_FLAG_STATELESS | 325 + DL_FLAG_PM_RUNTIME | 326 + DL_FLAG_RPM_ACTIVE); 327 + if (IS_ERR(link)) { 328 + dev_err(dev, "Failed to add device_link to %d: %ld\n", i, 329 + PTR_ERR(link)); 330 + return -EINVAL; 331 + } 332 + 333 + fsl_chan->pd_dev = pd_chan; 334 + 335 + pm_runtime_use_autosuspend(fsl_chan->pd_dev); 336 + pm_runtime_set_autosuspend_delay(fsl_chan->pd_dev, 200); 337 + pm_runtime_set_active(fsl_chan->pd_dev); 338 + } 339 + 340 + return 0; 341 + } 339 342 340 343 static int fsl_edma_probe(struct platform_device *pdev) 341 344 { ··· 421 270 struct device_node *np = pdev->dev.of_node; 422 271 struct fsl_edma_engine *fsl_edma; 423 272 const struct fsl_edma_drvdata *drvdata = NULL; 424 - struct fsl_edma_chan *fsl_chan; 273 + u32 chan_mask[2] = {0, 0}; 425 274 struct edma_regs *regs; 426 - int len, chans; 275 + int chans; 427 276 int ret, i; 428 277 429 278 if (of_id) ··· 439 288 return ret; 440 289 } 441 290 442 - len = sizeof(*fsl_edma) + sizeof(*fsl_chan) * chans; 443 - fsl_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL); 291 + fsl_edma = devm_kzalloc(&pdev->dev, struct_size(fsl_edma, chans, chans), 292 + GFP_KERNEL); 444 293 if (!fsl_edma) 445 294 return -ENOMEM; 446 295 ··· 452 301 if (IS_ERR(fsl_edma->membase)) 453 302 return PTR_ERR(fsl_edma->membase); 454 303 455 - fsl_edma_setup_regs(fsl_edma); 456 - regs = &fsl_edma->regs; 304 + if (!(drvdata->flags & FSL_EDMA_DRV_SPLIT_REG)) { 305 + fsl_edma_setup_regs(fsl_edma); 306 + regs = &fsl_edma->regs; 307 + } 457 308 458 - if (drvdata->has_dmaclk) { 459 - fsl_edma->dmaclk = devm_clk_get(&pdev->dev, "dma"); 309 + if (drvdata->flags & FSL_EDMA_DRV_HAS_DMACLK) { 310 + fsl_edma->dmaclk = devm_clk_get_enabled(&pdev->dev, "dma"); 460 311 if (IS_ERR(fsl_edma->dmaclk)) { 461 312 dev_err(&pdev->dev, "Missing DMA block clock.\n"); 462 313 return PTR_ERR(fsl_edma->dmaclk); 463 314 } 315 + } 464 316 465 - ret = clk_prepare_enable(fsl_edma->dmaclk); 466 - if (ret) { 467 - dev_err(&pdev->dev, "DMA clk block failed.\n"); 468 - return ret; 317 + if (drvdata->flags & FSL_EDMA_DRV_HAS_CHCLK) { 318 + fsl_edma->chclk = devm_clk_get_enabled(&pdev->dev, "mp"); 319 + if (IS_ERR(fsl_edma->chclk)) { 320 + dev_err(&pdev->dev, "Missing MP block clock.\n"); 321 + return PTR_ERR(fsl_edma->chclk); 469 322 } 323 + } 324 + 325 + ret = of_property_read_variable_u32_array(np, "dma-channel-mask", chan_mask, 1, 2); 326 + 327 + if (ret > 0) { 328 + fsl_edma->chan_masked = chan_mask[1]; 329 + fsl_edma->chan_masked <<= 32; 330 + fsl_edma->chan_masked |= chan_mask[0]; 470 331 } 471 332 472 333 for (i = 0; i < fsl_edma->drvdata->dmamuxs; i++) { 473 334 char clkname[32]; 335 + 336 + /* eDMAv3 mux register move to TCD area if ch_mux exist */ 337 + if (drvdata->flags & FSL_EDMA_DRV_SPLIT_REG) 338 + break; 474 339 475 340 fsl_edma->muxbase[i] = devm_platform_ioremap_resource(pdev, 476 341 1 + i); ··· 497 330 } 498 331 499 332 sprintf(clkname, "dmamux%d", i); 500 - fsl_edma->muxclk[i] = devm_clk_get(&pdev->dev, clkname); 333 + fsl_edma->muxclk[i] = devm_clk_get_enabled(&pdev->dev, clkname); 501 334 if (IS_ERR(fsl_edma->muxclk[i])) { 502 335 dev_err(&pdev->dev, "Missing DMAMUX block clock.\n"); 503 336 /* on error: disable all previously enabled clks */ 504 - fsl_disable_clocks(fsl_edma, i); 505 337 return PTR_ERR(fsl_edma->muxclk[i]); 506 338 } 507 - 508 - ret = clk_prepare_enable(fsl_edma->muxclk[i]); 509 - if (ret) 510 - /* on error: disable all previously enabled clks */ 511 - fsl_disable_clocks(fsl_edma, i); 512 - 513 339 } 514 340 515 341 fsl_edma->big_endian = of_property_read_bool(np, "big-endian"); 516 342 343 + if (drvdata->flags & FSL_EDMA_DRV_HAS_PD) { 344 + ret = fsl_edma3_attach_pd(pdev, fsl_edma); 345 + if (ret) 346 + return ret; 347 + } 348 + 517 349 INIT_LIST_HEAD(&fsl_edma->dma_dev.channels); 518 350 for (i = 0; i < fsl_edma->n_chans; i++) { 519 351 struct fsl_edma_chan *fsl_chan = &fsl_edma->chans[i]; 352 + int len; 353 + 354 + if (fsl_edma->chan_masked & BIT(i)) 355 + continue; 356 + 357 + snprintf(fsl_chan->chan_name, sizeof(fsl_chan->chan_name), "%s-CH%02d", 358 + dev_name(&pdev->dev), i); 520 359 521 360 fsl_chan->edma = fsl_edma; 522 361 fsl_chan->pm_state = RUNNING; ··· 530 357 fsl_chan->idle = true; 531 358 fsl_chan->dma_dir = DMA_NONE; 532 359 fsl_chan->vchan.desc_free = fsl_edma_free_desc; 360 + 361 + len = (drvdata->flags & FSL_EDMA_DRV_SPLIT_REG) ? 362 + offsetof(struct fsl_edma3_ch_reg, tcd) : 0; 363 + fsl_chan->tcd = fsl_edma->membase 364 + + i * drvdata->chreg_space_sz + drvdata->chreg_off + len; 365 + 366 + fsl_chan->pdev = pdev; 533 367 vchan_init(&fsl_chan->vchan, &fsl_edma->dma_dev); 534 368 535 - edma_writew(fsl_edma, 0x0, &regs->tcd[i].csr); 369 + edma_write_tcdreg(fsl_chan, 0, csr); 536 370 fsl_edma_chan_mux(fsl_chan, 0, false); 537 371 } 538 372 539 - edma_writel(fsl_edma, ~0, regs->intl); 540 373 ret = fsl_edma->drvdata->setup_irq(pdev, fsl_edma); 541 374 if (ret) 542 375 return ret; ··· 570 391 571 392 fsl_edma->dma_dev.src_addr_widths = FSL_EDMA_BUSWIDTHS; 572 393 fsl_edma->dma_dev.dst_addr_widths = FSL_EDMA_BUSWIDTHS; 573 - fsl_edma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); 574 394 575 - fsl_edma->dma_dev.copy_align = DMAENGINE_ALIGN_32_BYTES; 395 + if (drvdata->flags & FSL_EDMA_DRV_BUS_8BYTE) { 396 + fsl_edma->dma_dev.src_addr_widths |= BIT(DMA_SLAVE_BUSWIDTH_8_BYTES); 397 + fsl_edma->dma_dev.dst_addr_widths |= BIT(DMA_SLAVE_BUSWIDTH_8_BYTES); 398 + } 399 + 400 + fsl_edma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); 401 + if (drvdata->flags & FSL_EDMA_DRV_DEV_TO_DEV) 402 + fsl_edma->dma_dev.directions |= BIT(DMA_DEV_TO_DEV); 403 + 404 + fsl_edma->dma_dev.copy_align = drvdata->flags & FSL_EDMA_DRV_ALIGN_64BYTE ? 405 + DMAENGINE_ALIGN_64_BYTES : 406 + DMAENGINE_ALIGN_32_BYTES; 407 + 576 408 /* Per worst case 'nbytes = 1' take CITER as the max_seg_size */ 577 409 dma_set_max_seg_size(fsl_edma->dma_dev.dev, 0x3fff); 410 + 411 + fsl_edma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; 578 412 579 413 platform_set_drvdata(pdev, fsl_edma); 580 414 ··· 595 403 if (ret) { 596 404 dev_err(&pdev->dev, 597 405 "Can't register Freescale eDMA engine. (%d)\n", ret); 598 - fsl_disable_clocks(fsl_edma, fsl_edma->drvdata->dmamuxs); 599 406 return ret; 600 407 } 601 408 602 - ret = of_dma_controller_register(np, fsl_edma_xlate, fsl_edma); 409 + ret = of_dma_controller_register(np, 410 + drvdata->flags & FSL_EDMA_DRV_SPLIT_REG ? fsl_edma3_xlate : fsl_edma_xlate, 411 + fsl_edma); 603 412 if (ret) { 604 413 dev_err(&pdev->dev, 605 414 "Can't register Freescale eDMA of_dma. (%d)\n", ret); 606 415 dma_async_device_unregister(&fsl_edma->dma_dev); 607 - fsl_disable_clocks(fsl_edma, fsl_edma->drvdata->dmamuxs); 608 416 return ret; 609 417 } 610 418 611 419 /* enable round robin arbitration */ 612 - edma_writel(fsl_edma, EDMA_CR_ERGA | EDMA_CR_ERCA, regs->cr); 420 + if (!(drvdata->flags & FSL_EDMA_DRV_SPLIT_REG)) 421 + edma_writel(fsl_edma, EDMA_CR_ERGA | EDMA_CR_ERCA, regs->cr); 613 422 614 423 return 0; 615 424 } ··· 663 470 for (i = 0; i < fsl_edma->n_chans; i++) { 664 471 fsl_chan = &fsl_edma->chans[i]; 665 472 fsl_chan->pm_state = RUNNING; 666 - edma_writew(fsl_edma, 0x0, &regs->tcd[i].csr); 473 + edma_write_tcdreg(fsl_chan, 0, csr); 667 474 if (fsl_chan->slave_id != 0) 668 475 fsl_edma_chan_mux(fsl_chan, fsl_chan->slave_id, true); 669 476 }
+2 -2
drivers/dma/fsl-qdma.c
··· 13 13 14 14 #include <linux/module.h> 15 15 #include <linux/delay.h> 16 - #include <linux/of_irq.h> 17 - #include <linux/of_platform.h> 16 + #include <linux/of.h> 18 17 #include <linux/of_dma.h> 19 18 #include <linux/dma-mapping.h> 19 + #include <linux/platform_device.h> 20 20 21 21 #include "virt-dma.h" 22 22 #include "fsldma.h"
+2 -1
drivers/dma/fsl_raid.c
··· 60 60 */ 61 61 #include <linux/interrupt.h> 62 62 #include <linux/module.h> 63 + #include <linux/of.h> 63 64 #include <linux/of_irq.h> 64 - #include <linux/of_address.h> 65 65 #include <linux/of_platform.h> 66 + #include <linux/platform_device.h> 66 67 #include <linux/dma-mapping.h> 67 68 #include <linux/dmapool.h> 68 69 #include <linux/dmaengine.h>
+2 -1
drivers/dma/fsldma.c
··· 28 28 #include <linux/delay.h> 29 29 #include <linux/dma-mapping.h> 30 30 #include <linux/dmapool.h> 31 + #include <linux/of.h> 31 32 #include <linux/of_address.h> 32 33 #include <linux/of_irq.h> 33 - #include <linux/of_platform.h> 34 + #include <linux/platform_device.h> 34 35 #include <linux/fsldma.h> 35 36 #include "dmaengine.h" 36 37 #include "fsldma.h"
-2
drivers/dma/idxd/device.c
··· 769 769 goto err_alloc; 770 770 } 771 771 772 - memset(addr, 0, size); 773 - 774 772 spin_lock(&evl->lock); 775 773 evl->log = addr; 776 774 evl->dma = dma_addr;
-5
drivers/dma/idxd/idxd.h
··· 660 660 void idxd_unregister_bus_type(void); 661 661 int idxd_register_devices(struct idxd_device *idxd); 662 662 void idxd_unregister_devices(struct idxd_device *idxd); 663 - int idxd_register_driver(void); 664 - void idxd_unregister_driver(void); 665 663 void idxd_wqs_quiesce(struct idxd_device *idxd); 666 664 bool idxd_queue_int_handle_resubmit(struct idxd_desc *desc); 667 665 void multi_u64_to_bmap(unsigned long *bmap, u64 *val, int count); ··· 671 673 void idxd_unmask_error_interrupts(struct idxd_device *idxd); 672 674 673 675 /* device control */ 674 - int idxd_register_idxd_drv(void); 675 - void idxd_unregister_idxd_drv(void); 676 676 int idxd_device_drv_probe(struct idxd_dev *idxd_dev); 677 677 void idxd_device_drv_remove(struct idxd_dev *idxd_dev); 678 678 int drv_enable_wq(struct idxd_wq *wq); ··· 715 719 /* dmaengine */ 716 720 int idxd_register_dma_device(struct idxd_device *idxd); 717 721 void idxd_unregister_dma_device(struct idxd_device *idxd); 718 - void idxd_parse_completion_status(u8 status, enum dmaengine_tx_result *res); 719 722 void idxd_dma_complete_txd(struct idxd_desc *desc, 720 723 enum idxd_complete_type comp_type, bool free_desc); 721 724
+3 -4
drivers/dma/idxd/perfmon.c
··· 245 245 int shift = 64 - idxd->idxd_pmu->counter_width; 246 246 struct hw_perf_event *hwc = &event->hw; 247 247 248 + prev_raw_count = local64_read(&hwc->prev_count); 248 249 do { 249 - prev_raw_count = local64_read(&hwc->prev_count); 250 250 new_raw_count = perfmon_pmu_read_counter(event); 251 - } while (local64_cmpxchg(&hwc->prev_count, prev_raw_count, 252 - new_raw_count) != prev_raw_count); 253 - 251 + } while (!local64_try_cmpxchg(&hwc->prev_count, 252 + &prev_raw_count, new_raw_count)); 254 253 n = (new_raw_count << shift); 255 254 p = (prev_raw_count << shift); 256 255
+13 -20
drivers/dma/idxd/sysfs.c
··· 1088 1088 if (wq->state != IDXD_WQ_DISABLED) 1089 1089 return -EPERM; 1090 1090 1091 - if (!idxd->hw.wq_cap.wq_ats_support) 1092 - return -EOPNOTSUPP; 1091 + if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) 1092 + return -EPERM; 1093 1093 1094 1094 rc = kstrtobool(buf, &ats_dis); 1095 1095 if (rc < 0) ··· 1124 1124 if (wq->state != IDXD_WQ_DISABLED) 1125 1125 return -EPERM; 1126 1126 1127 - if (!idxd->hw.wq_cap.wq_prs_support) 1128 - return -EOPNOTSUPP; 1127 + if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) 1128 + return -EPERM; 1129 1129 1130 1130 rc = kstrtobool(buf, &prs_dis); 1131 1131 if (rc < 0) ··· 1281 1281 NULL, 1282 1282 }; 1283 1283 1284 - static bool idxd_wq_attr_op_config_invisible(struct attribute *attr, 1285 - struct idxd_device *idxd) 1286 - { 1287 - return attr == &dev_attr_wq_op_config.attr && 1288 - !idxd->hw.wq_cap.op_config; 1289 - } 1284 + /* A WQ attr is invisible if the feature is not supported in WQCAP. */ 1285 + #define idxd_wq_attr_invisible(name, cap_field, a, idxd) \ 1286 + ((a) == &dev_attr_wq_##name.attr && !(idxd)->hw.wq_cap.cap_field) 1290 1287 1291 1288 static bool idxd_wq_attr_max_batch_size_invisible(struct attribute *attr, 1292 1289 struct idxd_device *idxd) ··· 1293 1296 idxd->data->type == IDXD_TYPE_IAX; 1294 1297 } 1295 1298 1296 - static bool idxd_wq_attr_wq_prs_disable_invisible(struct attribute *attr, 1297 - struct idxd_device *idxd) 1298 - { 1299 - return attr == &dev_attr_wq_prs_disable.attr && 1300 - !idxd->hw.wq_cap.wq_prs_support; 1301 - } 1302 - 1303 1299 static umode_t idxd_wq_attr_visible(struct kobject *kobj, 1304 1300 struct attribute *attr, int n) 1305 1301 { ··· 1300 1310 struct idxd_wq *wq = confdev_to_wq(dev); 1301 1311 struct idxd_device *idxd = wq->idxd; 1302 1312 1303 - if (idxd_wq_attr_op_config_invisible(attr, idxd)) 1313 + if (idxd_wq_attr_invisible(op_config, op_config, attr, idxd)) 1304 1314 return 0; 1305 1315 1306 1316 if (idxd_wq_attr_max_batch_size_invisible(attr, idxd)) 1307 1317 return 0; 1308 1318 1309 - if (idxd_wq_attr_wq_prs_disable_invisible(attr, idxd)) 1319 + if (idxd_wq_attr_invisible(prs_disable, wq_prs_support, attr, idxd)) 1320 + return 0; 1321 + 1322 + if (idxd_wq_attr_invisible(ats_disable, wq_ats_support, attr, idxd)) 1310 1323 return 0; 1311 1324 1312 1325 return attr->mode; ··· 1466 1473 { 1467 1474 struct idxd_device *idxd = confdev_to_idxd(dev); 1468 1475 1469 - return sysfs_emit(buf, "%u\n", device_pasid_enabled(idxd)); 1476 + return sysfs_emit(buf, "%u\n", device_user_pasid_enabled(idxd)); 1470 1477 } 1471 1478 static DEVICE_ATTR_RO(pasid_enabled); 1472 1479
-1
drivers/dma/img-mdc-dma.c
··· 17 17 #include <linux/mfd/syscon.h> 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 - #include <linux/of_device.h> 21 20 #include <linux/of_dma.h> 22 21 #include <linux/platform_device.h> 23 22 #include <linux/pm_runtime.h>
+1 -1
drivers/dma/imx-dma.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/dmaengine.h> 23 23 #include <linux/module.h> 24 - #include <linux/of_device.h> 24 + #include <linux/of.h> 25 25 #include <linux/of_dma.h> 26 26 27 27 #include <asm/irq.h>
-1
drivers/dma/imx-sdma.c
··· 31 31 #include <linux/dmaengine.h> 32 32 #include <linux/of.h> 33 33 #include <linux/of_address.h> 34 - #include <linux/of_device.h> 35 34 #include <linux/of_dma.h> 36 35 #include <linux/workqueue.h> 37 36
+1 -1
drivers/dma/ioat/dca.c
··· 51 51 /* pack PCI B/D/F into a u16 */ 52 52 static inline u16 dcaid_from_pcidev(struct pci_dev *pci) 53 53 { 54 - return (pci->bus->number << 8) | pci->devfn; 54 + return pci_dev_id(pci); 55 55 } 56 56 57 57 static int dca_enabled_in_bios(struct pci_dev *pdev)
+1
drivers/dma/ioat/dma.h
··· 74 74 struct dca_provider *dca; 75 75 enum ioat_irq_mode irq_mode; 76 76 u32 cap; 77 + int chancnt; 77 78 78 79 /* shadow version for CB3.3 chan reset errata workaround */ 79 80 u64 msixtba0;
+10 -9
drivers/dma/ioat/init.c
··· 420 420 421 421 msix: 422 422 /* The number of MSI-X vectors should equal the number of channels */ 423 - msixcnt = ioat_dma->dma_dev.chancnt; 423 + msixcnt = ioat_dma->chancnt; 424 424 for (i = 0; i < msixcnt; i++) 425 425 ioat_dma->msix_entries[i].entry = i; 426 426 ··· 511 511 dma_cap_set(DMA_MEMCPY, dma->cap_mask); 512 512 dma->dev = &pdev->dev; 513 513 514 - if (!dma->chancnt) { 514 + if (!ioat_dma->chancnt) { 515 515 dev_err(dev, "channel enumeration error\n"); 516 516 goto err_setup_interrupts; 517 517 } ··· 567 567 struct device *dev = &ioat_dma->pdev->dev; 568 568 struct dma_device *dma = &ioat_dma->dma_dev; 569 569 u8 xfercap_log; 570 + int chancnt; 570 571 int i; 571 572 572 573 INIT_LIST_HEAD(&dma->channels); 573 - dma->chancnt = readb(ioat_dma->reg_base + IOAT_CHANCNT_OFFSET); 574 - dma->chancnt &= 0x1f; /* bits [4:0] valid */ 575 - if (dma->chancnt > ARRAY_SIZE(ioat_dma->idx)) { 574 + chancnt = readb(ioat_dma->reg_base + IOAT_CHANCNT_OFFSET); 575 + chancnt &= 0x1f; /* bits [4:0] valid */ 576 + if (chancnt > ARRAY_SIZE(ioat_dma->idx)) { 576 577 dev_warn(dev, "(%d) exceeds max supported channels (%zu)\n", 577 - dma->chancnt, ARRAY_SIZE(ioat_dma->idx)); 578 - dma->chancnt = ARRAY_SIZE(ioat_dma->idx); 578 + chancnt, ARRAY_SIZE(ioat_dma->idx)); 579 + chancnt = ARRAY_SIZE(ioat_dma->idx); 579 580 } 580 581 xfercap_log = readb(ioat_dma->reg_base + IOAT_XFERCAP_OFFSET); 581 582 xfercap_log &= 0x1f; /* bits [4:0] valid */ ··· 584 583 return; 585 584 dev_dbg(dev, "%s: xfercap = %d\n", __func__, 1 << xfercap_log); 586 585 587 - for (i = 0; i < dma->chancnt; i++) { 586 + for (i = 0; i < chancnt; i++) { 588 587 ioat_chan = kzalloc(sizeof(*ioat_chan), GFP_KERNEL); 589 588 if (!ioat_chan) 590 589 break; ··· 597 596 break; 598 597 } 599 598 } 600 - dma->chancnt = i; 599 + ioat_dma->chancnt = i; 601 600 } 602 601 603 602 /**
-2
drivers/dma/ipu/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0-only 2 - obj-y += ipu_irq.o ipu_idmac.o
-1801
drivers/dma/ipu/ipu_idmac.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Copyright (C) 2008 4 - * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de> 5 - * 6 - * Copyright (C) 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. 7 - */ 8 - 9 - #include <linux/dma-mapping.h> 10 - #include <linux/init.h> 11 - #include <linux/platform_device.h> 12 - #include <linux/err.h> 13 - #include <linux/spinlock.h> 14 - #include <linux/delay.h> 15 - #include <linux/list.h> 16 - #include <linux/clk.h> 17 - #include <linux/vmalloc.h> 18 - #include <linux/string.h> 19 - #include <linux/interrupt.h> 20 - #include <linux/io.h> 21 - #include <linux/module.h> 22 - #include <linux/dma/ipu-dma.h> 23 - 24 - #include "../dmaengine.h" 25 - #include "ipu_intern.h" 26 - 27 - #define FS_VF_IN_VALID 0x00000002 28 - #define FS_ENC_IN_VALID 0x00000001 29 - 30 - static int ipu_disable_channel(struct idmac *idmac, struct idmac_channel *ichan, 31 - bool wait_for_stop); 32 - 33 - /* 34 - * There can be only one, we could allocate it dynamically, but then we'd have 35 - * to add an extra parameter to some functions, and use something as ugly as 36 - * struct ipu *ipu = to_ipu(to_idmac(ichan->dma_chan.device)); 37 - * in the ISR 38 - */ 39 - static struct ipu ipu_data; 40 - 41 - #define to_ipu(id) container_of(id, struct ipu, idmac) 42 - 43 - static u32 __idmac_read_icreg(struct ipu *ipu, unsigned long reg) 44 - { 45 - return __raw_readl(ipu->reg_ic + reg); 46 - } 47 - 48 - #define idmac_read_icreg(ipu, reg) __idmac_read_icreg(ipu, reg - IC_CONF) 49 - 50 - static void __idmac_write_icreg(struct ipu *ipu, u32 value, unsigned long reg) 51 - { 52 - __raw_writel(value, ipu->reg_ic + reg); 53 - } 54 - 55 - #define idmac_write_icreg(ipu, v, reg) __idmac_write_icreg(ipu, v, reg - IC_CONF) 56 - 57 - static u32 idmac_read_ipureg(struct ipu *ipu, unsigned long reg) 58 - { 59 - return __raw_readl(ipu->reg_ipu + reg); 60 - } 61 - 62 - static void idmac_write_ipureg(struct ipu *ipu, u32 value, unsigned long reg) 63 - { 64 - __raw_writel(value, ipu->reg_ipu + reg); 65 - } 66 - 67 - /***************************************************************************** 68 - * IPU / IC common functions 69 - */ 70 - static void dump_idmac_reg(struct ipu *ipu) 71 - { 72 - dev_dbg(ipu->dev, "IDMAC_CONF 0x%x, IC_CONF 0x%x, IDMAC_CHA_EN 0x%x, " 73 - "IDMAC_CHA_PRI 0x%x, IDMAC_CHA_BUSY 0x%x\n", 74 - idmac_read_icreg(ipu, IDMAC_CONF), 75 - idmac_read_icreg(ipu, IC_CONF), 76 - idmac_read_icreg(ipu, IDMAC_CHA_EN), 77 - idmac_read_icreg(ipu, IDMAC_CHA_PRI), 78 - idmac_read_icreg(ipu, IDMAC_CHA_BUSY)); 79 - dev_dbg(ipu->dev, "BUF0_RDY 0x%x, BUF1_RDY 0x%x, CUR_BUF 0x%x, " 80 - "DB_MODE 0x%x, TASKS_STAT 0x%x\n", 81 - idmac_read_ipureg(ipu, IPU_CHA_BUF0_RDY), 82 - idmac_read_ipureg(ipu, IPU_CHA_BUF1_RDY), 83 - idmac_read_ipureg(ipu, IPU_CHA_CUR_BUF), 84 - idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL), 85 - idmac_read_ipureg(ipu, IPU_TASKS_STAT)); 86 - } 87 - 88 - static uint32_t bytes_per_pixel(enum pixel_fmt fmt) 89 - { 90 - switch (fmt) { 91 - case IPU_PIX_FMT_GENERIC: /* generic data */ 92 - case IPU_PIX_FMT_RGB332: 93 - case IPU_PIX_FMT_YUV420P: 94 - case IPU_PIX_FMT_YUV422P: 95 - default: 96 - return 1; 97 - case IPU_PIX_FMT_RGB565: 98 - case IPU_PIX_FMT_YUYV: 99 - case IPU_PIX_FMT_UYVY: 100 - return 2; 101 - case IPU_PIX_FMT_BGR24: 102 - case IPU_PIX_FMT_RGB24: 103 - return 3; 104 - case IPU_PIX_FMT_GENERIC_32: /* generic data */ 105 - case IPU_PIX_FMT_BGR32: 106 - case IPU_PIX_FMT_RGB32: 107 - case IPU_PIX_FMT_ABGR32: 108 - return 4; 109 - } 110 - } 111 - 112 - /* Enable direct write to memory by the Camera Sensor Interface */ 113 - static void ipu_ic_enable_task(struct ipu *ipu, enum ipu_channel channel) 114 - { 115 - uint32_t ic_conf, mask; 116 - 117 - switch (channel) { 118 - case IDMAC_IC_0: 119 - mask = IC_CONF_PRPENC_EN; 120 - break; 121 - case IDMAC_IC_7: 122 - mask = IC_CONF_RWS_EN | IC_CONF_PRPENC_EN; 123 - break; 124 - default: 125 - return; 126 - } 127 - ic_conf = idmac_read_icreg(ipu, IC_CONF) | mask; 128 - idmac_write_icreg(ipu, ic_conf, IC_CONF); 129 - } 130 - 131 - /* Called under spin_lock_irqsave(&ipu_data.lock) */ 132 - static void ipu_ic_disable_task(struct ipu *ipu, enum ipu_channel channel) 133 - { 134 - uint32_t ic_conf, mask; 135 - 136 - switch (channel) { 137 - case IDMAC_IC_0: 138 - mask = IC_CONF_PRPENC_EN; 139 - break; 140 - case IDMAC_IC_7: 141 - mask = IC_CONF_RWS_EN | IC_CONF_PRPENC_EN; 142 - break; 143 - default: 144 - return; 145 - } 146 - ic_conf = idmac_read_icreg(ipu, IC_CONF) & ~mask; 147 - idmac_write_icreg(ipu, ic_conf, IC_CONF); 148 - } 149 - 150 - static uint32_t ipu_channel_status(struct ipu *ipu, enum ipu_channel channel) 151 - { 152 - uint32_t stat = TASK_STAT_IDLE; 153 - uint32_t task_stat_reg = idmac_read_ipureg(ipu, IPU_TASKS_STAT); 154 - 155 - switch (channel) { 156 - case IDMAC_IC_7: 157 - stat = (task_stat_reg & TSTAT_CSI2MEM_MASK) >> 158 - TSTAT_CSI2MEM_OFFSET; 159 - break; 160 - case IDMAC_IC_0: 161 - case IDMAC_SDC_0: 162 - case IDMAC_SDC_1: 163 - default: 164 - break; 165 - } 166 - return stat; 167 - } 168 - 169 - struct chan_param_mem_planar { 170 - /* Word 0 */ 171 - u32 xv:10; 172 - u32 yv:10; 173 - u32 xb:12; 174 - 175 - u32 yb:12; 176 - u32 res1:2; 177 - u32 nsb:1; 178 - u32 lnpb:6; 179 - u32 ubo_l:11; 180 - 181 - u32 ubo_h:15; 182 - u32 vbo_l:17; 183 - 184 - u32 vbo_h:9; 185 - u32 res2:3; 186 - u32 fw:12; 187 - u32 fh_l:8; 188 - 189 - u32 fh_h:4; 190 - u32 res3:28; 191 - 192 - /* Word 1 */ 193 - u32 eba0; 194 - 195 - u32 eba1; 196 - 197 - u32 bpp:3; 198 - u32 sl:14; 199 - u32 pfs:3; 200 - u32 bam:3; 201 - u32 res4:2; 202 - u32 npb:6; 203 - u32 res5:1; 204 - 205 - u32 sat:2; 206 - u32 res6:30; 207 - } __attribute__ ((packed)); 208 - 209 - struct chan_param_mem_interleaved { 210 - /* Word 0 */ 211 - u32 xv:10; 212 - u32 yv:10; 213 - u32 xb:12; 214 - 215 - u32 yb:12; 216 - u32 sce:1; 217 - u32 res1:1; 218 - u32 nsb:1; 219 - u32 lnpb:6; 220 - u32 sx:10; 221 - u32 sy_l:1; 222 - 223 - u32 sy_h:9; 224 - u32 ns:10; 225 - u32 sm:10; 226 - u32 sdx_l:3; 227 - 228 - u32 sdx_h:2; 229 - u32 sdy:5; 230 - u32 sdrx:1; 231 - u32 sdry:1; 232 - u32 sdr1:1; 233 - u32 res2:2; 234 - u32 fw:12; 235 - u32 fh_l:8; 236 - 237 - u32 fh_h:4; 238 - u32 res3:28; 239 - 240 - /* Word 1 */ 241 - u32 eba0; 242 - 243 - u32 eba1; 244 - 245 - u32 bpp:3; 246 - u32 sl:14; 247 - u32 pfs:3; 248 - u32 bam:3; 249 - u32 res4:2; 250 - u32 npb:6; 251 - u32 res5:1; 252 - 253 - u32 sat:2; 254 - u32 scc:1; 255 - u32 ofs0:5; 256 - u32 ofs1:5; 257 - u32 ofs2:5; 258 - u32 ofs3:5; 259 - u32 wid0:3; 260 - u32 wid1:3; 261 - u32 wid2:3; 262 - 263 - u32 wid3:3; 264 - u32 dec_sel:1; 265 - u32 res6:28; 266 - } __attribute__ ((packed)); 267 - 268 - union chan_param_mem { 269 - struct chan_param_mem_planar pp; 270 - struct chan_param_mem_interleaved ip; 271 - }; 272 - 273 - static void ipu_ch_param_set_plane_offset(union chan_param_mem *params, 274 - u32 u_offset, u32 v_offset) 275 - { 276 - params->pp.ubo_l = u_offset & 0x7ff; 277 - params->pp.ubo_h = u_offset >> 11; 278 - params->pp.vbo_l = v_offset & 0x1ffff; 279 - params->pp.vbo_h = v_offset >> 17; 280 - } 281 - 282 - static void ipu_ch_param_set_size(union chan_param_mem *params, 283 - uint32_t pixel_fmt, uint16_t width, 284 - uint16_t height, uint16_t stride) 285 - { 286 - u32 u_offset; 287 - u32 v_offset; 288 - 289 - params->pp.fw = width - 1; 290 - params->pp.fh_l = height - 1; 291 - params->pp.fh_h = (height - 1) >> 8; 292 - params->pp.sl = stride - 1; 293 - 294 - switch (pixel_fmt) { 295 - case IPU_PIX_FMT_GENERIC: 296 - /*Represents 8-bit Generic data */ 297 - params->pp.bpp = 3; 298 - params->pp.pfs = 7; 299 - params->pp.npb = 31; 300 - params->pp.sat = 2; /* SAT = use 32-bit access */ 301 - break; 302 - case IPU_PIX_FMT_GENERIC_32: 303 - /*Represents 32-bit Generic data */ 304 - params->pp.bpp = 0; 305 - params->pp.pfs = 7; 306 - params->pp.npb = 7; 307 - params->pp.sat = 2; /* SAT = use 32-bit access */ 308 - break; 309 - case IPU_PIX_FMT_RGB565: 310 - params->ip.bpp = 2; 311 - params->ip.pfs = 4; 312 - params->ip.npb = 15; 313 - params->ip.sat = 2; /* SAT = 32-bit access */ 314 - params->ip.ofs0 = 0; /* Red bit offset */ 315 - params->ip.ofs1 = 5; /* Green bit offset */ 316 - params->ip.ofs2 = 11; /* Blue bit offset */ 317 - params->ip.ofs3 = 16; /* Alpha bit offset */ 318 - params->ip.wid0 = 4; /* Red bit width - 1 */ 319 - params->ip.wid1 = 5; /* Green bit width - 1 */ 320 - params->ip.wid2 = 4; /* Blue bit width - 1 */ 321 - break; 322 - case IPU_PIX_FMT_BGR24: 323 - params->ip.bpp = 1; /* 24 BPP & RGB PFS */ 324 - params->ip.pfs = 4; 325 - params->ip.npb = 7; 326 - params->ip.sat = 2; /* SAT = 32-bit access */ 327 - params->ip.ofs0 = 0; /* Red bit offset */ 328 - params->ip.ofs1 = 8; /* Green bit offset */ 329 - params->ip.ofs2 = 16; /* Blue bit offset */ 330 - params->ip.ofs3 = 24; /* Alpha bit offset */ 331 - params->ip.wid0 = 7; /* Red bit width - 1 */ 332 - params->ip.wid1 = 7; /* Green bit width - 1 */ 333 - params->ip.wid2 = 7; /* Blue bit width - 1 */ 334 - break; 335 - case IPU_PIX_FMT_RGB24: 336 - params->ip.bpp = 1; /* 24 BPP & RGB PFS */ 337 - params->ip.pfs = 4; 338 - params->ip.npb = 7; 339 - params->ip.sat = 2; /* SAT = 32-bit access */ 340 - params->ip.ofs0 = 16; /* Red bit offset */ 341 - params->ip.ofs1 = 8; /* Green bit offset */ 342 - params->ip.ofs2 = 0; /* Blue bit offset */ 343 - params->ip.ofs3 = 24; /* Alpha bit offset */ 344 - params->ip.wid0 = 7; /* Red bit width - 1 */ 345 - params->ip.wid1 = 7; /* Green bit width - 1 */ 346 - params->ip.wid2 = 7; /* Blue bit width - 1 */ 347 - break; 348 - case IPU_PIX_FMT_BGRA32: 349 - case IPU_PIX_FMT_BGR32: 350 - case IPU_PIX_FMT_ABGR32: 351 - params->ip.bpp = 0; 352 - params->ip.pfs = 4; 353 - params->ip.npb = 7; 354 - params->ip.sat = 2; /* SAT = 32-bit access */ 355 - params->ip.ofs0 = 8; /* Red bit offset */ 356 - params->ip.ofs1 = 16; /* Green bit offset */ 357 - params->ip.ofs2 = 24; /* Blue bit offset */ 358 - params->ip.ofs3 = 0; /* Alpha bit offset */ 359 - params->ip.wid0 = 7; /* Red bit width - 1 */ 360 - params->ip.wid1 = 7; /* Green bit width - 1 */ 361 - params->ip.wid2 = 7; /* Blue bit width - 1 */ 362 - params->ip.wid3 = 7; /* Alpha bit width - 1 */ 363 - break; 364 - case IPU_PIX_FMT_RGBA32: 365 - case IPU_PIX_FMT_RGB32: 366 - params->ip.bpp = 0; 367 - params->ip.pfs = 4; 368 - params->ip.npb = 7; 369 - params->ip.sat = 2; /* SAT = 32-bit access */ 370 - params->ip.ofs0 = 24; /* Red bit offset */ 371 - params->ip.ofs1 = 16; /* Green bit offset */ 372 - params->ip.ofs2 = 8; /* Blue bit offset */ 373 - params->ip.ofs3 = 0; /* Alpha bit offset */ 374 - params->ip.wid0 = 7; /* Red bit width - 1 */ 375 - params->ip.wid1 = 7; /* Green bit width - 1 */ 376 - params->ip.wid2 = 7; /* Blue bit width - 1 */ 377 - params->ip.wid3 = 7; /* Alpha bit width - 1 */ 378 - break; 379 - case IPU_PIX_FMT_UYVY: 380 - params->ip.bpp = 2; 381 - params->ip.pfs = 6; 382 - params->ip.npb = 7; 383 - params->ip.sat = 2; /* SAT = 32-bit access */ 384 - break; 385 - case IPU_PIX_FMT_YUV420P2: 386 - case IPU_PIX_FMT_YUV420P: 387 - params->ip.bpp = 3; 388 - params->ip.pfs = 3; 389 - params->ip.npb = 7; 390 - params->ip.sat = 2; /* SAT = 32-bit access */ 391 - u_offset = stride * height; 392 - v_offset = u_offset + u_offset / 4; 393 - ipu_ch_param_set_plane_offset(params, u_offset, v_offset); 394 - break; 395 - case IPU_PIX_FMT_YVU422P: 396 - params->ip.bpp = 3; 397 - params->ip.pfs = 2; 398 - params->ip.npb = 7; 399 - params->ip.sat = 2; /* SAT = 32-bit access */ 400 - v_offset = stride * height; 401 - u_offset = v_offset + v_offset / 2; 402 - ipu_ch_param_set_plane_offset(params, u_offset, v_offset); 403 - break; 404 - case IPU_PIX_FMT_YUV422P: 405 - params->ip.bpp = 3; 406 - params->ip.pfs = 2; 407 - params->ip.npb = 7; 408 - params->ip.sat = 2; /* SAT = 32-bit access */ 409 - u_offset = stride * height; 410 - v_offset = u_offset + u_offset / 2; 411 - ipu_ch_param_set_plane_offset(params, u_offset, v_offset); 412 - break; 413 - default: 414 - dev_err(ipu_data.dev, 415 - "mx3 ipu: unimplemented pixel format %d\n", pixel_fmt); 416 - break; 417 - } 418 - 419 - params->pp.nsb = 1; 420 - } 421 - 422 - static void ipu_ch_param_set_buffer(union chan_param_mem *params, 423 - dma_addr_t buf0, dma_addr_t buf1) 424 - { 425 - params->pp.eba0 = buf0; 426 - params->pp.eba1 = buf1; 427 - } 428 - 429 - static void ipu_ch_param_set_rotation(union chan_param_mem *params, 430 - enum ipu_rotate_mode rotate) 431 - { 432 - params->pp.bam = rotate; 433 - } 434 - 435 - static void ipu_write_param_mem(uint32_t addr, uint32_t *data, 436 - uint32_t num_words) 437 - { 438 - for (; num_words > 0; num_words--) { 439 - dev_dbg(ipu_data.dev, 440 - "write param mem - addr = 0x%08X, data = 0x%08X\n", 441 - addr, *data); 442 - idmac_write_ipureg(&ipu_data, addr, IPU_IMA_ADDR); 443 - idmac_write_ipureg(&ipu_data, *data++, IPU_IMA_DATA); 444 - addr++; 445 - if ((addr & 0x7) == 5) { 446 - addr &= ~0x7; /* set to word 0 */ 447 - addr += 8; /* increment to next row */ 448 - } 449 - } 450 - } 451 - 452 - static int calc_resize_coeffs(uint32_t in_size, uint32_t out_size, 453 - uint32_t *resize_coeff, 454 - uint32_t *downsize_coeff) 455 - { 456 - uint32_t temp_size; 457 - uint32_t temp_downsize; 458 - 459 - *resize_coeff = 1 << 13; 460 - *downsize_coeff = 1 << 13; 461 - 462 - /* Cannot downsize more than 8:1 */ 463 - if (out_size << 3 < in_size) 464 - return -EINVAL; 465 - 466 - /* compute downsizing coefficient */ 467 - temp_downsize = 0; 468 - temp_size = in_size; 469 - while (temp_size >= out_size * 2 && temp_downsize < 2) { 470 - temp_size >>= 1; 471 - temp_downsize++; 472 - } 473 - *downsize_coeff = temp_downsize; 474 - 475 - /* 476 - * compute resizing coefficient using the following formula: 477 - * resize_coeff = M*(SI -1)/(SO - 1) 478 - * where M = 2^13, SI - input size, SO - output size 479 - */ 480 - *resize_coeff = (8192L * (temp_size - 1)) / (out_size - 1); 481 - if (*resize_coeff >= 16384L) { 482 - dev_err(ipu_data.dev, "Warning! Overflow on resize coeff.\n"); 483 - *resize_coeff = 0x3FFF; 484 - } 485 - 486 - dev_dbg(ipu_data.dev, "resizing from %u -> %u pixels, " 487 - "downsize=%u, resize=%u.%lu (reg=%u)\n", in_size, out_size, 488 - *downsize_coeff, *resize_coeff >= 8192L ? 1 : 0, 489 - ((*resize_coeff & 0x1FFF) * 10000L) / 8192L, *resize_coeff); 490 - 491 - return 0; 492 - } 493 - 494 - static enum ipu_color_space format_to_colorspace(enum pixel_fmt fmt) 495 - { 496 - switch (fmt) { 497 - case IPU_PIX_FMT_RGB565: 498 - case IPU_PIX_FMT_BGR24: 499 - case IPU_PIX_FMT_RGB24: 500 - case IPU_PIX_FMT_BGR32: 501 - case IPU_PIX_FMT_RGB32: 502 - return IPU_COLORSPACE_RGB; 503 - default: 504 - return IPU_COLORSPACE_YCBCR; 505 - } 506 - } 507 - 508 - static int ipu_ic_init_prpenc(struct ipu *ipu, 509 - union ipu_channel_param *params, bool src_is_csi) 510 - { 511 - uint32_t reg, ic_conf; 512 - uint32_t downsize_coeff, resize_coeff; 513 - enum ipu_color_space in_fmt, out_fmt; 514 - 515 - /* Setup vertical resizing */ 516 - calc_resize_coeffs(params->video.in_height, 517 - params->video.out_height, 518 - &resize_coeff, &downsize_coeff); 519 - reg = (downsize_coeff << 30) | (resize_coeff << 16); 520 - 521 - /* Setup horizontal resizing */ 522 - calc_resize_coeffs(params->video.in_width, 523 - params->video.out_width, 524 - &resize_coeff, &downsize_coeff); 525 - reg |= (downsize_coeff << 14) | resize_coeff; 526 - 527 - /* Setup color space conversion */ 528 - in_fmt = format_to_colorspace(params->video.in_pixel_fmt); 529 - out_fmt = format_to_colorspace(params->video.out_pixel_fmt); 530 - 531 - /* 532 - * Colourspace conversion unsupported yet - see _init_csc() in 533 - * Freescale sources 534 - */ 535 - if (in_fmt != out_fmt) { 536 - dev_err(ipu->dev, "Colourspace conversion unsupported!\n"); 537 - return -EOPNOTSUPP; 538 - } 539 - 540 - idmac_write_icreg(ipu, reg, IC_PRP_ENC_RSC); 541 - 542 - ic_conf = idmac_read_icreg(ipu, IC_CONF); 543 - 544 - if (src_is_csi) 545 - ic_conf &= ~IC_CONF_RWS_EN; 546 - else 547 - ic_conf |= IC_CONF_RWS_EN; 548 - 549 - idmac_write_icreg(ipu, ic_conf, IC_CONF); 550 - 551 - return 0; 552 - } 553 - 554 - static uint32_t dma_param_addr(uint32_t dma_ch) 555 - { 556 - /* Channel Parameter Memory */ 557 - return 0x10000 | (dma_ch << 4); 558 - } 559 - 560 - static void ipu_channel_set_priority(struct ipu *ipu, enum ipu_channel channel, 561 - bool prio) 562 - { 563 - u32 reg = idmac_read_icreg(ipu, IDMAC_CHA_PRI); 564 - 565 - if (prio) 566 - reg |= 1UL << channel; 567 - else 568 - reg &= ~(1UL << channel); 569 - 570 - idmac_write_icreg(ipu, reg, IDMAC_CHA_PRI); 571 - 572 - dump_idmac_reg(ipu); 573 - } 574 - 575 - static uint32_t ipu_channel_conf_mask(enum ipu_channel channel) 576 - { 577 - uint32_t mask; 578 - 579 - switch (channel) { 580 - case IDMAC_IC_0: 581 - case IDMAC_IC_7: 582 - mask = IPU_CONF_CSI_EN | IPU_CONF_IC_EN; 583 - break; 584 - case IDMAC_SDC_0: 585 - case IDMAC_SDC_1: 586 - mask = IPU_CONF_SDC_EN | IPU_CONF_DI_EN; 587 - break; 588 - default: 589 - mask = 0; 590 - break; 591 - } 592 - 593 - return mask; 594 - } 595 - 596 - /** 597 - * ipu_enable_channel() - enable an IPU channel. 598 - * @idmac: IPU DMAC context. 599 - * @ichan: IDMAC channel. 600 - * @return: 0 on success or negative error code on failure. 601 - */ 602 - static int ipu_enable_channel(struct idmac *idmac, struct idmac_channel *ichan) 603 - { 604 - struct ipu *ipu = to_ipu(idmac); 605 - enum ipu_channel channel = ichan->dma_chan.chan_id; 606 - uint32_t reg; 607 - unsigned long flags; 608 - 609 - spin_lock_irqsave(&ipu->lock, flags); 610 - 611 - /* Reset to buffer 0 */ 612 - idmac_write_ipureg(ipu, 1UL << channel, IPU_CHA_CUR_BUF); 613 - ichan->active_buffer = 0; 614 - ichan->status = IPU_CHANNEL_ENABLED; 615 - 616 - switch (channel) { 617 - case IDMAC_SDC_0: 618 - case IDMAC_SDC_1: 619 - case IDMAC_IC_7: 620 - ipu_channel_set_priority(ipu, channel, true); 621 - break; 622 - default: 623 - break; 624 - } 625 - 626 - reg = idmac_read_icreg(ipu, IDMAC_CHA_EN); 627 - 628 - idmac_write_icreg(ipu, reg | (1UL << channel), IDMAC_CHA_EN); 629 - 630 - ipu_ic_enable_task(ipu, channel); 631 - 632 - spin_unlock_irqrestore(&ipu->lock, flags); 633 - return 0; 634 - } 635 - 636 - /** 637 - * ipu_init_channel_buffer() - initialize a buffer for logical IPU channel. 638 - * @ichan: IDMAC channel. 639 - * @pixel_fmt: pixel format of buffer. Pixel format is a FOURCC ASCII code. 640 - * @width: width of buffer in pixels. 641 - * @height: height of buffer in pixels. 642 - * @stride: stride length of buffer in pixels. 643 - * @rot_mode: rotation mode of buffer. A rotation setting other than 644 - * IPU_ROTATE_VERT_FLIP should only be used for input buffers of 645 - * rotation channels. 646 - * @phyaddr_0: buffer 0 physical address. 647 - * @phyaddr_1: buffer 1 physical address. Setting this to a value other than 648 - * NULL enables double buffering mode. 649 - * @return: 0 on success or negative error code on failure. 650 - */ 651 - static int ipu_init_channel_buffer(struct idmac_channel *ichan, 652 - enum pixel_fmt pixel_fmt, 653 - uint16_t width, uint16_t height, 654 - uint32_t stride, 655 - enum ipu_rotate_mode rot_mode, 656 - dma_addr_t phyaddr_0, dma_addr_t phyaddr_1) 657 - { 658 - enum ipu_channel channel = ichan->dma_chan.chan_id; 659 - struct idmac *idmac = to_idmac(ichan->dma_chan.device); 660 - struct ipu *ipu = to_ipu(idmac); 661 - union chan_param_mem params = {}; 662 - unsigned long flags; 663 - uint32_t reg; 664 - uint32_t stride_bytes; 665 - 666 - stride_bytes = stride * bytes_per_pixel(pixel_fmt); 667 - 668 - if (stride_bytes % 4) { 669 - dev_err(ipu->dev, 670 - "Stride length must be 32-bit aligned, stride = %d, bytes = %d\n", 671 - stride, stride_bytes); 672 - return -EINVAL; 673 - } 674 - 675 - /* IC channel's stride must be a multiple of 8 pixels */ 676 - if ((channel <= IDMAC_IC_13) && (stride % 8)) { 677 - dev_err(ipu->dev, "Stride must be 8 pixel multiple\n"); 678 - return -EINVAL; 679 - } 680 - 681 - /* Build parameter memory data for DMA channel */ 682 - ipu_ch_param_set_size(&params, pixel_fmt, width, height, stride_bytes); 683 - ipu_ch_param_set_buffer(&params, phyaddr_0, phyaddr_1); 684 - ipu_ch_param_set_rotation(&params, rot_mode); 685 - 686 - spin_lock_irqsave(&ipu->lock, flags); 687 - 688 - ipu_write_param_mem(dma_param_addr(channel), (uint32_t *)&params, 10); 689 - 690 - reg = idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL); 691 - 692 - if (phyaddr_1) 693 - reg |= 1UL << channel; 694 - else 695 - reg &= ~(1UL << channel); 696 - 697 - idmac_write_ipureg(ipu, reg, IPU_CHA_DB_MODE_SEL); 698 - 699 - ichan->status = IPU_CHANNEL_READY; 700 - 701 - spin_unlock_irqrestore(&ipu->lock, flags); 702 - 703 - return 0; 704 - } 705 - 706 - /** 707 - * ipu_select_buffer() - mark a channel's buffer as ready. 708 - * @channel: channel ID. 709 - * @buffer_n: buffer number to mark ready. 710 - */ 711 - static void ipu_select_buffer(enum ipu_channel channel, int buffer_n) 712 - { 713 - /* No locking - this is a write-one-to-set register, cleared by IPU */ 714 - if (buffer_n == 0) 715 - /* Mark buffer 0 as ready. */ 716 - idmac_write_ipureg(&ipu_data, 1UL << channel, IPU_CHA_BUF0_RDY); 717 - else 718 - /* Mark buffer 1 as ready. */ 719 - idmac_write_ipureg(&ipu_data, 1UL << channel, IPU_CHA_BUF1_RDY); 720 - } 721 - 722 - /** 723 - * ipu_update_channel_buffer() - update physical address of a channel buffer. 724 - * @ichan: IDMAC channel. 725 - * @buffer_n: buffer number to update. 726 - * 0 or 1 are the only valid values. 727 - * @phyaddr: buffer physical address. 728 - */ 729 - /* Called under spin_lock(_irqsave)(&ichan->lock) */ 730 - static void ipu_update_channel_buffer(struct idmac_channel *ichan, 731 - int buffer_n, dma_addr_t phyaddr) 732 - { 733 - enum ipu_channel channel = ichan->dma_chan.chan_id; 734 - uint32_t reg; 735 - unsigned long flags; 736 - 737 - spin_lock_irqsave(&ipu_data.lock, flags); 738 - 739 - if (buffer_n == 0) { 740 - reg = idmac_read_ipureg(&ipu_data, IPU_CHA_BUF0_RDY); 741 - if (reg & (1UL << channel)) { 742 - ipu_ic_disable_task(&ipu_data, channel); 743 - ichan->status = IPU_CHANNEL_READY; 744 - } 745 - 746 - /* 44.3.3.1.9 - Row Number 1 (WORD1, offset 0) */ 747 - idmac_write_ipureg(&ipu_data, dma_param_addr(channel) + 748 - 0x0008UL, IPU_IMA_ADDR); 749 - idmac_write_ipureg(&ipu_data, phyaddr, IPU_IMA_DATA); 750 - } else { 751 - reg = idmac_read_ipureg(&ipu_data, IPU_CHA_BUF1_RDY); 752 - if (reg & (1UL << channel)) { 753 - ipu_ic_disable_task(&ipu_data, channel); 754 - ichan->status = IPU_CHANNEL_READY; 755 - } 756 - 757 - /* Check if double-buffering is already enabled */ 758 - reg = idmac_read_ipureg(&ipu_data, IPU_CHA_DB_MODE_SEL); 759 - 760 - if (!(reg & (1UL << channel))) 761 - idmac_write_ipureg(&ipu_data, reg | (1UL << channel), 762 - IPU_CHA_DB_MODE_SEL); 763 - 764 - /* 44.3.3.1.9 - Row Number 1 (WORD1, offset 1) */ 765 - idmac_write_ipureg(&ipu_data, dma_param_addr(channel) + 766 - 0x0009UL, IPU_IMA_ADDR); 767 - idmac_write_ipureg(&ipu_data, phyaddr, IPU_IMA_DATA); 768 - } 769 - 770 - spin_unlock_irqrestore(&ipu_data.lock, flags); 771 - } 772 - 773 - /* Called under spin_lock_irqsave(&ichan->lock) */ 774 - static int ipu_submit_buffer(struct idmac_channel *ichan, 775 - struct idmac_tx_desc *desc, struct scatterlist *sg, int buf_idx) 776 - { 777 - unsigned int chan_id = ichan->dma_chan.chan_id; 778 - struct device *dev = &ichan->dma_chan.dev->device; 779 - 780 - if (async_tx_test_ack(&desc->txd)) 781 - return -EINTR; 782 - 783 - /* 784 - * On first invocation this shouldn't be necessary, the call to 785 - * ipu_init_channel_buffer() above will set addresses for us, so we 786 - * could make it conditional on status >= IPU_CHANNEL_ENABLED, but 787 - * doing it again shouldn't hurt either. 788 - */ 789 - ipu_update_channel_buffer(ichan, buf_idx, sg_dma_address(sg)); 790 - 791 - ipu_select_buffer(chan_id, buf_idx); 792 - dev_dbg(dev, "Updated sg %p on channel 0x%x buffer %d\n", 793 - sg, chan_id, buf_idx); 794 - 795 - return 0; 796 - } 797 - 798 - /* Called under spin_lock_irqsave(&ichan->lock) */ 799 - static int ipu_submit_channel_buffers(struct idmac_channel *ichan, 800 - struct idmac_tx_desc *desc) 801 - { 802 - struct scatterlist *sg; 803 - int i, ret = 0; 804 - 805 - for (i = 0, sg = desc->sg; i < 2 && sg; i++) { 806 - if (!ichan->sg[i]) { 807 - ichan->sg[i] = sg; 808 - 809 - ret = ipu_submit_buffer(ichan, desc, sg, i); 810 - if (ret < 0) 811 - return ret; 812 - 813 - sg = sg_next(sg); 814 - } 815 - } 816 - 817 - return ret; 818 - } 819 - 820 - static dma_cookie_t idmac_tx_submit(struct dma_async_tx_descriptor *tx) 821 - { 822 - struct idmac_tx_desc *desc = to_tx_desc(tx); 823 - struct idmac_channel *ichan = to_idmac_chan(tx->chan); 824 - struct idmac *idmac = to_idmac(tx->chan->device); 825 - struct ipu *ipu = to_ipu(idmac); 826 - struct device *dev = &ichan->dma_chan.dev->device; 827 - dma_cookie_t cookie; 828 - unsigned long flags; 829 - int ret; 830 - 831 - /* Sanity check */ 832 - if (!list_empty(&desc->list)) { 833 - /* The descriptor doesn't belong to client */ 834 - dev_err(dev, "Descriptor %p not prepared!\n", tx); 835 - return -EBUSY; 836 - } 837 - 838 - mutex_lock(&ichan->chan_mutex); 839 - 840 - async_tx_clear_ack(tx); 841 - 842 - if (ichan->status < IPU_CHANNEL_READY) { 843 - struct idmac_video_param *video = &ichan->params.video; 844 - /* 845 - * Initial buffer assignment - the first two sg-entries from 846 - * the descriptor will end up in the IDMAC buffers 847 - */ 848 - dma_addr_t dma_1 = sg_is_last(desc->sg) ? 0 : 849 - sg_dma_address(&desc->sg[1]); 850 - 851 - WARN_ON(ichan->sg[0] || ichan->sg[1]); 852 - 853 - cookie = ipu_init_channel_buffer(ichan, 854 - video->out_pixel_fmt, 855 - video->out_width, 856 - video->out_height, 857 - video->out_stride, 858 - IPU_ROTATE_NONE, 859 - sg_dma_address(&desc->sg[0]), 860 - dma_1); 861 - if (cookie < 0) 862 - goto out; 863 - } 864 - 865 - dev_dbg(dev, "Submitting sg %p\n", &desc->sg[0]); 866 - 867 - cookie = dma_cookie_assign(tx); 868 - 869 - /* ipu->lock can be taken under ichan->lock, but not v.v. */ 870 - spin_lock_irqsave(&ichan->lock, flags); 871 - 872 - list_add_tail(&desc->list, &ichan->queue); 873 - /* submit_buffers() atomically verifies and fills empty sg slots */ 874 - ret = ipu_submit_channel_buffers(ichan, desc); 875 - 876 - spin_unlock_irqrestore(&ichan->lock, flags); 877 - 878 - if (ret < 0) { 879 - cookie = ret; 880 - goto dequeue; 881 - } 882 - 883 - if (ichan->status < IPU_CHANNEL_ENABLED) { 884 - ret = ipu_enable_channel(idmac, ichan); 885 - if (ret < 0) { 886 - cookie = ret; 887 - goto dequeue; 888 - } 889 - } 890 - 891 - dump_idmac_reg(ipu); 892 - 893 - dequeue: 894 - if (cookie < 0) { 895 - spin_lock_irqsave(&ichan->lock, flags); 896 - list_del_init(&desc->list); 897 - spin_unlock_irqrestore(&ichan->lock, flags); 898 - tx->cookie = cookie; 899 - ichan->dma_chan.cookie = cookie; 900 - } 901 - 902 - out: 903 - mutex_unlock(&ichan->chan_mutex); 904 - 905 - return cookie; 906 - } 907 - 908 - /* Called with ichan->chan_mutex held */ 909 - static int idmac_desc_alloc(struct idmac_channel *ichan, int n) 910 - { 911 - struct idmac_tx_desc *desc = 912 - vmalloc(array_size(n, sizeof(struct idmac_tx_desc))); 913 - struct idmac *idmac = to_idmac(ichan->dma_chan.device); 914 - 915 - if (!desc) 916 - return -ENOMEM; 917 - 918 - /* No interrupts, just disable the tasklet for a moment */ 919 - tasklet_disable(&to_ipu(idmac)->tasklet); 920 - 921 - ichan->n_tx_desc = n; 922 - ichan->desc = desc; 923 - INIT_LIST_HEAD(&ichan->queue); 924 - INIT_LIST_HEAD(&ichan->free_list); 925 - 926 - while (n--) { 927 - struct dma_async_tx_descriptor *txd = &desc->txd; 928 - 929 - memset(txd, 0, sizeof(*txd)); 930 - dma_async_tx_descriptor_init(txd, &ichan->dma_chan); 931 - txd->tx_submit = idmac_tx_submit; 932 - 933 - list_add(&desc->list, &ichan->free_list); 934 - 935 - desc++; 936 - } 937 - 938 - tasklet_enable(&to_ipu(idmac)->tasklet); 939 - 940 - return 0; 941 - } 942 - 943 - /** 944 - * ipu_init_channel() - initialize an IPU channel. 945 - * @idmac: IPU DMAC context. 946 - * @ichan: pointer to the channel object. 947 - * @return 0 on success or negative error code on failure. 948 - */ 949 - static int ipu_init_channel(struct idmac *idmac, struct idmac_channel *ichan) 950 - { 951 - union ipu_channel_param *params = &ichan->params; 952 - uint32_t ipu_conf; 953 - enum ipu_channel channel = ichan->dma_chan.chan_id; 954 - unsigned long flags; 955 - uint32_t reg; 956 - struct ipu *ipu = to_ipu(idmac); 957 - int ret = 0, n_desc = 0; 958 - 959 - dev_dbg(ipu->dev, "init channel = %d\n", channel); 960 - 961 - if (channel != IDMAC_SDC_0 && channel != IDMAC_SDC_1 && 962 - channel != IDMAC_IC_7) 963 - return -EINVAL; 964 - 965 - spin_lock_irqsave(&ipu->lock, flags); 966 - 967 - switch (channel) { 968 - case IDMAC_IC_7: 969 - n_desc = 16; 970 - reg = idmac_read_icreg(ipu, IC_CONF); 971 - idmac_write_icreg(ipu, reg & ~IC_CONF_CSI_MEM_WR_EN, IC_CONF); 972 - break; 973 - case IDMAC_IC_0: 974 - n_desc = 16; 975 - reg = idmac_read_ipureg(ipu, IPU_FS_PROC_FLOW); 976 - idmac_write_ipureg(ipu, reg & ~FS_ENC_IN_VALID, IPU_FS_PROC_FLOW); 977 - ret = ipu_ic_init_prpenc(ipu, params, true); 978 - break; 979 - case IDMAC_SDC_0: 980 - case IDMAC_SDC_1: 981 - n_desc = 4; 982 - break; 983 - default: 984 - break; 985 - } 986 - 987 - ipu->channel_init_mask |= 1L << channel; 988 - 989 - /* Enable IPU sub module */ 990 - ipu_conf = idmac_read_ipureg(ipu, IPU_CONF) | 991 - ipu_channel_conf_mask(channel); 992 - idmac_write_ipureg(ipu, ipu_conf, IPU_CONF); 993 - 994 - spin_unlock_irqrestore(&ipu->lock, flags); 995 - 996 - if (n_desc && !ichan->desc) 997 - ret = idmac_desc_alloc(ichan, n_desc); 998 - 999 - dump_idmac_reg(ipu); 1000 - 1001 - return ret; 1002 - } 1003 - 1004 - /** 1005 - * ipu_uninit_channel() - uninitialize an IPU channel. 1006 - * @idmac: IPU DMAC context. 1007 - * @ichan: pointer to the channel object. 1008 - */ 1009 - static void ipu_uninit_channel(struct idmac *idmac, struct idmac_channel *ichan) 1010 - { 1011 - enum ipu_channel channel = ichan->dma_chan.chan_id; 1012 - unsigned long flags; 1013 - uint32_t reg; 1014 - unsigned long chan_mask = 1UL << channel; 1015 - uint32_t ipu_conf; 1016 - struct ipu *ipu = to_ipu(idmac); 1017 - 1018 - spin_lock_irqsave(&ipu->lock, flags); 1019 - 1020 - if (!(ipu->channel_init_mask & chan_mask)) { 1021 - dev_err(ipu->dev, "Channel already uninitialized %d\n", 1022 - channel); 1023 - spin_unlock_irqrestore(&ipu->lock, flags); 1024 - return; 1025 - } 1026 - 1027 - /* Reset the double buffer */ 1028 - reg = idmac_read_ipureg(ipu, IPU_CHA_DB_MODE_SEL); 1029 - idmac_write_ipureg(ipu, reg & ~chan_mask, IPU_CHA_DB_MODE_SEL); 1030 - 1031 - ichan->sec_chan_en = false; 1032 - 1033 - switch (channel) { 1034 - case IDMAC_IC_7: 1035 - reg = idmac_read_icreg(ipu, IC_CONF); 1036 - idmac_write_icreg(ipu, reg & ~(IC_CONF_RWS_EN | IC_CONF_PRPENC_EN), 1037 - IC_CONF); 1038 - break; 1039 - case IDMAC_IC_0: 1040 - reg = idmac_read_icreg(ipu, IC_CONF); 1041 - idmac_write_icreg(ipu, reg & ~(IC_CONF_PRPENC_EN | IC_CONF_PRPENC_CSC1), 1042 - IC_CONF); 1043 - break; 1044 - case IDMAC_SDC_0: 1045 - case IDMAC_SDC_1: 1046 - default: 1047 - break; 1048 - } 1049 - 1050 - ipu->channel_init_mask &= ~(1L << channel); 1051 - 1052 - ipu_conf = idmac_read_ipureg(ipu, IPU_CONF) & 1053 - ~ipu_channel_conf_mask(channel); 1054 - idmac_write_ipureg(ipu, ipu_conf, IPU_CONF); 1055 - 1056 - spin_unlock_irqrestore(&ipu->lock, flags); 1057 - 1058 - ichan->n_tx_desc = 0; 1059 - vfree(ichan->desc); 1060 - ichan->desc = NULL; 1061 - } 1062 - 1063 - /** 1064 - * ipu_disable_channel() - disable an IPU channel. 1065 - * @idmac: IPU DMAC context. 1066 - * @ichan: channel object pointer. 1067 - * @wait_for_stop: flag to set whether to wait for channel end of frame or 1068 - * return immediately. 1069 - * @return: 0 on success or negative error code on failure. 1070 - */ 1071 - static int ipu_disable_channel(struct idmac *idmac, struct idmac_channel *ichan, 1072 - bool wait_for_stop) 1073 - { 1074 - enum ipu_channel channel = ichan->dma_chan.chan_id; 1075 - struct ipu *ipu = to_ipu(idmac); 1076 - uint32_t reg; 1077 - unsigned long flags; 1078 - unsigned long chan_mask = 1UL << channel; 1079 - unsigned int timeout; 1080 - 1081 - if (wait_for_stop && channel != IDMAC_SDC_1 && channel != IDMAC_SDC_0) { 1082 - timeout = 40; 1083 - /* This waiting always fails. Related to spurious irq problem */ 1084 - while ((idmac_read_icreg(ipu, IDMAC_CHA_BUSY) & chan_mask) || 1085 - (ipu_channel_status(ipu, channel) == TASK_STAT_ACTIVE)) { 1086 - timeout--; 1087 - msleep(10); 1088 - 1089 - if (!timeout) { 1090 - dev_dbg(ipu->dev, 1091 - "Warning: timeout waiting for channel %u to " 1092 - "stop: buf0_rdy = 0x%08X, buf1_rdy = 0x%08X, " 1093 - "busy = 0x%08X, tstat = 0x%08X\n", channel, 1094 - idmac_read_ipureg(ipu, IPU_CHA_BUF0_RDY), 1095 - idmac_read_ipureg(ipu, IPU_CHA_BUF1_RDY), 1096 - idmac_read_icreg(ipu, IDMAC_CHA_BUSY), 1097 - idmac_read_ipureg(ipu, IPU_TASKS_STAT)); 1098 - break; 1099 - } 1100 - } 1101 - dev_dbg(ipu->dev, "timeout = %d * 10ms\n", 40 - timeout); 1102 - } 1103 - /* SDC BG and FG must be disabled before DMA is disabled */ 1104 - if (wait_for_stop && (channel == IDMAC_SDC_0 || 1105 - channel == IDMAC_SDC_1)) { 1106 - for (timeout = 5; 1107 - timeout && !ipu_irq_status(ichan->eof_irq); timeout--) 1108 - msleep(5); 1109 - } 1110 - 1111 - spin_lock_irqsave(&ipu->lock, flags); 1112 - 1113 - /* Disable IC task */ 1114 - ipu_ic_disable_task(ipu, channel); 1115 - 1116 - /* Disable DMA channel(s) */ 1117 - reg = idmac_read_icreg(ipu, IDMAC_CHA_EN); 1118 - idmac_write_icreg(ipu, reg & ~chan_mask, IDMAC_CHA_EN); 1119 - 1120 - spin_unlock_irqrestore(&ipu->lock, flags); 1121 - 1122 - return 0; 1123 - } 1124 - 1125 - static struct scatterlist *idmac_sg_next(struct idmac_channel *ichan, 1126 - struct idmac_tx_desc **desc, struct scatterlist *sg) 1127 - { 1128 - struct scatterlist *sgnew = sg ? sg_next(sg) : NULL; 1129 - 1130 - if (sgnew) 1131 - /* next sg-element in this list */ 1132 - return sgnew; 1133 - 1134 - if ((*desc)->list.next == &ichan->queue) 1135 - /* No more descriptors on the queue */ 1136 - return NULL; 1137 - 1138 - /* Fetch next descriptor */ 1139 - *desc = list_entry((*desc)->list.next, struct idmac_tx_desc, list); 1140 - return (*desc)->sg; 1141 - } 1142 - 1143 - /* 1144 - * We have several possibilities here: 1145 - * current BUF next BUF 1146 - * 1147 - * not last sg next not last sg 1148 - * not last sg next last sg 1149 - * last sg first sg from next descriptor 1150 - * last sg NULL 1151 - * 1152 - * Besides, the descriptor queue might be empty or not. We process all these 1153 - * cases carefully. 1154 - */ 1155 - static irqreturn_t idmac_interrupt(int irq, void *dev_id) 1156 - { 1157 - struct idmac_channel *ichan = dev_id; 1158 - struct device *dev = &ichan->dma_chan.dev->device; 1159 - unsigned int chan_id = ichan->dma_chan.chan_id; 1160 - struct scatterlist **sg, *sgnext, *sgnew = NULL; 1161 - /* Next transfer descriptor */ 1162 - struct idmac_tx_desc *desc, *descnew; 1163 - bool done = false; 1164 - u32 ready0, ready1, curbuf, err; 1165 - struct dmaengine_desc_callback cb; 1166 - 1167 - /* IDMAC has cleared the respective BUFx_RDY bit, we manage the buffer */ 1168 - 1169 - dev_dbg(dev, "IDMAC irq %d, buf %d\n", irq, ichan->active_buffer); 1170 - 1171 - spin_lock(&ipu_data.lock); 1172 - 1173 - ready0 = idmac_read_ipureg(&ipu_data, IPU_CHA_BUF0_RDY); 1174 - ready1 = idmac_read_ipureg(&ipu_data, IPU_CHA_BUF1_RDY); 1175 - curbuf = idmac_read_ipureg(&ipu_data, IPU_CHA_CUR_BUF); 1176 - err = idmac_read_ipureg(&ipu_data, IPU_INT_STAT_4); 1177 - 1178 - if (err & (1 << chan_id)) { 1179 - idmac_write_ipureg(&ipu_data, 1 << chan_id, IPU_INT_STAT_4); 1180 - spin_unlock(&ipu_data.lock); 1181 - /* 1182 - * Doing this 1183 - * ichan->sg[0] = ichan->sg[1] = NULL; 1184 - * you can force channel re-enable on the next tx_submit(), but 1185 - * this is dirty - think about descriptors with multiple 1186 - * sg elements. 1187 - */ 1188 - dev_warn(dev, "NFB4EOF on channel %d, ready %x, %x, cur %x\n", 1189 - chan_id, ready0, ready1, curbuf); 1190 - return IRQ_HANDLED; 1191 - } 1192 - spin_unlock(&ipu_data.lock); 1193 - 1194 - /* Other interrupts do not interfere with this channel */ 1195 - spin_lock(&ichan->lock); 1196 - if (unlikely((ichan->active_buffer && (ready1 >> chan_id) & 1) || 1197 - (!ichan->active_buffer && (ready0 >> chan_id) & 1) 1198 - )) { 1199 - spin_unlock(&ichan->lock); 1200 - dev_dbg(dev, 1201 - "IRQ with active buffer still ready on channel %x, " 1202 - "active %d, ready %x, %x!\n", chan_id, 1203 - ichan->active_buffer, ready0, ready1); 1204 - return IRQ_NONE; 1205 - } 1206 - 1207 - if (unlikely(list_empty(&ichan->queue))) { 1208 - ichan->sg[ichan->active_buffer] = NULL; 1209 - spin_unlock(&ichan->lock); 1210 - dev_err(dev, 1211 - "IRQ without queued buffers on channel %x, active %d, " 1212 - "ready %x, %x!\n", chan_id, 1213 - ichan->active_buffer, ready0, ready1); 1214 - return IRQ_NONE; 1215 - } 1216 - 1217 - /* 1218 - * active_buffer is a software flag, it shows which buffer we are 1219 - * currently expecting back from the hardware, IDMAC should be 1220 - * processing the other buffer already 1221 - */ 1222 - sg = &ichan->sg[ichan->active_buffer]; 1223 - sgnext = ichan->sg[!ichan->active_buffer]; 1224 - 1225 - if (!*sg) { 1226 - spin_unlock(&ichan->lock); 1227 - return IRQ_HANDLED; 1228 - } 1229 - 1230 - desc = list_entry(ichan->queue.next, struct idmac_tx_desc, list); 1231 - descnew = desc; 1232 - 1233 - dev_dbg(dev, "IDMAC irq %d, dma %#llx, next dma %#llx, current %d, curbuf %#x\n", 1234 - irq, (u64)sg_dma_address(*sg), 1235 - sgnext ? (u64)sg_dma_address(sgnext) : 0, 1236 - ichan->active_buffer, curbuf); 1237 - 1238 - /* Find the descriptor of sgnext */ 1239 - sgnew = idmac_sg_next(ichan, &descnew, *sg); 1240 - if (sgnext != sgnew) 1241 - dev_err(dev, "Submitted buffer %p, next buffer %p\n", sgnext, sgnew); 1242 - 1243 - /* 1244 - * if sgnext == NULL sg must be the last element in a scatterlist and 1245 - * queue must be empty 1246 - */ 1247 - if (unlikely(!sgnext)) { 1248 - if (!WARN_ON(sg_next(*sg))) 1249 - dev_dbg(dev, "Underrun on channel %x\n", chan_id); 1250 - ichan->sg[!ichan->active_buffer] = sgnew; 1251 - 1252 - if (unlikely(sgnew)) { 1253 - ipu_submit_buffer(ichan, descnew, sgnew, !ichan->active_buffer); 1254 - } else { 1255 - spin_lock(&ipu_data.lock); 1256 - ipu_ic_disable_task(&ipu_data, chan_id); 1257 - spin_unlock(&ipu_data.lock); 1258 - ichan->status = IPU_CHANNEL_READY; 1259 - /* Continue to check for complete descriptor */ 1260 - } 1261 - } 1262 - 1263 - /* Calculate and submit the next sg element */ 1264 - sgnew = idmac_sg_next(ichan, &descnew, sgnew); 1265 - 1266 - if (unlikely(!sg_next(*sg)) || !sgnext) { 1267 - /* 1268 - * Last element in scatterlist done, remove from the queue, 1269 - * _init for debugging 1270 - */ 1271 - list_del_init(&desc->list); 1272 - done = true; 1273 - } 1274 - 1275 - *sg = sgnew; 1276 - 1277 - if (likely(sgnew) && 1278 - ipu_submit_buffer(ichan, descnew, sgnew, ichan->active_buffer) < 0) { 1279 - dmaengine_desc_get_callback(&descnew->txd, &cb); 1280 - 1281 - list_del_init(&descnew->list); 1282 - spin_unlock(&ichan->lock); 1283 - 1284 - dmaengine_desc_callback_invoke(&cb, NULL); 1285 - spin_lock(&ichan->lock); 1286 - } 1287 - 1288 - /* Flip the active buffer - even if update above failed */ 1289 - ichan->active_buffer = !ichan->active_buffer; 1290 - if (done) 1291 - dma_cookie_complete(&desc->txd); 1292 - 1293 - dmaengine_desc_get_callback(&desc->txd, &cb); 1294 - 1295 - spin_unlock(&ichan->lock); 1296 - 1297 - if (done && (desc->txd.flags & DMA_PREP_INTERRUPT)) 1298 - dmaengine_desc_callback_invoke(&cb, NULL); 1299 - 1300 - return IRQ_HANDLED; 1301 - } 1302 - 1303 - static void ipu_gc_tasklet(struct tasklet_struct *t) 1304 - { 1305 - struct ipu *ipu = from_tasklet(ipu, t, tasklet); 1306 - int i; 1307 - 1308 - for (i = 0; i < IPU_CHANNELS_NUM; i++) { 1309 - struct idmac_channel *ichan = ipu->channel + i; 1310 - struct idmac_tx_desc *desc; 1311 - unsigned long flags; 1312 - struct scatterlist *sg; 1313 - int j, k; 1314 - 1315 - for (j = 0; j < ichan->n_tx_desc; j++) { 1316 - desc = ichan->desc + j; 1317 - spin_lock_irqsave(&ichan->lock, flags); 1318 - if (async_tx_test_ack(&desc->txd)) { 1319 - list_move(&desc->list, &ichan->free_list); 1320 - for_each_sg(desc->sg, sg, desc->sg_len, k) { 1321 - if (ichan->sg[0] == sg) 1322 - ichan->sg[0] = NULL; 1323 - else if (ichan->sg[1] == sg) 1324 - ichan->sg[1] = NULL; 1325 - } 1326 - async_tx_clear_ack(&desc->txd); 1327 - } 1328 - spin_unlock_irqrestore(&ichan->lock, flags); 1329 - } 1330 - } 1331 - } 1332 - 1333 - /* Allocate and initialise a transfer descriptor. */ 1334 - static struct dma_async_tx_descriptor *idmac_prep_slave_sg(struct dma_chan *chan, 1335 - struct scatterlist *sgl, unsigned int sg_len, 1336 - enum dma_transfer_direction direction, unsigned long tx_flags, 1337 - void *context) 1338 - { 1339 - struct idmac_channel *ichan = to_idmac_chan(chan); 1340 - struct idmac_tx_desc *desc = NULL; 1341 - struct dma_async_tx_descriptor *txd = NULL; 1342 - unsigned long flags; 1343 - 1344 - /* We only can handle these three channels so far */ 1345 - if (chan->chan_id != IDMAC_SDC_0 && chan->chan_id != IDMAC_SDC_1 && 1346 - chan->chan_id != IDMAC_IC_7) 1347 - return NULL; 1348 - 1349 - if (!is_slave_direction(direction)) { 1350 - dev_err(chan->device->dev, "Invalid DMA direction %d!\n", direction); 1351 - return NULL; 1352 - } 1353 - 1354 - mutex_lock(&ichan->chan_mutex); 1355 - 1356 - spin_lock_irqsave(&ichan->lock, flags); 1357 - if (!list_empty(&ichan->free_list)) { 1358 - desc = list_entry(ichan->free_list.next, 1359 - struct idmac_tx_desc, list); 1360 - 1361 - list_del_init(&desc->list); 1362 - 1363 - desc->sg_len = sg_len; 1364 - desc->sg = sgl; 1365 - txd = &desc->txd; 1366 - txd->flags = tx_flags; 1367 - } 1368 - spin_unlock_irqrestore(&ichan->lock, flags); 1369 - 1370 - mutex_unlock(&ichan->chan_mutex); 1371 - 1372 - tasklet_schedule(&to_ipu(to_idmac(chan->device))->tasklet); 1373 - 1374 - return txd; 1375 - } 1376 - 1377 - /* Re-select the current buffer and re-activate the channel */ 1378 - static void idmac_issue_pending(struct dma_chan *chan) 1379 - { 1380 - struct idmac_channel *ichan = to_idmac_chan(chan); 1381 - struct idmac *idmac = to_idmac(chan->device); 1382 - struct ipu *ipu = to_ipu(idmac); 1383 - unsigned long flags; 1384 - 1385 - /* This is not always needed, but doesn't hurt either */ 1386 - spin_lock_irqsave(&ipu->lock, flags); 1387 - ipu_select_buffer(chan->chan_id, ichan->active_buffer); 1388 - spin_unlock_irqrestore(&ipu->lock, flags); 1389 - 1390 - /* 1391 - * Might need to perform some parts of initialisation from 1392 - * ipu_enable_channel(), but not all, we do not want to reset to buffer 1393 - * 0, don't need to set priority again either, but re-enabling the task 1394 - * and the channel might be a good idea. 1395 - */ 1396 - } 1397 - 1398 - static int idmac_pause(struct dma_chan *chan) 1399 - { 1400 - struct idmac_channel *ichan = to_idmac_chan(chan); 1401 - struct idmac *idmac = to_idmac(chan->device); 1402 - struct ipu *ipu = to_ipu(idmac); 1403 - struct list_head *list, *tmp; 1404 - unsigned long flags; 1405 - 1406 - mutex_lock(&ichan->chan_mutex); 1407 - 1408 - spin_lock_irqsave(&ipu->lock, flags); 1409 - ipu_ic_disable_task(ipu, chan->chan_id); 1410 - 1411 - /* Return all descriptors into "prepared" state */ 1412 - list_for_each_safe(list, tmp, &ichan->queue) 1413 - list_del_init(list); 1414 - 1415 - ichan->sg[0] = NULL; 1416 - ichan->sg[1] = NULL; 1417 - 1418 - spin_unlock_irqrestore(&ipu->lock, flags); 1419 - 1420 - ichan->status = IPU_CHANNEL_INITIALIZED; 1421 - 1422 - mutex_unlock(&ichan->chan_mutex); 1423 - 1424 - return 0; 1425 - } 1426 - 1427 - static int __idmac_terminate_all(struct dma_chan *chan) 1428 - { 1429 - struct idmac_channel *ichan = to_idmac_chan(chan); 1430 - struct idmac *idmac = to_idmac(chan->device); 1431 - struct ipu *ipu = to_ipu(idmac); 1432 - unsigned long flags; 1433 - int i; 1434 - 1435 - ipu_disable_channel(idmac, ichan, 1436 - ichan->status >= IPU_CHANNEL_ENABLED); 1437 - 1438 - tasklet_disable(&ipu->tasklet); 1439 - 1440 - /* ichan->queue is modified in ISR, have to spinlock */ 1441 - spin_lock_irqsave(&ichan->lock, flags); 1442 - list_splice_init(&ichan->queue, &ichan->free_list); 1443 - 1444 - if (ichan->desc) 1445 - for (i = 0; i < ichan->n_tx_desc; i++) { 1446 - struct idmac_tx_desc *desc = ichan->desc + i; 1447 - if (list_empty(&desc->list)) 1448 - /* Descriptor was prepared, but not submitted */ 1449 - list_add(&desc->list, &ichan->free_list); 1450 - 1451 - async_tx_clear_ack(&desc->txd); 1452 - } 1453 - 1454 - ichan->sg[0] = NULL; 1455 - ichan->sg[1] = NULL; 1456 - spin_unlock_irqrestore(&ichan->lock, flags); 1457 - 1458 - tasklet_enable(&ipu->tasklet); 1459 - 1460 - ichan->status = IPU_CHANNEL_INITIALIZED; 1461 - 1462 - return 0; 1463 - } 1464 - 1465 - static int idmac_terminate_all(struct dma_chan *chan) 1466 - { 1467 - struct idmac_channel *ichan = to_idmac_chan(chan); 1468 - int ret; 1469 - 1470 - mutex_lock(&ichan->chan_mutex); 1471 - 1472 - ret = __idmac_terminate_all(chan); 1473 - 1474 - mutex_unlock(&ichan->chan_mutex); 1475 - 1476 - return ret; 1477 - } 1478 - 1479 - #ifdef DEBUG 1480 - static irqreturn_t ic_sof_irq(int irq, void *dev_id) 1481 - { 1482 - struct idmac_channel *ichan = dev_id; 1483 - printk(KERN_DEBUG "Got SOF IRQ %d on Channel %d\n", 1484 - irq, ichan->dma_chan.chan_id); 1485 - disable_irq_nosync(irq); 1486 - return IRQ_HANDLED; 1487 - } 1488 - 1489 - static irqreturn_t ic_eof_irq(int irq, void *dev_id) 1490 - { 1491 - struct idmac_channel *ichan = dev_id; 1492 - printk(KERN_DEBUG "Got EOF IRQ %d on Channel %d\n", 1493 - irq, ichan->dma_chan.chan_id); 1494 - disable_irq_nosync(irq); 1495 - return IRQ_HANDLED; 1496 - } 1497 - 1498 - static int ic_sof = -EINVAL, ic_eof = -EINVAL; 1499 - #endif 1500 - 1501 - static int idmac_alloc_chan_resources(struct dma_chan *chan) 1502 - { 1503 - struct idmac_channel *ichan = to_idmac_chan(chan); 1504 - struct idmac *idmac = to_idmac(chan->device); 1505 - int ret; 1506 - 1507 - /* dmaengine.c now guarantees to only offer free channels */ 1508 - BUG_ON(chan->client_count > 1); 1509 - WARN_ON(ichan->status != IPU_CHANNEL_FREE); 1510 - 1511 - dma_cookie_init(chan); 1512 - 1513 - ret = ipu_irq_map(chan->chan_id); 1514 - if (ret < 0) 1515 - goto eimap; 1516 - 1517 - ichan->eof_irq = ret; 1518 - 1519 - /* 1520 - * Important to first disable the channel, because maybe someone 1521 - * used it before us, e.g., the bootloader 1522 - */ 1523 - ipu_disable_channel(idmac, ichan, true); 1524 - 1525 - ret = ipu_init_channel(idmac, ichan); 1526 - if (ret < 0) 1527 - goto eichan; 1528 - 1529 - ret = request_irq(ichan->eof_irq, idmac_interrupt, 0, 1530 - ichan->eof_name, ichan); 1531 - if (ret < 0) 1532 - goto erirq; 1533 - 1534 - #ifdef DEBUG 1535 - if (chan->chan_id == IDMAC_IC_7) { 1536 - ic_sof = ipu_irq_map(69); 1537 - if (ic_sof > 0) { 1538 - ret = request_irq(ic_sof, ic_sof_irq, 0, "IC SOF", ichan); 1539 - if (ret) 1540 - dev_err(&chan->dev->device, "request irq failed for IC SOF"); 1541 - } 1542 - ic_eof = ipu_irq_map(70); 1543 - if (ic_eof > 0) { 1544 - ret = request_irq(ic_eof, ic_eof_irq, 0, "IC EOF", ichan); 1545 - if (ret) 1546 - dev_err(&chan->dev->device, "request irq failed for IC EOF"); 1547 - } 1548 - } 1549 - #endif 1550 - 1551 - ichan->status = IPU_CHANNEL_INITIALIZED; 1552 - 1553 - dev_dbg(&chan->dev->device, "Found channel 0x%x, irq %d\n", 1554 - chan->chan_id, ichan->eof_irq); 1555 - 1556 - return ret; 1557 - 1558 - erirq: 1559 - ipu_uninit_channel(idmac, ichan); 1560 - eichan: 1561 - ipu_irq_unmap(chan->chan_id); 1562 - eimap: 1563 - return ret; 1564 - } 1565 - 1566 - static void idmac_free_chan_resources(struct dma_chan *chan) 1567 - { 1568 - struct idmac_channel *ichan = to_idmac_chan(chan); 1569 - struct idmac *idmac = to_idmac(chan->device); 1570 - 1571 - mutex_lock(&ichan->chan_mutex); 1572 - 1573 - __idmac_terminate_all(chan); 1574 - 1575 - if (ichan->status > IPU_CHANNEL_FREE) { 1576 - #ifdef DEBUG 1577 - if (chan->chan_id == IDMAC_IC_7) { 1578 - if (ic_sof > 0) { 1579 - free_irq(ic_sof, ichan); 1580 - ipu_irq_unmap(69); 1581 - ic_sof = -EINVAL; 1582 - } 1583 - if (ic_eof > 0) { 1584 - free_irq(ic_eof, ichan); 1585 - ipu_irq_unmap(70); 1586 - ic_eof = -EINVAL; 1587 - } 1588 - } 1589 - #endif 1590 - free_irq(ichan->eof_irq, ichan); 1591 - ipu_irq_unmap(chan->chan_id); 1592 - } 1593 - 1594 - ichan->status = IPU_CHANNEL_FREE; 1595 - 1596 - ipu_uninit_channel(idmac, ichan); 1597 - 1598 - mutex_unlock(&ichan->chan_mutex); 1599 - 1600 - tasklet_schedule(&to_ipu(idmac)->tasklet); 1601 - } 1602 - 1603 - static enum dma_status idmac_tx_status(struct dma_chan *chan, 1604 - dma_cookie_t cookie, struct dma_tx_state *txstate) 1605 - { 1606 - return dma_cookie_status(chan, cookie, txstate); 1607 - } 1608 - 1609 - static int __init ipu_idmac_init(struct ipu *ipu) 1610 - { 1611 - struct idmac *idmac = &ipu->idmac; 1612 - struct dma_device *dma = &idmac->dma; 1613 - int i; 1614 - 1615 - dma_cap_set(DMA_SLAVE, dma->cap_mask); 1616 - dma_cap_set(DMA_PRIVATE, dma->cap_mask); 1617 - 1618 - /* Compulsory common fields */ 1619 - dma->dev = ipu->dev; 1620 - dma->device_alloc_chan_resources = idmac_alloc_chan_resources; 1621 - dma->device_free_chan_resources = idmac_free_chan_resources; 1622 - dma->device_tx_status = idmac_tx_status; 1623 - dma->device_issue_pending = idmac_issue_pending; 1624 - 1625 - /* Compulsory for DMA_SLAVE fields */ 1626 - dma->device_prep_slave_sg = idmac_prep_slave_sg; 1627 - dma->device_pause = idmac_pause; 1628 - dma->device_terminate_all = idmac_terminate_all; 1629 - 1630 - INIT_LIST_HEAD(&dma->channels); 1631 - for (i = 0; i < IPU_CHANNELS_NUM; i++) { 1632 - struct idmac_channel *ichan = ipu->channel + i; 1633 - struct dma_chan *dma_chan = &ichan->dma_chan; 1634 - 1635 - spin_lock_init(&ichan->lock); 1636 - mutex_init(&ichan->chan_mutex); 1637 - 1638 - ichan->status = IPU_CHANNEL_FREE; 1639 - ichan->sec_chan_en = false; 1640 - snprintf(ichan->eof_name, sizeof(ichan->eof_name), "IDMAC EOF %d", i); 1641 - 1642 - dma_chan->device = &idmac->dma; 1643 - dma_cookie_init(dma_chan); 1644 - dma_chan->chan_id = i; 1645 - list_add_tail(&dma_chan->device_node, &dma->channels); 1646 - } 1647 - 1648 - idmac_write_icreg(ipu, 0x00000070, IDMAC_CONF); 1649 - 1650 - return dma_async_device_register(&idmac->dma); 1651 - } 1652 - 1653 - static void ipu_idmac_exit(struct ipu *ipu) 1654 - { 1655 - int i; 1656 - struct idmac *idmac = &ipu->idmac; 1657 - 1658 - for (i = 0; i < IPU_CHANNELS_NUM; i++) { 1659 - struct idmac_channel *ichan = ipu->channel + i; 1660 - 1661 - idmac_terminate_all(&ichan->dma_chan); 1662 - } 1663 - 1664 - dma_async_device_unregister(&idmac->dma); 1665 - } 1666 - 1667 - /***************************************************************************** 1668 - * IPU common probe / remove 1669 - */ 1670 - 1671 - static int __init ipu_probe(struct platform_device *pdev) 1672 - { 1673 - struct resource *mem_ipu, *mem_ic; 1674 - int ret; 1675 - 1676 - spin_lock_init(&ipu_data.lock); 1677 - 1678 - mem_ipu = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1679 - mem_ic = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1680 - if (!mem_ipu || !mem_ic) 1681 - return -EINVAL; 1682 - 1683 - ipu_data.dev = &pdev->dev; 1684 - 1685 - platform_set_drvdata(pdev, &ipu_data); 1686 - 1687 - ret = platform_get_irq(pdev, 0); 1688 - if (ret < 0) 1689 - goto err_noirq; 1690 - 1691 - ipu_data.irq_fn = ret; 1692 - ret = platform_get_irq(pdev, 1); 1693 - if (ret < 0) 1694 - goto err_noirq; 1695 - 1696 - ipu_data.irq_err = ret; 1697 - 1698 - dev_dbg(&pdev->dev, "fn irq %u, err irq %u\n", 1699 - ipu_data.irq_fn, ipu_data.irq_err); 1700 - 1701 - /* Remap IPU common registers */ 1702 - ipu_data.reg_ipu = ioremap(mem_ipu->start, resource_size(mem_ipu)); 1703 - if (!ipu_data.reg_ipu) { 1704 - ret = -ENOMEM; 1705 - goto err_ioremap_ipu; 1706 - } 1707 - 1708 - /* Remap Image Converter and Image DMA Controller registers */ 1709 - ipu_data.reg_ic = ioremap(mem_ic->start, resource_size(mem_ic)); 1710 - if (!ipu_data.reg_ic) { 1711 - ret = -ENOMEM; 1712 - goto err_ioremap_ic; 1713 - } 1714 - 1715 - /* Get IPU clock */ 1716 - ipu_data.ipu_clk = clk_get(&pdev->dev, NULL); 1717 - if (IS_ERR(ipu_data.ipu_clk)) { 1718 - ret = PTR_ERR(ipu_data.ipu_clk); 1719 - goto err_clk_get; 1720 - } 1721 - 1722 - /* Make sure IPU HSP clock is running */ 1723 - clk_prepare_enable(ipu_data.ipu_clk); 1724 - 1725 - /* Disable all interrupts */ 1726 - idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_1); 1727 - idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_2); 1728 - idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_3); 1729 - idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_4); 1730 - idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_5); 1731 - 1732 - dev_dbg(&pdev->dev, "%s @ 0x%08lx, fn irq %u, err irq %u\n", pdev->name, 1733 - (unsigned long)mem_ipu->start, ipu_data.irq_fn, ipu_data.irq_err); 1734 - 1735 - ret = ipu_irq_attach_irq(&ipu_data, pdev); 1736 - if (ret < 0) 1737 - goto err_attach_irq; 1738 - 1739 - /* Initialize DMA engine */ 1740 - ret = ipu_idmac_init(&ipu_data); 1741 - if (ret < 0) 1742 - goto err_idmac_init; 1743 - 1744 - tasklet_setup(&ipu_data.tasklet, ipu_gc_tasklet); 1745 - 1746 - ipu_data.dev = &pdev->dev; 1747 - 1748 - dev_dbg(ipu_data.dev, "IPU initialized\n"); 1749 - 1750 - return 0; 1751 - 1752 - err_idmac_init: 1753 - err_attach_irq: 1754 - ipu_irq_detach_irq(&ipu_data, pdev); 1755 - clk_disable_unprepare(ipu_data.ipu_clk); 1756 - clk_put(ipu_data.ipu_clk); 1757 - err_clk_get: 1758 - iounmap(ipu_data.reg_ic); 1759 - err_ioremap_ic: 1760 - iounmap(ipu_data.reg_ipu); 1761 - err_ioremap_ipu: 1762 - err_noirq: 1763 - dev_err(&pdev->dev, "Failed to probe IPU: %d\n", ret); 1764 - return ret; 1765 - } 1766 - 1767 - static int ipu_remove(struct platform_device *pdev) 1768 - { 1769 - struct ipu *ipu = platform_get_drvdata(pdev); 1770 - 1771 - ipu_idmac_exit(ipu); 1772 - ipu_irq_detach_irq(ipu, pdev); 1773 - clk_disable_unprepare(ipu->ipu_clk); 1774 - clk_put(ipu->ipu_clk); 1775 - iounmap(ipu->reg_ic); 1776 - iounmap(ipu->reg_ipu); 1777 - tasklet_kill(&ipu->tasklet); 1778 - 1779 - return 0; 1780 - } 1781 - 1782 - /* 1783 - * We need two MEM resources - with IPU-common and Image Converter registers, 1784 - * including PF_CONF and IDMAC_* registers, and two IRQs - function and error 1785 - */ 1786 - static struct platform_driver ipu_platform_driver = { 1787 - .driver = { 1788 - .name = "ipu-core", 1789 - }, 1790 - .remove = ipu_remove, 1791 - }; 1792 - 1793 - static int __init ipu_init(void) 1794 - { 1795 - return platform_driver_probe(&ipu_platform_driver, ipu_probe); 1796 - } 1797 - subsys_initcall(ipu_init); 1798 - 1799 - MODULE_DESCRIPTION("IPU core driver"); 1800 - MODULE_AUTHOR("Guennadi Liakhovetski <lg@denx.de>"); 1801 - MODULE_ALIAS("platform:ipu-core");
-173
drivers/dma/ipu/ipu_intern.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Copyright (C) 2008 4 - * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de> 5 - * 6 - * Copyright (C) 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. 7 - */ 8 - 9 - #ifndef _IPU_INTERN_H_ 10 - #define _IPU_INTERN_H_ 11 - 12 - #include <linux/dmaengine.h> 13 - #include <linux/platform_device.h> 14 - #include <linux/interrupt.h> 15 - 16 - /* IPU Common registers */ 17 - #define IPU_CONF 0x00 18 - #define IPU_CHA_BUF0_RDY 0x04 19 - #define IPU_CHA_BUF1_RDY 0x08 20 - #define IPU_CHA_DB_MODE_SEL 0x0C 21 - #define IPU_CHA_CUR_BUF 0x10 22 - #define IPU_FS_PROC_FLOW 0x14 23 - #define IPU_FS_DISP_FLOW 0x18 24 - #define IPU_TASKS_STAT 0x1C 25 - #define IPU_IMA_ADDR 0x20 26 - #define IPU_IMA_DATA 0x24 27 - #define IPU_INT_CTRL_1 0x28 28 - #define IPU_INT_CTRL_2 0x2C 29 - #define IPU_INT_CTRL_3 0x30 30 - #define IPU_INT_CTRL_4 0x34 31 - #define IPU_INT_CTRL_5 0x38 32 - #define IPU_INT_STAT_1 0x3C 33 - #define IPU_INT_STAT_2 0x40 34 - #define IPU_INT_STAT_3 0x44 35 - #define IPU_INT_STAT_4 0x48 36 - #define IPU_INT_STAT_5 0x4C 37 - #define IPU_BRK_CTRL_1 0x50 38 - #define IPU_BRK_CTRL_2 0x54 39 - #define IPU_BRK_STAT 0x58 40 - #define IPU_DIAGB_CTRL 0x5C 41 - 42 - /* IPU_CONF Register bits */ 43 - #define IPU_CONF_CSI_EN 0x00000001 44 - #define IPU_CONF_IC_EN 0x00000002 45 - #define IPU_CONF_ROT_EN 0x00000004 46 - #define IPU_CONF_PF_EN 0x00000008 47 - #define IPU_CONF_SDC_EN 0x00000010 48 - #define IPU_CONF_ADC_EN 0x00000020 49 - #define IPU_CONF_DI_EN 0x00000040 50 - #define IPU_CONF_DU_EN 0x00000080 51 - #define IPU_CONF_PXL_ENDIAN 0x00000100 52 - 53 - /* Image Converter Registers */ 54 - #define IC_CONF 0x88 55 - #define IC_PRP_ENC_RSC 0x8C 56 - #define IC_PRP_VF_RSC 0x90 57 - #define IC_PP_RSC 0x94 58 - #define IC_CMBP_1 0x98 59 - #define IC_CMBP_2 0x9C 60 - #define PF_CONF 0xA0 61 - #define IDMAC_CONF 0xA4 62 - #define IDMAC_CHA_EN 0xA8 63 - #define IDMAC_CHA_PRI 0xAC 64 - #define IDMAC_CHA_BUSY 0xB0 65 - 66 - /* Image Converter Register bits */ 67 - #define IC_CONF_PRPENC_EN 0x00000001 68 - #define IC_CONF_PRPENC_CSC1 0x00000002 69 - #define IC_CONF_PRPENC_ROT_EN 0x00000004 70 - #define IC_CONF_PRPVF_EN 0x00000100 71 - #define IC_CONF_PRPVF_CSC1 0x00000200 72 - #define IC_CONF_PRPVF_CSC2 0x00000400 73 - #define IC_CONF_PRPVF_CMB 0x00000800 74 - #define IC_CONF_PRPVF_ROT_EN 0x00001000 75 - #define IC_CONF_PP_EN 0x00010000 76 - #define IC_CONF_PP_CSC1 0x00020000 77 - #define IC_CONF_PP_CSC2 0x00040000 78 - #define IC_CONF_PP_CMB 0x00080000 79 - #define IC_CONF_PP_ROT_EN 0x00100000 80 - #define IC_CONF_IC_GLB_LOC_A 0x10000000 81 - #define IC_CONF_KEY_COLOR_EN 0x20000000 82 - #define IC_CONF_RWS_EN 0x40000000 83 - #define IC_CONF_CSI_MEM_WR_EN 0x80000000 84 - 85 - #define IDMA_CHAN_INVALID 0x000000FF 86 - #define IDMA_IC_0 0x00000001 87 - #define IDMA_IC_1 0x00000002 88 - #define IDMA_IC_2 0x00000004 89 - #define IDMA_IC_3 0x00000008 90 - #define IDMA_IC_4 0x00000010 91 - #define IDMA_IC_5 0x00000020 92 - #define IDMA_IC_6 0x00000040 93 - #define IDMA_IC_7 0x00000080 94 - #define IDMA_IC_8 0x00000100 95 - #define IDMA_IC_9 0x00000200 96 - #define IDMA_IC_10 0x00000400 97 - #define IDMA_IC_11 0x00000800 98 - #define IDMA_IC_12 0x00001000 99 - #define IDMA_IC_13 0x00002000 100 - #define IDMA_SDC_BG 0x00004000 101 - #define IDMA_SDC_FG 0x00008000 102 - #define IDMA_SDC_MASK 0x00010000 103 - #define IDMA_SDC_PARTIAL 0x00020000 104 - #define IDMA_ADC_SYS1_WR 0x00040000 105 - #define IDMA_ADC_SYS2_WR 0x00080000 106 - #define IDMA_ADC_SYS1_CMD 0x00100000 107 - #define IDMA_ADC_SYS2_CMD 0x00200000 108 - #define IDMA_ADC_SYS1_RD 0x00400000 109 - #define IDMA_ADC_SYS2_RD 0x00800000 110 - #define IDMA_PF_QP 0x01000000 111 - #define IDMA_PF_BSP 0x02000000 112 - #define IDMA_PF_Y_IN 0x04000000 113 - #define IDMA_PF_U_IN 0x08000000 114 - #define IDMA_PF_V_IN 0x10000000 115 - #define IDMA_PF_Y_OUT 0x20000000 116 - #define IDMA_PF_U_OUT 0x40000000 117 - #define IDMA_PF_V_OUT 0x80000000 118 - 119 - #define TSTAT_PF_H264_PAUSE 0x00000001 120 - #define TSTAT_CSI2MEM_MASK 0x0000000C 121 - #define TSTAT_CSI2MEM_OFFSET 2 122 - #define TSTAT_VF_MASK 0x00000600 123 - #define TSTAT_VF_OFFSET 9 124 - #define TSTAT_VF_ROT_MASK 0x000C0000 125 - #define TSTAT_VF_ROT_OFFSET 18 126 - #define TSTAT_ENC_MASK 0x00000180 127 - #define TSTAT_ENC_OFFSET 7 128 - #define TSTAT_ENC_ROT_MASK 0x00030000 129 - #define TSTAT_ENC_ROT_OFFSET 16 130 - #define TSTAT_PP_MASK 0x00001800 131 - #define TSTAT_PP_OFFSET 11 132 - #define TSTAT_PP_ROT_MASK 0x00300000 133 - #define TSTAT_PP_ROT_OFFSET 20 134 - #define TSTAT_PF_MASK 0x00C00000 135 - #define TSTAT_PF_OFFSET 22 136 - #define TSTAT_ADCSYS1_MASK 0x03000000 137 - #define TSTAT_ADCSYS1_OFFSET 24 138 - #define TSTAT_ADCSYS2_MASK 0x0C000000 139 - #define TSTAT_ADCSYS2_OFFSET 26 140 - 141 - #define TASK_STAT_IDLE 0 142 - #define TASK_STAT_ACTIVE 1 143 - #define TASK_STAT_WAIT4READY 2 144 - 145 - struct idmac { 146 - struct dma_device dma; 147 - }; 148 - 149 - struct ipu { 150 - void __iomem *reg_ipu; 151 - void __iomem *reg_ic; 152 - unsigned int irq_fn; /* IPU Function IRQ to the CPU */ 153 - unsigned int irq_err; /* IPU Error IRQ to the CPU */ 154 - unsigned int irq_base; /* Beginning of the IPU IRQ range */ 155 - unsigned long channel_init_mask; 156 - spinlock_t lock; 157 - struct clk *ipu_clk; 158 - struct device *dev; 159 - struct idmac idmac; 160 - struct idmac_channel channel[IPU_CHANNELS_NUM]; 161 - struct tasklet_struct tasklet; 162 - }; 163 - 164 - #define to_idmac(d) container_of(d, struct idmac, dma) 165 - 166 - extern int ipu_irq_attach_irq(struct ipu *ipu, struct platform_device *dev); 167 - extern void ipu_irq_detach_irq(struct ipu *ipu, struct platform_device *dev); 168 - 169 - extern bool ipu_irq_status(uint32_t irq); 170 - extern int ipu_irq_map(unsigned int source); 171 - extern int ipu_irq_unmap(unsigned int source); 172 - 173 - #endif
-367
drivers/dma/ipu/ipu_irq.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * Copyright (C) 2008 4 - * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de> 5 - */ 6 - 7 - #include <linux/init.h> 8 - #include <linux/err.h> 9 - #include <linux/spinlock.h> 10 - #include <linux/delay.h> 11 - #include <linux/clk.h> 12 - #include <linux/irq.h> 13 - #include <linux/io.h> 14 - #include <linux/module.h> 15 - #include <linux/dma/ipu-dma.h> 16 - 17 - #include "ipu_intern.h" 18 - 19 - /* 20 - * Register read / write - shall be inlined by the compiler 21 - */ 22 - static u32 ipu_read_reg(struct ipu *ipu, unsigned long reg) 23 - { 24 - return __raw_readl(ipu->reg_ipu + reg); 25 - } 26 - 27 - static void ipu_write_reg(struct ipu *ipu, u32 value, unsigned long reg) 28 - { 29 - __raw_writel(value, ipu->reg_ipu + reg); 30 - } 31 - 32 - 33 - /* 34 - * IPU IRQ chip driver 35 - */ 36 - 37 - #define IPU_IRQ_NR_FN_BANKS 3 38 - #define IPU_IRQ_NR_ERR_BANKS 2 39 - #define IPU_IRQ_NR_BANKS (IPU_IRQ_NR_FN_BANKS + IPU_IRQ_NR_ERR_BANKS) 40 - 41 - struct ipu_irq_bank { 42 - unsigned int control; 43 - unsigned int status; 44 - struct ipu *ipu; 45 - }; 46 - 47 - static struct ipu_irq_bank irq_bank[IPU_IRQ_NR_BANKS] = { 48 - /* 3 groups of functional interrupts */ 49 - { 50 - .control = IPU_INT_CTRL_1, 51 - .status = IPU_INT_STAT_1, 52 - }, { 53 - .control = IPU_INT_CTRL_2, 54 - .status = IPU_INT_STAT_2, 55 - }, { 56 - .control = IPU_INT_CTRL_3, 57 - .status = IPU_INT_STAT_3, 58 - }, 59 - /* 2 groups of error interrupts */ 60 - { 61 - .control = IPU_INT_CTRL_4, 62 - .status = IPU_INT_STAT_4, 63 - }, { 64 - .control = IPU_INT_CTRL_5, 65 - .status = IPU_INT_STAT_5, 66 - }, 67 - }; 68 - 69 - struct ipu_irq_map { 70 - unsigned int irq; 71 - int source; 72 - struct ipu_irq_bank *bank; 73 - struct ipu *ipu; 74 - }; 75 - 76 - static struct ipu_irq_map irq_map[CONFIG_MX3_IPU_IRQS]; 77 - /* Protects allocations from the above array of maps */ 78 - static DEFINE_MUTEX(map_lock); 79 - /* Protects register accesses and individual mappings */ 80 - static DEFINE_RAW_SPINLOCK(bank_lock); 81 - 82 - static struct ipu_irq_map *src2map(unsigned int src) 83 - { 84 - int i; 85 - 86 - for (i = 0; i < CONFIG_MX3_IPU_IRQS; i++) 87 - if (irq_map[i].source == src) 88 - return irq_map + i; 89 - 90 - return NULL; 91 - } 92 - 93 - static void ipu_irq_unmask(struct irq_data *d) 94 - { 95 - struct ipu_irq_map *map = irq_data_get_irq_chip_data(d); 96 - struct ipu_irq_bank *bank; 97 - uint32_t reg; 98 - unsigned long lock_flags; 99 - 100 - raw_spin_lock_irqsave(&bank_lock, lock_flags); 101 - 102 - bank = map->bank; 103 - if (!bank) { 104 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 105 - pr_err("IPU: %s(%u) - unmapped!\n", __func__, d->irq); 106 - return; 107 - } 108 - 109 - reg = ipu_read_reg(bank->ipu, bank->control); 110 - reg |= (1UL << (map->source & 31)); 111 - ipu_write_reg(bank->ipu, reg, bank->control); 112 - 113 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 114 - } 115 - 116 - static void ipu_irq_mask(struct irq_data *d) 117 - { 118 - struct ipu_irq_map *map = irq_data_get_irq_chip_data(d); 119 - struct ipu_irq_bank *bank; 120 - uint32_t reg; 121 - unsigned long lock_flags; 122 - 123 - raw_spin_lock_irqsave(&bank_lock, lock_flags); 124 - 125 - bank = map->bank; 126 - if (!bank) { 127 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 128 - pr_err("IPU: %s(%u) - unmapped!\n", __func__, d->irq); 129 - return; 130 - } 131 - 132 - reg = ipu_read_reg(bank->ipu, bank->control); 133 - reg &= ~(1UL << (map->source & 31)); 134 - ipu_write_reg(bank->ipu, reg, bank->control); 135 - 136 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 137 - } 138 - 139 - static void ipu_irq_ack(struct irq_data *d) 140 - { 141 - struct ipu_irq_map *map = irq_data_get_irq_chip_data(d); 142 - struct ipu_irq_bank *bank; 143 - unsigned long lock_flags; 144 - 145 - raw_spin_lock_irqsave(&bank_lock, lock_flags); 146 - 147 - bank = map->bank; 148 - if (!bank) { 149 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 150 - pr_err("IPU: %s(%u) - unmapped!\n", __func__, d->irq); 151 - return; 152 - } 153 - 154 - ipu_write_reg(bank->ipu, 1UL << (map->source & 31), bank->status); 155 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 156 - } 157 - 158 - /** 159 - * ipu_irq_status() - returns the current interrupt status of the specified IRQ. 160 - * @irq: interrupt line to get status for. 161 - * @return: true if the interrupt is pending/asserted or false if the 162 - * interrupt is not pending. 163 - */ 164 - bool ipu_irq_status(unsigned int irq) 165 - { 166 - struct ipu_irq_map *map = irq_get_chip_data(irq); 167 - struct ipu_irq_bank *bank; 168 - unsigned long lock_flags; 169 - bool ret; 170 - 171 - raw_spin_lock_irqsave(&bank_lock, lock_flags); 172 - bank = map->bank; 173 - ret = bank && ipu_read_reg(bank->ipu, bank->status) & 174 - (1UL << (map->source & 31)); 175 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 176 - 177 - return ret; 178 - } 179 - 180 - /** 181 - * ipu_irq_map() - map an IPU interrupt source to an IRQ number 182 - * @source: interrupt source bit position (see below) 183 - * @return: mapped IRQ number or negative error code 184 - * 185 - * The source parameter has to be explained further. On i.MX31 IPU has 137 IRQ 186 - * sources, they are broken down in 5 32-bit registers, like 32, 32, 24, 32, 17. 187 - * However, the source argument of this function is not the sequence number of 188 - * the possible IRQ, but rather its bit position. So, first interrupt in fourth 189 - * register has source number 96, and not 88. This makes calculations easier, 190 - * and also provides forward compatibility with any future IPU implementations 191 - * with any interrupt bit assignments. 192 - */ 193 - int ipu_irq_map(unsigned int source) 194 - { 195 - int i, ret = -ENOMEM; 196 - struct ipu_irq_map *map; 197 - 198 - might_sleep(); 199 - 200 - mutex_lock(&map_lock); 201 - map = src2map(source); 202 - if (map) { 203 - pr_err("IPU: Source %u already mapped to IRQ %u\n", source, map->irq); 204 - ret = -EBUSY; 205 - goto out; 206 - } 207 - 208 - for (i = 0; i < CONFIG_MX3_IPU_IRQS; i++) { 209 - if (irq_map[i].source < 0) { 210 - unsigned long lock_flags; 211 - 212 - raw_spin_lock_irqsave(&bank_lock, lock_flags); 213 - irq_map[i].source = source; 214 - irq_map[i].bank = irq_bank + source / 32; 215 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 216 - 217 - ret = irq_map[i].irq; 218 - pr_debug("IPU: mapped source %u to IRQ %u\n", 219 - source, ret); 220 - break; 221 - } 222 - } 223 - out: 224 - mutex_unlock(&map_lock); 225 - 226 - if (ret < 0) 227 - pr_err("IPU: couldn't map source %u: %d\n", source, ret); 228 - 229 - return ret; 230 - } 231 - 232 - /** 233 - * ipu_irq_unmap() - unmap an IPU interrupt source 234 - * @source: interrupt source bit position (see ipu_irq_map()) 235 - * @return: 0 or negative error code 236 - */ 237 - int ipu_irq_unmap(unsigned int source) 238 - { 239 - int i, ret = -EINVAL; 240 - 241 - might_sleep(); 242 - 243 - mutex_lock(&map_lock); 244 - for (i = 0; i < CONFIG_MX3_IPU_IRQS; i++) { 245 - if (irq_map[i].source == source) { 246 - unsigned long lock_flags; 247 - 248 - pr_debug("IPU: unmapped source %u from IRQ %u\n", 249 - source, irq_map[i].irq); 250 - 251 - raw_spin_lock_irqsave(&bank_lock, lock_flags); 252 - irq_map[i].source = -EINVAL; 253 - irq_map[i].bank = NULL; 254 - raw_spin_unlock_irqrestore(&bank_lock, lock_flags); 255 - 256 - ret = 0; 257 - break; 258 - } 259 - } 260 - mutex_unlock(&map_lock); 261 - 262 - return ret; 263 - } 264 - 265 - /* Chained IRQ handler for IPU function and error interrupt */ 266 - static void ipu_irq_handler(struct irq_desc *desc) 267 - { 268 - struct ipu *ipu = irq_desc_get_handler_data(desc); 269 - u32 status; 270 - int i, line; 271 - 272 - for (i = 0; i < IPU_IRQ_NR_BANKS; i++) { 273 - struct ipu_irq_bank *bank = irq_bank + i; 274 - 275 - raw_spin_lock(&bank_lock); 276 - status = ipu_read_reg(ipu, bank->status); 277 - /* 278 - * Don't think we have to clear all interrupts here, they will 279 - * be acked by ->handle_irq() (handle_level_irq). However, we 280 - * might want to clear unhandled interrupts after the loop... 281 - */ 282 - status &= ipu_read_reg(ipu, bank->control); 283 - raw_spin_unlock(&bank_lock); 284 - while ((line = ffs(status))) { 285 - struct ipu_irq_map *map; 286 - unsigned int irq; 287 - 288 - line--; 289 - status &= ~(1UL << line); 290 - 291 - raw_spin_lock(&bank_lock); 292 - map = src2map(32 * i + line); 293 - if (!map) { 294 - raw_spin_unlock(&bank_lock); 295 - pr_err("IPU: Interrupt on unmapped source %u bank %d\n", 296 - line, i); 297 - continue; 298 - } 299 - irq = map->irq; 300 - raw_spin_unlock(&bank_lock); 301 - generic_handle_irq(irq); 302 - } 303 - } 304 - } 305 - 306 - static struct irq_chip ipu_irq_chip = { 307 - .name = "ipu_irq", 308 - .irq_ack = ipu_irq_ack, 309 - .irq_mask = ipu_irq_mask, 310 - .irq_unmask = ipu_irq_unmask, 311 - }; 312 - 313 - /* Install the IRQ handler */ 314 - int __init ipu_irq_attach_irq(struct ipu *ipu, struct platform_device *dev) 315 - { 316 - unsigned int irq, i; 317 - int irq_base = irq_alloc_descs(-1, 0, CONFIG_MX3_IPU_IRQS, 318 - numa_node_id()); 319 - 320 - if (irq_base < 0) 321 - return irq_base; 322 - 323 - for (i = 0; i < IPU_IRQ_NR_BANKS; i++) 324 - irq_bank[i].ipu = ipu; 325 - 326 - for (i = 0; i < CONFIG_MX3_IPU_IRQS; i++) { 327 - int ret; 328 - 329 - irq = irq_base + i; 330 - ret = irq_set_chip(irq, &ipu_irq_chip); 331 - if (ret < 0) 332 - return ret; 333 - ret = irq_set_chip_data(irq, irq_map + i); 334 - if (ret < 0) 335 - return ret; 336 - irq_map[i].ipu = ipu; 337 - irq_map[i].irq = irq; 338 - irq_map[i].source = -EINVAL; 339 - irq_set_handler(irq, handle_level_irq); 340 - irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE); 341 - } 342 - 343 - irq_set_chained_handler_and_data(ipu->irq_fn, ipu_irq_handler, ipu); 344 - 345 - irq_set_chained_handler_and_data(ipu->irq_err, ipu_irq_handler, ipu); 346 - 347 - ipu->irq_base = irq_base; 348 - 349 - return 0; 350 - } 351 - 352 - void ipu_irq_detach_irq(struct ipu *ipu, struct platform_device *dev) 353 - { 354 - unsigned int irq, irq_base; 355 - 356 - irq_base = ipu->irq_base; 357 - 358 - irq_set_chained_handler_and_data(ipu->irq_fn, NULL, NULL); 359 - 360 - irq_set_chained_handler_and_data(ipu->irq_err, NULL, NULL); 361 - 362 - for (irq = irq_base; irq < irq_base + CONFIG_MX3_IPU_IRQS; irq++) { 363 - irq_set_status_flags(irq, IRQ_NOREQUEST); 364 - irq_set_chip(irq, NULL); 365 - irq_set_chip_data(irq, NULL); 366 - } 367 - }
+1 -6
drivers/dma/lgm/lgm-dma.c
··· 1732 1732 * registered DMA channels and DMA capabilities to clients before their 1733 1733 * initialization. 1734 1734 */ 1735 - static int __init intel_ldma_init(void) 1736 - { 1737 - return platform_driver_register(&intel_ldma_driver); 1738 - } 1739 - 1740 - device_initcall(intel_ldma_init); 1735 + builtin_platform_driver(intel_ldma_driver);
+3 -1
drivers/dma/lpc18xx-dmamux.c
··· 12 12 #include <linux/err.h> 13 13 #include <linux/init.h> 14 14 #include <linux/mfd/syscon.h> 15 - #include <linux/of_device.h> 15 + #include <linux/of.h> 16 16 #include <linux/of_dma.h> 17 + #include <linux/of_platform.h> 18 + #include <linux/platform_device.h> 17 19 #include <linux/regmap.h> 18 20 #include <linux/spinlock.h> 19 21
+9 -34
drivers/dma/mcf-edma.c drivers/dma/mcf-edma-main.c
··· 19 19 struct fsl_edma_engine *mcf_edma = dev_id; 20 20 struct edma_regs *regs = &mcf_edma->regs; 21 21 unsigned int ch; 22 - struct fsl_edma_chan *mcf_chan; 23 22 u64 intmap; 24 23 25 24 intmap = ioread32(regs->inth); ··· 30 31 for (ch = 0; ch < mcf_edma->n_chans; ch++) { 31 32 if (intmap & BIT(ch)) { 32 33 iowrite8(EDMA_MASK_CH(ch), regs->cint); 33 - 34 - mcf_chan = &mcf_edma->chans[ch]; 35 - 36 - spin_lock(&mcf_chan->vchan.lock); 37 - 38 - if (!mcf_chan->edesc) { 39 - /* terminate_all called before */ 40 - spin_unlock(&mcf_chan->vchan.lock); 41 - continue; 42 - } 43 - 44 - if (!mcf_chan->edesc->iscyclic) { 45 - list_del(&mcf_chan->edesc->vdesc.node); 46 - vchan_cookie_complete(&mcf_chan->edesc->vdesc); 47 - mcf_chan->edesc = NULL; 48 - mcf_chan->status = DMA_COMPLETE; 49 - mcf_chan->idle = true; 50 - } else { 51 - vchan_cyclic_callback(&mcf_chan->edesc->vdesc); 52 - } 53 - 54 - if (!mcf_chan->edesc) 55 - fsl_edma_xfer_desc(mcf_chan); 56 - 57 - spin_unlock(&mcf_chan->vchan.lock); 34 + fsl_edma_tx_chan_handler(&mcf_edma->chans[ch]); 58 35 } 59 36 } 60 37 ··· 51 76 if (err & BIT(ch)) { 52 77 fsl_edma_disable_request(&mcf_edma->chans[ch]); 53 78 iowrite8(EDMA_CERR_CERR(ch), regs->cerr); 54 - mcf_edma->chans[ch].status = DMA_ERROR; 55 - mcf_edma->chans[ch].idle = true; 79 + fsl_edma_err_chan_handler(&mcf_edma->chans[ch]); 56 80 } 57 81 } 58 82 ··· 146 172 } 147 173 148 174 static struct fsl_edma_drvdata mcf_data = { 149 - .version = v2, 175 + .flags = FSL_EDMA_DRV_EDMA64, 150 176 .setup_irq = mcf_edma_irq_init, 151 177 }; 152 178 ··· 154 180 { 155 181 struct mcf_edma_platform_data *pdata; 156 182 struct fsl_edma_engine *mcf_edma; 157 - struct fsl_edma_chan *mcf_chan; 158 183 struct edma_regs *regs; 159 - int ret, i, len, chans; 184 + int ret, i, chans; 160 185 161 186 pdata = dev_get_platdata(&pdev->dev); 162 187 if (!pdata) { ··· 170 197 chans = pdata->dma_channels; 171 198 } 172 199 173 - len = sizeof(*mcf_edma) + sizeof(*mcf_chan) * chans; 174 - mcf_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL); 200 + mcf_edma = devm_kzalloc(&pdev->dev, struct_size(mcf_edma, chans, chans), 201 + GFP_KERNEL); 175 202 if (!mcf_edma) 176 203 return -ENOMEM; 177 204 ··· 200 227 mcf_chan->dma_dir = DMA_NONE; 201 228 mcf_chan->vchan.desc_free = fsl_edma_free_desc; 202 229 vchan_init(&mcf_chan->vchan, &mcf_edma->dma_dev); 203 - iowrite32(0x0, &regs->tcd[i].csr); 230 + mcf_chan->tcd = mcf_edma->membase + EDMA_TCD 231 + + i * sizeof(struct fsl_edma_hw_tcd); 232 + iowrite32(0x0, &mcf_chan->tcd->csr); 204 233 } 205 234 206 235 iowrite32(~0, regs->inth);
-1
drivers/dma/mediatek/mtk-cqdma.c
··· 18 18 #include <linux/list.h> 19 19 #include <linux/module.h> 20 20 #include <linux/of.h> 21 - #include <linux/of_device.h> 22 21 #include <linux/of_dma.h> 23 22 #include <linux/platform_device.h> 24 23 #include <linux/pm_runtime.h>
-1
drivers/dma/mediatek/mtk-hsdma.c
··· 17 17 #include <linux/list.h> 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 - #include <linux/of_device.h> 21 20 #include <linux/of_dma.h> 22 21 #include <linux/platform_device.h> 23 22 #include <linux/pm_runtime.h>
-2
drivers/dma/mediatek/mtk-uart-apdma.c
··· 16 16 #include <linux/kernel.h> 17 17 #include <linux/list.h> 18 18 #include <linux/module.h> 19 - #include <linux/of_device.h> 20 19 #include <linux/of_dma.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/pm_runtime.h> ··· 550 551 } 551 552 552 553 pm_runtime_enable(&pdev->dev); 553 - pm_runtime_set_active(&pdev->dev); 554 554 555 555 rc = dma_async_device_register(&mtkd->ddev); 556 556 if (rc)
+2 -2
drivers/dma/mpc512x_dma.c
··· 36 36 #include <linux/interrupt.h> 37 37 #include <linux/io.h> 38 38 #include <linux/slab.h> 39 + #include <linux/of.h> 39 40 #include <linux/of_address.h> 40 - #include <linux/of_device.h> 41 41 #include <linux/of_irq.h> 42 42 #include <linux/of_dma.h> 43 - #include <linux/of_platform.h> 43 + #include <linux/platform_device.h> 44 44 45 45 #include <linux/random.h> 46 46
-1
drivers/dma/mxs-dma.c
··· 21 21 #include <linux/module.h> 22 22 #include <linux/stmp_device.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_device.h> 25 24 #include <linux/of_dma.h> 26 25 #include <linux/list.h> 27 26 #include <linux/dma/mxs-dma.h>
-1
drivers/dma/nbpfaxi.c
··· 15 15 #include <linux/log2.h> 16 16 #include <linux/module.h> 17 17 #include <linux/of.h> 18 - #include <linux/of_device.h> 19 18 #include <linux/of_dma.h> 20 19 #include <linux/platform_device.h> 21 20 #include <linux/slab.h>
+3 -2
drivers/dma/owl-dma.c
··· 20 20 #include <linux/io.h> 21 21 #include <linux/mm.h> 22 22 #include <linux/module.h> 23 - #include <linux/of_device.h> 23 + #include <linux/of.h> 24 24 #include <linux/of_dma.h> 25 + #include <linux/platform_device.h> 25 26 #include <linux/slab.h> 26 27 #include "virt-dma.h" 27 28 ··· 1117 1116 dev_info(&pdev->dev, "dma-channels %d, dma-requests %d\n", 1118 1117 nr_channels, nr_requests); 1119 1118 1120 - od->devid = (enum owl_dma_id)of_device_get_match_data(&pdev->dev); 1119 + od->devid = (uintptr_t)of_device_get_match_data(&pdev->dev); 1121 1120 1122 1121 od->nr_pchans = nr_channels; 1123 1122 od->nr_vchans = nr_requests;
+1 -1
drivers/dma/ppc4xx/adma.c
··· 28 28 #include <linux/of.h> 29 29 #include <linux/of_address.h> 30 30 #include <linux/of_irq.h> 31 - #include <linux/of_platform.h> 31 + #include <linux/platform_device.h> 32 32 #include <asm/dcr.h> 33 33 #include <asm/dcr-regs.h> 34 34 #include "adma.h"
+1 -2
drivers/dma/qcom/gpi.c
··· 2160 2160 return -ENOMEM; 2161 2161 2162 2162 gpi_dev->dev = &pdev->dev; 2163 - gpi_dev->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2164 - gpi_dev->regs = devm_ioremap_resource(gpi_dev->dev, gpi_dev->res); 2163 + gpi_dev->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &gpi_dev->res); 2165 2164 if (IS_ERR(gpi_dev->regs)) 2166 2165 return PTR_ERR(gpi_dev->regs); 2167 2166 gpi_dev->ee_base = gpi_dev->regs;
+6 -8
drivers/dma/qcom/hidma.c
··· 45 45 #include <linux/dmaengine.h> 46 46 #include <linux/dma-mapping.h> 47 47 #include <linux/list.h> 48 + #include <linux/mod_devicetable.h> 48 49 #include <linux/module.h> 49 50 #include <linux/platform_device.h> 50 51 #include <linux/slab.h> 51 52 #include <linux/spinlock.h> 52 53 #include <linux/of_dma.h> 53 - #include <linux/of_device.h> 54 54 #include <linux/property.h> 55 55 #include <linux/delay.h> 56 56 #include <linux/acpi.h> ··· 765 765 pm_runtime_set_active(&pdev->dev); 766 766 pm_runtime_enable(&pdev->dev); 767 767 768 - trca_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); 769 - trca = devm_ioremap_resource(&pdev->dev, trca_resource); 768 + trca = devm_platform_get_and_ioremap_resource(pdev, 0, &trca_resource); 770 769 if (IS_ERR(trca)) { 771 - rc = -ENOMEM; 770 + rc = PTR_ERR(trca); 772 771 goto bailout; 773 772 } 774 773 775 - evca_resource = platform_get_resource(pdev, IORESOURCE_MEM, 1); 776 - evca = devm_ioremap_resource(&pdev->dev, evca_resource); 774 + evca = devm_platform_get_and_ioremap_resource(pdev, 1, &evca_resource); 777 775 if (IS_ERR(evca)) { 778 - rc = -ENOMEM; 776 + rc = PTR_ERR(evca); 779 777 goto bailout; 780 778 } 781 779 ··· 783 785 */ 784 786 chirq = platform_get_irq(pdev, 0); 785 787 if (chirq < 0) { 786 - rc = -ENODEV; 788 + rc = chirq; 787 789 goto bailout; 788 790 } 789 791
+2 -3
drivers/dma/qcom/hidma_mgmt.c
··· 176 176 pm_runtime_enable(&pdev->dev); 177 177 pm_runtime_get_sync(&pdev->dev); 178 178 179 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 180 - virtaddr = devm_ioremap_resource(&pdev->dev, res); 179 + virtaddr = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 181 180 if (IS_ERR(virtaddr)) { 182 - rc = -ENOMEM; 181 + rc = PTR_ERR(virtaddr); 183 182 goto out; 184 183 } 185 184
+10 -7
drivers/dma/sh/rz-dmac.c
··· 9 9 * Copyright 2012 Javier Martin, Vista Silicon <javier.martin@vista-silicon.com> 10 10 */ 11 11 12 + #include <linux/bitfield.h> 12 13 #include <linux/dma-mapping.h> 13 14 #include <linux/dmaengine.h> 14 15 #include <linux/interrupt.h> ··· 146 145 #define CHCFG_REQD BIT(3) 147 146 #define CHCFG_SEL(bits) ((bits) & 0x07) 148 147 #define CHCFG_MEM_COPY (0x80400008) 149 - #define CHCFG_FILL_DDS(a) (((a) << 16) & GENMASK(19, 16)) 150 - #define CHCFG_FILL_SDS(a) (((a) << 12) & GENMASK(15, 12)) 148 + #define CHCFG_FILL_DDS_MASK GENMASK(19, 16) 149 + #define CHCFG_FILL_SDS_MASK GENMASK(15, 12) 151 150 #define CHCFG_FILL_TM(a) (((a) & BIT(5)) << 22) 152 151 #define CHCFG_FILL_AM(a) (((a) & GENMASK(4, 2)) << 6) 153 152 #define CHCFG_FILL_LVL(a) (((a) & BIT(1)) << 5) ··· 608 607 if (val == CHCFG_DS_INVALID) 609 608 return -EINVAL; 610 609 611 - channel->chcfg |= CHCFG_FILL_DDS(val); 610 + channel->chcfg &= ~CHCFG_FILL_DDS_MASK; 611 + channel->chcfg |= FIELD_PREP(CHCFG_FILL_DDS_MASK, val); 612 612 613 613 val = rz_dmac_ds_to_val_mapping(config->src_addr_width); 614 614 if (val == CHCFG_DS_INVALID) 615 615 return -EINVAL; 616 616 617 - channel->chcfg |= CHCFG_FILL_SDS(val); 617 + channel->chcfg &= ~CHCFG_FILL_SDS_MASK; 618 + channel->chcfg |= FIELD_PREP(CHCFG_FILL_SDS_MASK, val); 618 619 619 620 return 0; 620 621 } ··· 950 947 dma_register_err: 951 948 of_dma_controller_free(pdev->dev.of_node); 952 949 err: 953 - reset_control_assert(dmac->rstc); 954 950 channel_num = i ? i - 1 : 0; 955 951 for (i = 0; i < channel_num; i++) { 956 952 struct rz_dmac_chan *channel = &dmac->channels[i]; ··· 960 958 channel->lmdesc.base_dma); 961 959 } 962 960 961 + reset_control_assert(dmac->rstc); 963 962 err_pm_runtime_put: 964 963 pm_runtime_put(&pdev->dev); 965 964 err_pm_disable: ··· 974 971 struct rz_dmac *dmac = platform_get_drvdata(pdev); 975 972 unsigned int i; 976 973 974 + dma_async_device_unregister(&dmac->engine); 975 + of_dma_controller_free(pdev->dev.of_node); 977 976 for (i = 0; i < dmac->n_channels; i++) { 978 977 struct rz_dmac_chan *channel = &dmac->channels[i]; 979 978 ··· 984 979 channel->lmdesc.base, 985 980 channel->lmdesc.base_dma); 986 981 } 987 - of_dma_controller_free(pdev->dev.of_node); 988 - dma_async_device_unregister(&dmac->engine); 989 982 reset_control_assert(dmac->rstc); 990 983 pm_runtime_put(&pdev->dev); 991 984 pm_runtime_disable(&pdev->dev);
+3 -5
drivers/dma/sh/shdmac.c
··· 23 23 #include <linux/module.h> 24 24 #include <linux/notifier.h> 25 25 #include <linux/of.h> 26 - #include <linux/of_device.h> 27 26 #include <linux/platform_device.h> 28 27 #include <linux/pm_runtime.h> 29 28 #include <linux/rculist.h> ··· 677 678 int err, errirq, i, irq_cnt = 0, irqres = 0, irq_cap = 0; 678 679 struct sh_dmae_device *shdev; 679 680 struct dma_device *dma_dev; 680 - struct resource *chan, *dmars, *errirq_res, *chanirq_res; 681 + struct resource *dmars, *errirq_res, *chanirq_res; 681 682 682 683 if (pdev->dev.of_node) 683 684 pdata = of_device_get_match_data(&pdev->dev); ··· 688 689 if (!pdata || !pdata->channel_num) 689 690 return -ENODEV; 690 691 691 - chan = platform_get_resource(pdev, IORESOURCE_MEM, 0); 692 692 /* DMARS area is optional */ 693 693 dmars = platform_get_resource(pdev, IORESOURCE_MEM, 1); 694 694 /* ··· 707 709 * requested with the IRQF_SHARED flag 708 710 */ 709 711 errirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 710 - if (!chan || !errirq_res) 712 + if (!errirq_res) 711 713 return -ENODEV; 712 714 713 715 shdev = devm_kzalloc(&pdev->dev, sizeof(struct sh_dmae_device), ··· 717 719 718 720 dma_dev = &shdev->shdma_dev.dma_dev; 719 721 720 - shdev->chan_reg = devm_ioremap_resource(&pdev->dev, chan); 722 + shdev->chan_reg = devm_platform_ioremap_resource(pdev, 0); 721 723 if (IS_ERR(shdev->chan_reg)) 722 724 return PTR_ERR(shdev->chan_reg); 723 725 if (dmars) {
+1 -1
drivers/dma/sprd-dma.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/of.h> 17 17 #include <linux/of_dma.h> 18 - #include <linux/of_device.h> 18 + #include <linux/platform_device.h> 19 19 #include <linux/pm_runtime.h> 20 20 #include <linux/slab.h> 21 21
+4
drivers/dma/ste_dma40.c
··· 3590 3590 spin_lock_init(&base->lcla_pool.lock); 3591 3591 3592 3592 base->irq = platform_get_irq(pdev, 0); 3593 + if (base->irq < 0) { 3594 + ret = base->irq; 3595 + goto destroy_cache; 3596 + } 3593 3597 3594 3598 ret = request_irq(base->irq, d40_handle_interrupt, 0, D40_NAME, base); 3595 3599 if (ret) {
+1 -2
drivers/dma/stm32-dma.c
··· 1581 1581 1582 1582 dd = &dmadev->ddev; 1583 1583 1584 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1585 - dmadev->base = devm_ioremap_resource(&pdev->dev, res); 1584 + dmadev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 1586 1585 if (IS_ERR(dmadev->base)) 1587 1586 return PTR_ERR(dmadev->base); 1588 1587
+3 -1
drivers/dma/stm32-dmamux.c
··· 15 15 #include <linux/err.h> 16 16 #include <linux/init.h> 17 17 #include <linux/module.h> 18 - #include <linux/of_device.h> 18 + #include <linux/of.h> 19 19 #include <linux/of_dma.h> 20 + #include <linux/of_platform.h> 21 + #include <linux/platform_device.h> 20 22 #include <linux/pm_runtime.h> 21 23 #include <linux/reset.h> 22 24 #include <linux/slab.h>
-1
drivers/dma/stm32-mdma.c
··· 24 24 #include <linux/log2.h> 25 25 #include <linux/module.h> 26 26 #include <linux/of.h> 27 - #include <linux/of_device.h> 28 27 #include <linux/of_dma.h> 29 28 #include <linux/platform_device.h> 30 29 #include <linux/pm_runtime.h>
+1 -1
drivers/dma/sun6i-dma.c
··· 14 14 #include <linux/dmapool.h> 15 15 #include <linux/interrupt.h> 16 16 #include <linux/module.h> 17 + #include <linux/of.h> 17 18 #include <linux/of_dma.h> 18 - #include <linux/of_device.h> 19 19 #include <linux/platform_device.h> 20 20 #include <linux/reset.h> 21 21 #include <linux/slab.h>
+1 -1
drivers/dma/tegra186-gpc-dma.c
··· 13 13 #include <linux/iopoll.h> 14 14 #include <linux/minmax.h> 15 15 #include <linux/module.h> 16 - #include <linux/of_device.h> 16 + #include <linux/of.h> 17 17 #include <linux/of_dma.h> 18 18 #include <linux/platform_device.h> 19 19 #include <linux/reset.h>
-1
drivers/dma/tegra20-apb-dma.c
··· 17 17 #include <linux/mm.h> 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 - #include <linux/of_device.h> 21 20 #include <linux/of_dma.h> 22 21 #include <linux/platform_device.h> 23 22 #include <linux/pm.h>
+2 -1
drivers/dma/tegra210-adma.c
··· 8 8 #include <linux/clk.h> 9 9 #include <linux/iopoll.h> 10 10 #include <linux/module.h> 11 - #include <linux/of_device.h> 11 + #include <linux/of.h> 12 12 #include <linux/of_dma.h> 13 13 #include <linux/of_irq.h> 14 + #include <linux/platform_device.h> 14 15 #include <linux/pm_runtime.h> 15 16 #include <linux/slab.h> 16 17
+3 -2
drivers/dma/ti/dma-crossbar.c
··· 3 3 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com 4 4 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> 5 5 */ 6 + #include <linux/platform_device.h> 6 7 #include <linux/slab.h> 7 8 #include <linux/err.h> 8 9 #include <linux/init.h> 9 10 #include <linux/list.h> 10 11 #include <linux/io.h> 11 - #include <linux/of_address.h> 12 - #include <linux/of_device.h> 12 + #include <linux/of.h> 13 13 #include <linux/of_dma.h> 14 + #include <linux/of_platform.h> 14 15 15 16 #define TI_XBAR_DRA7 0 16 17 #define TI_XBAR_AM335X 1
-1
drivers/dma/ti/edma.c
··· 20 20 #include <linux/of_dma.h> 21 21 #include <linux/of_irq.h> 22 22 #include <linux/of_address.h> 23 - #include <linux/of_device.h> 24 23 #include <linux/pm_runtime.h> 25 24 26 25 #include <linux/platform_data/edma.h>
+2
drivers/dma/ti/k3-udma-private.c
··· 3 3 * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com 4 4 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> 5 5 */ 6 + #include <linux/of.h> 7 + #include <linux/of_platform.h> 6 8 7 9 int xudma_navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread) 8 10 {
-1
drivers/dma/ti/k3-udma.c
··· 20 20 #include <linux/sys_soc.h> 21 21 #include <linux/of.h> 22 22 #include <linux/of_dma.h> 23 - #include <linux/of_device.h> 24 23 #include <linux/of_irq.h> 25 24 #include <linux/workqueue.h> 26 25 #include <linux/completion.h>
+1 -1
drivers/dma/ti/omap-dma.c
··· 16 16 #include <linux/platform_device.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/spinlock.h> 19 + #include <linux/of.h> 19 20 #include <linux/of_dma.h> 20 - #include <linux/of_device.h> 21 21 22 22 #include "../virt-dma.h" 23 23
+2 -1
drivers/dma/xgene-dma.c
··· 18 18 #include <linux/interrupt.h> 19 19 #include <linux/io.h> 20 20 #include <linux/irq.h> 21 + #include <linux/mod_devicetable.h> 21 22 #include <linux/module.h> 22 - #include <linux/of_device.h> 23 + #include <linux/platform_device.h> 23 24 24 25 #include "dmaengine.h" 25 26
+61 -13
drivers/dma/xilinx/xilinx_dma.c
··· 41 41 #include <linux/io.h> 42 42 #include <linux/iopoll.h> 43 43 #include <linux/module.h> 44 - #include <linux/of_address.h> 44 + #include <linux/of.h> 45 45 #include <linux/of_dma.h> 46 - #include <linux/of_platform.h> 47 46 #include <linux/of_irq.h> 47 + #include <linux/platform_device.h> 48 48 #include <linux/slab.h> 49 49 #include <linux/clk.h> 50 50 #include <linux/io-64-nonatomic-lo-hi.h> ··· 173 173 #define XILINX_DMA_MAX_TRANS_LEN_MAX 23 174 174 #define XILINX_DMA_V2_MAX_TRANS_LEN_MAX 26 175 175 #define XILINX_DMA_CR_COALESCE_MAX GENMASK(23, 16) 176 + #define XILINX_DMA_CR_DELAY_MAX GENMASK(31, 24) 176 177 #define XILINX_DMA_CR_CYCLIC_BD_EN_MASK BIT(4) 177 178 #define XILINX_DMA_CR_COALESCE_SHIFT 16 179 + #define XILINX_DMA_CR_DELAY_SHIFT 24 178 180 #define XILINX_DMA_BD_SOP BIT(27) 179 181 #define XILINX_DMA_BD_EOP BIT(26) 182 + #define XILINX_DMA_BD_COMP_MASK BIT(31) 180 183 #define XILINX_DMA_COALESCE_MAX 255 181 - #define XILINX_DMA_NUM_DESCS 255 184 + #define XILINX_DMA_NUM_DESCS 512 182 185 #define XILINX_DMA_NUM_APP_WORDS 5 183 186 184 187 /* AXI CDMA Specific Registers/Offsets */ ··· 413 410 * @stop_transfer: Differentiate b/w DMA IP's quiesce 414 411 * @tdest: TDEST value for mcdma 415 412 * @has_vflip: S2MM vertical flip 413 + * @irq_delay: Interrupt delay timeout 416 414 */ 417 415 struct xilinx_dma_chan { 418 416 struct xilinx_dma_device *xdev; ··· 452 448 int (*stop_transfer)(struct xilinx_dma_chan *chan); 453 449 u16 tdest; 454 450 bool has_vflip; 451 + u8 irq_delay; 455 452 }; 456 453 457 454 /** ··· 498 493 * @s2mm_chan_id: DMA s2mm channel identifier 499 494 * @mm2s_chan_id: DMA mm2s channel identifier 500 495 * @max_buffer_len: Max buffer length 496 + * @has_axistream_connected: AXI DMA connected to AXI Stream IP 501 497 */ 502 498 struct xilinx_dma_device { 503 499 void __iomem *regs; ··· 517 511 u32 s2mm_chan_id; 518 512 u32 mm2s_chan_id; 519 513 u32 max_buffer_len; 514 + bool has_axistream_connected; 520 515 }; 521 516 522 517 /* Macros */ ··· 629 622 hw->buf_addr = buf_addr + sg_used; 630 623 } 631 624 } 625 + 626 + /** 627 + * xilinx_dma_get_metadata_ptr- Populate metadata pointer and payload length 628 + * @tx: async transaction descriptor 629 + * @payload_len: metadata payload length 630 + * @max_len: metadata max length 631 + * Return: The app field pointer. 632 + */ 633 + static void *xilinx_dma_get_metadata_ptr(struct dma_async_tx_descriptor *tx, 634 + size_t *payload_len, size_t *max_len) 635 + { 636 + struct xilinx_dma_tx_descriptor *desc = to_dma_tx_descriptor(tx); 637 + struct xilinx_axidma_tx_segment *seg; 638 + 639 + *max_len = *payload_len = sizeof(u32) * XILINX_DMA_NUM_APP_WORDS; 640 + seg = list_first_entry(&desc->segments, 641 + struct xilinx_axidma_tx_segment, node); 642 + return seg->hw.app; 643 + } 644 + 645 + static struct dma_descriptor_metadata_ops xilinx_dma_metadata_ops = { 646 + .get_ptr = xilinx_dma_get_metadata_ptr, 647 + }; 632 648 633 649 /* ----------------------------------------------------------------------------- 634 650 * Descriptors and segments alloc and free ··· 1565 1535 if (chan->has_sg) 1566 1536 xilinx_write(chan, XILINX_DMA_REG_CURDESC, 1567 1537 head_desc->async_tx.phys); 1538 + reg &= ~XILINX_DMA_CR_DELAY_MAX; 1539 + reg |= chan->irq_delay << XILINX_DMA_CR_DELAY_SHIFT; 1540 + dma_ctrl_write(chan, XILINX_DMA_REG_DMACR, reg); 1568 1541 1569 1542 xilinx_dma_start(chan); 1570 1543 ··· 1716 1683 return; 1717 1684 1718 1685 list_for_each_entry_safe(desc, next, &chan->active_list, node) { 1686 + if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { 1687 + struct xilinx_axidma_tx_segment *seg; 1688 + 1689 + seg = list_last_entry(&desc->segments, 1690 + struct xilinx_axidma_tx_segment, node); 1691 + if (!(seg->hw.status & XILINX_DMA_BD_COMP_MASK) && chan->has_sg) 1692 + break; 1693 + } 1719 1694 if (chan->has_sg && chan->xdev->dma_config->dmatype != 1720 1695 XDMA_TYPE_VDMA) 1721 1696 desc->residue = xilinx_dma_get_residue(chan, desc); ··· 1857 1816 spin_unlock(&chan->lock); 1858 1817 } 1859 1818 1860 - tasklet_schedule(&chan->tasklet); 1819 + tasklet_hi_schedule(&chan->tasklet); 1861 1820 return IRQ_HANDLED; 1862 1821 } 1863 1822 ··· 1905 1864 } 1906 1865 } 1907 1866 1908 - if (status & XILINX_DMA_DMASR_DLY_CNT_IRQ) { 1909 - /* 1910 - * Device takes too long to do the transfer when user requires 1911 - * responsiveness. 1912 - */ 1913 - dev_dbg(chan->dev, "Inter-packet latency too long\n"); 1914 - } 1915 - 1916 - if (status & XILINX_DMA_DMASR_FRM_CNT_IRQ) { 1867 + if (status & (XILINX_DMA_DMASR_FRM_CNT_IRQ | 1868 + XILINX_DMA_DMASR_DLY_CNT_IRQ)) { 1917 1869 spin_lock(&chan->lock); 1918 1870 xilinx_dma_complete_descriptor(chan); 1919 1871 chan->idle = true; ··· 2254 2220 node); 2255 2221 segment->hw.control |= XILINX_DMA_BD_EOP; 2256 2222 } 2223 + 2224 + if (chan->xdev->has_axistream_connected) 2225 + desc->async_tx.metadata_ops = &xilinx_dma_metadata_ops; 2257 2226 2258 2227 return &desc->async_tx; 2259 2228 ··· 2833 2796 /* Retrieve the channel properties from the device tree */ 2834 2797 has_dre = of_property_read_bool(node, "xlnx,include-dre"); 2835 2798 2799 + of_property_read_u8(node, "xlnx,irq-delay", &chan->irq_delay); 2800 + 2836 2801 chan->genlock = of_property_read_bool(node, "xlnx,genlock-mode"); 2837 2802 2838 2803 err = of_property_read_u32(node, "xlnx,datawidth", &value); ··· 3106 3067 } 3107 3068 } 3108 3069 3070 + if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { 3071 + xdev->has_axistream_connected = 3072 + of_property_read_bool(node, "xlnx,axistream-connected"); 3073 + } 3074 + 3109 3075 if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) { 3110 3076 err = of_property_read_u32(node, "xlnx,num-fstores", 3111 3077 &num_frames); ··· 3135 3091 xdev->ext_addr = true; 3136 3092 else 3137 3093 xdev->ext_addr = false; 3094 + 3095 + /* Set metadata mode */ 3096 + if (xdev->has_axistream_connected) 3097 + xdev->common.desc_metadata_modes = DESC_METADATA_ENGINE; 3138 3098 3139 3099 /* Set the dma mask bits */ 3140 3100 err = dma_set_mask_and_coherent(xdev->dev, DMA_BIT_MASK(addr_width));
+2 -1
drivers/dma/xilinx/zynqmp_dma.c
··· 11 11 #include <linux/interrupt.h> 12 12 #include <linux/io.h> 13 13 #include <linux/module.h> 14 + #include <linux/of.h> 14 15 #include <linux/of_dma.h> 15 - #include <linux/of_platform.h> 16 + #include <linux/platform_device.h> 16 17 #include <linux/slab.h> 17 18 #include <linux/clk.h> 18 19 #include <linux/io-64-nonatomic-lo-hi.h>