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