Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  skl-debug.c - Debugfs for skl driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 2016-17 Intel Corp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <uapi/sound/skl-tplg-interface.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "skl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "skl-sst-dsp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "skl-sst-ipc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "skl-topology.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "../common/sst-dsp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "../common/sst-dsp-priv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define MOD_BUF		PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define FW_REG_BUF	PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define FW_REG_SIZE	0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) struct skl_debug {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	struct skl_dev *skl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct dentry *fs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct dentry *modules;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	u8 fw_read_buff[FW_REG_BUF];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 				int max_pin, ssize_t size, bool direction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	ssize_t ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	for (i = 0; i < max_pin; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		ret += scnprintf(buf + size, MOD_BUF - size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 				"%s %d\n\tModule %d\n\tInstance %d\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 				"In-used %s\n\tType %s\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 				"\tState %d\n\tIndex %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 				direction ? "Input Pin:" : "Output Pin:",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 				i, m_pin[i].id.module_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 				m_pin[i].id.instance_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 				m_pin[i].in_use ? "Used" : "Unused",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 				m_pin[i].is_dynamic ? "Dynamic" : "Static",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 				m_pin[i].pin_state, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		size += ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	return ret;
^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) static ssize_t skl_print_fmt(struct skl_module_fmt *fmt, char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 					ssize_t size, bool direction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	return scnprintf(buf + size, MOD_BUF - size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			"%s\n\tCh %d\n\tFreq %d\n\tBit depth %d\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			"Valid bit depth %d\n\tCh config %#x\n\tInterleaving %d\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			"Sample Type %d\n\tCh Map %#x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			direction ? "Input Format:" : "Output Format:",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			fmt->channels, fmt->s_freq, fmt->bit_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			fmt->valid_bit_depth, fmt->ch_cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			fmt->interleaving_style, fmt->sample_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			fmt->ch_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) static ssize_t module_read(struct file *file, char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			   size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct skl_module_cfg *mconfig = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct skl_module *module = mconfig->module;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct skl_module_res *res = &module->resources[mconfig->res_idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	buf = kzalloc(MOD_BUF, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	ret = scnprintf(buf, MOD_BUF, "Module:\n\tUUID %pUL\n\tModule id %d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			"\tInstance id %d\n\tPvt_id %d\n", mconfig->guid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			mconfig->id.module_id, mconfig->id.instance_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			mconfig->id.pvt_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			"Resources:\n\tCPC %#x\n\tIBS %#x\n\tOBS %#x\t\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			res->cpc, res->ibs, res->obs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			"Module data:\n\tCore %d\n\tIn queue %d\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			"Out queue %d\n\tType %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			mconfig->core_id, mconfig->max_in_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			mconfig->max_out_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			mconfig->is_loadable ? "loadable" : "inbuilt");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	ret += skl_print_fmt(mconfig->in_fmt, buf, ret, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	ret += skl_print_fmt(mconfig->out_fmt, buf, ret, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			"Fixup:\n\tParams %#x\n\tConverter %#x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			mconfig->params_fixup, mconfig->converter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			"Module Gateway:\n\tType %#x\n\tVbus %#x\n\tHW conn %#x\n\tSlot %#x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			mconfig->dev_type, mconfig->vbus_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			mconfig->hw_conn_type, mconfig->time_slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			"Pipeline:\n\tID %d\n\tPriority %d\n\tConn Type %d\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			"Pages %#x\n", mconfig->pipe->ppl_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			mconfig->pipe->pipe_priority, mconfig->pipe->conn_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			mconfig->pipe->memory_pages);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 			"\tParams:\n\t\tHost DMA %d\n\t\tLink DMA %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			mconfig->pipe->p_params->host_dma_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			mconfig->pipe->p_params->link_dma_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			"\tPCM params:\n\t\tCh %d\n\t\tFreq %d\n\t\tFormat %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			mconfig->pipe->p_params->ch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			mconfig->pipe->p_params->s_freq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			mconfig->pipe->p_params->s_fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			"\tLink %#x\n\tStream %#x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			mconfig->pipe->p_params->linktype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			mconfig->pipe->p_params->stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			"\tState %d\n\tPassthru %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			mconfig->pipe->state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			mconfig->pipe->passthru ? "true" : "false");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	ret += skl_print_pins(mconfig->m_in_pin, buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			mconfig->max_in_queue, ret, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	ret += skl_print_pins(mconfig->m_out_pin, buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			mconfig->max_out_queue, ret, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	ret += scnprintf(buf + ret, MOD_BUF - ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			"Other:\n\tDomain %d\n\tHomogeneous Input %s\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			"Homogeneous Output %s\n\tIn Queue Mask %d\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			"Out Queue Mask %d\n\tDMA ID %d\n\tMem Pages %d\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			"Module Type %d\n\tModule State %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			mconfig->domain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			mconfig->homogenous_inputs ? "true" : "false",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			mconfig->homogenous_outputs ? "true" : "false",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			mconfig->in_queue_mask, mconfig->out_queue_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			mconfig->dma_id, mconfig->mem_pages, mconfig->m_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			mconfig->m_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static const struct file_operations mcfg_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	.open = simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	.read = module_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	.llseek = default_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) void skl_debug_init_module(struct skl_debug *d,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			struct snd_soc_dapm_widget *w,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 			struct skl_module_cfg *mconfig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	debugfs_create_file(w->name, 0444, d->modules, mconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			    &mcfg_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			       size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct skl_debug *d = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	struct sst_dsp *sst = d->skl->dsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	size_t w0_stat_sz = sst->addr.w0_stat_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	void __iomem *in_base = sst->mailbox.in_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	void __iomem *fw_reg_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	unsigned int offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	char *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	ssize_t ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	tmp = kzalloc(FW_REG_BUF, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	if (!tmp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	fw_reg_addr = in_base - w0_stat_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	memset(d->fw_read_buff, 0, FW_REG_BUF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	if (w0_stat_sz > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		__ioread32_copy(d->fw_read_buff, fw_reg_addr, w0_stat_sz >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	for (offset = 0; offset < FW_REG_SIZE; offset += 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		ret += scnprintf(tmp + ret, FW_REG_BUF - ret, "%#.4x: ", offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		hex_dump_to_buffer(d->fw_read_buff + offset, 16, 16, 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 				   tmp + ret, FW_REG_BUF - ret, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		ret += strlen(tmp + ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		/* print newline for each offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (FW_REG_BUF - ret > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			tmp[ret++] = '\n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	ret = simple_read_from_buffer(user_buf, count, ppos, tmp, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	kfree(tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) static const struct file_operations soft_regs_ctrl_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	.open = simple_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	.read = fw_softreg_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	.llseek = default_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct skl_debug *skl_debugfs_init(struct skl_dev *skl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	struct skl_debug *d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	d = devm_kzalloc(&skl->pci->dev, sizeof(*d), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	if (!d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	/* create the debugfs dir with platform component's debugfs as parent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	d->fs = debugfs_create_dir("dsp", skl->component->debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	d->skl = skl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	d->dev = &skl->pci->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	/* now create the module dir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	d->modules = debugfs_create_dir("modules", d->fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	debugfs_create_file("fw_soft_regs_rd", 0444, d->fs, d,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			    &soft_regs_ctrl_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	return d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) void skl_debugfs_exit(struct skl_dev *skl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	struct skl_debug *d = skl->debugfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	debugfs_remove_recursive(d->fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	d = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }