Lines Matching +full:micbias2 +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-only
28 #include <linux/mfd/twl4030-audio.h>
59 u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1];
71 twl4030->ctl_cache[i - TWL4030_REG_EAR_CTL] = byte; in tw4030_init_ctl_cache()
81 return -EIO; in twl4030_read()
90 value = twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL]; in twl4030_read()
108 if (twl4030->earpiece_enabled) in twl4030_can_write_to_chip()
112 if (twl4030->predrivel_enabled) in twl4030_can_write_to_chip()
116 if (twl4030->predriver_enabled) in twl4030_can_write_to_chip()
120 if (twl4030->carkitl_enabled) in twl4030_can_write_to_chip()
124 if (twl4030->carkitr_enabled) in twl4030_can_write_to_chip()
128 if (twl4030->hsl_enabled || twl4030->hsr_enabled) in twl4030_can_write_to_chip()
153 twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL] = value; in twl4030_write()
180 if (enable == twl4030->codec_powered) in twl4030_codec_enable()
189 twl4030->codec_powered = enable; in twl4030_codec_enable()
202 &pdata->digimic_delay); in twl4030_setup_pdata_of()
204 &pdata->ramp_delay_value); in twl4030_setup_pdata_of()
206 &pdata->offset_cncl_path); in twl4030_setup_pdata_of()
208 pdata->hs_extmute = value; in twl4030_setup_pdata_of()
210 pdata->hs_extmute_gpio = of_get_named_gpio(node, in twl4030_setup_pdata_of()
212 if (gpio_is_valid(pdata->hs_extmute_gpio)) in twl4030_setup_pdata_of()
213 pdata->hs_extmute = 1; in twl4030_setup_pdata_of()
218 struct twl4030_codec_data *pdata = dev_get_platdata(component->dev); in twl4030_get_pdata()
221 twl4030_codec_node = of_get_child_by_name(component->dev->parent->of_node, in twl4030_get_pdata()
225 pdata = devm_kzalloc(component->dev, in twl4030_get_pdata()
248 if (pdata && pdata->hs_extmute) { in twl4030_init_chip()
249 if (gpio_is_valid(pdata->hs_extmute_gpio)) { in twl4030_init_chip()
252 if (!pdata->hs_extmute_gpio) in twl4030_init_chip()
253 dev_warn(component->dev, in twl4030_init_chip()
256 ret = gpio_request_one(pdata->hs_extmute_gpio, in twl4030_init_chip()
260 dev_err(component->dev, in twl4030_init_chip()
262 pdata->hs_extmute_gpio = -1; in twl4030_init_chip()
280 /* anti-pop when changing analog gain */ in twl4030_init_chip()
296 twl4030->pdata = pdata; in twl4030_init_chip()
300 reg |= (pdata->ramp_delay_value << 2); in twl4030_init_chip()
308 reg |= pdata->offset_cncl_path; in twl4030_init_chip()
336 twl4030->apll_enabled++; in twl4030_apll_enable()
337 if (twl4030->apll_enabled == 1) in twl4030_apll_enable()
341 twl4030->apll_enabled--; in twl4030_apll_enable()
342 if (!twl4030->apll_enabled) in twl4030_apll_enable()
513 /* Digital bypass gain, mute instead of -30dB */
515 0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1),
516 2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0),
517 4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
520 /* Digital bypass left (TX1L -> RX2L) */
526 /* Digital bypass right (TX1R -> RX2R) */
534 * from -51 to -10 dB in 1 dB steps (mute instead of -51 dB)
536 static DECLARE_TLV_DB_SCALE(twl4030_dapm_dbypassv_tlv, -5100, 100, 1);
538 /* Digital bypass voice: sidetone (VUL -> VDL)*/
556 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); \
561 twl4030->pin_name##_enabled = 1; \
565 twl4030->pin_name##_enabled = 0; \
585 /* HF ramp-up */ in handsfree_ramp()
596 /* HF ramp-down */ in handsfree_ramp()
611 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in handsfreelpga_event()
627 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in handsfreerpga_event()
643 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in vibramux_event()
652 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in apll_event()
668 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aif_event()
695 struct twl4030_codec_data *pdata = twl4030->pdata; in headset_ramp()
696 /* Base values for ramp delay calculation: 2^19 - 2^26 */ in headset_ramp()
704 twl4030->sysclk) + 1; in headset_ramp()
707 * the pop-noise */ in headset_ramp()
708 if (pdata && pdata->hs_extmute) { in headset_ramp()
709 if (gpio_is_valid(pdata->hs_extmute_gpio)) { in headset_ramp()
710 gpio_set_value(pdata->hs_extmute_gpio, 1); in headset_ramp()
718 /* Headset ramp-up according to the TRM */ in headset_ramp()
729 /* Headset ramp-down _not_ according to in headset_ramp()
744 if (pdata && pdata->hs_extmute) { in headset_ramp()
745 if (gpio_is_valid(pdata->hs_extmute_gpio)) { in headset_ramp()
746 gpio_set_value(pdata->hs_extmute_gpio, 0); in headset_ramp()
757 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in headsetlpga_event()
762 /* Do the ramp-up only once */ in headsetlpga_event()
763 if (!twl4030->hsr_enabled) in headsetlpga_event()
766 twl4030->hsl_enabled = 1; in headsetlpga_event()
769 /* Do the ramp-down only if both headsetL/R is disabled */ in headsetlpga_event()
770 if (!twl4030->hsr_enabled) in headsetlpga_event()
773 twl4030->hsl_enabled = 0; in headsetlpga_event()
782 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in headsetrpga_event()
787 /* Do the ramp-up only once */ in headsetrpga_event()
788 if (!twl4030->hsl_enabled) in headsetrpga_event()
791 twl4030->hsr_enabled = 1; in headsetrpga_event()
794 /* Do the ramp-down only if both headsetL/R is disabled */ in headsetrpga_event()
795 if (!twl4030->hsl_enabled) in headsetrpga_event()
798 twl4030->hsr_enabled = 0; in headsetrpga_event()
807 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in digimic_event()
809 struct twl4030_codec_data *pdata = twl4030->pdata; in digimic_event()
811 if (pdata && pdata->digimic_delay) in digimic_event()
812 twl4030_wait_ms(pdata->digimic_delay); in digimic_event()
822 * 0x3 : -6 dB
830 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_twl4030()
832 unsigned int reg = mc->reg; in snd_soc_get_volsw_twl4030()
833 unsigned int shift = mc->shift; in snd_soc_get_volsw_twl4030()
834 unsigned int rshift = mc->rshift; in snd_soc_get_volsw_twl4030()
835 int max = mc->max; in snd_soc_get_volsw_twl4030()
836 int mask = (1 << fls(max)) - 1; in snd_soc_get_volsw_twl4030()
838 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_twl4030()
840 if (ucontrol->value.integer.value[0]) in snd_soc_get_volsw_twl4030()
841 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_twl4030()
842 max + 1 - ucontrol->value.integer.value[0]; in snd_soc_get_volsw_twl4030()
845 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_twl4030()
847 if (ucontrol->value.integer.value[1]) in snd_soc_get_volsw_twl4030()
848 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_twl4030()
849 max + 1 - ucontrol->value.integer.value[1]; in snd_soc_get_volsw_twl4030()
859 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_twl4030()
861 unsigned int reg = mc->reg; in snd_soc_put_volsw_twl4030()
862 unsigned int shift = mc->shift; in snd_soc_put_volsw_twl4030()
863 unsigned int rshift = mc->rshift; in snd_soc_put_volsw_twl4030()
864 int max = mc->max; in snd_soc_put_volsw_twl4030()
865 int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_twl4030()
868 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_put_volsw_twl4030()
872 val = max + 1 - val; in snd_soc_put_volsw_twl4030()
875 val2 = (ucontrol->value.integer.value[1] & mask); in snd_soc_put_volsw_twl4030()
878 val2 = max + 1 - val2; in snd_soc_put_volsw_twl4030()
888 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_r2_twl4030()
890 unsigned int reg = mc->reg; in snd_soc_get_volsw_r2_twl4030()
891 unsigned int reg2 = mc->rreg; in snd_soc_get_volsw_r2_twl4030()
892 unsigned int shift = mc->shift; in snd_soc_get_volsw_r2_twl4030()
893 int max = mc->max; in snd_soc_get_volsw_r2_twl4030()
894 int mask = (1<<fls(max))-1; in snd_soc_get_volsw_r2_twl4030()
896 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_r2_twl4030()
898 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_r2_twl4030()
901 if (ucontrol->value.integer.value[0]) in snd_soc_get_volsw_r2_twl4030()
902 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_r2_twl4030()
903 max + 1 - ucontrol->value.integer.value[0]; in snd_soc_get_volsw_r2_twl4030()
904 if (ucontrol->value.integer.value[1]) in snd_soc_get_volsw_r2_twl4030()
905 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_r2_twl4030()
906 max + 1 - ucontrol->value.integer.value[1]; in snd_soc_get_volsw_r2_twl4030()
915 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_r2_twl4030()
917 unsigned int reg = mc->reg; in snd_soc_put_volsw_r2_twl4030()
918 unsigned int reg2 = mc->rreg; in snd_soc_put_volsw_r2_twl4030()
919 unsigned int shift = mc->shift; in snd_soc_put_volsw_r2_twl4030()
920 int max = mc->max; in snd_soc_put_volsw_r2_twl4030()
921 int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_r2_twl4030()
926 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_put_volsw_r2_twl4030()
927 val2 = (ucontrol->value.integer.value[1] & mask); in snd_soc_put_volsw_r2_twl4030()
930 val = max + 1 - val; in snd_soc_put_volsw_r2_twl4030()
932 val2 = max + 1 - val2; in snd_soc_put_volsw_r2_twl4030()
960 if (twl4030->configured) { in snd_soc_put_twl4030_opmode_enum_double()
961 dev_err(component->dev, in snd_soc_put_twl4030_opmode_enum_double()
962 "operation mode cannot be changed on-the-fly\n"); in snd_soc_put_twl4030_opmode_enum_double()
963 return -EBUSY; in snd_soc_put_twl4030_opmode_enum_double()
971 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB)
973 static DECLARE_TLV_DB_SCALE(digital_fine_tlv, -6300, 100, 1);
984 * from -37 to 12 dB in 1 dB steps (mute instead of -37 dB)
986 static DECLARE_TLV_DB_SCALE(digital_voice_downlink_tlv, -3700, 100, 1);
990 * -24 dB to 12 dB in 2 dB steps
992 static DECLARE_TLV_DB_SCALE(analog_tlv, -2400, 200, 0);
996 * -6 dB to 6 dB in 6 dB steps (mute instead of -12)
998 static DECLARE_TLV_DB_SCALE(output_tvl, -1200, 600, 1);
1002 * 0 dB to 12 dB in 6 dB steps (mute instead of -6)
1004 static DECLARE_TLV_DB_SCALE(output_ear_tvl, -600, 600, 1);
1037 /* Vibra H-bridge direction mode */
1039 "Vibra H-bridge direction", "Audio data MSB",
1046 /* Vibra H-bridge direction */
1142 SOC_ENUM("Vibra H-bridge mode", twl4030_vibradirmode_enum),
1143 SOC_ENUM("Vibra H-bridge direction", twl4030_vibradir_enum),
1355 SND_SOC_DAPM_SUPPLY("micbias2 select", TWL4030_REG_MICBIAS_CTL, 6, 0,
1370 /* Stream -> DAC mapping */
1377 /* ADC -> Stream mapping */
1392 /* Supply for the digital part (APLL) */
1512 {"DIGIMIC1", NULL, "micbias2 select"},
1544 /* Supply for the Analog loopbacks */
1594 if (mst_substream == twl4030->master_substream) in twl4030_constraints()
1595 slv_substream = twl4030->slave_substream; in twl4030_constraints()
1596 else if (mst_substream == twl4030->slave_substream) in twl4030_constraints()
1597 slv_substream = twl4030->master_substream; in twl4030_constraints()
1602 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1604 twl4030->rate); in twl4030_constraints()
1606 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1608 twl4030->sample_bits); in twl4030_constraints()
1610 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1612 twl4030->channels); in twl4030_constraints()
1640 struct snd_soc_component *component = dai->component; in twl4030_startup()
1643 if (twl4030->master_substream) { in twl4030_startup()
1644 twl4030->slave_substream = substream; in twl4030_startup()
1648 if (twl4030->configured) in twl4030_startup()
1649 twl4030_constraints(twl4030, twl4030->master_substream); in twl4030_startup()
1656 snd_pcm_hw_constraint_single(substream->runtime, in twl4030_startup()
1660 twl4030->master_substream = substream; in twl4030_startup()
1669 struct snd_soc_component *component = dai->component; in twl4030_shutdown()
1672 if (twl4030->master_substream == substream) in twl4030_shutdown()
1673 twl4030->master_substream = twl4030->slave_substream; in twl4030_shutdown()
1675 twl4030->slave_substream = NULL; in twl4030_shutdown()
1679 if (!twl4030->master_substream) in twl4030_shutdown()
1680 twl4030->configured = 0; in twl4030_shutdown()
1681 else if (!twl4030->master_substream->runtime->channels) in twl4030_shutdown()
1682 twl4030->configured = 0; in twl4030_shutdown()
1685 if (substream->runtime->channels == 4) in twl4030_shutdown()
1686 twl4030_tdm_enable(component, substream->stream, 0); in twl4030_shutdown()
1693 struct snd_soc_component *component = dai->component; in twl4030_hw_params()
1706 twl4030_tdm_enable(component, substream->stream, 1); in twl4030_hw_params()
1708 return -EINVAL; in twl4030_hw_params()
1711 if (twl4030->configured) in twl4030_hw_params()
1752 dev_err(component->dev, "%s: unknown rate %d\n", __func__, in twl4030_hw_params()
1754 return -EINVAL; in twl4030_hw_params()
1769 dev_err(component->dev, "%s: unsupported bits/sample %d\n", in twl4030_hw_params()
1771 return -EINVAL; in twl4030_hw_params()
1775 if (twl4030->codec_powered) { in twl4030_hw_params()
1792 twl4030->configured = 1; in twl4030_hw_params()
1793 twl4030->rate = params_rate(params); in twl4030_hw_params()
1794 twl4030->sample_bits = hw_param_interval(params, in twl4030_hw_params()
1795 SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min; in twl4030_hw_params()
1796 twl4030->channels = params_channels(params); in twl4030_hw_params()
1801 if (twl4030->slave_substream) in twl4030_hw_params()
1810 struct snd_soc_component *component = codec_dai->component; in twl4030_set_dai_sysclk()
1819 dev_err(component->dev, "Unsupported HFCLKIN: %u\n", freq); in twl4030_set_dai_sysclk()
1820 return -EINVAL; in twl4030_set_dai_sysclk()
1823 if ((freq / 1000) != twl4030->sysclk) { in twl4030_set_dai_sysclk()
1824 dev_err(component->dev, in twl4030_set_dai_sysclk()
1826 freq, twl4030->sysclk * 1000); in twl4030_set_dai_sysclk()
1827 return -EINVAL; in twl4030_set_dai_sysclk()
1835 struct snd_soc_component *component = codec_dai->component; in twl4030_set_dai_fmt()
1854 return -EINVAL; in twl4030_set_dai_fmt()
1867 return -EINVAL; in twl4030_set_dai_fmt()
1871 if (twl4030->codec_powered) { in twl4030_set_dai_fmt()
1889 struct snd_soc_component *component = dai->component; in twl4030_set_tristate()
1925 struct snd_soc_component *component = dai->component; in twl4030_voice_startup()
1932 if (twl4030->sysclk != 26000) { in twl4030_voice_startup()
1933 dev_err(component->dev, in twl4030_voice_startup()
1935 __func__, twl4030->sysclk); in twl4030_voice_startup()
1936 return -EINVAL; in twl4030_voice_startup()
1946 dev_err(component->dev, "%s: the codec mode is not option2\n", in twl4030_voice_startup()
1948 return -EINVAL; in twl4030_voice_startup()
1957 struct snd_soc_component *component = dai->component; in twl4030_voice_shutdown()
1960 twl4030_voice_enable(component, substream->stream, 0); in twl4030_voice_shutdown()
1967 struct snd_soc_component *component = dai->component; in twl4030_voice_hw_params()
1972 twl4030_voice_enable(component, substream->stream, 1); in twl4030_voice_hw_params()
1987 dev_err(component->dev, "%s: unknown rate %d\n", __func__, in twl4030_voice_hw_params()
1989 return -EINVAL; in twl4030_voice_hw_params()
1993 if (twl4030->codec_powered) { in twl4030_voice_hw_params()
2012 struct snd_soc_component *component = codec_dai->component; in twl4030_voice_set_dai_sysclk()
2016 dev_err(component->dev, in twl4030_voice_set_dai_sysclk()
2019 return -EINVAL; in twl4030_voice_set_dai_sysclk()
2021 if ((freq / 1000) != twl4030->sysclk) { in twl4030_voice_set_dai_sysclk()
2022 dev_err(component->dev, in twl4030_voice_set_dai_sysclk()
2024 freq, twl4030->sysclk * 1000); in twl4030_voice_set_dai_sysclk()
2025 return -EINVAL; in twl4030_voice_set_dai_sysclk()
2033 struct snd_soc_component *component = codec_dai->component; in twl4030_voice_set_dai_fmt()
2050 return -EINVAL; in twl4030_voice_set_dai_fmt()
2062 return -EINVAL; in twl4030_voice_set_dai_fmt()
2066 if (twl4030->codec_powered) { in twl4030_voice_set_dai_fmt()
2084 struct snd_soc_component *component = dai->component; in twl4030_voice_set_tristate()
2118 .name = "twl4030-hifi",
2136 .name = "twl4030-voice",
2157 twl4030 = devm_kzalloc(component->dev, sizeof(struct twl4030_priv), in twl4030_soc_probe()
2160 return -ENOMEM; in twl4030_soc_probe()
2163 twl4030->sysclk = twl4030_audio_get_mclk() / 1000; in twl4030_soc_probe()
2173 struct twl4030_codec_data *pdata = twl4030->pdata; in twl4030_soc_remove()
2175 if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio)) in twl4030_soc_remove()
2176 gpio_free(pdata->hs_extmute_gpio); in twl4030_soc_remove()
2198 return devm_snd_soc_register_component(&pdev->dev, in twl4030_codec_probe()
2203 MODULE_ALIAS("platform:twl4030-codec");
2208 .name = "twl4030-codec",