fifo.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Renesas USB driver
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. *
  16. */
  17. #ifndef RENESAS_USB_FIFO_H
  18. #define RENESAS_USB_FIFO_H
  19. #include <linux/interrupt.h>
  20. #include <linux/sh_dma.h>
  21. #include <asm/dma.h>
  22. #include "pipe.h"
  23. #define DMA_ADDR_INVALID (~(dma_addr_t)0)
  24. struct usbhs_fifo {
  25. char *name;
  26. u32 port; /* xFIFO */
  27. u32 sel; /* xFIFOSEL */
  28. u32 ctr; /* xFIFOCTR */
  29. struct usbhs_pipe *pipe;
  30. struct tasklet_struct tasklet;
  31. struct dma_chan *tx_chan;
  32. struct dma_chan *rx_chan;
  33. struct sh_dmae_slave tx_slave;
  34. struct sh_dmae_slave rx_slave;
  35. };
  36. struct usbhs_fifo_info {
  37. struct usbhs_fifo cfifo;
  38. struct usbhs_fifo d0fifo;
  39. struct usbhs_fifo d1fifo;
  40. };
  41. struct usbhs_pkt_handle;
  42. struct usbhs_pkt {
  43. struct list_head node;
  44. struct usbhs_pipe *pipe;
  45. struct usbhs_pkt_handle *handler;
  46. dma_addr_t dma;
  47. void *buf;
  48. int length;
  49. int trans;
  50. int actual;
  51. int zero;
  52. };
  53. struct usbhs_pkt_handle {
  54. int (*prepare)(struct usbhs_pkt *pkt, int *is_done);
  55. int (*try_run)(struct usbhs_pkt *pkt, int *is_done);
  56. int (*dma_done)(struct usbhs_pkt *pkt, int *is_done);
  57. };
  58. /*
  59. * fifo
  60. */
  61. int usbhs_fifo_probe(struct usbhs_priv *priv);
  62. void usbhs_fifo_remove(struct usbhs_priv *priv);
  63. void usbhs_fifo_init(struct usbhs_priv *priv);
  64. void usbhs_fifo_quit(struct usbhs_priv *priv);
  65. /*
  66. * packet info
  67. */
  68. enum {
  69. USBHSF_PKT_PREPARE,
  70. USBHSF_PKT_TRY_RUN,
  71. USBHSF_PKT_DMA_DONE,
  72. };
  73. extern struct usbhs_pkt_handle usbhs_fifo_pio_push_handler;
  74. extern struct usbhs_pkt_handle usbhs_fifo_pio_pop_handler;
  75. extern struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler;
  76. extern struct usbhs_pkt_handle usbhs_fifo_dma_push_handler;
  77. extern struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler;
  78. void usbhs_pkt_init(struct usbhs_pkt *pkt);
  79. void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
  80. struct usbhs_pkt_handle *handler,
  81. void *buf, int len, int zero);
  82. struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
  83. int __usbhs_pkt_handler(struct usbhs_pipe *pipe, int type);
  84. #define usbhs_pkt_start(p) __usbhs_pkt_handler(p, USBHSF_PKT_PREPARE)
  85. #define usbhs_pkt_run(p) __usbhs_pkt_handler(p, USBHSF_PKT_TRY_RUN)
  86. #define usbhs_pkt_dmadone(p) __usbhs_pkt_handler(p, USBHSF_PKT_DMA_DONE)
  87. #endif /* RENESAS_USB_FIFO_H */