22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/device.h>
25 #include <linux/slab.h>
50 #define CLK_32K_OUT2_DISABLE 0x01
51 #define INACTIVE_RESET_AUDIO 0x02
52 #define ENABLE_AUDIO_CLK_TO_AUDIO_BLK 0x10
53 #define ENABLE_VINTCORE12_SUPPLY 0x04
54 #define GPIO27_DIR_OUTPUT 0x04
55 #define GPIO29_DIR_OUTPUT 0x10
56 #define GPIO31_DIR_OUTPUT 0x40
59 #define AB8500_CTRL3_REG 0x0200
60 #define AB8500_GPIO_DIR4_REG 0x1013
63 #define AB8500_NR_OF_ANC_COEFF_BANKS 2
67 #define AB8500_ANC_SM_DELAY 2000
69 #define AB8500_FILTER_CONTROL(xname, xcount, xmin, xmax) \
70 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
71 .info = filter_control_info, \
72 .get = filter_control_get, .put = filter_control_put, \
73 .private_value = (unsigned long)&(struct filter_control) \
74 {.count = xcount, .min = xmin, .max = xmax} }
83 static const char *
const enum_sid_state[] = {
94 static const char *
const enum_anc_state[] = {
97 "FIR and IIR are configured",
140 static inline const char *amic_micbias_str(
enum amic_micbias micbias)
156 return "DIFFERENTIAL";
158 return "SINGLE ENDED";
173 unsigned int value = 0;
180 "%s: ERROR: Register (0x%02x:0x%02x) read failed (%d).\n",
184 "%s: Read 0x%02x from register 0x%02x:0x%02x\n",
186 value = (
unsigned int)value8;
193 static int ab8500_codec_write_reg(
struct snd_soc_codec *codec,
194 unsigned int reg,
unsigned int value)
202 "%s: ERROR: Register (%02x:%02x) write failed (%d).\n",
206 "%s: Wrote 0x%02x into register %02x:%02x\n",
219 static const char *
const enum_ear_lineout_source[] = {
"Headset Left",
225 dapm_enum_ear_lineout_source);
230 static const char *
const enum_lineout_source[] = {
"Mono Path",
"Stereo Path"};
241 static const char *
const enum_HFx_sel[] = {
"Audio Path",
"ANC"};
258 static const char *
const enum_mic1ab_sel[] = {
"Mic 1b",
"Mic 1a"};
266 static const char *
const enum_ad3_sel[] = {
"Mic 1",
"DMic 3"};
274 static const char *
const enum_ad6_sel[] = {
"Mic 1",
"DMic 6"};
284 static const char *
const enum_ad5_sel[] = {
"Mic 2",
"DMic 5"};
294 static const char *
const enum_ad1_sel[] = {
"LineIn Left",
"DMic 1"};
302 static const char *
const enum_mic2lr_sel[] = {
"Mic 2",
"LineIn Right"};
310 static const char *
const enum_ad2_sel[] = {
"LineIn Right",
"DMic 2"};
320 static const char *
const enum_anc_in_sel[] = {
"Mic 1 / DMic 6",
345 static const char *
const enum_stfir1_in_sel[] = {
346 "LineIn Left",
"LineIn Right",
"Mic 1",
"Headset Left"
351 SOC_DAPM_ENUM(
"Sidetone Left Source", dapm_enum_stfir1_in_sel),
357 static const char *
const enum_stfir2_in_sel[] = {
358 "LineIn Right",
"Mic 1",
"DMic 4",
"Headset Right"
363 SOC_DAPM_ENUM(
"Sidetone Right Source", dapm_enum_stfir2_in_sel),
368 static const char *
const enum_pwm2vibx[] = {
"Audio Path",
"PWM Generator"};
747 dapm_stfir1_in_select),
750 dapm_stfir2_in_select),
770 {
"Main Supply",
NULL,
"V-AUD"},
771 {
"Main Supply",
NULL,
"audioclk"},
772 {
"Main Supply",
NULL,
"Audio Power"},
773 {
"Main Supply",
NULL,
"Audio Analog Power"},
775 {
"DAC",
NULL,
"ab8500_0p"},
776 {
"DAC",
NULL,
"Main Supply"},
777 {
"ADC",
NULL,
"ab8500_0c"},
778 {
"ADC",
NULL,
"Main Supply"},
781 {
"ANC Configure Input",
NULL,
"Main Supply"},
782 {
"ANC Configure Output",
NULL,
"ANC Configure Input"},
785 {
"ADC",
NULL,
"ADC Input"},
786 {
"DAC Output",
NULL,
"DAC"},
790 {
"DA_IN1",
NULL,
"ab8500_0p"},
791 {
"DA_IN1",
NULL,
"Charge Pump"},
792 {
"DA_IN2",
NULL,
"ab8500_0p"},
793 {
"DA_IN2",
NULL,
"Charge Pump"},
797 {
"DA1 Enable",
NULL,
"DA_IN1"},
798 {
"DA2 Enable",
NULL,
"DA_IN2"},
800 {
"HSL Digital Volume",
NULL,
"DA1 Enable"},
801 {
"HSR Digital Volume",
NULL,
"DA2 Enable"},
803 {
"HSL DAC",
NULL,
"HSL Digital Volume"},
804 {
"HSR DAC",
NULL,
"HSR Digital Volume"},
806 {
"HSL DAC Mute",
NULL,
"HSL DAC"},
807 {
"HSR DAC Mute",
NULL,
"HSR DAC"},
809 {
"HSL DAC Driver",
NULL,
"HSL DAC Mute"},
810 {
"HSR DAC Driver",
NULL,
"HSR DAC Mute"},
812 {
"HSL Mute",
NULL,
"HSL DAC Driver"},
813 {
"HSR Mute",
NULL,
"HSR DAC Driver"},
815 {
"HSL Enable",
NULL,
"HSL Mute"},
816 {
"HSR Enable",
NULL,
"HSR Mute"},
818 {
"HSL Volume",
NULL,
"HSL Enable"},
819 {
"HSR Volume",
NULL,
"HSR Enable"},
821 {
"Headset Left",
NULL,
"HSL Volume"},
822 {
"Headset Right",
NULL,
"HSR Volume"},
826 {
"DA_IN3",
NULL,
"ab8500_0p"},
827 {
"DA3 Channel Volume",
NULL,
"DA_IN3"},
828 {
"DA_IN4",
NULL,
"ab8500_0p"},
829 {
"DA4 Channel Volume",
NULL,
"DA_IN4"},
831 {
"Speaker Left Source",
"Audio Path",
"DA3 Channel Volume"},
832 {
"Speaker Right Source",
"Audio Path",
"DA4 Channel Volume"},
834 {
"DA3 or ANC path to HfL",
NULL,
"Speaker Left Source"},
835 {
"DA4 or ANC path to HfR",
NULL,
"Speaker Right Source"},
839 {
"HFL DAC",
NULL,
"DA3 or ANC path to HfL"},
840 {
"HFR DAC",
NULL,
"DA4 or ANC path to HfR"},
842 {
"HFL Enable",
NULL,
"HFL DAC"},
843 {
"HFR Enable",
NULL,
"HFR DAC"},
845 {
"Speaker Left",
NULL,
"HFL Enable"},
846 {
"Speaker Right",
NULL,
"HFR Enable"},
850 {
"Earpiece or LineOut Mono Source",
"Headset Left",
851 "HSL Digital Volume"},
852 {
"Earpiece or LineOut Mono Source",
"Speaker Left",
853 "DA3 or ANC path to HfL"},
855 {
"EAR DAC",
NULL,
"Earpiece or LineOut Mono Source"},
857 {
"EAR Mute",
NULL,
"EAR DAC"},
859 {
"EAR Enable",
NULL,
"EAR Mute"},
861 {
"Earpiece",
NULL,
"EAR Enable"},
865 {
"LineOut Source",
"Stereo Path",
"HSL DAC Driver"},
866 {
"LineOut Source",
"Stereo Path",
"HSR DAC Driver"},
870 {
"LineOut Source",
"Mono Path",
"EAR DAC"},
874 {
"LOL Disable HFL",
NULL,
"LineOut Source"},
875 {
"LOR Disable HFR",
NULL,
"LineOut Source"},
877 {
"LOL Enable",
NULL,
"LOL Disable HFL"},
878 {
"LOR Enable",
NULL,
"LOR Disable HFR"},
880 {
"LineOut Left",
NULL,
"LOL Enable"},
881 {
"LineOut Right",
NULL,
"LOR Enable"},
885 {
"DA_IN5",
NULL,
"ab8500_0p"},
886 {
"DA5 Channel Volume",
NULL,
"DA_IN5"},
887 {
"DA_IN6",
NULL,
"ab8500_0p"},
888 {
"DA6 Channel Volume",
NULL,
"DA_IN6"},
890 {
"VIB1 DAC",
NULL,
"DA5 Channel Volume"},
891 {
"VIB2 DAC",
NULL,
"DA6 Channel Volume"},
893 {
"Vibra 1 Controller",
"Audio Path",
"VIB1 DAC"},
894 {
"Vibra 2 Controller",
"Audio Path",
"VIB2 DAC"},
895 {
"Vibra 1 Controller",
"PWM Generator",
"PWMGEN1"},
896 {
"Vibra 2 Controller",
"PWM Generator",
"PWMGEN2"},
898 {
"VIB1 Enable",
NULL,
"Vibra 1 Controller"},
899 {
"VIB2 Enable",
NULL,
"Vibra 2 Controller"},
901 {
"Vibra 1",
NULL,
"VIB1 Enable"},
902 {
"Vibra 2",
NULL,
"VIB2 Enable"},
907 {
"MIC2 V-AMICx Enable",
NULL,
"Mic 2"},
910 {
"LINL Mute",
NULL,
"LineIn Left"},
911 {
"LINR Mute",
NULL,
"LineIn Right"},
913 {
"LINL Enable",
NULL,
"LINL Mute"},
914 {
"LINR Enable",
NULL,
"LINR Mute"},
917 {
"Mic 2 or LINR Select",
"LineIn Right",
"LINR Enable"},
918 {
"Mic 2 or LINR Select",
"Mic 2",
"MIC2 V-AMICx Enable"},
920 {
"LINL ADC",
NULL,
"LINL Enable"},
921 {
"LINR ADC",
NULL,
"Mic 2 or LINR Select"},
923 {
"AD1 Source Select",
"LineIn Left",
"LINL ADC"},
924 {
"AD2 Source Select",
"LineIn Right",
"LINR ADC"},
926 {
"AD1 Channel Volume",
NULL,
"AD1 Source Select"},
927 {
"AD2 Channel Volume",
NULL,
"AD2 Source Select"},
929 {
"AD12 Enable",
NULL,
"AD1 Channel Volume"},
930 {
"AD12 Enable",
NULL,
"AD2 Channel Volume"},
932 {
"AD_OUT1",
NULL,
"ab8500_0c"},
933 {
"AD_OUT1",
NULL,
"AD12 Enable"},
934 {
"AD_OUT2",
NULL,
"ab8500_0c"},
935 {
"AD_OUT2",
NULL,
"AD12 Enable"},
939 {
"MIC1 Mute",
NULL,
"Mic 1"},
941 {
"MIC1A V-AMICx Enable",
NULL,
"MIC1 Mute"},
942 {
"MIC1B V-AMICx Enable",
NULL,
"MIC1 Mute"},
944 {
"Mic 1a or 1b Select",
"Mic 1a",
"MIC1A V-AMICx Enable"},
945 {
"Mic 1a or 1b Select",
"Mic 1b",
"MIC1B V-AMICx Enable"},
947 {
"MIC1 ADC",
NULL,
"Mic 1a or 1b Select"},
949 {
"AD3 Source Select",
"Mic 1",
"MIC1 ADC"},
951 {
"AD3 Channel Volume",
NULL,
"AD3 Source Select"},
953 {
"AD3 Enable",
NULL,
"AD3 Channel Volume"},
955 {
"AD_OUT3",
NULL,
"ab8500_0c"},
956 {
"AD_OUT3",
NULL,
"AD3 Enable"},
960 {
"AD5 Source Select",
"Mic 2",
"LINR ADC"},
961 {
"AD6 Source Select",
"Mic 1",
"MIC1 ADC"},
963 {
"AD5 Channel Volume",
NULL,
"AD5 Source Select"},
964 {
"AD6 Channel Volume",
NULL,
"AD6 Source Select"},
966 {
"AD57 Enable",
NULL,
"AD5 Channel Volume"},
967 {
"AD68 Enable",
NULL,
"AD6 Channel Volume"},
969 {
"AD_OUT57",
NULL,
"ab8500_0c"},
970 {
"AD_OUT57",
NULL,
"AD57 Enable"},
971 {
"AD_OUT68",
NULL,
"ab8500_0c"},
972 {
"AD_OUT68",
NULL,
"AD68 Enable"},
976 {
"DMic 1",
NULL,
"V-DMIC"},
977 {
"DMic 2",
NULL,
"V-DMIC"},
978 {
"DMic 3",
NULL,
"V-DMIC"},
979 {
"DMic 4",
NULL,
"V-DMIC"},
980 {
"DMic 5",
NULL,
"V-DMIC"},
981 {
"DMic 6",
NULL,
"V-DMIC"},
983 {
"AD1 Source Select",
NULL,
"DMic 1"},
984 {
"AD2 Source Select",
NULL,
"DMic 2"},
985 {
"AD3 Source Select",
NULL,
"DMic 3"},
986 {
"AD5 Source Select",
NULL,
"DMic 5"},
987 {
"AD6 Source Select",
NULL,
"DMic 6"},
989 {
"AD4 Channel Volume",
NULL,
"DMic 4"},
990 {
"AD4 Enable",
NULL,
"AD4 Channel Volume"},
992 {
"AD_OUT4",
NULL,
"ab8500_0c"},
993 {
"AD_OUT4",
NULL,
"AD4 Enable"},
997 {
"LINL to HSL Volume",
NULL,
"LINL Enable"},
998 {
"LINR to HSR Volume",
NULL,
"LINR Enable"},
1000 {
"HSL DAC Driver",
NULL,
"LINL to HSL Volume"},
1001 {
"HSR DAC Driver",
NULL,
"LINR to HSR Volume"},
1005 {
"ANC Source",
"Mic 2 / DMic 5",
"AD5 Channel Volume"},
1006 {
"ANC Source",
"Mic 1 / DMic 6",
"AD6 Channel Volume"},
1008 {
"ANC",
"Switch",
"ANC Source"},
1010 {
"Speaker Left Source",
"ANC",
"ANC"},
1011 {
"Speaker Right Source",
"ANC",
"ANC"},
1012 {
"ANC to Earpiece",
"Switch",
"ANC"},
1014 {
"HSL Digital Volume",
NULL,
"ANC to Earpiece"},
1018 {
"Sidetone Left Source",
"LineIn Left",
"AD12 Enable"},
1019 {
"Sidetone Left Source",
"LineIn Right",
"AD12 Enable"},
1020 {
"Sidetone Left Source",
"Mic 1",
"AD3 Enable"},
1021 {
"Sidetone Left Source",
"Headset Left",
"DA_IN1"},
1022 {
"Sidetone Right Source",
"LineIn Right",
"AD12 Enable"},
1023 {
"Sidetone Right Source",
"Mic 1",
"AD3 Enable"},
1024 {
"Sidetone Right Source",
"DMic 4",
"AD4 Enable"},
1025 {
"Sidetone Right Source",
"Headset Right",
"DA_IN2"},
1027 {
"STFIR1 Control",
NULL,
"Sidetone Left Source"},
1028 {
"STFIR2 Control",
NULL,
"Sidetone Right Source"},
1030 {
"STFIR1 Volume",
NULL,
"STFIR1 Control"},
1031 {
"STFIR2 Volume",
NULL,
"STFIR2 Control"},
1033 {
"DA1 Enable",
NULL,
"STFIR1 Volume"},
1034 {
"DA2 Enable",
NULL,
"STFIR2 Volume"},
1038 {
"MIC1A V-AMICx Enable",
NULL,
"V-AMIC1"},
1039 {
"MIC1A V-AMICx Enable",
NULL,
"V-AMIC2"},
1043 {
"MIC1B V-AMICx Enable",
NULL,
"V-AMIC1"},
1044 {
"MIC1B V-AMICx Enable",
NULL,
"V-AMIC2"},
1048 {
"MIC2 V-AMICx Enable",
NULL,
"V-AMIC1"},
1049 {
"MIC2 V-AMICx Enable",
NULL,
"V-AMIC2"},
1054 unsigned int bnk,
unsigned int par,
unsigned int val)
1056 if (par == 0 && bnk == 0)
1070 static void anc_iir(
struct snd_soc_codec *codec,
unsigned int bnk,
1071 unsigned int par,
unsigned int val)
1087 }
else if (par > 3) {
1102 bool apply_fir,
bool apply_iir)
1105 unsigned int bnk, par,
val;
1107 dev_dbg(codec->
dev,
"%s: Enter.\n", __func__);
1121 anc_fir(codec, bnk, par, val);
1129 anc_iir(codec, bnk, par, val);
1132 dev_dbg(codec->
dev,
"%s: Exit.\n", __func__);
1139 static int sid_status_control_get(
struct snd_kcontrol *kcontrol,
1153 static int sid_status_control_put(
struct snd_kcontrol *kcontrol,
1161 dev_dbg(codec->
dev,
"%s: Enter\n", __func__);
1165 "%s: ERROR: This control supports '%s' only!\n",
1175 dev_err(codec->
dev,
"%s: Sidetone busy while off!\n",
1208 static int anc_status_control_get(
struct snd_kcontrol *kcontrol,
1221 static int anc_status_control_put(
struct snd_kcontrol *kcontrol,
1227 bool apply_fir, apply_iir;
1230 dev_dbg(dev,
"%s: Enter.\n", __func__);
1234 req = ucontrol->
value.integer.value[0];
1237 dev_err(dev,
"%s: ERROR: Unsupported status to set '%s'!\n",
1238 __func__, enum_anc_state[req]);
1246 "ANC Configure Input");
1249 "%s: ERROR: Failed to enable power (status = %d)!\n",
1256 anc_configure(codec, apply_fir, apply_iir);
1279 dev_err(dev,
"%s: Unable to configure ANC! (status = %d)\n",
1282 dev_dbg(dev,
"%s: Exit.\n", __func__);
1284 return (status < 0) ? status : 1;
1287 static int filter_control_info(
struct snd_kcontrol *kcontrol,
1301 static int filter_control_get(
struct snd_kcontrol *kcontrol,
1317 static int filter_control_put(
struct snd_kcontrol *kcontrol,
1346 static const unsigned int hs_gain_tlv[] = {
1359 static const char *
const enum_hsfadspeed[] = {
"2ms",
"0.5ms",
"10.6ms",
1364 static const char *
const enum_envdetthre[] = {
1365 "250mV",
"300mV",
"350mV",
"400mV",
1366 "450mV",
"500mV",
"550mV",
"600mV",
1367 "650mV",
"700mV",
"750mV",
"800mV",
1368 "850mV",
"900mV",
"950mV",
"1.00V" };
1373 static const char *
const enum_envdettime[] = {
1374 "26.6us",
"53.2us",
"106us",
"213us",
1375 "426us",
"851us",
"1.70ms",
"3.40ms",
1376 "6.81ms",
"13.6ms",
"27.2ms",
"54.5ms",
1377 "109ms",
"218ms",
"436ms",
"872ms" };
1381 static const char *
const enum_sinc31[] = {
"Sinc 3",
"Sinc 1"};
1385 static const char *
const enum_fadespeed[] = {
"1ms",
"4ms",
"8ms",
"16ms"};
1391 static const char *
const enum_lowpow[] = {
"Normal",
"Low Power"};
1397 static const char *
const enum_av_mode[] = {
"Audio",
"Voice"};
1415 static const char *
const enum_da2hslr[] = {
"Sidetone",
"Audio Path"};
1420 static const char *
const enum_sinc53[] = {
"Sinc 5",
"Sinc 3"};
1432 static const char *
const enum_da_from_slot_map[] = {
"SLOT0",
1466 enum_da_from_slot_map);
1469 enum_da_from_slot_map);
1472 enum_da_from_slot_map);
1475 enum_da_from_slot_map);
1478 enum_da_from_slot_map);
1481 enum_da_from_slot_map);
1484 enum_da_from_slot_map);
1487 enum_da_from_slot_map);
1490 static const char *
const enum_ad_to_slot_map[] = {
"AD_OUT1",
1502 enum_ad_to_slot_map);
1505 enum_ad_to_slot_map);
1508 enum_ad_to_slot_map);
1511 enum_ad_to_slot_map);
1514 enum_ad_to_slot_map);
1517 enum_ad_to_slot_map);
1520 enum_ad_to_slot_map);
1523 enum_ad_to_slot_map);
1526 enum_ad_to_slot_map);
1529 enum_ad_to_slot_map);
1532 enum_ad_to_slot_map);
1535 enum_ad_to_slot_map);
1538 enum_ad_to_slot_map);
1541 enum_ad_to_slot_map);
1544 enum_ad_to_slot_map);
1547 enum_ad_to_slot_map);
1550 enum_ad_to_slot_map);
1553 enum_ad_to_slot_map);
1556 enum_ad_to_slot_map);
1559 enum_ad_to_slot_map);
1562 enum_ad_to_slot_map);
1565 enum_ad_to_slot_map);
1568 enum_ad_to_slot_map);
1571 enum_ad_to_slot_map);
1574 enum_ad_to_slot_map);
1577 enum_ad_to_slot_map);
1580 enum_ad_to_slot_map);
1583 enum_ad_to_slot_map);
1586 enum_ad_to_slot_map);
1589 enum_ad_to_slot_map);
1592 enum_ad_to_slot_map);
1595 enum_ad_to_slot_map);
1598 static const char *
const enum_mask[] = {
"Unmasked",
"Masked"};
1602 static const char *
const enum_bitclk0[] = {
"19_2_MHz",
"38_4_MHz"};
1606 static const char *
const enum_slavemaster[] = {
"Slave",
"Master"};
1619 SOC_ENUM(
"Charge Pump High Threshold For Low Voltage",
1620 soc_enum_envdeththre),
1621 SOC_ENUM(
"Charge Pump Low Threshold For Low Voltage",
1622 soc_enum_envdetlthre),
1623 SOC_SINGLE(
"Charge Pump Envelope Detection Switch",
1626 SOC_ENUM(
"Charge Pump Envelope Detection Decay Time",
1627 soc_enum_envdettime),
1630 SOC_ENUM(
"Headset Mode", soc_enum_da12voice),
1640 SOC_SINGLE(
"Headset DAC Drv Low Power Switch",
1643 SOC_ENUM(
"Headset Fade Speed", soc_enum_hsfadspeed),
1644 SOC_ENUM(
"Headset Source", soc_enum_da2hslr),
1645 SOC_ENUM(
"Headset Filter", soc_enum_hsesinc),
1659 soc_enum_eardaclowpow),
1661 soc_enum_eardrvlowpow),
1664 SOC_ENUM(
"HF Mode", soc_enum_da34voice),
1700 SOC_ENUM(
"Vibra Mode", soc_enum_da56voice),
1743 SOC_ENUM(
"Mic Mode", soc_enum_ad34voice),
1744 SOC_ENUM(
"Mic Filter", soc_enum_dmic34sinc),
1758 SOC_ENUM(
"LineIn Filter", soc_enum_dmic12sinc),
1759 SOC_ENUM(
"LineIn Mode", soc_enum_ad12voice),
1771 1, lin2hs_gain_tlv),
1774 SOC_ENUM(
"DMic Filter", soc_enum_dmic56sinc),
1780 SOC_ENUM(
"Digital Gain Fade Speed", soc_enum_fadespeed),
1788 SOC_ENUM(
"Digital Interface DA 1 From Slot Map", soc_enum_da1slotmap),
1789 SOC_ENUM(
"Digital Interface DA 2 From Slot Map", soc_enum_da2slotmap),
1790 SOC_ENUM(
"Digital Interface DA 3 From Slot Map", soc_enum_da3slotmap),
1791 SOC_ENUM(
"Digital Interface DA 4 From Slot Map", soc_enum_da4slotmap),
1792 SOC_ENUM(
"Digital Interface DA 5 From Slot Map", soc_enum_da5slotmap),
1793 SOC_ENUM(
"Digital Interface DA 6 From Slot Map", soc_enum_da6slotmap),
1794 SOC_ENUM(
"Digital Interface DA 7 From Slot Map", soc_enum_da7slotmap),
1795 SOC_ENUM(
"Digital Interface DA 8 From Slot Map", soc_enum_da8slotmap),
1798 SOC_ENUM(
"Digital Interface AD To Slot 0 Map", soc_enum_adslot0map),
1799 SOC_ENUM(
"Digital Interface AD To Slot 1 Map", soc_enum_adslot1map),
1800 SOC_ENUM(
"Digital Interface AD To Slot 2 Map", soc_enum_adslot2map),
1801 SOC_ENUM(
"Digital Interface AD To Slot 3 Map", soc_enum_adslot3map),
1802 SOC_ENUM(
"Digital Interface AD To Slot 4 Map", soc_enum_adslot4map),
1803 SOC_ENUM(
"Digital Interface AD To Slot 5 Map", soc_enum_adslot5map),
1804 SOC_ENUM(
"Digital Interface AD To Slot 6 Map", soc_enum_adslot6map),
1805 SOC_ENUM(
"Digital Interface AD To Slot 7 Map", soc_enum_adslot7map),
1806 SOC_ENUM(
"Digital Interface AD To Slot 8 Map", soc_enum_adslot8map),
1807 SOC_ENUM(
"Digital Interface AD To Slot 9 Map", soc_enum_adslot9map),
1808 SOC_ENUM(
"Digital Interface AD To Slot 10 Map", soc_enum_adslot10map),
1809 SOC_ENUM(
"Digital Interface AD To Slot 11 Map", soc_enum_adslot11map),
1810 SOC_ENUM(
"Digital Interface AD To Slot 12 Map", soc_enum_adslot12map),
1811 SOC_ENUM(
"Digital Interface AD To Slot 13 Map", soc_enum_adslot13map),
1812 SOC_ENUM(
"Digital Interface AD To Slot 14 Map", soc_enum_adslot14map),
1813 SOC_ENUM(
"Digital Interface AD To Slot 15 Map", soc_enum_adslot15map),
1814 SOC_ENUM(
"Digital Interface AD To Slot 16 Map", soc_enum_adslot16map),
1815 SOC_ENUM(
"Digital Interface AD To Slot 17 Map", soc_enum_adslot17map),
1816 SOC_ENUM(
"Digital Interface AD To Slot 18 Map", soc_enum_adslot18map),
1817 SOC_ENUM(
"Digital Interface AD To Slot 19 Map", soc_enum_adslot19map),
1818 SOC_ENUM(
"Digital Interface AD To Slot 20 Map", soc_enum_adslot20map),
1819 SOC_ENUM(
"Digital Interface AD To Slot 21 Map", soc_enum_adslot21map),
1820 SOC_ENUM(
"Digital Interface AD To Slot 22 Map", soc_enum_adslot22map),
1821 SOC_ENUM(
"Digital Interface AD To Slot 23 Map", soc_enum_adslot23map),
1822 SOC_ENUM(
"Digital Interface AD To Slot 24 Map", soc_enum_adslot24map),
1823 SOC_ENUM(
"Digital Interface AD To Slot 25 Map", soc_enum_adslot25map),
1824 SOC_ENUM(
"Digital Interface AD To Slot 26 Map", soc_enum_adslot26map),
1825 SOC_ENUM(
"Digital Interface AD To Slot 27 Map", soc_enum_adslot27map),
1826 SOC_ENUM(
"Digital Interface AD To Slot 28 Map", soc_enum_adslot28map),
1827 SOC_ENUM(
"Digital Interface AD To Slot 29 Map", soc_enum_adslot29map),
1828 SOC_ENUM(
"Digital Interface AD To Slot 30 Map", soc_enum_adslot30map),
1829 SOC_ENUM(
"Digital Interface AD To Slot 31 Map", soc_enum_adslot31map),
1832 SOC_SINGLE(
"Digital Interface AD 1 Loopback Switch",
1835 SOC_SINGLE(
"Digital Interface AD 2 Loopback Switch",
1838 SOC_SINGLE(
"Digital Interface AD 3 Loopback Switch",
1841 SOC_SINGLE(
"Digital Interface AD 4 Loopback Switch",
1844 SOC_SINGLE(
"Digital Interface AD 5 Loopback Switch",
1847 SOC_SINGLE(
"Digital Interface AD 6 Loopback Switch",
1850 SOC_SINGLE(
"Digital Interface AD 7 Loopback Switch",
1853 SOC_SINGLE(
"Digital Interface AD 8 Loopback Switch",
1858 SOC_SINGLE(
"Digital Interface 0 FIFO Enable Switch",
1861 SOC_ENUM(
"Burst FIFO Mask", soc_enum_bfifomask),
1862 SOC_ENUM(
"Burst FIFO Bit-clock Frequency", soc_enum_bfifo19m2),
1875 SOC_ENUM(
"Burst FIFO Interface Mode", soc_enum_bfifomast),
1892 anc_status_control_get, anc_status_control_put),
1908 sid_status_control_get, sid_status_control_put),
1932 static int ab8500_audio_init_audioblock(
struct snd_soc_codec *codec)
1936 dev_dbg(codec->
dev,
"%s: Enter.\n", __func__);
1949 static int ab8500_audio_setup_mics(
struct snd_soc_codec *codec,
1957 dev_dbg(codec->
dev,
"%s: Enter.\n", __func__);
1975 dev_dbg(codec->
dev,
"%s: Mic 1a regulator: %s\n", __func__,
1977 route = &ab8500_dapm_routes_mic1a_vamicx[amics->
mic1a_micbias];
1979 dev_dbg(codec->
dev,
"%s: Mic 1b regulator: %s\n", __func__,
1981 route = &ab8500_dapm_routes_mic1b_vamicx[amics->
mic1b_micbias];
1983 dev_dbg(codec->
dev,
"%s: Mic 2 regulator: %s\n", __func__,
1985 route = &ab8500_dapm_routes_mic2_vamicx[amics->
mic2_micbias];
1989 "%s: Failed to add AMic-regulator DAPM-routes (%d).\n",
1995 dev_dbg(codec->
dev,
"%s: Mic 1 mic-type: %s\n", __func__,
2000 dev_dbg(codec->
dev,
"%s: Mic 2 mic-type: %s\n", __func__,
2010 static int ab8500_audio_set_ear_cmv(
struct snd_soc_codec *codec,
2030 "%s: Unknown earpiece CM-voltage (%d)!\n",
2031 __func__, (
int)ear_cmv);
2034 dev_dbg(codec->
dev,
"%s: Earpiece CM-voltage: %s\n", __func__,
2060 "%s: ERROR: Unsupported bit-delay (0x%x)!\n",
2065 dev_dbg(dai->
codec->dev,
"%s: IF0 Bit-delay: %d bits.\n",
2073 static int ab8500_codec_set_dai_clock_gate(
struct snd_soc_codec *codec,
2086 dev_dbg(codec->
dev,
"%s: IF0 Clock is continuous.\n",
2091 dev_dbg(codec->
dev,
"%s: IF0 Clock is gated.\n",
2096 "%s: ERROR: Unsupported clock mask (0x%x)!\n",
2097 __func__, fmt & SND_SOC_DAIFMT_CLOCK_MASK);
2106 static int ab8500_codec_set_dai_fmt(
struct snd_soc_dai *dai,
unsigned int fmt)
2113 dev_dbg(codec->
dev,
"%s: Enter (fmt = 0x%x)\n", __func__, fmt);
2124 "%s: IF0 Master-mode: AB8500 master.\n", __func__);
2129 "%s: IF0 Master-mode: AB8500 slave.\n", __func__);
2134 "%s: ERROR: The device is either a master or a slave.\n",
2138 "%s: ERROR: Unsupporter master mask 0x%x\n",
2139 __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
2147 status = ab8500_codec_set_dai_clock_gate(codec, fmt);
2150 "%s: ERRROR: Failed to set clock gate (%d).\n",
2165 dev_dbg(dai->
codec->dev,
"%s: IF0 Protocol: I2S\n", __func__);
2167 ab8500_audio_set_bit_delay(dai, 0);
2172 "%s: IF0 Protocol: DSP A (TDM)\n", __func__);
2174 ab8500_audio_set_bit_delay(dai, 1);
2179 "%s: IF0 Protocol: DSP B (TDM)\n", __func__);
2181 ab8500_audio_set_bit_delay(dai, 0);
2186 "%s: ERROR: Unsupported format (0x%x)!\n",
2187 __func__, fmt & SND_SOC_DAIFMT_FORMAT_MASK);
2194 "%s: IF0: Normal bit clock, normal frame\n",
2199 "%s: IF0: Normal bit clock, inverted frame\n",
2205 "%s: IF0: Inverted bit clock, normal frame\n",
2211 "%s: IF0: Inverted bit clock, inverted frame\n",
2218 "%s: ERROR: Unsupported INV mask 0x%x\n",
2219 __func__, fmt & SND_SOC_DAIFMT_INV_MASK);
2228 static int ab8500_codec_set_dai_tdm_slot(
struct snd_soc_dai *dai,
2233 unsigned int val,
mask, slots_active;
2239 switch (slot_width) {
2253 dev_err(dai->
codec->dev,
"%s: Unsupported slot-width 0x%x\n",
2254 __func__, slot_width);
2258 dev_dbg(dai->
codec->dev,
"%s: IF0 slot-width: %d bits.\n",
2259 __func__, slot_width);
2263 dev_dbg(dai->
codec->dev,
"%s: Slots, total: %d\n", __func__, slots);
2282 "%s: ERROR: Unsupported number of slots (%d)!\n",
2291 dev_dbg(dai->
codec->dev,
"%s: Slots, active, TX: %d\n", __func__,
2293 switch (slots_active) {
2313 "%s: In 8-channel mode DA-from-slot mapping is set manually.",
2318 "%s: Unsupported number of active TX-slots (%d)!\n",
2319 __func__, slots_active);
2325 dev_dbg(dai->
codec->dev,
"%s: Slots, active, RX: %d\n", __func__,
2327 switch (slots_active) {
2346 "%s: In 8-channel mode AD-to-slot mapping is set manually.",
2351 "%s: Unsupported number of active RX-slots (%d)!\n",
2352 __func__, slots_active);
2361 .name =
"ab8500-codec-dai.0",
2364 .stream_name =
"ab8500_0p",
2372 .set_tdm_slot = ab8500_codec_set_dai_tdm_slot,
2373 .set_fmt = ab8500_codec_set_dai_fmt,
2376 .symmetric_rates = 1
2379 .name =
"ab8500-codec-dai.1",
2382 .stream_name =
"ab8500_0c",
2390 .set_tdm_slot = ab8500_codec_set_dai_tdm_slot,
2391 .set_fmt = ab8500_codec_set_dai_fmt,
2394 .symmetric_rates = 1
2429 if (!of_property_read_u32(np,
"stericsson,earpeice-cmv", &value)) {
2445 dev_err(dev,
"Unsuitable earpiece voltage found in DT\n");
2448 dev_warn(dev,
"No earpiece voltage found in DT - using default\n");
2462 dev_dbg(dev,
"%s: Enter.\n", __func__);
2465 pdata = dev_get_platdata(dev->
parent);
2473 if (pdata && !pdata->
codec)
2479 if (!(pdata && pdata->
codec))
2482 ab8500_codec_of_probe(dev, np, pdata->
codec);
2485 if (!(pdata && pdata->
codec)) {
2486 dev_err(dev,
"No codec platform data or DT found\n");
2491 status = ab8500_audio_setup_mics(codec, &pdata->
codec->amics);
2493 pr_err(
"%s: Failed to setup mics (%d)!\n", __func__, status);
2496 status = ab8500_audio_set_ear_cmv(codec, pdata->
codec->ear_cmv);
2498 pr_err(
"%s: Failed to set earpiece CM-voltage (%d)!\n",
2503 status = ab8500_audio_init_audioblock(codec);
2505 dev_err(dev,
"%s: failed to init audio-block (%d)!\n",
2511 ab8500_codec_write_reg(codec,
2514 ab8500_codec_write_reg(codec,
2523 "%s: failed to add ab8500 filter controls (%d).\n",
2545 .probe = ab8500_codec_probe,
2546 .read = ab8500_codec_read_reg,
2547 .write = ab8500_codec_write_reg,
2548 .reg_word_size =
sizeof(
u8),
2551 .dapm_widgets = ab8500_dapm_widgets,
2552 .num_dapm_widgets =
ARRAY_SIZE(ab8500_dapm_widgets),
2553 .dapm_routes = ab8500_dapm_routes,
2554 .num_dapm_routes =
ARRAY_SIZE(ab8500_dapm_routes),
2562 dev_dbg(&pdev->
dev,
"%s: Enter.\n", __func__);
2571 dev_dbg(&pdev->
dev,
"%s: Register codec.\n", __func__);
2577 "%s: Error: Failed to register codec (%d).\n",
2594 .name =
"ab8500-codec",
2597 .probe = ab8500_codec_driver_probe,
2598 .remove =
__devexit_p(ab8500_codec_driver_remove),