Lines Matching +full:8 +full:- +full:channel
1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * - implement DAPM and input muxing
9 * - implement modulation limit
10 * - implement non-default PWM start
13 * because the registers are of unequal size, and multi-byte registers
18 * it doesn't matter because the entire map can be accessed as 8-bit
21 * routines have to be open-coded.
70 #define TAS5086_CHANNEL_VOL(X) (0x08 + (X)) /* Channel 1-6 volume */
88 * Default TAS5086 power-up configuration
172 size = tas5086_register_size(&client->dev, reg);
174 return -EINVAL;
178 for (i = size; i >= 1; --i) {
180 value >>= 8;
189 return -EIO;
202 size = tas5086_register_size(&client->dev, reg);
204 return -EINVAL;
208 msgs[0].addr = client->addr;
213 msgs[1].addr = client->addr;
218 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
222 return -EIO;
227 *value <<= 8;
245 /* Current sample rate for de-emphasis control */
259 if (priv->deemph) {
261 if (tas5086_deemph[i] == priv->rate) {
268 return regmap_update_bits(priv->regmap, TAS5086_SYS_CONTROL_1,
278 ucontrol->value.integer.value[0] = priv->deemph;
289 priv->deemph = ucontrol->value.integer.value[0];
298 struct snd_soc_component *component = codec_dai->component;
303 priv->mclk = freq;
306 priv->sclk = freq;
316 struct snd_soc_component *component = codec_dai->component;
321 dev_err(component->dev, "Invalid clocking mode\n");
322 return -EINVAL;
326 priv->format = format;
347 return -ENOENT;
354 struct snd_soc_component *component = dai->component;
359 priv->rate = params_rate(params);
363 ARRAY_SIZE(tas5086_sample_rates), priv->rate);
366 dev_err(component->dev, "Invalid sample rate\n");
367 return -EINVAL;
370 ret = regmap_update_bits(priv->regmap, TAS5086_CLOCK_CONTROL,
378 priv->mclk / priv->rate);
380 dev_err(component->dev, "Invalid MCLK / Fs ratio\n");
381 return -EINVAL;
384 ret = regmap_update_bits(priv->regmap, TAS5086_CLOCK_CONTROL,
391 ret = regmap_update_bits(priv->regmap, TAS5086_CLOCK_CONTROL,
393 (priv->sclk == 48 * priv->rate) ?
401 * a logical bit-boundary. Hence, we have to refer to the format passed
406 switch (priv->format & SND_SOC_DAIFMT_FORMAT_MASK) {
417 dev_err(component->dev, "Invalid DAI format\n");
418 return -EINVAL;
433 dev_err(component->dev, "Invalid bit width\n");
434 return -EINVAL;
437 ret = regmap_write(priv->regmap, TAS5086_SERIAL_DATA_IF, val);
442 ret = regmap_update_bits(priv->regmap, TAS5086_CLOCK_CONTROL,
452 struct snd_soc_component *component = dai->component;
459 return regmap_write(priv->regmap, TAS5086_SOFT_MUTE, val);
464 if (priv->reset) {
465 /* Reset codec - minimum assertion time is 400ns */
466 gpiod_set_value_cansleep(priv->reset, 1);
468 gpiod_set_value_cansleep(priv->reset, 0);
487 * If any of the channels is configured to start in Mid-Z mode,
488 * configure 'part 1' of the PWM starts to use Mid-Z, and tell
489 * all configured mid-z channels to start under 'part 1'.
491 if (priv->pwm_start_mid_z)
492 regmap_write(priv->regmap, TAS5086_PWM_START,
494 priv->pwm_start_mid_z);
496 /* lookup and set split-capacitor charge period */
497 if (priv->charge_period == 0) {
498 regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, 0);
502 priv->charge_period);
504 regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE,
508 "Invalid split-cap charge period of %d ns.\n",
509 priv->charge_period);
513 ret = regmap_write(priv->regmap, TAS5086_OSC_TRIM, 0x00);
518 ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x20);
523 ret = regmap_write(priv->regmap, TAS5086_SOFT_MUTE,
532 static const DECLARE_TLV_DB_SCALE(tas5086_dac_tlv, -10350, 50, 1);
537 SOC_DOUBLE_R_TLV("Channel 1/2 Playback Volume",
540 SOC_DOUBLE_R_TLV("Channel 3/4 Playback Volume",
543 SOC_DOUBLE_R_TLV("Channel 5/6 Playback Volume",
546 SOC_SINGLE_BOOL_EXT("De-emphasis Switch", 0,
553 "SDIN1-L", "SDIN1-R", "SDIN2-L", "SDIN2-R",
554 "SDIN3-L", "SDIN3-R", "Ground (0)", "nc"
558 SOC_ENUM_SINGLE(TAS5086_INPUT_MUX, 20, 8, tas5086_dapm_sdin_texts),
559 SOC_ENUM_SINGLE(TAS5086_INPUT_MUX, 16, 8, tas5086_dapm_sdin_texts),
560 SOC_ENUM_SINGLE(TAS5086_INPUT_MUX, 12, 8, tas5086_dapm_sdin_texts),
561 SOC_ENUM_SINGLE(TAS5086_INPUT_MUX, 8, 8, tas5086_dapm_sdin_texts),
562 SOC_ENUM_SINGLE(TAS5086_INPUT_MUX, 4, 8, tas5086_dapm_sdin_texts),
563 SOC_ENUM_SINGLE(TAS5086_INPUT_MUX, 0, 8, tas5086_dapm_sdin_texts),
567 SOC_DAPM_ENUM("Channel 1 input", tas5086_dapm_input_mux_enum[0]),
568 SOC_DAPM_ENUM("Channel 2 input", tas5086_dapm_input_mux_enum[1]),
569 SOC_DAPM_ENUM("Channel 3 input", tas5086_dapm_input_mux_enum[2]),
570 SOC_DAPM_ENUM("Channel 4 input", tas5086_dapm_input_mux_enum[3]),
571 SOC_DAPM_ENUM("Channel 5 input", tas5086_dapm_input_mux_enum[4]),
572 SOC_DAPM_ENUM("Channel 6 input", tas5086_dapm_input_mux_enum[5]),
577 { "Channel 1 Mux", "Channel 2 Mux", "Channel 3 Mux",
578 "Channel 4 Mux", "Channel 5 Mux", "Channel 6 Mux" };
584 SOC_ENUM_SINGLE(TAS5086_PWM_OUTPUT_MUX, 8, 6, tas5086_dapm_channel_texts),
599 SND_SOC_DAPM_INPUT("SDIN1-L"),
600 SND_SOC_DAPM_INPUT("SDIN1-R"),
601 SND_SOC_DAPM_INPUT("SDIN2-L"),
602 SND_SOC_DAPM_INPUT("SDIN2-R"),
603 SND_SOC_DAPM_INPUT("SDIN3-L"),
604 SND_SOC_DAPM_INPUT("SDIN3-R"),
605 SND_SOC_DAPM_INPUT("SDIN4-L"),
606 SND_SOC_DAPM_INPUT("SDIN4-R"),
615 SND_SOC_DAPM_MUX("Channel 1 Mux", SND_SOC_NOPM, 0, 0,
617 SND_SOC_DAPM_MUX("Channel 2 Mux", SND_SOC_NOPM, 0, 0,
619 SND_SOC_DAPM_MUX("Channel 3 Mux", SND_SOC_NOPM, 0, 0,
621 SND_SOC_DAPM_MUX("Channel 4 Mux", SND_SOC_NOPM, 0, 0,
623 SND_SOC_DAPM_MUX("Channel 5 Mux", SND_SOC_NOPM, 0, 0,
625 SND_SOC_DAPM_MUX("Channel 6 Mux", SND_SOC_NOPM, 0, 0,
643 /* SDIN inputs -> channel muxes */
644 { "Channel 1 Mux", "SDIN1-L", "SDIN1-L" },
645 { "Channel 1 Mux", "SDIN1-R", "SDIN1-R" },
646 { "Channel 1 Mux", "SDIN2-L", "SDIN2-L" },
647 { "Channel 1 Mux", "SDIN2-R", "SDIN2-R" },
648 { "Channel 1 Mux", "SDIN3-L", "SDIN3-L" },
649 { "Channel 1 Mux", "SDIN3-R", "SDIN3-R" },
651 { "Channel 2 Mux", "SDIN1-L", "SDIN1-L" },
652 { "Channel 2 Mux", "SDIN1-R", "SDIN1-R" },
653 { "Channel 2 Mux", "SDIN2-L", "SDIN2-L" },
654 { "Channel 2 Mux", "SDIN2-R", "SDIN2-R" },
655 { "Channel 2 Mux", "SDIN3-L", "SDIN3-L" },
656 { "Channel 2 Mux", "SDIN3-R", "SDIN3-R" },
658 { "Channel 2 Mux", "SDIN1-L", "SDIN1-L" },
659 { "Channel 2 Mux", "SDIN1-R", "SDIN1-R" },
660 { "Channel 2 Mux", "SDIN2-L", "SDIN2-L" },
661 { "Channel 2 Mux", "SDIN2-R", "SDIN2-R" },
662 { "Channel 2 Mux", "SDIN3-L", "SDIN3-L" },
663 { "Channel 2 Mux", "SDIN3-R", "SDIN3-R" },
665 { "Channel 3 Mux", "SDIN1-L", "SDIN1-L" },
666 { "Channel 3 Mux", "SDIN1-R", "SDIN1-R" },
667 { "Channel 3 Mux", "SDIN2-L", "SDIN2-L" },
668 { "Channel 3 Mux", "SDIN2-R", "SDIN2-R" },
669 { "Channel 3 Mux", "SDIN3-L", "SDIN3-L" },
670 { "Channel 3 Mux", "SDIN3-R", "SDIN3-R" },
672 { "Channel 4 Mux", "SDIN1-L", "SDIN1-L" },
673 { "Channel 4 Mux", "SDIN1-R", "SDIN1-R" },
674 { "Channel 4 Mux", "SDIN2-L", "SDIN2-L" },
675 { "Channel 4 Mux", "SDIN2-R", "SDIN2-R" },
676 { "Channel 4 Mux", "SDIN3-L", "SDIN3-L" },
677 { "Channel 4 Mux", "SDIN3-R", "SDIN3-R" },
679 { "Channel 5 Mux", "SDIN1-L", "SDIN1-L" },
680 { "Channel 5 Mux", "SDIN1-R", "SDIN1-R" },
681 { "Channel 5 Mux", "SDIN2-L", "SDIN2-L" },
682 { "Channel 5 Mux", "SDIN2-R", "SDIN2-R" },
683 { "Channel 5 Mux", "SDIN3-L", "SDIN3-L" },
684 { "Channel 5 Mux", "SDIN3-R", "SDIN3-R" },
686 { "Channel 6 Mux", "SDIN1-L", "SDIN1-L" },
687 { "Channel 6 Mux", "SDIN1-R", "SDIN1-R" },
688 { "Channel 6 Mux", "SDIN2-L", "SDIN2-L" },
689 { "Channel 6 Mux", "SDIN2-R", "SDIN2-R" },
690 { "Channel 6 Mux", "SDIN3-L", "SDIN3-L" },
691 { "Channel 6 Mux", "SDIN3-R", "SDIN3-R" },
693 /* Channel muxes -> PWM muxes */
694 { "PWM1 Mux", "Channel 1 Mux", "Channel 1 Mux" },
695 { "PWM2 Mux", "Channel 1 Mux", "Channel 1 Mux" },
696 { "PWM3 Mux", "Channel 1 Mux", "Channel 1 Mux" },
697 { "PWM4 Mux", "Channel 1 Mux", "Channel 1 Mux" },
698 { "PWM5 Mux", "Channel 1 Mux", "Channel 1 Mux" },
699 { "PWM6 Mux", "Channel 1 Mux", "Channel 1 Mux" },
701 { "PWM1 Mux", "Channel 2 Mux", "Channel 2 Mux" },
702 { "PWM2 Mux", "Channel 2 Mux", "Channel 2 Mux" },
703 { "PWM3 Mux", "Channel 2 Mux", "Channel 2 Mux" },
704 { "PWM4 Mux", "Channel 2 Mux", "Channel 2 Mux" },
705 { "PWM5 Mux", "Channel 2 Mux", "Channel 2 Mux" },
706 { "PWM6 Mux", "Channel 2 Mux", "Channel 2 Mux" },
708 { "PWM1 Mux", "Channel 3 Mux", "Channel 3 Mux" },
709 { "PWM2 Mux", "Channel 3 Mux", "Channel 3 Mux" },
710 { "PWM3 Mux", "Channel 3 Mux", "Channel 3 Mux" },
711 { "PWM4 Mux", "Channel 3 Mux", "Channel 3 Mux" },
712 { "PWM5 Mux", "Channel 3 Mux", "Channel 3 Mux" },
713 { "PWM6 Mux", "Channel 3 Mux", "Channel 3 Mux" },
715 { "PWM1 Mux", "Channel 4 Mux", "Channel 4 Mux" },
716 { "PWM2 Mux", "Channel 4 Mux", "Channel 4 Mux" },
717 { "PWM3 Mux", "Channel 4 Mux", "Channel 4 Mux" },
718 { "PWM4 Mux", "Channel 4 Mux", "Channel 4 Mux" },
719 { "PWM5 Mux", "Channel 4 Mux", "Channel 4 Mux" },
720 { "PWM6 Mux", "Channel 4 Mux", "Channel 4 Mux" },
722 { "PWM1 Mux", "Channel 5 Mux", "Channel 5 Mux" },
723 { "PWM2 Mux", "Channel 5 Mux", "Channel 5 Mux" },
724 { "PWM3 Mux", "Channel 5 Mux", "Channel 5 Mux" },
725 { "PWM4 Mux", "Channel 5 Mux", "Channel 5 Mux" },
726 { "PWM5 Mux", "Channel 5 Mux", "Channel 5 Mux" },
727 { "PWM6 Mux", "Channel 5 Mux", "Channel 5 Mux" },
729 { "PWM1 Mux", "Channel 6 Mux", "Channel 6 Mux" },
730 { "PWM2 Mux", "Channel 6 Mux", "Channel 6 Mux" },
731 { "PWM3 Mux", "Channel 6 Mux", "Channel 6 Mux" },
732 { "PWM4 Mux", "Channel 6 Mux", "Channel 6 Mux" },
733 { "PWM5 Mux", "Channel 6 Mux", "Channel 6 Mux" },
734 { "PWM6 Mux", "Channel 6 Mux", "Channel 6 Mux" },
754 .name = "tas5086-hifi",
772 ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x60);
776 regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
786 ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
791 regcache_mark_dirty(priv->regmap);
793 ret = tas5086_init(component->dev, priv);
797 ret = regcache_sync(priv->regmap);
821 ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
823 dev_err(component->dev, "Failed to enable regulators: %d\n", ret);
827 priv->pwm_start_mid_z = 0;
828 priv->charge_period = 1300000; /* hardware default is 1300 ms */
830 if (of_match_device(of_match_ptr(tas5086_dt_ids), component->dev)) {
831 struct device_node *of_node = component->dev->of_node;
833 of_property_read_u32(of_node, "ti,charge-period",
834 &priv->charge_period);
840 "ti,mid-z-channel-%d", i + 1);
843 priv->pwm_start_mid_z |= 1 << i;
848 ret = tas5086_init(component->dev, priv);
853 ret = regmap_write(priv->regmap, TAS5086_MASTER_VOL, 0x30);
860 regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
869 if (priv->reset) {
871 gpiod_set_value_cansleep(priv->reset, 1);
874 regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
900 .reg_bits = 8,
916 struct device *dev = &i2c->dev;
921 return -ENOMEM;
924 priv->supplies[i].supply = supply_names[i];
926 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(priv->supplies),
927 priv->supplies);
933 priv->regmap = devm_regmap_init(dev, NULL, i2c, &tas5086_regmap);
934 if (IS_ERR(priv->regmap)) {
935 ret = PTR_ERR(priv->regmap);
936 dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret);
943 priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
944 if (IS_ERR(priv->reset))
945 return PTR_ERR(priv->reset);
946 gpiod_set_consumer_name(priv->reset, "TAS5086 Reset");
948 ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
957 ret = regmap_read(priv->regmap, TAS5086_DEV_ID, &i);
961 ret = -ENODEV;
968 regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
971 ret = devm_snd_soc_register_component(&i2c->dev,