fifo.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 <linux/workqueue.h>
  22. #include <asm/dma.h>
  23. #include "pipe.h"
  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 dma_chan *tx_chan;
  31. struct dma_chan *rx_chan;
  32. struct sh_dmae_slave tx_slave;
  33. struct sh_dmae_slave rx_slave;
  34. };
  35. #define USBHS_MAX_NUM_DFIFO 4
  36. struct usbhs_fifo_info {
  37. struct usbhs_fifo cfifo;
  38. struct usbhs_fifo dfifo[USBHS_MAX_NUM_DFIFO];
  39. };
  40. #define usbhsf_get_dnfifo(p, n) (&((p)->fifo_info.dfifo[n]))
  41. #define usbhs_for_each_dfifo(priv, dfifo, i) \
  42. for ((i) = 0; \
  43. ((i) < USBHS_MAX_NUM_DFIFO) && \
  44. ((dfifo) = usbhsf_get_dnfifo(priv, (i))); \
  45. (i)++)
  46. struct usbhs_pkt_handle;
  47. struct usbhs_pkt {
  48. struct list_head node;
  49. struct usbhs_pipe *pipe;
  50. struct usbhs_pkt_handle *handler;
  51. void (*done)(struct usbhs_priv *priv,
  52. struct usbhs_pkt *pkt);
  53. struct work_struct work;
  54. dma_addr_t dma;
  55. dma_cookie_t cookie;
  56. void *buf;
  57. int length;
  58. int trans;
  59. int actual;
  60. int zero;
  61. int sequence;
  62. };
  63. struct usbhs_pkt_handle {
  64. int (*prepare)(struct usbhs_pkt *pkt, int *is_done);
  65. int (*try_run)(struct usbhs_pkt *pkt, int *is_done);
  66. int (*dma_done)(struct usbhs_pkt *pkt, int *is_done);
  67. };
  68. /*
  69. * fifo
  70. */
  71. int usbhs_fifo_probe(struct usbhs_priv *priv);
  72. void usbhs_fifo_remove(struct usbhs_priv *priv);
  73. void usbhs_fifo_init(struct usbhs_priv *priv);
  74. void usbhs_fifo_quit(struct usbhs_priv *priv);
  75. void usbhs_fifo_clear_dcp(struct usbhs_pipe *pipe);
  76. /*
  77. * packet info
  78. */
  79. extern struct usbhs_pkt_handle usbhs_fifo_pio_push_handler;
  80. extern struct usbhs_pkt_handle usbhs_fifo_pio_pop_handler;
  81. extern struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler;
  82. extern struct usbhs_pkt_handle usbhs_fifo_dma_push_handler;
  83. extern struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler;
  84. extern struct usbhs_pkt_handle usbhs_dcp_status_stage_in_handler;
  85. extern struct usbhs_pkt_handle usbhs_dcp_status_stage_out_handler;
  86. extern struct usbhs_pkt_handle usbhs_dcp_data_stage_in_handler;
  87. extern struct usbhs_pkt_handle usbhs_dcp_data_stage_out_handler;
  88. void usbhs_pkt_init(struct usbhs_pkt *pkt);
  89. void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
  90. void (*done)(struct usbhs_priv *priv,
  91. struct usbhs_pkt *pkt),
  92. void *buf, int len, int zero, int sequence);
  93. struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
  94. void usbhs_pkt_start(struct usbhs_pipe *pipe);
  95. #endif /* RENESAS_USB_FIFO_H */