Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: qcom: add debugfs entry for soundwire register dump

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

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210907105636.3171-1-srinivas.kandagatla@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Srinivas Kandagatla and committed by
Vinod Koul
abd9a604 4cbbe74d

+27
+27
drivers/soundwire/qcom.c
··· 7 7 #include <linux/io.h> 8 8 #include <linux/kernel.h> 9 9 #include <linux/module.h> 10 + #include <linux/debugfs.h> 10 11 #include <linux/of.h> 11 12 #include <linux/of_irq.h> 12 13 #include <linux/of_device.h> ··· 84 83 #define SWRM_DP_PORT_HCTRL_BANK(n, m) (0x1134 + 0x100 * (n - 1) + 0x40 * m) 85 84 #define SWRM_DP_BLOCK_CTRL3_BANK(n, m) (0x1138 + 0x100 * (n - 1) + 0x40 * m) 86 85 #define SWRM_DIN_DPn_PCM_PORT_CTRL(n) (0x1054 + 0x100 * (n - 1)) 86 + #define SWR_MSTR_MAX_REG_ADDR (0x1740) 87 87 88 88 #define SWRM_DP_PORT_CTRL_EN_CHAN_SHFT 0x18 89 89 #define SWRM_DP_PORT_CTRL_OFFSET2_SHFT 0x10 ··· 129 127 struct device *dev; 130 128 struct regmap *regmap; 131 129 void __iomem *mmio; 130 + #ifdef CONFIG_DEBUG_FS 131 + struct dentry *debugfs; 132 + #endif 132 133 struct completion broadcast; 133 134 struct completion enumeration; 134 135 struct work_struct slave_work; ··· 1197 1192 return 0; 1198 1193 } 1199 1194 1195 + #ifdef CONFIG_DEBUG_FS 1196 + static int swrm_reg_show(struct seq_file *s_file, void *data) 1197 + { 1198 + struct qcom_swrm_ctrl *swrm = s_file->private; 1199 + int reg, reg_val; 1200 + 1201 + for (reg = 0; reg <= SWR_MSTR_MAX_REG_ADDR; reg += 4) { 1202 + swrm->reg_read(swrm, reg, &reg_val); 1203 + seq_printf(s_file, "0x%.3x: 0x%.2x\n", reg, reg_val); 1204 + } 1205 + 1206 + return 0; 1207 + } 1208 + DEFINE_SHOW_ATTRIBUTE(swrm_reg); 1209 + #endif 1210 + 1200 1211 static int qcom_swrm_probe(struct platform_device *pdev) 1201 1212 { 1202 1213 struct device *dev = &pdev->dev; ··· 1322 1301 dev_info(dev, "Qualcomm Soundwire controller v%x.%x.%x Registered\n", 1323 1302 (ctrl->version >> 24) & 0xff, (ctrl->version >> 16) & 0xff, 1324 1303 ctrl->version & 0xffff); 1304 + 1305 + #ifdef CONFIG_DEBUG_FS 1306 + ctrl->debugfs = debugfs_create_dir("qualcomm-sdw", ctrl->bus.debugfs); 1307 + debugfs_create_file("qualcomm-registers", 0400, ctrl->debugfs, ctrl, 1308 + &swrm_reg_fops); 1309 + #endif 1325 1310 1326 1311 return 0; 1327 1312