#include <linux/bitmap.h>
#include <linux/bitops.h>
#include <linux/dmaengine.h>
#include <linux/dmapool.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of_dma.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#define SUN4I_DMA_CFG_LOADING BIT(31)
#define SUN4I_DMA_CFG_DST_DATA_WIDTH(width) ((width) << 25)
#define SUN4I_DMA_CFG_DST_BURST_LENGTH(len) ((len) << 23)
#define SUN4I_DMA_CFG_DST_ADDR_MODE(mode) ((mode) << 21)
#define SUN4I_DMA_CFG_DST_DRQ_TYPE(type) ((type) << 16)
#define SUN4I_DMA_CFG_SRC_DATA_WIDTH(width) ((width) << 9)
#define SUN4I_DMA_CFG_SRC_BURST_LENGTH(len) ((len) << 7)
#define SUN4I_DMA_CFG_SRC_ADDR_MODE(mode) ((mode) << 5)
#define SUN4I_DMA_CFG_SRC_DRQ_TYPE(type) (type)
#define SUN4I_NDMA_DRQ_TYPE_SDRAM 0x16
#define SUN4I_NDMA_DRQ_TYPE_LIMIT (0x1F + 1)
#define SUN4I_NDMA_ADDR_MODE_LINEAR 0
#define SUN4I_NDMA_ADDR_MODE_IO 1
#define SUN4I_NDMA_CFG_CONT_MODE BIT(30)
#define SUN4I_NDMA_CFG_WAIT_STATE(n) ((n) << 27)
#define SUN4I_NDMA_CFG_DST_NON_SECURE BIT(22)
#define SUN4I_NDMA_CFG_BYTE_COUNT_MODE_REMAIN BIT(15)
#define SUN4I_NDMA_CFG_SRC_NON_SECURE BIT(6)
#define SUN4I_DDMA_ADDR_MODE_LINEAR 0
#define SUN4I_DDMA_ADDR_MODE_IO 1
#define SUN4I_DDMA_ADDR_MODE_HORIZONTAL_PAGE 2
#define SUN4I_DDMA_ADDR_MODE_VERTICAL_PAGE 3