1 /* include/linux/usb/dwc3.h
3 * Copyright (c) 2012 Samsung Electronics Co. Ltd
5 * Designware SuperSpeed USB 3.0 DRD Controller global and OTG registers
7 * SPDX-License-Identifier: GPL-2.0+
13 /* Global constants */
14 #define DWC3_ENDPOINTS_NUM 32
16 #define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE
17 #define DWC3_EVENT_TYPE_MASK 0xfe
19 #define DWC3_EVENT_TYPE_DEV 0
20 #define DWC3_EVENT_TYPE_CARKIT 3
21 #define DWC3_EVENT_TYPE_I2C 4
23 #define DWC3_DEVICE_EVENT_DISCONNECT 0
24 #define DWC3_DEVICE_EVENT_RESET 1
25 #define DWC3_DEVICE_EVENT_CONNECT_DONE 2
26 #define DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE 3
27 #define DWC3_DEVICE_EVENT_WAKEUP 4
28 #define DWC3_DEVICE_EVENT_EOPF 6
29 #define DWC3_DEVICE_EVENT_SOF 7
30 #define DWC3_DEVICE_EVENT_ERRATIC_ERROR 9
31 #define DWC3_DEVICE_EVENT_CMD_CMPL 10
32 #define DWC3_DEVICE_EVENT_OVERFLOW 11
34 #define DWC3_GEVNTCOUNT_MASK 0xfffc
35 #define DWC3_GSNPSID_MASK 0xffff0000
36 #define DWC3_GSNPSID_SHIFT 16
37 #define DWC3_GSNPSREV_MASK 0xffff
39 #define DWC3_REVISION_MASK 0xffff
41 #define DWC3_REG_OFFSET 0xC100
43 struct g_event_buffer {
50 struct d_physical_endpoint {
57 struct dwc3 { /* offset: 0xC100 */
100 u32 g_usb2phycfg[16];
101 u32 g_usb2i2cctl[16];
102 u32 g_usb2phyacc[16];
103 u32 g_usb3pipectl[16];
108 struct g_event_buffer g_evnt_buf[32];
131 struct d_physical_endpoint d_phy_ep_cmd[32];
156 /* Global Configuration Register */
157 #define DWC3_GCTL_PWRDNSCALE(n) ((n) << 19)
158 #define DWC3_GCTL_U2RSTECN (1 << 16)
159 #define DWC3_GCTL_RAMCLKSEL(x) \
160 (((x) & DWC3_GCTL_CLK_MASK) << 6)
161 #define DWC3_GCTL_CLK_BUS (0)
162 #define DWC3_GCTL_CLK_PIPE (1)
163 #define DWC3_GCTL_CLK_PIPEHALF (2)
164 #define DWC3_GCTL_CLK_MASK (3)
165 #define DWC3_GCTL_PRTCAP(n) (((n) & (3 << 12)) >> 12)
166 #define DWC3_GCTL_PRTCAPDIR(n) ((n) << 12)
167 #define DWC3_GCTL_PRTCAP_HOST 1
168 #define DWC3_GCTL_PRTCAP_DEVICE 2
169 #define DWC3_GCTL_PRTCAP_OTG 3
170 #define DWC3_GCTL_CORESOFTRESET (1 << 11)
171 #define DWC3_GCTL_SCALEDOWN(n) ((n) << 4)
172 #define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3)
173 #define DWC3_GCTL_DISSCRAMBLE (1 << 3)
174 #define DWC3_GCTL_DSBLCLKGTNG (1 << 0)
176 /* Global HWPARAMS1 Register */
177 #define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24)
178 #define DWC3_GHWPARAMS1_EN_PWROPT_NO 0
179 #define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1
181 /* Global USB2 PHY Configuration Register */
182 #define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31)
183 #define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6)
185 /* Global USB3 PIPE Control Register */
186 #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31)
187 #define DWC3_GUSB3PIPECTL_SUSPHY (1 << 17)
189 /* Global TX Fifo Size Register */
190 #define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff)
191 #define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000)
193 /* Device Control Register */
194 #define DWC3_DCTL_RUN_STOP (1 << 31)
195 #define DWC3_DCTL_CSFTRST (1 << 30)
196 #define DWC3_DCTL_LSFTRST (1 << 29)
198 /* Global Frame Length Adjustment Register */
199 #define GFLADJ_30MHZ_REG_SEL (1 << 7)
200 #define GFLADJ_30MHZ(n) ((n) & 0x3f)
201 #define GFLADJ_30MHZ_DEFAULT 0x20
203 #ifdef CONFIG_USB_XHCI_DWC3
204 void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode);
205 void dwc3_core_soft_reset(struct dwc3 *dwc3_reg);
206 int dwc3_core_init(struct dwc3 *dwc3_reg);
207 void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val);
209 #endif /* __DWC3_H_ */