aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMylene JOSSERAND <mylene.josserand@free-electrons.com>2017-12-13 07:34:07 -0500
committerMark Brown <broonie@kernel.org>2018-01-24 12:31:06 -0500
commiteda85d1fee05d69e97939f9603b857f2244d72d9 (patch)
tree3453e5efa0e5972c3619fb21340b3096dc98d098
parent4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323 (diff)
ASoC: sun8i-codec: Add ADC support for a33
Add ADC support for the sun8i-codec driver. This driver uses microphones widgets and routes provided by the analog part (sun8i-codec-analog). Some digital configurations are needed by creating new ADC widgets and routes. Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sunxi/sun8i-codec.c82
1 files changed, 80 insertions, 2 deletions
diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c
index 3dd183be08a4..7a15df924316 100644
--- a/sound/soc/sunxi/sun8i-codec.c
+++ b/sound/soc/sunxi/sun8i-codec.c
@@ -37,9 +37,11 @@
37#define SUN8I_SYSCLK_CTL_SYSCLK_SRC 0 37#define SUN8I_SYSCLK_CTL_SYSCLK_SRC 0
38#define SUN8I_MOD_CLK_ENA 0x010 38#define SUN8I_MOD_CLK_ENA 0x010
39#define SUN8I_MOD_CLK_ENA_AIF1 15 39#define SUN8I_MOD_CLK_ENA_AIF1 15
40#define SUN8I_MOD_CLK_ENA_ADC 3
40#define SUN8I_MOD_CLK_ENA_DAC 2 41#define SUN8I_MOD_CLK_ENA_DAC 2
41#define SUN8I_MOD_RST_CTL 0x014 42#define SUN8I_MOD_RST_CTL 0x014
42#define SUN8I_MOD_RST_CTL_AIF1 15 43#define SUN8I_MOD_RST_CTL_AIF1 15
44#define SUN8I_MOD_RST_CTL_ADC 3
43#define SUN8I_MOD_RST_CTL_DAC 2 45#define SUN8I_MOD_RST_CTL_DAC 2
44#define SUN8I_SYS_SR_CTRL 0x018 46#define SUN8I_SYS_SR_CTRL 0x018
45#define SUN8I_SYS_SR_CTRL_AIF1_FS 12 47#define SUN8I_SYS_SR_CTRL_AIF1_FS 12
@@ -54,9 +56,25 @@
54#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ 4 56#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ 4
55#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16 (1 << 4) 57#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16 (1 << 4)
56#define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT 2 58#define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT 2
59#define SUN8I_AIF1_ADCDAT_CTRL 0x044
60#define SUN8I_AIF1_ADCDAT_CTRL_AIF1_DA0L_ENA 15
61#define SUN8I_AIF1_ADCDAT_CTRL_AIF1_DA0R_ENA 14
57#define SUN8I_AIF1_DACDAT_CTRL 0x048 62#define SUN8I_AIF1_DACDAT_CTRL 0x048
58#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0L_ENA 15 63#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0L_ENA 15
59#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA 14 64#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA 14
65#define SUN8I_AIF1_MXR_SRC 0x04c
66#define SUN8I_AIF1_MXR_SRC_AD0L_MXL_SRC_AIF1DA0L 15
67#define SUN8I_AIF1_MXR_SRC_AD0L_MXL_SRC_AIF2DACL 14
68#define SUN8I_AIF1_MXR_SRC_AD0L_MXL_SRC_ADCL 13
69#define SUN8I_AIF1_MXR_SRC_AD0L_MXL_SRC_AIF2DACR 12
70#define SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_AIF1DA0R 11
71#define SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_AIF2DACR 10
72#define SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_ADCR 9
73#define SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_AIF2DACL 8
74#define SUN8I_ADC_DIG_CTRL 0x100
75#define SUN8I_ADC_DIG_CTRL_ENDA 15
76#define SUN8I_ADC_DIG_CTRL_ADOUT_DTS 2
77#define SUN8I_ADC_DIG_CTRL_ADOUT_DLY 1
60#define SUN8I_DAC_DIG_CTRL 0x120 78#define SUN8I_DAC_DIG_CTRL 0x120
61#define SUN8I_DAC_DIG_CTRL_ENDA 15 79#define SUN8I_DAC_DIG_CTRL_ENDA 15
62#define SUN8I_DAC_MXR_SRC 0x130 80#define SUN8I_DAC_MXR_SRC 0x130
@@ -338,10 +356,30 @@ static const struct snd_kcontrol_new sun8i_dac_mixer_controls[] = {
338 SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_ADCR, 1, 0), 356 SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_ADCR, 1, 0),
339}; 357};
340 358
359static const struct snd_kcontrol_new sun8i_input_mixer_controls[] = {
360 SOC_DAPM_DOUBLE("AIF1 Slot 0 Digital ADC Capture Switch",
361 SUN8I_AIF1_MXR_SRC,
362 SUN8I_AIF1_MXR_SRC_AD0L_MXL_SRC_AIF1DA0L,
363 SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_AIF1DA0R, 1, 0),
364 SOC_DAPM_DOUBLE("AIF2 Digital ADC Capture Switch", SUN8I_AIF1_MXR_SRC,
365 SUN8I_AIF1_MXR_SRC_AD0L_MXL_SRC_AIF2DACL,
366 SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_AIF2DACR, 1, 0),
367 SOC_DAPM_DOUBLE("AIF1 Data Digital ADC Capture Switch",
368 SUN8I_AIF1_MXR_SRC,
369 SUN8I_AIF1_MXR_SRC_AD0L_MXL_SRC_ADCL,
370 SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_ADCR, 1, 0),
371 SOC_DAPM_DOUBLE("AIF2 Inv Digital ADC Capture Switch",
372 SUN8I_AIF1_MXR_SRC,
373 SUN8I_AIF1_MXR_SRC_AD0L_MXL_SRC_AIF2DACR,
374 SUN8I_AIF1_MXR_SRC_AD0R_MXR_SRC_AIF2DACL, 1, 0),
375};
376
341static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = { 377static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {
342 /* Digital parts of the DACs */ 378 /* Digital parts of the DACs and ADC */
343 SND_SOC_DAPM_SUPPLY("DAC", SUN8I_DAC_DIG_CTRL, SUN8I_DAC_DIG_CTRL_ENDA, 379 SND_SOC_DAPM_SUPPLY("DAC", SUN8I_DAC_DIG_CTRL, SUN8I_DAC_DIG_CTRL_ENDA,
344 0, NULL, 0), 380 0, NULL, 0),
381 SND_SOC_DAPM_SUPPLY("ADC", SUN8I_ADC_DIG_CTRL, SUN8I_ADC_DIG_CTRL_ENDA,
382 0, NULL, 0),
345 383
346 /* Analog DAC AIF */ 384 /* Analog DAC AIF */
347 SND_SOC_DAPM_AIF_IN("AIF1 Slot 0 Left", "Playback", 0, 385 SND_SOC_DAPM_AIF_IN("AIF1 Slot 0 Left", "Playback", 0,
@@ -351,17 +389,31 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {
351 SUN8I_AIF1_DACDAT_CTRL, 389 SUN8I_AIF1_DACDAT_CTRL,
352 SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA, 0), 390 SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA, 0),
353 391
354 /* DAC Mixers */ 392 /* Analog ADC AIF */
393 SND_SOC_DAPM_AIF_IN("AIF1 Slot 0 Left ADC", "Capture", 0,
394 SUN8I_AIF1_ADCDAT_CTRL,
395 SUN8I_AIF1_ADCDAT_CTRL_AIF1_DA0L_ENA, 0),
396 SND_SOC_DAPM_AIF_IN("AIF1 Slot 0 Right ADC", "Capture", 0,
397 SUN8I_AIF1_ADCDAT_CTRL,
398 SUN8I_AIF1_ADCDAT_CTRL_AIF1_DA0R_ENA, 0),
399
400 /* DAC and ADC Mixers */
355 SOC_MIXER_ARRAY("Left Digital DAC Mixer", SND_SOC_NOPM, 0, 0, 401 SOC_MIXER_ARRAY("Left Digital DAC Mixer", SND_SOC_NOPM, 0, 0,
356 sun8i_dac_mixer_controls), 402 sun8i_dac_mixer_controls),
357 SOC_MIXER_ARRAY("Right Digital DAC Mixer", SND_SOC_NOPM, 0, 0, 403 SOC_MIXER_ARRAY("Right Digital DAC Mixer", SND_SOC_NOPM, 0, 0,
358 sun8i_dac_mixer_controls), 404 sun8i_dac_mixer_controls),
405 SOC_MIXER_ARRAY("Left Digital ADC Mixer", SND_SOC_NOPM, 0, 0,
406 sun8i_input_mixer_controls),
407 SOC_MIXER_ARRAY("Right Digital ADC Mixer", SND_SOC_NOPM, 0, 0,
408 sun8i_input_mixer_controls),
359 409
360 /* Clocks */ 410 /* Clocks */
361 SND_SOC_DAPM_SUPPLY("MODCLK AFI1", SUN8I_MOD_CLK_ENA, 411 SND_SOC_DAPM_SUPPLY("MODCLK AFI1", SUN8I_MOD_CLK_ENA,
362 SUN8I_MOD_CLK_ENA_AIF1, 0, NULL, 0), 412 SUN8I_MOD_CLK_ENA_AIF1, 0, NULL, 0),
363 SND_SOC_DAPM_SUPPLY("MODCLK DAC", SUN8I_MOD_CLK_ENA, 413 SND_SOC_DAPM_SUPPLY("MODCLK DAC", SUN8I_MOD_CLK_ENA,
364 SUN8I_MOD_CLK_ENA_DAC, 0, NULL, 0), 414 SUN8I_MOD_CLK_ENA_DAC, 0, NULL, 0),
415 SND_SOC_DAPM_SUPPLY("MODCLK ADC", SUN8I_MOD_CLK_ENA,
416 SUN8I_MOD_CLK_ENA_ADC, 0, NULL, 0),
365 SND_SOC_DAPM_SUPPLY("AIF1", SUN8I_SYSCLK_CTL, 417 SND_SOC_DAPM_SUPPLY("AIF1", SUN8I_SYSCLK_CTL,
366 SUN8I_SYSCLK_CTL_AIF1CLK_ENA, 0, NULL, 0), 418 SUN8I_SYSCLK_CTL_AIF1CLK_ENA, 0, NULL, 0),
367 SND_SOC_DAPM_SUPPLY("SYSCLK", SUN8I_SYSCLK_CTL, 419 SND_SOC_DAPM_SUPPLY("SYSCLK", SUN8I_SYSCLK_CTL,
@@ -378,6 +430,12 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {
378 SUN8I_MOD_RST_CTL_AIF1, 0, NULL, 0), 430 SUN8I_MOD_RST_CTL_AIF1, 0, NULL, 0),
379 SND_SOC_DAPM_SUPPLY("RST DAC", SUN8I_MOD_RST_CTL, 431 SND_SOC_DAPM_SUPPLY("RST DAC", SUN8I_MOD_RST_CTL,
380 SUN8I_MOD_RST_CTL_DAC, 0, NULL, 0), 432 SUN8I_MOD_RST_CTL_DAC, 0, NULL, 0),
433 SND_SOC_DAPM_SUPPLY("RST ADC", SUN8I_MOD_RST_CTL,
434 SUN8I_MOD_RST_CTL_ADC, 0, NULL, 0),
435
436 SND_SOC_DAPM_MIC("Headset Mic", NULL),
437 SND_SOC_DAPM_MIC("Mic", NULL),
438
381}; 439};
382 440
383static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = { 441static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = {
@@ -387,11 +445,16 @@ static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = {
387 { "RST AIF1", NULL, "AIF1 PLL" }, 445 { "RST AIF1", NULL, "AIF1 PLL" },
388 { "MODCLK AFI1", NULL, "RST AIF1" }, 446 { "MODCLK AFI1", NULL, "RST AIF1" },
389 { "DAC", NULL, "MODCLK AFI1" }, 447 { "DAC", NULL, "MODCLK AFI1" },
448 { "ADC", NULL, "MODCLK AFI1" },
390 449
391 { "RST DAC", NULL, "SYSCLK" }, 450 { "RST DAC", NULL, "SYSCLK" },
392 { "MODCLK DAC", NULL, "RST DAC" }, 451 { "MODCLK DAC", NULL, "RST DAC" },
393 { "DAC", NULL, "MODCLK DAC" }, 452 { "DAC", NULL, "MODCLK DAC" },
394 453
454 { "RST ADC", NULL, "SYSCLK" },
455 { "MODCLK ADC", NULL, "RST ADC" },
456 { "ADC", NULL, "MODCLK ADC" },
457
395 /* DAC Routes */ 458 /* DAC Routes */
396 { "AIF1 Slot 0 Right", NULL, "DAC" }, 459 { "AIF1 Slot 0 Right", NULL, "DAC" },
397 { "AIF1 Slot 0 Left", NULL, "DAC" }, 460 { "AIF1 Slot 0 Left", NULL, "DAC" },
@@ -401,6 +464,12 @@ static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = {
401 "AIF1 Slot 0 Left"}, 464 "AIF1 Slot 0 Left"},
402 { "Right Digital DAC Mixer", "AIF1 Slot 0 Digital DAC Playback Switch", 465 { "Right Digital DAC Mixer", "AIF1 Slot 0 Digital DAC Playback Switch",
403 "AIF1 Slot 0 Right"}, 466 "AIF1 Slot 0 Right"},
467
468 /* ADC routes */
469 { "Left Digital ADC Mixer", "AIF1 Data Digital ADC Capture Switch",
470 "AIF1 Slot 0 Left ADC" },
471 { "Right Digital ADC Mixer", "AIF1 Data Digital ADC Capture Switch",
472 "AIF1 Slot 0 Right ADC" },
404}; 473};
405 474
406static const struct snd_soc_dai_ops sun8i_codec_dai_ops = { 475static const struct snd_soc_dai_ops sun8i_codec_dai_ops = {
@@ -418,6 +487,15 @@ static struct snd_soc_dai_driver sun8i_codec_dai = {
418 .rates = SNDRV_PCM_RATE_8000_192000, 487 .rates = SNDRV_PCM_RATE_8000_192000,
419 .formats = SNDRV_PCM_FMTBIT_S16_LE, 488 .formats = SNDRV_PCM_FMTBIT_S16_LE,
420 }, 489 },
490 /* capture capabilities */
491 .capture = {
492 .stream_name = "Capture",
493 .channels_min = 1,
494 .channels_max = 2,
495 .rates = SNDRV_PCM_RATE_8000_192000,
496 .formats = SNDRV_PCM_FMTBIT_S16_LE,
497 .sig_bits = 24,
498 },
421 /* pcm operations */ 499 /* pcm operations */
422 .ops = &sun8i_codec_dai_ops, 500 .ops = &sun8i_codec_dai_ops,
423}; 501};