fsl_ssi_dbg.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Freescale SSI ALSA SoC Digital Audio Interface (DAI) debugging functions
  3. *
  4. * Copyright 2014 Markus Pargmann <mpa@pengutronix.de>, Pengutronix
  5. *
  6. * Splitted from fsl_ssi.c
  7. *
  8. * This file is licensed under the terms of the GNU General Public License
  9. * version 2. This program is licensed "as is" without any warranty of any
  10. * kind, whether express or implied.
  11. */
  12. #include <linux/debugfs.h>
  13. #include <linux/device.h>
  14. #include <linux/kernel.h>
  15. #include "fsl_ssi.h"
  16. void fsl_ssi_dbg_isr(struct fsl_ssi_dbg *dbg, u32 sisr)
  17. {
  18. if (sisr & CCSR_SSI_SISR_RFRC)
  19. dbg->stats.rfrc++;
  20. if (sisr & CCSR_SSI_SISR_TFRC)
  21. dbg->stats.tfrc++;
  22. if (sisr & CCSR_SSI_SISR_CMDAU)
  23. dbg->stats.cmdau++;
  24. if (sisr & CCSR_SSI_SISR_CMDDU)
  25. dbg->stats.cmddu++;
  26. if (sisr & CCSR_SSI_SISR_RXT)
  27. dbg->stats.rxt++;
  28. if (sisr & CCSR_SSI_SISR_RDR1)
  29. dbg->stats.rdr1++;
  30. if (sisr & CCSR_SSI_SISR_RDR0)
  31. dbg->stats.rdr0++;
  32. if (sisr & CCSR_SSI_SISR_TDE1)
  33. dbg->stats.tde1++;
  34. if (sisr & CCSR_SSI_SISR_TDE0)
  35. dbg->stats.tde0++;
  36. if (sisr & CCSR_SSI_SISR_ROE1)
  37. dbg->stats.roe1++;
  38. if (sisr & CCSR_SSI_SISR_ROE0)
  39. dbg->stats.roe0++;
  40. if (sisr & CCSR_SSI_SISR_TUE1)
  41. dbg->stats.tue1++;
  42. if (sisr & CCSR_SSI_SISR_TUE0)
  43. dbg->stats.tue0++;
  44. if (sisr & CCSR_SSI_SISR_TFS)
  45. dbg->stats.tfs++;
  46. if (sisr & CCSR_SSI_SISR_RFS)
  47. dbg->stats.rfs++;
  48. if (sisr & CCSR_SSI_SISR_TLS)
  49. dbg->stats.tls++;
  50. if (sisr & CCSR_SSI_SISR_RLS)
  51. dbg->stats.rls++;
  52. if (sisr & CCSR_SSI_SISR_RFF1)
  53. dbg->stats.rff1++;
  54. if (sisr & CCSR_SSI_SISR_RFF0)
  55. dbg->stats.rff0++;
  56. if (sisr & CCSR_SSI_SISR_TFE1)
  57. dbg->stats.tfe1++;
  58. if (sisr & CCSR_SSI_SISR_TFE0)
  59. dbg->stats.tfe0++;
  60. }
  61. /* Show the statistics of a flag only if its interrupt is enabled. The
  62. * compiler will optimze this code to a no-op if the interrupt is not
  63. * enabled.
  64. */
  65. #define SIER_SHOW(flag, name) \
  66. do { \
  67. if (CCSR_SSI_SIER_##flag) \
  68. seq_printf(s, #name "=%u\n", ssi_dbg->stats.name); \
  69. } while (0)
  70. /**
  71. * fsl_sysfs_ssi_show: display SSI statistics
  72. *
  73. * Display the statistics for the current SSI device. To avoid confusion,
  74. * we only show those counts that are enabled.
  75. */
  76. static int fsl_ssi_stats_show(struct seq_file *s, void *unused)
  77. {
  78. struct fsl_ssi_dbg *ssi_dbg = s->private;
  79. SIER_SHOW(RFRC_EN, rfrc);
  80. SIER_SHOW(TFRC_EN, tfrc);
  81. SIER_SHOW(CMDAU_EN, cmdau);
  82. SIER_SHOW(CMDDU_EN, cmddu);
  83. SIER_SHOW(RXT_EN, rxt);
  84. SIER_SHOW(RDR1_EN, rdr1);
  85. SIER_SHOW(RDR0_EN, rdr0);
  86. SIER_SHOW(TDE1_EN, tde1);
  87. SIER_SHOW(TDE0_EN, tde0);
  88. SIER_SHOW(ROE1_EN, roe1);
  89. SIER_SHOW(ROE0_EN, roe0);
  90. SIER_SHOW(TUE1_EN, tue1);
  91. SIER_SHOW(TUE0_EN, tue0);
  92. SIER_SHOW(TFS_EN, tfs);
  93. SIER_SHOW(RFS_EN, rfs);
  94. SIER_SHOW(TLS_EN, tls);
  95. SIER_SHOW(RLS_EN, rls);
  96. SIER_SHOW(RFF1_EN, rff1);
  97. SIER_SHOW(RFF0_EN, rff0);
  98. SIER_SHOW(TFE1_EN, tfe1);
  99. SIER_SHOW(TFE0_EN, tfe0);
  100. return 0;
  101. }
  102. static int fsl_ssi_stats_open(struct inode *inode, struct file *file)
  103. {
  104. return single_open(file, fsl_ssi_stats_show, inode->i_private);
  105. }
  106. static const struct file_operations fsl_ssi_stats_ops = {
  107. .open = fsl_ssi_stats_open,
  108. .read = seq_read,
  109. .llseek = seq_lseek,
  110. .release = single_release,
  111. };
  112. int fsl_ssi_debugfs_create(struct fsl_ssi_dbg *ssi_dbg, struct device *dev)
  113. {
  114. ssi_dbg->dbg_dir = debugfs_create_dir(dev_name(dev), NULL);
  115. if (!ssi_dbg->dbg_dir)
  116. return -ENOMEM;
  117. ssi_dbg->dbg_stats = debugfs_create_file("stats", S_IRUGO,
  118. ssi_dbg->dbg_dir, ssi_dbg, &fsl_ssi_stats_ops);
  119. if (!ssi_dbg->dbg_stats) {
  120. debugfs_remove(ssi_dbg->dbg_dir);
  121. return -ENOMEM;
  122. }
  123. return 0;
  124. }
  125. void fsl_ssi_debugfs_remove(struct fsl_ssi_dbg *ssi_dbg)
  126. {
  127. debugfs_remove(ssi_dbg->dbg_stats);
  128. debugfs_remove(ssi_dbg->dbg_dir);
  129. }