Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/sh/drivers/dma/dma-isa.c |
| 3 | * |
| 4 | * Generic ISA DMA wrapper for SH DMA API |
| 5 | * |
| 6 | * Copyright (C) 2003, 2004 Paul Mundt |
| 7 | * |
| 8 | * This file is subject to the terms and conditions of the GNU General Public |
| 9 | * License. See the file "COPYING" in the main directory of this archive |
| 10 | * for more details. |
| 11 | */ |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <asm/dma.h> |
| 15 | |
| 16 | /* |
| 17 | * This implements a small wrapper set to make code using the old ISA DMA API |
| 18 | * work with the SH DMA API. Since most of the work in the new API happens |
| 19 | * at ops->xfer() time, we simply use the various set_dma_xxx() routines to |
| 20 | * fill in per-channel info, and then hand hand this off to ops->xfer() at |
| 21 | * enable_dma() time. |
| 22 | * |
| 23 | * For channels that are doing on-demand data transfer via cascading, the |
| 24 | * channel itself will still need to be configured through the new API. As |
| 25 | * such, this code is meant for only the simplest of tasks (and shouldn't be |
| 26 | * used in any new drivers at all). |
| 27 | * |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 28 | * NOTE: ops->xfer() is the preferred way of doing things. However, there |
| 29 | * are some users of the ISA DMA API that exist in common code that we |
| 30 | * don't necessarily want to go out of our way to break, so we still |
| 31 | * allow for some compatability at that level. Any new code is strongly |
| 32 | * advised to run far away from the ISA DMA API and use the SH DMA API |
| 33 | * directly. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | */ |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 35 | unsigned long claim_dma_lock(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { |
| 37 | unsigned long flags; |
| 38 | |
| 39 | spin_lock_irqsave(&dma_spin_lock, flags); |
| 40 | |
| 41 | return flags; |
| 42 | } |
| 43 | EXPORT_SYMBOL(claim_dma_lock); |
| 44 | |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 45 | void release_dma_lock(unsigned long flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | { |
| 47 | spin_unlock_irqrestore(&dma_spin_lock, flags); |
| 48 | } |
| 49 | EXPORT_SYMBOL(release_dma_lock); |
| 50 | |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 51 | void disable_dma(unsigned int chan) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | { |
| 53 | /* Nothing */ |
| 54 | } |
| 55 | EXPORT_SYMBOL(disable_dma); |
| 56 | |
Paul Mundt | 0d83177 | 2006-01-16 22:14:09 -0800 | [diff] [blame] | 57 | void enable_dma(unsigned int chan) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { |
| 59 | struct dma_info *info = get_dma_info(chan); |
| 60 | struct dma_channel *channel = &info->channels[chan]; |
| 61 | |
| 62 | info->ops->xfer(channel); |
| 63 | } |
| 64 | EXPORT_SYMBOL(enable_dma); |
| 65 | |
| 66 | void clear_dma_ff(unsigned int chan) |
| 67 | { |
| 68 | /* Nothing */ |
| 69 | } |
| 70 | EXPORT_SYMBOL(clear_dma_ff); |
| 71 | |
| 72 | void set_dma_mode(unsigned int chan, char mode) |
| 73 | { |
| 74 | struct dma_info *info = get_dma_info(chan); |
| 75 | struct dma_channel *channel = &info->channels[chan]; |
| 76 | |
| 77 | channel->mode = mode; |
| 78 | } |
| 79 | EXPORT_SYMBOL(set_dma_mode); |
| 80 | |
| 81 | void set_dma_addr(unsigned int chan, unsigned int addr) |
| 82 | { |
| 83 | struct dma_info *info = get_dma_info(chan); |
| 84 | struct dma_channel *channel = &info->channels[chan]; |
| 85 | |
| 86 | /* |
| 87 | * Single address mode is the only thing supported through |
| 88 | * this interface. |
| 89 | */ |
| 90 | if ((channel->mode & DMA_MODE_MASK) == DMA_MODE_READ) { |
| 91 | channel->sar = addr; |
| 92 | } else { |
| 93 | channel->dar = addr; |
| 94 | } |
| 95 | } |
| 96 | EXPORT_SYMBOL(set_dma_addr); |
| 97 | |
| 98 | void set_dma_count(unsigned int chan, unsigned int count) |
| 99 | { |
| 100 | struct dma_info *info = get_dma_info(chan); |
| 101 | struct dma_channel *channel = &info->channels[chan]; |
| 102 | |
| 103 | channel->count = count; |
| 104 | } |
| 105 | EXPORT_SYMBOL(set_dma_count); |
| 106 | |