162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-1.0+ */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Renesas USB driver 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2011 Renesas Solutions Corp. 662306a36Sopenharmony_ci * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci#ifndef RENESAS_USB_PIPE_H 962306a36Sopenharmony_ci#define RENESAS_USB_PIPE_H 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include "common.h" 1262306a36Sopenharmony_ci#include "fifo.h" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* 1562306a36Sopenharmony_ci * struct 1662306a36Sopenharmony_ci */ 1762306a36Sopenharmony_cistruct usbhs_pipe { 1862306a36Sopenharmony_ci u32 pipe_type; /* USB_ENDPOINT_XFER_xxx */ 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci struct usbhs_priv *priv; 2162306a36Sopenharmony_ci struct usbhs_fifo *fifo; 2262306a36Sopenharmony_ci struct list_head list; 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci int maxp; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci u32 flags; 2762306a36Sopenharmony_ci#define USBHS_PIPE_FLAGS_IS_USED (1 << 0) 2862306a36Sopenharmony_ci#define USBHS_PIPE_FLAGS_IS_DIR_IN (1 << 1) 2962306a36Sopenharmony_ci#define USBHS_PIPE_FLAGS_IS_DIR_HOST (1 << 2) 3062306a36Sopenharmony_ci#define USBHS_PIPE_FLAGS_IS_RUNNING (1 << 3) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci const struct usbhs_pkt_handle *handler; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci void *mod_private; 3562306a36Sopenharmony_ci}; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistruct usbhs_pipe_info { 3862306a36Sopenharmony_ci struct usbhs_pipe *pipe; 3962306a36Sopenharmony_ci int size; /* array size of "pipe" */ 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci int (*dma_map_ctrl)(struct device *dma_dev, struct usbhs_pkt *pkt, 4262306a36Sopenharmony_ci int map); 4362306a36Sopenharmony_ci}; 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/* 4662306a36Sopenharmony_ci * pipe list 4762306a36Sopenharmony_ci */ 4862306a36Sopenharmony_ci#define __usbhs_for_each_pipe(start, pos, info, i) \ 4962306a36Sopenharmony_ci for ((i) = start; \ 5062306a36Sopenharmony_ci ((i) < (info)->size) && ((pos) = (info)->pipe + (i)); \ 5162306a36Sopenharmony_ci (i)++) 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci#define usbhs_for_each_pipe(pos, priv, i) \ 5462306a36Sopenharmony_ci __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i) 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#define usbhs_for_each_pipe_with_dcp(pos, priv, i) \ 5762306a36Sopenharmony_ci __usbhs_for_each_pipe(0, pos, &((priv)->pipe_info), i) 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* 6062306a36Sopenharmony_ci * data 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_ci#define usbhs_priv_to_pipeinfo(pr) (&(pr)->pipe_info) 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* 6562306a36Sopenharmony_ci * pipe control 6662306a36Sopenharmony_ci */ 6762306a36Sopenharmony_cichar *usbhs_pipe_name(struct usbhs_pipe *pipe); 6862306a36Sopenharmony_cistruct usbhs_pipe 6962306a36Sopenharmony_ci*usbhs_pipe_malloc(struct usbhs_priv *priv, int endpoint_type, int dir_in); 7062306a36Sopenharmony_civoid usbhs_pipe_free(struct usbhs_pipe *pipe); 7162306a36Sopenharmony_ciint usbhs_pipe_probe(struct usbhs_priv *priv); 7262306a36Sopenharmony_civoid usbhs_pipe_remove(struct usbhs_priv *priv); 7362306a36Sopenharmony_ciint usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe); 7462306a36Sopenharmony_ciint usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe); 7562306a36Sopenharmony_ciint usbhs_pipe_is_running(struct usbhs_pipe *pipe); 7662306a36Sopenharmony_civoid usbhs_pipe_running(struct usbhs_pipe *pipe, int running); 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_civoid usbhs_pipe_init(struct usbhs_priv *priv, 7962306a36Sopenharmony_ci int (*dma_map_ctrl)(struct device *dma_dev, 8062306a36Sopenharmony_ci struct usbhs_pkt *pkt, int map)); 8162306a36Sopenharmony_ciint usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe); 8262306a36Sopenharmony_civoid usbhs_pipe_clear(struct usbhs_pipe *pipe); 8362306a36Sopenharmony_civoid usbhs_pipe_clear_without_sequence(struct usbhs_pipe *pipe, 8462306a36Sopenharmony_ci int needs_bfre, int bfre_enable); 8562306a36Sopenharmony_ciint usbhs_pipe_is_accessible(struct usbhs_pipe *pipe); 8662306a36Sopenharmony_cibool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe); 8762306a36Sopenharmony_civoid usbhs_pipe_enable(struct usbhs_pipe *pipe); 8862306a36Sopenharmony_civoid usbhs_pipe_disable(struct usbhs_pipe *pipe); 8962306a36Sopenharmony_civoid usbhs_pipe_stall(struct usbhs_pipe *pipe); 9062306a36Sopenharmony_ciint usbhs_pipe_is_stall(struct usbhs_pipe *pipe); 9162306a36Sopenharmony_civoid usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len); 9262306a36Sopenharmony_civoid usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); 9362306a36Sopenharmony_civoid usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, 9462306a36Sopenharmony_ci u16 epnum, u16 maxp); 9562306a36Sopenharmony_civoid usbhs_pipe_config_change_bfre(struct usbhs_pipe *pipe, int enable); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#define usbhs_pipe_sequence_data0(pipe) usbhs_pipe_data_sequence(pipe, 0) 9862306a36Sopenharmony_ci#define usbhs_pipe_sequence_data1(pipe) usbhs_pipe_data_sequence(pipe, 1) 9962306a36Sopenharmony_civoid usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int data); 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci#define usbhs_pipe_to_priv(p) ((p)->priv) 10262306a36Sopenharmony_ci#define usbhs_pipe_number(p) (int)((p) - (p)->priv->pipe_info.pipe) 10362306a36Sopenharmony_ci#define usbhs_pipe_is_dcp(p) ((p)->priv->pipe_info.pipe == (p)) 10462306a36Sopenharmony_ci#define usbhs_pipe_to_fifo(p) ((p)->fifo) 10562306a36Sopenharmony_ci#define usbhs_pipe_is_busy(p) usbhs_pipe_to_fifo(p) 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci#define usbhs_pipe_type(p) ((p)->pipe_type) 10862306a36Sopenharmony_ci#define usbhs_pipe_type_is(p, t) ((p)->pipe_type == t) 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* 11162306a36Sopenharmony_ci * dcp control 11262306a36Sopenharmony_ci */ 11362306a36Sopenharmony_cistruct usbhs_pipe *usbhs_dcp_malloc(struct usbhs_priv *priv); 11462306a36Sopenharmony_civoid usbhs_dcp_control_transfer_done(struct usbhs_pipe *pipe); 11562306a36Sopenharmony_civoid usbhs_dcp_dir_for_host(struct usbhs_pipe *pipe, int dir_out); 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#endif /* RENESAS_USB_PIPE_H */ 118