18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-1.0+ */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Renesas USB driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2011 Renesas Solutions Corp. 68c2ecf20Sopenharmony_ci * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#ifndef RENESAS_USB_PIPE_H 98c2ecf20Sopenharmony_ci#define RENESAS_USB_PIPE_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include "common.h" 128c2ecf20Sopenharmony_ci#include "fifo.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * struct 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_cistruct usbhs_pipe { 188c2ecf20Sopenharmony_ci u32 pipe_type; /* USB_ENDPOINT_XFER_xxx */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci struct usbhs_priv *priv; 218c2ecf20Sopenharmony_ci struct usbhs_fifo *fifo; 228c2ecf20Sopenharmony_ci struct list_head list; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci int maxp; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci u32 flags; 278c2ecf20Sopenharmony_ci#define USBHS_PIPE_FLAGS_IS_USED (1 << 0) 288c2ecf20Sopenharmony_ci#define USBHS_PIPE_FLAGS_IS_DIR_IN (1 << 1) 298c2ecf20Sopenharmony_ci#define USBHS_PIPE_FLAGS_IS_DIR_HOST (1 << 2) 308c2ecf20Sopenharmony_ci#define USBHS_PIPE_FLAGS_IS_RUNNING (1 << 3) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci const struct usbhs_pkt_handle *handler; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci void *mod_private; 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistruct usbhs_pipe_info { 388c2ecf20Sopenharmony_ci struct usbhs_pipe *pipe; 398c2ecf20Sopenharmony_ci int size; /* array size of "pipe" */ 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci int (*dma_map_ctrl)(struct device *dma_dev, struct usbhs_pkt *pkt, 428c2ecf20Sopenharmony_ci int map); 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * pipe list 478c2ecf20Sopenharmony_ci */ 488c2ecf20Sopenharmony_ci#define __usbhs_for_each_pipe(start, pos, info, i) \ 498c2ecf20Sopenharmony_ci for ((i) = start; \ 508c2ecf20Sopenharmony_ci ((i) < (info)->size) && ((pos) = (info)->pipe + (i)); \ 518c2ecf20Sopenharmony_ci (i)++) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define usbhs_for_each_pipe(pos, priv, i) \ 548c2ecf20Sopenharmony_ci __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define usbhs_for_each_pipe_with_dcp(pos, priv, i) \ 578c2ecf20Sopenharmony_ci __usbhs_for_each_pipe(0, pos, &((priv)->pipe_info), i) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci/* 608c2ecf20Sopenharmony_ci * data 618c2ecf20Sopenharmony_ci */ 628c2ecf20Sopenharmony_ci#define usbhs_priv_to_pipeinfo(pr) (&(pr)->pipe_info) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* 658c2ecf20Sopenharmony_ci * pipe control 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_cichar *usbhs_pipe_name(struct usbhs_pipe *pipe); 688c2ecf20Sopenharmony_cistruct usbhs_pipe 698c2ecf20Sopenharmony_ci*usbhs_pipe_malloc(struct usbhs_priv *priv, int endpoint_type, int dir_in); 708c2ecf20Sopenharmony_civoid usbhs_pipe_free(struct usbhs_pipe *pipe); 718c2ecf20Sopenharmony_ciint usbhs_pipe_probe(struct usbhs_priv *priv); 728c2ecf20Sopenharmony_civoid usbhs_pipe_remove(struct usbhs_priv *priv); 738c2ecf20Sopenharmony_ciint usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe); 748c2ecf20Sopenharmony_ciint usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe); 758c2ecf20Sopenharmony_ciint usbhs_pipe_is_running(struct usbhs_pipe *pipe); 768c2ecf20Sopenharmony_civoid usbhs_pipe_running(struct usbhs_pipe *pipe, int running); 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_civoid usbhs_pipe_init(struct usbhs_priv *priv, 798c2ecf20Sopenharmony_ci int (*dma_map_ctrl)(struct device *dma_dev, 808c2ecf20Sopenharmony_ci struct usbhs_pkt *pkt, int map)); 818c2ecf20Sopenharmony_ciint usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe); 828c2ecf20Sopenharmony_civoid usbhs_pipe_clear(struct usbhs_pipe *pipe); 838c2ecf20Sopenharmony_civoid usbhs_pipe_clear_without_sequence(struct usbhs_pipe *pipe, 848c2ecf20Sopenharmony_ci int needs_bfre, int bfre_enable); 858c2ecf20Sopenharmony_ciint usbhs_pipe_is_accessible(struct usbhs_pipe *pipe); 868c2ecf20Sopenharmony_cibool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe); 878c2ecf20Sopenharmony_civoid usbhs_pipe_enable(struct usbhs_pipe *pipe); 888c2ecf20Sopenharmony_civoid usbhs_pipe_disable(struct usbhs_pipe *pipe); 898c2ecf20Sopenharmony_civoid usbhs_pipe_stall(struct usbhs_pipe *pipe); 908c2ecf20Sopenharmony_ciint usbhs_pipe_is_stall(struct usbhs_pipe *pipe); 918c2ecf20Sopenharmony_civoid usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len); 928c2ecf20Sopenharmony_civoid usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); 938c2ecf20Sopenharmony_civoid usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, 948c2ecf20Sopenharmony_ci u16 epnum, u16 maxp); 958c2ecf20Sopenharmony_civoid usbhs_pipe_config_change_bfre(struct usbhs_pipe *pipe, int enable); 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define usbhs_pipe_sequence_data0(pipe) usbhs_pipe_data_sequence(pipe, 0) 988c2ecf20Sopenharmony_ci#define usbhs_pipe_sequence_data1(pipe) usbhs_pipe_data_sequence(pipe, 1) 998c2ecf20Sopenharmony_civoid usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int data); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#define usbhs_pipe_to_priv(p) ((p)->priv) 1028c2ecf20Sopenharmony_ci#define usbhs_pipe_number(p) (int)((p) - (p)->priv->pipe_info.pipe) 1038c2ecf20Sopenharmony_ci#define usbhs_pipe_is_dcp(p) ((p)->priv->pipe_info.pipe == (p)) 1048c2ecf20Sopenharmony_ci#define usbhs_pipe_to_fifo(p) ((p)->fifo) 1058c2ecf20Sopenharmony_ci#define usbhs_pipe_is_busy(p) usbhs_pipe_to_fifo(p) 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define usbhs_pipe_type(p) ((p)->pipe_type) 1088c2ecf20Sopenharmony_ci#define usbhs_pipe_type_is(p, t) ((p)->pipe_type == t) 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci/* 1118c2ecf20Sopenharmony_ci * dcp control 1128c2ecf20Sopenharmony_ci */ 1138c2ecf20Sopenharmony_cistruct usbhs_pipe *usbhs_dcp_malloc(struct usbhs_priv *priv); 1148c2ecf20Sopenharmony_civoid usbhs_dcp_control_transfer_done(struct usbhs_pipe *pipe); 1158c2ecf20Sopenharmony_civoid usbhs_dcp_dir_for_host(struct usbhs_pipe *pipe, int dir_out); 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci#endif /* RENESAS_USB_PIPE_H */ 118