1 // SPDX-License-Identifier: GPL-2.0
3 // Freescale SSI ALSA SoC Digital Audio Interface (DAI) debugging functions
5 // Copyright 2014 Markus Pargmann <mpa@pengutronix.de>, Pengutronix
7 // Split from fsl_ssi.c
9 #include <linux/debugfs.h>
10 #include <linux/device.h>
11 #include <linux/kernel.h>
15 void fsl_ssi_dbg_isr(struct fsl_ssi_dbg
*dbg
, u32 sisr
)
17 if (sisr
& SSI_SISR_RFRC
)
20 if (sisr
& SSI_SISR_TFRC
)
23 if (sisr
& SSI_SISR_CMDAU
)
26 if (sisr
& SSI_SISR_CMDDU
)
29 if (sisr
& SSI_SISR_RXT
)
32 if (sisr
& SSI_SISR_RDR1
)
35 if (sisr
& SSI_SISR_RDR0
)
38 if (sisr
& SSI_SISR_TDE1
)
41 if (sisr
& SSI_SISR_TDE0
)
44 if (sisr
& SSI_SISR_ROE1
)
47 if (sisr
& SSI_SISR_ROE0
)
50 if (sisr
& SSI_SISR_TUE1
)
53 if (sisr
& SSI_SISR_TUE0
)
56 if (sisr
& SSI_SISR_TFS
)
59 if (sisr
& SSI_SISR_RFS
)
62 if (sisr
& SSI_SISR_TLS
)
65 if (sisr
& SSI_SISR_RLS
)
68 if (sisr
& SSI_SISR_RFF1
)
71 if (sisr
& SSI_SISR_RFF0
)
74 if (sisr
& SSI_SISR_TFE1
)
77 if (sisr
& SSI_SISR_TFE0
)
82 * Show the statistics of a flag only if its interrupt is enabled
84 * Compilers will optimize it to a no-op if the interrupt is disabled
86 #define SIER_SHOW(flag, name) \
88 if (SSI_SIER_##flag) \
89 seq_printf(s, #name "=%u\n", ssi_dbg->stats.name); \
94 * Display the statistics for the current SSI device
96 * To avoid confusion, only show those counts that are enabled
98 static int fsl_ssi_stats_show(struct seq_file
*s
, void *unused
)
100 struct fsl_ssi_dbg
*ssi_dbg
= s
->private;
102 SIER_SHOW(RFRC_EN
, rfrc
);
103 SIER_SHOW(TFRC_EN
, tfrc
);
104 SIER_SHOW(CMDAU_EN
, cmdau
);
105 SIER_SHOW(CMDDU_EN
, cmddu
);
106 SIER_SHOW(RXT_EN
, rxt
);
107 SIER_SHOW(RDR1_EN
, rdr1
);
108 SIER_SHOW(RDR0_EN
, rdr0
);
109 SIER_SHOW(TDE1_EN
, tde1
);
110 SIER_SHOW(TDE0_EN
, tde0
);
111 SIER_SHOW(ROE1_EN
, roe1
);
112 SIER_SHOW(ROE0_EN
, roe0
);
113 SIER_SHOW(TUE1_EN
, tue1
);
114 SIER_SHOW(TUE0_EN
, tue0
);
115 SIER_SHOW(TFS_EN
, tfs
);
116 SIER_SHOW(RFS_EN
, rfs
);
117 SIER_SHOW(TLS_EN
, tls
);
118 SIER_SHOW(RLS_EN
, rls
);
119 SIER_SHOW(RFF1_EN
, rff1
);
120 SIER_SHOW(RFF0_EN
, rff0
);
121 SIER_SHOW(TFE1_EN
, tfe1
);
122 SIER_SHOW(TFE0_EN
, tfe0
);
127 DEFINE_SHOW_ATTRIBUTE(fsl_ssi_stats
);
129 void fsl_ssi_debugfs_create(struct fsl_ssi_dbg
*ssi_dbg
, struct device
*dev
)
131 ssi_dbg
->dbg_dir
= debugfs_create_dir(dev_name(dev
), NULL
);
133 debugfs_create_file("stats", 0444, ssi_dbg
->dbg_dir
, ssi_dbg
,
134 &fsl_ssi_stats_fops
);
137 void fsl_ssi_debugfs_remove(struct fsl_ssi_dbg
*ssi_dbg
)
139 debugfs_remove_recursive(ssi_dbg
->dbg_dir
);