blob: 04d000ae7bdcf47d93f14706e47730759dd3d5c9 [file] [log] [blame]
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +09001/*
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
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090020#include "pipe.h"
21
Kuninori Morimotod3af90a2011-06-06 14:18:44 +090022struct usbhs_fifo {
23 u32 port; /* xFIFO */
24 u32 sel; /* xFIFOSEL */
25 u32 ctr; /* xFIFOCTR */
26};
27
28struct usbhs_fifo_info {
29 struct usbhs_fifo cfifo;
30};
31
Kuninori Morimotodad67392011-06-06 14:18:28 +090032struct usbhs_pkt_handle;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090033struct usbhs_pkt {
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090034 struct list_head node;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090035 struct usbhs_pipe *pipe;
Kuninori Morimotodad67392011-06-06 14:18:28 +090036 struct usbhs_pkt_handle *handler;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090037 void *buf;
38 int length;
39 int actual;
Kuninori Morimoto659d4952011-06-06 14:18:23 +090040 int zero;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090041};
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090042
Kuninori Morimotodad67392011-06-06 14:18:28 +090043struct usbhs_pkt_handle {
Kuninori Morimoto97664a22011-06-06 14:18:38 +090044 int (*prepare)(struct usbhs_pkt *pkt, int *is_done);
45 int (*try_run)(struct usbhs_pkt *pkt, int *is_done);
Kuninori Morimotodad67392011-06-06 14:18:28 +090046};
47
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090048/*
49 * fifo
50 */
Kuninori Morimotod3af90a2011-06-06 14:18:44 +090051int usbhs_fifo_probe(struct usbhs_priv *priv);
52void usbhs_fifo_remove(struct usbhs_priv *priv);
Kuninori Morimotodad67392011-06-06 14:18:28 +090053void usbhs_fifo_init(struct usbhs_priv *priv);
54void usbhs_fifo_quit(struct usbhs_priv *priv);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090055
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090056/*
57 * packet info
58 */
Kuninori Morimoto97664a22011-06-06 14:18:38 +090059enum {
60 USBHSF_PKT_PREPARE,
61 USBHSF_PKT_TRY_RUN,
62};
63
Kuninori Morimotodad67392011-06-06 14:18:28 +090064extern struct usbhs_pkt_handle usbhs_fifo_push_handler;
65extern struct usbhs_pkt_handle usbhs_fifo_pop_handler;
66extern struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler;
67
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090068void usbhs_pkt_init(struct usbhs_pkt *pkt);
Kuninori Morimoto659d4952011-06-06 14:18:23 +090069void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
Kuninori Morimotodad67392011-06-06 14:18:28 +090070 struct usbhs_pkt_handle *handler,
Kuninori Morimoto659d4952011-06-06 14:18:23 +090071 void *buf, int len, int zero);
Kuninori Morimoto97664a22011-06-06 14:18:38 +090072struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
73int __usbhs_pkt_handler(struct usbhs_pipe *pipe, int type);
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090074
Kuninori Morimoto97664a22011-06-06 14:18:38 +090075#define usbhs_pkt_start(p) __usbhs_pkt_handler(p, USBHSF_PKT_PREPARE)
76#define usbhs_pkt_run(p) __usbhs_pkt_handler(p, USBHSF_PKT_TRY_RUN)
Kuninori Morimotodad67392011-06-06 14:18:28 +090077
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090078#endif /* RENESAS_USB_FIFO_H */