Lines Matching +full:gpio +full:- +full:mux

20  *  ---------------------------------------
21 * MONO_LOUT -> N/A | MONO_LOUT -> N/A
22 * | IN1L -> LINE1L
23 * | IN1R -> LINE1R
24 * | IN2L -> LINE2L
25 * | IN2R -> LINE2R
26 * | MIC3L/R -> N/A
29 * ---------------------------------------
41 #include <linux/gpio.h>
126 * wanting to read volatile bits from those registers that has both read-only
132 u8 *cache = codec->reg_cache; in aic3x_read()
134 if (codec->cache_only) in aic3x_read()
135 return -EINVAL; in aic3x_read()
137 return -1; in aic3x_read()
139 codec->cache_bypass = 1; in aic3x_read()
141 codec->cache_bypass = 0; in aic3x_read()
162 struct snd_soc_dapm_widget *widget = wlist->widgets[0]; in snd_soc_dapm_put_volsw_aic3x()
164 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_dapm_put_volsw_aic3x()
165 unsigned int reg = mc->reg; in snd_soc_dapm_put_volsw_aic3x()
166 unsigned int shift = mc->shift; in snd_soc_dapm_put_volsw_aic3x()
167 int max = mc->max; in snd_soc_dapm_put_volsw_aic3x()
168 unsigned int mask = (1 << fls(max)) - 1; in snd_soc_dapm_put_volsw_aic3x()
169 unsigned int invert = mc->invert; in snd_soc_dapm_put_volsw_aic3x()
175 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_dapm_put_volsw_aic3x()
182 val = mask - val; in snd_soc_dapm_put_volsw_aic3x()
186 mutex_lock(&widget->codec->mutex); in snd_soc_dapm_put_volsw_aic3x()
188 if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) { in snd_soc_dapm_put_volsw_aic3x()
190 list_for_each_entry(path, &widget->dapm->card->paths, list) { in snd_soc_dapm_put_volsw_aic3x()
191 if (path->kcontrol != kcontrol) in snd_soc_dapm_put_volsw_aic3x()
198 path->connect = invert ? 0 : 1; in snd_soc_dapm_put_volsw_aic3x()
201 path->connect = invert ? 1 : 0; in snd_soc_dapm_put_volsw_aic3x()
203 dapm_mark_dirty(path->source, "tlv320aic3x source"); in snd_soc_dapm_put_volsw_aic3x()
204 dapm_mark_dirty(path->sink, "tlv320aic3x sink"); in snd_soc_dapm_put_volsw_aic3x()
210 snd_soc_dapm_sync(widget->dapm); in snd_soc_dapm_put_volsw_aic3x()
213 ret = snd_soc_update_bits(widget->codec, reg, val_mask, val); in snd_soc_dapm_put_volsw_aic3x()
215 mutex_unlock(&widget->codec->mutex); in snd_soc_dapm_put_volsw_aic3x()
222 { "differential of HPLOUT", "constant VCM", "single-ended" };
224 { "differential of HPROUT", "constant VCM", "single-ended",
226 static const char *aic3x_linein_mode_mux[] = { "single-ended", "differential" };
257 * DAC digital volumes. From -63.5 to 0 dB in 0.5 dB steps
259 static DECLARE_TLV_DB_SCALE(dac_tlv, -6350, 50, 0);
263 * Output stage volumes. From -78.3 to 0 dB. Muted below -78.3 dB.
266 * Define dB scale so that it is mostly correct for range about -55 to 0 dB
268 * so much). This setting shows -50 dB (actual is -50.3 dB) for register
269 * value 100 and -58.5 dB (actual is -78.3 dB) for register value 117.
271 static DECLARE_TLV_DB_SCALE(output_stage_tlv, -5900, 50, 1);
280 * only for swapped L-to-R and R-to-L routes. See below stereo controls
281 * for direct L-to-L and R-to-R routes.
325 /* Stereo output controls for direct L-to-L and R-to-R routes */
386 SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]),
390 * Class-D amplifier gain. From 0 to 18 dB in 6 dB steps
395 SOC_DOUBLE_TLV("Class-D Amplifier Gain", CLASSD_CTRL, 6, 4, 3, 0, classd_amp_tlv);
397 /* Left DAC Mux */
401 /* Right DAC Mux */
405 /* Left HPCOM Mux */
409 /* Right HPCOM Mux */
501 /* Left Line1 Mux */
507 /* Right Line1 Mux */
513 /* Left Line2 Mux */
517 /* Right Line2 Mux */
524 SND_SOC_DAPM_MUX("Left DAC Mux", SND_SOC_NOPM, 0, 0,
526 SND_SOC_DAPM_MUX("Left HPCOM Mux", SND_SOC_NOPM, 0, 0,
534 SND_SOC_DAPM_MUX("Right DAC Mux", SND_SOC_NOPM, 0, 0,
536 SND_SOC_DAPM_MUX("Right HPCOM Mux", SND_SOC_NOPM, 0, 0,
550 SND_SOC_DAPM_MUX("Left Line1L Mux", SND_SOC_NOPM, 0, 0,
552 SND_SOC_DAPM_MUX("Left Line1R Mux", SND_SOC_NOPM, 0, 0,
554 SND_SOC_DAPM_MUX("Left Line2L Mux", SND_SOC_NOPM, 0, 0,
563 SND_SOC_DAPM_MUX("Right Line1L Mux", SND_SOC_NOPM, 0, 0,
565 SND_SOC_DAPM_MUX("Right Line1R Mux", SND_SOC_NOPM, 0, 0,
567 SND_SOC_DAPM_MUX("Right Line2R Mux", SND_SOC_NOPM, 0, 0,
639 * used to keep codec bias on if gpio or detection features are needed.
647 /* Class-D outputs */
648 SND_SOC_DAPM_PGA("Left Class-D Out", CLASSD_CTRL, 3, 0, NULL, 0),
649 SND_SOC_DAPM_PGA("Right Class-D Out", CLASSD_CTRL, 2, 0, NULL, 0),
657 {"Left Line1L Mux", "single-ended", "LINE1L"},
658 {"Left Line1L Mux", "differential", "LINE1L"},
660 {"Left Line2L Mux", "single-ended", "LINE2L"},
661 {"Left Line2L Mux", "differential", "LINE2L"},
663 {"Left PGA Mixer", "Line1L Switch", "Left Line1L Mux"},
664 {"Left PGA Mixer", "Line1R Switch", "Left Line1R Mux"},
665 {"Left PGA Mixer", "Line2L Switch", "Left Line2L Mux"},
673 {"Right Line1R Mux", "single-ended", "LINE1R"},
674 {"Right Line1R Mux", "differential", "LINE1R"},
676 {"Right Line2R Mux", "single-ended", "LINE2R"},
677 {"Right Line2R Mux", "differential", "LINE2R"},
679 {"Right PGA Mixer", "Line1L Switch", "Right Line1L Mux"},
680 {"Right PGA Mixer", "Line1R Switch", "Right Line1R Mux"},
681 {"Right PGA Mixer", "Line2R Switch", "Right Line2R Mux"},
697 {"Left DAC Mux", "DAC_L1", "Left DAC"},
698 {"Left DAC Mux", "DAC_L2", "Left DAC"},
699 {"Left DAC Mux", "DAC_L3", "Left DAC"},
702 {"Right DAC Mux", "DAC_R1", "Right DAC"},
703 {"Right DAC Mux", "DAC_R2", "Right DAC"},
704 {"Right DAC Mux", "DAC_R3", "Right DAC"},
707 {"Left Line Mixer", "Line2L Bypass Switch", "Left Line2L Mux"},
709 {"Left Line Mixer", "DACL1 Switch", "Left DAC Mux"},
710 {"Left Line Mixer", "Line2R Bypass Switch", "Right Line2R Mux"},
712 {"Left Line Mixer", "DACR1 Switch", "Right DAC Mux"},
715 {"Left Line Out", NULL, "Left DAC Mux"},
719 {"Right Line Mixer", "Line2L Bypass Switch", "Left Line2L Mux"},
721 {"Right Line Mixer", "DACL1 Switch", "Left DAC Mux"},
722 {"Right Line Mixer", "Line2R Bypass Switch", "Right Line2R Mux"},
724 {"Right Line Mixer", "DACR1 Switch", "Right DAC Mux"},
727 {"Right Line Out", NULL, "Right DAC Mux"},
731 {"Mono Mixer", "Line2L Bypass Switch", "Left Line2L Mux"},
733 {"Mono Mixer", "DACL1 Switch", "Left DAC Mux"},
734 {"Mono Mixer", "Line2R Bypass Switch", "Right Line2R Mux"},
736 {"Mono Mixer", "DACR1 Switch", "Right DAC Mux"},
742 {"Left HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"},
744 {"Left HP Mixer", "DACL1 Switch", "Left DAC Mux"},
745 {"Left HP Mixer", "Line2R Bypass Switch", "Right Line2R Mux"},
747 {"Left HP Mixer", "DACR1 Switch", "Right DAC Mux"},
750 {"Left HP Out", NULL, "Left DAC Mux"},
754 {"Right HP Mixer", "Line2L Bypass Switch", "Left Line2L Mux"},
756 {"Right HP Mixer", "DACL1 Switch", "Left DAC Mux"},
757 {"Right HP Mixer", "Line2R Bypass Switch", "Right Line2R Mux"},
759 {"Right HP Mixer", "DACR1 Switch", "Right DAC Mux"},
762 {"Right HP Out", NULL, "Right DAC Mux"},
766 {"Left HPCOM Mixer", "Line2L Bypass Switch", "Left Line2L Mux"},
768 {"Left HPCOM Mixer", "DACL1 Switch", "Left DAC Mux"},
769 {"Left HPCOM Mixer", "Line2R Bypass Switch", "Right Line2R Mux"},
771 {"Left HPCOM Mixer", "DACR1 Switch", "Right DAC Mux"},
773 {"Left HPCOM Mux", "differential of HPLOUT", "Left HP Mixer"},
774 {"Left HPCOM Mux", "constant VCM", "Left HPCOM Mixer"},
775 {"Left HPCOM Mux", "single-ended", "Left HPCOM Mixer"},
776 {"Left HP Com", NULL, "Left HPCOM Mux"},
780 {"Right HPCOM Mixer", "Line2L Bypass Switch", "Left Line2L Mux"},
782 {"Right HPCOM Mixer", "DACL1 Switch", "Left DAC Mux"},
783 {"Right HPCOM Mixer", "Line2R Bypass Switch", "Right Line2R Mux"},
785 {"Right HPCOM Mixer", "DACR1 Switch", "Right DAC Mux"},
787 {"Right HPCOM Mux", "differential of HPROUT", "Right HP Mixer"},
788 {"Right HPCOM Mux", "constant VCM", "Right HPCOM Mixer"},
789 {"Right HPCOM Mux", "single-ended", "Right HPCOM Mixer"},
790 {"Right HPCOM Mux", "differential of HPLCOM", "Left HPCOM Mixer"},
791 {"Right HPCOM Mux", "external feedback", "Right HPCOM Mixer"},
792 {"Right HP Com", NULL, "Right HPCOM Mux"},
797 /* Class-D outputs */
798 {"Left Class-D Out", NULL, "Left Line Out"},
799 {"Right Class-D Out", NULL, "Left Line Out"},
800 {"SPOP", NULL, "Left Class-D Out"},
801 {"SPOM", NULL, "Right Class-D Out"},
807 struct snd_soc_dapm_context *dapm = &codec->dapm; in aic3x_add_widgets()
815 if (aic3x->model == AIC3X_MODEL_3007) { in aic3x_add_widgets()
829 struct snd_soc_pcm_runtime *rtd = substream->private_data; in aic3x_hw_params()
830 struct snd_soc_codec *codec =rtd->codec; in aic3x_hw_params()
860 if (aic3x->sysclk / (128 * pll_q) == fsref) { in aic3x_hw_params()
892 data -= 2; in aic3x_hw_params()
905 codec_clk = (2048 * fsref) / (aic3x->sysclk / 1000); in aic3x_hw_params()
919 if (abs(codec_clk - tmp_clk) < in aic3x_hw_params()
920 abs(codec_clk - last_clk)) { in aic3x_hw_params()
940 d = ((2048 * p * fsref) - j * aic3x->sysclk) in aic3x_hw_params()
941 * 100 / (aic3x->sysclk/100); in aic3x_hw_params()
947 if (abs(codec_clk - clk) < abs(codec_clk - last_clk)) { in aic3x_hw_params()
959 return -EINVAL; in aic3x_hw_params()
979 struct snd_soc_codec *codec = dai->codec; in aic3x_mute()
997 struct snd_soc_codec *codec = codec_dai->codec; in aic3x_set_dai_sysclk()
1000 aic3x->sysclk = freq; in aic3x_set_dai_sysclk()
1007 struct snd_soc_codec *codec = codec_dai->codec; in aic3x_set_dai_fmt()
1018 aic3x->master = 1; in aic3x_set_dai_fmt()
1022 aic3x->master = 0; in aic3x_set_dai_fmt()
1026 return -EINVAL; in aic3x_set_dai_fmt()
1049 return -EINVAL; in aic3x_set_dai_fmt()
1062 u8 tmp1, tmp2, *cache = codec->reg_cache; in aic3x_init_3007()
1070 /* Class-D speaker driver init; datasheet p. 46 */ in aic3x_init_3007()
1088 struct aic3x_priv *aic3x = disable_nb->aic3x; in aic3x_regulator_event()
1095 if (gpio_is_valid(aic3x->gpio_reset)) in aic3x_regulator_event()
1096 gpio_set_value(aic3x->gpio_reset, 0); in aic3x_regulator_event()
1097 aic3x->codec->cache_sync = 1; in aic3x_regulator_event()
1107 u8 *cache = codec->reg_cache; in aic3x_set_power()
1110 ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies), in aic3x_set_power()
1111 aic3x->supplies); in aic3x_set_power()
1114 aic3x->power = 1; in aic3x_set_power()
1119 if (!codec->cache_sync) in aic3x_set_power()
1122 if (gpio_is_valid(aic3x->gpio_reset)) { in aic3x_set_power()
1124 gpio_set_value(aic3x->gpio_reset, 1); in aic3x_set_power()
1128 codec->cache_only = 0; in aic3x_set_power()
1131 if (aic3x->model == AIC3X_MODEL_3007) in aic3x_set_power()
1133 codec->cache_sync = 0; in aic3x_set_power()
1141 codec->cache_sync = 1; in aic3x_set_power()
1142 aic3x->power = 0; in aic3x_set_power()
1144 codec->cache_only = 1; in aic3x_set_power()
1145 ret = regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), in aic3x_set_power()
1146 aic3x->supplies); in aic3x_set_power()
1161 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY && in aic3x_set_bias_level()
1162 aic3x->master) { in aic3x_set_bias_level()
1169 if (!aic3x->power) in aic3x_set_bias_level()
1171 if (codec->dapm.bias_level == SND_SOC_BIAS_PREPARE && in aic3x_set_bias_level()
1172 aic3x->master) { in aic3x_set_bias_level()
1179 if (aic3x->power) in aic3x_set_bias_level()
1183 codec->dapm.bias_level = level; in aic3x_set_bias_level()
1188 void aic3x_set_gpio(struct snd_soc_codec *codec, int gpio, int state) in aic3x_set_gpio() argument
1190 u8 reg = gpio ? AIC3X_GPIO2_REG : AIC3X_GPIO1_REG; in aic3x_set_gpio()
1191 u8 bit = gpio ? 3: 0; in aic3x_set_gpio()
1197 int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio) in aic3x_get_gpio() argument
1199 u8 reg = gpio ? AIC3X_GPIO2_REG : AIC3X_GPIO1_REG; in aic3x_get_gpio()
1200 u8 val = 0, bit = gpio ? 2 : 1; in aic3x_get_gpio()
1254 .name = "tlv320aic3x-hifi",
1352 if (aic3x->model == AIC3X_MODEL_3007) { in aic3x_init()
1365 if (gpio_is_valid(aic3x->gpio_reset) && in aic3x_is_shared_reset()
1366 aic3x->gpio_reset == a->gpio_reset) in aic3x_is_shared_reset()
1378 INIT_LIST_HEAD(&aic3x->list); in aic3x_probe()
1379 aic3x->codec = codec; in aic3x_probe()
1380 codec->dapm.idle_bias_off = 1; in aic3x_probe()
1382 ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type); in aic3x_probe()
1384 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); in aic3x_probe()
1388 if (gpio_is_valid(aic3x->gpio_reset) && in aic3x_probe()
1390 ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); in aic3x_probe()
1393 gpio_direction_output(aic3x->gpio_reset, 0); in aic3x_probe()
1396 for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) in aic3x_probe()
1397 aic3x->supplies[i].supply = aic3x_supply_names[i]; in aic3x_probe()
1399 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(aic3x->supplies), in aic3x_probe()
1400 aic3x->supplies); in aic3x_probe()
1402 dev_err(codec->dev, "Failed to request supplies: %d\n", ret); in aic3x_probe()
1405 for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { in aic3x_probe()
1406 aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; in aic3x_probe()
1407 aic3x->disable_nb[i].aic3x = aic3x; in aic3x_probe()
1408 ret = regulator_register_notifier(aic3x->supplies[i].consumer, in aic3x_probe()
1409 &aic3x->disable_nb[i].nb); in aic3x_probe()
1411 dev_err(codec->dev, in aic3x_probe()
1418 codec->cache_only = 1; in aic3x_probe()
1421 if (aic3x->setup) { in aic3x_probe()
1422 /* setup GPIO functions */ in aic3x_probe()
1424 (aic3x->setup->gpio_func[0] & 0xf) << 4); in aic3x_probe()
1426 (aic3x->setup->gpio_func[1] & 0xf) << 4); in aic3x_probe()
1431 if (aic3x->model == AIC3X_MODEL_3007) in aic3x_probe()
1435 list_add(&aic3x->list, &reset_list); in aic3x_probe()
1440 while (i--) in aic3x_probe()
1441 regulator_unregister_notifier(aic3x->supplies[i].consumer, in aic3x_probe()
1442 &aic3x->disable_nb[i].nb); in aic3x_probe()
1443 regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); in aic3x_probe()
1445 if (gpio_is_valid(aic3x->gpio_reset) && in aic3x_probe()
1447 gpio_free(aic3x->gpio_reset); in aic3x_probe()
1458 list_del(&aic3x->list); in aic3x_remove()
1459 if (gpio_is_valid(aic3x->gpio_reset) && in aic3x_remove()
1461 gpio_set_value(aic3x->gpio_reset, 0); in aic3x_remove()
1462 gpio_free(aic3x->gpio_reset); in aic3x_remove()
1464 for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) in aic3x_remove()
1465 regulator_unregister_notifier(aic3x->supplies[i].consumer, in aic3x_remove()
1466 &aic3x->disable_nb[i].nb); in aic3x_remove()
1467 regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); in aic3x_remove()
1503 struct aic3x_pdata *pdata = i2c->dev.platform_data; in aic3x_i2c_probe()
1507 aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); in aic3x_i2c_probe()
1509 dev_err(&i2c->dev, "failed to create private data\n"); in aic3x_i2c_probe()
1510 return -ENOMEM; in aic3x_i2c_probe()
1513 aic3x->control_type = SND_SOC_I2C; in aic3x_i2c_probe()
1517 aic3x->gpio_reset = pdata->gpio_reset; in aic3x_i2c_probe()
1518 aic3x->setup = pdata->setup; in aic3x_i2c_probe()
1520 aic3x->gpio_reset = -1; in aic3x_i2c_probe()
1523 aic3x->model = id->driver_data; in aic3x_i2c_probe()
1525 ret = snd_soc_register_codec(&i2c->dev, in aic3x_i2c_probe()
1532 snd_soc_unregister_codec(&client->dev); in aic3x_i2c_remove()
1539 .name = "tlv320aic3x-codec",