summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/wm8903.c143
1 files changed, 143 insertions, 0 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 7acd563d9128..8a254ad332d7 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -212,6 +212,147 @@ static u16 wm8903_reg_defaults[] = {
0x0000, /* R172 - Analogue Output Bias 0 */
};
+#ifdef CONFIG_DEBUG_FS
+
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+
+#define SEQ_PR_WM8903(x) \
+ do { \
+ seq_printf(s, "0x%04X : 0x%08X \n", \
+ (x), snd_soc_read(codec, (x))); \
+ } while (0)
+
+static int dbg_wm8903_show(struct seq_file *s, void *unused)
+{
+ struct snd_soc_codec* codec = s->private;
+
+ seq_printf(s, "WM8903 config Registers \n");
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_SW_RESET_AND_ID);
+ SEQ_PR_WM8903(WM8903_REVISION_NUMBER);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_BIAS_CONTROL_0);
+ SEQ_PR_WM8903(WM8903_VMID_CONTROL_0);
+ SEQ_PR_WM8903(WM8903_MIC_BIAS_CONTROL_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ANALOGUE_DAC_0);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_ADC_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_POWER_MANAGEMENT_0);
+ SEQ_PR_WM8903(WM8903_POWER_MANAGEMENT_1);
+ SEQ_PR_WM8903(WM8903_POWER_MANAGEMENT_2);
+ SEQ_PR_WM8903(WM8903_POWER_MANAGEMENT_3);
+ SEQ_PR_WM8903(WM8903_POWER_MANAGEMENT_4);
+ SEQ_PR_WM8903(WM8903_POWER_MANAGEMENT_5);
+ SEQ_PR_WM8903(WM8903_POWER_MANAGEMENT_6);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_CLOCK_RATES_0);
+ SEQ_PR_WM8903(WM8903_CLOCK_RATES_1);
+ SEQ_PR_WM8903(WM8903_CLOCK_RATES_2);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_AUDIO_INTERFACE_0);
+ SEQ_PR_WM8903(WM8903_AUDIO_INTERFACE_1);
+ SEQ_PR_WM8903(WM8903_AUDIO_INTERFACE_2);
+ SEQ_PR_WM8903(WM8903_AUDIO_INTERFACE_3);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_DAC_DIGITAL_VOLUME_LEFT);
+ SEQ_PR_WM8903(WM8903_DAC_DIGITAL_VOLUME_RIGHT);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_DAC_DIGITAL_0);
+ SEQ_PR_WM8903(WM8903_DAC_DIGITAL_1);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ADC_DIGITAL_VOLUME_LEFT);
+ SEQ_PR_WM8903(WM8903_ADC_DIGITAL_VOLUME_RIGHT);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ADC_DIGITAL_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_DIGITAL_MICROPHONE_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_DRC_0);
+ SEQ_PR_WM8903(WM8903_DRC_1);
+ SEQ_PR_WM8903(WM8903_DRC_2);
+ SEQ_PR_WM8903(WM8903_DRC_3);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ANALOGUE_LEFT_INPUT_0);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_RIGHT_INPUT_0);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_LEFT_INPUT_1);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_RIGHT_INPUT_1);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ANALOGUE_LEFT_MIX_0);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_RIGHT_MIX_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ANALOGUE_SPK_MIX_LEFT_0);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_SPK_MIX_LEFT_1);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_SPK_MIX_RIGHT_0);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_SPK_MIX_RIGHT_1);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ANALOGUE_OUT1_LEFT);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_OUT1_RIGHT);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_OUT2_LEFT);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_OUT2_RIGHT);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_OUT3_LEFT);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_OUT3_RIGHT);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ANALOGUE_SPK_OUTPUT_CONTROL_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_DC_SERVO_0);
+ SEQ_PR_WM8903(WM8903_DC_SERVO_2);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ANALOGUE_HP_0);
+ SEQ_PR_WM8903(WM8903_ANALOGUE_LINEOUT_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_CHARGE_PUMP_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_CLASS_W_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_WRITE_SEQUENCER_0);
+ SEQ_PR_WM8903(WM8903_WRITE_SEQUENCER_1);
+ SEQ_PR_WM8903(WM8903_WRITE_SEQUENCER_2);
+ SEQ_PR_WM8903(WM8903_WRITE_SEQUENCER_3);
+ SEQ_PR_WM8903(WM8903_WRITE_SEQUENCER_4);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_CONTROL_INTERFACE);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_GPIO_CONTROL_1);
+ SEQ_PR_WM8903(WM8903_GPIO_CONTROL_2);
+ SEQ_PR_WM8903(WM8903_GPIO_CONTROL_3);
+ SEQ_PR_WM8903(WM8903_GPIO_CONTROL_4);
+ SEQ_PR_WM8903(WM8903_GPIO_CONTROL_5);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_ANALOGUE_OUTPUT_BIAS_0);
+ seq_printf(s, "------------------------\n");
+ SEQ_PR_WM8903(WM8903_REGISTER_COUNT);
+ SEQ_PR_WM8903(WM8903_MAX_REGISTER);
+
+ return 0;
+}
+
+static int dbg_wm8903_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, dbg_wm8903_show, inode->i_private);
+}
+
+static const struct file_operations debug_fops = {
+ .open = dbg_wm8903_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static void wm8903_debuginit(struct snd_soc_codec* codec)
+{
+ (void) debugfs_create_file("wm8903", S_IRUGO,
+ NULL, codec, &debug_fops);
+}
+
+#else
+static void __init wm8903_debuginit(struct snd_soc_codec* codec)
+{
+ return;
+}
+#endif
+
struct wm8903_priv {
struct snd_soc_codec codec;
u16 reg_cache[ARRAY_SIZE(wm8903_reg_defaults)];
@@ -1790,6 +1931,8 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
wm8903_dai.dev = &i2c->dev;
wm8903_codec = codec;
+ wm8903_debuginit(codec);
+
ret = snd_soc_register_codec(codec);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);