.. | .. |
---|
1 | | -/* |
---|
2 | | - * File: sound/soc/codecs/ssm2602.c |
---|
3 | | - * Author: Cliff Cai <Cliff.Cai@analog.com> |
---|
4 | | - * |
---|
5 | | - * Created: Tue June 06 2008 |
---|
6 | | - * Description: Driver for ssm2602 sound chip |
---|
7 | | - * |
---|
8 | | - * Modified: |
---|
9 | | - * Copyright 2008 Analog Devices Inc. |
---|
10 | | - * |
---|
11 | | - * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
---|
12 | | - * |
---|
13 | | - * This program is free software; you can redistribute it and/or modify |
---|
14 | | - * it under the terms of the GNU General Public License as published by |
---|
15 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
16 | | - * (at your option) any later version. |
---|
17 | | - * |
---|
18 | | - * This program is distributed in the hope that it will be useful, |
---|
19 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
21 | | - * GNU General Public License for more details. |
---|
22 | | - * |
---|
23 | | - * You should have received a copy of the GNU General Public License |
---|
24 | | - * along with this program; if not, see the file COPYING, or write |
---|
25 | | - * to the Free Software Foundation, Inc., |
---|
26 | | - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
27 | | - */ |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
| 2 | +// |
---|
| 3 | +// File: sound/soc/codecs/ssm2602.c |
---|
| 4 | +// Author: Cliff Cai <Cliff.Cai@analog.com> |
---|
| 5 | +// |
---|
| 6 | +// Created: Tue June 06 2008 |
---|
| 7 | +// Description: Driver for ssm2602 sound chip |
---|
| 8 | +// |
---|
| 9 | +// Modified: |
---|
| 10 | +// Copyright 2008 Analog Devices Inc. |
---|
| 11 | +// |
---|
| 12 | +// Bugs: Enter bugs at http://blackfin.uclinux.org/ |
---|
28 | 13 | |
---|
| 14 | +#include <linux/delay.h> |
---|
29 | 15 | #include <linux/module.h> |
---|
30 | 16 | #include <linux/regmap.h> |
---|
31 | 17 | #include <linux/slab.h> |
---|
.. | .. |
---|
65 | 51 | { .reg = 0x07, .def = 0x000a }, |
---|
66 | 52 | { .reg = 0x08, .def = 0x0000 }, |
---|
67 | 53 | { .reg = 0x09, .def = 0x0000 } |
---|
| 54 | +}; |
---|
| 55 | + |
---|
| 56 | +/* |
---|
| 57 | + * ssm2602 register patch |
---|
| 58 | + * Workaround for playback distortions after power up: activates digital |
---|
| 59 | + * core, and then powers on output, DAC, and whole chip at the same time |
---|
| 60 | + */ |
---|
| 61 | + |
---|
| 62 | +static const struct reg_sequence ssm2602_patch[] = { |
---|
| 63 | + { SSM2602_ACTIVE, 0x01 }, |
---|
| 64 | + { SSM2602_PWR, 0x07 }, |
---|
| 65 | + { SSM2602_RESET, 0x00 }, |
---|
68 | 66 | }; |
---|
69 | 67 | |
---|
70 | 68 | |
---|
.. | .. |
---|
111 | 109 | |
---|
112 | 110 | SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA, 0, 1, 0), |
---|
113 | 111 | SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA, 8, 1, 0), |
---|
114 | | -SOC_SINGLE("Mic Switch", SSM2602_APANA, 1, 1, 1), |
---|
115 | 112 | }; |
---|
116 | 113 | |
---|
117 | 114 | /* Output Mixer */ |
---|
.. | .. |
---|
121 | 118 | SOC_DAPM_SINGLE("Mic Sidetone Switch", SSM2602_APANA, 5, 1, 0), |
---|
122 | 119 | }; |
---|
123 | 120 | |
---|
| 121 | +static const struct snd_kcontrol_new mic_ctl = |
---|
| 122 | + SOC_DAPM_SINGLE("Switch", SSM2602_APANA, 1, 1, 1); |
---|
| 123 | + |
---|
124 | 124 | /* Input mux */ |
---|
125 | 125 | static const struct snd_kcontrol_new ssm2602_input_mux_controls = |
---|
126 | 126 | SOC_DAPM_ENUM("Input Select", ssm2602_enum[0]); |
---|
| 127 | + |
---|
| 128 | +static int ssm2602_mic_switch_event(struct snd_soc_dapm_widget *w, |
---|
| 129 | + struct snd_kcontrol *kcontrol, int event) |
---|
| 130 | +{ |
---|
| 131 | + /* |
---|
| 132 | + * According to the ssm2603 data sheet (control register sequencing), |
---|
| 133 | + * the digital core should be activated only after all necessary bits |
---|
| 134 | + * in the power register are enabled, and a delay determined by the |
---|
| 135 | + * decoupling capacitor on the VMID pin has passed. If the digital core |
---|
| 136 | + * is activated too early, or even before the ADC is powered up, audible |
---|
| 137 | + * artifacts appear at the beginning and end of the recorded signal. |
---|
| 138 | + * |
---|
| 139 | + * In practice, audible artifacts disappear well over 500 ms. |
---|
| 140 | + */ |
---|
| 141 | + msleep(500); |
---|
| 142 | + |
---|
| 143 | + return 0; |
---|
| 144 | +} |
---|
127 | 145 | |
---|
128 | 146 | static const struct snd_soc_dapm_widget ssm260x_dapm_widgets[] = { |
---|
129 | 147 | SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SSM2602_PWR, 3, 1), |
---|
.. | .. |
---|
145 | 163 | |
---|
146 | 164 | SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &ssm2602_input_mux_controls), |
---|
147 | 165 | SND_SOC_DAPM_MICBIAS("Mic Bias", SSM2602_PWR, 1, 1), |
---|
| 166 | + |
---|
| 167 | +SND_SOC_DAPM_SWITCH_E("Mic Switch", SSM2602_APANA, 1, 1, &mic_ctl, |
---|
| 168 | + ssm2602_mic_switch_event, SND_SOC_DAPM_PRE_PMU), |
---|
148 | 169 | |
---|
149 | 170 | SND_SOC_DAPM_OUTPUT("LHPOUT"), |
---|
150 | 171 | SND_SOC_DAPM_OUTPUT("RHPOUT"), |
---|
.. | .. |
---|
178 | 199 | {"LHPOUT", NULL, "Output Mixer"}, |
---|
179 | 200 | |
---|
180 | 201 | {"Input Mux", "Line", "Line Input"}, |
---|
181 | | - {"Input Mux", "Mic", "Mic Bias"}, |
---|
| 202 | + {"Input Mux", "Mic", "Mic Switch"}, |
---|
182 | 203 | {"ADC", NULL, "Input Mux"}, |
---|
| 204 | + |
---|
| 205 | + {"Mic Switch", NULL, "Mic Bias"}, |
---|
183 | 206 | |
---|
184 | 207 | {"Mic Bias", NULL, "MICIN"}, |
---|
185 | 208 | }; |
---|
.. | .. |
---|
327 | 350 | return 0; |
---|
328 | 351 | } |
---|
329 | 352 | |
---|
330 | | -static int ssm2602_mute(struct snd_soc_dai *dai, int mute) |
---|
| 353 | +static int ssm2602_mute(struct snd_soc_dai *dai, int mute, int direction) |
---|
331 | 354 | { |
---|
332 | 355 | struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(dai->component); |
---|
333 | 356 | |
---|
.. | .. |
---|
494 | 517 | static const struct snd_soc_dai_ops ssm2602_dai_ops = { |
---|
495 | 518 | .startup = ssm2602_startup, |
---|
496 | 519 | .hw_params = ssm2602_hw_params, |
---|
497 | | - .digital_mute = ssm2602_mute, |
---|
| 520 | + .mute_stream = ssm2602_mute, |
---|
498 | 521 | .set_sysclk = ssm2602_set_dai_sysclk, |
---|
499 | 522 | .set_fmt = ssm2602_set_dai_fmt, |
---|
| 523 | + .no_capture_mute = 1, |
---|
500 | 524 | }; |
---|
501 | 525 | |
---|
502 | 526 | static struct snd_soc_dai_driver ssm2602_dai = { |
---|
.. | .. |
---|
577 | 601 | return ret; |
---|
578 | 602 | } |
---|
579 | 603 | |
---|
| 604 | + regmap_register_patch(ssm2602->regmap, ssm2602_patch, |
---|
| 605 | + ARRAY_SIZE(ssm2602_patch)); |
---|
| 606 | + |
---|
580 | 607 | /* set the update bits */ |
---|
581 | 608 | regmap_update_bits(ssm2602->regmap, SSM2602_LINVOL, |
---|
582 | 609 | LINVOL_LRIN_BOTH, LINVOL_LRIN_BOTH); |
---|