cppi_dma.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* Copyright (C) 2005-2006 by Texas Instruments */
  2. #ifndef _CPPI_DMA_H_
  3. #define _CPPI_DMA_H_
  4. #include <linux/slab.h>
  5. #include <linux/list.h>
  6. #include <linux/errno.h>
  7. #include <linux/dmapool.h>
  8. #include "musb_dma.h"
  9. #include "musb_core.h"
  10. /* FIXME fully isolate CPPI from DaVinci ... the "CPPI generic" registers
  11. * would seem to be shared with the TUSB6020 (over VLYNQ).
  12. */
  13. #include "davinci.h"
  14. /* CPPI RX/TX state RAM */
  15. struct cppi_tx_stateram {
  16. u32 tx_head; /* "DMA packet" head descriptor */
  17. u32 tx_buf;
  18. u32 tx_current; /* current descriptor */
  19. u32 tx_buf_current;
  20. u32 tx_info; /* flags, remaining buflen */
  21. u32 tx_rem_len;
  22. u32 tx_dummy; /* unused */
  23. u32 tx_complete;
  24. };
  25. struct cppi_rx_stateram {
  26. u32 rx_skipbytes;
  27. u32 rx_head;
  28. u32 rx_sop; /* "DMA packet" head descriptor */
  29. u32 rx_current; /* current descriptor */
  30. u32 rx_buf_current;
  31. u32 rx_len_len;
  32. u32 rx_cnt_cnt;
  33. u32 rx_complete;
  34. };
  35. /* hw_options bits in CPPI buffer descriptors */
  36. #define CPPI_SOP_SET ((u32)(1 << 31))
  37. #define CPPI_EOP_SET ((u32)(1 << 30))
  38. #define CPPI_OWN_SET ((u32)(1 << 29)) /* owned by cppi */
  39. #define CPPI_EOQ_MASK ((u32)(1 << 28))
  40. #define CPPI_ZERO_SET ((u32)(1 << 23)) /* rx saw zlp; tx issues one */
  41. #define CPPI_RXABT_MASK ((u32)(1 << 19)) /* need more rx buffers */
  42. #define CPPI_RECV_PKTLEN_MASK 0xFFFF
  43. #define CPPI_BUFFER_LEN_MASK 0xFFFF
  44. #define CPPI_TEAR_READY ((u32)(1 << 31))
  45. /* CPPI data structure definitions */
  46. #define CPPI_DESCRIPTOR_ALIGN 16 /* bytes; 5-dec docs say 4-byte align */
  47. struct cppi_descriptor {
  48. /* hardware overlay */
  49. u32 hw_next; /* next buffer descriptor Pointer */
  50. u32 hw_bufp; /* i/o buffer pointer */
  51. u32 hw_off_len; /* buffer_offset16, buffer_length16 */
  52. u32 hw_options; /* flags: SOP, EOP etc*/
  53. struct cppi_descriptor *next;
  54. dma_addr_t dma; /* address of this descriptor */
  55. u32 buflen; /* for RX: original buffer length */
  56. } __attribute__ ((aligned(CPPI_DESCRIPTOR_ALIGN)));
  57. struct cppi;
  58. /* CPPI Channel Control structure */
  59. struct cppi_channel {
  60. struct dma_channel channel;
  61. /* back pointer to the DMA controller structure */
  62. struct cppi *controller;
  63. /* which direction of which endpoint? */
  64. struct musb_hw_ep *hw_ep;
  65. bool transmit;
  66. u8 index;
  67. /* DMA modes: RNDIS or "transparent" */
  68. u8 is_rndis;
  69. /* book keeping for current transfer request */
  70. dma_addr_t buf_dma;
  71. u32 buf_len;
  72. u32 maxpacket;
  73. u32 offset; /* dma requested */
  74. void __iomem *state_ram; /* CPPI state */
  75. struct cppi_descriptor *freelist;
  76. /* BD management fields */
  77. struct cppi_descriptor *head;
  78. struct cppi_descriptor *tail;
  79. struct cppi_descriptor *last_processed;
  80. /* use tx_complete in host role to track endpoints waiting for
  81. * FIFONOTEMPTY to clear.
  82. */
  83. struct list_head tx_complete;
  84. };
  85. /* CPPI DMA controller object */
  86. struct cppi {
  87. struct dma_controller controller;
  88. struct musb *musb;
  89. void __iomem *mregs; /* Mentor regs */
  90. void __iomem *tibase; /* TI/CPPI regs */
  91. int irq;
  92. struct cppi_channel tx[4];
  93. struct cppi_channel rx[4];
  94. struct dma_pool *pool;
  95. struct list_head tx_complete;
  96. };
  97. /* CPPI IRQ handler */
  98. extern irqreturn_t cppi_interrupt(int, void *);
  99. #endif /* end of ifndef _CPPI_DMA_H_ */