^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) * debugfs.c - DesignWare USB3 DRD Controller DebugFS file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Authors: Felipe Balbi <balbi@ti.com>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/usb/ch9.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "gadget.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "io.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define DWC3_LSP_MUX_UNSELECTED 0xfffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define dump_register(nm) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) .name = __stringify(nm), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) .offset = DWC3_ ##nm, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define dump_ep_register_set(n) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) .name = "DEPCMDPAR2("__stringify(n)")", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) .offset = DWC3_DEP_BASE(n) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) DWC3_DEPCMDPAR2, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .name = "DEPCMDPAR1("__stringify(n)")", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) .offset = DWC3_DEP_BASE(n) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) DWC3_DEPCMDPAR1, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) .name = "DEPCMDPAR0("__stringify(n)")", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) .offset = DWC3_DEP_BASE(n) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) DWC3_DEPCMDPAR0, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) .name = "DEPCMD("__stringify(n)")", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .offset = DWC3_DEP_BASE(n) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) DWC3_DEPCMD, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static const struct debugfs_reg32 dwc3_regs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) dump_register(GSBUSCFG0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) dump_register(GSBUSCFG1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) dump_register(GTXTHRCFG),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) dump_register(GRXTHRCFG),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) dump_register(GCTL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) dump_register(GEVTEN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) dump_register(GSTS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) dump_register(GUCTL1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) dump_register(GSNPSID),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) dump_register(GGPIO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) dump_register(GUID),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) dump_register(GUCTL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) dump_register(GBUSERRADDR0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) dump_register(GBUSERRADDR1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) dump_register(GPRTBIMAP0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) dump_register(GPRTBIMAP1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) dump_register(GHWPARAMS0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) dump_register(GHWPARAMS1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) dump_register(GHWPARAMS2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) dump_register(GHWPARAMS3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) dump_register(GHWPARAMS4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) dump_register(GHWPARAMS5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) dump_register(GHWPARAMS6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) dump_register(GHWPARAMS7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) dump_register(GDBGFIFOSPACE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) dump_register(GDBGLTSSM),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) dump_register(GDBGBMU),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) dump_register(GPRTBIMAP_HS0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) dump_register(GPRTBIMAP_HS1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) dump_register(GPRTBIMAP_FS0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) dump_register(GPRTBIMAP_FS1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) dump_register(GUSB2PHYCFG(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) dump_register(GUSB2PHYCFG(1)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) dump_register(GUSB2PHYCFG(2)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) dump_register(GUSB2PHYCFG(3)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) dump_register(GUSB2PHYCFG(4)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) dump_register(GUSB2PHYCFG(5)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) dump_register(GUSB2PHYCFG(6)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) dump_register(GUSB2PHYCFG(7)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) dump_register(GUSB2PHYCFG(8)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) dump_register(GUSB2PHYCFG(9)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) dump_register(GUSB2PHYCFG(10)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) dump_register(GUSB2PHYCFG(11)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) dump_register(GUSB2PHYCFG(12)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) dump_register(GUSB2PHYCFG(13)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) dump_register(GUSB2PHYCFG(14)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) dump_register(GUSB2PHYCFG(15)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) dump_register(GUSB2I2CCTL(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) dump_register(GUSB2I2CCTL(1)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) dump_register(GUSB2I2CCTL(2)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) dump_register(GUSB2I2CCTL(3)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) dump_register(GUSB2I2CCTL(4)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) dump_register(GUSB2I2CCTL(5)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) dump_register(GUSB2I2CCTL(6)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) dump_register(GUSB2I2CCTL(7)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) dump_register(GUSB2I2CCTL(8)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) dump_register(GUSB2I2CCTL(9)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) dump_register(GUSB2I2CCTL(10)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) dump_register(GUSB2I2CCTL(11)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) dump_register(GUSB2I2CCTL(12)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) dump_register(GUSB2I2CCTL(13)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) dump_register(GUSB2I2CCTL(14)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) dump_register(GUSB2I2CCTL(15)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) dump_register(GUSB2PHYACC(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) dump_register(GUSB2PHYACC(1)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) dump_register(GUSB2PHYACC(2)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) dump_register(GUSB2PHYACC(3)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) dump_register(GUSB2PHYACC(4)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) dump_register(GUSB2PHYACC(5)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) dump_register(GUSB2PHYACC(6)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) dump_register(GUSB2PHYACC(7)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) dump_register(GUSB2PHYACC(8)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) dump_register(GUSB2PHYACC(9)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) dump_register(GUSB2PHYACC(10)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) dump_register(GUSB2PHYACC(11)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) dump_register(GUSB2PHYACC(12)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) dump_register(GUSB2PHYACC(13)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) dump_register(GUSB2PHYACC(14)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) dump_register(GUSB2PHYACC(15)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) dump_register(GUSB3PIPECTL(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) dump_register(GUSB3PIPECTL(1)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) dump_register(GUSB3PIPECTL(2)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) dump_register(GUSB3PIPECTL(3)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) dump_register(GUSB3PIPECTL(4)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) dump_register(GUSB3PIPECTL(5)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) dump_register(GUSB3PIPECTL(6)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) dump_register(GUSB3PIPECTL(7)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) dump_register(GUSB3PIPECTL(8)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) dump_register(GUSB3PIPECTL(9)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) dump_register(GUSB3PIPECTL(10)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) dump_register(GUSB3PIPECTL(11)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) dump_register(GUSB3PIPECTL(12)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) dump_register(GUSB3PIPECTL(13)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) dump_register(GUSB3PIPECTL(14)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) dump_register(GUSB3PIPECTL(15)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) dump_register(GTXFIFOSIZ(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) dump_register(GTXFIFOSIZ(1)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) dump_register(GTXFIFOSIZ(2)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) dump_register(GTXFIFOSIZ(3)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) dump_register(GTXFIFOSIZ(4)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) dump_register(GTXFIFOSIZ(5)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) dump_register(GTXFIFOSIZ(6)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) dump_register(GTXFIFOSIZ(7)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) dump_register(GTXFIFOSIZ(8)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) dump_register(GTXFIFOSIZ(9)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) dump_register(GTXFIFOSIZ(10)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) dump_register(GTXFIFOSIZ(11)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) dump_register(GTXFIFOSIZ(12)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) dump_register(GTXFIFOSIZ(13)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) dump_register(GTXFIFOSIZ(14)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) dump_register(GTXFIFOSIZ(15)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) dump_register(GTXFIFOSIZ(16)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) dump_register(GTXFIFOSIZ(17)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) dump_register(GTXFIFOSIZ(18)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) dump_register(GTXFIFOSIZ(19)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) dump_register(GTXFIFOSIZ(20)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) dump_register(GTXFIFOSIZ(21)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) dump_register(GTXFIFOSIZ(22)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) dump_register(GTXFIFOSIZ(23)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) dump_register(GTXFIFOSIZ(24)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) dump_register(GTXFIFOSIZ(25)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) dump_register(GTXFIFOSIZ(26)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) dump_register(GTXFIFOSIZ(27)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) dump_register(GTXFIFOSIZ(28)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) dump_register(GTXFIFOSIZ(29)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) dump_register(GTXFIFOSIZ(30)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) dump_register(GTXFIFOSIZ(31)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) dump_register(GRXFIFOSIZ(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) dump_register(GRXFIFOSIZ(1)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) dump_register(GRXFIFOSIZ(2)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) dump_register(GRXFIFOSIZ(3)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) dump_register(GRXFIFOSIZ(4)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) dump_register(GRXFIFOSIZ(5)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) dump_register(GRXFIFOSIZ(6)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) dump_register(GRXFIFOSIZ(7)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) dump_register(GRXFIFOSIZ(8)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) dump_register(GRXFIFOSIZ(9)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) dump_register(GRXFIFOSIZ(10)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) dump_register(GRXFIFOSIZ(11)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) dump_register(GRXFIFOSIZ(12)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) dump_register(GRXFIFOSIZ(13)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) dump_register(GRXFIFOSIZ(14)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) dump_register(GRXFIFOSIZ(15)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) dump_register(GRXFIFOSIZ(16)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) dump_register(GRXFIFOSIZ(17)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) dump_register(GRXFIFOSIZ(18)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) dump_register(GRXFIFOSIZ(19)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) dump_register(GRXFIFOSIZ(20)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) dump_register(GRXFIFOSIZ(21)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) dump_register(GRXFIFOSIZ(22)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) dump_register(GRXFIFOSIZ(23)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) dump_register(GRXFIFOSIZ(24)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) dump_register(GRXFIFOSIZ(25)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) dump_register(GRXFIFOSIZ(26)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) dump_register(GRXFIFOSIZ(27)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) dump_register(GRXFIFOSIZ(28)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) dump_register(GRXFIFOSIZ(29)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) dump_register(GRXFIFOSIZ(30)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) dump_register(GRXFIFOSIZ(31)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) dump_register(GEVNTADRLO(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) dump_register(GEVNTADRHI(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) dump_register(GEVNTSIZ(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) dump_register(GEVNTCOUNT(0)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) dump_register(GHWPARAMS8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) dump_register(DCFG),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) dump_register(DCTL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) dump_register(DEVTEN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) dump_register(DSTS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) dump_register(DGCMDPAR),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) dump_register(DGCMD),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) dump_register(DALEPENA),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) dump_ep_register_set(0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) dump_ep_register_set(1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) dump_ep_register_set(2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) dump_ep_register_set(3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) dump_ep_register_set(4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) dump_ep_register_set(5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) dump_ep_register_set(6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) dump_ep_register_set(7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) dump_ep_register_set(8),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) dump_ep_register_set(9),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) dump_ep_register_set(10),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) dump_ep_register_set(11),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) dump_ep_register_set(12),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) dump_ep_register_set(13),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) dump_ep_register_set(14),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) dump_ep_register_set(15),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) dump_ep_register_set(16),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) dump_ep_register_set(17),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) dump_ep_register_set(18),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) dump_ep_register_set(19),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) dump_ep_register_set(20),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) dump_ep_register_set(21),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) dump_ep_register_set(22),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) dump_ep_register_set(23),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) dump_ep_register_set(24),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) dump_ep_register_set(25),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) dump_ep_register_set(26),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) dump_ep_register_set(27),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) dump_ep_register_set(28),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) dump_ep_register_set(29),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) dump_ep_register_set(30),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) dump_ep_register_set(31),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) dump_register(OCFG),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) dump_register(OCTL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) dump_register(OEVT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) dump_register(OEVTEN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) dump_register(OSTS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static void dwc3_host_lsp(struct seq_file *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) bool dbc_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) u32 sel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) dbc_enabled = !!(dwc->hwparams.hwparams1 & DWC3_GHWPARAMS1_ENDBC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) sel = dwc->dbg_lsp_select;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) if (sel == DWC3_LSP_MUX_UNSELECTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) seq_puts(s, "Write LSP selection to print for host\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) reg = DWC3_GDBGLSPMUX_HOSTSELECT(sel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) dwc3_writel(dwc->regs, DWC3_GDBGLSPMUX, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) val = dwc3_readl(dwc->regs, DWC3_GDBGLSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) seq_printf(s, "GDBGLSP[%d] = 0x%08x\n", sel, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) if (dbc_enabled && sel < 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) reg |= DWC3_GDBGLSPMUX_ENDBC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) dwc3_writel(dwc->regs, DWC3_GDBGLSPMUX, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) val = dwc3_readl(dwc->regs, DWC3_GDBGLSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) seq_printf(s, "GDBGLSP_DBC[%d] = 0x%08x\n", sel, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static void dwc3_gadget_lsp(struct seq_file *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) for (i = 0; i < 16; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) reg = DWC3_GDBGLSPMUX_DEVSELECT(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) dwc3_writel(dwc->regs, DWC3_GDBGLSPMUX, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) reg = dwc3_readl(dwc->regs, DWC3_GDBGLSP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) seq_printf(s, "GDBGLSP[%d] = 0x%08x\n", i, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) static int dwc3_lsp_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) unsigned int current_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) reg = dwc3_readl(dwc->regs, DWC3_GSTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) current_mode = DWC3_GSTS_CURMOD(reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) switch (current_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) case DWC3_GSTS_CURMOD_HOST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) dwc3_host_lsp(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) case DWC3_GSTS_CURMOD_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) dwc3_gadget_lsp(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) seq_puts(s, "Mode is unknown, no LSP register printed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) static int dwc3_lsp_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) return single_open(file, dwc3_lsp_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static ssize_t dwc3_lsp_write(struct file *file, const char __user *ubuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct seq_file *s = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) char buf[32] = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) u32 sel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) ret = kstrtouint(buf, 0, &sel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) dwc->dbg_lsp_select = sel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) static const struct file_operations dwc3_lsp_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) .open = dwc3_lsp_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) .write = dwc3_lsp_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) static int dwc3_mode_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) reg = dwc3_readl(dwc->regs, DWC3_GCTL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) switch (DWC3_GCTL_PRTCAP(reg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) case DWC3_GCTL_PRTCAP_HOST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) seq_puts(s, "host\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) case DWC3_GCTL_PRTCAP_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) seq_puts(s, "device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) case DWC3_GCTL_PRTCAP_OTG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) seq_puts(s, "otg\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) seq_printf(s, "UNKNOWN %08x\n", DWC3_GCTL_PRTCAP(reg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) static int dwc3_mode_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) return single_open(file, dwc3_mode_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) static ssize_t dwc3_mode_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) const char __user *ubuf, size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) struct seq_file *s = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) u32 mode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) char buf[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) if (dwc->dr_mode != USB_DR_MODE_OTG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) if (!strncmp(buf, "host", 4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) mode = DWC3_GCTL_PRTCAP_HOST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (!strncmp(buf, "device", 6))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) mode = DWC3_GCTL_PRTCAP_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) if (!strncmp(buf, "otg", 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) mode = DWC3_GCTL_PRTCAP_OTG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) #if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) dwc->desired_role_sw_mode = mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) dwc3_set_mode(dwc, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) static const struct file_operations dwc3_mode_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) .open = dwc3_mode_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) .write = dwc3_mode_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) static int dwc3_testmode_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) reg = dwc3_readl(dwc->regs, DWC3_DCTL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) reg &= DWC3_DCTL_TSTCTRL_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) reg >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) switch (reg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) seq_puts(s, "no test\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) case USB_TEST_J:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) seq_puts(s, "test_j\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) case USB_TEST_K:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) seq_puts(s, "test_k\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) case USB_TEST_SE0_NAK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) seq_puts(s, "test_se0_nak\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) case USB_TEST_PACKET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) seq_puts(s, "test_packet\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) case USB_TEST_FORCE_ENABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) seq_puts(s, "test_force_enable\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) seq_printf(s, "UNKNOWN %d\n", reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) static int dwc3_testmode_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) return single_open(file, dwc3_testmode_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) static ssize_t dwc3_testmode_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) const char __user *ubuf, size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) struct seq_file *s = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) u32 testmode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) char buf[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) if (!strncmp(buf, "test_j", 6))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) testmode = USB_TEST_J;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) else if (!strncmp(buf, "test_k", 6))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) testmode = USB_TEST_K;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) else if (!strncmp(buf, "test_se0_nak", 12))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) testmode = USB_TEST_SE0_NAK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) else if (!strncmp(buf, "test_packet", 11))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) testmode = USB_TEST_PACKET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) else if (!strncmp(buf, "test_force_enable", 17))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) testmode = USB_TEST_FORCE_ENABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) testmode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) dwc3_gadget_set_test_mode(dwc, testmode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) static const struct file_operations dwc3_testmode_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) .open = dwc3_testmode_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) .write = dwc3_testmode_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static int dwc3_link_state_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) enum dwc3_link_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) u8 speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) reg = dwc3_readl(dwc->regs, DWC3_GSTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) seq_puts(s, "Not available\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) reg = dwc3_readl(dwc->regs, DWC3_DSTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) state = DWC3_DSTS_USBLNKST(reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) speed = reg & DWC3_DSTS_CONNECTSPD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) seq_printf(s, "%s\n", (speed >= DWC3_DSTS_SUPERSPEED) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) dwc3_gadget_link_string(state) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) dwc3_gadget_hs_link_string(state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) static int dwc3_link_state_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) return single_open(file, dwc3_link_state_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) static ssize_t dwc3_link_state_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) const char __user *ubuf, size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) struct seq_file *s = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) struct dwc3 *dwc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) enum dwc3_link_state state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) char buf[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) u8 speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) if (!strncmp(buf, "SS.Disabled", 11))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) state = DWC3_LINK_STATE_SS_DIS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) else if (!strncmp(buf, "Rx.Detect", 9))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) state = DWC3_LINK_STATE_RX_DET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) else if (!strncmp(buf, "SS.Inactive", 11))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) state = DWC3_LINK_STATE_SS_INACT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) else if (!strncmp(buf, "Recovery", 8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) state = DWC3_LINK_STATE_RECOV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) else if (!strncmp(buf, "Compliance", 10))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) state = DWC3_LINK_STATE_CMPLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) else if (!strncmp(buf, "Loopback", 8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) state = DWC3_LINK_STATE_LPBK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) reg = dwc3_readl(dwc->regs, DWC3_GSTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) reg = dwc3_readl(dwc->regs, DWC3_DSTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) speed = reg & DWC3_DSTS_CONNECTSPD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) if (speed < DWC3_DSTS_SUPERSPEED &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) state != DWC3_LINK_STATE_RECOV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) dwc3_gadget_set_link_state(dwc, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) static const struct file_operations dwc3_link_state_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) .open = dwc3_link_state_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) .write = dwc3_link_state_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) struct dwc3_ep_file_map {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) const char name[25];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) const struct file_operations *const fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) static int dwc3_tx_fifo_size_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) u32 mdwidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) val = dwc3_core_fifo_space(dep, DWC3_TXFIFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) /* Convert to bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) mdwidth = dwc3_mdwidth(dwc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) val *= mdwidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) val >>= 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) seq_printf(s, "%u\n", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) static int dwc3_rx_fifo_size_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) u32 mdwidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) val = dwc3_core_fifo_space(dep, DWC3_RXFIFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) /* Convert to bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) mdwidth = dwc3_mdwidth(dwc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) val *= mdwidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) val >>= 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) seq_printf(s, "%u\n", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) static int dwc3_tx_request_queue_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) val = dwc3_core_fifo_space(dep, DWC3_TXREQQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) seq_printf(s, "%u\n", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) static int dwc3_rx_request_queue_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) val = dwc3_core_fifo_space(dep, DWC3_RXREQQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) seq_printf(s, "%u\n", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) static int dwc3_rx_info_queue_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) val = dwc3_core_fifo_space(dep, DWC3_RXINFOQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) seq_printf(s, "%u\n", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) static int dwc3_descriptor_fetch_queue_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) val = dwc3_core_fifo_space(dep, DWC3_DESCFETCHQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) seq_printf(s, "%u\n", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) static int dwc3_event_queue_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) val = dwc3_core_fifo_space(dep, DWC3_EVENTQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) seq_printf(s, "%u\n", val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) static int dwc3_transfer_type_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) if (!(dep->flags & DWC3_EP_ENABLED) || !dep->endpoint.desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) seq_puts(s, "--\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) switch (usb_endpoint_type(dep->endpoint.desc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) case USB_ENDPOINT_XFER_CONTROL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) seq_puts(s, "control\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) case USB_ENDPOINT_XFER_ISOC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) seq_puts(s, "isochronous\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) case USB_ENDPOINT_XFER_BULK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) seq_puts(s, "bulk\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) case USB_ENDPOINT_XFER_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) seq_puts(s, "interrupt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) seq_puts(s, "--\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) static int dwc3_trb_ring_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) if (dep->number <= 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) seq_puts(s, "--\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) seq_puts(s, "buffer_addr,size,type,ioc,isp_imi,csp,chn,lst,hwo\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) for (i = 0; i < DWC3_TRB_NUM; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) struct dwc3_trb *trb = &dep->trb_pool[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) unsigned int type = DWC3_TRBCTL_TYPE(trb->ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) seq_printf(s, "%08x%08x,%d,%s,%d,%d,%d,%d,%d,%d %c%c\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) trb->bph, trb->bpl, trb->size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) dwc3_trb_type_string(type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) !!(trb->ctrl & DWC3_TRB_CTRL_IOC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) !!(trb->ctrl & DWC3_TRB_CTRL_ISP_IMI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) !!(trb->ctrl & DWC3_TRB_CTRL_CSP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) !!(trb->ctrl & DWC3_TRB_CTRL_CHN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) !!(trb->ctrl & DWC3_TRB_CTRL_LST),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) !!(trb->ctrl & DWC3_TRB_CTRL_HWO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) dep->trb_enqueue == i ? 'E' : ' ',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) dep->trb_dequeue == i ? 'D' : ' ');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) static int dwc3_ep_info_register_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) struct dwc3_ep *dep = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) struct dwc3 *dwc = dep->dwc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) u64 ep_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) u32 lower_32_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) u32 upper_32_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) spin_lock_irqsave(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) reg = DWC3_GDBGLSPMUX_EPSELECT(dep->number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) dwc3_writel(dwc->regs, DWC3_GDBGLSPMUX, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) lower_32_bits = dwc3_readl(dwc->regs, DWC3_GDBGEPINFO0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) upper_32_bits = dwc3_readl(dwc->regs, DWC3_GDBGEPINFO1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) ep_info = ((u64)upper_32_bits << 32) | lower_32_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) seq_printf(s, "0x%016llx\n", ep_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) spin_unlock_irqrestore(&dwc->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) DEFINE_SHOW_ATTRIBUTE(dwc3_tx_fifo_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) DEFINE_SHOW_ATTRIBUTE(dwc3_rx_fifo_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) DEFINE_SHOW_ATTRIBUTE(dwc3_tx_request_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) DEFINE_SHOW_ATTRIBUTE(dwc3_rx_request_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) DEFINE_SHOW_ATTRIBUTE(dwc3_rx_info_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) DEFINE_SHOW_ATTRIBUTE(dwc3_descriptor_fetch_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) DEFINE_SHOW_ATTRIBUTE(dwc3_event_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) DEFINE_SHOW_ATTRIBUTE(dwc3_transfer_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) DEFINE_SHOW_ATTRIBUTE(dwc3_trb_ring);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) DEFINE_SHOW_ATTRIBUTE(dwc3_ep_info_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) static const struct dwc3_ep_file_map dwc3_ep_file_map[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) { "tx_fifo_size", &dwc3_tx_fifo_size_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) { "rx_fifo_size", &dwc3_rx_fifo_size_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) { "tx_request_queue", &dwc3_tx_request_queue_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) { "rx_request_queue", &dwc3_rx_request_queue_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) { "rx_info_queue", &dwc3_rx_info_queue_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) { "descriptor_fetch_queue", &dwc3_descriptor_fetch_queue_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) { "event_queue", &dwc3_event_queue_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) { "transfer_type", &dwc3_transfer_type_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) { "trb_ring", &dwc3_trb_ring_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) { "GDBGEPINFO", &dwc3_ep_info_register_fops, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) struct dentry *parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) for (i = 0; i < ARRAY_SIZE(dwc3_ep_file_map); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) const struct file_operations *fops = dwc3_ep_file_map[i].fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) const char *name = dwc3_ep_file_map[i].name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) debugfs_create_file(name, 0444, parent, dep, fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) struct dentry *dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) dir = debugfs_create_dir(dep->name, dep->dwc->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) dwc3_debugfs_create_endpoint_files(dep, dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) void dwc3_debugfs_init(struct dwc3 *dwc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) struct dentry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) dwc->regset = kzalloc(sizeof(*dwc->regset), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) if (!dwc->regset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) dwc->dbg_lsp_select = DWC3_LSP_MUX_UNSELECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) dwc->regset->regs = dwc3_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) dwc->regset->nregs = ARRAY_SIZE(dwc3_regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) dwc->regset->base = dwc->regs - DWC3_GLOBALS_REGS_START;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) root = debugfs_create_dir(dev_name(dwc->dev), usb_debug_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) dwc->root = root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) debugfs_create_regset32("regdump", 0444, root, dwc->regset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) debugfs_create_file("lsp_dump", 0644, root, dwc, &dwc3_lsp_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) debugfs_create_file("mode", 0644, root, dwc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) &dwc3_mode_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) IS_ENABLED(CONFIG_USB_DWC3_GADGET)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) debugfs_create_file("testmode", 0644, root, dwc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) &dwc3_testmode_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) debugfs_create_file("link_state", 0644, root, dwc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) &dwc3_link_state_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) void dwc3_debugfs_exit(struct dwc3 *dwc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) debugfs_remove_recursive(dwc->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) kfree(dwc->regset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) }