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