Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // // Renesas R-Car debugfs support
0004 //
0005 // Copyright (c) 2021 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
0006 //
0007 //  > mount -t debugfs none /sys/kernel/debug
0008 //  > cd /sys/kernel/debug/asoc/rcar-sound/ec500000.sound/rdai{N}/
0009 //  > cat playback/xxx
0010 //  > cat capture/xxx
0011 //
0012 #ifdef CONFIG_DEBUG_FS
0013 
0014 #include <linux/debugfs.h>
0015 #include "rsnd.h"
0016 
0017 static int rsnd_debugfs_show(struct seq_file *m, void *v)
0018 {
0019     struct rsnd_dai_stream *io = m->private;
0020     struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io);
0021     struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
0022     int i;
0023 
0024     /* adg is out of mods */
0025     rsnd_adg_clk_dbg_info(priv, m);
0026 
0027     for_each_rsnd_mod(i, mod, io) {
0028         u32 *status = mod->ops->get_status(mod, io, mod->type);
0029 
0030         seq_printf(m, "name: %s\n", rsnd_mod_name(mod));
0031         seq_printf(m, "status: %08x\n", *status);
0032 
0033         if (mod->ops->debug_info)
0034             mod->ops->debug_info(m, io, mod);
0035     }
0036 
0037     return 0;
0038 }
0039 DEFINE_SHOW_ATTRIBUTE(rsnd_debugfs);
0040 
0041 void rsnd_debugfs_reg_show(struct seq_file *m, phys_addr_t _addr,
0042                void __iomem *base, int offset, int size)
0043 {
0044     int i, j;
0045 
0046     for (i = 0; i < size; i += 0x10) {
0047         phys_addr_t addr = _addr + offset + i;
0048 
0049         seq_printf(m, "%pa:", &addr);
0050         for (j = 0; j < 0x10; j += 0x4)
0051             seq_printf(m, " %08x", __raw_readl(base + offset + i + j));
0052         seq_puts(m, "\n");
0053     }
0054 }
0055 
0056 void rsnd_debugfs_mod_reg_show(struct seq_file *m, struct rsnd_mod *mod,
0057                    int reg_id, int offset, int size)
0058 {
0059     struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
0060 
0061     rsnd_debugfs_reg_show(m,
0062                   rsnd_gen_get_phy_addr(priv, reg_id),
0063                   rsnd_gen_get_base_addr(priv, reg_id),
0064                   offset, size);
0065 }
0066 
0067 int rsnd_debugfs_probe(struct snd_soc_component *component)
0068 {
0069     struct rsnd_priv *priv = dev_get_drvdata(component->dev);
0070     struct rsnd_dai *rdai;
0071     struct dentry *dir;
0072     char name[64];
0073     int i;
0074 
0075     /* Gen1 is not supported */
0076     if (rsnd_is_gen1(priv))
0077         return 0;
0078 
0079     for_each_rsnd_dai(rdai, priv, i) {
0080         /*
0081          * created debugfs will be automatically
0082          * removed, nothing to do for _remove.
0083          * see
0084          *  soc_cleanup_component_debugfs()
0085          */
0086         snprintf(name, sizeof(name), "rdai%d", i);
0087         dir = debugfs_create_dir(name, component->debugfs_root);
0088 
0089         debugfs_create_file("playback", 0444, dir, &rdai->playback, &rsnd_debugfs_fops);
0090         debugfs_create_file("capture",  0444, dir, &rdai->capture,  &rsnd_debugfs_fops);
0091     }
0092 
0093     return 0;
0094 }
0095 
0096 #endif /* CONFIG_DEBUG_FS */