All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guneshwor Singh <guneshwor.o.singh@intel.com>
To: alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>
Cc: Sodhi@alsa-project.org, Patches Audio <patches.audio@intel.com>,
	Babu@alsa-project.org, Takashi Iwai <tiwai@suse.de>,
	Pardha Saradhi <pardha.saradhi.kesapragada@intel.com>,
	Jayachandran <jayachandran.b@intel.com>,
	Guneshwor Singh <guneshwor.o.singh@intel.com>,
	Ramesh <ramesh.babu@intel.com>,
	Mousumi Jana <mousumix.jana@intel.com>,
	liam.r.girdwood@linux.intel.com,
	Vinod Koul <vinod.koul@intel.com>,
	Kesapragada@alsa-project.org, "Sodhi,
	VunnyX" <vunnyx.sodhi@intel.com>,
	B@alsa-project.org
Subject: [PATCH v2 4/4] ASoC: Intel: Skylake: Add support to read firmware registers
Date: Thu, 29 Jun 2017 12:26:04 +0530	[thread overview]
Message-ID: <20170629065604.30105-5-guneshwor.o.singh@intel.com> (raw)
In-Reply-To: <20170629065604.30105-1-guneshwor.o.singh@intel.com>

From: "Sodhi, VunnyX" <vunnyx.sodhi@intel.com>

This patch adds debugfs support to read fw registers, mailbox
offsets and sram address.

Signed-off-by: Mousumi Jana <mousumix.jana@intel.com>
Signed-off-by: Babu, Ramesh <ramesh.babu@intel.com>
Signed-off-by: B, Jayachandran <jayachandran.b@intel.com>
Signed-off-by: Kesapragada, Pardha Saradhi <pardha.saradhi.kesapragada@intel.com>
Signed-off-by: Sodhi, VunnyX <vunnyx.sodhi@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-debug.c | 59 +++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
index 98d93f284af8..2650e04d4921 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -16,8 +16,15 @@
 #include <linux/pci.h>
 #include <linux/debugfs.h>
 #include "skl.h"
+#include "skl-sst-dsp.h"
+#include "skl-sst-ipc.h"
 #include "skl-tplg-interface.h"
 #include "skl-topology.h"
+#include "../common/sst-dsp-priv.h"
+
+#define MOD_BUF		PAGE_SIZE
+#define FW_REG_BUF	PAGE_SIZE
+#define FW_REG_SIZE	0x60
 
 #define MOD_BUF		PAGE_SIZE
 
@@ -27,6 +34,7 @@ struct skl_debug {
 
 	struct dentry *fs;
 	struct dentry *modules;
+	u8 fw_read_buff[FW_REG_BUF];
 };
 
 static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,
@@ -169,6 +177,51 @@ void skl_debug_init_module(struct skl_debug *d,
 		dev_err(d->dev, "%s: module debugfs init failed\n", w->name);
 }
 
+static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
+			       size_t count, loff_t *ppos)
+{
+	struct skl_debug *d = file->private_data;
+	struct sst_dsp *sst = d->skl->skl_sst->dsp;
+	size_t w0_stat_sz = sst->addr.w0_stat_sz;
+	void __iomem *in_base = sst->mailbox.in_base;
+	void __iomem *fw_reg_addr;
+	unsigned int offset;
+	char *tmp;
+	ssize_t ret = 0;
+
+	tmp = kzalloc(FW_REG_BUF, GFP_KERNEL);
+	if (!tmp)
+		return -ENOMEM;
+
+	fw_reg_addr = in_base - w0_stat_sz;
+	memset(d->fw_read_buff, 0, FW_REG_BUF);
+
+	if (w0_stat_sz > 0)
+		__iowrite32_copy(d->fw_read_buff, fw_reg_addr, w0_stat_sz >> 2);
+
+	for (offset = 0; offset < FW_REG_SIZE; offset += 16) {
+		ret += snprintf(tmp + ret, FW_REG_BUF - ret, "%#.4x: ", offset);
+		hex_dump_to_buffer(d->fw_read_buff + offset, 16, 16, 4,
+				   tmp + ret, FW_REG_BUF - ret, 0);
+		ret += strlen(tmp + ret);
+
+		/* print newline for each offset */
+		if (FW_REG_BUF - ret > 0)
+			tmp[ret++] = '\n';
+	}
+
+	ret = simple_read_from_buffer(user_buf, count, ppos, tmp, ret);
+	kfree(tmp);
+
+	return ret;
+}
+
+static const struct file_operations soft_regs_ctrl_fops = {
+	.open = simple_open,
+	.read = fw_softreg_read,
+	.llseek = default_llseek,
+};
+
 struct skl_debug *skl_debugfs_init(struct skl *skl)
 {
 	struct skl_debug *d;
@@ -194,6 +247,12 @@ struct skl_debug *skl_debugfs_init(struct skl *skl)
 		goto err;
 	}
 
+	if (!debugfs_create_file("fw_soft_regs_rd", 0444, d->fs, d,
+				 &soft_regs_ctrl_fops)) {
+		dev_err(d->dev, "fw soft regs control debugfs init failed\n");
+		goto err;
+	}
+
 	return d;
 
 err:
-- 
2.13.0

  parent reply	other threads:[~2017-06-29  6:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29  6:56 [v2 0/4] Add debugfs support for skylake driver Guneshwor Singh
2017-06-29  6:56 ` [PATCH v2 1/4] ASoC: Intel: Skylake: Add debugfs support Guneshwor Singh
2017-06-29  7:43   ` Takashi Sakamoto
2017-06-29  7:56     ` Vinod Koul
2017-06-29  8:16       ` Takashi Sakamoto
2017-06-29 10:16         ` Vinod Koul
2017-06-29  6:56 ` [PATCH v2 2/4] ASoC: Intel: Skylake: Debugfs facility to dump module config Guneshwor Singh
2017-06-29  6:56 ` [PATCH v2 3/4] ASoC: Intel: common: Add sram address to sst_addr structure Guneshwor Singh
2017-06-30 12:29   ` Applied "ASoC: Intel: Skylake: Add sram address to sst_addr structure" to the asoc tree Mark Brown
2017-06-29  6:56 ` Guneshwor Singh [this message]
2017-07-02 12:12   ` [PATCH v2 4/4] ASoC: Intel: Skylake: Add support to read firmware registers kbuild test robot
2017-07-03  3:27     ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170629065604.30105-5-guneshwor.o.singh@intel.com \
    --to=guneshwor.o.singh@intel.com \
    --cc=B@alsa-project.org \
    --cc=Babu@alsa-project.org \
    --cc=Kesapragada@alsa-project.org \
    --cc=Sodhi@alsa-project.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jayachandran.b@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=mousumix.jana@intel.com \
    --cc=pardha.saradhi.kesapragada@intel.com \
    --cc=patches.audio@intel.com \
    --cc=ramesh.babu@intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@intel.com \
    --cc=vunnyx.sodhi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.