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. * NOTE: ops->xfer() is the preferred way of doing things. However, there
  28. * are some users of the ISA DMA API that exist in common code that we
  29. * don't necessarily want to go out of our way to break, so we still
  30. * allow for some compatibility at that level. Any new code is strongly
  31. * advised to run far away from the ISA DMA API and use the SH DMA API
  32. * directly.
  33. */
  34. unsigned long claim_dma_lock(void)
  35. {
  36. unsigned long flags;
  37. spin_lock_irqsave(&dma_spin_lock, flags);
  38. return flags;
  39. }
  40. EXPORT_SYMBOL(claim_dma_lock);
  41. void release_dma_lock(unsigned long flags)
  42. {
  43. spin_unlock_irqrestore(&dma_spin_lock, flags);
  44. }
  45. EXPORT_SYMBOL(release_dma_lock);
  46. void disable_dma(unsigned int chan)
  47. {
  48. /* Nothing */
  49. }
  50. EXPORT_SYMBOL(disable_dma);
  51. void enable_dma(unsigned int chan)
  52. {
  53. struct dma_info *info = get_dma_info(chan);
  54. struct dma_channel *channel = &info->channels[chan];
  55. info->ops->xfer(channel);
  56. }
  57. EXPORT_SYMBOL(enable_dma);
  58. void clear_dma_ff(unsigned int chan)
  59. {
  60. /* Nothing */
  61. }
  62. EXPORT_SYMBOL(clear_dma_ff);
  63. void set_dma_mode(unsigned int chan, char mode)
  64. {
  65. struct dma_info *info = get_dma_info(chan);
  66. struct dma_channel *channel = &info->channels[chan];
  67. channel->mode = mode;
  68. }
  69. EXPORT_SYMBOL(set_dma_mode);
  70. void set_dma_addr(unsigned int chan, unsigned int addr)
  71. {
  72. struct dma_info *info = get_dma_info(chan);
  73. struct dma_channel *channel = &info->channels[chan];
  74. /*
  75. * Single address mode is the only thing supported through
  76. * this interface.
  77. */
  78. if ((channel->mode & DMA_MODE_MASK) == DMA_MODE_READ) {
  79. channel->sar = addr;
  80. } else {
  81. channel->dar = addr;
  82. }
  83. }
  84. EXPORT_SYMBOL(set_dma_addr);
  85. void set_dma_count(unsigned int chan, unsigned int count)
  86. {
  87. struct dma_info *info = get_dma_info(chan);
  88. struct dma_channel *channel = &info->channels[chan];
  89. channel->count = count;
  90. }
  91. EXPORT_SYMBOL(set_dma_count);