Commit 5cdf6c09 authored by Vinod Koul's avatar Vinod Koul Committed by Mark Brown

ASoC: Intel: Skylake: Add debugfs support

For debug, the kernel debugfs mechanism is available. We can add various
debug options for driver like module configuration read, firmware register
read etc.

This patch adds debugfs as a child to asoc plaform component and caller is
added for skylake driver to do init and cleanup of debugfs.
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarVunny Sodhi <vunnyx.sodhi@intel.com>
Signed-off-by: default avatarGuneshwor Singh <guneshwor.o.singh@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 46b5a4d2
snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \ snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \
skl-topology.o skl-topology.o
ifdef CONFIG_DEBUG_FS
snd-soc-skl-objs += skl-debug.o
endif
obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
# Skylake IPC Support # Skylake IPC Support
......
/*
* skl-debug.c - Debugfs for skl driver
*
* Copyright (C) 2016-17 Intel Corp
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/pci.h>
#include <linux/debugfs.h>
#include "skl.h"
struct skl_debug {
struct skl *skl;
struct device *dev;
struct dentry *fs;
};
struct skl_debug *skl_debugfs_init(struct skl *skl)
{
struct skl_debug *d;
d = devm_kzalloc(&skl->pci->dev, sizeof(*d), GFP_KERNEL);
if (!d)
return NULL;
/* create the debugfs dir with platform component's debugfs as parent */
d->fs = debugfs_create_dir("dsp",
skl->platform->component.debugfs_root);
if (IS_ERR(d->fs) || !d->fs) {
dev_err(&skl->pci->dev, "debugfs root creation failed\n");
return NULL;
}
d->skl = skl;
d->dev = &skl->pci->dev;
return d;
}
void skl_debugfs_exit(struct skl_debug *d)
{
debugfs_remove_recursive(d->fs);
kfree(d);
}
...@@ -1249,12 +1249,16 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) ...@@ -1249,12 +1249,16 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform)
pm_runtime_get_sync(platform->dev); pm_runtime_get_sync(platform->dev);
if ((ebus_to_hbus(ebus))->ppcap) { if ((ebus_to_hbus(ebus))->ppcap) {
skl->platform = platform;
/* init debugfs */
skl->debugfs = skl_debugfs_init(skl);
ret = skl_tplg_init(platform, ebus); ret = skl_tplg_init(platform, ebus);
if (ret < 0) { if (ret < 0) {
dev_err(platform->dev, "Failed to init topology!\n"); dev_err(platform->dev, "Failed to init topology!\n");
return ret; return ret;
} }
skl->platform = platform;
/* load the firmwares, since all is set */ /* load the firmwares, since all is set */
ops = skl_get_dsp_ops(skl->pci->device); ops = skl_get_dsp_ops(skl->pci->device);
......
...@@ -866,6 +866,8 @@ static void skl_remove(struct pci_dev *pci) ...@@ -866,6 +866,8 @@ static void skl_remove(struct pci_dev *pci)
/* codec removal, invoke bus_device_remove */ /* codec removal, invoke bus_device_remove */
snd_hdac_ext_bus_device_remove(ebus); snd_hdac_ext_bus_device_remove(ebus);
skl_debugfs_exit(skl->debugfs);
skl->debugfs = NULL;
skl_platform_unregister(&pci->dev); skl_platform_unregister(&pci->dev);
skl_free_dsp(skl); skl_free_dsp(skl);
skl_machine_device_unregister(skl); skl_machine_device_unregister(skl);
......
...@@ -42,6 +42,8 @@ struct skl_dsp_resource { ...@@ -42,6 +42,8 @@ struct skl_dsp_resource {
u32 mem; u32 mem;
}; };
struct skl_debug;
struct skl { struct skl {
struct hdac_ext_bus ebus; struct hdac_ext_bus ebus;
struct pci_dev *pci; struct pci_dev *pci;
...@@ -66,6 +68,8 @@ struct skl { ...@@ -66,6 +68,8 @@ struct skl {
int supend_active; int supend_active;
struct work_struct probe_work; struct work_struct probe_work;
struct skl_debug *debugfs;
}; };
#define skl_to_ebus(s) (&(s)->ebus) #define skl_to_ebus(s) (&(s)->ebus)
...@@ -116,4 +120,16 @@ void skl_update_d0i3c(struct device *dev, bool enable); ...@@ -116,4 +120,16 @@ void skl_update_d0i3c(struct device *dev, bool enable);
int skl_nhlt_create_sysfs(struct skl *skl); int skl_nhlt_create_sysfs(struct skl *skl);
void skl_nhlt_remove_sysfs(struct skl *skl); void skl_nhlt_remove_sysfs(struct skl *skl);
#ifdef CONFIG_DEBUG_FS
struct skl_debug *skl_debugfs_init(struct skl *skl);
void skl_debugfs_exit(struct skl_debug *d);
#else
static inline struct skl_debug *skl_debugfs_init(struct skl *skl)
{
return NULL;
}
static inline void skl_debugfs_exit(struct skl_debug *d)
{}
#endif
#endif /* __SOUND_SOC_SKL_H */ #endif /* __SOUND_SOC_SKL_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment