clear-pkgs-linux-iot-lts2018/0210-ASoC-Intel-Skylake-Add...

169 lines
4.4 KiB
Diff
Raw Permalink Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Vinod Koul <vinod.koul@intel.com>
Date: Mon, 31 Aug 2015 14:12:14 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Add debugfs NHLT ssp override
Add debugfs entries for reading and writing SSP blobs which
driver can use to program DSP
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
sound/soc/intel/skylake/skl-debug.c | 92 +++++++++++++++++++++++++++--
1 file changed, 88 insertions(+), 4 deletions(-)
diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
2020-10-27 02:14:06 +08:00
index d848f5fe0956..9f3a596bb060 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -22,10 +22,17 @@
#include "skl-topology.h"
#include "../common/sst-dsp.h"
#include "../common/sst-dsp-priv.h"
+#include "skl-nhlt.h"
#define MOD_BUF PAGE_SIZE
#define FW_REG_BUF PAGE_SIZE
#define FW_REG_SIZE 0x60
+#define MAX_SSP 4
+
+struct nhlt_blob {
+ size_t size;
+ struct nhlt_specific_cfg *cfg;
+};
struct skl_debug {
struct skl *skl;
@@ -35,6 +42,62 @@ struct skl_debug {
struct dentry *modules;
struct dentry *nhlt;
u8 fw_read_buff[FW_REG_BUF];
+ struct nhlt_blob ssp_blob[MAX_SSP];
+};
+
+static ssize_t nhlt_read(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct nhlt_blob *blob = file->private_data;
+
+ if (!blob->cfg)
+ return -EIO;
+
+ return simple_read_from_buffer(user_buf, count, ppos,
+ blob->cfg, blob->size);
+}
+
+static ssize_t nhlt_write(struct file *file,
+ const char __user *user_buf, size_t count, loff_t *ppos)
+{
+ struct nhlt_blob *blob = file->private_data;
+ struct nhlt_specific_cfg *new_cfg;
+ ssize_t written;
+ size_t size = blob->size;
+
+ if (!blob->cfg) {
+ /* allocate mem for blob */
+ blob->cfg = kzalloc(count, GFP_KERNEL);
+ if (!blob->cfg)
+ return -ENOMEM;
+ size = count;
+ } else if (blob->size < count) {
+ /* size if different, so relloc */
+ new_cfg = krealloc(blob->cfg, count, GFP_KERNEL);
+ if (!new_cfg)
+ return -ENOMEM;
+ size = count;
+ blob->cfg = new_cfg;
+ }
+
+ written = simple_write_to_buffer(blob->cfg, size, ppos,
+ user_buf, count);
+ blob->size = written;
+
+ /* Userspace has been fiddling around behind the kernel's back */
+ add_taint(TAINT_USER, LOCKDEP_NOW_UNRELIABLE);
+
+ print_hex_dump(KERN_DEBUG, "Debugfs Blob:", DUMP_PREFIX_OFFSET, 8, 4,
+ blob->cfg, blob->size, false);
+
+ return written;
+}
+
+static const struct file_operations nhlt_fops = {
+ .open = simple_open,
+ .read = nhlt_read,
+ .write = nhlt_write,
+ .llseek = default_llseek,
};
static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,
2020-04-02 08:26:12 +08:00
@@ -168,7 +231,6 @@ static const struct file_operations mcfg_fops = {
.llseek = default_llseek,
};
-
void skl_debug_init_module(struct skl_debug *d,
struct snd_soc_dapm_widget *w,
struct skl_module_cfg *mconfig)
2020-04-02 08:26:12 +08:00
@@ -224,6 +286,15 @@ static const struct file_operations soft_regs_ctrl_fops = {
.llseek = default_llseek,
};
+static void skl_exit_nhlt(struct skl_debug *d)
+{
+ int i;
+
+ /* free blob memory, if allocated */
+ for (i = 0; i < MAX_SSP; i++)
+ kfree(d->ssp_blob[i].cfg);
+}
+
static ssize_t nhlt_control_read(struct file *file,
char __user *user_buf, size_t count, loff_t *ppos)
{
2020-04-02 08:26:12 +08:00
@@ -247,12 +318,14 @@ static ssize_t nhlt_control_write(struct file *file,
return -EFAULT;
buf[len] = 0;
- if (!strncmp(buf, "enable\n", len))
+ if (!strncmp(buf, "enable\n", len)) {
d->skl->nhlt_override = true;
- else if (!strncmp(buf, "disable\n", len))
+ } else if (!strncmp(buf, "disable\n", len)) {
d->skl->nhlt_override = false;
- else
+ skl_exit_nhlt(d);
+ } else {
return -EINVAL;
+ }
/* Userspace has been fiddling around behind the kernel's back */
add_taint(TAINT_USER, LOCKDEP_NOW_UNRELIABLE);
2020-04-02 08:26:12 +08:00
@@ -269,6 +342,9 @@ static const struct file_operations ssp_cntrl_nhlt_fops = {
static int skl_init_nhlt(struct skl_debug *d)
{
+ int i;
+ char name[12];
+
if (!debugfs_create_file("control",
0644, d->nhlt,
d, &ssp_cntrl_nhlt_fops)) {
2020-04-02 08:26:12 +08:00
@@ -276,6 +352,14 @@ static int skl_init_nhlt(struct skl_debug *d)
return -EIO;
}
+ for (i = 0; i < MAX_SSP; i++) {
+ snprintf(name, (sizeof(name)-1), "ssp%d", i);
+ if (!debugfs_create_file(name,
+ 0644, d->nhlt,
+ &d->ssp_blob[i], &nhlt_fops))
+ dev_err(d->dev, "%s: debugfs init failed\n", name);
+ }
+
return 0;
}
--
https://clearlinux.org