xref: /linux/drivers/soundwire/debugfs.c (revision fdd3d14c)
188ac86f2SPierre-Louis Bossart // SPDX-License-Identifier: GPL-2.0-only
2bf03473dSPierre-Louis Bossart // Copyright(c) 2017-2019 Intel Corporation.
3bf03473dSPierre-Louis Bossart 
4*fdd3d14cSKrzysztof Kozlowski #include <linux/cleanup.h>
5bf03473dSPierre-Louis Bossart #include <linux/device.h>
6bf03473dSPierre-Louis Bossart #include <linux/debugfs.h>
7fe46d2a4SPierre-Louis Bossart #include <linux/firmware.h>
8bf03473dSPierre-Louis Bossart #include <linux/mod_devicetable.h>
9b275bf45SCharles Keepax #include <linux/pm_runtime.h>
10bf03473dSPierre-Louis Bossart #include <linux/slab.h>
11bf03473dSPierre-Louis Bossart #include <linux/soundwire/sdw.h>
12bf03473dSPierre-Louis Bossart #include <linux/soundwire/sdw_registers.h>
13bf03473dSPierre-Louis Bossart #include "bus.h"
14bf03473dSPierre-Louis Bossart 
15bf03473dSPierre-Louis Bossart static struct dentry *sdw_debugfs_root;
16bf03473dSPierre-Louis Bossart 
sdw_bus_debugfs_init(struct sdw_bus * bus)17bf03473dSPierre-Louis Bossart void sdw_bus_debugfs_init(struct sdw_bus *bus)
18bf03473dSPierre-Louis Bossart {
19bf03473dSPierre-Louis Bossart 	char name[16];
20bf03473dSPierre-Louis Bossart 
21bf03473dSPierre-Louis Bossart 	if (!sdw_debugfs_root)
22bf03473dSPierre-Louis Bossart 		return;
23bf03473dSPierre-Louis Bossart 
24bf03473dSPierre-Louis Bossart 	/* create the debugfs master-N */
256543ac13SPierre-Louis Bossart 	snprintf(name, sizeof(name), "master-%d-%d", bus->controller_id, bus->link_id);
26bf03473dSPierre-Louis Bossart 	bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root);
27bf03473dSPierre-Louis Bossart }
28bf03473dSPierre-Louis Bossart 
sdw_bus_debugfs_exit(struct sdw_bus * bus)29bf03473dSPierre-Louis Bossart void sdw_bus_debugfs_exit(struct sdw_bus *bus)
30bf03473dSPierre-Louis Bossart {
31bf03473dSPierre-Louis Bossart 	debugfs_remove_recursive(bus->debugfs);
32bf03473dSPierre-Louis Bossart }
33bf03473dSPierre-Louis Bossart 
34bf03473dSPierre-Louis Bossart #define RD_BUF (3 * PAGE_SIZE)
35bf03473dSPierre-Louis Bossart 
sdw_sprintf(struct sdw_slave * slave,char * buf,size_t pos,unsigned int reg)36bf03473dSPierre-Louis Bossart static ssize_t sdw_sprintf(struct sdw_slave *slave,
37bf03473dSPierre-Louis Bossart 			   char *buf, size_t pos, unsigned int reg)
38bf03473dSPierre-Louis Bossart {
39bf03473dSPierre-Louis Bossart 	int value;
40bf03473dSPierre-Louis Bossart 
41b275bf45SCharles Keepax 	value = sdw_read_no_pm(slave, reg);
42bf03473dSPierre-Louis Bossart 
43bf03473dSPierre-Louis Bossart 	if (value < 0)
44bf03473dSPierre-Louis Bossart 		return scnprintf(buf + pos, RD_BUF - pos, "%3x\tXX\n", reg);
45bf03473dSPierre-Louis Bossart 	else
46bf03473dSPierre-Louis Bossart 		return scnprintf(buf + pos, RD_BUF - pos,
47bf03473dSPierre-Louis Bossart 				"%3x\t%2x\n", reg, value);
48bf03473dSPierre-Louis Bossart }
49bf03473dSPierre-Louis Bossart 
sdw_slave_reg_show(struct seq_file * s_file,void * data)50bf03473dSPierre-Louis Bossart static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
51bf03473dSPierre-Louis Bossart {
52bf03473dSPierre-Louis Bossart 	struct sdw_slave *slave = s_file->private;
53bf03473dSPierre-Louis Bossart 	ssize_t ret;
54bf03473dSPierre-Louis Bossart 	int i, j;
55bf03473dSPierre-Louis Bossart 
56*fdd3d14cSKrzysztof Kozlowski 	char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL);
57bf03473dSPierre-Louis Bossart 	if (!buf)
58bf03473dSPierre-Louis Bossart 		return -ENOMEM;
59bf03473dSPierre-Louis Bossart 
60217f5e0dSKrzysztof Kozlowski 	ret = pm_runtime_get_sync(&slave->dev);
61b275bf45SCharles Keepax 	if (ret < 0 && ret != -EACCES) {
62217f5e0dSKrzysztof Kozlowski 		pm_runtime_put_noidle(&slave->dev);
63b275bf45SCharles Keepax 		return ret;
64b275bf45SCharles Keepax 	}
65b275bf45SCharles Keepax 
66bf03473dSPierre-Louis Bossart 	ret = scnprintf(buf, RD_BUF, "Register  Value\n");
67bf03473dSPierre-Louis Bossart 
68bf03473dSPierre-Louis Bossart 	/* DP0 non-banked registers */
69bf03473dSPierre-Louis Bossart 	ret += scnprintf(buf + ret, RD_BUF - ret, "\nDP0\n");
70bf03473dSPierre-Louis Bossart 	for (i = SDW_DP0_INT; i <= SDW_DP0_PREPARECTRL; i++)
71bf03473dSPierre-Louis Bossart 		ret += sdw_sprintf(slave, buf, ret, i);
72bf03473dSPierre-Louis Bossart 
73bf03473dSPierre-Louis Bossart 	/* DP0 Bank 0 registers */
74bf03473dSPierre-Louis Bossart 	ret += scnprintf(buf + ret, RD_BUF - ret, "Bank0\n");
75bf03473dSPierre-Louis Bossart 	ret += sdw_sprintf(slave, buf, ret, SDW_DP0_CHANNELEN);
76bf03473dSPierre-Louis Bossart 	for (i = SDW_DP0_SAMPLECTRL1; i <= SDW_DP0_LANECTRL; i++)
77bf03473dSPierre-Louis Bossart 		ret += sdw_sprintf(slave, buf, ret, i);
78bf03473dSPierre-Louis Bossart 
79bf03473dSPierre-Louis Bossart 	/* DP0 Bank 1 registers */
80bf03473dSPierre-Louis Bossart 	ret += scnprintf(buf + ret, RD_BUF - ret, "Bank1\n");
81bf03473dSPierre-Louis Bossart 	ret += sdw_sprintf(slave, buf, ret,
82bf03473dSPierre-Louis Bossart 			SDW_DP0_CHANNELEN + SDW_BANK1_OFFSET);
83bf03473dSPierre-Louis Bossart 	for (i = SDW_DP0_SAMPLECTRL1 + SDW_BANK1_OFFSET;
84bf03473dSPierre-Louis Bossart 			i <= SDW_DP0_LANECTRL + SDW_BANK1_OFFSET; i++)
85bf03473dSPierre-Louis Bossart 		ret += sdw_sprintf(slave, buf, ret, i);
86bf03473dSPierre-Louis Bossart 
87bf03473dSPierre-Louis Bossart 	/* SCP registers */
88bf03473dSPierre-Louis Bossart 	ret += scnprintf(buf + ret, RD_BUF - ret, "\nSCP\n");
89038306aaSUday M Bhat 	for (i = SDW_SCP_INT1; i <= SDW_SCP_BUS_CLOCK_BASE; i++)
90bf03473dSPierre-Louis Bossart 		ret += sdw_sprintf(slave, buf, ret, i);
91bf03473dSPierre-Louis Bossart 	for (i = SDW_SCP_DEVID_0; i <= SDW_SCP_DEVID_5; i++)
92bf03473dSPierre-Louis Bossart 		ret += sdw_sprintf(slave, buf, ret, i);
93038306aaSUday M Bhat 	for (i = SDW_SCP_FRAMECTRL_B0; i <= SDW_SCP_BUSCLOCK_SCALE_B0; i++)
94038306aaSUday M Bhat 		ret += sdw_sprintf(slave, buf, ret, i);
95038306aaSUday M Bhat 	for (i = SDW_SCP_FRAMECTRL_B1; i <= SDW_SCP_BUSCLOCK_SCALE_B1; i++)
96038306aaSUday M Bhat 		ret += sdw_sprintf(slave, buf, ret, i);
97038306aaSUday M Bhat 	for (i = SDW_SCP_PHY_OUT_CTRL_0; i <= SDW_SCP_PHY_OUT_CTRL_7; i++)
98038306aaSUday M Bhat 		ret += sdw_sprintf(slave, buf, ret, i);
99038306aaSUday M Bhat 
100bf03473dSPierre-Louis Bossart 
101bf03473dSPierre-Louis Bossart 	/*
102bf03473dSPierre-Louis Bossart 	 * SCP Bank 0/1 registers are read-only and cannot be
103bf03473dSPierre-Louis Bossart 	 * retrieved from the Slave. The Master typically keeps track
104bf03473dSPierre-Louis Bossart 	 * of the current frame size so the information can be found
105bf03473dSPierre-Louis Bossart 	 * in other places
106bf03473dSPierre-Louis Bossart 	 */
107bf03473dSPierre-Louis Bossart 
108bf03473dSPierre-Louis Bossart 	/* DP1..14 registers */
109bf03473dSPierre-Louis Bossart 	for (i = 1; SDW_VALID_PORT_RANGE(i); i++) {
110bf03473dSPierre-Louis Bossart 
111bf03473dSPierre-Louis Bossart 		/* DPi registers */
112bf03473dSPierre-Louis Bossart 		ret += scnprintf(buf + ret, RD_BUF - ret, "\nDP%d\n", i);
113bf03473dSPierre-Louis Bossart 		for (j = SDW_DPN_INT(i); j <= SDW_DPN_PREPARECTRL(i); j++)
114bf03473dSPierre-Louis Bossart 			ret += sdw_sprintf(slave, buf, ret, j);
115bf03473dSPierre-Louis Bossart 
116bf03473dSPierre-Louis Bossart 		/* DPi Bank0 registers */
117bf03473dSPierre-Louis Bossart 		ret += scnprintf(buf + ret, RD_BUF - ret, "Bank0\n");
118bf03473dSPierre-Louis Bossart 		for (j = SDW_DPN_CHANNELEN_B0(i);
119bf03473dSPierre-Louis Bossart 		     j <= SDW_DPN_LANECTRL_B0(i); j++)
120bf03473dSPierre-Louis Bossart 			ret += sdw_sprintf(slave, buf, ret, j);
121bf03473dSPierre-Louis Bossart 
122bf03473dSPierre-Louis Bossart 		/* DPi Bank1 registers */
123bf03473dSPierre-Louis Bossart 		ret += scnprintf(buf + ret, RD_BUF - ret, "Bank1\n");
124bf03473dSPierre-Louis Bossart 		for (j = SDW_DPN_CHANNELEN_B1(i);
125bf03473dSPierre-Louis Bossart 		     j <= SDW_DPN_LANECTRL_B1(i); j++)
126bf03473dSPierre-Louis Bossart 			ret += sdw_sprintf(slave, buf, ret, j);
127bf03473dSPierre-Louis Bossart 	}
128bf03473dSPierre-Louis Bossart 
129bf03473dSPierre-Louis Bossart 	seq_printf(s_file, "%s", buf);
130b275bf45SCharles Keepax 
131b275bf45SCharles Keepax 	pm_runtime_mark_last_busy(&slave->dev);
132b275bf45SCharles Keepax 	pm_runtime_put(&slave->dev);
133b275bf45SCharles Keepax 
134bf03473dSPierre-Louis Bossart 	return 0;
135bf03473dSPierre-Louis Bossart }
136bf03473dSPierre-Louis Bossart DEFINE_SHOW_ATTRIBUTE(sdw_slave_reg);
137bf03473dSPierre-Louis Bossart 
138fe46d2a4SPierre-Louis Bossart #define MAX_CMD_BYTES 256
139fe46d2a4SPierre-Louis Bossart 
140fe46d2a4SPierre-Louis Bossart static int cmd;
141fe46d2a4SPierre-Louis Bossart static u32 start_addr;
142fe46d2a4SPierre-Louis Bossart static size_t num_bytes;
143fe46d2a4SPierre-Louis Bossart static u8 read_buffer[MAX_CMD_BYTES];
144fe46d2a4SPierre-Louis Bossart static char *firmware_file;
145fe46d2a4SPierre-Louis Bossart 
set_command(void * data,u64 value)146fe46d2a4SPierre-Louis Bossart static int set_command(void *data, u64 value)
147fe46d2a4SPierre-Louis Bossart {
148fe46d2a4SPierre-Louis Bossart 	struct sdw_slave *slave = data;
149fe46d2a4SPierre-Louis Bossart 
150fe46d2a4SPierre-Louis Bossart 	if (value > 1)
151fe46d2a4SPierre-Louis Bossart 		return -EINVAL;
152fe46d2a4SPierre-Louis Bossart 
153fe46d2a4SPierre-Louis Bossart 	/* Userspace changed the hardware state behind the kernel's back */
154fe46d2a4SPierre-Louis Bossart 	add_taint(TAINT_USER, LOCKDEP_STILL_OK);
155fe46d2a4SPierre-Louis Bossart 
156fe46d2a4SPierre-Louis Bossart 	dev_dbg(&slave->dev, "command: %s\n", value ? "read" : "write");
157fe46d2a4SPierre-Louis Bossart 	cmd = value;
158fe46d2a4SPierre-Louis Bossart 
159fe46d2a4SPierre-Louis Bossart 	return 0;
160fe46d2a4SPierre-Louis Bossart }
161fe46d2a4SPierre-Louis Bossart DEFINE_DEBUGFS_ATTRIBUTE(set_command_fops, NULL,
162fe46d2a4SPierre-Louis Bossart 			 set_command, "%llu\n");
163fe46d2a4SPierre-Louis Bossart 
set_start_address(void * data,u64 value)164fe46d2a4SPierre-Louis Bossart static int set_start_address(void *data, u64 value)
165fe46d2a4SPierre-Louis Bossart {
166fe46d2a4SPierre-Louis Bossart 	struct sdw_slave *slave = data;
167fe46d2a4SPierre-Louis Bossart 
168fe46d2a4SPierre-Louis Bossart 	/* Userspace changed the hardware state behind the kernel's back */
169fe46d2a4SPierre-Louis Bossart 	add_taint(TAINT_USER, LOCKDEP_STILL_OK);
170fe46d2a4SPierre-Louis Bossart 
171fe46d2a4SPierre-Louis Bossart 	dev_dbg(&slave->dev, "start address %#llx\n", value);
172fe46d2a4SPierre-Louis Bossart 
173fe46d2a4SPierre-Louis Bossart 	start_addr = value;
174fe46d2a4SPierre-Louis Bossart 
175fe46d2a4SPierre-Louis Bossart 	return 0;
176fe46d2a4SPierre-Louis Bossart }
177fe46d2a4SPierre-Louis Bossart DEFINE_DEBUGFS_ATTRIBUTE(set_start_address_fops, NULL,
178fe46d2a4SPierre-Louis Bossart 			 set_start_address, "%llu\n");
179fe46d2a4SPierre-Louis Bossart 
set_num_bytes(void * data,u64 value)180fe46d2a4SPierre-Louis Bossart static int set_num_bytes(void *data, u64 value)
181fe46d2a4SPierre-Louis Bossart {
182fe46d2a4SPierre-Louis Bossart 	struct sdw_slave *slave = data;
183fe46d2a4SPierre-Louis Bossart 
184fe46d2a4SPierre-Louis Bossart 	if (value == 0 || value > MAX_CMD_BYTES)
185fe46d2a4SPierre-Louis Bossart 		return -EINVAL;
186fe46d2a4SPierre-Louis Bossart 
187fe46d2a4SPierre-Louis Bossart 	/* Userspace changed the hardware state behind the kernel's back */
188fe46d2a4SPierre-Louis Bossart 	add_taint(TAINT_USER, LOCKDEP_STILL_OK);
189fe46d2a4SPierre-Louis Bossart 
190fe46d2a4SPierre-Louis Bossart 	dev_dbg(&slave->dev, "number of bytes %lld\n", value);
191fe46d2a4SPierre-Louis Bossart 
192fe46d2a4SPierre-Louis Bossart 	num_bytes = value;
193fe46d2a4SPierre-Louis Bossart 
194fe46d2a4SPierre-Louis Bossart 	return 0;
195fe46d2a4SPierre-Louis Bossart }
196fe46d2a4SPierre-Louis Bossart DEFINE_DEBUGFS_ATTRIBUTE(set_num_bytes_fops, NULL,
197fe46d2a4SPierre-Louis Bossart 			 set_num_bytes, "%llu\n");
198fe46d2a4SPierre-Louis Bossart 
cmd_go(void * data,u64 value)199fe46d2a4SPierre-Louis Bossart static int cmd_go(void *data, u64 value)
200fe46d2a4SPierre-Louis Bossart {
201fe46d2a4SPierre-Louis Bossart 	struct sdw_slave *slave = data;
202fe46d2a4SPierre-Louis Bossart 	int ret;
203fe46d2a4SPierre-Louis Bossart 
204fe46d2a4SPierre-Louis Bossart 	if (value != 1)
205fe46d2a4SPierre-Louis Bossart 		return -EINVAL;
206fe46d2a4SPierre-Louis Bossart 
207fe46d2a4SPierre-Louis Bossart 	/* one last check */
208fe46d2a4SPierre-Louis Bossart 	if (start_addr > SDW_REG_MAX ||
209fe46d2a4SPierre-Louis Bossart 	    num_bytes == 0 || num_bytes > MAX_CMD_BYTES)
210fe46d2a4SPierre-Louis Bossart 		return -EINVAL;
211fe46d2a4SPierre-Louis Bossart 
212fe46d2a4SPierre-Louis Bossart 	ret = pm_runtime_get_sync(&slave->dev);
213fe46d2a4SPierre-Louis Bossart 	if (ret < 0 && ret != -EACCES) {
214fe46d2a4SPierre-Louis Bossart 		pm_runtime_put_noidle(&slave->dev);
215fe46d2a4SPierre-Louis Bossart 		return ret;
216fe46d2a4SPierre-Louis Bossart 	}
217fe46d2a4SPierre-Louis Bossart 
218fe46d2a4SPierre-Louis Bossart 	/* Userspace changed the hardware state behind the kernel's back */
219fe46d2a4SPierre-Louis Bossart 	add_taint(TAINT_USER, LOCKDEP_STILL_OK);
220fe46d2a4SPierre-Louis Bossart 
221fe46d2a4SPierre-Louis Bossart 	dev_dbg(&slave->dev, "starting command\n");
222fe46d2a4SPierre-Louis Bossart 
223fe46d2a4SPierre-Louis Bossart 	if (cmd == 0) {
224fe46d2a4SPierre-Louis Bossart 		const struct firmware *fw;
225fe46d2a4SPierre-Louis Bossart 
226fe46d2a4SPierre-Louis Bossart 		ret = request_firmware(&fw, firmware_file, &slave->dev);
227fe46d2a4SPierre-Louis Bossart 		if (ret < 0) {
228fe46d2a4SPierre-Louis Bossart 			dev_err(&slave->dev, "firmware %s not found\n", firmware_file);
229fe46d2a4SPierre-Louis Bossart 			goto out;
230fe46d2a4SPierre-Louis Bossart 		}
231fe46d2a4SPierre-Louis Bossart 
232fe46d2a4SPierre-Louis Bossart 		if (fw->size != num_bytes) {
233fe46d2a4SPierre-Louis Bossart 			dev_err(&slave->dev,
234fe46d2a4SPierre-Louis Bossart 				"firmware %s: unexpected size %zd, desired %zd\n",
235fe46d2a4SPierre-Louis Bossart 				firmware_file, fw->size, num_bytes);
236fe46d2a4SPierre-Louis Bossart 			release_firmware(fw);
237fe46d2a4SPierre-Louis Bossart 			goto out;
238fe46d2a4SPierre-Louis Bossart 		}
239fe46d2a4SPierre-Louis Bossart 
240fe46d2a4SPierre-Louis Bossart 		ret = sdw_nwrite_no_pm(slave, start_addr, num_bytes, fw->data);
241fe46d2a4SPierre-Louis Bossart 		release_firmware(fw);
242fe46d2a4SPierre-Louis Bossart 	} else {
243fe46d2a4SPierre-Louis Bossart 		ret = sdw_nread_no_pm(slave, start_addr, num_bytes, read_buffer);
244fe46d2a4SPierre-Louis Bossart 	}
245fe46d2a4SPierre-Louis Bossart 
246fe46d2a4SPierre-Louis Bossart 	dev_dbg(&slave->dev, "command completed %d\n", ret);
247fe46d2a4SPierre-Louis Bossart 
248fe46d2a4SPierre-Louis Bossart out:
249fe46d2a4SPierre-Louis Bossart 	pm_runtime_mark_last_busy(&slave->dev);
250fe46d2a4SPierre-Louis Bossart 	pm_runtime_put(&slave->dev);
251fe46d2a4SPierre-Louis Bossart 
252fe46d2a4SPierre-Louis Bossart 	return ret;
253fe46d2a4SPierre-Louis Bossart }
254fe46d2a4SPierre-Louis Bossart DEFINE_DEBUGFS_ATTRIBUTE(cmd_go_fops, NULL,
255fe46d2a4SPierre-Louis Bossart 			 cmd_go, "%llu\n");
256fe46d2a4SPierre-Louis Bossart 
257fe46d2a4SPierre-Louis Bossart #define MAX_LINE_LEN 128
258fe46d2a4SPierre-Louis Bossart 
read_buffer_show(struct seq_file * s_file,void * data)259fe46d2a4SPierre-Louis Bossart static int read_buffer_show(struct seq_file *s_file, void *data)
260fe46d2a4SPierre-Louis Bossart {
261fe46d2a4SPierre-Louis Bossart 	char buf[MAX_LINE_LEN];
262fe46d2a4SPierre-Louis Bossart 	int i;
263fe46d2a4SPierre-Louis Bossart 
264fe46d2a4SPierre-Louis Bossart 	if (num_bytes == 0 || num_bytes > MAX_CMD_BYTES)
265fe46d2a4SPierre-Louis Bossart 		return -EINVAL;
266fe46d2a4SPierre-Louis Bossart 
267fe46d2a4SPierre-Louis Bossart 	for (i = 0; i < num_bytes; i++) {
268fe46d2a4SPierre-Louis Bossart 		scnprintf(buf, MAX_LINE_LEN, "address %#x val 0x%02x\n",
269fe46d2a4SPierre-Louis Bossart 			  start_addr + i, read_buffer[i]);
270fe46d2a4SPierre-Louis Bossart 		seq_printf(s_file, "%s", buf);
271fe46d2a4SPierre-Louis Bossart 	}
272fe46d2a4SPierre-Louis Bossart 
273fe46d2a4SPierre-Louis Bossart 	return 0;
274fe46d2a4SPierre-Louis Bossart }
275fe46d2a4SPierre-Louis Bossart DEFINE_SHOW_ATTRIBUTE(read_buffer);
276fe46d2a4SPierre-Louis Bossart 
sdw_slave_debugfs_init(struct sdw_slave * slave)277bf03473dSPierre-Louis Bossart void sdw_slave_debugfs_init(struct sdw_slave *slave)
278bf03473dSPierre-Louis Bossart {
279bf03473dSPierre-Louis Bossart 	struct dentry *master;
280bf03473dSPierre-Louis Bossart 	struct dentry *d;
281bf03473dSPierre-Louis Bossart 	char name[32];
282bf03473dSPierre-Louis Bossart 
283bf03473dSPierre-Louis Bossart 	master = slave->bus->debugfs;
284bf03473dSPierre-Louis Bossart 
285bf03473dSPierre-Louis Bossart 	/* create the debugfs slave-name */
286bf03473dSPierre-Louis Bossart 	snprintf(name, sizeof(name), "%s", dev_name(&slave->dev));
287bf03473dSPierre-Louis Bossart 	d = debugfs_create_dir(name, master);
288bf03473dSPierre-Louis Bossart 
289bf03473dSPierre-Louis Bossart 	debugfs_create_file("registers", 0400, d, slave, &sdw_slave_reg_fops);
290bf03473dSPierre-Louis Bossart 
291fe46d2a4SPierre-Louis Bossart 	/* interface to send arbitrary commands */
292fe46d2a4SPierre-Louis Bossart 	debugfs_create_file("command", 0200, d, slave, &set_command_fops);
293fe46d2a4SPierre-Louis Bossart 	debugfs_create_file("start_address", 0200, d, slave, &set_start_address_fops);
294fe46d2a4SPierre-Louis Bossart 	debugfs_create_file("num_bytes", 0200, d, slave, &set_num_bytes_fops);
295fe46d2a4SPierre-Louis Bossart 	debugfs_create_file("go", 0200, d, slave, &cmd_go_fops);
296fe46d2a4SPierre-Louis Bossart 
297fe46d2a4SPierre-Louis Bossart 	debugfs_create_file("read_buffer", 0400, d, slave, &read_buffer_fops);
298fe46d2a4SPierre-Louis Bossart 	firmware_file = NULL;
299fe46d2a4SPierre-Louis Bossart 	debugfs_create_str("firmware_file", 0200, d, &firmware_file);
300fe46d2a4SPierre-Louis Bossart 
301bf03473dSPierre-Louis Bossart 	slave->debugfs = d;
302bf03473dSPierre-Louis Bossart }
303bf03473dSPierre-Louis Bossart 
sdw_slave_debugfs_exit(struct sdw_slave * slave)304bf03473dSPierre-Louis Bossart void sdw_slave_debugfs_exit(struct sdw_slave *slave)
305bf03473dSPierre-Louis Bossart {
306bf03473dSPierre-Louis Bossart 	debugfs_remove_recursive(slave->debugfs);
307bf03473dSPierre-Louis Bossart }
308bf03473dSPierre-Louis Bossart 
sdw_debugfs_init(void)309bf03473dSPierre-Louis Bossart void sdw_debugfs_init(void)
310bf03473dSPierre-Louis Bossart {
311bf03473dSPierre-Louis Bossart 	sdw_debugfs_root = debugfs_create_dir("soundwire", NULL);
312bf03473dSPierre-Louis Bossart }
313bf03473dSPierre-Louis Bossart 
sdw_debugfs_exit(void)314bf03473dSPierre-Louis Bossart void sdw_debugfs_exit(void)
315bf03473dSPierre-Louis Bossart {
316bf03473dSPierre-Louis Bossart 	debugfs_remove_recursive(sdw_debugfs_root);
317bf03473dSPierre-Louis Bossart }
318