xref: /openbmc/linux/drivers/usb/musb/musb_debugfs.c (revision 6658a62e)
15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
27f7f9e2aSFelipe Balbi /*
37f7f9e2aSFelipe Balbi  * MUSB OTG driver debugfs support
47f7f9e2aSFelipe Balbi  *
57f7f9e2aSFelipe Balbi  * Copyright 2010 Nokia Corporation
67f7f9e2aSFelipe Balbi  * Contact: Felipe Balbi <felipe.balbi@nokia.com>
77f7f9e2aSFelipe Balbi  */
87f7f9e2aSFelipe Balbi 
97f7f9e2aSFelipe Balbi #include <linux/module.h>
107f7f9e2aSFelipe Balbi #include <linux/kernel.h>
117f7f9e2aSFelipe Balbi #include <linux/init.h>
127f7f9e2aSFelipe Balbi #include <linux/debugfs.h>
137f7f9e2aSFelipe Balbi #include <linux/seq_file.h>
147f7f9e2aSFelipe Balbi 
157c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
167f7f9e2aSFelipe Balbi 
177f7f9e2aSFelipe Balbi #include "musb_core.h"
187f7f9e2aSFelipe Balbi #include "musb_debug.h"
197f7f9e2aSFelipe Balbi 
207f7f9e2aSFelipe Balbi struct musb_register_map {
217f7f9e2aSFelipe Balbi 	char			*name;
227f7f9e2aSFelipe Balbi 	unsigned		offset;
237f7f9e2aSFelipe Balbi 	unsigned		size;
247f7f9e2aSFelipe Balbi };
257f7f9e2aSFelipe Balbi 
267f7f9e2aSFelipe Balbi static const struct musb_register_map musb_regmap[] = {
27c2365ce5SRoman Byshko 	{ "FAddr",	MUSB_FADDR,	8 },
28c2365ce5SRoman Byshko 	{ "Power",	MUSB_POWER,	8 },
29c2365ce5SRoman Byshko 	{ "Frame",	MUSB_FRAME,	16 },
30c2365ce5SRoman Byshko 	{ "Index",	MUSB_INDEX,	8 },
31c2365ce5SRoman Byshko 	{ "Testmode",	MUSB_TESTMODE,	8 },
32c2365ce5SRoman Byshko 	{ "TxMaxPp",	MUSB_TXMAXP,	16 },
33c2365ce5SRoman Byshko 	{ "TxCSRp",	MUSB_TXCSR,	16 },
34c2365ce5SRoman Byshko 	{ "RxMaxPp",	MUSB_RXMAXP,	16 },
35c2365ce5SRoman Byshko 	{ "RxCSR",	MUSB_RXCSR,	16 },
36c2365ce5SRoman Byshko 	{ "RxCount",	MUSB_RXCOUNT,	16 },
37c2365ce5SRoman Byshko 	{ "IntrRxE",	MUSB_INTRRXE,	16 },
38c2365ce5SRoman Byshko 	{ "IntrTxE",	MUSB_INTRTXE,	16 },
39c2365ce5SRoman Byshko 	{ "IntrUsbE",	MUSB_INTRUSBE,	8 },
40c2365ce5SRoman Byshko 	{ "DevCtl",	MUSB_DEVCTL,	8 },
417f7f9e2aSFelipe Balbi 	{ "VControl",	0x68,		32 },
42*6658a62eSXingxing Luo 	{ "HWVers",	MUSB_HWVERS,	16 },
43c2365ce5SRoman Byshko 	{ "LinkInfo",	MUSB_LINKINFO,	8 },
44c2365ce5SRoman Byshko 	{ "VPLen",	MUSB_VPLEN,	8 },
45c2365ce5SRoman Byshko 	{ "HS_EOF1",	MUSB_HS_EOF1,	8 },
46c2365ce5SRoman Byshko 	{ "FS_EOF1",	MUSB_FS_EOF1,	8 },
47c2365ce5SRoman Byshko 	{ "LS_EOF1",	MUSB_LS_EOF1,	8 },
487f7f9e2aSFelipe Balbi 	{ "SOFT_RST",	0x7F,		8 },
497f7f9e2aSFelipe Balbi 	{ "DMA_CNTLch0",	0x204,	16 },
500936fb5eSAnand Gadiyar 	{ "DMA_ADDRch0",	0x208,	32 },
510936fb5eSAnand Gadiyar 	{ "DMA_COUNTch0",	0x20C,	32 },
527f7f9e2aSFelipe Balbi 	{ "DMA_CNTLch1",	0x214,	16 },
530936fb5eSAnand Gadiyar 	{ "DMA_ADDRch1",	0x218,	32 },
540936fb5eSAnand Gadiyar 	{ "DMA_COUNTch1",	0x21C,	32 },
557f7f9e2aSFelipe Balbi 	{ "DMA_CNTLch2",	0x224,	16 },
560936fb5eSAnand Gadiyar 	{ "DMA_ADDRch2",	0x228,	32 },
570936fb5eSAnand Gadiyar 	{ "DMA_COUNTch2",	0x22C,	32 },
587f7f9e2aSFelipe Balbi 	{ "DMA_CNTLch3",	0x234,	16 },
590936fb5eSAnand Gadiyar 	{ "DMA_ADDRch3",	0x238,	32 },
600936fb5eSAnand Gadiyar 	{ "DMA_COUNTch3",	0x23C,	32 },
617f7f9e2aSFelipe Balbi 	{ "DMA_CNTLch4",	0x244,	16 },
620936fb5eSAnand Gadiyar 	{ "DMA_ADDRch4",	0x248,	32 },
630936fb5eSAnand Gadiyar 	{ "DMA_COUNTch4",	0x24C,	32 },
647f7f9e2aSFelipe Balbi 	{ "DMA_CNTLch5",	0x254,	16 },
650936fb5eSAnand Gadiyar 	{ "DMA_ADDRch5",	0x258,	32 },
660936fb5eSAnand Gadiyar 	{ "DMA_COUNTch5",	0x25C,	32 },
677f7f9e2aSFelipe Balbi 	{ "DMA_CNTLch6",	0x264,	16 },
680936fb5eSAnand Gadiyar 	{ "DMA_ADDRch6",	0x268,	32 },
690936fb5eSAnand Gadiyar 	{ "DMA_COUNTch6",	0x26C,	32 },
707f7f9e2aSFelipe Balbi 	{ "DMA_CNTLch7",	0x274,	16 },
710936fb5eSAnand Gadiyar 	{ "DMA_ADDRch7",	0x278,	32 },
720936fb5eSAnand Gadiyar 	{ "DMA_COUNTch7",	0x27C,	32 },
73449a7e99SFelipe Balbi 	{ "ConfigData",	MUSB_CONFIGDATA,8 },
74449a7e99SFelipe Balbi 	{ "BabbleCtl",	MUSB_BABBLE_CTL,8 },
75449a7e99SFelipe Balbi 	{ "TxFIFOsz",	MUSB_TXFIFOSZ,	8 },
76449a7e99SFelipe Balbi 	{ "RxFIFOsz",	MUSB_RXFIFOSZ,	8 },
77449a7e99SFelipe Balbi 	{ "TxFIFOadd",	MUSB_TXFIFOADD,	16 },
78449a7e99SFelipe Balbi 	{ "RxFIFOadd",	MUSB_RXFIFOADD,	16 },
79449a7e99SFelipe Balbi 	{ "EPInfo",	MUSB_EPINFO,	8 },
80449a7e99SFelipe Balbi 	{ "RAMInfo",	MUSB_RAMINFO,	8 },
817f7f9e2aSFelipe Balbi 	{  }	/* Terminating Entry */
827f7f9e2aSFelipe Balbi };
837f7f9e2aSFelipe Balbi 
musb_regdump_show(struct seq_file * s,void * unused)847f7f9e2aSFelipe Balbi static int musb_regdump_show(struct seq_file *s, void *unused)
857f7f9e2aSFelipe Balbi {
867f7f9e2aSFelipe Balbi 	struct musb		*musb = s->private;
877f7f9e2aSFelipe Balbi 	unsigned		i;
887f7f9e2aSFelipe Balbi 
897f7f9e2aSFelipe Balbi 	seq_printf(s, "MUSB (M)HDRC Register Dump\n");
907b6c1b4cSBin Liu 	pm_runtime_get_sync(musb->controller);
917f7f9e2aSFelipe Balbi 
927f7f9e2aSFelipe Balbi 	for (i = 0; i < ARRAY_SIZE(musb_regmap); i++) {
937f7f9e2aSFelipe Balbi 		switch (musb_regmap[i].size) {
947f7f9e2aSFelipe Balbi 		case 8:
957f7f9e2aSFelipe Balbi 			seq_printf(s, "%-12s: %02x\n", musb_regmap[i].name,
967f7f9e2aSFelipe Balbi 					musb_readb(musb->mregs, musb_regmap[i].offset));
977f7f9e2aSFelipe Balbi 			break;
987f7f9e2aSFelipe Balbi 		case 16:
997f7f9e2aSFelipe Balbi 			seq_printf(s, "%-12s: %04x\n", musb_regmap[i].name,
1007f7f9e2aSFelipe Balbi 					musb_readw(musb->mregs, musb_regmap[i].offset));
1017f7f9e2aSFelipe Balbi 			break;
1027f7f9e2aSFelipe Balbi 		case 32:
1037f7f9e2aSFelipe Balbi 			seq_printf(s, "%-12s: %08x\n", musb_regmap[i].name,
1047f7f9e2aSFelipe Balbi 					musb_readl(musb->mregs, musb_regmap[i].offset));
1057f7f9e2aSFelipe Balbi 			break;
1067f7f9e2aSFelipe Balbi 		}
1077f7f9e2aSFelipe Balbi 	}
1087f7f9e2aSFelipe Balbi 
1097b6c1b4cSBin Liu 	pm_runtime_mark_last_busy(musb->controller);
1107b6c1b4cSBin Liu 	pm_runtime_put_autosuspend(musb->controller);
1117f7f9e2aSFelipe Balbi 	return 0;
1127f7f9e2aSFelipe Balbi }
113efb85c4dSAndy Shevchenko DEFINE_SHOW_ATTRIBUTE(musb_regdump);
1147f7f9e2aSFelipe Balbi 
musb_test_mode_show(struct seq_file * s,void * unused)1157f7f9e2aSFelipe Balbi static int musb_test_mode_show(struct seq_file *s, void *unused)
1167f7f9e2aSFelipe Balbi {
1177f7f9e2aSFelipe Balbi 	struct musb		*musb = s->private;
1187f7f9e2aSFelipe Balbi 	unsigned		test;
1197f7f9e2aSFelipe Balbi 
1207b6c1b4cSBin Liu 	pm_runtime_get_sync(musb->controller);
1217f7f9e2aSFelipe Balbi 	test = musb_readb(musb->mregs, MUSB_TESTMODE);
1227b6c1b4cSBin Liu 	pm_runtime_mark_last_busy(musb->controller);
1237b6c1b4cSBin Liu 	pm_runtime_put_autosuspend(musb->controller);
1247f7f9e2aSFelipe Balbi 
1257eebe4ecSPali Rohár 	if (test == (MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_FS))
1267eebe4ecSPali Rohár 		seq_printf(s, "force host full-speed\n");
1277eebe4ecSPali Rohár 
1287eebe4ecSPali Rohár 	else if (test == (MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_HS))
1297eebe4ecSPali Rohár 		seq_printf(s, "force host high-speed\n");
1307eebe4ecSPali Rohár 
1317eebe4ecSPali Rohár 	else if (test == MUSB_TEST_FORCE_HOST)
1327f7f9e2aSFelipe Balbi 		seq_printf(s, "force host\n");
1337f7f9e2aSFelipe Balbi 
1347eebe4ecSPali Rohár 	else if (test == MUSB_TEST_FIFO_ACCESS)
1357f7f9e2aSFelipe Balbi 		seq_printf(s, "fifo access\n");
1367f7f9e2aSFelipe Balbi 
1377eebe4ecSPali Rohár 	else if (test == MUSB_TEST_FORCE_FS)
1387f7f9e2aSFelipe Balbi 		seq_printf(s, "force full-speed\n");
1397f7f9e2aSFelipe Balbi 
1407eebe4ecSPali Rohár 	else if (test == MUSB_TEST_FORCE_HS)
1417f7f9e2aSFelipe Balbi 		seq_printf(s, "force high-speed\n");
1427f7f9e2aSFelipe Balbi 
1437eebe4ecSPali Rohár 	else if (test == MUSB_TEST_PACKET)
1447f7f9e2aSFelipe Balbi 		seq_printf(s, "test packet\n");
1457f7f9e2aSFelipe Balbi 
1467eebe4ecSPali Rohár 	else if (test == MUSB_TEST_K)
1477f7f9e2aSFelipe Balbi 		seq_printf(s, "test K\n");
1487f7f9e2aSFelipe Balbi 
1497eebe4ecSPali Rohár 	else if (test == MUSB_TEST_J)
1507f7f9e2aSFelipe Balbi 		seq_printf(s, "test J\n");
1517f7f9e2aSFelipe Balbi 
1527eebe4ecSPali Rohár 	else if (test == MUSB_TEST_SE0_NAK)
1537f7f9e2aSFelipe Balbi 		seq_printf(s, "test SE0 NAK\n");
1547f7f9e2aSFelipe Balbi 
1557f7f9e2aSFelipe Balbi 	return 0;
1567f7f9e2aSFelipe Balbi }
1577f7f9e2aSFelipe Balbi 
musb_test_mode_open(struct inode * inode,struct file * file)1587f7f9e2aSFelipe Balbi static int musb_test_mode_open(struct inode *inode, struct file *file)
1597f7f9e2aSFelipe Balbi {
1607f7f9e2aSFelipe Balbi 	return single_open(file, musb_test_mode_show, inode->i_private);
1617f7f9e2aSFelipe Balbi }
1627f7f9e2aSFelipe Balbi 
musb_test_mode_write(struct file * file,const char __user * ubuf,size_t count,loff_t * ppos)1637f7f9e2aSFelipe Balbi static ssize_t musb_test_mode_write(struct file *file,
1647f7f9e2aSFelipe Balbi 		const char __user *ubuf, size_t count, loff_t *ppos)
1657f7f9e2aSFelipe Balbi {
166024cfa59SMathias Nyman 	struct seq_file		*s = file->private_data;
167024cfa59SMathias Nyman 	struct musb		*musb = s->private;
168205845efSBin Liu 	u8			test;
1697eebe4ecSPali Rohár 	char			buf[24];
1707f7f9e2aSFelipe Balbi 
171e4befc12SDinghao Liu 	memset(buf, 0x00, sizeof(buf));
172e4befc12SDinghao Liu 
173e4befc12SDinghao Liu 	if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
174e4befc12SDinghao Liu 		return -EFAULT;
175e4befc12SDinghao Liu 
1767b6c1b4cSBin Liu 	pm_runtime_get_sync(musb->controller);
177205845efSBin Liu 	test = musb_readb(musb->mregs, MUSB_TESTMODE);
178205845efSBin Liu 	if (test) {
179205845efSBin Liu 		dev_err(musb->controller, "Error: test mode is already set. "
180205845efSBin Liu 			"Please do USB Bus Reset to start a new test.\n");
1817b6c1b4cSBin Liu 		goto ret;
182205845efSBin Liu 	}
183205845efSBin Liu 
1847eebe4ecSPali Rohár 	if (strstarts(buf, "force host full-speed"))
1857eebe4ecSPali Rohár 		test = MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_FS;
1867eebe4ecSPali Rohár 
1877eebe4ecSPali Rohár 	else if (strstarts(buf, "force host high-speed"))
1887eebe4ecSPali Rohár 		test = MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_HS;
1897eebe4ecSPali Rohár 
1907eebe4ecSPali Rohár 	else if (strstarts(buf, "force host"))
1917f7f9e2aSFelipe Balbi 		test = MUSB_TEST_FORCE_HOST;
1927f7f9e2aSFelipe Balbi 
1937eebe4ecSPali Rohár 	else if (strstarts(buf, "fifo access"))
1947f7f9e2aSFelipe Balbi 		test = MUSB_TEST_FIFO_ACCESS;
1957f7f9e2aSFelipe Balbi 
1967eebe4ecSPali Rohár 	else if (strstarts(buf, "force full-speed"))
1977f7f9e2aSFelipe Balbi 		test = MUSB_TEST_FORCE_FS;
1987f7f9e2aSFelipe Balbi 
1997eebe4ecSPali Rohár 	else if (strstarts(buf, "force high-speed"))
2007f7f9e2aSFelipe Balbi 		test = MUSB_TEST_FORCE_HS;
2017f7f9e2aSFelipe Balbi 
2027eebe4ecSPali Rohár 	else if (strstarts(buf, "test packet")) {
2037f7f9e2aSFelipe Balbi 		test = MUSB_TEST_PACKET;
2047f7f9e2aSFelipe Balbi 		musb_load_testpacket(musb);
2057f7f9e2aSFelipe Balbi 	}
2067f7f9e2aSFelipe Balbi 
2077eebe4ecSPali Rohár 	else if (strstarts(buf, "test K"))
2087f7f9e2aSFelipe Balbi 		test = MUSB_TEST_K;
2097f7f9e2aSFelipe Balbi 
2107eebe4ecSPali Rohár 	else if (strstarts(buf, "test J"))
2117f7f9e2aSFelipe Balbi 		test = MUSB_TEST_J;
2127f7f9e2aSFelipe Balbi 
2137eebe4ecSPali Rohár 	else if (strstarts(buf, "test SE0 NAK"))
2147f7f9e2aSFelipe Balbi 		test = MUSB_TEST_SE0_NAK;
2157f7f9e2aSFelipe Balbi 
2167f7f9e2aSFelipe Balbi 	musb_writeb(musb->mregs, MUSB_TESTMODE, test);
2177f7f9e2aSFelipe Balbi 
2187b6c1b4cSBin Liu ret:
2197b6c1b4cSBin Liu 	pm_runtime_mark_last_busy(musb->controller);
2207b6c1b4cSBin Liu 	pm_runtime_put_autosuspend(musb->controller);
2217f7f9e2aSFelipe Balbi 	return count;
2227f7f9e2aSFelipe Balbi }
2237f7f9e2aSFelipe Balbi 
2247f7f9e2aSFelipe Balbi static const struct file_operations musb_test_mode_fops = {
2257f7f9e2aSFelipe Balbi 	.open			= musb_test_mode_open,
2267f7f9e2aSFelipe Balbi 	.write			= musb_test_mode_write,
2277f7f9e2aSFelipe Balbi 	.read			= seq_read,
2287f7f9e2aSFelipe Balbi 	.llseek			= seq_lseek,
2297f7f9e2aSFelipe Balbi 	.release		= single_release,
2307f7f9e2aSFelipe Balbi };
2317f7f9e2aSFelipe Balbi 
musb_softconnect_show(struct seq_file * s,void * unused)232ffc1d299SBin Liu static int musb_softconnect_show(struct seq_file *s, void *unused)
233ffc1d299SBin Liu {
234ffc1d299SBin Liu 	struct musb	*musb = s->private;
235ffc1d299SBin Liu 	u8		reg;
236ffc1d299SBin Liu 	int		connect;
237ffc1d299SBin Liu 
23821acc656SPaul Cercueil 	switch (musb_get_state(musb)) {
239ffc1d299SBin Liu 	case OTG_STATE_A_HOST:
240ffc1d299SBin Liu 	case OTG_STATE_A_WAIT_BCON:
2417b6c1b4cSBin Liu 		pm_runtime_get_sync(musb->controller);
2427b6c1b4cSBin Liu 
243ffc1d299SBin Liu 		reg = musb_readb(musb->mregs, MUSB_DEVCTL);
244ffc1d299SBin Liu 		connect = reg & MUSB_DEVCTL_SESSION ? 1 : 0;
2457b6c1b4cSBin Liu 
2467b6c1b4cSBin Liu 		pm_runtime_mark_last_busy(musb->controller);
2477b6c1b4cSBin Liu 		pm_runtime_put_autosuspend(musb->controller);
248ffc1d299SBin Liu 		break;
249ffc1d299SBin Liu 	default:
250ffc1d299SBin Liu 		connect = -1;
251ffc1d299SBin Liu 	}
252ffc1d299SBin Liu 
253ffc1d299SBin Liu 	seq_printf(s, "%d\n", connect);
254ffc1d299SBin Liu 
255ffc1d299SBin Liu 	return 0;
256ffc1d299SBin Liu }
257ffc1d299SBin Liu 
musb_softconnect_open(struct inode * inode,struct file * file)258ffc1d299SBin Liu static int musb_softconnect_open(struct inode *inode, struct file *file)
259ffc1d299SBin Liu {
260ffc1d299SBin Liu 	return single_open(file, musb_softconnect_show, inode->i_private);
261ffc1d299SBin Liu }
262ffc1d299SBin Liu 
musb_softconnect_write(struct file * file,const char __user * ubuf,size_t count,loff_t * ppos)263ffc1d299SBin Liu static ssize_t musb_softconnect_write(struct file *file,
264ffc1d299SBin Liu 		const char __user *ubuf, size_t count, loff_t *ppos)
265ffc1d299SBin Liu {
266ffc1d299SBin Liu 	struct seq_file		*s = file->private_data;
267ffc1d299SBin Liu 	struct musb		*musb = s->private;
268ffc1d299SBin Liu 	char			buf[2];
269ffc1d299SBin Liu 	u8			reg;
270ffc1d299SBin Liu 
271ffc1d299SBin Liu 	memset(buf, 0x00, sizeof(buf));
272ffc1d299SBin Liu 
273ffc1d299SBin Liu 	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
274ffc1d299SBin Liu 		return -EFAULT;
275ffc1d299SBin Liu 
2767b6c1b4cSBin Liu 	pm_runtime_get_sync(musb->controller);
277ffc1d299SBin Liu 	if (!strncmp(buf, "0", 1)) {
27821acc656SPaul Cercueil 		switch (musb_get_state(musb)) {
279ffc1d299SBin Liu 		case OTG_STATE_A_HOST:
280ffc1d299SBin Liu 			musb_root_disconnect(musb);
281ffc1d299SBin Liu 			reg = musb_readb(musb->mregs, MUSB_DEVCTL);
282ffc1d299SBin Liu 			reg &= ~MUSB_DEVCTL_SESSION;
283ffc1d299SBin Liu 			musb_writeb(musb->mregs, MUSB_DEVCTL, reg);
284ffc1d299SBin Liu 			break;
285ffc1d299SBin Liu 		default:
286ffc1d299SBin Liu 			break;
287ffc1d299SBin Liu 		}
288ffc1d299SBin Liu 	} else if (!strncmp(buf, "1", 1)) {
28921acc656SPaul Cercueil 		switch (musb_get_state(musb)) {
290ffc1d299SBin Liu 		case OTG_STATE_A_WAIT_BCON:
291ffc1d299SBin Liu 			/*
292ffc1d299SBin Liu 			 * musb_save_context() called in musb_runtime_suspend()
293ffc1d299SBin Liu 			 * might cache devctl with SESSION bit cleared during
294ffc1d299SBin Liu 			 * soft-disconnect, so specifically set SESSION bit
295ffc1d299SBin Liu 			 * here to preserve it for musb_runtime_resume().
296ffc1d299SBin Liu 			 */
297ffc1d299SBin Liu 			musb->context.devctl |= MUSB_DEVCTL_SESSION;
298ffc1d299SBin Liu 			reg = musb_readb(musb->mregs, MUSB_DEVCTL);
299ffc1d299SBin Liu 			reg |= MUSB_DEVCTL_SESSION;
300ffc1d299SBin Liu 			musb_writeb(musb->mregs, MUSB_DEVCTL, reg);
301ffc1d299SBin Liu 			break;
302ffc1d299SBin Liu 		default:
303ffc1d299SBin Liu 			break;
304ffc1d299SBin Liu 		}
305ffc1d299SBin Liu 	}
306ffc1d299SBin Liu 
3077b6c1b4cSBin Liu 	pm_runtime_mark_last_busy(musb->controller);
3087b6c1b4cSBin Liu 	pm_runtime_put_autosuspend(musb->controller);
309ffc1d299SBin Liu 	return count;
310ffc1d299SBin Liu }
311ffc1d299SBin Liu 
312ffc1d299SBin Liu /*
313ffc1d299SBin Liu  * In host mode, connect/disconnect the bus without physically
314ffc1d299SBin Liu  * remove the devices.
315ffc1d299SBin Liu  */
316ffc1d299SBin Liu static const struct file_operations musb_softconnect_fops = {
317ffc1d299SBin Liu 	.open			= musb_softconnect_open,
318ffc1d299SBin Liu 	.write			= musb_softconnect_write,
319ffc1d299SBin Liu 	.read			= seq_read,
320ffc1d299SBin Liu 	.llseek			= seq_lseek,
321ffc1d299SBin Liu 	.release		= single_release,
322ffc1d299SBin Liu };
323ffc1d299SBin Liu 
musb_init_debugfs(struct musb * musb)3248a1ef171SGreg Kroah-Hartman void musb_init_debugfs(struct musb *musb)
3257f7f9e2aSFelipe Balbi {
3267f7f9e2aSFelipe Balbi 	struct dentry *root;
3277f7f9e2aSFelipe Balbi 
328d4836b69SChunfeng Yun 	root = debugfs_create_dir(dev_name(musb->controller), usb_debug_root);
3298d2421e6SAjay Kumar Gupta 	musb->debugfs_root = root;
3307f7f9e2aSFelipe Balbi 
3318a1ef171SGreg Kroah-Hartman 	debugfs_create_file("regdump", S_IRUGO, root, musb, &musb_regdump_fops);
3328a1ef171SGreg Kroah-Hartman 	debugfs_create_file("testmode", S_IRUGO | S_IWUSR, root, musb,
3338a1ef171SGreg Kroah-Hartman 			    &musb_test_mode_fops);
3348a1ef171SGreg Kroah-Hartman 	debugfs_create_file("softconnect", S_IRUGO | S_IWUSR, root, musb,
3358a1ef171SGreg Kroah-Hartman 			    &musb_softconnect_fops);
3367f7f9e2aSFelipe Balbi }
3377f7f9e2aSFelipe Balbi 
musb_exit_debugfs(struct musb * musb)338b0f9da7eSFelipe Balbi void /* __init_or_exit */ musb_exit_debugfs(struct musb *musb)
3397f7f9e2aSFelipe Balbi {
3408d2421e6SAjay Kumar Gupta 	debugfs_remove_recursive(musb->debugfs_root);
3417f7f9e2aSFelipe Balbi }
342