18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci// 38c2ecf20Sopenharmony_ci// Freescale SSI ALSA SoC Digital Audio Interface (DAI) debugging functions 48c2ecf20Sopenharmony_ci// 58c2ecf20Sopenharmony_ci// Copyright 2014 Markus Pargmann <mpa@pengutronix.de>, Pengutronix 68c2ecf20Sopenharmony_ci// 78c2ecf20Sopenharmony_ci// Split from fsl_ssi.c 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/debugfs.h> 108c2ecf20Sopenharmony_ci#include <linux/device.h> 118c2ecf20Sopenharmony_ci#include <linux/kernel.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include "fsl_ssi.h" 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_civoid fsl_ssi_dbg_isr(struct fsl_ssi_dbg *dbg, u32 sisr) 168c2ecf20Sopenharmony_ci{ 178c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_RFRC) 188c2ecf20Sopenharmony_ci dbg->stats.rfrc++; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TFRC) 218c2ecf20Sopenharmony_ci dbg->stats.tfrc++; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_CMDAU) 248c2ecf20Sopenharmony_ci dbg->stats.cmdau++; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_CMDDU) 278c2ecf20Sopenharmony_ci dbg->stats.cmddu++; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_RXT) 308c2ecf20Sopenharmony_ci dbg->stats.rxt++; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_RDR1) 338c2ecf20Sopenharmony_ci dbg->stats.rdr1++; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_RDR0) 368c2ecf20Sopenharmony_ci dbg->stats.rdr0++; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TDE1) 398c2ecf20Sopenharmony_ci dbg->stats.tde1++; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TDE0) 428c2ecf20Sopenharmony_ci dbg->stats.tde0++; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_ROE1) 458c2ecf20Sopenharmony_ci dbg->stats.roe1++; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_ROE0) 488c2ecf20Sopenharmony_ci dbg->stats.roe0++; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TUE1) 518c2ecf20Sopenharmony_ci dbg->stats.tue1++; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TUE0) 548c2ecf20Sopenharmony_ci dbg->stats.tue0++; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TFS) 578c2ecf20Sopenharmony_ci dbg->stats.tfs++; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_RFS) 608c2ecf20Sopenharmony_ci dbg->stats.rfs++; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TLS) 638c2ecf20Sopenharmony_ci dbg->stats.tls++; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_RLS) 668c2ecf20Sopenharmony_ci dbg->stats.rls++; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_RFF1) 698c2ecf20Sopenharmony_ci dbg->stats.rff1++; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_RFF0) 728c2ecf20Sopenharmony_ci dbg->stats.rff0++; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TFE1) 758c2ecf20Sopenharmony_ci dbg->stats.tfe1++; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci if (sisr & SSI_SISR_TFE0) 788c2ecf20Sopenharmony_ci dbg->stats.tfe0++; 798c2ecf20Sopenharmony_ci} 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* 828c2ecf20Sopenharmony_ci * Show the statistics of a flag only if its interrupt is enabled 838c2ecf20Sopenharmony_ci * 848c2ecf20Sopenharmony_ci * Compilers will optimize it to a no-op if the interrupt is disabled 858c2ecf20Sopenharmony_ci */ 868c2ecf20Sopenharmony_ci#define SIER_SHOW(flag, name) \ 878c2ecf20Sopenharmony_ci do { \ 888c2ecf20Sopenharmony_ci if (SSI_SIER_##flag) \ 898c2ecf20Sopenharmony_ci seq_printf(s, #name "=%u\n", ssi_dbg->stats.name); \ 908c2ecf20Sopenharmony_ci } while (0) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* 948c2ecf20Sopenharmony_ci * Display the statistics for the current SSI device 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * To avoid confusion, only show those counts that are enabled 978c2ecf20Sopenharmony_ci */ 988c2ecf20Sopenharmony_cistatic int fsl_ssi_stats_show(struct seq_file *s, void *unused) 998c2ecf20Sopenharmony_ci{ 1008c2ecf20Sopenharmony_ci struct fsl_ssi_dbg *ssi_dbg = s->private; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci SIER_SHOW(RFRC_EN, rfrc); 1038c2ecf20Sopenharmony_ci SIER_SHOW(TFRC_EN, tfrc); 1048c2ecf20Sopenharmony_ci SIER_SHOW(CMDAU_EN, cmdau); 1058c2ecf20Sopenharmony_ci SIER_SHOW(CMDDU_EN, cmddu); 1068c2ecf20Sopenharmony_ci SIER_SHOW(RXT_EN, rxt); 1078c2ecf20Sopenharmony_ci SIER_SHOW(RDR1_EN, rdr1); 1088c2ecf20Sopenharmony_ci SIER_SHOW(RDR0_EN, rdr0); 1098c2ecf20Sopenharmony_ci SIER_SHOW(TDE1_EN, tde1); 1108c2ecf20Sopenharmony_ci SIER_SHOW(TDE0_EN, tde0); 1118c2ecf20Sopenharmony_ci SIER_SHOW(ROE1_EN, roe1); 1128c2ecf20Sopenharmony_ci SIER_SHOW(ROE0_EN, roe0); 1138c2ecf20Sopenharmony_ci SIER_SHOW(TUE1_EN, tue1); 1148c2ecf20Sopenharmony_ci SIER_SHOW(TUE0_EN, tue0); 1158c2ecf20Sopenharmony_ci SIER_SHOW(TFS_EN, tfs); 1168c2ecf20Sopenharmony_ci SIER_SHOW(RFS_EN, rfs); 1178c2ecf20Sopenharmony_ci SIER_SHOW(TLS_EN, tls); 1188c2ecf20Sopenharmony_ci SIER_SHOW(RLS_EN, rls); 1198c2ecf20Sopenharmony_ci SIER_SHOW(RFF1_EN, rff1); 1208c2ecf20Sopenharmony_ci SIER_SHOW(RFF0_EN, rff0); 1218c2ecf20Sopenharmony_ci SIER_SHOW(TFE1_EN, tfe1); 1228c2ecf20Sopenharmony_ci SIER_SHOW(TFE0_EN, tfe0); 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci return 0; 1258c2ecf20Sopenharmony_ci} 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ciDEFINE_SHOW_ATTRIBUTE(fsl_ssi_stats); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_civoid fsl_ssi_debugfs_create(struct fsl_ssi_dbg *ssi_dbg, struct device *dev) 1308c2ecf20Sopenharmony_ci{ 1318c2ecf20Sopenharmony_ci ssi_dbg->dbg_dir = debugfs_create_dir(dev_name(dev), NULL); 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci debugfs_create_file("stats", 0444, ssi_dbg->dbg_dir, ssi_dbg, 1348c2ecf20Sopenharmony_ci &fsl_ssi_stats_fops); 1358c2ecf20Sopenharmony_ci} 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_civoid fsl_ssi_debugfs_remove(struct fsl_ssi_dbg *ssi_dbg) 1388c2ecf20Sopenharmony_ci{ 1398c2ecf20Sopenharmony_ci debugfs_remove_recursive(ssi_dbg->dbg_dir); 1408c2ecf20Sopenharmony_ci} 141