Initial commit
[wrt350n-kernel.git] / include / asm-mn10300 / dma.h
blob098df2e617ab22b5eec54fb885106165f202166c
1 /* MN10300 ISA DMA handlers and definitions
3 * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #ifndef _ASM_DMA_H
12 #define _ASM_DMA_H
14 #include <asm/system.h>
15 #include <linux/spinlock.h>
16 #include <asm/io.h>
17 #include <linux/delay.h>
19 #undef MAX_DMA_CHANNELS /* switch off linux/kernel/dma.c */
20 #define MAX_DMA_ADDRESS 0xbfffffff
22 extern spinlock_t dma_spin_lock;
24 static inline unsigned long claim_dma_lock(void)
26 unsigned long flags;
27 spin_lock_irqsave(&dma_spin_lock, flags);
28 return flags;
31 static inline void release_dma_lock(unsigned long flags)
33 spin_unlock_irqrestore(&dma_spin_lock, flags);
36 /* enable/disable a specific DMA channel */
37 static inline void enable_dma(unsigned int dmanr)
41 static inline void disable_dma(unsigned int dmanr)
45 /* Clear the 'DMA Pointer Flip Flop'.
46 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
47 * Use this once to initialize the FF to a known state.
48 * After that, keep track of it. :-)
49 * --- In order to do that, the DMA routines below should ---
50 * --- only be used while holding the DMA lock ! ---
52 static inline void clear_dma_ff(unsigned int dmanr)
56 /* set mode (above) for a specific DMA channel */
57 static inline void set_dma_mode(unsigned int dmanr, char mode)
61 /* Set only the page register bits of the transfer address.
62 * This is used for successive transfers when we know the contents of
63 * the lower 16 bits of the DMA current address register, but a 64k boundary
64 * may have been crossed.
66 static inline void set_dma_page(unsigned int dmanr, char pagenr)
71 /* Set transfer address & page bits for specific DMA channel.
72 * Assumes dma flipflop is clear.
74 static inline void set_dma_addr(unsigned int dmanr, unsigned int a)
79 /* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
80 * a specific DMA channel.
81 * You must ensure the parameters are valid.
82 * NOTE: from a manual: "the number of transfers is one more
83 * than the initial word count"! This is taken into account.
84 * Assumes dma flip-flop is clear.
85 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
87 static inline void set_dma_count(unsigned int dmanr, unsigned int count)
92 /* Get DMA residue count. After a DMA transfer, this
93 * should return zero. Reading this while a DMA transfer is
94 * still in progress will return unpredictable results.
95 * If called before the channel has been used, it may return 1.
96 * Otherwise, it returns the number of _bytes_ left to transfer.
98 * Assumes DMA flip-flop is clear.
100 static inline int get_dma_residue(unsigned int dmanr)
102 return 0;
106 /* These are in kernel/dma.c: */
107 extern int request_dma(unsigned int dmanr, const char *device_id);
108 extern void free_dma(unsigned int dmanr);
110 /* From PCI */
112 #ifdef CONFIG_PCI
113 extern int isa_dma_bridge_buggy;
114 #else
115 #define isa_dma_bridge_buggy (0)
116 #endif
118 #endif /* _ASM_DMA_H */