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