|
@@ -399,3 +399,99 @@ static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
|
|
{
|
|
{
|
|
volatile unsigned int *dmalp;
|
|
volatile unsigned int *dmalp;
|
|
|
|
|
|
|
|
+#ifdef DMA_DEBUG
|
|
|
|
+ printk("set_dma_addr(dmanr=%d,a=%x)\n", dmanr, a);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ dmalp = (unsigned int *) dma_base_addr[dmanr];
|
|
|
|
+
|
|
|
|
+ /* Determine which address registers are used for memory/device accesses */
|
|
|
|
+ if (dmalp[MCFDMA_DMR] & MCFDMA_DMR_SRCM) {
|
|
|
|
+ /* Source incrementing, must be memory */
|
|
|
|
+ dmalp[MCFDMA_DSAR] = a;
|
|
|
|
+ /* Set dest address, must be device */
|
|
|
|
+ dmalp[MCFDMA_DDAR] = dma_device_address[dmanr];
|
|
|
|
+ } else {
|
|
|
|
+ /* Destination incrementing, must be memory */
|
|
|
|
+ dmalp[MCFDMA_DDAR] = a;
|
|
|
|
+ /* Set source address, must be device */
|
|
|
|
+ dmalp[MCFDMA_DSAR] = dma_device_address[dmanr];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+#ifdef DEBUG_DMA
|
|
|
|
+ printk("%s(%d): dmanr=%d DMR[%x]=%x SAR[%x]=%08x DAR[%x]=%08x\n",
|
|
|
|
+ __FILE__, __LINE__, dmanr, (int) &dmawp[MCFDMA_DMR], dmawp[MCFDMA_DMR],
|
|
|
|
+ (int) &dmalp[MCFDMA_DSAR], dmalp[MCFDMA_DSAR],
|
|
|
|
+ (int) &dmalp[MCFDMA_DDAR], dmalp[MCFDMA_DDAR]);
|
|
|
|
+#endif
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Specific for Coldfire - sets device address.
|
|
|
|
+ * Should be called after the mode set call, and before set DMA address.
|
|
|
|
+ */
|
|
|
|
+static __inline__ void set_dma_device_addr(unsigned int dmanr, unsigned int a)
|
|
|
|
+{
|
|
|
|
+#ifdef DMA_DEBUG
|
|
|
|
+ printk("set_dma_device_addr(dmanr=%d,a=%x)\n", dmanr, a);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ dma_device_address[dmanr] = a;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * NOTE 2: "count" represents _bytes_.
|
|
|
|
+ *
|
|
|
|
+ * NOTE 3: While a 32-bit register, "count" is only a maximum 24-bit value.
|
|
|
|
+ */
|
|
|
|
+static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
|
|
|
|
+{
|
|
|
|
+ volatile unsigned int *dmalp;
|
|
|
|
+
|
|
|
|
+#ifdef DMA_DEBUG
|
|
|
|
+ printk("set_dma_count(dmanr=%d,count=%d)\n", dmanr, count);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ dmalp = (unsigned int *) dma_base_addr[dmanr];
|
|
|
|
+ dmalp[MCFDMA_DBCR] = count;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Get DMA residue count. After a DMA transfer, this
|
|
|
|
+ * should return zero. Reading this while a DMA transfer is
|
|
|
|
+ * still in progress will return unpredictable results.
|
|
|
|
+ * Otherwise, it returns the number of _bytes_ left to transfer.
|
|
|
|
+ */
|
|
|
|
+static __inline__ int get_dma_residue(unsigned int dmanr)
|
|
|
|
+{
|
|
|
|
+ volatile unsigned int *dmalp;
|
|
|
|
+ unsigned int count;
|
|
|
|
+
|
|
|
|
+#ifdef DMA_DEBUG
|
|
|
|
+ printk("get_dma_residue(dmanr=%d)\n", dmanr);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ dmalp = (unsigned int *) dma_base_addr[dmanr];
|
|
|
|
+ count = dmalp[MCFDMA_DBCR];
|
|
|
|
+ return(count);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif /* !defined(CONFIG_M5272) */
|
|
|
|
+#endif /* CONFIG_COLDFIRE */
|
|
|
|
+
|
|
|
|
+/* it's useless on the m68k, but unfortunately needed by the new
|
|
|
|
+ bootmem allocator (but this should do it for this) */
|
|
|
|
+#define MAX_DMA_ADDRESS PAGE_OFFSET
|
|
|
|
+
|
|
|
|
+#define MAX_DMA_CHANNELS 8
|
|
|
|
+
|
|
|
|
+extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */
|
|
|
|
+extern void free_dma(unsigned int dmanr); /* release it again */
|
|
|
|
+
|
|
|
|
+#ifdef CONFIG_PCI
|
|
|
|
+extern int isa_dma_bridge_buggy;
|
|
|
|
+#else
|
|
|
|
+#define isa_dma_bridge_buggy (0)
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#endif /* _M68K_DMA_H */
|