1 // SPDX-License-Identifier: GPL-2.0
3 * xhci-dbc.h - xHCI debug capability early driver
5 * Copyright (C) 2016 Intel Corporation
7 * Author: Lu Baolu <baolu.lu@linux.intel.com>
10 #ifndef __LINUX_XHCI_DBC_H
11 #define __LINUX_XHCI_DBC_H
13 #include <linux/types.h>
14 #include <linux/usb/ch9.h>
17 * xHCI Debug Capability Register interfaces:
22 __le32 ersts; /* Event Ring Segment Table Size*/
23 __le32 __reserved_0; /* 0c~0f reserved bits */
24 __le64 erstba; /* Event Ring Segment Table Base Address */
25 __le64 erdp; /* Event Ring Dequeue Pointer */
28 __le32 portsc; /* Port status and control */
29 __le32 __reserved_1; /* 2b~28 reserved bits */
30 __le64 dccp; /* Debug Capability Context Pointer */
31 __le32 devinfo1; /* Device Descriptor Info Register 1 */
32 __le32 devinfo2; /* Device Descriptor Info Register 2 */
35 #define DEBUG_MAX_BURST(p) (((p) >> 16) & 0xff)
37 #define CTRL_DBC_RUN BIT(0)
38 #define CTRL_PORT_ENABLE BIT(1)
39 #define CTRL_HALT_OUT_TR BIT(2)
40 #define CTRL_HALT_IN_TR BIT(3)
41 #define CTRL_DBC_RUN_CHANGE BIT(4)
42 #define CTRL_DBC_ENABLE BIT(31)
44 #define DCST_DEBUG_PORT(p) (((p) >> 24) & 0xff)
46 #define PORTSC_CONN_STATUS BIT(0)
47 #define PORTSC_CONN_CHANGE BIT(17)
48 #define PORTSC_RESET_CHANGE BIT(21)
49 #define PORTSC_LINK_CHANGE BIT(22)
50 #define PORTSC_CONFIG_CHANGE BIT(23)
53 * xHCI Debug Capability data structures:
59 struct xdbc_erst_entry {
65 struct xdbc_info_context {
71 __le32 __reserved_0[7];
74 struct xdbc_ep_context {
79 __le32 __reserved_0[11];
83 struct xdbc_info_context info;
84 struct xdbc_ep_context out;
85 struct xdbc_ep_context in;
88 #define XDBC_INFO_CONTEXT_SIZE 48
89 #define XDBC_MAX_STRING_LENGTH 64
90 #define XDBC_STRING_MANUFACTURER "Linux Foundation"
91 #define XDBC_STRING_PRODUCT "Linux USB GDB Target"
92 #define XDBC_STRING_SERIAL "0001"
95 char string0[XDBC_MAX_STRING_LENGTH];
96 char manufacturer[XDBC_MAX_STRING_LENGTH];
97 char product[XDBC_MAX_STRING_LENGTH];
98 char serial[XDBC_MAX_STRING_LENGTH];
101 #define XDBC_PROTOCOL 1 /* GNU Remote Debug Command Set */
102 #define XDBC_VENDOR_ID 0x1d6b /* Linux Foundation 0x1d6b */
103 #define XDBC_PRODUCT_ID 0x0011 /* __le16 idProduct; device 0011 */
104 #define XDBC_DEVICE_REV 0x0010 /* 0.10 */
107 * xHCI Debug Capability software state structures:
109 struct xdbc_segment {
110 struct xdbc_trb *trbs;
114 #define XDBC_TRBS_PER_SEGMENT 256
117 struct xdbc_segment *segment;
118 struct xdbc_trb *enqueue;
119 struct xdbc_trb *dequeue;
123 #define XDBC_EPID_OUT 2
124 #define XDBC_EPID_IN 3
132 void __iomem *xhci_base;
137 /* DbC register base */
138 struct xdbc_regs __iomem *xdbc_reg;
141 dma_addr_t table_dma;
144 /* event ring segment table */
149 /* event ring segments */
150 struct xdbc_ring evt_ring;
151 struct xdbc_segment evt_seg;
153 /* debug capability contexts */
158 /* descriptor strings */
159 dma_addr_t string_dma;
163 /* bulk OUT endpoint */
164 struct xdbc_ring out_ring;
165 struct xdbc_segment out_seg;
169 /* bulk IN endpoint */
170 struct xdbc_ring in_ring;
171 struct xdbc_segment in_seg;
177 /* spinlock for early_xdbc_write() reentrancy */
181 #define XDBC_PCI_MAX_BUSES 256
182 #define XDBC_PCI_MAX_DEVICES 32
183 #define XDBC_PCI_MAX_FUNCTION 8
185 #define XDBC_TABLE_ENTRY_SIZE 64
186 #define XDBC_ERST_ENTRY_NUM 1
187 #define XDBC_DBCC_ENTRY_NUM 3
188 #define XDBC_STRING_ENTRY_NUM 4
190 /* Bits definitions for xdbc_state.flags: */
191 #define XDBC_FLAGS_INITIALIZED BIT(0)
192 #define XDBC_FLAGS_IN_STALL BIT(1)
193 #define XDBC_FLAGS_OUT_STALL BIT(2)
194 #define XDBC_FLAGS_IN_PROCESS BIT(3)
195 #define XDBC_FLAGS_OUT_PROCESS BIT(4)
196 #define XDBC_FLAGS_CONFIGURED BIT(5)
198 #define XDBC_MAX_PACKET 1024
200 /* Door bell target: */
201 #define OUT_EP_DOORBELL 0
202 #define IN_EP_DOORBELL 1
203 #define DOOR_BELL_TARGET(p) (((p) & 0xff) << 8)
205 #define xdbc_read64(regs) xhci_read_64(NULL, (regs))
206 #define xdbc_write64(val, regs) xhci_write_64(NULL, (val), (regs))
208 #endif /* __LINUX_XHCI_DBC_H */