xref: /openbmc/linux/drivers/usb/host/xhci-debugfs.h (revision 89e33ea7)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * xhci-debugfs.h - xHCI debugfs interface
4  *
5  * Copyright (C) 2017 Intel Corporation
6  *
7  * Author: Lu Baolu <baolu.lu@linux.intel.com>
8  */
9 
10 #ifndef __LINUX_XHCI_DEBUGFS_H
11 #define __LINUX_XHCI_DEBUGFS_H
12 
13 #include <linux/debugfs.h>
14 
15 #define DEBUGFS_NAMELEN 32
16 
17 #define REG_CAPLENGTH					0x00
18 #define REG_HCSPARAMS1					0x04
19 #define REG_HCSPARAMS2					0x08
20 #define REG_HCSPARAMS3					0x0c
21 #define REG_HCCPARAMS1					0x10
22 #define REG_DOORBELLOFF					0x14
23 #define REG_RUNTIMEOFF					0x18
24 #define REG_HCCPARAMS2					0x1c
25 
26 #define	REG_USBCMD					0x00
27 #define REG_USBSTS					0x04
28 #define REG_PAGESIZE					0x08
29 #define REG_DNCTRL					0x14
30 #define REG_CRCR					0x18
31 #define REG_DCBAAP_LOW					0x30
32 #define REG_DCBAAP_HIGH					0x34
33 #define REG_CONFIG					0x38
34 
35 #define REG_MFINDEX					0x00
36 #define REG_IR0_IMAN					0x20
37 #define REG_IR0_IMOD					0x24
38 #define REG_IR0_ERSTSZ					0x28
39 #define REG_IR0_ERSTBA_LOW				0x30
40 #define REG_IR0_ERSTBA_HIGH				0x34
41 #define REG_IR0_ERDP_LOW				0x38
42 #define REG_IR0_ERDP_HIGH				0x3c
43 
44 #define REG_EXTCAP_USBLEGSUP				0x00
45 #define REG_EXTCAP_USBLEGCTLSTS				0x04
46 
47 #define REG_EXTCAP_REVISION				0x00
48 #define REG_EXTCAP_NAME					0x04
49 #define REG_EXTCAP_PORTINFO				0x08
50 #define REG_EXTCAP_PORTTYPE				0x0c
51 #define REG_EXTCAP_MANTISSA1				0x10
52 #define REG_EXTCAP_MANTISSA2				0x14
53 #define REG_EXTCAP_MANTISSA3				0x18
54 #define REG_EXTCAP_MANTISSA4				0x1c
55 #define REG_EXTCAP_MANTISSA5				0x20
56 #define REG_EXTCAP_MANTISSA6				0x24
57 
58 #define REG_EXTCAP_DBC_CAPABILITY			0x00
59 #define REG_EXTCAP_DBC_DOORBELL				0x04
60 #define REG_EXTCAP_DBC_ERSTSIZE				0x08
61 #define REG_EXTCAP_DBC_ERST_LOW				0x10
62 #define REG_EXTCAP_DBC_ERST_HIGH			0x14
63 #define REG_EXTCAP_DBC_ERDP_LOW				0x18
64 #define REG_EXTCAP_DBC_ERDP_HIGH			0x1c
65 #define REG_EXTCAP_DBC_CONTROL				0x20
66 #define REG_EXTCAP_DBC_STATUS				0x24
67 #define REG_EXTCAP_DBC_PORTSC				0x28
68 #define REG_EXTCAP_DBC_CONT_LOW				0x30
69 #define REG_EXTCAP_DBC_CONT_HIGH			0x34
70 #define REG_EXTCAP_DBC_DEVINFO1				0x38
71 #define REG_EXTCAP_DBC_DEVINFO2				0x3c
72 
73 #define dump_register(nm)				\
74 {							\
75 	.name	= __stringify(nm),			\
76 	.offset	= REG_ ##nm,				\
77 }
78 
79 struct xhci_regset {
80 	char			name[DEBUGFS_NAMELEN];
81 	struct debugfs_regset32	regset;
82 	size_t			nregs;
83 	struct list_head	list;
84 };
85 
86 struct xhci_file_map {
87 	const char		*name;
88 	int			(*show)(struct seq_file *s, void *unused);
89 };
90 
91 struct xhci_ep_priv {
92 	char			name[DEBUGFS_NAMELEN];
93 	struct dentry		*root;
94 };
95 
96 struct xhci_slot_priv {
97 	char			name[DEBUGFS_NAMELEN];
98 	struct dentry		*root;
99 	struct xhci_ep_priv	*eps[31];
100 	struct xhci_virt_device	*dev;
101 };
102 
103 #ifdef CONFIG_DEBUG_FS
104 void xhci_debugfs_init(struct xhci_hcd *xhci);
105 void xhci_debugfs_exit(struct xhci_hcd *xhci);
106 void __init xhci_debugfs_create_root(void);
107 void __exit xhci_debugfs_remove_root(void);
108 void xhci_debugfs_create_slot(struct xhci_hcd *xhci, int slot_id);
109 void xhci_debugfs_remove_slot(struct xhci_hcd *xhci, int slot_id);
110 void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
111 				  struct xhci_virt_device *virt_dev,
112 				  int ep_index);
113 void xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
114 				  struct xhci_virt_device *virt_dev,
115 				  int ep_index);
116 #else
117 static inline void xhci_debugfs_init(struct xhci_hcd *xhci) { }
118 static inline void xhci_debugfs_exit(struct xhci_hcd *xhci) { }
119 static inline void __init xhci_debugfs_create_root(void) { }
120 static inline void __exit xhci_debugfs_remove_root(void) { }
121 static inline void xhci_debugfs_create_slot(struct xhci_hcd *x, int s) { }
122 static inline void xhci_debugfs_remove_slot(struct xhci_hcd *x, int s) { }
123 static inline void
124 xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
125 			     struct xhci_virt_device *virt_dev,
126 			     int ep_index) { }
127 static inline void
128 xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
129 			     struct xhci_virt_device *virt_dev,
130 			     int ep_index) { }
131 #endif /* CONFIG_DEBUG_FS */
132 
133 #endif /* __LINUX_XHCI_DEBUGFS_H */
134