xref: /openbmc/linux/drivers/usb/host/xhci-debugfs.h (revision 673d7468)
13e45ed3cSNishad Kamdar /* SPDX-License-Identifier: GPL-2.0 */
202b6fdc2SLu Baolu /*
302b6fdc2SLu Baolu  * xhci-debugfs.h - xHCI debugfs interface
402b6fdc2SLu Baolu  *
502b6fdc2SLu Baolu  * Copyright (C) 2017 Intel Corporation
602b6fdc2SLu Baolu  *
702b6fdc2SLu Baolu  * Author: Lu Baolu <baolu.lu@linux.intel.com>
802b6fdc2SLu Baolu  */
902b6fdc2SLu Baolu 
1002b6fdc2SLu Baolu #ifndef __LINUX_XHCI_DEBUGFS_H
1102b6fdc2SLu Baolu #define __LINUX_XHCI_DEBUGFS_H
1202b6fdc2SLu Baolu 
1302b6fdc2SLu Baolu #include <linux/debugfs.h>
1402b6fdc2SLu Baolu 
1502b6fdc2SLu Baolu #define DEBUGFS_NAMELEN 32
1602b6fdc2SLu Baolu 
1702b6fdc2SLu Baolu #define REG_CAPLENGTH					0x00
1802b6fdc2SLu Baolu #define REG_HCSPARAMS1					0x04
1902b6fdc2SLu Baolu #define REG_HCSPARAMS2					0x08
2002b6fdc2SLu Baolu #define REG_HCSPARAMS3					0x0c
2102b6fdc2SLu Baolu #define REG_HCCPARAMS1					0x10
2202b6fdc2SLu Baolu #define REG_DOORBELLOFF					0x14
2302b6fdc2SLu Baolu #define REG_RUNTIMEOFF					0x18
2402b6fdc2SLu Baolu #define REG_HCCPARAMS2					0x1c
2502b6fdc2SLu Baolu 
2602b6fdc2SLu Baolu #define	REG_USBCMD					0x00
2702b6fdc2SLu Baolu #define REG_USBSTS					0x04
2802b6fdc2SLu Baolu #define REG_PAGESIZE					0x08
2902b6fdc2SLu Baolu #define REG_DNCTRL					0x14
3002b6fdc2SLu Baolu #define REG_CRCR					0x18
3102b6fdc2SLu Baolu #define REG_DCBAAP_LOW					0x30
3202b6fdc2SLu Baolu #define REG_DCBAAP_HIGH					0x34
3302b6fdc2SLu Baolu #define REG_CONFIG					0x38
3402b6fdc2SLu Baolu 
3502b6fdc2SLu Baolu #define REG_MFINDEX					0x00
3602b6fdc2SLu Baolu #define REG_IR0_IMAN					0x20
3702b6fdc2SLu Baolu #define REG_IR0_IMOD					0x24
3802b6fdc2SLu Baolu #define REG_IR0_ERSTSZ					0x28
3902b6fdc2SLu Baolu #define REG_IR0_ERSTBA_LOW				0x30
4002b6fdc2SLu Baolu #define REG_IR0_ERSTBA_HIGH				0x34
4102b6fdc2SLu Baolu #define REG_IR0_ERDP_LOW				0x38
4202b6fdc2SLu Baolu #define REG_IR0_ERDP_HIGH				0x3c
4302b6fdc2SLu Baolu 
4402b6fdc2SLu Baolu #define REG_EXTCAP_USBLEGSUP				0x00
4502b6fdc2SLu Baolu #define REG_EXTCAP_USBLEGCTLSTS				0x04
4602b6fdc2SLu Baolu 
4702b6fdc2SLu Baolu #define REG_EXTCAP_REVISION				0x00
4802b6fdc2SLu Baolu #define REG_EXTCAP_NAME					0x04
4902b6fdc2SLu Baolu #define REG_EXTCAP_PORTINFO				0x08
5002b6fdc2SLu Baolu #define REG_EXTCAP_PORTTYPE				0x0c
5102b6fdc2SLu Baolu #define REG_EXTCAP_MANTISSA1				0x10
5202b6fdc2SLu Baolu #define REG_EXTCAP_MANTISSA2				0x14
5302b6fdc2SLu Baolu #define REG_EXTCAP_MANTISSA3				0x18
5402b6fdc2SLu Baolu #define REG_EXTCAP_MANTISSA4				0x1c
5502b6fdc2SLu Baolu #define REG_EXTCAP_MANTISSA5				0x20
5602b6fdc2SLu Baolu #define REG_EXTCAP_MANTISSA6				0x24
5702b6fdc2SLu Baolu 
5802b6fdc2SLu Baolu #define REG_EXTCAP_DBC_CAPABILITY			0x00
5902b6fdc2SLu Baolu #define REG_EXTCAP_DBC_DOORBELL				0x04
6002b6fdc2SLu Baolu #define REG_EXTCAP_DBC_ERSTSIZE				0x08
6102b6fdc2SLu Baolu #define REG_EXTCAP_DBC_ERST_LOW				0x10
6202b6fdc2SLu Baolu #define REG_EXTCAP_DBC_ERST_HIGH			0x14
6302b6fdc2SLu Baolu #define REG_EXTCAP_DBC_ERDP_LOW				0x18
6402b6fdc2SLu Baolu #define REG_EXTCAP_DBC_ERDP_HIGH			0x1c
6502b6fdc2SLu Baolu #define REG_EXTCAP_DBC_CONTROL				0x20
6602b6fdc2SLu Baolu #define REG_EXTCAP_DBC_STATUS				0x24
6702b6fdc2SLu Baolu #define REG_EXTCAP_DBC_PORTSC				0x28
6802b6fdc2SLu Baolu #define REG_EXTCAP_DBC_CONT_LOW				0x30
6902b6fdc2SLu Baolu #define REG_EXTCAP_DBC_CONT_HIGH			0x34
7002b6fdc2SLu Baolu #define REG_EXTCAP_DBC_DEVINFO1				0x38
7102b6fdc2SLu Baolu #define REG_EXTCAP_DBC_DEVINFO2				0x3c
7202b6fdc2SLu Baolu 
7302b6fdc2SLu Baolu #define dump_register(nm)				\
7402b6fdc2SLu Baolu {							\
7502b6fdc2SLu Baolu 	.name	= __stringify(nm),			\
7602b6fdc2SLu Baolu 	.offset	= REG_ ##nm,				\
7702b6fdc2SLu Baolu }
7802b6fdc2SLu Baolu 
7902b6fdc2SLu Baolu struct xhci_regset {
8002b6fdc2SLu Baolu 	char			name[DEBUGFS_NAMELEN];
8102b6fdc2SLu Baolu 	struct debugfs_regset32	regset;
8202b6fdc2SLu Baolu 	size_t			nregs;
8302b6fdc2SLu Baolu 	struct list_head	list;
8402b6fdc2SLu Baolu };
8502b6fdc2SLu Baolu 
8602b6fdc2SLu Baolu struct xhci_file_map {
8702b6fdc2SLu Baolu 	const char		*name;
8802b6fdc2SLu Baolu 	int			(*show)(struct seq_file *s, void *unused);
8902b6fdc2SLu Baolu };
9002b6fdc2SLu Baolu 
9102b6fdc2SLu Baolu struct xhci_ep_priv {
9202b6fdc2SLu Baolu 	char			name[DEBUGFS_NAMELEN];
9302b6fdc2SLu Baolu 	struct dentry		*root;
94673d7468SLi Jun 	struct xhci_stream_info *stream_info;
95673d7468SLi Jun 	struct xhci_ring	*show_ring;
96673d7468SLi Jun 	unsigned int		stream_id;
9702b6fdc2SLu Baolu };
9802b6fdc2SLu Baolu 
9902b6fdc2SLu Baolu struct xhci_slot_priv {
10002b6fdc2SLu Baolu 	char			name[DEBUGFS_NAMELEN];
10102b6fdc2SLu Baolu 	struct dentry		*root;
10202b6fdc2SLu Baolu 	struct xhci_ep_priv	*eps[31];
10302b6fdc2SLu Baolu 	struct xhci_virt_device	*dev;
10402b6fdc2SLu Baolu };
10502b6fdc2SLu Baolu 
10602b6fdc2SLu Baolu #ifdef CONFIG_DEBUG_FS
10702b6fdc2SLu Baolu void xhci_debugfs_init(struct xhci_hcd *xhci);
10802b6fdc2SLu Baolu void xhci_debugfs_exit(struct xhci_hcd *xhci);
10902b6fdc2SLu Baolu void __init xhci_debugfs_create_root(void);
11002b6fdc2SLu Baolu void __exit xhci_debugfs_remove_root(void);
11102b6fdc2SLu Baolu void xhci_debugfs_create_slot(struct xhci_hcd *xhci, int slot_id);
11202b6fdc2SLu Baolu void xhci_debugfs_remove_slot(struct xhci_hcd *xhci, int slot_id);
11302b6fdc2SLu Baolu void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
11402b6fdc2SLu Baolu 				  struct xhci_virt_device *virt_dev,
11502b6fdc2SLu Baolu 				  int ep_index);
11602b6fdc2SLu Baolu void xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
11702b6fdc2SLu Baolu 				  struct xhci_virt_device *virt_dev,
11802b6fdc2SLu Baolu 				  int ep_index);
119673d7468SLi Jun void xhci_debugfs_create_stream_files(struct xhci_hcd *xhci,
120673d7468SLi Jun 				      struct xhci_virt_device *virt_dev,
121673d7468SLi Jun 				      int ep_index);
12202b6fdc2SLu Baolu #else
xhci_debugfs_init(struct xhci_hcd * xhci)12302b6fdc2SLu Baolu static inline void xhci_debugfs_init(struct xhci_hcd *xhci) { }
xhci_debugfs_exit(struct xhci_hcd * xhci)12402b6fdc2SLu Baolu static inline void xhci_debugfs_exit(struct xhci_hcd *xhci) { }
xhci_debugfs_create_root(void)12502b6fdc2SLu Baolu static inline void __init xhci_debugfs_create_root(void) { }
xhci_debugfs_remove_root(void)12602b6fdc2SLu Baolu static inline void __exit xhci_debugfs_remove_root(void) { }
xhci_debugfs_create_slot(struct xhci_hcd * x,int s)12702b6fdc2SLu Baolu static inline void xhci_debugfs_create_slot(struct xhci_hcd *x, int s) { }
xhci_debugfs_remove_slot(struct xhci_hcd * x,int s)12802b6fdc2SLu Baolu static inline void xhci_debugfs_remove_slot(struct xhci_hcd *x, int s) { }
12902b6fdc2SLu Baolu static inline void
xhci_debugfs_create_endpoint(struct xhci_hcd * xhci,struct xhci_virt_device * virt_dev,int ep_index)13002b6fdc2SLu Baolu xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
13102b6fdc2SLu Baolu 			     struct xhci_virt_device *virt_dev,
13202b6fdc2SLu Baolu 			     int ep_index) { }
13302b6fdc2SLu Baolu static inline void
xhci_debugfs_remove_endpoint(struct xhci_hcd * xhci,struct xhci_virt_device * virt_dev,int ep_index)13402b6fdc2SLu Baolu xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
13502b6fdc2SLu Baolu 			     struct xhci_virt_device *virt_dev,
13602b6fdc2SLu Baolu 			     int ep_index) { }
137673d7468SLi Jun static inline void
xhci_debugfs_create_stream_files(struct xhci_hcd * xhci,struct xhci_virt_device * virt_dev,int ep_index)138673d7468SLi Jun xhci_debugfs_create_stream_files(struct xhci_hcd *xhci,
139673d7468SLi Jun 				 struct xhci_virt_device *virt_dev,
140673d7468SLi Jun 				 int ep_index) { }
14102b6fdc2SLu Baolu #endif /* CONFIG_DEBUG_FS */
14202b6fdc2SLu Baolu 
14302b6fdc2SLu Baolu #endif /* __LINUX_XHCI_DEBUGFS_H */
144