pipe.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_PIPE_H
  18. #define RENESAS_USB_PIPE_H
  19. #include "./common.h"
  20. /*
  21. * struct
  22. */
  23. struct usbhs_pipe {
  24. u32 pipe_type; /* USB_ENDPOINT_XFER_xxx */
  25. struct usbhs_priv *priv;
  26. u32 flags;
  27. #define USBHS_PIPE_FLAGS_IS_USED (1 << 0)
  28. #define USBHS_PIPE_FLAGS_IS_DIR_IN (1 << 1)
  29. void *mod_private;
  30. };
  31. struct usbhs_pipe_info {
  32. struct usbhs_pipe *pipe;
  33. int size; /* array size of "pipe" */
  34. int bufnmb_last; /* FIXME : driver needs good allocator */
  35. };
  36. /*
  37. * pipe list
  38. */
  39. #define __usbhs_for_each_pipe(start, pos, info, i) \
  40. for (i = start, pos = (info)->pipe; \
  41. i < (info)->size; \
  42. i++, pos = (info)->pipe + i)
  43. #define usbhs_for_each_pipe(pos, priv, i) \
  44. __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i)
  45. #define usbhs_for_each_pipe_with_dcp(pos, priv, i) \
  46. __usbhs_for_each_pipe(0, pos, &((priv)->pipe_info), i)
  47. /*
  48. * pipe module probe / remove
  49. */
  50. int usbhs_pipe_probe(struct usbhs_priv *priv);
  51. void usbhs_pipe_remove(struct usbhs_priv *priv);
  52. /*
  53. * cfifo
  54. */
  55. int usbhs_fifo_write(struct usbhs_pipe *pipe, u8 *buf, int len);
  56. int usbhs_fifo_read(struct usbhs_pipe *pipe, u8 *buf, int len);
  57. int usbhs_fifo_prepare_write(struct usbhs_pipe *pipe);
  58. int usbhs_fifo_prepare_read(struct usbhs_pipe *pipe);
  59. void usbhs_fifo_enable(struct usbhs_pipe *pipe);
  60. void usbhs_fifo_disable(struct usbhs_pipe *pipe);
  61. void usbhs_fifo_stall(struct usbhs_pipe *pipe);
  62. void usbhs_fifo_send_terminator(struct usbhs_pipe *pipe);
  63. /*
  64. * usb request
  65. */
  66. void usbhs_usbreq_get_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req);
  67. void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req);
  68. /*
  69. * pipe control
  70. */
  71. struct usbhs_pipe
  72. *usbhs_pipe_malloc(struct usbhs_priv *priv,
  73. const struct usb_endpoint_descriptor *desc);
  74. int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe);
  75. void usbhs_pipe_init(struct usbhs_priv *priv);
  76. int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe);
  77. void usbhs_pipe_clear_sequence(struct usbhs_pipe *pipe);
  78. #define usbhs_pipe_number(p) (int)((p) - (p)->priv->pipe_info.pipe)
  79. /*
  80. * dcp control
  81. */
  82. struct usbhs_pipe *usbhs_dcp_malloc(struct usbhs_priv *priv);
  83. void usbhs_dcp_control_transfer_done(struct usbhs_pipe *pipe);
  84. #endif /* RENESAS_USB_PIPE_H */