fifo.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. void (*done)(struct usbhs_priv *priv,
  47. struct usbhs_pkt *pkt);
  48. dma_addr_t dma;
  49. void *buf;
  50. int length;
  51. int trans;
  52. int actual;
  53. int zero;
  54. int sequence;
  55. };
  56. struct usbhs_pkt_handle {
  57. int (*prepare)(struct usbhs_pkt *pkt, int *is_done);
  58. int (*try_run)(struct usbhs_pkt *pkt, int *is_done);
  59. int (*dma_done)(struct usbhs_pkt *pkt, int *is_done);
  60. };
  61. /*
  62. * fifo
  63. */
  64. int usbhs_fifo_probe(struct usbhs_priv *priv);
  65. void usbhs_fifo_remove(struct usbhs_priv *priv);
  66. void usbhs_fifo_init(struct usbhs_priv *priv);
  67. void usbhs_fifo_quit(struct usbhs_priv *priv);
  68. /*
  69. * packet info
  70. */
  71. extern struct usbhs_pkt_handle usbhs_fifo_pio_push_handler;
  72. extern struct usbhs_pkt_handle usbhs_fifo_pio_pop_handler;
  73. extern struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler;
  74. extern struct usbhs_pkt_handle usbhs_fifo_dma_push_handler;
  75. extern struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler;
  76. extern struct usbhs_pkt_handle usbhs_dcp_status_stage_in_handler;
  77. extern struct usbhs_pkt_handle usbhs_dcp_status_stage_out_handler;
  78. extern struct usbhs_pkt_handle usbhs_dcp_data_stage_in_handler;
  79. extern struct usbhs_pkt_handle usbhs_dcp_data_stage_out_handler;
  80. void usbhs_pkt_init(struct usbhs_pkt *pkt);
  81. void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
  82. void (*done)(struct usbhs_priv *priv,
  83. struct usbhs_pkt *pkt),
  84. void *buf, int len, int zero, int sequence);
  85. struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
  86. void usbhs_pkt_start(struct usbhs_pipe *pipe);
  87. #endif /* RENESAS_USB_FIFO_H */