1 /* 2 * 3 * Copyright (C) 2015 Rockchip Electronics 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 */ 14 15 #ifndef __DWC2_PRIV_H__ 16 #define __DWC2_PRIV_H__ 17 #include <usb/dwc2_registers.h> 18 19 #define EP_MAXLEN (64 * 1024) 20 #define EP0_MAXLEN 64 21 22 #define RX_FIFO_SIZE 0x210 23 #define DTX_FIFO_SIZE_0_OFFSET RX_FIFO_SIZE 24 #define DTX_FIFO_SIZE_0 0x10 25 #define DTX_FIFO_SIZE_1_OFFSET (DTX_FIFO_SIZE_0_OFFSET +\ 26 DTX_FIFO_SIZE_0) 27 #define DTX_FIFO_SIZE_1 0x100 28 #define DTX_FIFO_SIZE_2_OFFSET (DTX_FIFO_SIZE_1_OFFSET +\ 29 DTX_FIFO_SIZE_1) 30 #define DTX_FIFO_SIZE_2 0x10 31 32 struct job { 33 SIMPLEQ_ENTRY(job) queue; // linkage 34 void *data; 35 size_t length; 36 size_t xfered_length; 37 size_t xfer_length; 38 int zlp; // append zero length packet? 39 int autofree; // free after processing? 40 }; 41 SIMPLEQ_HEAD(job_queue, job); 42 43 typedef struct dwc2_ep { 44 dwc2_ep_reg_t *ep_regs; 45 struct job_queue job_queue; 46 unsigned txfifo:5; 47 unsigned busy:1; 48 unsigned ep_num:8; 49 } dwc2_ep_t; 50 51 typedef struct dwc2_pdata { 52 dwc2_reg_t *regs; 53 dwc2_ep_t eps[MAX_EPS_CHANNELS][2]; 54 uint32_t fifo_map; 55 void *setup_buf; 56 } dwc2_pdata_t; 57 58 #define DWC2_PDATA(ctrl) ((dwc2_pdata_t *)((ctrl)->pdata)) 59 60 #endif 61