.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * wm8990.c -- WM8990 ALSA Soc Audio driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2008 Wolfson Microelectronics PLC. |
---|
5 | 6 | * 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. |
---|
11 | 7 | */ |
---|
12 | 8 | |
---|
13 | 9 | #include <linux/module.h> |
---|
.. | .. |
---|
36 | 32 | unsigned int pcmclk; |
---|
37 | 33 | }; |
---|
38 | 34 | |
---|
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 | | - |
---|
114 | 35 | #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); |
---|
117 | 36 | |
---|
118 | 37 | static const DECLARE_TLV_DB_SCALE(in_pga_tlv, -1650, 3000, 0); |
---|
119 | 38 | |
---|
120 | 39 | static const DECLARE_TLV_DB_SCALE(out_mix_tlv, 0, -2100, 0); |
---|
121 | 40 | |
---|
122 | 41 | 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); |
---|
125 | 42 | |
---|
126 | 43 | static const DECLARE_TLV_DB_SCALE(out_dac_tlv, -7163, 0, 0); |
---|
127 | 44 | |
---|
.. | .. |
---|
144 | 61 | return ret; |
---|
145 | 62 | |
---|
146 | 63 | /* 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); |
---|
148 | 65 | return snd_soc_component_write(component, reg, val | 0x0100); |
---|
149 | 66 | } |
---|
150 | 67 | |
---|
.. | .. |
---|
381 | 298 | |
---|
382 | 299 | switch (reg_shift) { |
---|
383 | 300 | 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); |
---|
385 | 302 | if (reg & WM8990_LDLO) { |
---|
386 | 303 | printk(KERN_WARNING |
---|
387 | 304 | "Cannot set as Output Mixer 1 LDLO Set\n"); |
---|
.. | .. |
---|
389 | 306 | } |
---|
390 | 307 | break; |
---|
391 | 308 | 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); |
---|
393 | 310 | if (reg & WM8990_RDRO) { |
---|
394 | 311 | printk(KERN_WARNING |
---|
395 | 312 | "Cannot set as Output Mixer 2 RDRO Set\n"); |
---|
.. | .. |
---|
397 | 314 | } |
---|
398 | 315 | break; |
---|
399 | 316 | 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); |
---|
401 | 318 | if (reg & WM8990_LDSPK) { |
---|
402 | 319 | printk(KERN_WARNING |
---|
403 | 320 | "Cannot set as Speaker Mixer LDSPK Set\n"); |
---|
.. | .. |
---|
405 | 322 | } |
---|
406 | 323 | break; |
---|
407 | 324 | 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); |
---|
409 | 326 | if (reg & WM8990_RDSPK) { |
---|
410 | 327 | printk(KERN_WARNING |
---|
411 | 328 | "Cannot set as Speaker Mixer RDSPK Set\n"); |
---|
.. | .. |
---|
489 | 406 | |
---|
490 | 407 | static const struct snd_kcontrol_new wm8990_dapm_ainrmux_controls = |
---|
491 | 408 | 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 | | -}; |
---|
500 | 409 | |
---|
501 | 410 | /* LOMIX */ |
---|
502 | 411 | static const struct snd_kcontrol_new wm8990_dapm_lomix_controls[] = { |
---|
.. | .. |
---|
983 | 892 | struct snd_soc_component *component = codec_dai->component; |
---|
984 | 893 | u16 audio1, audio3; |
---|
985 | 894 | |
---|
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); |
---|
988 | 897 | |
---|
989 | 898 | /* set master/slave audio interface */ |
---|
990 | 899 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
---|
.. | .. |
---|
1067 | 976 | struct snd_soc_dai *dai) |
---|
1068 | 977 | { |
---|
1069 | 978 | 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); |
---|
1071 | 980 | |
---|
1072 | 981 | audio1 &= ~WM8990_AIF_WL_MASK; |
---|
1073 | 982 | /* bit size */ |
---|
.. | .. |
---|
1089 | 998 | return 0; |
---|
1090 | 999 | } |
---|
1091 | 1000 | |
---|
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) |
---|
1093 | 1002 | { |
---|
1094 | 1003 | struct snd_soc_component *component = dai->component; |
---|
1095 | 1004 | u16 val; |
---|
1096 | 1005 | |
---|
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; |
---|
1098 | 1007 | |
---|
1099 | 1008 | if (mute) |
---|
1100 | 1009 | snd_soc_component_write(component, WM8990_DAC_CTRL, val | WM8990_DAC_MUTE); |
---|
.. | .. |
---|
1243 | 1152 | */ |
---|
1244 | 1153 | static const struct snd_soc_dai_ops wm8990_dai_ops = { |
---|
1245 | 1154 | .hw_params = wm8990_hw_params, |
---|
1246 | | - .digital_mute = wm8990_mute, |
---|
| 1155 | + .mute_stream = wm8990_mute, |
---|
1247 | 1156 | .set_fmt = wm8990_set_dai_fmt, |
---|
1248 | 1157 | .set_clkdiv = wm8990_set_dai_clkdiv, |
---|
1249 | 1158 | .set_pll = wm8990_set_dai_pll, |
---|
1250 | 1159 | .set_sysclk = wm8990_set_dai_sysclk, |
---|
| 1160 | + .no_capture_mute = 1, |
---|
1251 | 1161 | }; |
---|
1252 | 1162 | |
---|
1253 | 1163 | static struct snd_soc_dai_driver wm8990_dai = { |
---|
.. | .. |
---|
1308 | 1218 | .use_pmdown_time = 1, |
---|
1309 | 1219 | .endianness = 1, |
---|
1310 | 1220 | .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, |
---|
1322 | 1221 | }; |
---|
1323 | 1222 | |
---|
1324 | 1223 | static int wm8990_i2c_probe(struct i2c_client *i2c, |
---|