1 // SPDX-License-Identifier: GPL-2.0
3 // // Renesas R-Car debugfs support
5 // Copyright (c) 2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 // > mount -t debugfs none /sys/kernel/debug
8 // > cd /sys/kernel/debug/asoc/rcar-sound/ec500000.sound/rdai{N}/
12 #ifdef CONFIG_DEBUG_FS
14 #include <linux/debugfs.h>
17 static int rsnd_debugfs_show(struct seq_file *m, void *v)
19 struct rsnd_dai_stream *io = m->private;
20 struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io);
21 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
24 /* adg is out of mods */
25 rsnd_adg_clk_dbg_info(priv, m);
27 for_each_rsnd_mod(i, mod, io) {
28 u32 *status = mod->ops->get_status(mod, io, mod->type);
30 seq_printf(m, "name: %s\n", rsnd_mod_name(mod));
31 seq_printf(m, "status: %08x\n", *status);
33 if (mod->ops->debug_info)
34 mod->ops->debug_info(m, io, mod);
39 DEFINE_SHOW_ATTRIBUTE(rsnd_debugfs);
41 void rsnd_debugfs_reg_show(struct seq_file *m, phys_addr_t _addr,
42 void __iomem *base, int offset, int size)
46 for (i = 0; i < size; i += 0x10) {
47 phys_addr_t addr = _addr + offset + i;
49 seq_printf(m, "%pa:", &addr);
50 for (j = 0; j < 0x10; j += 0x4)
51 seq_printf(m, " %08x", __raw_readl(base + offset + i + j));
56 void rsnd_debugfs_mod_reg_show(struct seq_file *m, struct rsnd_mod *mod,
57 int reg_id, int offset, int size)
59 struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
61 rsnd_debugfs_reg_show(m,
62 rsnd_gen_get_phy_addr(priv, reg_id),
63 rsnd_gen_get_base_addr(priv, reg_id),
67 int rsnd_debugfs_probe(struct snd_soc_component *component)
69 struct rsnd_priv *priv = dev_get_drvdata(component->dev);
70 struct rsnd_dai *rdai;
75 /* Gen1 is not supported */
76 if (rsnd_is_gen1(priv))
79 for_each_rsnd_dai(rdai, priv, i) {
81 * created debugfs will be automatically
82 * removed, nothing to do for _remove.
84 * soc_cleanup_component_debugfs()
86 snprintf(name, sizeof(name), "rdai%d", i);
87 dir = debugfs_create_dir(name, component->debugfs_root);
89 debugfs_create_file("playback", 0444, dir, &rdai->playback, &rsnd_debugfs_fops);
90 debugfs_create_file("capture", 0444, dir, &rdai->capture, &rsnd_debugfs_fops);
96 #endif /* CONFIG_DEBUG_FS */