dma: pl330: add getposition() API
authorSeokju Yoon <sukju.yoon@samsung.com>
Mon, 15 Jun 2015 08:07:34 +0000 (17:07 +0900)
committerTaekki Kim <taekki.kim@samsung.com>
Mon, 14 May 2018 05:42:46 +0000 (14:42 +0900)
This patch adds a getposition() API to provide the current DMA buffer
position.

Change-Id: I8627e4c0d494701fe272fda55ac3e64792065074
Signed-off-by: Soohyun Kim <soohyuni.kim@samsung.com>
Signed-off-by: Seokju Yoon <sukju.yoon@samsung.com>
drivers/dma/pl330.c
include/linux/amba/pl330.h [new file with mode: 0644]

index f122c2a7b9f0bc7383ac5114107fb4aac018066d..719abf6712570e2b7be841e082cce74e6ee30c0b 100644 (file)
@@ -2759,6 +2759,26 @@ static irqreturn_t pl330_irq_handler(int irq, void *data)
                return IRQ_NONE;
 }
 
+int pl330_dma_getposition(struct dma_chan *chan,
+               dma_addr_t *src, dma_addr_t *dst)
+{
+       struct dma_pl330_chan *pch = to_pchan(chan);
+       void __iomem *regs;
+       struct pl330_thread *thrd;
+
+       if (unlikely(!pch))
+               return -EINVAL;
+
+       thrd = pch->thread;
+       regs = pch->dmac->base;
+
+       *src = readl(regs + SA(thrd->id));
+       *dst = readl(regs + DA(thrd->id));
+
+       return 0;
+}
+EXPORT_SYMBOL(pl330_dma_getposition);
+
 #define PL330_DMA_BUSWIDTHS \
        BIT(DMA_SLAVE_BUSWIDTH_UNDEFINED) | \
        BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
diff --git a/include/linux/amba/pl330.h b/include/linux/amba/pl330.h
new file mode 100644 (file)
index 0000000..c95df58
--- /dev/null
@@ -0,0 +1,37 @@
+/* linux/include/linux/amba/pl330.h
+ *
+ * Copyright (C) 2010 Samsung Electronics Co. Ltd.
+ *     Jaswinder Singh <jassi.brar@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef        __AMBA_PL330_H_
+#define        __AMBA_PL330_H_
+
+#include <linux/dmaengine.h>
+
+struct dma_pl330_platdata {
+       /*
+        * Number of valid peripherals connected to DMAC.
+        * This may be different from the value read from
+        * CR0, as the PL330 implementation might have 'holes'
+        * in the peri list or the peri could also be reached
+        * from another DMAC which the platform prefers.
+        */
+       u8 nr_valid_peri;
+       /* Array of valid peripherals */
+       u8 *peri_id;
+       /* Operational capabilities */
+       dma_cap_mask_t cap_mask;
+       /* Bytes to allocate for MC buffer */
+       unsigned mcbuf_sz;
+};
+
+extern bool pl330_filter(struct dma_chan *chan, void *param);
+extern int pl330_dma_getposition(struct dma_chan *chan,
+               dma_addr_t *src, dma_addr_t *dst);
+#endif /* __AMBA_PL330_H_ */