dma-isa.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * This implements a small wrapper set to make code using the old ISA DMA API
  17. * work with the SH DMA API. Since most of the work in the new API happens
  18. * at ops->xfer() time, we simply use the various set_dma_xxx() routines to
  19. * fill in per-channel info, and then hand hand this off to ops->xfer() at
  20. * enable_dma() time.
  21. *
  22. * For channels that are doing on-demand data transfer via cascading, the
  23. * channel itself will still need to be configured through the new API. As
  24. * such, this code is meant for only the simplest of tasks (and shouldn't be
  25. * used in any new drivers at all).
  26. *
  27. * It should also be noted that various functions here are labelled as
  28. * being deprecated. This is due to the fact that the ops->xfer() method is
  29. * the preferred way of doing things (as well as just grabbing the spinlock
  30. * directly). As such, any users of this interface will be warned rather
  31. * loudly.
  32. */
  33. unsigned long __deprecated claim_dma_lock(void)
  34. {
  35. unsigned long flags;
  36. spin_lock_irqsave(&dma_spin_lock, flags);
  37. return flags;
  38. }
  39. EXPORT_SYMBOL(claim_dma_lock);
  40. void __deprecated release_dma_lock(unsigned long flags)
  41. {
  42. spin_unlock_irqrestore(&dma_spin_lock, flags);
  43. }
  44. EXPORT_SYMBOL(release_dma_lock);
  45. void __deprecated disable_dma(unsigned int chan)
  46. {
  47. /* Nothing */
  48. }
  49. EXPORT_SYMBOL(disable_dma);
  50. void __deprecated enable_dma(unsigned int chan)
  51. {
  52. struct dma_info *info = get_dma_info(chan);
  53. struct dma_channel *channel = &info->channels[chan];
  54. info->ops->xfer(channel);
  55. }
  56. EXPORT_SYMBOL(enable_dma);
  57. void clear_dma_ff(unsigned int chan)
  58. {
  59. /* Nothing */
  60. }
  61. EXPORT_SYMBOL(clear_dma_ff);
  62. void set_dma_mode(unsigned int chan, char mode)
  63. {
  64. struct dma_info *info = get_dma_info(chan);
  65. struct dma_channel *channel = &info->channels[chan];
  66. channel->mode = mode;
  67. }
  68. EXPORT_SYMBOL(set_dma_mode);
  69. void set_dma_addr(unsigned int chan, unsigned int addr)
  70. {
  71. struct dma_info *info = get_dma_info(chan);
  72. struct dma_channel *channel = &info->channels[chan];
  73. /*
  74. * Single address mode is the only thing supported through
  75. * this interface.
  76. */
  77. if ((channel->mode & DMA_MODE_MASK) == DMA_MODE_READ) {
  78. channel->sar = addr;
  79. } else {
  80. channel->dar = addr;
  81. }
  82. }
  83. EXPORT_SYMBOL(set_dma_addr);
  84. void set_dma_count(unsigned int chan, unsigned int count)
  85. {
  86. struct dma_info *info = get_dma_info(chan);
  87. struct dma_channel *channel = &info->channels[chan];
  88. channel->count = count;
  89. }
  90. EXPORT_SYMBOL(set_dma_count);