forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/codecs/wm8990.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * wm8990.c -- WM8990 ALSA Soc Audio driver
34 *
45 * Copyright 2008 Wolfson Microelectronics PLC.
56 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
117 */
128
139 #include <linux/module.h>
....@@ -36,92 +32,13 @@
3632 unsigned int pcmclk;
3733 };
3834
39
-static bool wm8990_volatile_register(struct device *dev, unsigned int reg)
40
-{
41
- switch (reg) {
42
- case WM8990_RESET:
43
- return true;
44
- default:
45
- return false;
46
- }
47
-}
48
-
49
-static const struct reg_default wm8990_reg_defaults[] = {
50
- { 1, 0x0000 }, /* R1 - Power Management (1) */
51
- { 2, 0x6000 }, /* R2 - Power Management (2) */
52
- { 3, 0x0000 }, /* R3 - Power Management (3) */
53
- { 4, 0x4050 }, /* R4 - Audio Interface (1) */
54
- { 5, 0x4000 }, /* R5 - Audio Interface (2) */
55
- { 6, 0x01C8 }, /* R6 - Clocking (1) */
56
- { 7, 0x0000 }, /* R7 - Clocking (2) */
57
- { 8, 0x0040 }, /* R8 - Audio Interface (3) */
58
- { 9, 0x0040 }, /* R9 - Audio Interface (4) */
59
- { 10, 0x0004 }, /* R10 - DAC CTRL */
60
- { 11, 0x00C0 }, /* R11 - Left DAC Digital Volume */
61
- { 12, 0x00C0 }, /* R12 - Right DAC Digital Volume */
62
- { 13, 0x0000 }, /* R13 - Digital Side Tone */
63
- { 14, 0x0100 }, /* R14 - ADC CTRL */
64
- { 15, 0x00C0 }, /* R15 - Left ADC Digital Volume */
65
- { 16, 0x00C0 }, /* R16 - Right ADC Digital Volume */
66
-
67
- { 18, 0x0000 }, /* R18 - GPIO CTRL 1 */
68
- { 19, 0x1000 }, /* R19 - GPIO1 & GPIO2 */
69
- { 20, 0x1010 }, /* R20 - GPIO3 & GPIO4 */
70
- { 21, 0x1010 }, /* R21 - GPIO5 & GPIO6 */
71
- { 22, 0x8000 }, /* R22 - GPIOCTRL 2 */
72
- { 23, 0x0800 }, /* R23 - GPIO_POL */
73
- { 24, 0x008B }, /* R24 - Left Line Input 1&2 Volume */
74
- { 25, 0x008B }, /* R25 - Left Line Input 3&4 Volume */
75
- { 26, 0x008B }, /* R26 - Right Line Input 1&2 Volume */
76
- { 27, 0x008B }, /* R27 - Right Line Input 3&4 Volume */
77
- { 28, 0x0000 }, /* R28 - Left Output Volume */
78
- { 29, 0x0000 }, /* R29 - Right Output Volume */
79
- { 30, 0x0066 }, /* R30 - Line Outputs Volume */
80
- { 31, 0x0022 }, /* R31 - Out3/4 Volume */
81
- { 32, 0x0079 }, /* R32 - Left OPGA Volume */
82
- { 33, 0x0079 }, /* R33 - Right OPGA Volume */
83
- { 34, 0x0003 }, /* R34 - Speaker Volume */
84
- { 35, 0x0003 }, /* R35 - ClassD1 */
85
-
86
- { 37, 0x0100 }, /* R37 - ClassD3 */
87
- { 38, 0x0079 }, /* R38 - ClassD4 */
88
- { 39, 0x0000 }, /* R39 - Input Mixer1 */
89
- { 40, 0x0000 }, /* R40 - Input Mixer2 */
90
- { 41, 0x0000 }, /* R41 - Input Mixer3 */
91
- { 42, 0x0000 }, /* R42 - Input Mixer4 */
92
- { 43, 0x0000 }, /* R43 - Input Mixer5 */
93
- { 44, 0x0000 }, /* R44 - Input Mixer6 */
94
- { 45, 0x0000 }, /* R45 - Output Mixer1 */
95
- { 46, 0x0000 }, /* R46 - Output Mixer2 */
96
- { 47, 0x0000 }, /* R47 - Output Mixer3 */
97
- { 48, 0x0000 }, /* R48 - Output Mixer4 */
98
- { 49, 0x0000 }, /* R49 - Output Mixer5 */
99
- { 50, 0x0000 }, /* R50 - Output Mixer6 */
100
- { 51, 0x0180 }, /* R51 - Out3/4 Mixer */
101
- { 52, 0x0000 }, /* R52 - Line Mixer1 */
102
- { 53, 0x0000 }, /* R53 - Line Mixer2 */
103
- { 54, 0x0000 }, /* R54 - Speaker Mixer */
104
- { 55, 0x0000 }, /* R55 - Additional Control */
105
- { 56, 0x0000 }, /* R56 - AntiPOP1 */
106
- { 57, 0x0000 }, /* R57 - AntiPOP2 */
107
- { 58, 0x0000 }, /* R58 - MICBIAS */
108
-
109
- { 60, 0x0008 }, /* R60 - PLL1 */
110
- { 61, 0x0031 }, /* R61 - PLL2 */
111
- { 62, 0x0026 }, /* R62 - PLL3 */
112
-};
113
-
11435 #define wm8990_reset(c) snd_soc_component_write(c, WM8990_RESET, 0)
115
-
116
-static const DECLARE_TLV_DB_SCALE(rec_mix_tlv, -1500, 600, 0);
11736
11837 static const DECLARE_TLV_DB_SCALE(in_pga_tlv, -1650, 3000, 0);
11938
12039 static const DECLARE_TLV_DB_SCALE(out_mix_tlv, 0, -2100, 0);
12140
12241 static const DECLARE_TLV_DB_SCALE(out_pga_tlv, -7300, 600, 0);
123
-
124
-static const DECLARE_TLV_DB_SCALE(out_omix_tlv, -600, 0, 0);
12542
12643 static const DECLARE_TLV_DB_SCALE(out_dac_tlv, -7163, 0, 0);
12744
....@@ -144,7 +61,7 @@
14461 return ret;
14562
14663 /* now hit the volume update bits (always bit 8) */
147
- val = snd_soc_component_read32(component, reg);
64
+ val = snd_soc_component_read(component, reg);
14865 return snd_soc_component_write(component, reg, val | 0x0100);
14966 }
15067
....@@ -381,7 +298,7 @@
381298
382299 switch (reg_shift) {
383300 case WM8990_SPEAKER_MIXER | (WM8990_LDSPK_BIT << 8) :
384
- reg = snd_soc_component_read32(component, WM8990_OUTPUT_MIXER1);
301
+ reg = snd_soc_component_read(component, WM8990_OUTPUT_MIXER1);
385302 if (reg & WM8990_LDLO) {
386303 printk(KERN_WARNING
387304 "Cannot set as Output Mixer 1 LDLO Set\n");
....@@ -389,7 +306,7 @@
389306 }
390307 break;
391308 case WM8990_SPEAKER_MIXER | (WM8990_RDSPK_BIT << 8):
392
- reg = snd_soc_component_read32(component, WM8990_OUTPUT_MIXER2);
309
+ reg = snd_soc_component_read(component, WM8990_OUTPUT_MIXER2);
393310 if (reg & WM8990_RDRO) {
394311 printk(KERN_WARNING
395312 "Cannot set as Output Mixer 2 RDRO Set\n");
....@@ -397,7 +314,7 @@
397314 }
398315 break;
399316 case WM8990_OUTPUT_MIXER1 | (WM8990_LDLO_BIT << 8):
400
- reg = snd_soc_component_read32(component, WM8990_SPEAKER_MIXER);
317
+ reg = snd_soc_component_read(component, WM8990_SPEAKER_MIXER);
401318 if (reg & WM8990_LDSPK) {
402319 printk(KERN_WARNING
403320 "Cannot set as Speaker Mixer LDSPK Set\n");
....@@ -405,7 +322,7 @@
405322 }
406323 break;
407324 case WM8990_OUTPUT_MIXER2 | (WM8990_RDRO_BIT << 8):
408
- reg = snd_soc_component_read32(component, WM8990_SPEAKER_MIXER);
325
+ reg = snd_soc_component_read(component, WM8990_SPEAKER_MIXER);
409326 if (reg & WM8990_RDSPK) {
410327 printk(KERN_WARNING
411328 "Cannot set as Speaker Mixer RDSPK Set\n");
....@@ -489,14 +406,6 @@
489406
490407 static const struct snd_kcontrol_new wm8990_dapm_ainrmux_controls =
491408 SOC_DAPM_ENUM("Route", wm8990_ainrmux_enum);
492
-
493
-/* RXVOICE */
494
-static const struct snd_kcontrol_new wm8990_dapm_rxvoice_controls[] = {
495
-SOC_DAPM_SINGLE_TLV("LIN4/RXN", WM8990_INPUT_MIXER5, WM8990_LR4BVOL_SHIFT,
496
- WM8990_LR4BVOL_MASK, 0, in_mix_tlv),
497
-SOC_DAPM_SINGLE_TLV("RIN4/RXP", WM8990_INPUT_MIXER6, WM8990_RL4BVOL_SHIFT,
498
- WM8990_RL4BVOL_MASK, 0, in_mix_tlv),
499
-};
500409
501410 /* LOMIX */
502411 static const struct snd_kcontrol_new wm8990_dapm_lomix_controls[] = {
....@@ -983,8 +892,8 @@
983892 struct snd_soc_component *component = codec_dai->component;
984893 u16 audio1, audio3;
985894
986
- audio1 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_1);
987
- audio3 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_3);
895
+ audio1 = snd_soc_component_read(component, WM8990_AUDIO_INTERFACE_1);
896
+ audio3 = snd_soc_component_read(component, WM8990_AUDIO_INTERFACE_3);
988897
989898 /* set master/slave audio interface */
990899 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
....@@ -1067,7 +976,7 @@
1067976 struct snd_soc_dai *dai)
1068977 {
1069978 struct snd_soc_component *component = dai->component;
1070
- u16 audio1 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_1);
979
+ u16 audio1 = snd_soc_component_read(component, WM8990_AUDIO_INTERFACE_1);
1071980
1072981 audio1 &= ~WM8990_AIF_WL_MASK;
1073982 /* bit size */
....@@ -1089,12 +998,12 @@
1089998 return 0;
1090999 }
10911000
1092
-static int wm8990_mute(struct snd_soc_dai *dai, int mute)
1001
+static int wm8990_mute(struct snd_soc_dai *dai, int mute, int direction)
10931002 {
10941003 struct snd_soc_component *component = dai->component;
10951004 u16 val;
10961005
1097
- val = snd_soc_component_read32(component, WM8990_DAC_CTRL) & ~WM8990_DAC_MUTE;
1006
+ val = snd_soc_component_read(component, WM8990_DAC_CTRL) & ~WM8990_DAC_MUTE;
10981007
10991008 if (mute)
11001009 snd_soc_component_write(component, WM8990_DAC_CTRL, val | WM8990_DAC_MUTE);
....@@ -1243,11 +1152,12 @@
12431152 */
12441153 static const struct snd_soc_dai_ops wm8990_dai_ops = {
12451154 .hw_params = wm8990_hw_params,
1246
- .digital_mute = wm8990_mute,
1155
+ .mute_stream = wm8990_mute,
12471156 .set_fmt = wm8990_set_dai_fmt,
12481157 .set_clkdiv = wm8990_set_dai_clkdiv,
12491158 .set_pll = wm8990_set_dai_pll,
12501159 .set_sysclk = wm8990_set_dai_sysclk,
1160
+ .no_capture_mute = 1,
12511161 };
12521162
12531163 static struct snd_soc_dai_driver wm8990_dai = {
....@@ -1308,17 +1218,6 @@
13081218 .use_pmdown_time = 1,
13091219 .endianness = 1,
13101220 .non_legacy_dai_naming = 1,
1311
-};
1312
-
1313
-static const struct regmap_config wm8990_regmap = {
1314
- .reg_bits = 8,
1315
- .val_bits = 16,
1316
-
1317
- .max_register = WM8990_PLL3,
1318
- .volatile_reg = wm8990_volatile_register,
1319
- .reg_defaults = wm8990_reg_defaults,
1320
- .num_reg_defaults = ARRAY_SIZE(wm8990_reg_defaults),
1321
- .cache_type = REGCACHE_RBTREE,
13221221 };
13231222
13241223 static int wm8990_i2c_probe(struct i2c_client *i2c,