blob: 4292f8c9e1f7fa560e91219d567176014cd319fa [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 */
Kuninori Morimotod77e3f42011-06-06 14:18:50 +090026
27 struct usbhs_pipe *pipe;
Kuninori Morimotod3af90a2011-06-06 14:18:44 +090028};
29
30struct usbhs_fifo_info {
31 struct usbhs_fifo cfifo;
32};
33
Kuninori Morimotodad67392011-06-06 14:18:28 +090034struct usbhs_pkt_handle;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090035struct usbhs_pkt {
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090036 struct list_head node;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090037 struct usbhs_pipe *pipe;
Kuninori Morimotodad67392011-06-06 14:18:28 +090038 struct usbhs_pkt_handle *handler;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090039 void *buf;
40 int length;
41 int actual;
Kuninori Morimoto659d4952011-06-06 14:18:23 +090042 int zero;
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090043};
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090044
Kuninori Morimotodad67392011-06-06 14:18:28 +090045struct usbhs_pkt_handle {
Kuninori Morimoto97664a22011-06-06 14:18:38 +090046 int (*prepare)(struct usbhs_pkt *pkt, int *is_done);
47 int (*try_run)(struct usbhs_pkt *pkt, int *is_done);
Kuninori Morimotodad67392011-06-06 14:18:28 +090048};
49
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090050/*
51 * fifo
52 */
Kuninori Morimotod3af90a2011-06-06 14:18:44 +090053int usbhs_fifo_probe(struct usbhs_priv *priv);
54void usbhs_fifo_remove(struct usbhs_priv *priv);
Kuninori Morimotodad67392011-06-06 14:18:28 +090055void usbhs_fifo_init(struct usbhs_priv *priv);
56void usbhs_fifo_quit(struct usbhs_priv *priv);
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090057
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090058/*
59 * packet info
60 */
Kuninori Morimoto97664a22011-06-06 14:18:38 +090061enum {
62 USBHSF_PKT_PREPARE,
63 USBHSF_PKT_TRY_RUN,
64};
65
Kuninori Morimotodad67392011-06-06 14:18:28 +090066extern struct usbhs_pkt_handle usbhs_fifo_push_handler;
67extern struct usbhs_pkt_handle usbhs_fifo_pop_handler;
68extern struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler;
69
Kuninori Morimoto6acb95d2011-06-06 14:18:16 +090070void usbhs_pkt_init(struct usbhs_pkt *pkt);
Kuninori Morimoto659d4952011-06-06 14:18:23 +090071void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
Kuninori Morimotodad67392011-06-06 14:18:28 +090072 struct usbhs_pkt_handle *handler,
Kuninori Morimoto659d4952011-06-06 14:18:23 +090073 void *buf, int len, int zero);
Kuninori Morimoto97664a22011-06-06 14:18:38 +090074struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
75int __usbhs_pkt_handler(struct usbhs_pipe *pipe, int type);
Kuninori Morimoto4bd04812011-06-06 14:18:07 +090076
Kuninori Morimoto97664a22011-06-06 14:18:38 +090077#define usbhs_pkt_start(p) __usbhs_pkt_handler(p, USBHSF_PKT_PREPARE)
78#define usbhs_pkt_run(p) __usbhs_pkt_handler(p, USBHSF_PKT_TRY_RUN)
Kuninori Morimotodad67392011-06-06 14:18:28 +090079
Kuninori Morimotoe8d548d2011-06-06 14:18:03 +090080#endif /* RENESAS_USB_FIFO_H */