ASoC: Intel: avs: Allow for dumping FW_REGS area

SRAM0 window begins with a block of memory, usually of size PAGE_SIZE,
dedicated to the base firmware registers. When debugging firmware, it is
desirable to be able to dump them at will.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20221202152841.672536-16-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Cezary Rojewski 2022-12-02 16:28:40 +01:00 committed by Mark Brown
parent 34d27c7170
commit 870f6e5abb
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -48,6 +48,29 @@ void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsig
wake_up(&adev->trace_waitq);
}
static ssize_t fw_regs_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
{
struct avs_dev *adev = file->private_data;
char *buf;
int ret;
buf = kzalloc(AVS_FW_REGS_SIZE, GFP_KERNEL);
if (!buf)
return -ENOMEM;
memcpy_fromio(buf, avs_sram_addr(adev, AVS_FW_REGS_WINDOW), AVS_FW_REGS_SIZE);
ret = simple_read_from_buffer(to, count, ppos, buf, AVS_FW_REGS_SIZE);
kfree(buf);
return ret;
}
static const struct file_operations fw_regs_fops = {
.open = simple_open,
.read = fw_regs_read,
.llseek = no_llseek,
};
static ssize_t probe_points_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
{
struct avs_dev *adev = file->private_data;
@ -369,6 +392,7 @@ void avs_debugfs_init(struct avs_dev *adev)
debugfs_create_file("strace", 0444, adev->debugfs_root, adev, &strace_fops);
debugfs_create_file("trace_control", 0644, adev->debugfs_root, adev, &trace_control_fops);
debugfs_create_file("fw_regs", 0444, adev->debugfs_root, adev, &fw_regs_fops);
debugfs_create_u32("trace_aging_period", 0644, adev->debugfs_root,
&adev->aging_timer_period);