dma-ep93xx.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_ARCH_DMA_H
  3. #define __ASM_ARCH_DMA_H
  4. #include <linux/types.h>
  5. #include <linux/dmaengine.h>
  6. #include <linux/dma-mapping.h>
  7. /*
  8. * M2P channels.
  9. *
  10. * Note that these values are also directly used for setting the PPALLOC
  11. * register.
  12. */
  13. #define EP93XX_DMA_I2S1 0
  14. #define EP93XX_DMA_I2S2 1
  15. #define EP93XX_DMA_AAC1 2
  16. #define EP93XX_DMA_AAC2 3
  17. #define EP93XX_DMA_AAC3 4
  18. #define EP93XX_DMA_I2S3 5
  19. #define EP93XX_DMA_UART1 6
  20. #define EP93XX_DMA_UART2 7
  21. #define EP93XX_DMA_UART3 8
  22. #define EP93XX_DMA_IRDA 9
  23. /* M2M channels */
  24. #define EP93XX_DMA_SSP 10
  25. #define EP93XX_DMA_IDE 11
  26. /**
  27. * struct ep93xx_dma_data - configuration data for the EP93xx dmaengine
  28. * @port: peripheral which is requesting the channel
  29. * @direction: TX/RX channel
  30. * @name: optional name for the channel, this is displayed in /proc/interrupts
  31. *
  32. * This information is passed as private channel parameter in a filter
  33. * function. Note that this is only needed for slave/cyclic channels. For
  34. * memcpy channels %NULL data should be passed.
  35. */
  36. struct ep93xx_dma_data {
  37. int port;
  38. enum dma_transfer_direction direction;
  39. const char *name;
  40. };
  41. /**
  42. * struct ep93xx_dma_chan_data - platform specific data for a DMA channel
  43. * @name: name of the channel, used for getting the right clock for the channel
  44. * @base: mapped registers
  45. * @irq: interrupt number used by this channel
  46. */
  47. struct ep93xx_dma_chan_data {
  48. const char *name;
  49. void __iomem *base;
  50. int irq;
  51. };
  52. /**
  53. * struct ep93xx_dma_platform_data - platform data for the dmaengine driver
  54. * @channels: array of channels which are passed to the driver
  55. * @num_channels: number of channels in the array
  56. *
  57. * This structure is passed to the DMA engine driver via platform data. For
  58. * M2P channels, contract is that even channels are for TX and odd for RX.
  59. * There is no requirement for the M2M channels.
  60. */
  61. struct ep93xx_dma_platform_data {
  62. struct ep93xx_dma_chan_data *channels;
  63. size_t num_channels;
  64. };
  65. static inline bool ep93xx_dma_chan_is_m2p(struct dma_chan *chan)
  66. {
  67. return !strcmp(dev_name(chan->device->dev), "ep93xx-dma-m2p");
  68. }
  69. /**
  70. * ep93xx_dma_chan_direction - returns direction the channel can be used
  71. * @chan: channel
  72. *
  73. * This function can be used in filter functions to find out whether the
  74. * channel supports given DMA direction. Only M2P channels have such
  75. * limitation, for M2M channels the direction is configurable.
  76. */
  77. static inline enum dma_transfer_direction
  78. ep93xx_dma_chan_direction(struct dma_chan *chan)
  79. {
  80. if (!ep93xx_dma_chan_is_m2p(chan))
  81. return DMA_TRANS_NONE;
  82. /* even channels are for TX, odd for RX */
  83. return (chan->chan_id % 2 == 0) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
  84. }
  85. #endif /* __ASM_ARCH_DMA_H */