Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-1.0+ */
0002 /*
0003  * Renesas USB driver
0004  *
0005  * Copyright (C) 2011 Renesas Solutions Corp.
0006  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
0007  */
0008 #ifndef RENESAS_USB_PIPE_H
0009 #define RENESAS_USB_PIPE_H
0010 
0011 #include "common.h"
0012 #include "fifo.h"
0013 
0014 /*
0015  *  struct
0016  */
0017 struct usbhs_pipe {
0018     u32 pipe_type;  /* USB_ENDPOINT_XFER_xxx */
0019 
0020     struct usbhs_priv *priv;
0021     struct usbhs_fifo *fifo;
0022     struct list_head list;
0023 
0024     int maxp;
0025 
0026     u32 flags;
0027 #define USBHS_PIPE_FLAGS_IS_USED        (1 << 0)
0028 #define USBHS_PIPE_FLAGS_IS_DIR_IN      (1 << 1)
0029 #define USBHS_PIPE_FLAGS_IS_DIR_HOST        (1 << 2)
0030 #define USBHS_PIPE_FLAGS_IS_RUNNING     (1 << 3)
0031 
0032     const struct usbhs_pkt_handle *handler;
0033 
0034     void *mod_private;
0035 };
0036 
0037 struct usbhs_pipe_info {
0038     struct usbhs_pipe *pipe;
0039     int size;   /* array size of "pipe" */
0040 
0041     int (*dma_map_ctrl)(struct device *dma_dev, struct usbhs_pkt *pkt,
0042                 int map);
0043 };
0044 
0045 /*
0046  * pipe list
0047  */
0048 #define __usbhs_for_each_pipe(start, pos, info, i)  \
0049     for ((i) = start;                       \
0050          ((i) < (info)->size) && ((pos) = (info)->pipe + (i));  \
0051          (i)++)
0052 
0053 #define usbhs_for_each_pipe(pos, priv, i)           \
0054     __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i)
0055 
0056 #define usbhs_for_each_pipe_with_dcp(pos, priv, i)      \
0057     __usbhs_for_each_pipe(0, pos, &((priv)->pipe_info), i)
0058 
0059 /*
0060  * data
0061  */
0062 #define usbhs_priv_to_pipeinfo(pr)  (&(pr)->pipe_info)
0063 
0064 /*
0065  * pipe control
0066  */
0067 char *usbhs_pipe_name(struct usbhs_pipe *pipe);
0068 struct usbhs_pipe
0069 *usbhs_pipe_malloc(struct usbhs_priv *priv, int endpoint_type, int dir_in);
0070 void usbhs_pipe_free(struct usbhs_pipe *pipe);
0071 int usbhs_pipe_probe(struct usbhs_priv *priv);
0072 void usbhs_pipe_remove(struct usbhs_priv *priv);
0073 int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe);
0074 int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe);
0075 int usbhs_pipe_is_running(struct usbhs_pipe *pipe);
0076 void usbhs_pipe_running(struct usbhs_pipe *pipe, int running);
0077 
0078 void usbhs_pipe_init(struct usbhs_priv *priv,
0079              int (*dma_map_ctrl)(struct device *dma_dev,
0080                      struct usbhs_pkt *pkt, int map));
0081 int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe);
0082 void usbhs_pipe_clear(struct usbhs_pipe *pipe);
0083 void usbhs_pipe_clear_without_sequence(struct usbhs_pipe *pipe,
0084                        int needs_bfre, int bfre_enable);
0085 int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe);
0086 bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe);
0087 void usbhs_pipe_enable(struct usbhs_pipe *pipe);
0088 void usbhs_pipe_disable(struct usbhs_pipe *pipe);
0089 void usbhs_pipe_stall(struct usbhs_pipe *pipe);
0090 int usbhs_pipe_is_stall(struct usbhs_pipe *pipe);
0091 void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len);
0092 void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo);
0093 void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel,
0094                   u16 epnum, u16 maxp);
0095 void usbhs_pipe_config_change_bfre(struct usbhs_pipe *pipe, int enable);
0096 
0097 #define usbhs_pipe_sequence_data0(pipe) usbhs_pipe_data_sequence(pipe, 0)
0098 #define usbhs_pipe_sequence_data1(pipe) usbhs_pipe_data_sequence(pipe, 1)
0099 void usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int data);
0100 
0101 #define usbhs_pipe_to_priv(p)   ((p)->priv)
0102 #define usbhs_pipe_number(p)    (int)((p) - (p)->priv->pipe_info.pipe)
0103 #define usbhs_pipe_is_dcp(p)    ((p)->priv->pipe_info.pipe == (p))
0104 #define usbhs_pipe_to_fifo(p)   ((p)->fifo)
0105 #define usbhs_pipe_is_busy(p)   usbhs_pipe_to_fifo(p)
0106 
0107 #define usbhs_pipe_type(p)      ((p)->pipe_type)
0108 #define usbhs_pipe_type_is(p, t)    ((p)->pipe_type == t)
0109 
0110 /*
0111  * dcp control
0112  */
0113 struct usbhs_pipe *usbhs_dcp_malloc(struct usbhs_priv *priv);
0114 void usbhs_dcp_control_transfer_done(struct usbhs_pipe *pipe);
0115 void usbhs_dcp_dir_for_host(struct usbhs_pipe *pipe, int dir_out);
0116 
0117 #endif /* RENESAS_USB_PIPE_H */