davinci_cpdma.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Texas Instruments CPDMA Driver
  3. *
  4. * Copyright (C) 2010 Texas Instruments
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation version 2.
  9. *
  10. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  11. * kind, whether express or implied; without even the implied warranty
  12. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef __DAVINCI_CPDMA_H__
  16. #define __DAVINCI_CPDMA_H__
  17. #define CPDMA_MAX_CHANNELS BITS_PER_LONG
  18. #define CPDMA_RX_SOURCE_PORT(__status__) ((__status__ >> 16) & 0x7)
  19. #define CPDMA_EOI_RX_THRESH 0x0
  20. #define CPDMA_EOI_RX 0x1
  21. #define CPDMA_EOI_TX 0x2
  22. #define CPDMA_EOI_MISC 0x3
  23. struct cpdma_params {
  24. struct device *dev;
  25. void __iomem *dmaregs;
  26. void __iomem *txhdp, *rxhdp, *txcp, *rxcp;
  27. void __iomem *rxthresh, *rxfree;
  28. int num_chan;
  29. bool has_soft_reset;
  30. int min_packet_size;
  31. u32 desc_mem_phys;
  32. u32 desc_hw_addr;
  33. int desc_mem_size;
  34. int desc_align;
  35. /*
  36. * Some instances of embedded cpdma controllers have extra control and
  37. * status registers. The following flag enables access to these
  38. * "extended" registers.
  39. */
  40. bool has_ext_regs;
  41. };
  42. struct cpdma_chan_stats {
  43. u32 head_enqueue;
  44. u32 tail_enqueue;
  45. u32 pad_enqueue;
  46. u32 misqueued;
  47. u32 desc_alloc_fail;
  48. u32 pad_alloc_fail;
  49. u32 runt_receive_buff;
  50. u32 runt_transmit_buff;
  51. u32 empty_dequeue;
  52. u32 busy_dequeue;
  53. u32 good_dequeue;
  54. u32 requeue;
  55. u32 teardown_dequeue;
  56. };
  57. struct cpdma_ctlr;
  58. struct cpdma_chan;
  59. typedef void (*cpdma_handler_fn)(void *token, int len, int status);
  60. struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params);
  61. int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr);
  62. int cpdma_ctlr_start(struct cpdma_ctlr *ctlr);
  63. int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr);
  64. struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
  65. cpdma_handler_fn handler, int rx_type);
  66. int cpdma_chan_get_rx_buf_num(struct cpdma_chan *chan);
  67. int cpdma_chan_destroy(struct cpdma_chan *chan);
  68. int cpdma_chan_start(struct cpdma_chan *chan);
  69. int cpdma_chan_stop(struct cpdma_chan *chan);
  70. int cpdma_chan_get_stats(struct cpdma_chan *chan,
  71. struct cpdma_chan_stats *stats);
  72. int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data,
  73. int len, int directed);
  74. int cpdma_chan_process(struct cpdma_chan *chan, int quota);
  75. int cpdma_ctlr_int_ctrl(struct cpdma_ctlr *ctlr, bool enable);
  76. void cpdma_ctlr_eoi(struct cpdma_ctlr *ctlr, u32 value);
  77. int cpdma_chan_int_ctrl(struct cpdma_chan *chan, bool enable);
  78. u32 cpdma_ctrl_rxchs_state(struct cpdma_ctlr *ctlr);
  79. u32 cpdma_ctrl_txchs_state(struct cpdma_ctlr *ctlr);
  80. bool cpdma_check_free_tx_desc(struct cpdma_chan *chan);
  81. enum cpdma_control {
  82. CPDMA_CMD_IDLE, /* write-only */
  83. CPDMA_COPY_ERROR_FRAMES, /* read-write */
  84. CPDMA_RX_OFF_LEN_UPDATE, /* read-write */
  85. CPDMA_RX_OWNERSHIP_FLIP, /* read-write */
  86. CPDMA_TX_PRIO_FIXED, /* read-write */
  87. CPDMA_STAT_IDLE, /* read-only */
  88. CPDMA_STAT_TX_ERR_CHAN, /* read-only */
  89. CPDMA_STAT_TX_ERR_CODE, /* read-only */
  90. CPDMA_STAT_RX_ERR_CHAN, /* read-only */
  91. CPDMA_STAT_RX_ERR_CODE, /* read-only */
  92. CPDMA_RX_BUFFER_OFFSET, /* read-write */
  93. };
  94. int cpdma_control_get(struct cpdma_ctlr *ctlr, int control);
  95. int cpdma_control_set(struct cpdma_ctlr *ctlr, int control, int value);
  96. #endif