Add Qualcomm MSM ADM DMAEngine driver
Subsystems (4)
cover Add Qualcomm MSM ADM DMAEngine driver
Qualcomm Application Datamover(ADM) supports simple, scatter gather and box mode dma transfers.
This driver implements the scatter gather and box mode transfer.
Our ADM hardware needs these following fields for a transfer.
-------------------
Scatter gather mode
-------------------
32-bit command configuration.
32-bit source address
32 bit destination address
16-bit length
---------
Box Mode
---------
32-bit command configuration
32-bit source address
32-bit destination address
16-bit source row length
16-bit destination row length
16-bit source row numbers
16-bit destination row numbers
16-bit source row offset
16-bit destination row offset
As of now there is no support to pass private data like "command" configuration in standard DMAEngine API.
We are using "device_prep_dma_sg" API to do the SG and box mode transfer, but since the current APIs doesn't support a way to pass the "command configuration", "source and destination row numbers" we are using "length" and "offset" field of the existing scatterlist to achieve it. Let us know if there is a better way to do it or new API needs to be created.
Here we are using same length field as above for command configuration, 16 MSB bits offset field of scatterlist for passing row numbers and remaining of 16 LSB bits for offset.
Ravi Kumar V (1):
msm: DMAEngine: Add DMAEngine driver based on old MSM DMA APIs
arch/arm/mach-msm/include/mach/dma.h | 53 +++ drivers/dma/Kconfig | 12 + drivers/dma/Makefile | 1 + drivers/dma/msm-dma.c | 719 ++++++++++++++++++++++++++++++++++ 4 files changed, 785 insertions(+), 0 deletions(-) create mode 100644 drivers/dma/msm-dma.c
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 1/1 msm: DMAEngine: Add DMAEngine driver based on old MSM DMA APIs
Add DMAEngine based driver using the old MSM DMA APIs internally. The benefit of this approach is that not all the drivers have to get converted to DMAEngine APIs simultaneosly while both the drivers can stay enabled in the kernel. The client drivers using the old MSM APIs directly can now convert to DMAEngine one by one.
--- arch/arm/mach-msm/include/mach/dma.h | 53 +++ drivers/dma/Kconfig | 12 + drivers/dma/Makefile | 1 + drivers/dma/msm-dma.c | 719 ++++++++++++++++++++++++++++++++++ 4 files changed, 785 insertions(+), 0 deletions(-) create mode 100644 drivers/dma/msm-dma.c
arch/arm/mach-msm/include/mach/dma.h +53 -0
@@ -18,6 +18,59 @@#include <linux/list.h> #include <mach/msm_iomap.h> +#ifdef CONFIG_NEED_SG_DMA_LENGTH +#define msm_dma_len (sg, len) (((sg)->dma_length) = \ + (((sg)->dma_length) & 0xFFFF0000) | \ + (len & 0xFFFF)) +#define msm_dma_mode (sg, mode) (((sg)->dma_length) = \ + (((sg)->dma_length) & 0xFFFCFFFF) | \ + (mode << 16)) +#define msm_dma_crci (sg, crci) (((sg)->dma_length) = \ + (((sg)->dma_length) & 0x0003FFFF) | \ + (crci << 15)) +#define msm_dma_endian (sg, en) (((sg)->dma_length) = \ + (((sg)->dma_length) & 0x03FFFFFF) | \ + (en << 26)) +#else +#define msm_dma_len (sg, len) (((sg)->length) = \ + (((sg)->length) & 0xFFFF0000) | \ + (len & 0xFFFF)) +#define msm_dma_mode (sg, mode) (((sg)->length) = \ + (((sg)->length) & 0xFFFCFFFF) | \ + (mode << 16)) +#define msm_dma_crci (sg, crci) (((sg)->length) = \ + (((sg)->length) & 0x0003FFFF) | \ + (crci << 15)) +#define msm_dma_endian (sg, en) (((sg)->length) = \ + (((sg)->length) & 0x03FFFFFF) | \ + (en << 26)) +#endif +#define msm_dma_offset (sg, val) (((sg)->offset) = \ + (((sg)->offset) & 0xFFFF0000) | \ + (val & 0xFFFF)) +#define msm_dma_row_count (sg, cnt) (((sg)->offset) = \ + (((sg)->offset) & 0x0000FFFF) | \ + (cnt << 16)) +#define msm_dma_address (sg) ((sg)->dma_address) + +#define MSM_DMA_LEN_MASK 0xFFFF +#define MSM_DMA_CMD_MODE_MASK 0x00030000 +#define MSM_DMA_CMD_MODE_SHIFT 16 +#define MSM_DMA_CMD_MASK 0xFFFC0000 +#define MSM_DMA_CMD_SHIFT 15 +#define MSM_DMA_ENDIAN_MASK 0xFC000000 +#define MSM_DMA_ENDIAN_SHIFT 23 +#define MSM_OFFSET_MASK 0xFFFF +#define MSM_ROW_CNT_MASK 0xFFFF0000 +#define MSM_ROW_CNT_SHIFT 16 +#define MSM_SG_MODE_CMD 0x00000002 +#define MSM_BOX_MODE_CMD 0x00000003 + +#define FORCED_FLUSH 0 +#define GRACEFUL_FLUSH 1 + +#define MSM_CMD_CRCI_SHIFT 3 +struct msm_dmov_errdata {uint32_t flush[6 ]; };
drivers/dma/Kconfig +12 -0
@@ -245,6 +245,18 @@ config EP93XX_DMA help Enable support for the Cirrus Logic EP93xx M2P/M2M DMA controller. +config MSM_DMA + tristate "Qualcomm MSM DMA support" + depends on ARCH_MSM + select DMA_ENGINE + help + Support the Qualcomm DMA engine. This engine is integrated into + Qualcomm chips. + + Say Y here if you have such a chipset. + + If unsure, say N. + config DMA_ENGINE bool
drivers/dma/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_COH901318) += coh901318.o coh901318_lli.o obj-$(CONFIG_AMCC_PPC440SPE_ADMA) += ppc4xx/ obj-$(CONFIG_IMX_SDMA) += imx-sdma.o obj-$(CONFIG_IMX_DMA) += imx-dma.o +obj-$(CONFIG_MSM_DMA) += msm-dma.o obj-$(CONFIG_MXS_DMA) += mxs-dma.o obj-$(CONFIG_TIMB_DMA) += timb_dma.o obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o
drivers/dma/msm-dma.c new file +719 -0
719 lines not on this page · raw message
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 1/1] msm: DMAEngine: Add DMAEngine driver based on old MSM DMA APIs
Quoted 30 lines · Ravi Kumar V
arch/arm/mach-msm/include/mach/dma.h +24
-0@@ -18,6 +18,59 @@#include <linux/list.h> #include <mach/msm_iomap.h> +#ifdef CONFIG_NEED_SG_DMA_LENGTH +#define msm_dma_len (sg, len) (((sg)->dma_length) = \ + (((sg)->dma_length) & 0xFFFF0000) | \ + (len & 0xFFFF)) +#define msm_dma_mode (sg, mode) (((sg)->dma_length) = \ + (((sg)->dma_length) & 0xFFFCFFFF) | \ + (mode << 16)) +#define msm_dma_crci (sg, crci) (((sg)->dma_length) = \ + (((sg)->dma_length) & 0x0003FFFF) | \ + (crci << 15)) +#define msm_dma_endian (sg, en) (((sg)->dma_length) = \ + (((sg)->dma_length) & 0x03FFFFFF) | \ + (en << 26)) +#else +#define msm_dma_len (sg, len) (((sg)->length) = \ + (((sg)->length) & 0xFFFF0000) | \ + (len & 0xFFFF)) +#define msm_dma_mode (sg, mode) (((sg)->length) = \ + (((sg)->length) & 0xFFFCFFFF) | \ + (mode << 16)) +#define msm_dma_crci (sg, crci) (((sg)->length) = \ + (((sg)->length) & 0x0003FFFF) | \ + (crci << 15)) +#define msm_dma_endian (sg, en) (((sg)->length) = \
arch/arm/mach-msm/include/mach/dma.h line 54
Quoted 10 lines
arch/arm/mach-msm/include/mach/dma.h +10
-0+ (((sg)->length) & 0x03FFFFFF) | \ + (en << 26)) +#endif +#define msm_dma_offset (sg, val) (((sg)->offset) = \ + (((sg)->offset) & 0xFFFF0000) | \ + (val & 0xFFFF)) +#define msm_dma_row_count (sg, cnt) (((sg)->offset) = \ + (((sg)->offset) & 0x0000FFFF) | \ + (cnt << 16)) +#define msm_dma_address (sg) ((sg)->dma_address)
It looks like you are encoding some extra data in the dma_length/length and offsets fields of the scatterlist. At a minimum, this needs some explanation, but I'm not sure this is quite the right approach.
The problem is that a driver using DMAEngine would need to know about this extra information to really be able to use the MSM dma.
Some descriptions of the bits, which are still defined in arch/arm/mach-msm/include/mach/dma.h:
- Mode: one of SINGLE, SG, IND_SG, or BOX. Existing drivers seem to only make use of SINGLE (by implication, being zero), and BOX mode. This driver looks like it handles these two cases as well, building the proper types of descriptors.
- CRCI: an MSM-specific term for the flow-control channels on the DMA controller. These are small integers describing which CRCI channel is connected to which device.
- Endian: Some bits directing the controller to perform various types of endian conversions as it transfers the data.
Current drivers that are using the current dmov dma interface seem to be drivers/mmc/host/msm_sdcc.c and drivers/tty/serial/msm_serial_hs.c. Both make use of the BOX mode, and require a CRCI channel.
The question is how do would we extend DMAEngine to support these concepts. Supporting BOX mode, and being able to describe the flow-control channel are probably the most significant.
A good starting point will be to figure out what other DMA hardware supports, and might need out of DMAEngine.
It's certainly a possibility to put the driver in as is, but the clients would have to know the MSM-specific features to be able to use themic features to be able to use them.
David
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.