Lines Matching +full:static +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2012
8 * for ST-Ericsson.
14 * for ST-Ericsson.
31 #include <linux/mfd/abx500/ab8500-sysctrl.h>
32 #include <linux/mfd/abx500/ab8500-codec.h>
41 #include <sound/soc-dapm.h>
44 #include "ab8500-codec.h"
58 /* Nr of FIR/IIR-coeff banks in ANC-block */
79 static const char * const enum_sid_state[] = {
90 static const char * const enum_anc_state[] = {
123 /* Private data for AB8500 device-driver */
138 static inline const char *amic_micbias_str(enum amic_micbias micbias) in amic_micbias_str()
150 static inline const char *amic_type_str(enum amic_type type) in amic_type_str()
166 /* Read a register from the audio-bank of AB8500 */
167 static int ab8500_codec_read_reg(void *context, unsigned int reg, in ab8500_codec_read_reg()
181 /* Write to a register in the audio-bank of AB8500 */
182 static int ab8500_codec_write_reg(void *context, unsigned int reg, in ab8500_codec_write_reg()
191 static const struct regmap_config ab8500_codec_regmap = {
197 * Controls - DAPM
203 static const char * const enum_ear_lineout_source[] = {"Headset Left",
205 static SOC_ENUM_SINGLE_DECL(dapm_enum_ear_lineout_source, AB8500_DMICFILTCONF,
207 static const struct snd_kcontrol_new dapm_ear_lineout_source =
214 static const char * const enum_lineout_source[] = {"Mono Path", "Stereo Path"};
215 static SOC_ENUM_DOUBLE_DECL(dapm_enum_lineout_source, AB8500_ANACONF5,
218 static const struct snd_kcontrol_new dapm_lineout_source[] = {
224 /* Speaker Left - ANC selector */
225 static const char * const enum_HFx_sel[] = {"Audio Path", "ANC"};
226 static SOC_ENUM_SINGLE_DECL(dapm_enum_HFl_sel, AB8500_DIGMULTCONF2,
228 static const struct snd_kcontrol_new dapm_HFl_select[] = {
232 /* Speaker Right - ANC selector */
233 static SOC_ENUM_SINGLE_DECL(dapm_enum_HFr_sel, AB8500_DIGMULTCONF2,
235 static const struct snd_kcontrol_new dapm_HFr_select[] = {
241 /* Mic 1 - Mic 1a or 1b selector */
242 static const char * const enum_mic1ab_sel[] = {"Mic 1b", "Mic 1a"};
243 static SOC_ENUM_SINGLE_DECL(dapm_enum_mic1ab_sel, AB8500_ANACONF3,
245 static const struct snd_kcontrol_new dapm_mic1ab_mux[] = {
249 /* Mic 1 - AD3 - Mic 1 or DMic 3 selector */
250 static const char * const enum_ad3_sel[] = {"Mic 1", "DMic 3"};
251 static SOC_ENUM_SINGLE_DECL(dapm_enum_ad3_sel, AB8500_DIGMULTCONF1,
253 static const struct snd_kcontrol_new dapm_ad3_select[] = {
257 /* Mic 1 - AD6 - Mic 1 or DMic 6 selector */
258 static const char * const enum_ad6_sel[] = {"Mic 1", "DMic 6"};
259 static SOC_ENUM_SINGLE_DECL(dapm_enum_ad6_sel, AB8500_DIGMULTCONF1,
261 static const struct snd_kcontrol_new dapm_ad6_select[] = {
267 /* Mic 2 - AD5 - Mic 2 or DMic 5 selector */
268 static const char * const enum_ad5_sel[] = {"Mic 2", "DMic 5"};
269 static SOC_ENUM_SINGLE_DECL(dapm_enum_ad5_sel, AB8500_DIGMULTCONF1,
271 static const struct snd_kcontrol_new dapm_ad5_select[] = {
277 /* LineIn left - AD1 - LineIn Left or DMic 1 selector */
278 static const char * const enum_ad1_sel[] = {"LineIn Left", "DMic 1"};
279 static SOC_ENUM_SINGLE_DECL(dapm_enum_ad1_sel, AB8500_DIGMULTCONF1,
281 static const struct snd_kcontrol_new dapm_ad1_select[] = {
285 /* LineIn right - Mic 2 or LineIn Right selector */
286 static const char * const enum_mic2lr_sel[] = {"Mic 2", "LineIn Right"};
287 static SOC_ENUM_SINGLE_DECL(dapm_enum_mic2lr_sel, AB8500_ANACONF3,
289 static const struct snd_kcontrol_new dapm_mic2lr_select[] = {
293 /* LineIn right - AD2 - LineIn Right or DMic2 selector */
294 static const char * const enum_ad2_sel[] = {"LineIn Right", "DMic 2"};
295 static SOC_ENUM_SINGLE_DECL(dapm_enum_ad2_sel, AB8500_DIGMULTCONF1,
297 static const struct snd_kcontrol_new dapm_ad2_select[] = {
304 static const char * const enum_anc_in_sel[] = {"Mic 1 / DMic 6",
306 static SOC_ENUM_SINGLE_DECL(dapm_enum_anc_in_sel, AB8500_DMICFILTCONF,
308 static const struct snd_kcontrol_new dapm_anc_in_select[] = {
312 /* ANC - Enable/Disable */
313 static const struct snd_kcontrol_new dapm_anc_enable[] = {
318 /* ANC to Earpiece - Mute */
319 static const struct snd_kcontrol_new dapm_anc_ear_mute[] = {
328 /* Sidetone left - Input selector */
329 static const char * const enum_stfir1_in_sel[] = {
332 static SOC_ENUM_SINGLE_DECL(dapm_enum_stfir1_in_sel, AB8500_DIGMULTCONF2,
334 static const struct snd_kcontrol_new dapm_stfir1_in_select[] = {
340 /* Sidetone right - Input selector */
341 static const char * const enum_stfir2_in_sel[] = {
344 static SOC_ENUM_SINGLE_DECL(dapm_enum_stfir2_in_sel, AB8500_DIGMULTCONF2,
346 static const struct snd_kcontrol_new dapm_stfir2_in_select[] = {
352 static const char * const enum_pwm2vibx[] = {"Audio Path", "PWM Generator"};
354 static SOC_ENUM_SINGLE_DECL(dapm_enum_pwm2vib1, AB8500_PWMGENCONF1,
357 static const struct snd_kcontrol_new dapm_pwm2vib1[] = {
361 static SOC_ENUM_SINGLE_DECL(dapm_enum_pwm2vib2, AB8500_PWMGENCONF1,
364 static const struct snd_kcontrol_new dapm_pwm2vib2[] = {
369 * DAPM-widgets
372 static const struct snd_soc_dapm_widget ab8500_dapm_widgets[] = {
378 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AUD", 0, 0),
379 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC1", 0, 0),
380 SND_SOC_DAPM_REGULATOR_SUPPLY("V-AMIC2", 0, 0),
381 SND_SOC_DAPM_REGULATOR_SUPPLY("V-DMIC", 0, 0),
421 SND_SOC_DAPM_DAC("DA1 Enable", "ab8500_0p",
423 SND_SOC_DAPM_DAC("DA2 Enable", "ab8500_0p",
452 SND_SOC_DAPM_MIXER("HSL Enable",
455 SND_SOC_DAPM_MIXER("HSR Enable",
480 SND_SOC_DAPM_MIXER("LOL Enable",
483 SND_SOC_DAPM_MIXER("LOR Enable",
500 SND_SOC_DAPM_MIXER("EAR Enable",
530 SND_SOC_DAPM_MIXER("HFL Enable",
533 SND_SOC_DAPM_MIXER("HFR Enable",
561 SND_SOC_DAPM_MIXER("VIB1 Enable",
564 SND_SOC_DAPM_MIXER("VIB2 Enable",
580 SND_SOC_DAPM_MIXER("MIC1A V-AMICx Enable",
583 SND_SOC_DAPM_MIXER("MIC1B V-AMICx Enable",
594 SND_SOC_DAPM_MIXER("AD3 Enable",
605 SND_SOC_DAPM_MIXER("MIC2 V-AMICx Enable", AB8500_ANACONF2,
620 SND_SOC_DAPM_MIXER("LINL Enable", AB8500_ANACONF2,
623 SND_SOC_DAPM_MIXER("LINR Enable", AB8500_ANACONF2,
655 SND_SOC_DAPM_MIXER("AD12 Enable",
671 SND_SOC_DAPM_MIXER("AD57 Enable",
674 SND_SOC_DAPM_MIXER("AD68 Enable",
708 SND_SOC_DAPM_MIXER("AD4 Enable",
750 * DAPM-routes
752 static const struct snd_soc_dapm_route ab8500_dapm_routes[] = {
753 /* Power AB8500 audio-block when AD/DA is active */
754 {"Main Supply", NULL, "V-AUD"},
781 {"DA1 Enable", NULL, "DA_IN1"},
782 {"DA2 Enable", NULL, "DA_IN2"},
784 {"HSL Digital Volume", NULL, "DA1 Enable"},
785 {"HSR Digital Volume", NULL, "DA2 Enable"},
799 {"HSL Enable", NULL, "HSL Mute"},
800 {"HSR Enable", NULL, "HSR Mute"},
802 {"HSL Volume", NULL, "HSL Enable"},
803 {"HSR Volume", NULL, "HSR Enable"},
826 {"HFL Enable", NULL, "HFL DAC"},
827 {"HFR Enable", NULL, "HFR DAC"},
829 {"Speaker Left", NULL, "HFL Enable"},
830 {"Speaker Right", NULL, "HFR Enable"},
843 {"EAR Enable", NULL, "EAR Mute"},
845 {"Earpiece", NULL, "EAR Enable"},
861 {"LOL Enable", NULL, "LOL Disable HFL"},
862 {"LOR Enable", NULL, "LOR Disable HFR"},
864 {"LineOut Left", NULL, "LOL Enable"},
865 {"LineOut Right", NULL, "LOR Enable"},
882 {"VIB1 Enable", NULL, "Vibra 1 Controller"},
883 {"VIB2 Enable", NULL, "Vibra 2 Controller"},
885 {"Vibra 1", NULL, "VIB1 Enable"},
886 {"Vibra 2", NULL, "VIB2 Enable"},
891 {"MIC2 V-AMICx Enable", NULL, "Mic 2"},
897 {"LINL Enable", NULL, "LINL Mute"},
898 {"LINR Enable", NULL, "LINR Mute"},
901 {"Mic 2 or LINR Select", "LineIn Right", "LINR Enable"},
902 {"Mic 2 or LINR Select", "Mic 2", "MIC2 V-AMICx Enable"},
904 {"LINL ADC", NULL, "LINL Enable"},
913 {"AD12 Enable", NULL, "AD1 Channel Volume"},
914 {"AD12 Enable", NULL, "AD2 Channel Volume"},
917 {"AD_OUT1", NULL, "AD12 Enable"},
919 {"AD_OUT2", NULL, "AD12 Enable"},
925 {"MIC1A V-AMICx Enable", NULL, "MIC1 Mute"},
926 {"MIC1B V-AMICx Enable", NULL, "MIC1 Mute"},
928 {"Mic 1a or 1b Select", "Mic 1a", "MIC1A V-AMICx Enable"},
929 {"Mic 1a or 1b Select", "Mic 1b", "MIC1B V-AMICx Enable"},
937 {"AD3 Enable", NULL, "AD3 Channel Volume"},
940 {"AD_OUT3", NULL, "AD3 Enable"},
950 {"AD57 Enable", NULL, "AD5 Channel Volume"},
951 {"AD68 Enable", NULL, "AD6 Channel Volume"},
954 {"AD_OUT57", NULL, "AD57 Enable"},
956 {"AD_OUT68", NULL, "AD68 Enable"},
960 {"DMic 1", NULL, "V-DMIC"},
961 {"DMic 2", NULL, "V-DMIC"},
962 {"DMic 3", NULL, "V-DMIC"},
963 {"DMic 4", NULL, "V-DMIC"},
964 {"DMic 5", NULL, "V-DMIC"},
965 {"DMic 6", NULL, "V-DMIC"},
974 {"AD4 Enable", NULL, "AD4 Channel Volume"},
977 {"AD_OUT4", NULL, "AD4 Enable"},
981 {"LINL to HSL Volume", NULL, "LINL Enable"},
982 {"LINR to HSR Volume", NULL, "LINR Enable"},
1002 {"Sidetone Left Source", "LineIn Left", "AD12 Enable"},
1003 {"Sidetone Left Source", "LineIn Right", "AD12 Enable"},
1004 {"Sidetone Left Source", "Mic 1", "AD3 Enable"},
1006 {"Sidetone Right Source", "LineIn Right", "AD12 Enable"},
1007 {"Sidetone Right Source", "Mic 1", "AD3 Enable"},
1008 {"Sidetone Right Source", "DMic 4", "AD4 Enable"},
1017 {"DA1 Enable", NULL, "STFIR1 Volume"},
1018 {"DA2 Enable", NULL, "STFIR2 Volume"},
1021 static const struct snd_soc_dapm_route ab8500_dapm_routes_mic1a_vamicx[] = {
1022 {"MIC1A V-AMICx Enable", NULL, "V-AMIC1"},
1023 {"MIC1A V-AMICx Enable", NULL, "V-AMIC2"},
1026 static const struct snd_soc_dapm_route ab8500_dapm_routes_mic1b_vamicx[] = {
1027 {"MIC1B V-AMICx Enable", NULL, "V-AMIC1"},
1028 {"MIC1B V-AMICx Enable", NULL, "V-AMIC2"},
1031 static const struct snd_soc_dapm_route ab8500_dapm_routes_mic2_vamicx[] = {
1032 {"MIC2 V-AMICx Enable", NULL, "V-AMIC1"},
1033 {"MIC2 V-AMICx Enable", NULL, "V-AMIC2"},
1036 /* ANC FIR-coefficients configuration sequence */
1037 static void anc_fir(struct snd_soc_component *component, in anc_fir()
1048 if (par == AB8500_ANC_FIR_COEFFS - 1 && bnk == 1) in anc_fir()
1053 /* ANC IIR-coefficients configuration sequence */
1054 static void anc_iir(struct snd_soc_component *component, unsigned int bnk, in anc_iir()
1079 if (par == AB8500_ANC_IIR_COEFFS - 1 && bnk == 1) in anc_iir()
1084 /* ANC IIR-/FIR-coefficients configuration sequence */
1085 static void anc_configure(struct snd_soc_component *component, in anc_configure()
1088 struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); in anc_configure()
1091 dev_dbg(component->dev, "%s: Enter.\n", __func__); in anc_configure()
1104 drvdata->anc_fir_values[par]); in anc_configure()
1112 drvdata->anc_iir_values[par]); in anc_configure()
1116 dev_dbg(component->dev, "%s: Exit.\n", __func__); in anc_configure()
1120 * Control-events
1123 static int sid_status_control_get(struct snd_kcontrol *kcontrol, in sid_status_control_get()
1127 struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); in sid_status_control_get()
1129 mutex_lock(&drvdata->ctrl_lock); in sid_status_control_get()
1130 ucontrol->value.enumerated.item[0] = drvdata->sid_status; in sid_status_control_get()
1131 mutex_unlock(&drvdata->ctrl_lock); in sid_status_control_get()
1136 /* Write sidetone FIR-coefficients configuration sequence */
1137 static int sid_status_control_put(struct snd_kcontrol *kcontrol, in sid_status_control_put()
1141 struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); in sid_status_control_put()
1145 dev_dbg(component->dev, "%s: Enter\n", __func__); in sid_status_control_put()
1147 if (ucontrol->value.enumerated.item[0] != SID_APPLY_FIR) { in sid_status_control_put()
1148 dev_err(component->dev, in sid_status_control_put()
1151 return -EIO; in sid_status_control_put()
1154 mutex_lock(&drvdata->ctrl_lock); in sid_status_control_put()
1159 dev_err(component->dev, "%s: Sidetone busy while off!\n", in sid_status_control_put()
1161 status = -EPERM; in sid_status_control_put()
1163 status = -EBUSY; in sid_status_control_put()
1171 val = snd_soc_component_read(component, drvdata->sid_fir_values[param]); in sid_status_control_put()
1182 drvdata->sid_status = SID_FIR_CONFIGURED; in sid_status_control_put()
1185 mutex_unlock(&drvdata->ctrl_lock); in sid_status_control_put()
1187 dev_dbg(component->dev, "%s: Exit\n", __func__); in sid_status_control_put()
1192 static int anc_status_control_get(struct snd_kcontrol *kcontrol, in anc_status_control_get()
1196 struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); in anc_status_control_get()
1198 mutex_lock(&drvdata->ctrl_lock); in anc_status_control_get()
1199 ucontrol->value.enumerated.item[0] = drvdata->anc_status; in anc_status_control_get()
1200 mutex_unlock(&drvdata->ctrl_lock); in anc_status_control_get()
1205 static int anc_status_control_put(struct snd_kcontrol *kcontrol, in anc_status_control_put()
1210 struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); in anc_status_control_put()
1211 struct device *dev = component->dev; in anc_status_control_put()
1218 mutex_lock(&drvdata->ctrl_lock); in anc_status_control_put()
1220 req = ucontrol->value.enumerated.item[0]; in anc_status_control_put()
1222 status = -EINVAL; in anc_status_control_put()
1229 status = -EINVAL; in anc_status_control_put()
1238 "%s: ERROR: Failed to enable power (status = %d)!\n", in anc_status_control_put()
1247 if (drvdata->anc_status == ANC_IIR_CONFIGURED) in anc_status_control_put()
1248 drvdata->anc_status = ANC_FIR_IIR_CONFIGURED; in anc_status_control_put()
1249 else if (drvdata->anc_status != ANC_FIR_IIR_CONFIGURED) in anc_status_control_put()
1250 drvdata->anc_status = ANC_FIR_CONFIGURED; in anc_status_control_put()
1253 if (drvdata->anc_status == ANC_FIR_CONFIGURED) in anc_status_control_put()
1254 drvdata->anc_status = ANC_FIR_IIR_CONFIGURED; in anc_status_control_put()
1255 else if (drvdata->anc_status != ANC_FIR_IIR_CONFIGURED) in anc_status_control_put()
1256 drvdata->anc_status = ANC_IIR_CONFIGURED; in anc_status_control_put()
1263 mutex_unlock(&drvdata->ctrl_lock); in anc_status_control_put()
1274 static int filter_control_info(struct snd_kcontrol *kcontrol, in filter_control_info()
1278 (struct filter_control *)kcontrol->private_value; in filter_control_info()
1280 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in filter_control_info()
1281 uinfo->count = fc->count; in filter_control_info()
1282 uinfo->value.integer.min = fc->min; in filter_control_info()
1283 uinfo->value.integer.max = fc->max; in filter_control_info()
1288 static int filter_control_get(struct snd_kcontrol *kcontrol, in filter_control_get()
1294 (struct filter_control *)kcontrol->private_value; in filter_control_get()
1297 mutex_lock(&drvdata->ctrl_lock); in filter_control_get()
1298 for (i = 0; i < fc->count; i++) in filter_control_get()
1299 ucontrol->value.integer.value[i] = fc->value[i]; in filter_control_get()
1300 mutex_unlock(&drvdata->ctrl_lock); in filter_control_get()
1305 static int filter_control_put(struct snd_kcontrol *kcontrol, in filter_control_put()
1311 (struct filter_control *)kcontrol->private_value; in filter_control_put()
1314 mutex_lock(&drvdata->ctrl_lock); in filter_control_put()
1315 for (i = 0; i < fc->count; i++) in filter_control_put()
1316 fc->value[i] = ucontrol->value.integer.value[i]; in filter_control_put()
1317 mutex_unlock(&drvdata->ctrl_lock); in filter_control_put()
1323 * Controls - Non-DAPM ASoC
1326 static DECLARE_TLV_DB_SCALE(adx_dig_gain_tlv, -3200, 100, 1);
1327 /* -32dB = Mute */
1329 static DECLARE_TLV_DB_SCALE(dax_dig_gain_tlv, -6300, 100, 1);
1330 /* -63dB = Mute */
1332 static DECLARE_TLV_DB_SCALE(hs_ear_dig_gain_tlv, -100, 100, 1);
1333 /* -1dB = Mute */
1335 static const DECLARE_TLV_DB_RANGE(hs_gain_tlv,
1336 0, 3, TLV_DB_SCALE_ITEM(-3200, 400, 0),
1337 4, 15, TLV_DB_SCALE_ITEM(-1800, 200, 0)
1340 static DECLARE_TLV_DB_SCALE(mic_gain_tlv, 0, 100, 0);
1342 static DECLARE_TLV_DB_SCALE(lin_gain_tlv, -1000, 200, 0);
1344 static DECLARE_TLV_DB_SCALE(lin2hs_gain_tlv, -3800, 200, 1);
1345 /* -38dB = Mute */
1347 static const char * const enum_hsfadspeed[] = {"2ms", "0.5ms", "10.6ms",
1349 static SOC_ENUM_SINGLE_DECL(soc_enum_hsfadspeed,
1352 static const char * const enum_envdetthre[] = {
1357 static SOC_ENUM_SINGLE_DECL(soc_enum_envdeththre,
1359 static SOC_ENUM_SINGLE_DECL(soc_enum_envdetlthre,
1361 static const char * const enum_envdettime[] = {
1366 static SOC_ENUM_SINGLE_DECL(soc_enum_envdettime,
1369 static const char * const enum_sinc31[] = {"Sinc 3", "Sinc 1"};
1370 static SOC_ENUM_SINGLE_DECL(soc_enum_hsesinc, AB8500_HSLEARDIGGAIN,
1373 static const char * const enum_fadespeed[] = {"1ms", "4ms", "8ms", "16ms"};
1374 static SOC_ENUM_SINGLE_DECL(soc_enum_fadespeed, AB8500_HSRDIGGAIN,
1379 static const char * const enum_lowpow[] = {"Normal", "Low Power"};
1380 static SOC_ENUM_SINGLE_DECL(soc_enum_eardaclowpow, AB8500_ANACONF1,
1382 static SOC_ENUM_SINGLE_DECL(soc_enum_eardrvlowpow, AB8500_ANACONF1,
1385 static const char * const enum_av_mode[] = {"Audio", "Voice"};
1386 static SOC_ENUM_DOUBLE_DECL(soc_enum_ad12voice, AB8500_ADFILTCONF,
1388 static SOC_ENUM_DOUBLE_DECL(soc_enum_ad34voice, AB8500_ADFILTCONF,
1393 static SOC_ENUM_SINGLE_DECL(soc_enum_da12voice,
1396 static SOC_ENUM_SINGLE_DECL(soc_enum_da34voice,
1399 static SOC_ENUM_SINGLE_DECL(soc_enum_da56voice,
1403 static const char * const enum_da2hslr[] = {"Sidetone", "Audio Path"};
1404 static SOC_ENUM_DOUBLE_DECL(soc_enum_da2hslr, AB8500_DIGMULTCONF1,
1408 static const char * const enum_sinc53[] = {"Sinc 5", "Sinc 3"};
1409 static SOC_ENUM_DOUBLE_DECL(soc_enum_dmic12sinc, AB8500_DMICFILTCONF,
1412 static SOC_ENUM_DOUBLE_DECL(soc_enum_dmic34sinc, AB8500_DMICFILTCONF,
1415 static SOC_ENUM_DOUBLE_DECL(soc_enum_dmic56sinc, AB8500_DMICFILTCONF,
1419 /* Digital interface - DA from slot mapping */
1420 static const char * const enum_da_from_slot_map[] = {"SLOT0",
1452 static SOC_ENUM_SINGLE_DECL(soc_enum_da1slotmap,
1455 static SOC_ENUM_SINGLE_DECL(soc_enum_da2slotmap,
1458 static SOC_ENUM_SINGLE_DECL(soc_enum_da3slotmap,
1461 static SOC_ENUM_SINGLE_DECL(soc_enum_da4slotmap,
1464 static SOC_ENUM_SINGLE_DECL(soc_enum_da5slotmap,
1467 static SOC_ENUM_SINGLE_DECL(soc_enum_da6slotmap,
1470 static SOC_ENUM_SINGLE_DECL(soc_enum_da7slotmap,
1473 static SOC_ENUM_SINGLE_DECL(soc_enum_da8slotmap,
1477 /* Digital interface - AD to slot mapping */
1478 static const char * const enum_ad_to_slot_map[] = {"AD_OUT1",
1494 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot0map,
1497 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot1map,
1500 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot2map,
1503 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot3map,
1506 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot4map,
1509 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot5map,
1512 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot6map,
1515 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot7map,
1518 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot8map,
1521 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot9map,
1524 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot10map,
1527 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot11map,
1530 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot12map,
1533 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot13map,
1536 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot14map,
1539 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot15map,
1542 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot16map,
1545 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot17map,
1548 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot18map,
1551 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot19map,
1554 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot20map,
1557 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot21map,
1560 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot22map,
1563 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot23map,
1566 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot24map,
1569 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot25map,
1572 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot26map,
1575 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot27map,
1578 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot28map,
1581 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot29map,
1584 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot30map,
1587 static SOC_ENUM_SINGLE_DECL(soc_enum_adslot31map,
1591 /* Digital interface - Burst mode */
1592 static const char * const enum_mask[] = {"Unmasked", "Masked"};
1593 static SOC_ENUM_SINGLE_DECL(soc_enum_bfifomask,
1596 static const char * const enum_bitclk0[] = {"19_2_MHz", "38_4_MHz"};
1597 static SOC_ENUM_SINGLE_DECL(soc_enum_bfifo19m2,
1600 static const char * const enum_slavemaster[] = {"Slave", "Master"};
1601 static SOC_ENUM_SINGLE_DECL(soc_enum_bfifomast,
1606 static SOC_ENUM_SINGLE_EXT_DECL(soc_enum_sidstate, enum_sid_state);
1609 static SOC_ENUM_SINGLE_EXT_DECL(soc_enum_ancstate, enum_anc_state);
1611 static struct snd_kcontrol_new ab8500_ctrls[] = {
1781 /* Digital interface - DA from slot mapping */
1791 /* Digital interface - AD to slot mapping */
1825 /* Digital interface - Loopback */
1851 /* Digital interface - Burst FIFO */
1852 SOC_SINGLE("Digital Interface 0 FIFO Enable Switch",
1856 SOC_ENUM("Burst FIFO Bit-clock Frequency", soc_enum_bfifo19m2),
1866 SOC_SINGLE("Burst FIFO FS Extra Bit-clocks",
1907 static struct snd_kcontrol_new ab8500_filter_controls[] = {
1923 * Extended interface for codec-driver
1926 static int ab8500_audio_init_audioblock(struct snd_soc_component *component) in ab8500_audio_init_audioblock()
1930 dev_dbg(component->dev, "%s: Enter.\n", __func__); in ab8500_audio_init_audioblock()
1932 /* Reset audio-registers and disable 32kHz-clock output 2 */ in ab8500_audio_init_audioblock()
1943 static int ab8500_audio_setup_mics(struct snd_soc_component *component, in ab8500_audio_setup_mics()
1952 dev_dbg(component->dev, "%s: Enter.\n", __func__); in ab8500_audio_setup_mics()
1954 /* Set DMic-clocks to outputs */ in ab8500_audio_setup_mics()
1955 status = abx500_get_register_interruptible(component->dev, AB8500_MISC, in ab8500_audio_setup_mics()
1962 status = abx500_set_register_interruptible(component->dev, in ab8500_audio_setup_mics()
1969 /* Attach regulators to AMic DAPM-paths */ in ab8500_audio_setup_mics()
1970 dev_dbg(component->dev, "%s: Mic 1a regulator: %s\n", __func__, in ab8500_audio_setup_mics()
1971 amic_micbias_str(amics->mic1a_micbias)); in ab8500_audio_setup_mics()
1972 route = &ab8500_dapm_routes_mic1a_vamicx[amics->mic1a_micbias]; in ab8500_audio_setup_mics()
1974 dev_dbg(component->dev, "%s: Mic 1b regulator: %s\n", __func__, in ab8500_audio_setup_mics()
1975 amic_micbias_str(amics->mic1b_micbias)); in ab8500_audio_setup_mics()
1976 route = &ab8500_dapm_routes_mic1b_vamicx[amics->mic1b_micbias]; in ab8500_audio_setup_mics()
1978 dev_dbg(component->dev, "%s: Mic 2 regulator: %s\n", __func__, in ab8500_audio_setup_mics()
1979 amic_micbias_str(amics->mic2_micbias)); in ab8500_audio_setup_mics()
1980 route = &ab8500_dapm_routes_mic2_vamicx[amics->mic2_micbias]; in ab8500_audio_setup_mics()
1983 dev_err(component->dev, in ab8500_audio_setup_mics()
1984 "%s: Failed to add AMic-regulator DAPM-routes (%d).\n", in ab8500_audio_setup_mics()
1989 /* Set AMic-configuration */ in ab8500_audio_setup_mics()
1990 dev_dbg(component->dev, "%s: Mic 1 mic-type: %s\n", __func__, in ab8500_audio_setup_mics()
1991 amic_type_str(amics->mic1_type)); in ab8500_audio_setup_mics()
1993 amics->mic1_type == AMIC_TYPE_DIFFERENTIAL ? in ab8500_audio_setup_mics()
1995 dev_dbg(component->dev, "%s: Mic 2 mic-type: %s\n", __func__, in ab8500_audio_setup_mics()
1996 amic_type_str(amics->mic2_type)); in ab8500_audio_setup_mics()
1998 amics->mic2_type == AMIC_TYPE_DIFFERENTIAL ? in ab8500_audio_setup_mics()
2004 static int ab8500_audio_set_ear_cmv(struct snd_soc_component *component, in ab8500_audio_set_ear_cmv()
2023 dev_err(component->dev, in ab8500_audio_set_ear_cmv()
2024 "%s: Unknown earpiece CM-voltage (%d)!\n", in ab8500_audio_set_ear_cmv()
2026 return -EINVAL; in ab8500_audio_set_ear_cmv()
2028 dev_dbg(component->dev, "%s: Earpiece CM-voltage: %s\n", __func__, in ab8500_audio_set_ear_cmv()
2036 static int ab8500_audio_set_bit_delay(struct snd_soc_dai *dai, in ab8500_audio_set_bit_delay()
2040 struct snd_soc_component *component = dai->component; in ab8500_audio_set_bit_delay()
2052 dev_err(dai->component->dev, in ab8500_audio_set_bit_delay()
2053 "%s: ERROR: Unsupported bit-delay (0x%x)!\n", in ab8500_audio_set_bit_delay()
2055 return -EINVAL; in ab8500_audio_set_bit_delay()
2058 dev_dbg(dai->component->dev, "%s: IF0 Bit-delay: %d bits.\n", in ab8500_audio_set_bit_delay()
2066 static int ab8500_codec_set_dai_clock_gate(struct snd_soc_component *component, in ab8500_codec_set_dai_clock_gate()
2079 dev_dbg(component->dev, "%s: IF0 Clock is continuous.\n", in ab8500_codec_set_dai_clock_gate()
2084 dev_dbg(component->dev, "%s: IF0 Clock is gated.\n", in ab8500_codec_set_dai_clock_gate()
2088 dev_err(component->dev, in ab8500_codec_set_dai_clock_gate()
2091 return -EINVAL; in ab8500_codec_set_dai_clock_gate()
2099 static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) in ab8500_codec_set_dai_fmt()
2103 struct snd_soc_component *component = dai->component; in ab8500_codec_set_dai_fmt()
2106 dev_dbg(component->dev, "%s: Enter (fmt = 0x%x)\n", __func__, fmt); in ab8500_codec_set_dai_fmt()
2116 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_fmt()
2117 "%s: IF0 Master-mode: AB8500 master.\n", __func__); in ab8500_codec_set_dai_fmt()
2121 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_fmt()
2122 "%s: IF0 Master-mode: AB8500 slave.\n", __func__); in ab8500_codec_set_dai_fmt()
2126 dev_err(dai->component->dev, in ab8500_codec_set_dai_fmt()
2131 dev_err(dai->component->dev, in ab8500_codec_set_dai_fmt()
2134 return -EINVAL; in ab8500_codec_set_dai_fmt()
2142 dev_err(dai->component->dev, in ab8500_codec_set_dai_fmt()
2158 dev_dbg(dai->component->dev, "%s: IF0 Protocol: I2S\n", __func__); in ab8500_codec_set_dai_fmt()
2164 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_fmt()
2171 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_fmt()
2178 dev_err(dai->component->dev, in ab8500_codec_set_dai_fmt()
2181 return -EINVAL; in ab8500_codec_set_dai_fmt()
2186 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_fmt()
2191 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_fmt()
2197 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_fmt()
2203 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_fmt()
2210 dev_err(dai->component->dev, in ab8500_codec_set_dai_fmt()
2213 return -EINVAL; in ab8500_codec_set_dai_fmt()
2221 static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, in ab8500_codec_set_dai_tdm_slot()
2225 struct snd_soc_component *component = dai->component; in ab8500_codec_set_dai_tdm_slot()
2246 dev_err(dai->component->dev, "%s: Unsupported slot-width 0x%x\n", in ab8500_codec_set_dai_tdm_slot()
2248 return -EINVAL; in ab8500_codec_set_dai_tdm_slot()
2251 dev_dbg(dai->component->dev, "%s: IF0 slot-width: %d bits.\n", in ab8500_codec_set_dai_tdm_slot()
2256 dev_dbg(dai->component->dev, "%s: Slots, total: %d\n", __func__, slots); in ab8500_codec_set_dai_tdm_slot()
2274 dev_err(dai->component->dev, in ab8500_codec_set_dai_tdm_slot()
2277 return -EINVAL; in ab8500_codec_set_dai_tdm_slot()
2284 return -EINVAL; in ab8500_codec_set_dai_tdm_slot()
2290 dev_dbg(dai->component->dev, "%s: Slots, active, TX: %d\n", __func__, in ab8500_codec_set_dai_tdm_slot()
2312 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_tdm_slot()
2313 "%s: In 8-channel mode DA-from-slot mapping is set manually.", in ab8500_codec_set_dai_tdm_slot()
2317 dev_err(dai->component->dev, in ab8500_codec_set_dai_tdm_slot()
2318 "%s: Unsupported number of active TX-slots (%d)!\n", in ab8500_codec_set_dai_tdm_slot()
2320 return -EINVAL; in ab8500_codec_set_dai_tdm_slot()
2323 /* Setup TDM AD according to active RX-slots */ in ab8500_codec_set_dai_tdm_slot()
2326 return -EINVAL; in ab8500_codec_set_dai_tdm_slot()
2331 dev_dbg(dai->component->dev, "%s: Slots, active, RX: %d\n", __func__, in ab8500_codec_set_dai_tdm_slot()
2356 dev_dbg(dai->component->dev, in ab8500_codec_set_dai_tdm_slot()
2357 "%s: In 8-channel mode AD-to-slot mapping is set manually.", in ab8500_codec_set_dai_tdm_slot()
2361 dev_err(dai->component->dev, in ab8500_codec_set_dai_tdm_slot()
2362 "%s: Unsupported number of active RX-slots (%d)!\n", in ab8500_codec_set_dai_tdm_slot()
2364 return -EINVAL; in ab8500_codec_set_dai_tdm_slot()
2370 static const struct snd_soc_dai_ops ab8500_codec_ops = {
2375 static struct snd_soc_dai_driver ab8500_codec_dai[] = {
2377 .name = "ab8500-codec-dai.0",
2390 .name = "ab8500-codec-dai.1",
2404 static void ab8500_codec_of_probe(struct device *dev, struct device_node *np, in ab8500_codec_of_probe()
2409 if (of_property_read_bool(np, "stericsson,amic1-type-single-ended")) in ab8500_codec_of_probe()
2410 codec->amics.mic1_type = AMIC_TYPE_SINGLE_ENDED; in ab8500_codec_of_probe()
2412 codec->amics.mic1_type = AMIC_TYPE_DIFFERENTIAL; in ab8500_codec_of_probe()
2414 if (of_property_read_bool(np, "stericsson,amic2-type-single-ended")) in ab8500_codec_of_probe()
2415 codec->amics.mic2_type = AMIC_TYPE_SINGLE_ENDED; in ab8500_codec_of_probe()
2417 codec->amics.mic2_type = AMIC_TYPE_DIFFERENTIAL; in ab8500_codec_of_probe()
2419 /* Has a non-standard Vamic been requested? */ in ab8500_codec_of_probe()
2420 if (of_property_read_bool(np, "stericsson,amic1a-bias-vamic2")) in ab8500_codec_of_probe()
2421 codec->amics.mic1a_micbias = AMIC_MICBIAS_VAMIC2; in ab8500_codec_of_probe()
2423 codec->amics.mic1a_micbias = AMIC_MICBIAS_VAMIC1; in ab8500_codec_of_probe()
2425 if (of_property_read_bool(np, "stericsson,amic1b-bias-vamic2")) in ab8500_codec_of_probe()
2426 codec->amics.mic1b_micbias = AMIC_MICBIAS_VAMIC2; in ab8500_codec_of_probe()
2428 codec->amics.mic1b_micbias = AMIC_MICBIAS_VAMIC1; in ab8500_codec_of_probe()
2430 if (of_property_read_bool(np, "stericsson,amic2-bias-vamic1")) in ab8500_codec_of_probe()
2431 codec->amics.mic2_micbias = AMIC_MICBIAS_VAMIC1; in ab8500_codec_of_probe()
2433 codec->amics.mic2_micbias = AMIC_MICBIAS_VAMIC2; in ab8500_codec_of_probe()
2435 if (!of_property_read_u32(np, "stericsson,earpeice-cmv", &value)) { in ab8500_codec_of_probe()
2438 codec->ear_cmv = EAR_CMV_0_95V; in ab8500_codec_of_probe()
2441 codec->ear_cmv = EAR_CMV_1_10V; in ab8500_codec_of_probe()
2444 codec->ear_cmv = EAR_CMV_1_27V; in ab8500_codec_of_probe()
2447 codec->ear_cmv = EAR_CMV_1_58V; in ab8500_codec_of_probe()
2450 codec->ear_cmv = EAR_CMV_UNKNOWN; in ab8500_codec_of_probe()
2454 dev_warn(dev, "No earpiece voltage found in DT - using default\n"); in ab8500_codec_of_probe()
2455 codec->ear_cmv = EAR_CMV_0_95V; in ab8500_codec_of_probe()
2459 static int ab8500_codec_probe(struct snd_soc_component *component) in ab8500_codec_probe()
2462 struct device *dev = component->dev; in ab8500_codec_probe()
2463 struct device_node *np = dev->of_node; in ab8500_codec_probe()
2480 pr_err("%s: Failed to set earpiece CM-voltage (%d)!\n", in ab8500_codec_probe()
2487 dev_err(dev, "%s: failed to init audio-block (%d)!\n", in ab8500_codec_probe()
2492 /* Override HW-defaults */ in ab8500_codec_probe()
2509 drvdata->anc_fir_values = (long *)fc->value; in ab8500_codec_probe()
2512 drvdata->anc_iir_values = (long *)fc->value; in ab8500_codec_probe()
2515 drvdata->sid_fir_values = (long *)fc->value; in ab8500_codec_probe()
2519 mutex_init(&drvdata->ctrl_lock); in ab8500_codec_probe()
2524 static const struct snd_soc_component_driver ab8500_component_driver = {
2538 static int ab8500_codec_driver_probe(struct platform_device *pdev) in ab8500_codec_driver_probe()
2543 dev_dbg(&pdev->dev, "%s: Enter.\n", __func__); in ab8500_codec_driver_probe()
2545 /* Create driver private-data struct */ in ab8500_codec_driver_probe()
2546 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct ab8500_codec_drvdata), in ab8500_codec_driver_probe()
2549 return -ENOMEM; in ab8500_codec_driver_probe()
2550 drvdata->sid_status = SID_UNCONFIGURED; in ab8500_codec_driver_probe()
2551 drvdata->anc_status = ANC_UNCONFIGURED; in ab8500_codec_driver_probe()
2552 dev_set_drvdata(&pdev->dev, drvdata); in ab8500_codec_driver_probe()
2554 drvdata->regmap = devm_regmap_init(&pdev->dev, NULL, &pdev->dev, in ab8500_codec_driver_probe()
2556 if (IS_ERR(drvdata->regmap)) { in ab8500_codec_driver_probe()
2557 status = PTR_ERR(drvdata->regmap); in ab8500_codec_driver_probe()
2558 dev_err(&pdev->dev, "%s: Failed to allocate regmap: %d\n", in ab8500_codec_driver_probe()
2563 dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); in ab8500_codec_driver_probe()
2564 status = devm_snd_soc_register_component(&pdev->dev, in ab8500_codec_driver_probe()
2569 dev_err(&pdev->dev, in ab8500_codec_driver_probe()
2576 static struct platform_driver ab8500_codec_platform_driver = {
2578 .name = "ab8500-codec",