diff options
| -rw-r--r-- | drivers/dma/Kconfig | 7 | ||||
| -rw-r--r-- | drivers/dma/Makefile | 1 | ||||
| -rw-r--r-- | drivers/dma/at_xdmac.c | 1510 | ||||
| -rw-r--r-- | include/dt-bindings/dma/at91.h | 25 |
4 files changed, 1543 insertions, 0 deletions
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index de469821bc1b..607271a999a9 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig | |||
| @@ -107,6 +107,13 @@ config AT_HDMAC | |||
| 107 | help | 107 | help |
| 108 | Support the Atmel AHB DMA controller. | 108 | Support the Atmel AHB DMA controller. |
| 109 | 109 | ||
| 110 | config AT_XDMAC | ||
| 111 | tristate "Atmel XDMA support" | ||
| 112 | depends on (ARCH_AT91 || COMPILE_TEST) | ||
| 113 | select DMA_ENGINE | ||
| 114 | help | ||
| 115 | Support the Atmel XDMA controller. | ||
| 116 | |||
| 110 | config FSL_DMA | 117 | config FSL_DMA |
| 111 | tristate "Freescale Elo series DMA support" | 118 | tristate "Freescale Elo series DMA support" |
| 112 | depends on FSL_SOC | 119 | depends on FSL_SOC |
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index cb626c179911..2022b5451377 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile | |||
| @@ -16,6 +16,7 @@ obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/ | |||
| 16 | obj-$(CONFIG_MV_XOR) += mv_xor.o | 16 | obj-$(CONFIG_MV_XOR) += mv_xor.o |
| 17 | obj-$(CONFIG_DW_DMAC_CORE) += dw/ | 17 | obj-$(CONFIG_DW_DMAC_CORE) += dw/ |
| 18 | obj-$(CONFIG_AT_HDMAC) += at_hdmac.o | 18 | obj-$(CONFIG_AT_HDMAC) += at_hdmac.o |
| 19 | obj-$(CONFIG_AT_XDMAC) += at_xdmac.o | ||
| 19 | obj-$(CONFIG_MX3_IPU) += ipu/ | 20 | obj-$(CONFIG_MX3_IPU) += ipu/ |
| 20 | obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o | 21 | obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o |
| 21 | obj-$(CONFIG_SH_DMAE_BASE) += sh/ | 22 | obj-$(CONFIG_SH_DMAE_BASE) += sh/ |
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c new file mode 100644 index 000000000000..4e9b023990ae --- /dev/null +++ b/drivers/dma/at_xdmac.c | |||
| @@ -0,0 +1,1510 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Atmel Extensible DMA Controller (aka XDMAC on AT91 systems) | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Atmel Corporation | ||
| 5 | * | ||
| 6 | * Author: Ludovic Desroches <ludovic.desroches@atmel.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify it | ||
| 9 | * under the terms of the GNU General Public License version 2 as published by | ||
| 10 | * the Free Software Foundation. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 15 | * more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License along with | ||
| 18 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <asm/barrier.h> | ||
| 22 | #include <dt-bindings/dma/at91.h> | ||
| 23 | #include <linux/clk.h> | ||
| 24 | #include <linux/dmaengine.h> | ||
| 25 | #include <linux/dmapool.h> | ||
| 26 | #include <linux/interrupt.h> | ||
| 27 | #include <linux/irq.h> | ||
| 28 | #include <linux/list.h> | ||
| 29 | #include <linux/module.h> | ||
| 30 | #include <linux/of_dma.h> | ||
| 31 | #include <linux/of_platform.h> | ||
| 32 | #include <linux/platform_device.h> | ||
| 33 | #include <linux/pm.h> | ||
| 34 | |||
| 35 | #include "dmaengine.h" | ||
| 36 | |||
| 37 | /* Global registers */ | ||
| 38 | #define AT_XDMAC_GTYPE 0x00 /* Global Type Register */ | ||
| 39 | #define AT_XDMAC_NB_CH(i) (((i) & 0x1F) + 1) /* Number of Channels Minus One */ | ||
| 40 | #define AT_XDMAC_FIFO_SZ(i) (((i) >> 5) & 0x7FF) /* Number of Bytes */ | ||
| 41 | #define AT_XDMAC_NB_REQ(i) ((((i) >> 16) & 0x3F) + 1) /* Number of Peripheral Requests Minus One */ | ||
| 42 | #define AT_XDMAC_GCFG 0x04 /* Global Configuration Register */ | ||
| 43 | #define AT_XDMAC_GWAC 0x08 /* Global Weighted Arbiter Configuration Register */ | ||
| 44 | #define AT_XDMAC_GIE 0x0C /* Global Interrupt Enable Register */ | ||
| 45 | #define AT_XDMAC_GID 0x10 /* Global Interrupt Disable Register */ | ||
| 46 | #define AT_XDMAC_GIM 0x14 /* Global Interrupt Mask Register */ | ||
| 47 | #define AT_XDMAC_GIS 0x18 /* Global Interrupt Status Register */ | ||
| 48 | #define AT_XDMAC_GE 0x1C /* Global Channel Enable Register */ | ||
| 49 | #define AT_XDMAC_GD 0x20 /* Global Channel Disable Register */ | ||
| 50 | #define AT_XDMAC_GS 0x24 /* Global Channel Status Register */ | ||
| 51 | #define AT_XDMAC_GRS 0x28 /* Global Channel Read Suspend Register */ | ||
| 52 | #define AT_XDMAC_GWS 0x2C /* Global Write Suspend Register */ | ||
| 53 | #define AT_XDMAC_GRWS 0x30 /* Global Channel Read Write Suspend Register */ | ||
| 54 | #define AT_XDMAC_GRWR 0x34 /* Global Channel Read Write Resume Register */ | ||
| 55 | #define AT_XDMAC_GSWR 0x38 /* Global Channel Software Request Register */ | ||
| 56 | #define AT_XDMAC_GSWS 0x3C /* Global channel Software Request Status Register */ | ||
| 57 | #define AT_XDMAC_GSWF 0x40 /* Global Channel Software Flush Request Register */ | ||
| 58 | #define AT_XDMAC_VERSION 0xFFC /* XDMAC Version Register */ | ||
| 59 | |||
| 60 | /* Channel relative registers offsets */ | ||
| 61 | #define AT_XDMAC_CIE 0x00 /* Channel Interrupt Enable Register */ | ||
| 62 | #define AT_XDMAC_CIE_BIE BIT(0) /* End of Block Interrupt Enable Bit */ | ||
| 63 | #define AT_XDMAC_CIE_LIE BIT(1) /* End of Linked List Interrupt Enable Bit */ | ||
| 64 | #define AT_XDMAC_CIE_DIE BIT(2) /* End of Disable Interrupt Enable Bit */ | ||
| 65 | #define AT_XDMAC_CIE_FIE BIT(3) /* End of Flush Interrupt Enable Bit */ | ||
| 66 | #define AT_XDMAC_CIE_RBEIE BIT(4) /* Read Bus Error Interrupt Enable Bit */ | ||
| 67 | #define AT_XDMAC_CIE_WBEIE BIT(5) /* Write Bus Error Interrupt Enable Bit */ | ||
| 68 | #define AT_XDMAC_CIE_ROIE BIT(6) /* Request Overflow Interrupt Enable Bit */ | ||
| 69 | #define AT_XDMAC_CID 0x04 /* Channel Interrupt Disable Register */ | ||
| 70 | #define AT_XDMAC_CID_BID BIT(0) /* End of Block Interrupt Disable Bit */ | ||
| 71 | #define AT_XDMAC_CID_LID BIT(1) /* End of Linked List Interrupt Disable Bit */ | ||
| 72 | #define AT_XDMAC_CID_DID BIT(2) /* End of Disable Interrupt Disable Bit */ | ||
| 73 | #define AT_XDMAC_CID_FID BIT(3) /* End of Flush Interrupt Disable Bit */ | ||
| 74 | #define AT_XDMAC_CID_RBEID BIT(4) /* Read Bus Error Interrupt Disable Bit */ | ||
| 75 | #define AT_XDMAC_CID_WBEID BIT(5) /* Write Bus Error Interrupt Disable Bit */ | ||
| 76 | #define AT_XDMAC_CID_ROID BIT(6) /* Request Overflow Interrupt Disable Bit */ | ||
| 77 | #define AT_XDMAC_CIM 0x08 /* Channel Interrupt Mask Register */ | ||
| 78 | #define AT_XDMAC_CIM_BIM BIT(0) /* End of Block Interrupt Mask Bit */ | ||
| 79 | #define AT_XDMAC_CIM_LIM BIT(1) /* End of Linked List Interrupt Mask Bit */ | ||
| 80 | #define AT_XDMAC_CIM_DIM BIT(2) /* End of Disable Interrupt Mask Bit */ | ||
| 81 | #define AT_XDMAC_CIM_FIM BIT(3) /* End of Flush Interrupt Mask Bit */ | ||
| 82 | #define AT_XDMAC_CIM_RBEIM BIT(4) /* Read Bus Error Interrupt Mask Bit */ | ||
| 83 | #define AT_XDMAC_CIM_WBEIM BIT(5) /* Write Bus Error Interrupt Mask Bit */ | ||
| 84 | #define AT_XDMAC_CIM_ROIM BIT(6) /* Request Overflow Interrupt Mask Bit */ | ||
| 85 | #define AT_XDMAC_CIS 0x0C /* Channel Interrupt Status Register */ | ||
| 86 | #define AT_XDMAC_CIS_BIS BIT(0) /* End of Block Interrupt Status Bit */ | ||
| 87 | #define AT_XDMAC_CIS_LIS BIT(1) /* End of Linked List Interrupt Status Bit */ | ||
| 88 | #define AT_XDMAC_CIS_DIS BIT(2) /* End of Disable Interrupt Status Bit */ | ||
| 89 | #define AT_XDMAC_CIS_FIS BIT(3) /* End of Flush Interrupt Status Bit */ | ||
| 90 | #define AT_XDMAC_CIS_RBEIS BIT(4) /* Read Bus Error Interrupt Status Bit */ | ||
| 91 | #define AT_XDMAC_CIS_WBEIS BIT(5) /* Write Bus Error Interrupt Status Bit */ | ||
| 92 | #define AT_XDMAC_CIS_ROIS BIT(6) /* Request Overflow Interrupt Status Bit */ | ||
| 93 | #define AT_XDMAC_CSA 0x10 /* Channel Source Address Register */ | ||
| 94 | #define AT_XDMAC_CDA 0x14 /* Channel Destination Address Register */ | ||
| 95 | #define AT_XDMAC_CNDA 0x18 /* Channel Next Descriptor Address Register */ | ||
| 96 | #define AT_XDMAC_CNDA_NDAIF(i) ((i) & 0x1) /* Channel x Next Descriptor Interface */ | ||
| 97 | #define AT_XDMAC_CNDA_NDA(i) ((i) & 0xfffffffc) /* Channel x Next Descriptor Address */ | ||
| 98 | #define AT_XDMAC_CNDC 0x1C /* Channel Next Descriptor Control Register */ | ||
| 99 | #define AT_XDMAC_CNDC_NDE (0x1 << 0) /* Channel x Next Descriptor Enable */ | ||
| 100 | #define AT_XDMAC_CNDC_NDSUP (0x1 << 1) /* Channel x Next Descriptor Source Update */ | ||
| 101 | #define AT_XDMAC_CNDC_NDDUP (0x1 << 2) /* Channel x Next Descriptor Destination Update */ | ||
| 102 | #define AT_XDMAC_CNDC_NDVIEW_NDV0 (0x0 << 3) /* Channel x Next Descriptor View 0 */ | ||
| 103 | #define AT_XDMAC_CNDC_NDVIEW_NDV1 (0x1 << 3) /* Channel x Next Descriptor View 1 */ | ||
| 104 | #define AT_XDMAC_CNDC_NDVIEW_NDV2 (0x2 << 3) /* Channel x Next Descriptor View 2 */ | ||
| 105 | #define AT_XDMAC_CNDC_NDVIEW_NDV3 (0x3 << 3) /* Channel x Next Descriptor View 3 */ | ||
| 106 | #define AT_XDMAC_CUBC 0x20 /* Channel Microblock Control Register */ | ||
| 107 | #define AT_XDMAC_CBC 0x24 /* Channel Block Control Register */ | ||
| 108 | #define AT_XDMAC_CC 0x28 /* Channel Configuration Register */ | ||
| 109 | #define AT_XDMAC_CC_TYPE (0x1 << 0) /* Channel Transfer Type */ | ||
| 110 | #define AT_XDMAC_CC_TYPE_MEM_TRAN (0x0 << 0) /* Memory to Memory Transfer */ | ||
| 111 | #define AT_XDMAC_CC_TYPE_PER_TRAN (0x1 << 0) /* Peripheral to Memory or Memory to Peripheral Transfer */ | ||
| 112 | #define AT_XDMAC_CC_MBSIZE_MASK (0x3 << 1) | ||
| 113 | #define AT_XDMAC_CC_MBSIZE_SINGLE (0x0 << 1) | ||
| 114 | #define AT_XDMAC_CC_MBSIZE_FOUR (0x1 << 1) | ||
| 115 | #define AT_XDMAC_CC_MBSIZE_EIGHT (0x2 << 1) | ||
| 116 | #define AT_XDMAC_CC_MBSIZE_SIXTEEN (0x3 << 1) | ||
| 117 | #define AT_XDMAC_CC_DSYNC (0x1 << 4) /* Channel Synchronization */ | ||
| 118 | #define AT_XDMAC_CC_DSYNC_PER2MEM (0x0 << 4) | ||
| 119 | #define AT_XDMAC_CC_DSYNC_MEM2PER (0x1 << 4) | ||
| 120 | #define AT_XDMAC_CC_PROT (0x1 << 5) /* Channel Protection */ | ||
| 121 | #define AT_XDMAC_CC_PROT_SEC (0x0 << 5) | ||
| 122 | #define AT_XDMAC_CC_PROT_UNSEC (0x1 << 5) | ||
| 123 | #define AT_XDMAC_CC_SWREQ (0x1 << 6) /* Channel Software Request Trigger */ | ||
| 124 | #define AT_XDMAC_CC_SWREQ_HWR_CONNECTED (0x0 << 6) | ||
| 125 | #define AT_XDMAC_CC_SWREQ_SWR_CONNECTED (0x1 << 6) | ||
| 126 | #define AT_XDMAC_CC_MEMSET (0x1 << 7) /* Channel Fill Block of memory */ | ||
| 127 | #define AT_XDMAC_CC_MEMSET_NORMAL_MODE (0x0 << 7) | ||
| 128 | #define AT_XDMAC_CC_MEMSET_HW_MODE (0x1 << 7) | ||
| 129 | #define AT_XDMAC_CC_CSIZE(i) ((0x7 & (i)) << 8) /* Channel Chunk Size */ | ||
| 130 | #define AT_XDMAC_CC_DWIDTH_OFFSET 11 | ||
| 131 | #define AT_XDMAC_CC_DWIDTH_MASK (0x3 << AT_XDMAC_CC_DWIDTH_OFFSET) | ||
| 132 | #define AT_XDMAC_CC_DWIDTH(i) ((0x3 & (i)) << AT_XDMAC_CC_DWIDTH_OFFSET) /* Channel Data Width */ | ||
| 133 | #define AT_XDMAC_CC_DWIDTH_BYTE 0x0 | ||
| 134 | #define AT_XDMAC_CC_DWIDTH_HALFWORD 0x1 | ||
| 135 | #define AT_XDMAC_CC_DWIDTH_WORD 0x2 | ||
| 136 | #define AT_XDMAC_CC_DWIDTH_DWORD 0x3 | ||
| 137 | #define AT_XDMAC_CC_SIF(i) ((0x1 & (i)) << 13) /* Channel Source Interface Identifier */ | ||
| 138 | #define AT_XDMAC_CC_DIF(i) ((0x1 & (i)) << 14) /* Channel Destination Interface Identifier */ | ||
| 139 | #define AT_XDMAC_CC_SAM_MASK (0x3 << 16) /* Channel Source Addressing Mode */ | ||
| 140 | #define AT_XDMAC_CC_SAM_FIXED_AM (0x0 << 16) | ||
| 141 | #define AT_XDMAC_CC_SAM_INCREMENTED_AM (0x1 << 16) | ||
| 142 | #define AT_XDMAC_CC_SAM_UBS_AM (0x2 << 16) | ||
| 143 | #define AT_XDMAC_CC_SAM_UBS_DS_AM (0x3 << 16) | ||
| 144 | #define AT_XDMAC_CC_DAM_MASK (0x3 << 18) /* Channel Source Addressing Mode */ | ||
| 145 | #define AT_XDMAC_CC_DAM_FIXED_AM (0x0 << 18) | ||
| 146 | #define AT_XDMAC_CC_DAM_INCREMENTED_AM (0x1 << 18) | ||
| 147 | #define AT_XDMAC_CC_DAM_UBS_AM (0x2 << 18) | ||
| 148 | #define AT_XDMAC_CC_DAM_UBS_DS_AM (0x3 << 18) | ||
| 149 | #define AT_XDMAC_CC_INITD (0x1 << 21) /* Channel Initialization Terminated (read only) */ | ||
