#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of_dma.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#define STM32_DMA_LISR 0x0000
#define STM32_DMA_HISR 0x0004
#define STM32_DMA_LIFCR 0x0008
#define STM32_DMA_HIFCR 0x000c
#define STM32_DMA_TCI BIT(5)
#define STM32_DMA_HTI BIT(4)
#define STM32_DMA_TEI BIT(3)
#define STM32_DMA_DMEI BIT(2)
#define STM32_DMA_FEI BIT(0)
#define STM32_DMA_MASKI (STM32_DMA_TCI \
#define STM32_DMA_SCR(x) (0x0010 + 0x18 * (x))
#define STM32_DMA_SCR_REQ(n) ((n & 0x7) << 25)
#define STM32_DMA_SCR_MBURST_MASK GENMASK(24, 23)
#define STM32_DMA_SCR_MBURST(n) ((n & 0x3) << 23)
#define STM32_DMA_SCR_PBURST_MASK GENMASK(22, 21)
#define STM32_DMA_SCR_PBURST(n) ((n & 0x3) << 21)
#define STM32_DMA_SCR_PL_MASK GENMASK(17, 16)
#define STM32_DMA_SCR_PL(n) ((n & 0x3) << 16)
#define STM32_DMA_SCR_MSIZE_MASK GENMASK(14, 13)
#define STM32_DMA_SCR_MSIZE(n) ((n & 0x3) << 13)
#define STM32_DMA_SCR_PSIZE_MASK GENMASK(12, 11)
#define STM32_DMA_SCR_PSIZE(n) ((n & 0x3) << 11)
#define STM32_DMA_SCR_PSIZE_GET(n) ((n & STM32_DMA_SCR_PSIZE_MASK) >> 11)
#define STM32_DMA_SCR_DIR_MASK GENMASK(7, 6)
#define STM32_DMA_SCR_DIR(n) ((n & 0x3) << 6)
#define STM32_DMA_SCR_CT BIT(19)
#define STM32_DMA_SCR_DBM BIT(18)
#define STM32_DMA_SCR_PINCOS BIT(15)
#define STM32_DMA_SCR_MINC BIT(10)
#define STM32_DMA_SCR_PINC BIT(9)
#define STM32_DMA_SCR_CIRC BIT(8)
#define STM32_DMA_SCR_PFCTRL BIT(5)
#define STM32_DMA_SCR_TCIE BIT(4)
#define STM32_DMA_SCR_TEIE BIT(2)
#define STM32_DMA_SCR_DMEIE BIT(1)
#define STM32_DMA_SCR_EN BIT(0)
#define STM32_DMA_SCR_CFG_MASK (STM32_DMA_SCR_PINC \
#define STM32_DMA_SCR_IRQ_MASK (STM32_DMA_SCR_TCIE \
#define STM32_DMA_SNDTR(x) (0x0014 + 0x18 * (x))
#define STM32_DMA_SPAR(x) (0x0018 + 0x18 * (x))
#define STM32_DMA_SM0AR(x) (0x001c + 0x18 * (x))