dma.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * linux/include/asm-arm/arch-sa1100/dma.h
  3. *
  4. * Generic SA1100 DMA support
  5. *
  6. * Copyright (C) 2000 Nicolas Pitre
  7. *
  8. */
  9. #ifndef __ASM_ARCH_DMA_H
  10. #define __ASM_ARCH_DMA_H
  11. #include <linux/config.h>
  12. #include "hardware.h"
  13. /*
  14. * This is the maximum DMA address that can be DMAd to.
  15. */
  16. #define MAX_DMA_ADDRESS 0xffffffff
  17. /*
  18. * The regular generic DMA interface is inappropriate for the
  19. * SA1100 DMA model. None of the SA1100 specific drivers using
  20. * DMA are portable anyway so it's pointless to try to twist the
  21. * regular DMA API to accommodate them.
  22. */
  23. #define MAX_DMA_CHANNELS 0
  24. /*
  25. * The SA1100 has six internal DMA channels.
  26. */
  27. #define SA1100_DMA_CHANNELS 6
  28. /*
  29. * Maximum physical DMA buffer size
  30. */
  31. #define MAX_DMA_SIZE 0x1fff
  32. #define CUT_DMA_SIZE 0x1000
  33. /*
  34. * All possible SA1100 devices a DMA channel can be attached to.
  35. */
  36. typedef enum {
  37. DMA_Ser0UDCWr = DDAR_Ser0UDCWr, /* Ser. port 0 UDC Write */
  38. DMA_Ser0UDCRd = DDAR_Ser0UDCRd, /* Ser. port 0 UDC Read */
  39. DMA_Ser1UARTWr = DDAR_Ser1UARTWr, /* Ser. port 1 UART Write */
  40. DMA_Ser1UARTRd = DDAR_Ser1UARTRd, /* Ser. port 1 UART Read */
  41. DMA_Ser1SDLCWr = DDAR_Ser1SDLCWr, /* Ser. port 1 SDLC Write */
  42. DMA_Ser1SDLCRd = DDAR_Ser1SDLCRd, /* Ser. port 1 SDLC Read */
  43. DMA_Ser2UARTWr = DDAR_Ser2UARTWr, /* Ser. port 2 UART Write */
  44. DMA_Ser2UARTRd = DDAR_Ser2UARTRd, /* Ser. port 2 UART Read */
  45. DMA_Ser2HSSPWr = DDAR_Ser2HSSPWr, /* Ser. port 2 HSSP Write */
  46. DMA_Ser2HSSPRd = DDAR_Ser2HSSPRd, /* Ser. port 2 HSSP Read */
  47. DMA_Ser3UARTWr = DDAR_Ser3UARTWr, /* Ser. port 3 UART Write */
  48. DMA_Ser3UARTRd = DDAR_Ser3UARTRd, /* Ser. port 3 UART Read */
  49. DMA_Ser4MCP0Wr = DDAR_Ser4MCP0Wr, /* Ser. port 4 MCP 0 Write (audio) */
  50. DMA_Ser4MCP0Rd = DDAR_Ser4MCP0Rd, /* Ser. port 4 MCP 0 Read (audio) */
  51. DMA_Ser4MCP1Wr = DDAR_Ser4MCP1Wr, /* Ser. port 4 MCP 1 Write */
  52. DMA_Ser4MCP1Rd = DDAR_Ser4MCP1Rd, /* Ser. port 4 MCP 1 Read */
  53. DMA_Ser4SSPWr = DDAR_Ser4SSPWr, /* Ser. port 4 SSP Write (16 bits) */
  54. DMA_Ser4SSPRd = DDAR_Ser4SSPRd /* Ser. port 4 SSP Read (16 bits) */
  55. } dma_device_t;
  56. typedef struct {
  57. volatile u_long DDAR;
  58. volatile u_long SetDCSR;
  59. volatile u_long ClrDCSR;
  60. volatile u_long RdDCSR;
  61. volatile dma_addr_t DBSA;
  62. volatile u_long DBTA;
  63. volatile dma_addr_t DBSB;
  64. volatile u_long DBTB;
  65. } dma_regs_t;
  66. typedef void (*dma_callback_t)(void *data);
  67. /*
  68. * DMA function prototypes
  69. */
  70. extern int sa1100_request_dma( dma_device_t device, const char *device_id,
  71. dma_callback_t callback, void *data,
  72. dma_regs_t **regs );
  73. extern void sa1100_free_dma( dma_regs_t *regs );
  74. extern int sa1100_start_dma( dma_regs_t *regs, dma_addr_t dma_ptr, u_int size );
  75. extern dma_addr_t sa1100_get_dma_pos(dma_regs_t *regs);
  76. extern void sa1100_reset_dma(dma_regs_t *regs);
  77. /**
  78. * sa1100_stop_dma - stop DMA in progress
  79. * @regs: identifier for the channel to use
  80. *
  81. * This stops DMA without clearing buffer pointers. Unlike
  82. * sa1100_clear_dma() this allows subsequent use of sa1100_resume_dma()
  83. * or sa1100_get_dma_pos().
  84. *
  85. * The @regs identifier is provided by a successful call to
  86. * sa1100_request_dma().
  87. **/
  88. #define sa1100_stop_dma(regs) ((regs)->ClrDCSR = DCSR_IE|DCSR_RUN)
  89. /**
  90. * sa1100_resume_dma - resume DMA on a stopped channel
  91. * @regs: identifier for the channel to use
  92. *
  93. * This resumes DMA on a channel previously stopped with
  94. * sa1100_stop_dma().
  95. *
  96. * The @regs identifier is provided by a successful call to
  97. * sa1100_request_dma().
  98. **/
  99. #define sa1100_resume_dma(regs) ((regs)->SetDCSR = DCSR_IE|DCSR_RUN)
  100. /**
  101. * sa1100_clear_dma - clear DMA pointers
  102. * @regs: identifier for the channel to use
  103. *
  104. * This clear any DMA state so the DMA engine is ready to restart
  105. * with new buffers through sa1100_start_dma(). Any buffers in flight
  106. * are discarded.
  107. *
  108. * The @regs identifier is provided by a successful call to
  109. * sa1100_request_dma().
  110. **/
  111. #define sa1100_clear_dma(regs) ((regs)->ClrDCSR = DCSR_IE|DCSR_RUN|DCSR_STRTA|DCSR_STRTB)
  112. #endif /* _ASM_ARCH_DMA_H */