All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
@ 2021-09-07 10:56 ` Srinivas Kandagatla
  0 siblings, 0 replies; 9+ messages in thread
From: Srinivas Kandagatla @ 2021-09-07 10:56 UTC (permalink / raw)
  To: vkoul, yung-chuan.liao
  Cc: pierre-louis.bossart, sanyog.r.kale, alsa-devel, linux-kernel,
	Srinivas Kandagatla

For debug purposes add an entry in debugfs to dump Qualcomm
SoundWire Controller registers.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/soundwire/qcom.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 0ef79d60e88e..a317bea2d42d 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -7,6 +7,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/debugfs.h>
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/of_device.h>
@@ -83,6 +84,7 @@
 #define SWRM_DP_PORT_HCTRL_BANK(n, m)	(0x1134 + 0x100 * (n - 1) + 0x40 * m)
 #define SWRM_DP_BLOCK_CTRL3_BANK(n, m)	(0x1138 + 0x100 * (n - 1) + 0x40 * m)
 #define SWRM_DIN_DPn_PCM_PORT_CTRL(n)	(0x1054 + 0x100 * (n - 1))
+#define SWR_MSTR_MAX_REG_ADDR		(0x1740)
 
 #define SWRM_DP_PORT_CTRL_EN_CHAN_SHFT				0x18
 #define SWRM_DP_PORT_CTRL_OFFSET2_SHFT				0x10
@@ -127,6 +129,9 @@ struct qcom_swrm_ctrl {
 	struct device *dev;
 	struct regmap *regmap;
 	void __iomem *mmio;
+#ifdef CONFIG_DEBUG_FS
+	struct dentry *debugfs;
+#endif
 	struct completion broadcast;
 	struct completion enumeration;
 	struct work_struct slave_work;
@@ -1192,6 +1197,22 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl)
 	return 0;
 }
 
+#ifdef CONFIG_DEBUG_FS
+static int swrm_reg_show(struct seq_file *s_file, void *data)
+{
+	struct qcom_swrm_ctrl *swrm = s_file->private;
+	int reg, reg_val;
+
+	for (reg = 0; reg <= SWR_MSTR_MAX_REG_ADDR; reg += 4) {
+		swrm->reg_read(swrm, reg, &reg_val);
+		seq_printf(s_file, "0x%.3x: 0x%.2x\n", reg, reg_val);
+	}
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(swrm_reg);
+#endif
+
 static int qcom_swrm_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -1302,6 +1323,12 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 		 (ctrl->version >> 24) & 0xff, (ctrl->version >> 16) & 0xff,
 		 ctrl->version & 0xffff);
 
+#ifdef CONFIG_DEBUG_FS
+	ctrl->debugfs = debugfs_create_dir("qualcomm-sdw", ctrl->bus.debugfs);
+	debugfs_create_file("qualcomm-registers", 0400, ctrl->debugfs, ctrl,
+			    &swrm_reg_fops);
+#endif
+
 	return 0;
 
 err_master_add:
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
@ 2021-09-07 10:56 ` Srinivas Kandagatla
  0 siblings, 0 replies; 9+ messages in thread
From: Srinivas Kandagatla @ 2021-09-07 10:56 UTC (permalink / raw)
  To: vkoul, yung-chuan.liao
  Cc: sanyog.r.kale, pierre-louis.bossart, alsa-devel, linux-kernel

For debug purposes add an entry in debugfs to dump Qualcomm
SoundWire Controller registers.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/soundwire/qcom.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 0ef79d60e88e..a317bea2d42d 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -7,6 +7,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/debugfs.h>
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/of_device.h>
@@ -83,6 +84,7 @@
 #define SWRM_DP_PORT_HCTRL_BANK(n, m)	(0x1134 + 0x100 * (n - 1) + 0x40 * m)
 #define SWRM_DP_BLOCK_CTRL3_BANK(n, m)	(0x1138 + 0x100 * (n - 1) + 0x40 * m)
 #define SWRM_DIN_DPn_PCM_PORT_CTRL(n)	(0x1054 + 0x100 * (n - 1))
+#define SWR_MSTR_MAX_REG_ADDR		(0x1740)
 
 #define SWRM_DP_PORT_CTRL_EN_CHAN_SHFT				0x18
 #define SWRM_DP_PORT_CTRL_OFFSET2_SHFT				0x10
@@ -127,6 +129,9 @@ struct qcom_swrm_ctrl {
 	struct device *dev;
 	struct regmap *regmap;
 	void __iomem *mmio;
+#ifdef CONFIG_DEBUG_FS
+	struct dentry *debugfs;
+#endif
 	struct completion broadcast;
 	struct completion enumeration;
 	struct work_struct slave_work;
@@ -1192,6 +1197,22 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl)
 	return 0;
 }
 
+#ifdef CONFIG_DEBUG_FS
+static int swrm_reg_show(struct seq_file *s_file, void *data)
+{
+	struct qcom_swrm_ctrl *swrm = s_file->private;
+	int reg, reg_val;
+
+	for (reg = 0; reg <= SWR_MSTR_MAX_REG_ADDR; reg += 4) {
+		swrm->reg_read(swrm, reg, &reg_val);
+		seq_printf(s_file, "0x%.3x: 0x%.2x\n", reg, reg_val);
+	}
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(swrm_reg);
+#endif
+
 static int qcom_swrm_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -1302,6 +1323,12 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 		 (ctrl->version >> 24) & 0xff, (ctrl->version >> 16) & 0xff,
 		 ctrl->version & 0xffff);
 
+#ifdef CONFIG_DEBUG_FS
+	ctrl->debugfs = debugfs_create_dir("qualcomm-sdw", ctrl->bus.debugfs);
+	debugfs_create_file("qualcomm-registers", 0400, ctrl->debugfs, ctrl,
+			    &swrm_reg_fops);
+#endif
+
 	return 0;
 
 err_master_add:
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
  2021-09-07 10:56 ` Srinivas Kandagatla
@ 2021-10-01  4:20   ` Vinod Koul
  -1 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2021-10-01  4:20 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: yung-chuan.liao, pierre-louis.bossart, sanyog.r.kale, alsa-devel,
	linux-kernel

HI Srini,

On 07-09-21, 11:56, Srinivas Kandagatla wrote:
> +#ifdef CONFIG_DEBUG_FS
> +static int swrm_reg_show(struct seq_file *s_file, void *data)
> +{
> +	struct qcom_swrm_ctrl *swrm = s_file->private;
> +	int reg, reg_val;
> +
> +	for (reg = 0; reg <= SWR_MSTR_MAX_REG_ADDR; reg += 4) {
> +		swrm->reg_read(swrm, reg, &reg_val);

Why not use regmap_read here, that would avoid reading from the bus when
we already have the values...

Second make sure later when pm_runtime support is added, this take a
reference ..

Thanks
-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
@ 2021-10-01  4:20   ` Vinod Koul
  0 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2021-10-01  4:20 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: sanyog.r.kale, yung-chuan.liao, pierre-louis.bossart, alsa-devel,
	linux-kernel

HI Srini,

On 07-09-21, 11:56, Srinivas Kandagatla wrote:
> +#ifdef CONFIG_DEBUG_FS
> +static int swrm_reg_show(struct seq_file *s_file, void *data)
> +{
> +	struct qcom_swrm_ctrl *swrm = s_file->private;
> +	int reg, reg_val;
> +
> +	for (reg = 0; reg <= SWR_MSTR_MAX_REG_ADDR; reg += 4) {
> +		swrm->reg_read(swrm, reg, &reg_val);

Why not use regmap_read here, that would avoid reading from the bus when
we already have the values...

Second make sure later when pm_runtime support is added, this take a
reference ..

Thanks
-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
  2021-10-01  4:20   ` Vinod Koul
  (?)
@ 2021-10-01 11:45   ` Pierre-Louis Bossart
  -1 siblings, 0 replies; 9+ messages in thread
From: Pierre-Louis Bossart @ 2021-10-01 11:45 UTC (permalink / raw)
  To: Vinod Koul, Srinivas Kandagatla
  Cc: sanyog.r.kale, yung-chuan.liao, alsa-devel, linux-kernel



On 9/30/21 11:20 PM, Vinod Koul wrote:
> HI Srini,
> 
> On 07-09-21, 11:56, Srinivas Kandagatla wrote:
>> +#ifdef CONFIG_DEBUG_FS
>> +static int swrm_reg_show(struct seq_file *s_file, void *data)
>> +{
>> +	struct qcom_swrm_ctrl *swrm = s_file->private;
>> +	int reg, reg_val;
>> +
>> +	for (reg = 0; reg <= SWR_MSTR_MAX_REG_ADDR; reg += 4) {
>> +		swrm->reg_read(swrm, reg, &reg_val);
> 
> Why not use regmap_read here, that would avoid reading from the bus when
> we already have the values...

It's an indirect read based on regmap.

	ctrl->reg_read = qcom_swrm_ahb_reg_read;
	ctrl->reg_write = qcom_swrm_ahb_reg_write;

static int qcom_swrm_ahb_reg_read(struct qcom_swrm_ctrl *ctrl, int reg,
				  u32 *val)
{
	struct regmap *wcd_regmap = ctrl->regmap;
	int ret;

	/* pg register + offset */
	ret = regmap_bulk_write(wcd_regmap, SWRM_AHB_BRIDGE_RD_ADDR_0,
			  (u8 *)&reg, 4);
	if (ret < 0)
		return SDW_CMD_FAIL;

	ret = regmap_bulk_read(wcd_regmap, SWRM_AHB_BRIDGE_RD_DATA_0,
			       val, 4);
	if (ret < 0)
		return SDW_CMD_FAIL;

	return SDW_CMD_OK;
}

> Second make sure later when pm_runtime support is added, this take a
> reference ..

Yes indeed, the SoundWire regmap doesn't change the pm_runtime status.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
  2021-10-01  4:20   ` Vinod Koul
@ 2021-10-08 10:54     ` Srinivas Kandagatla
  -1 siblings, 0 replies; 9+ messages in thread
From: Srinivas Kandagatla @ 2021-10-08 10:54 UTC (permalink / raw)
  To: Vinod Koul
  Cc: yung-chuan.liao, pierre-louis.bossart, sanyog.r.kale, alsa-devel,
	linux-kernel



On 01/10/2021 05:20, Vinod Koul wrote:
> HI Srini,
> 
> On 07-09-21, 11:56, Srinivas Kandagatla wrote:
>> +#ifdef CONFIG_DEBUG_FS
>> +static int swrm_reg_show(struct seq_file *s_file, void *data)
>> +{
>> +	struct qcom_swrm_ctrl *swrm = s_file->private;
>> +	int reg, reg_val;
>> +
>> +	for (reg = 0; reg <= SWR_MSTR_MAX_REG_ADDR; reg += 4) {
>> +		swrm->reg_read(swrm, reg, &reg_val);
> 
> Why not use regmap_read here, that would avoid reading from the bus when
> we already have the values...

Sorry for such late reply.
But these are controller registers which are not exposed as regmaps in 
mmio cases.


> 
> Second make sure later when pm_runtime support is added, this take a
> reference ..
> 
Yes, Am currently working on runtime pm support, I will make sure that 
this is take care.

--srini
> Thanks
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
@ 2021-10-08 10:54     ` Srinivas Kandagatla
  0 siblings, 0 replies; 9+ messages in thread
From: Srinivas Kandagatla @ 2021-10-08 10:54 UTC (permalink / raw)
  To: Vinod Koul
  Cc: sanyog.r.kale, yung-chuan.liao, pierre-louis.bossart, alsa-devel,
	linux-kernel



On 01/10/2021 05:20, Vinod Koul wrote:
> HI Srini,
> 
> On 07-09-21, 11:56, Srinivas Kandagatla wrote:
>> +#ifdef CONFIG_DEBUG_FS
>> +static int swrm_reg_show(struct seq_file *s_file, void *data)
>> +{
>> +	struct qcom_swrm_ctrl *swrm = s_file->private;
>> +	int reg, reg_val;
>> +
>> +	for (reg = 0; reg <= SWR_MSTR_MAX_REG_ADDR; reg += 4) {
>> +		swrm->reg_read(swrm, reg, &reg_val);
> 
> Why not use regmap_read here, that would avoid reading from the bus when
> we already have the values...

Sorry for such late reply.
But these are controller registers which are not exposed as regmaps in 
mmio cases.


> 
> Second make sure later when pm_runtime support is added, this take a
> reference ..
> 
Yes, Am currently working on runtime pm support, I will make sure that 
this is take care.

--srini
> Thanks
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
  2021-09-07 10:56 ` Srinivas Kandagatla
@ 2021-10-20 15:24   ` Vinod Koul
  -1 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2021-10-20 15:24 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: yung-chuan.liao, pierre-louis.bossart, sanyog.r.kale, alsa-devel,
	linux-kernel

On 07-09-21, 11:56, Srinivas Kandagatla wrote:
> For debug purposes add an entry in debugfs to dump Qualcomm
> SoundWire Controller registers.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump
@ 2021-10-20 15:24   ` Vinod Koul
  0 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2021-10-20 15:24 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: sanyog.r.kale, yung-chuan.liao, pierre-louis.bossart, alsa-devel,
	linux-kernel

On 07-09-21, 11:56, Srinivas Kandagatla wrote:
> For debug purposes add an entry in debugfs to dump Qualcomm
> SoundWire Controller registers.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-10-20 15:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 10:56 [PATCH] soundwire: qcom: add debugfs entry for soundwire register dump Srinivas Kandagatla
2021-09-07 10:56 ` Srinivas Kandagatla
2021-10-01  4:20 ` Vinod Koul
2021-10-01  4:20   ` Vinod Koul
2021-10-01 11:45   ` Pierre-Louis Bossart
2021-10-08 10:54   ` Srinivas Kandagatla
2021-10-08 10:54     ` Srinivas Kandagatla
2021-10-20 15:24 ` Vinod Koul
2021-10-20 15:24   ` Vinod Koul

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.