0001
0002
0003
0004
0005
0006
0007
0008 #ifndef RENESAS_USB_FIFO_H
0009 #define RENESAS_USB_FIFO_H
0010
0011 #include <linux/interrupt.h>
0012 #include <linux/sh_dma.h>
0013 #include <linux/workqueue.h>
0014 #include <asm/dma.h>
0015 #include "pipe.h"
0016
0017 struct usbhs_fifo {
0018 char *name;
0019 u32 port;
0020 u32 sel;
0021 u32 ctr;
0022
0023 struct usbhs_pipe *pipe;
0024
0025 struct dma_chan *tx_chan;
0026 struct dma_chan *rx_chan;
0027
0028 struct sh_dmae_slave tx_slave;
0029 struct sh_dmae_slave rx_slave;
0030 };
0031
0032 #define USBHS_MAX_NUM_DFIFO 4
0033 struct usbhs_fifo_info {
0034 struct usbhs_fifo cfifo;
0035 struct usbhs_fifo dfifo[USBHS_MAX_NUM_DFIFO];
0036 };
0037 #define usbhsf_get_dnfifo(p, n) (&((p)->fifo_info.dfifo[n]))
0038 #define usbhs_for_each_dfifo(priv, dfifo, i) \
0039 for ((i) = 0; \
0040 ((i) < USBHS_MAX_NUM_DFIFO) && \
0041 ((dfifo) = usbhsf_get_dnfifo(priv, (i))); \
0042 (i)++)
0043
0044 struct usbhs_pkt_handle;
0045 struct usbhs_pkt {
0046 struct list_head node;
0047 struct usbhs_pipe *pipe;
0048 const struct usbhs_pkt_handle *handler;
0049 void (*done)(struct usbhs_priv *priv,
0050 struct usbhs_pkt *pkt);
0051 struct work_struct work;
0052 dma_addr_t dma;
0053 const struct dmaengine_result *dma_result;
0054 void *buf;
0055 int length;
0056 int trans;
0057 int actual;
0058 int zero;
0059 int sequence;
0060 };
0061
0062 struct usbhs_pkt_handle {
0063 int (*prepare)(struct usbhs_pkt *pkt, int *is_done);
0064 int (*try_run)(struct usbhs_pkt *pkt, int *is_done);
0065 int (*dma_done)(struct usbhs_pkt *pkt, int *is_done);
0066 };
0067
0068
0069
0070
0071 int usbhs_fifo_probe(struct usbhs_priv *priv);
0072 void usbhs_fifo_remove(struct usbhs_priv *priv);
0073 void usbhs_fifo_init(struct usbhs_priv *priv);
0074 void usbhs_fifo_quit(struct usbhs_priv *priv);
0075 void usbhs_fifo_clear_dcp(struct usbhs_pipe *pipe);
0076
0077
0078
0079
0080 extern const struct usbhs_pkt_handle usbhs_fifo_pio_push_handler;
0081 extern const struct usbhs_pkt_handle usbhs_fifo_pio_pop_handler;
0082 extern const struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler;
0083
0084 extern const struct usbhs_pkt_handle usbhs_fifo_dma_push_handler;
0085 extern const struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler;
0086
0087 extern const struct usbhs_pkt_handle usbhs_dcp_status_stage_in_handler;
0088 extern const struct usbhs_pkt_handle usbhs_dcp_status_stage_out_handler;
0089
0090 extern const struct usbhs_pkt_handle usbhs_dcp_data_stage_in_handler;
0091 extern const struct usbhs_pkt_handle usbhs_dcp_data_stage_out_handler;
0092
0093 void usbhs_pkt_init(struct usbhs_pkt *pkt);
0094 void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt,
0095 void (*done)(struct usbhs_priv *priv,
0096 struct usbhs_pkt *pkt),
0097 void *buf, int len, int zero, int sequence);
0098 struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
0099 void usbhs_pkt_start(struct usbhs_pipe *pipe);
0100 struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe);
0101
0102 #endif