#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/of_dma.h>
#include "dmaengine.h"
#define MSGDMA_MAX_TRANS_LEN …
#define MSGDMA_DESC_NUM …
struct msgdma_extended_desc { … };
#define MSGDMA_DESC_CTL_SET_CH(x) …
#define MSGDMA_DESC_CTL_GEN_SOP …
#define MSGDMA_DESC_CTL_GEN_EOP …
#define MSGDMA_DESC_CTL_PARK_READS …
#define MSGDMA_DESC_CTL_PARK_WRITES …
#define MSGDMA_DESC_CTL_END_ON_EOP …
#define MSGDMA_DESC_CTL_END_ON_LEN …
#define MSGDMA_DESC_CTL_TR_COMP_IRQ …
#define MSGDMA_DESC_CTL_EARLY_IRQ …
#define MSGDMA_DESC_CTL_TR_ERR_IRQ …
#define MSGDMA_DESC_CTL_EARLY_DONE …
#define MSGDMA_DESC_CTL_GO …
#define MSGDMA_DESC_CTL_TX_FIRST …
#define MSGDMA_DESC_CTL_TX_MIDDLE …
#define MSGDMA_DESC_CTL_TX_LAST …
#define MSGDMA_DESC_CTL_TX_SINGLE …
#define MSGDMA_DESC_CTL_RX_SINGLE …
#define MSGDMA_DESC_STRIDE_RD …
#define MSGDMA_DESC_STRIDE_WR …
#define MSGDMA_DESC_STRIDE_RW …
#define MSGDMA_CSR_STATUS …
#define MSGDMA_CSR_CONTROL …
#define MSGDMA_CSR_RW_FILL_LEVEL …
#define MSGDMA_CSR_RESP_FILL_LEVEL …
#define MSGDMA_CSR_RW_SEQ_NUM …
#define MSGDMA_CSR_STAT_BUSY …
#define MSGDMA_CSR_STAT_DESC_BUF_EMPTY …
#define MSGDMA_CSR_STAT_DESC_BUF_FULL …
#define MSGDMA_CSR_STAT_RESP_BUF_EMPTY …
#define MSGDMA_CSR_STAT_RESP_BUF_FULL …
#define MSGDMA_CSR_STAT_STOPPED …
#define MSGDMA_CSR_STAT_RESETTING …
#define MSGDMA_CSR_STAT_STOPPED_ON_ERR …
#define MSGDMA_CSR_STAT_STOPPED_ON_EARLY …
#define MSGDMA_CSR_STAT_IRQ …
#define MSGDMA_CSR_STAT_MASK …
#define MSGDMA_CSR_STAT_MASK_WITHOUT_IRQ …
#define DESC_EMPTY …
#define MSGDMA_CSR_CTL_STOP …
#define MSGDMA_CSR_CTL_RESET …
#define MSGDMA_CSR_CTL_STOP_ON_ERR …
#define MSGDMA_CSR_CTL_STOP_ON_EARLY …
#define MSGDMA_CSR_CTL_GLOBAL_INTR …
#define MSGDMA_CSR_CTL_STOP_DESCS …
#define MSGDMA_CSR_WR_FILL_LEVEL_GET(v) …
#define MSGDMA_CSR_RD_FILL_LEVEL_GET(v) …
#define MSGDMA_CSR_RESP_FILL_LEVEL_GET(v) …
#define MSGDMA_CSR_SEQ_NUM_GET(v) …
#define MSGDMA_RESP_BYTES_TRANSFERRED …
#define MSGDMA_RESP_STATUS …
#define MSGDMA_RESP_EARLY_TERM …
#define MSGDMA_RESP_ERR_MASK …
struct msgdma_sw_desc { … };
struct msgdma_device { … };
#define to_mdev(chan) …
#define tx_to_desc(tx) …
static struct msgdma_sw_desc *msgdma_get_descriptor(struct msgdma_device *mdev)
{ … }
static void msgdma_free_descriptor(struct msgdma_device *mdev,
struct msgdma_sw_desc *desc)
{ … }
static void msgdma_free_desc_list(struct msgdma_device *mdev,
struct list_head *list)
{ … }
static void msgdma_desc_config(struct msgdma_extended_desc *desc,
dma_addr_t dst, dma_addr_t src, size_t len,
u32 stride)
{ … }
static void msgdma_desc_config_eod(struct msgdma_extended_desc *desc)
{ … }
static dma_cookie_t msgdma_tx_submit(struct dma_async_tx_descriptor *tx)
{ … }
static struct dma_async_tx_descriptor *
msgdma_prep_memcpy(struct dma_chan *dchan, dma_addr_t dma_dst,
dma_addr_t dma_src, size_t len, ulong flags)
{ … }
static struct dma_async_tx_descriptor *
msgdma_prep_slave_sg(struct dma_chan *dchan, struct scatterlist *sgl,
unsigned int sg_len, enum dma_transfer_direction dir,
unsigned long flags, void *context)
{ … }
static int msgdma_dma_config(struct dma_chan *dchan,
struct dma_slave_config *config)
{ … }
static void msgdma_reset(struct msgdma_device *mdev)
{
u32 val;
int ret;
iowrite32(MSGDMA_CSR_STAT_MASK, mdev->csr + MSGDMA_CSR_STATUS);
iowrite32(MSGDMA_CSR_CTL_RESET, mdev->csr + MSGDMA_CSR_CONTROL);
ret = readl_poll_timeout(mdev->csr + MSGDMA_CSR_STATUS, val,
(val & MSGDMA_CSR_STAT_RESETTING) == 0,
1, 10000);
if (ret)
dev_err(mdev->dev, "DMA channel did not reset\n");
iowrite32(MSGDMA_CSR_STAT_MASK, mdev->csr + MSGDMA_CSR_STATUS);
iowrite32(MSGDMA_CSR_CTL_STOP_ON_ERR | MSGDMA_CSR_CTL_STOP_ON_EARLY |
MSGDMA_CSR_CTL_GLOBAL_INTR, mdev->csr + MSGDMA_CSR_CONTROL);
mdev->idle = true;
};
static void msgdma_copy_one(struct msgdma_device *mdev,
struct msgdma_sw_desc *desc)
{ … }
static void msgdma_copy_desc_to_fifo(struct msgdma_device *mdev,
struct msgdma_sw_desc *desc)
{ … }
static void msgdma_start_transfer(struct msgdma_device *mdev)
{ … }
static void msgdma_issue_pending(struct dma_chan *chan)
{ … }
static void msgdma_chan_desc_cleanup(struct msgdma_device *mdev)
{ … }
static void msgdma_complete_descriptor(struct msgdma_device *mdev)
{ … }
static void msgdma_free_descriptors(struct msgdma_device *mdev)
{ … }
static void msgdma_free_chan_resources(struct dma_chan *dchan)
{ … }
static int msgdma_alloc_chan_resources(struct dma_chan *dchan)
{ … }
static void msgdma_tasklet(struct tasklet_struct *t)
{ … }
static irqreturn_t msgdma_irq_handler(int irq, void *data)
{ … }
static void msgdma_dev_remove(struct msgdma_device *mdev)
{ … }
static int request_and_map(struct platform_device *pdev, const char *name,
struct resource **res, void __iomem **ptr,
bool optional)
{ … }
static int msgdma_probe(struct platform_device *pdev)
{ … }
static void msgdma_remove(struct platform_device *pdev)
{ … }
#ifdef CONFIG_OF
static const struct of_device_id msgdma_match[] = …;
MODULE_DEVICE_TABLE(of, msgdma_match);
#endif
static struct platform_driver msgdma_driver = …;
module_platform_driver(…) …;
MODULE_ALIAS(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;