fifo.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "pipe.h"
  20. struct usbhs_fifo {
  21. u32 port; /* xFIFO */
  22. u32 sel; /* xFIFOSEL */
  23. u32 ctr; /* xFIFOCTR */
  24. };
  25. struct usbhs_fifo_info {
  26. struct usbhs_fifo cfifo;
  27. };
  28. struct usbhs_pkt_handle;
  29. struct usbhs_pkt {
  30. struct list_head node;
  31. struct usbhs_pipe *pipe;
  32. struct usbhs_pkt_handle *handler;
  33. void *buf;
  34. int length;
  35. int actual;
  36. int zero;
  37. };
  38. struct usbhs_pkt_handle {
  39. int (*prepare)(struct usbhs_pkt *pkt, int *is_done);
  40. int (*try_run)(struct usbhs_pkt *pkt, int *is_done);
  41. };
  42. /*
  43. * fifo
  44. */
  45. int usbhs_fifo_probe(struct usbhs_priv *priv);
  46. void usbhs_fifo_remove(struct usbhs_priv *priv);
  47. void usbhs_fifo_init(struct usbhs_priv *priv);
  48. void usbhs_fifo_quit(struct usbhs_priv *priv);
  49. /*
  50. * packet info
  51. */
  52. enum {
  53. USBHSF_PKT_PREPARE,
  54. USBHSF_PKT_TRY_RUN,
  55. };
  56. extern struct usbhs_pkt_handle usbhs_fifo_push_handler;
  57. extern struct usbhs_pkt_handle usbhs_fifo_pop_handler;
  58. extern struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler;
  59. void usbhs_pkt_init(struct usbhs_pkt *pkt);
  60. void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
  61. struct usbhs_pkt_handle *handler,
  62. void *buf, int len, int zero);
  63. struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
  64. int __usbhs_pkt_handler(struct usbhs_pipe *pipe, int type);
  65. #define usbhs_pkt_start(p) __usbhs_pkt_handler(p, USBHSF_PKT_PREPARE)
  66. #define usbhs_pkt_run(p) __usbhs_pkt_handler(p, USBHSF_PKT_TRY_RUN)
  67. #endif /* RENESAS_USB_FIFO_H */