18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * debugfs.c - Designware USB2 DRD controller debugfs
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2015 Intel Corporation
68c2ecf20Sopenharmony_ci * Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
108c2ecf20Sopenharmony_ci#include <linux/debugfs.h>
118c2ecf20Sopenharmony_ci#include <linux/seq_file.h>
128c2ecf20Sopenharmony_ci#include <linux/uaccess.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include "core.h"
158c2ecf20Sopenharmony_ci#include "debug.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
188c2ecf20Sopenharmony_ci	IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/**
218c2ecf20Sopenharmony_ci * testmode_write() - change usb test mode state.
228c2ecf20Sopenharmony_ci * @file: The  file to write to.
238c2ecf20Sopenharmony_ci * @ubuf: The buffer where user wrote.
248c2ecf20Sopenharmony_ci * @count: The ubuf size.
258c2ecf20Sopenharmony_ci * @ppos: Unused parameter.
268c2ecf20Sopenharmony_ci */
278c2ecf20Sopenharmony_cistatic ssize_t testmode_write(struct file *file, const char __user *ubuf, size_t
288c2ecf20Sopenharmony_ci		count, loff_t *ppos)
298c2ecf20Sopenharmony_ci{
308c2ecf20Sopenharmony_ci	struct seq_file		*s = file->private_data;
318c2ecf20Sopenharmony_ci	struct dwc2_hsotg	*hsotg = s->private;
328c2ecf20Sopenharmony_ci	unsigned long		flags;
338c2ecf20Sopenharmony_ci	u32			testmode = 0;
348c2ecf20Sopenharmony_ci	char			buf[32];
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
378c2ecf20Sopenharmony_ci		return -EFAULT;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	if (!strncmp(buf, "test_j", 6))
408c2ecf20Sopenharmony_ci		testmode = USB_TEST_J;
418c2ecf20Sopenharmony_ci	else if (!strncmp(buf, "test_k", 6))
428c2ecf20Sopenharmony_ci		testmode = USB_TEST_K;
438c2ecf20Sopenharmony_ci	else if (!strncmp(buf, "test_se0_nak", 12))
448c2ecf20Sopenharmony_ci		testmode = USB_TEST_SE0_NAK;
458c2ecf20Sopenharmony_ci	else if (!strncmp(buf, "test_packet", 11))
468c2ecf20Sopenharmony_ci		testmode = USB_TEST_PACKET;
478c2ecf20Sopenharmony_ci	else if (!strncmp(buf, "test_force_enable", 17))
488c2ecf20Sopenharmony_ci		testmode = USB_TEST_FORCE_ENABLE;
498c2ecf20Sopenharmony_ci	else
508c2ecf20Sopenharmony_ci		testmode = 0;
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	spin_lock_irqsave(&hsotg->lock, flags);
538c2ecf20Sopenharmony_ci	dwc2_hsotg_set_test_mode(hsotg, testmode);
548c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&hsotg->lock, flags);
558c2ecf20Sopenharmony_ci	return count;
568c2ecf20Sopenharmony_ci}
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/**
598c2ecf20Sopenharmony_ci * testmode_show() - debugfs: show usb test mode state
608c2ecf20Sopenharmony_ci * @s: The seq file to write to.
618c2ecf20Sopenharmony_ci * @unused: Unused parameter.
628c2ecf20Sopenharmony_ci *
638c2ecf20Sopenharmony_ci * This debugfs entry shows which usb test mode is currently enabled.
648c2ecf20Sopenharmony_ci */
658c2ecf20Sopenharmony_cistatic int testmode_show(struct seq_file *s, void *unused)
668c2ecf20Sopenharmony_ci{
678c2ecf20Sopenharmony_ci	struct dwc2_hsotg *hsotg = s->private;
688c2ecf20Sopenharmony_ci	unsigned long flags;
698c2ecf20Sopenharmony_ci	int dctl;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	spin_lock_irqsave(&hsotg->lock, flags);
728c2ecf20Sopenharmony_ci	dctl = dwc2_readl(hsotg, DCTL);
738c2ecf20Sopenharmony_ci	dctl &= DCTL_TSTCTL_MASK;
748c2ecf20Sopenharmony_ci	dctl >>= DCTL_TSTCTL_SHIFT;
758c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&hsotg->lock, flags);
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	switch (dctl) {
788c2ecf20Sopenharmony_ci	case 0:
798c2ecf20Sopenharmony_ci		seq_puts(s, "no test\n");
808c2ecf20Sopenharmony_ci		break;
818c2ecf20Sopenharmony_ci	case USB_TEST_J:
828c2ecf20Sopenharmony_ci		seq_puts(s, "test_j\n");
838c2ecf20Sopenharmony_ci		break;
848c2ecf20Sopenharmony_ci	case USB_TEST_K:
858c2ecf20Sopenharmony_ci		seq_puts(s, "test_k\n");
868c2ecf20Sopenharmony_ci		break;
878c2ecf20Sopenharmony_ci	case USB_TEST_SE0_NAK:
888c2ecf20Sopenharmony_ci		seq_puts(s, "test_se0_nak\n");
898c2ecf20Sopenharmony_ci		break;
908c2ecf20Sopenharmony_ci	case USB_TEST_PACKET:
918c2ecf20Sopenharmony_ci		seq_puts(s, "test_packet\n");
928c2ecf20Sopenharmony_ci		break;
938c2ecf20Sopenharmony_ci	case USB_TEST_FORCE_ENABLE:
948c2ecf20Sopenharmony_ci		seq_puts(s, "test_force_enable\n");
958c2ecf20Sopenharmony_ci		break;
968c2ecf20Sopenharmony_ci	default:
978c2ecf20Sopenharmony_ci		seq_printf(s, "UNKNOWN %d\n", dctl);
988c2ecf20Sopenharmony_ci	}
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	return 0;
1018c2ecf20Sopenharmony_ci}
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_cistatic int testmode_open(struct inode *inode, struct file *file)
1048c2ecf20Sopenharmony_ci{
1058c2ecf20Sopenharmony_ci	return single_open(file, testmode_show, inode->i_private);
1068c2ecf20Sopenharmony_ci}
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_cistatic const struct file_operations testmode_fops = {
1098c2ecf20Sopenharmony_ci	.owner		= THIS_MODULE,
1108c2ecf20Sopenharmony_ci	.open		= testmode_open,
1118c2ecf20Sopenharmony_ci	.write		= testmode_write,
1128c2ecf20Sopenharmony_ci	.read		= seq_read,
1138c2ecf20Sopenharmony_ci	.llseek		= seq_lseek,
1148c2ecf20Sopenharmony_ci	.release	= single_release,
1158c2ecf20Sopenharmony_ci};
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci/**
1188c2ecf20Sopenharmony_ci * state_show - debugfs: show overall driver and device state.
1198c2ecf20Sopenharmony_ci * @seq: The seq file to write to.
1208c2ecf20Sopenharmony_ci * @v: Unused parameter.
1218c2ecf20Sopenharmony_ci *
1228c2ecf20Sopenharmony_ci * This debugfs entry shows the overall state of the hardware and
1238c2ecf20Sopenharmony_ci * some general information about each of the endpoints available
1248c2ecf20Sopenharmony_ci * to the system.
1258c2ecf20Sopenharmony_ci */
1268c2ecf20Sopenharmony_cistatic int state_show(struct seq_file *seq, void *v)
1278c2ecf20Sopenharmony_ci{
1288c2ecf20Sopenharmony_ci	struct dwc2_hsotg *hsotg = seq->private;
1298c2ecf20Sopenharmony_ci	int idx;
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	seq_printf(seq, "DCFG=0x%08x, DCTL=0x%08x, DSTS=0x%08x\n",
1328c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DCFG),
1338c2ecf20Sopenharmony_ci		 dwc2_readl(hsotg, DCTL),
1348c2ecf20Sopenharmony_ci		 dwc2_readl(hsotg, DSTS));
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	seq_printf(seq, "DIEPMSK=0x%08x, DOEPMASK=0x%08x\n",
1378c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DIEPMSK), dwc2_readl(hsotg, DOEPMSK));
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci	seq_printf(seq, "GINTMSK=0x%08x, GINTSTS=0x%08x\n",
1408c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, GINTMSK),
1418c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, GINTSTS));
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	seq_printf(seq, "DAINTMSK=0x%08x, DAINT=0x%08x\n",
1448c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DAINTMSK),
1458c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DAINT));
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	seq_printf(seq, "GNPTXSTS=0x%08x, GRXSTSR=%08x\n",
1488c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, GNPTXSTS),
1498c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, GRXSTSR));
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	seq_puts(seq, "\nEndpoint status:\n");
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	for (idx = 0; idx < hsotg->num_of_eps; idx++) {
1548c2ecf20Sopenharmony_ci		u32 in, out;
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci		in = dwc2_readl(hsotg, DIEPCTL(idx));
1578c2ecf20Sopenharmony_ci		out = dwc2_readl(hsotg, DOEPCTL(idx));
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci		seq_printf(seq, "ep%d: DIEPCTL=0x%08x, DOEPCTL=0x%08x",
1608c2ecf20Sopenharmony_ci			   idx, in, out);
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci		in = dwc2_readl(hsotg, DIEPTSIZ(idx));
1638c2ecf20Sopenharmony_ci		out = dwc2_readl(hsotg, DOEPTSIZ(idx));
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci		seq_printf(seq, ", DIEPTSIZ=0x%08x, DOEPTSIZ=0x%08x",
1668c2ecf20Sopenharmony_ci			   in, out);
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci		seq_puts(seq, "\n");
1698c2ecf20Sopenharmony_ci	}
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	return 0;
1728c2ecf20Sopenharmony_ci}
1738c2ecf20Sopenharmony_ciDEFINE_SHOW_ATTRIBUTE(state);
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/**
1768c2ecf20Sopenharmony_ci * fifo_show - debugfs: show the fifo information
1778c2ecf20Sopenharmony_ci * @seq: The seq_file to write data to.
1788c2ecf20Sopenharmony_ci * @v: Unused parameter.
1798c2ecf20Sopenharmony_ci *
1808c2ecf20Sopenharmony_ci * Show the FIFO information for the overall fifo and all the
1818c2ecf20Sopenharmony_ci * periodic transmission FIFOs.
1828c2ecf20Sopenharmony_ci */
1838c2ecf20Sopenharmony_cistatic int fifo_show(struct seq_file *seq, void *v)
1848c2ecf20Sopenharmony_ci{
1858c2ecf20Sopenharmony_ci	struct dwc2_hsotg *hsotg = seq->private;
1868c2ecf20Sopenharmony_ci	int fifo_count = dwc2_hsotg_tx_fifo_count(hsotg);
1878c2ecf20Sopenharmony_ci	u32 val;
1888c2ecf20Sopenharmony_ci	int idx;
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci	seq_puts(seq, "Non-periodic FIFOs:\n");
1918c2ecf20Sopenharmony_ci	seq_printf(seq, "RXFIFO: Size %d\n", dwc2_readl(hsotg, GRXFSIZ));
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci	val = dwc2_readl(hsotg, GNPTXFSIZ);
1948c2ecf20Sopenharmony_ci	seq_printf(seq, "NPTXFIFO: Size %d, Start 0x%08x\n",
1958c2ecf20Sopenharmony_ci		   val >> FIFOSIZE_DEPTH_SHIFT,
1968c2ecf20Sopenharmony_ci		   val & FIFOSIZE_STARTADDR_MASK);
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci	seq_puts(seq, "\nPeriodic TXFIFOs:\n");
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci	for (idx = 1; idx <= fifo_count; idx++) {
2018c2ecf20Sopenharmony_ci		val = dwc2_readl(hsotg, DPTXFSIZN(idx));
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci		seq_printf(seq, "\tDPTXFIFO%2d: Size %d, Start 0x%08x\n", idx,
2048c2ecf20Sopenharmony_ci			   val >> FIFOSIZE_DEPTH_SHIFT,
2058c2ecf20Sopenharmony_ci			   val & FIFOSIZE_STARTADDR_MASK);
2068c2ecf20Sopenharmony_ci	}
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci	return 0;
2098c2ecf20Sopenharmony_ci}
2108c2ecf20Sopenharmony_ciDEFINE_SHOW_ATTRIBUTE(fifo);
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_cistatic const char *decode_direction(int is_in)
2138c2ecf20Sopenharmony_ci{
2148c2ecf20Sopenharmony_ci	return is_in ? "in" : "out";
2158c2ecf20Sopenharmony_ci}
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci/**
2188c2ecf20Sopenharmony_ci * ep_show - debugfs: show the state of an endpoint.
2198c2ecf20Sopenharmony_ci * @seq: The seq_file to write data to.
2208c2ecf20Sopenharmony_ci * @v: Unused parameter.
2218c2ecf20Sopenharmony_ci *
2228c2ecf20Sopenharmony_ci * This debugfs entry shows the state of the given endpoint (one is
2238c2ecf20Sopenharmony_ci * registered for each available).
2248c2ecf20Sopenharmony_ci */
2258c2ecf20Sopenharmony_cistatic int ep_show(struct seq_file *seq, void *v)
2268c2ecf20Sopenharmony_ci{
2278c2ecf20Sopenharmony_ci	struct dwc2_hsotg_ep *ep = seq->private;
2288c2ecf20Sopenharmony_ci	struct dwc2_hsotg *hsotg = ep->parent;
2298c2ecf20Sopenharmony_ci	struct dwc2_hsotg_req *req;
2308c2ecf20Sopenharmony_ci	int index = ep->index;
2318c2ecf20Sopenharmony_ci	int show_limit = 15;
2328c2ecf20Sopenharmony_ci	unsigned long flags;
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	seq_printf(seq, "Endpoint index %d, named %s,  dir %s:\n",
2358c2ecf20Sopenharmony_ci		   ep->index, ep->ep.name, decode_direction(ep->dir_in));
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	/* first show the register state */
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	seq_printf(seq, "\tDIEPCTL=0x%08x, DOEPCTL=0x%08x\n",
2408c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DIEPCTL(index)),
2418c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DOEPCTL(index)));
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	seq_printf(seq, "\tDIEPDMA=0x%08x, DOEPDMA=0x%08x\n",
2448c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DIEPDMA(index)),
2458c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DOEPDMA(index)));
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	seq_printf(seq, "\tDIEPINT=0x%08x, DOEPINT=0x%08x\n",
2488c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DIEPINT(index)),
2498c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DOEPINT(index)));
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	seq_printf(seq, "\tDIEPTSIZ=0x%08x, DOEPTSIZ=0x%08x\n",
2528c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DIEPTSIZ(index)),
2538c2ecf20Sopenharmony_ci		   dwc2_readl(hsotg, DOEPTSIZ(index)));
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	seq_puts(seq, "\n");
2568c2ecf20Sopenharmony_ci	seq_printf(seq, "mps %d\n", ep->ep.maxpacket);
2578c2ecf20Sopenharmony_ci	seq_printf(seq, "total_data=%ld\n", ep->total_data);
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	seq_printf(seq, "request list (%p,%p):\n",
2608c2ecf20Sopenharmony_ci		   ep->queue.next, ep->queue.prev);
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	spin_lock_irqsave(&hsotg->lock, flags);
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	list_for_each_entry(req, &ep->queue, queue) {
2658c2ecf20Sopenharmony_ci		if (--show_limit < 0) {
2668c2ecf20Sopenharmony_ci			seq_puts(seq, "not showing more requests...\n");
2678c2ecf20Sopenharmony_ci			break;
2688c2ecf20Sopenharmony_ci		}
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci		seq_printf(seq, "%c req %p: %d bytes @%p, ",
2718c2ecf20Sopenharmony_ci			   req == ep->req ? '*' : ' ',
2728c2ecf20Sopenharmony_ci			   req, req->req.length, req->req.buf);
2738c2ecf20Sopenharmony_ci		seq_printf(seq, "%d done, res %d\n",
2748c2ecf20Sopenharmony_ci			   req->req.actual, req->req.status);
2758c2ecf20Sopenharmony_ci	}
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&hsotg->lock, flags);
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	return 0;
2808c2ecf20Sopenharmony_ci}
2818c2ecf20Sopenharmony_ciDEFINE_SHOW_ATTRIBUTE(ep);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci/**
2848c2ecf20Sopenharmony_ci * dwc2_hsotg_create_debug - create debugfs directory and files
2858c2ecf20Sopenharmony_ci * @hsotg: The driver state
2868c2ecf20Sopenharmony_ci *
2878c2ecf20Sopenharmony_ci * Create the debugfs files to allow the user to get information
2888c2ecf20Sopenharmony_ci * about the state of the system. The directory name is created
2898c2ecf20Sopenharmony_ci * with the same name as the device itself, in case we end up
2908c2ecf20Sopenharmony_ci * with multiple blocks in future systems.
2918c2ecf20Sopenharmony_ci */
2928c2ecf20Sopenharmony_cistatic void dwc2_hsotg_create_debug(struct dwc2_hsotg *hsotg)
2938c2ecf20Sopenharmony_ci{
2948c2ecf20Sopenharmony_ci	struct dentry *root;
2958c2ecf20Sopenharmony_ci	unsigned int epidx;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	root = hsotg->debug_root;
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	/* create general state file */
3008c2ecf20Sopenharmony_ci	debugfs_create_file("state", 0444, root, hsotg, &state_fops);
3018c2ecf20Sopenharmony_ci	debugfs_create_file("testmode", 0644, root, hsotg, &testmode_fops);
3028c2ecf20Sopenharmony_ci	debugfs_create_file("fifo", 0444, root, hsotg, &fifo_fops);
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci	/* Create one file for each out endpoint */
3058c2ecf20Sopenharmony_ci	for (epidx = 0; epidx < hsotg->num_of_eps; epidx++) {
3068c2ecf20Sopenharmony_ci		struct dwc2_hsotg_ep *ep;
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci		ep = hsotg->eps_out[epidx];
3098c2ecf20Sopenharmony_ci		if (ep)
3108c2ecf20Sopenharmony_ci			debugfs_create_file(ep->name, 0444, root, ep, &ep_fops);
3118c2ecf20Sopenharmony_ci	}
3128c2ecf20Sopenharmony_ci	/* Create one file for each in endpoint. EP0 is handled with out eps */
3138c2ecf20Sopenharmony_ci	for (epidx = 1; epidx < hsotg->num_of_eps; epidx++) {
3148c2ecf20Sopenharmony_ci		struct dwc2_hsotg_ep *ep;
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci		ep = hsotg->eps_in[epidx];
3178c2ecf20Sopenharmony_ci		if (ep)
3188c2ecf20Sopenharmony_ci			debugfs_create_file(ep->name, 0444, root, ep, &ep_fops);
3198c2ecf20Sopenharmony_ci	}
3208c2ecf20Sopenharmony_ci}
3218c2ecf20Sopenharmony_ci#else
3228c2ecf20Sopenharmony_cistatic inline void dwc2_hsotg_create_debug(struct dwc2_hsotg *hsotg) {}
3238c2ecf20Sopenharmony_ci#endif
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci/* dwc2_hsotg_delete_debug is removed as cleanup in done in dwc2_debugfs_exit */
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci#define dump_register(nm)	\
3288c2ecf20Sopenharmony_ci{				\
3298c2ecf20Sopenharmony_ci	.name	= #nm,		\
3308c2ecf20Sopenharmony_ci	.offset	= nm,		\
3318c2ecf20Sopenharmony_ci}
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistatic const struct debugfs_reg32 dwc2_regs[] = {
3348c2ecf20Sopenharmony_ci	/*
3358c2ecf20Sopenharmony_ci	 * Accessing registers like this can trigger mode mismatch interrupt.
3368c2ecf20Sopenharmony_ci	 * However, according to dwc2 databook, the register access, in this
3378c2ecf20Sopenharmony_ci	 * case, is completed on the processor bus but is ignored by the core
3388c2ecf20Sopenharmony_ci	 * and does not affect its operation.
3398c2ecf20Sopenharmony_ci	 */
3408c2ecf20Sopenharmony_ci	dump_register(GOTGCTL),
3418c2ecf20Sopenharmony_ci	dump_register(GOTGINT),
3428c2ecf20Sopenharmony_ci	dump_register(GAHBCFG),
3438c2ecf20Sopenharmony_ci	dump_register(GUSBCFG),
3448c2ecf20Sopenharmony_ci	dump_register(GRSTCTL),
3458c2ecf20Sopenharmony_ci	dump_register(GINTSTS),
3468c2ecf20Sopenharmony_ci	dump_register(GINTMSK),
3478c2ecf20Sopenharmony_ci	dump_register(GRXSTSR),
3488c2ecf20Sopenharmony_ci	/* Omit GRXSTSP */
3498c2ecf20Sopenharmony_ci	dump_register(GRXFSIZ),
3508c2ecf20Sopenharmony_ci	dump_register(GNPTXFSIZ),
3518c2ecf20Sopenharmony_ci	dump_register(GNPTXSTS),
3528c2ecf20Sopenharmony_ci	dump_register(GI2CCTL),
3538c2ecf20Sopenharmony_ci	dump_register(GPVNDCTL),
3548c2ecf20Sopenharmony_ci	dump_register(GGPIO),
3558c2ecf20Sopenharmony_ci	dump_register(GUID),
3568c2ecf20Sopenharmony_ci	dump_register(GSNPSID),
3578c2ecf20Sopenharmony_ci	dump_register(GHWCFG1),
3588c2ecf20Sopenharmony_ci	dump_register(GHWCFG2),
3598c2ecf20Sopenharmony_ci	dump_register(GHWCFG3),
3608c2ecf20Sopenharmony_ci	dump_register(GHWCFG4),
3618c2ecf20Sopenharmony_ci	dump_register(GLPMCFG),
3628c2ecf20Sopenharmony_ci	dump_register(GPWRDN),
3638c2ecf20Sopenharmony_ci	dump_register(GDFIFOCFG),
3648c2ecf20Sopenharmony_ci	dump_register(ADPCTL),
3658c2ecf20Sopenharmony_ci	dump_register(HPTXFSIZ),
3668c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(1)),
3678c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(2)),
3688c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(3)),
3698c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(4)),
3708c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(5)),
3718c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(6)),
3728c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(7)),
3738c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(8)),
3748c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(9)),
3758c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(10)),
3768c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(11)),
3778c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(12)),
3788c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(13)),
3798c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(14)),
3808c2ecf20Sopenharmony_ci	dump_register(DPTXFSIZN(15)),
3818c2ecf20Sopenharmony_ci	dump_register(DCFG),
3828c2ecf20Sopenharmony_ci	dump_register(DCTL),
3838c2ecf20Sopenharmony_ci	dump_register(DSTS),
3848c2ecf20Sopenharmony_ci	dump_register(DIEPMSK),
3858c2ecf20Sopenharmony_ci	dump_register(DOEPMSK),
3868c2ecf20Sopenharmony_ci	dump_register(DAINT),
3878c2ecf20Sopenharmony_ci	dump_register(DAINTMSK),
3888c2ecf20Sopenharmony_ci	dump_register(DTKNQR1),
3898c2ecf20Sopenharmony_ci	dump_register(DTKNQR2),
3908c2ecf20Sopenharmony_ci	dump_register(DTKNQR3),
3918c2ecf20Sopenharmony_ci	dump_register(DTKNQR4),
3928c2ecf20Sopenharmony_ci	dump_register(DVBUSDIS),
3938c2ecf20Sopenharmony_ci	dump_register(DVBUSPULSE),
3948c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(0)),
3958c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(1)),
3968c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(2)),
3978c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(3)),
3988c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(4)),
3998c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(5)),
4008c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(6)),
4018c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(7)),
4028c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(8)),
4038c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(9)),
4048c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(10)),
4058c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(11)),
4068c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(12)),
4078c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(13)),
4088c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(14)),
4098c2ecf20Sopenharmony_ci	dump_register(DIEPCTL(15)),
4108c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(0)),
4118c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(1)),
4128c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(2)),
4138c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(3)),
4148c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(4)),
4158c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(5)),
4168c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(6)),
4178c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(7)),
4188c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(8)),
4198c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(9)),
4208c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(10)),
4218c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(11)),
4228c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(12)),
4238c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(13)),
4248c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(14)),
4258c2ecf20Sopenharmony_ci	dump_register(DOEPCTL(15)),
4268c2ecf20Sopenharmony_ci	dump_register(DIEPINT(0)),
4278c2ecf20Sopenharmony_ci	dump_register(DIEPINT(1)),
4288c2ecf20Sopenharmony_ci	dump_register(DIEPINT(2)),
4298c2ecf20Sopenharmony_ci	dump_register(DIEPINT(3)),
4308c2ecf20Sopenharmony_ci	dump_register(DIEPINT(4)),
4318c2ecf20Sopenharmony_ci	dump_register(DIEPINT(5)),
4328c2ecf20Sopenharmony_ci	dump_register(DIEPINT(6)),
4338c2ecf20Sopenharmony_ci	dump_register(DIEPINT(7)),
4348c2ecf20Sopenharmony_ci	dump_register(DIEPINT(8)),
4358c2ecf20Sopenharmony_ci	dump_register(DIEPINT(9)),
4368c2ecf20Sopenharmony_ci	dump_register(DIEPINT(10)),
4378c2ecf20Sopenharmony_ci	dump_register(DIEPINT(11)),
4388c2ecf20Sopenharmony_ci	dump_register(DIEPINT(12)),
4398c2ecf20Sopenharmony_ci	dump_register(DIEPINT(13)),
4408c2ecf20Sopenharmony_ci	dump_register(DIEPINT(14)),
4418c2ecf20Sopenharmony_ci	dump_register(DIEPINT(15)),
4428c2ecf20Sopenharmony_ci	dump_register(DOEPINT(0)),
4438c2ecf20Sopenharmony_ci	dump_register(DOEPINT(1)),
4448c2ecf20Sopenharmony_ci	dump_register(DOEPINT(2)),
4458c2ecf20Sopenharmony_ci	dump_register(DOEPINT(3)),
4468c2ecf20Sopenharmony_ci	dump_register(DOEPINT(4)),
4478c2ecf20Sopenharmony_ci	dump_register(DOEPINT(5)),
4488c2ecf20Sopenharmony_ci	dump_register(DOEPINT(6)),
4498c2ecf20Sopenharmony_ci	dump_register(DOEPINT(7)),
4508c2ecf20Sopenharmony_ci	dump_register(DOEPINT(8)),
4518c2ecf20Sopenharmony_ci	dump_register(DOEPINT(9)),
4528c2ecf20Sopenharmony_ci	dump_register(DOEPINT(10)),
4538c2ecf20Sopenharmony_ci	dump_register(DOEPINT(11)),
4548c2ecf20Sopenharmony_ci	dump_register(DOEPINT(12)),
4558c2ecf20Sopenharmony_ci	dump_register(DOEPINT(13)),
4568c2ecf20Sopenharmony_ci	dump_register(DOEPINT(14)),
4578c2ecf20Sopenharmony_ci	dump_register(DOEPINT(15)),
4588c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(0)),
4598c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(1)),
4608c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(2)),
4618c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(3)),
4628c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(4)),
4638c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(5)),
4648c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(6)),
4658c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(7)),
4668c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(8)),
4678c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(9)),
4688c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(10)),
4698c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(11)),
4708c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(12)),
4718c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(13)),
4728c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(14)),
4738c2ecf20Sopenharmony_ci	dump_register(DIEPTSIZ(15)),
4748c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(0)),
4758c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(1)),
4768c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(2)),
4778c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(3)),
4788c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(4)),
4798c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(5)),
4808c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(6)),
4818c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(7)),
4828c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(8)),
4838c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(9)),
4848c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(10)),
4858c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(11)),
4868c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(12)),
4878c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(13)),
4888c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(14)),
4898c2ecf20Sopenharmony_ci	dump_register(DOEPTSIZ(15)),
4908c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(0)),
4918c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(1)),
4928c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(2)),
4938c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(3)),
4948c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(4)),
4958c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(5)),
4968c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(6)),
4978c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(7)),
4988c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(8)),
4998c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(9)),
5008c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(10)),
5018c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(11)),
5028c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(12)),
5038c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(13)),
5048c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(14)),
5058c2ecf20Sopenharmony_ci	dump_register(DIEPDMA(15)),
5068c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(0)),
5078c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(1)),
5088c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(2)),
5098c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(3)),
5108c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(4)),
5118c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(5)),
5128c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(6)),
5138c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(7)),
5148c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(8)),
5158c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(9)),
5168c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(10)),
5178c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(11)),
5188c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(12)),
5198c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(13)),
5208c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(14)),
5218c2ecf20Sopenharmony_ci	dump_register(DOEPDMA(15)),
5228c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(0)),
5238c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(1)),
5248c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(2)),
5258c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(3)),
5268c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(4)),
5278c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(5)),
5288c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(6)),
5298c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(7)),
5308c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(8)),
5318c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(9)),
5328c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(10)),
5338c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(11)),
5348c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(12)),
5358c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(13)),
5368c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(14)),
5378c2ecf20Sopenharmony_ci	dump_register(DTXFSTS(15)),
5388c2ecf20Sopenharmony_ci	dump_register(PCGCTL),
5398c2ecf20Sopenharmony_ci	dump_register(HCFG),
5408c2ecf20Sopenharmony_ci	dump_register(HFIR),
5418c2ecf20Sopenharmony_ci	dump_register(HFNUM),
5428c2ecf20Sopenharmony_ci	dump_register(HPTXSTS),
5438c2ecf20Sopenharmony_ci	dump_register(HAINT),
5448c2ecf20Sopenharmony_ci	dump_register(HAINTMSK),
5458c2ecf20Sopenharmony_ci	dump_register(HFLBADDR),
5468c2ecf20Sopenharmony_ci	dump_register(HPRT0),
5478c2ecf20Sopenharmony_ci	dump_register(HCCHAR(0)),
5488c2ecf20Sopenharmony_ci	dump_register(HCCHAR(1)),
5498c2ecf20Sopenharmony_ci	dump_register(HCCHAR(2)),
5508c2ecf20Sopenharmony_ci	dump_register(HCCHAR(3)),
5518c2ecf20Sopenharmony_ci	dump_register(HCCHAR(4)),
5528c2ecf20Sopenharmony_ci	dump_register(HCCHAR(5)),
5538c2ecf20Sopenharmony_ci	dump_register(HCCHAR(6)),
5548c2ecf20Sopenharmony_ci	dump_register(HCCHAR(7)),
5558c2ecf20Sopenharmony_ci	dump_register(HCCHAR(8)),
5568c2ecf20Sopenharmony_ci	dump_register(HCCHAR(9)),
5578c2ecf20Sopenharmony_ci	dump_register(HCCHAR(10)),
5588c2ecf20Sopenharmony_ci	dump_register(HCCHAR(11)),
5598c2ecf20Sopenharmony_ci	dump_register(HCCHAR(12)),
5608c2ecf20Sopenharmony_ci	dump_register(HCCHAR(13)),
5618c2ecf20Sopenharmony_ci	dump_register(HCCHAR(14)),
5628c2ecf20Sopenharmony_ci	dump_register(HCCHAR(15)),
5638c2ecf20Sopenharmony_ci	dump_register(HCSPLT(0)),
5648c2ecf20Sopenharmony_ci	dump_register(HCSPLT(1)),
5658c2ecf20Sopenharmony_ci	dump_register(HCSPLT(2)),
5668c2ecf20Sopenharmony_ci	dump_register(HCSPLT(3)),
5678c2ecf20Sopenharmony_ci	dump_register(HCSPLT(4)),
5688c2ecf20Sopenharmony_ci	dump_register(HCSPLT(5)),
5698c2ecf20Sopenharmony_ci	dump_register(HCSPLT(6)),
5708c2ecf20Sopenharmony_ci	dump_register(HCSPLT(7)),
5718c2ecf20Sopenharmony_ci	dump_register(HCSPLT(8)),
5728c2ecf20Sopenharmony_ci	dump_register(HCSPLT(9)),
5738c2ecf20Sopenharmony_ci	dump_register(HCSPLT(10)),
5748c2ecf20Sopenharmony_ci	dump_register(HCSPLT(11)),
5758c2ecf20Sopenharmony_ci	dump_register(HCSPLT(12)),
5768c2ecf20Sopenharmony_ci	dump_register(HCSPLT(13)),
5778c2ecf20Sopenharmony_ci	dump_register(HCSPLT(14)),
5788c2ecf20Sopenharmony_ci	dump_register(HCSPLT(15)),
5798c2ecf20Sopenharmony_ci	dump_register(HCINT(0)),
5808c2ecf20Sopenharmony_ci	dump_register(HCINT(1)),
5818c2ecf20Sopenharmony_ci	dump_register(HCINT(2)),
5828c2ecf20Sopenharmony_ci	dump_register(HCINT(3)),
5838c2ecf20Sopenharmony_ci	dump_register(HCINT(4)),
5848c2ecf20Sopenharmony_ci	dump_register(HCINT(5)),
5858c2ecf20Sopenharmony_ci	dump_register(HCINT(6)),
5868c2ecf20Sopenharmony_ci	dump_register(HCINT(7)),
5878c2ecf20Sopenharmony_ci	dump_register(HCINT(8)),
5888c2ecf20Sopenharmony_ci	dump_register(HCINT(9)),
5898c2ecf20Sopenharmony_ci	dump_register(HCINT(10)),
5908c2ecf20Sopenharmony_ci	dump_register(HCINT(11)),
5918c2ecf20Sopenharmony_ci	dump_register(HCINT(12)),
5928c2ecf20Sopenharmony_ci	dump_register(HCINT(13)),
5938c2ecf20Sopenharmony_ci	dump_register(HCINT(14)),
5948c2ecf20Sopenharmony_ci	dump_register(HCINT(15)),
5958c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(0)),
5968c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(1)),
5978c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(2)),
5988c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(3)),
5998c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(4)),
6008c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(5)),
6018c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(6)),
6028c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(7)),
6038c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(8)),
6048c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(9)),
6058c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(10)),
6068c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(11)),
6078c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(12)),
6088c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(13)),
6098c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(14)),
6108c2ecf20Sopenharmony_ci	dump_register(HCINTMSK(15)),
6118c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(0)),
6128c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(1)),
6138c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(2)),
6148c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(3)),
6158c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(4)),
6168c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(5)),
6178c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(6)),
6188c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(7)),
6198c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(8)),
6208c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(9)),
6218c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(10)),
6228c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(11)),
6238c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(12)),
6248c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(13)),
6258c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(14)),
6268c2ecf20Sopenharmony_ci	dump_register(HCTSIZ(15)),
6278c2ecf20Sopenharmony_ci	dump_register(HCDMA(0)),
6288c2ecf20Sopenharmony_ci	dump_register(HCDMA(1)),
6298c2ecf20Sopenharmony_ci	dump_register(HCDMA(2)),
6308c2ecf20Sopenharmony_ci	dump_register(HCDMA(3)),
6318c2ecf20Sopenharmony_ci	dump_register(HCDMA(4)),
6328c2ecf20Sopenharmony_ci	dump_register(HCDMA(5)),
6338c2ecf20Sopenharmony_ci	dump_register(HCDMA(6)),
6348c2ecf20Sopenharmony_ci	dump_register(HCDMA(7)),
6358c2ecf20Sopenharmony_ci	dump_register(HCDMA(8)),
6368c2ecf20Sopenharmony_ci	dump_register(HCDMA(9)),
6378c2ecf20Sopenharmony_ci	dump_register(HCDMA(10)),
6388c2ecf20Sopenharmony_ci	dump_register(HCDMA(11)),
6398c2ecf20Sopenharmony_ci	dump_register(HCDMA(12)),
6408c2ecf20Sopenharmony_ci	dump_register(HCDMA(13)),
6418c2ecf20Sopenharmony_ci	dump_register(HCDMA(14)),
6428c2ecf20Sopenharmony_ci	dump_register(HCDMA(15)),
6438c2ecf20Sopenharmony_ci	dump_register(HCDMAB(0)),
6448c2ecf20Sopenharmony_ci	dump_register(HCDMAB(1)),
6458c2ecf20Sopenharmony_ci	dump_register(HCDMAB(2)),
6468c2ecf20Sopenharmony_ci	dump_register(HCDMAB(3)),
6478c2ecf20Sopenharmony_ci	dump_register(HCDMAB(4)),
6488c2ecf20Sopenharmony_ci	dump_register(HCDMAB(5)),
6498c2ecf20Sopenharmony_ci	dump_register(HCDMAB(6)),
6508c2ecf20Sopenharmony_ci	dump_register(HCDMAB(7)),
6518c2ecf20Sopenharmony_ci	dump_register(HCDMAB(8)),
6528c2ecf20Sopenharmony_ci	dump_register(HCDMAB(9)),
6538c2ecf20Sopenharmony_ci	dump_register(HCDMAB(10)),
6548c2ecf20Sopenharmony_ci	dump_register(HCDMAB(11)),
6558c2ecf20Sopenharmony_ci	dump_register(HCDMAB(12)),
6568c2ecf20Sopenharmony_ci	dump_register(HCDMAB(13)),
6578c2ecf20Sopenharmony_ci	dump_register(HCDMAB(14)),
6588c2ecf20Sopenharmony_ci	dump_register(HCDMAB(15)),
6598c2ecf20Sopenharmony_ci};
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_ci#define print_param(_seq, _ptr, _param) \
6628c2ecf20Sopenharmony_ciseq_printf((_seq), "%-30s: %d\n", #_param, (_ptr)->_param)
6638c2ecf20Sopenharmony_ci
6648c2ecf20Sopenharmony_ci#define print_param_hex(_seq, _ptr, _param) \
6658c2ecf20Sopenharmony_ciseq_printf((_seq), "%-30s: 0x%x\n", #_param, (_ptr)->_param)
6668c2ecf20Sopenharmony_ci
6678c2ecf20Sopenharmony_cistatic int params_show(struct seq_file *seq, void *v)
6688c2ecf20Sopenharmony_ci{
6698c2ecf20Sopenharmony_ci	struct dwc2_hsotg *hsotg = seq->private;
6708c2ecf20Sopenharmony_ci	struct dwc2_core_params *p = &hsotg->params;
6718c2ecf20Sopenharmony_ci	int i;
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_ci	print_param(seq, p, otg_cap);
6748c2ecf20Sopenharmony_ci	print_param(seq, p, dma_desc_enable);
6758c2ecf20Sopenharmony_ci	print_param(seq, p, dma_desc_fs_enable);
6768c2ecf20Sopenharmony_ci	print_param(seq, p, speed);
6778c2ecf20Sopenharmony_ci	print_param(seq, p, enable_dynamic_fifo);
6788c2ecf20Sopenharmony_ci	print_param(seq, p, en_multiple_tx_fifo);
6798c2ecf20Sopenharmony_ci	print_param(seq, p, host_rx_fifo_size);
6808c2ecf20Sopenharmony_ci	print_param(seq, p, host_nperio_tx_fifo_size);
6818c2ecf20Sopenharmony_ci	print_param(seq, p, host_perio_tx_fifo_size);
6828c2ecf20Sopenharmony_ci	print_param(seq, p, max_transfer_size);
6838c2ecf20Sopenharmony_ci	print_param(seq, p, max_packet_count);
6848c2ecf20Sopenharmony_ci	print_param(seq, p, host_channels);
6858c2ecf20Sopenharmony_ci	print_param(seq, p, phy_type);
6868c2ecf20Sopenharmony_ci	print_param(seq, p, phy_utmi_width);
6878c2ecf20Sopenharmony_ci	print_param(seq, p, phy_ulpi_ddr);
6888c2ecf20Sopenharmony_ci	print_param(seq, p, phy_ulpi_ext_vbus);
6898c2ecf20Sopenharmony_ci	print_param(seq, p, i2c_enable);
6908c2ecf20Sopenharmony_ci	print_param(seq, p, ipg_isoc_en);
6918c2ecf20Sopenharmony_ci	print_param(seq, p, ulpi_fs_ls);
6928c2ecf20Sopenharmony_ci	print_param(seq, p, host_support_fs_ls_low_power);
6938c2ecf20Sopenharmony_ci	print_param(seq, p, host_ls_low_power_phy_clk);
6948c2ecf20Sopenharmony_ci	print_param(seq, p, ts_dline);
6958c2ecf20Sopenharmony_ci	print_param(seq, p, reload_ctl);
6968c2ecf20Sopenharmony_ci	print_param_hex(seq, p, ahbcfg);
6978c2ecf20Sopenharmony_ci	print_param(seq, p, uframe_sched);
6988c2ecf20Sopenharmony_ci	print_param(seq, p, external_id_pin_ctl);
6998c2ecf20Sopenharmony_ci	print_param(seq, p, power_down);
7008c2ecf20Sopenharmony_ci	print_param(seq, p, lpm);
7018c2ecf20Sopenharmony_ci	print_param(seq, p, lpm_clock_gating);
7028c2ecf20Sopenharmony_ci	print_param(seq, p, besl);
7038c2ecf20Sopenharmony_ci	print_param(seq, p, hird_threshold_en);
7048c2ecf20Sopenharmony_ci	print_param(seq, p, hird_threshold);
7058c2ecf20Sopenharmony_ci	print_param(seq, p, service_interval);
7068c2ecf20Sopenharmony_ci	print_param(seq, p, host_dma);
7078c2ecf20Sopenharmony_ci	print_param(seq, p, g_dma);
7088c2ecf20Sopenharmony_ci	print_param(seq, p, g_dma_desc);
7098c2ecf20Sopenharmony_ci	print_param(seq, p, g_rx_fifo_size);
7108c2ecf20Sopenharmony_ci	print_param(seq, p, g_np_tx_fifo_size);
7118c2ecf20Sopenharmony_ci
7128c2ecf20Sopenharmony_ci	for (i = 0; i < MAX_EPS_CHANNELS; i++) {
7138c2ecf20Sopenharmony_ci		char str[32];
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ci		snprintf(str, 32, "g_tx_fifo_size[%d]", i);
7168c2ecf20Sopenharmony_ci		seq_printf(seq, "%-30s: %d\n", str, p->g_tx_fifo_size[i]);
7178c2ecf20Sopenharmony_ci	}
7188c2ecf20Sopenharmony_ci
7198c2ecf20Sopenharmony_ci	return 0;
7208c2ecf20Sopenharmony_ci}
7218c2ecf20Sopenharmony_ciDEFINE_SHOW_ATTRIBUTE(params);
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_cistatic int hw_params_show(struct seq_file *seq, void *v)
7248c2ecf20Sopenharmony_ci{
7258c2ecf20Sopenharmony_ci	struct dwc2_hsotg *hsotg = seq->private;
7268c2ecf20Sopenharmony_ci	struct dwc2_hw_params *hw = &hsotg->hw_params;
7278c2ecf20Sopenharmony_ci
7288c2ecf20Sopenharmony_ci	print_param(seq, hw, op_mode);
7298c2ecf20Sopenharmony_ci	print_param(seq, hw, arch);
7308c2ecf20Sopenharmony_ci	print_param(seq, hw, dma_desc_enable);
7318c2ecf20Sopenharmony_ci	print_param(seq, hw, enable_dynamic_fifo);
7328c2ecf20Sopenharmony_ci	print_param(seq, hw, en_multiple_tx_fifo);
7338c2ecf20Sopenharmony_ci	print_param(seq, hw, rx_fifo_size);
7348c2ecf20Sopenharmony_ci	print_param(seq, hw, host_nperio_tx_fifo_size);
7358c2ecf20Sopenharmony_ci	print_param(seq, hw, dev_nperio_tx_fifo_size);
7368c2ecf20Sopenharmony_ci	print_param(seq, hw, host_perio_tx_fifo_size);
7378c2ecf20Sopenharmony_ci	print_param(seq, hw, nperio_tx_q_depth);
7388c2ecf20Sopenharmony_ci	print_param(seq, hw, host_perio_tx_q_depth);
7398c2ecf20Sopenharmony_ci	print_param(seq, hw, dev_token_q_depth);
7408c2ecf20Sopenharmony_ci	print_param(seq, hw, max_transfer_size);
7418c2ecf20Sopenharmony_ci	print_param(seq, hw, max_packet_count);
7428c2ecf20Sopenharmony_ci	print_param(seq, hw, host_channels);
7438c2ecf20Sopenharmony_ci	print_param(seq, hw, hs_phy_type);
7448c2ecf20Sopenharmony_ci	print_param(seq, hw, fs_phy_type);
7458c2ecf20Sopenharmony_ci	print_param(seq, hw, i2c_enable);
7468c2ecf20Sopenharmony_ci	print_param(seq, hw, num_dev_ep);
7478c2ecf20Sopenharmony_ci	print_param(seq, hw, num_dev_perio_in_ep);
7488c2ecf20Sopenharmony_ci	print_param(seq, hw, total_fifo_size);
7498c2ecf20Sopenharmony_ci	print_param(seq, hw, power_optimized);
7508c2ecf20Sopenharmony_ci	print_param(seq, hw, utmi_phy_data_width);
7518c2ecf20Sopenharmony_ci	print_param_hex(seq, hw, snpsid);
7528c2ecf20Sopenharmony_ci	print_param_hex(seq, hw, dev_ep_dirs);
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_ci	return 0;
7558c2ecf20Sopenharmony_ci}
7568c2ecf20Sopenharmony_ciDEFINE_SHOW_ATTRIBUTE(hw_params);
7578c2ecf20Sopenharmony_ci
7588c2ecf20Sopenharmony_cistatic int dr_mode_show(struct seq_file *seq, void *v)
7598c2ecf20Sopenharmony_ci{
7608c2ecf20Sopenharmony_ci	struct dwc2_hsotg *hsotg = seq->private;
7618c2ecf20Sopenharmony_ci	const char *dr_mode = "";
7628c2ecf20Sopenharmony_ci
7638c2ecf20Sopenharmony_ci	device_property_read_string(hsotg->dev, "dr_mode", &dr_mode);
7648c2ecf20Sopenharmony_ci	seq_printf(seq, "%s\n", dr_mode);
7658c2ecf20Sopenharmony_ci	return 0;
7668c2ecf20Sopenharmony_ci}
7678c2ecf20Sopenharmony_ciDEFINE_SHOW_ATTRIBUTE(dr_mode);
7688c2ecf20Sopenharmony_ci
7698c2ecf20Sopenharmony_ciint dwc2_debugfs_init(struct dwc2_hsotg *hsotg)
7708c2ecf20Sopenharmony_ci{
7718c2ecf20Sopenharmony_ci	int			ret;
7728c2ecf20Sopenharmony_ci	struct dentry		*root;
7738c2ecf20Sopenharmony_ci
7748c2ecf20Sopenharmony_ci	root = debugfs_create_dir(dev_name(hsotg->dev), usb_debug_root);
7758c2ecf20Sopenharmony_ci	hsotg->debug_root = root;
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci	debugfs_create_file("params", 0444, root, hsotg, &params_fops);
7788c2ecf20Sopenharmony_ci	debugfs_create_file("hw_params", 0444, root, hsotg, &hw_params_fops);
7798c2ecf20Sopenharmony_ci	debugfs_create_file("dr_mode", 0444, root, hsotg, &dr_mode_fops);
7808c2ecf20Sopenharmony_ci
7818c2ecf20Sopenharmony_ci	/* Add gadget debugfs nodes */
7828c2ecf20Sopenharmony_ci	dwc2_hsotg_create_debug(hsotg);
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_ci	hsotg->regset = devm_kzalloc(hsotg->dev, sizeof(*hsotg->regset),
7858c2ecf20Sopenharmony_ci								GFP_KERNEL);
7868c2ecf20Sopenharmony_ci	if (!hsotg->regset) {
7878c2ecf20Sopenharmony_ci		ret = -ENOMEM;
7888c2ecf20Sopenharmony_ci		goto err;
7898c2ecf20Sopenharmony_ci	}
7908c2ecf20Sopenharmony_ci
7918c2ecf20Sopenharmony_ci	hsotg->regset->regs = dwc2_regs;
7928c2ecf20Sopenharmony_ci	hsotg->regset->nregs = ARRAY_SIZE(dwc2_regs);
7938c2ecf20Sopenharmony_ci	hsotg->regset->base = hsotg->regs;
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ci	debugfs_create_regset32("regdump", 0444, root, hsotg->regset);
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_ci	return 0;
7988c2ecf20Sopenharmony_cierr:
7998c2ecf20Sopenharmony_ci	debugfs_remove_recursive(hsotg->debug_root);
8008c2ecf20Sopenharmony_ci	return ret;
8018c2ecf20Sopenharmony_ci}
8028c2ecf20Sopenharmony_ci
8038c2ecf20Sopenharmony_civoid dwc2_debugfs_exit(struct dwc2_hsotg *hsotg)
8048c2ecf20Sopenharmony_ci{
8058c2ecf20Sopenharmony_ci	debugfs_remove_recursive(hsotg->debug_root);
8068c2ecf20Sopenharmony_ci	hsotg->debug_root = NULL;
8078c2ecf20Sopenharmony_ci}
808