fifo.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_pkt_handle;
  21. struct usbhs_pkt {
  22. struct list_head node;
  23. struct usbhs_pipe *pipe;
  24. struct usbhs_pkt_handle *handler;
  25. void *buf;
  26. int length;
  27. int actual;
  28. int zero;
  29. };
  30. struct usbhs_pkt_handle {
  31. int (*prepare)(struct usbhs_pkt *pkt, int *is_done);
  32. int (*try_run)(struct usbhs_pkt *pkt, int *is_done);
  33. };
  34. /*
  35. * fifo
  36. */
  37. void usbhs_fifo_init(struct usbhs_priv *priv);
  38. void usbhs_fifo_quit(struct usbhs_priv *priv);
  39. /*
  40. * packet info
  41. */
  42. enum {
  43. USBHSF_PKT_PREPARE,
  44. USBHSF_PKT_TRY_RUN,
  45. };
  46. extern struct usbhs_pkt_handle usbhs_fifo_push_handler;
  47. extern struct usbhs_pkt_handle usbhs_fifo_pop_handler;
  48. extern struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler;
  49. void usbhs_pkt_init(struct usbhs_pkt *pkt);
  50. void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
  51. struct usbhs_pkt_handle *handler,
  52. void *buf, int len, int zero);
  53. struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
  54. int __usbhs_pkt_handler(struct usbhs_pipe *pipe, int type);
  55. #define usbhs_pkt_start(p) __usbhs_pkt_handler(p, USBHSF_PKT_PREPARE)
  56. #define usbhs_pkt_run(p) __usbhs_pkt_handler(p, USBHSF_PKT_TRY_RUN)
  57. #endif /* RENESAS_USB_FIFO_H */