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_FIFO_H 98c2ecf20Sopenharmony_ci#define RENESAS_USB_FIFO_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 128c2ecf20Sopenharmony_ci#include <linux/sh_dma.h> 138c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 148c2ecf20Sopenharmony_ci#include <asm/dma.h> 158c2ecf20Sopenharmony_ci#include "pipe.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct usbhs_fifo { 188c2ecf20Sopenharmony_ci char *name; 198c2ecf20Sopenharmony_ci u32 port; /* xFIFO */ 208c2ecf20Sopenharmony_ci u32 sel; /* xFIFOSEL */ 218c2ecf20Sopenharmony_ci u32 ctr; /* xFIFOCTR */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci struct usbhs_pipe *pipe; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci struct dma_chan *tx_chan; 268c2ecf20Sopenharmony_ci struct dma_chan *rx_chan; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci struct sh_dmae_slave tx_slave; 298c2ecf20Sopenharmony_ci struct sh_dmae_slave rx_slave; 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define USBHS_MAX_NUM_DFIFO 4 338c2ecf20Sopenharmony_cistruct usbhs_fifo_info { 348c2ecf20Sopenharmony_ci struct usbhs_fifo cfifo; 358c2ecf20Sopenharmony_ci struct usbhs_fifo dfifo[USBHS_MAX_NUM_DFIFO]; 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci#define usbhsf_get_dnfifo(p, n) (&((p)->fifo_info.dfifo[n])) 388c2ecf20Sopenharmony_ci#define usbhs_for_each_dfifo(priv, dfifo, i) \ 398c2ecf20Sopenharmony_ci for ((i) = 0; \ 408c2ecf20Sopenharmony_ci ((i) < USBHS_MAX_NUM_DFIFO) && \ 418c2ecf20Sopenharmony_ci ((dfifo) = usbhsf_get_dnfifo(priv, (i))); \ 428c2ecf20Sopenharmony_ci (i)++) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistruct usbhs_pkt_handle; 458c2ecf20Sopenharmony_cistruct usbhs_pkt { 468c2ecf20Sopenharmony_ci struct list_head node; 478c2ecf20Sopenharmony_ci struct usbhs_pipe *pipe; 488c2ecf20Sopenharmony_ci const struct usbhs_pkt_handle *handler; 498c2ecf20Sopenharmony_ci void (*done)(struct usbhs_priv *priv, 508c2ecf20Sopenharmony_ci struct usbhs_pkt *pkt); 518c2ecf20Sopenharmony_ci struct work_struct work; 528c2ecf20Sopenharmony_ci dma_addr_t dma; 538c2ecf20Sopenharmony_ci const struct dmaengine_result *dma_result; 548c2ecf20Sopenharmony_ci void *buf; 558c2ecf20Sopenharmony_ci int length; 568c2ecf20Sopenharmony_ci int trans; 578c2ecf20Sopenharmony_ci int actual; 588c2ecf20Sopenharmony_ci int zero; 598c2ecf20Sopenharmony_ci int sequence; 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistruct usbhs_pkt_handle { 638c2ecf20Sopenharmony_ci int (*prepare)(struct usbhs_pkt *pkt, int *is_done); 648c2ecf20Sopenharmony_ci int (*try_run)(struct usbhs_pkt *pkt, int *is_done); 658c2ecf20Sopenharmony_ci int (*dma_done)(struct usbhs_pkt *pkt, int *is_done); 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* 698c2ecf20Sopenharmony_ci * fifo 708c2ecf20Sopenharmony_ci */ 718c2ecf20Sopenharmony_ciint usbhs_fifo_probe(struct usbhs_priv *priv); 728c2ecf20Sopenharmony_civoid usbhs_fifo_remove(struct usbhs_priv *priv); 738c2ecf20Sopenharmony_civoid usbhs_fifo_init(struct usbhs_priv *priv); 748c2ecf20Sopenharmony_civoid usbhs_fifo_quit(struct usbhs_priv *priv); 758c2ecf20Sopenharmony_civoid usbhs_fifo_clear_dcp(struct usbhs_pipe *pipe); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* 788c2ecf20Sopenharmony_ci * packet info 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_fifo_pio_push_handler; 818c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_fifo_pio_pop_handler; 828c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_ctrl_stage_end_handler; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_fifo_dma_push_handler; 858c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_dcp_status_stage_in_handler; 888c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_dcp_status_stage_out_handler; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_dcp_data_stage_in_handler; 918c2ecf20Sopenharmony_ciextern const struct usbhs_pkt_handle usbhs_dcp_data_stage_out_handler; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_civoid usbhs_pkt_init(struct usbhs_pkt *pkt); 948c2ecf20Sopenharmony_civoid usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, 958c2ecf20Sopenharmony_ci void (*done)(struct usbhs_priv *priv, 968c2ecf20Sopenharmony_ci struct usbhs_pkt *pkt), 978c2ecf20Sopenharmony_ci void *buf, int len, int zero, int sequence); 988c2ecf20Sopenharmony_cistruct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt); 998c2ecf20Sopenharmony_civoid usbhs_pkt_start(struct usbhs_pipe *pipe); 1008c2ecf20Sopenharmony_cistruct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe); 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#endif /* RENESAS_USB_FIFO_H */ 103