Lines Matching +full:adc +full:- +full:channel +full:- +full:clk +full:- +full:src
1 // SPDX-License-Identifier: GPL-2.0
2 // tscs454.c -- TSCS454 ALSA SoC Audio driver
7 #include <linux/clk.h>
21 #include <sound/soc-dapm.h>
50 pll->id = id; in pll_init()
51 mutex_init(&pll->lock); in pll_init()
66 aif->id = id; in aif_init()
85 cache[((norm_addrs[i] + 1) * COEFF_SIZE) - 1] = 0x40; in init_coeff_ram_cache()
90 init_coeff_ram_cache(ram->cache); in coeff_ram_init()
91 mutex_init(&ram->lock); in coeff_ram_init()
103 status->streams |= mask; in set_aif_status_active()
111 status->streams &= mask; in set_aif_status_inactive()
116 return status->streams; in aifs_active()
121 return (0x03 << aif_id * 2) & status->streams; in aif_active()
139 struct clk *sysclk;
282 tscs454->regmap = devm_regmap_init_i2c(i2c, &tscs454_regmap_cfg); in tscs454_data_init()
283 if (IS_ERR(tscs454->regmap)) { in tscs454_data_init()
284 ret = PTR_ERR(tscs454->regmap); in tscs454_data_init()
289 aif_init(&tscs454->aifs[i], i); in tscs454_data_init()
291 mutex_init(&tscs454->aifs_status_lock); in tscs454_data_init()
292 pll_init(&tscs454->pll1, 1); in tscs454_data_init()
293 pll_init(&tscs454->pll2, 2); in tscs454_data_init()
295 coeff_ram_init(&tscs454->dac_ram); in tscs454_data_init()
296 coeff_ram_init(&tscs454->spk_ram); in tscs454_data_init()
297 coeff_ram_init(&tscs454->sub_ram); in tscs454_data_init()
314 (struct coeff_ram_ctl *)kcontrol->private_value; in coeff_ram_get()
315 struct soc_bytes_ext *params = &ctl->bytes_ext; in coeff_ram_get()
319 if (strstr(kcontrol->id.name, "DAC")) { in coeff_ram_get()
320 coeff_ram = tscs454->dac_ram.cache; in coeff_ram_get()
321 coeff_ram_lock = &tscs454->dac_ram.lock; in coeff_ram_get()
322 } else if (strstr(kcontrol->id.name, "Speaker")) { in coeff_ram_get()
323 coeff_ram = tscs454->spk_ram.cache; in coeff_ram_get()
324 coeff_ram_lock = &tscs454->spk_ram.lock; in coeff_ram_get()
325 } else if (strstr(kcontrol->id.name, "Sub")) { in coeff_ram_get()
326 coeff_ram = tscs454->sub_ram.cache; in coeff_ram_get()
327 coeff_ram_lock = &tscs454->sub_ram.lock; in coeff_ram_get()
329 return -EINVAL; in coeff_ram_get()
334 memcpy(ucontrol->value.bytes.data, in coeff_ram_get()
335 &coeff_ram[ctl->addr * COEFF_SIZE], params->max); in coeff_ram_get()
362 ret = -EIO; in write_coeff_ram()
363 dev_err(component->dev, in write_coeff_ram()
368 ret = regmap_write(tscs454->regmap, r_addr, coeff_addr); in write_coeff_ram()
370 dev_err(component->dev, in write_coeff_ram()
375 ret = regmap_bulk_write(tscs454->regmap, r_wr, in write_coeff_ram()
379 dev_err(component->dev, in write_coeff_ram()
395 (struct coeff_ram_ctl *)kcontrol->private_value; in coeff_ram_put()
396 struct soc_bytes_ext *params = &ctl->bytes_ext; in coeff_ram_put()
397 unsigned int coeff_cnt = params->max / COEFF_SIZE; in coeff_ram_put()
407 if (strstr(kcontrol->id.name, "DAC")) { in coeff_ram_put()
408 coeff_ram = tscs454->dac_ram.cache; in coeff_ram_put()
409 coeff_ram_lock = &tscs454->dac_ram.lock; in coeff_ram_put()
410 coeff_ram_synced = &tscs454->dac_ram.synced; in coeff_ram_put()
414 } else if (strstr(kcontrol->id.name, "Speaker")) { in coeff_ram_put()
415 coeff_ram = tscs454->spk_ram.cache; in coeff_ram_put()
416 coeff_ram_lock = &tscs454->spk_ram.lock; in coeff_ram_put()
417 coeff_ram_synced = &tscs454->spk_ram.synced; in coeff_ram_put()
421 } else if (strstr(kcontrol->id.name, "Sub")) { in coeff_ram_put()
422 coeff_ram = tscs454->sub_ram.cache; in coeff_ram_put()
423 coeff_ram_lock = &tscs454->sub_ram.lock; in coeff_ram_put()
424 coeff_ram_synced = &tscs454->sub_ram.synced; in coeff_ram_put()
429 return -EINVAL; in coeff_ram_put()
436 memcpy(&coeff_ram[ctl->addr * COEFF_SIZE], in coeff_ram_put()
437 ucontrol->value.bytes.data, params->max); in coeff_ram_put()
439 mutex_lock(&tscs454->pll1.lock); in coeff_ram_put()
440 mutex_lock(&tscs454->pll2.lock); in coeff_ram_put()
446 ctl->addr, coeff_cnt); in coeff_ram_put()
448 dev_err(component->dev, in coeff_ram_put()
457 mutex_unlock(&tscs454->pll2.lock); in coeff_ram_put()
458 mutex_unlock(&tscs454->pll1.lock); in coeff_ram_put()
469 mutex_lock(&tscs454->dac_ram.lock); in coeff_ram_sync()
470 if (!tscs454->dac_ram.synced) { in coeff_ram_sync()
471 ret = write_coeff_ram(component, tscs454->dac_ram.cache, in coeff_ram_sync()
475 mutex_unlock(&tscs454->dac_ram.lock); in coeff_ram_sync()
479 mutex_unlock(&tscs454->dac_ram.lock); in coeff_ram_sync()
481 mutex_lock(&tscs454->spk_ram.lock); in coeff_ram_sync()
482 if (!tscs454->spk_ram.synced) { in coeff_ram_sync()
483 ret = write_coeff_ram(component, tscs454->spk_ram.cache, in coeff_ram_sync()
487 mutex_unlock(&tscs454->spk_ram.lock); in coeff_ram_sync()
491 mutex_unlock(&tscs454->spk_ram.lock); in coeff_ram_sync()
493 mutex_lock(&tscs454->sub_ram.lock); in coeff_ram_sync()
494 if (!tscs454->sub_ram.synced) { in coeff_ram_sync()
495 ret = write_coeff_ram(component, tscs454->sub_ram.cache, in coeff_ram_sync()
499 mutex_unlock(&tscs454->sub_ram.lock); in coeff_ram_sync()
503 mutex_unlock(&tscs454->sub_ram.lock); in coeff_ram_sync()
633 if (tscs454->sysclk_src_id < PLL_INPUT_BCLK) in set_sysclk()
634 freq = clk_get_rate(tscs454->sysclk); in set_sysclk()
636 freq = tscs454->bclk_freq; in set_sysclk()
639 ret = -EINVAL; in set_sysclk()
640 dev_err(component->dev, in set_sysclk()
647 pll_ctl->settings[i].addr, in set_sysclk()
648 pll_ctl->settings[i].val); in set_sysclk()
650 dev_err(component->dev, in set_sysclk()
662 mutex_lock(&pll->lock); in reserve_pll()
663 pll->users++; in reserve_pll()
664 mutex_unlock(&pll->lock); in reserve_pll()
669 mutex_lock(&pll->lock); in free_pll()
670 pll->users--; in free_pll()
671 mutex_unlock(&pll->lock); in free_pll()
678 snd_soc_dapm_to_component(source->dapm); in pll_connected()
682 if (strstr(source->name, "PLL 1")) { in pll_connected()
683 mutex_lock(&tscs454->pll1.lock); in pll_connected()
684 users = tscs454->pll1.users; in pll_connected()
685 mutex_unlock(&tscs454->pll1.lock); in pll_connected()
686 dev_dbg(component->dev, "%s(): PLL 1 users = %d\n", __func__, in pll_connected()
689 mutex_lock(&tscs454->pll2.lock); in pll_connected()
690 users = tscs454->pll2.users; in pll_connected()
691 mutex_unlock(&tscs454->pll2.lock); in pll_connected()
692 dev_dbg(component->dev, "%s(): PLL 2 users = %d\n", __func__, in pll_connected()
707 snd_soc_dapm_to_component(w->dapm); in pll_power_event()
715 if (strstr(w->name, "PLL 1")) in pll_power_event()
734 dev_err(component->dev, "Failed to %s PLL %d (%d)\n", in pll_power_event()
745 dev_err(component->dev, in pll_power_event()
773 ret = -ENODEV; in aif_set_master()
774 dev_err(component->dev, "Unknown DAI %d (%d)\n", aif_id, ret); in aif_set_master()
782 dev_err(component->dev, "Failed to set DAI %d to %s (%d)\n", in aif_set_master()
795 ret = aif_set_master(component, aif->id, aif->master); in aif_prepare()
807 mutex_lock(&tscs454->aifs_status_lock); in aif_free()
809 dev_dbg(component->dev, "%s(): aif %d\n", __func__, aif->id); in aif_free()
811 set_aif_status_inactive(&tscs454->aifs_status, aif->id, playback); in aif_free()
813 dev_dbg(component->dev, "Set aif %d inactive. Streams status is 0x%x\n", in aif_free()
814 aif->id, tscs454->aifs_status.streams); in aif_free()
816 if (!aif_active(&tscs454->aifs_status, aif->id)) { in aif_free()
818 aif_set_master(component, aif->id, false); in aif_free()
819 dev_dbg(component->dev, "Freeing pll %d from aif %d\n", in aif_free()
820 aif->pll->id, aif->id); in aif_free()
821 free_pll(aif->pll); in aif_free()
824 if (!aifs_active(&tscs454->aifs_status)) { in aif_free()
825 dev_dbg(component->dev, "Freeing pll %d from ir\n", in aif_free()
826 tscs454->internal_rate.pll->id); in aif_free()
827 free_pll(tscs454->internal_rate.pll); in aif_free()
830 mutex_unlock(&tscs454->aifs_status_lock); in aif_free()
902 "CH 0_1", "CH 2_3", "CH 4_5", "ADC/DMic 1",
943 "ADC/DMic 1 Left", "ADC/DMic 1 Right",
944 "ADC/DMic 1 Left Plus Right",
1003 SOC_DAPM_ENUM("Input Boost Channel 0 Enum",
1016 SOC_DAPM_ENUM("ADC Channel 0 Enum", adc_mux_ch0_enum);
1019 "ADC", "DMic"};
1025 SOC_DAPM_ENUM("Input Processor Channel 0 Enum",
1034 SOC_DAPM_ENUM("Input Boost Channel 1 Enum",
1041 SOC_DAPM_ENUM("ADC Channel 1 Enum", adc_mux_ch1_enum);
1047 SOC_DAPM_ENUM("Input Processor Channel 1 Enum",
1063 "Normal", "Mono Mix to Channel 0",
1064 "Mono Mix to Channel 1", "Add"};
1101 static DECLARE_TLV_DB_SCALE(in_pga_vol_tlv_arr, -1725, 75, 0);
1107 static DECLARE_TLV_DB_MINMAX(in_vol_tlv_arr, -7125, 2400);
1113 static DECLARE_TLV_DB_MINMAX(asrc_vol_tlv_arr, -9562, 600);
1124 "Channel 0", "Channel 1", "Channel 2", "Channel 3", "Peak"};
1131 static DECLARE_TLV_DB_SCALE(alc_max_gain_tlv_arr, -1200, 600, 0);
1132 static DECLARE_TLV_DB_SCALE(alc_target_tlv_arr, -2850, 150, 0);
1135 static DECLARE_TLV_DB_SCALE(alc_min_gain_tlv_arr, -1725, 600, 0);
1138 static DECLARE_TLV_DB_SCALE(ngth_tlv_arr, -7650, 150, 0);
1141 "PGA Constant", "ADC Mute"};
1187 static DECLARE_TLV_DB_MINMAX(mvol_tlv_arr, -9562, 0);
1191 static DECLARE_TLV_DB_SCALE(hp_vol_tlv_arr, -8850, 75, 0);
1195 static DECLARE_TLV_DB_SCALE(spk_vol_tlv_arr, -7725, 75, 0);
1201 "Pre Scale + EQ Band 0 - 1",
1202 "Pre Scale + EQ Band 0 - 2",
1203 "Pre Scale + EQ Band 0 - 3",
1204 "Pre Scale + EQ Band 0 - 4",
1205 "Pre Scale + EQ Band 0 - 5",
1251 static DECLARE_TLV_DB_MINMAX(mbc_mug_tlv_arr, -4650, 0);
1254 static DECLARE_TLV_DB_MINMAX(thr_tlv_arr, -9562, 0);
1479 (struct coeff_ram_ctl *)kcontrol->private_value; in bytes_info_ext()
1480 struct soc_bytes_ext *params = &ctl->bytes_ext; in bytes_info_ext()
1482 ucontrol->type = SNDRV_CTL_ELEM_TYPE_BYTES; in bytes_info_ext()
1483 ucontrol->count = params->max; in bytes_info_ext()
1535 SOC_ENUM("ADC Modular Rate", adc_modular_rate_enum),
1569 SOC_SINGLE_TLV("Input Boost Channel 0 Volume", R_CH0AIC,
1572 SOC_SINGLE_TLV("Input Boost Channel 1 Volume", R_CH1AIC,
1575 SOC_SINGLE_TLV("Input Boost Channel 2 Volume", R_CH2AIC,
1578 SOC_SINGLE_TLV("Input Boost Channel 3 Volume", R_CH3AIC,
1581 SOC_ENUM("Input Channel 1 Polarity", in_pol_ch1_enum),
1582 SOC_ENUM("Input Channel 0 Polarity", in_pol_ch0_enum),
1583 SOC_ENUM("Input Processor Channel 0/1 Operation",
1585 SOC_SINGLE("Input Channel 1 Mute Switch",
1587 SOC_SINGLE("Input Channel 0 Mute Switch",
1589 SOC_SINGLE("Input Channel 1 HPF Disable Switch",
1591 SOC_SINGLE("Input Channel 0 HPF Disable Switch",
1594 SOC_ENUM("Input Channel 3 Polarity", in_pol_ch3_enum),
1595 SOC_ENUM("Input Channel 2 Polarity", in_pol_ch2_enum),
1596 SOC_ENUM("Input Processor Channel 2/3 Operation",
1598 SOC_SINGLE("Input Channel 3 Mute Switch",
1600 SOC_SINGLE("Input Channel 2 Mute Switch",
1602 SOC_SINGLE("Input Channel 3 HPF Disable Switch",
1604 SOC_SINGLE("Input Channel 2 HPF Disable Switch",
1610 SOC_SINGLE("Input Channel 0 PGA Mute Switch",
1612 SOC_SINGLE_TLV("Input Channel 0 PGA Volume", R_PGACTL0,
1616 SOC_SINGLE("Input Channel 1 PGA Mute Switch",
1618 SOC_SINGLE_TLV("Input Channel 1 PGA Volume", R_PGACTL1,
1622 SOC_SINGLE("Input Channel 2 PGA Mute Switch",
1624 SOC_SINGLE_TLV("Input Channel 2 PGA Volume", R_PGACTL2,
1628 SOC_SINGLE("Input Channel 3 PGA Mute Switch",
1630 SOC_SINGLE_TLV("Input Channel 3 PGA Volume", R_PGACTL3,
1634 SOC_SINGLE_TLV("Input Channel 0 Volume", R_ICH0VOL,
1637 SOC_SINGLE_TLV("Input Channel 1 Volume", R_ICH1VOL,
1640 SOC_SINGLE_TLV("Input Channel 2 Volume", R_ICH2VOL,
1643 SOC_SINGLE_TLV("Input Channel 3 Volume", R_ICH3VOL,
1665 SOC_SINGLE("Input Channel 3 ALC Switch",
1667 SOC_SINGLE("Input Channel 2 ALC Switch",
1669 SOC_SINGLE("Input Channel 1 ALC Switch",
1671 SOC_SINGLE("Input Channel 0 ALC Switch",
1707 SOC_SINGLE("DAC De-Emphasis Switch", R_DACCTL, FB_DACCTL_DACDEM, 1, 0),
1712 SOC_SINGLE("Speaker De-Emphasis Switch",
1717 SOC_SINGLE("Sub De-Emphasis Switch", R_SUBCTL, FB_SUBCTL_SUBDEM, 1, 0),
1767 SOC_SINGLE_TLV("Speaker MBC1 Make-Up Gain Volume", R_SPKMBCMUG1,
1784 SOC_SINGLE_TLV("Speaker MBC2 Make-Up Gain Volume", R_SPKMBCMUG2,
1801 SOC_SINGLE_TLV("Speaker MBC 3 Make-Up Gain Volume", R_SPKMBCMUG3,
1826 SOC_SINGLE_TLV("Speaker CLE Make-Up Gain Volume", R_SPKCLEMUG,
1896 SOC_SINGLE_TLV("DAC MBC 1 Make-Up Gain Volume", R_DACMBCMUG1,
1913 SOC_SINGLE_TLV("DAC MBC 2 Make-Up Gain Volume", R_DACMBCMUG2,
1930 SOC_SINGLE_TLV("DAC MBC 3 Make-Up Gain Volume", R_DACMBCMUG3,
1955 SOC_SINGLE_TLV("DAC CLE Make-Up Gain Volume", R_DACCLEMUG,
2025 SOC_SINGLE_TLV("Sub MBC 1 Make-Up Gain Volume", R_SUBMBCMUG1,
2042 SOC_SINGLE_TLV("Sub MBC 2 Make-Up Gain Volume", R_SUBMBCMUG2,
2059 SOC_SINGLE_TLV("Sub MBC 3 Make-Up Gain Volume", R_SUBMBCMUG3,
2084 SOC_SINGLE_TLV("Sub CLE Make-Up Gain Volume", R_SUBCLEMUG,
2364 SND_SOC_DAPM_ADC("Input Processor Channel 3", NULL,
2366 SND_SOC_DAPM_ADC("Input Processor Channel 2", NULL,
2368 SND_SOC_DAPM_ADC("Input Processor Channel 1", NULL,
2370 SND_SOC_DAPM_ADC("Input Processor Channel 0", NULL,
2433 SND_SOC_DAPM_MUX("Input Boost Channel 0 Mux", SND_SOC_NOPM, 0, 0,
2435 SND_SOC_DAPM_MUX("ADC Channel 0 Mux", SND_SOC_NOPM, 0, 0,
2437 SND_SOC_DAPM_MUX("Input Processor Channel 0 Mux", SND_SOC_NOPM, 0, 0,
2440 SND_SOC_DAPM_MUX("Input Boost Channel 1 Mux", SND_SOC_NOPM, 0, 0,
2442 SND_SOC_DAPM_MUX("ADC Channel 1 Mux", SND_SOC_NOPM, 0, 0,
2444 SND_SOC_DAPM_MUX("Input Processor Channel 1 Mux", SND_SOC_NOPM, 0, 0,
2551 {"Sub Mux", "ADC/DMic 1 Left", "Input Processor Channel 0"},
2552 {"Sub Mux", "ADC/DMic 1 Right", "Input Processor Channel 1"},
2553 {"Sub Mux", "ADC/DMic 1 Left Plus Right", "Input Processor Channel 0"},
2554 {"Sub Mux", "ADC/DMic 1 Left Plus Right", "Input Processor Channel 1"},
2569 {"Input Boost Channel 0 Mux", "Input 3", "Line In 3 Left"},
2570 {"Input Boost Channel 0 Mux", "Input 2", "Line In 2 Left"},
2571 {"Input Boost Channel 0 Mux", "Input 1", "Line In 1 Left"},
2572 {"Input Boost Channel 0 Mux", "D2S", "D2S 1"},
2574 {"Input Boost Channel 1 Mux", "Input 3", "Line In 3 Right"},
2575 {"Input Boost Channel 1 Mux", "Input 2", "Line In 2 Right"},
2576 {"Input Boost Channel 1 Mux", "Input 1", "Line In 1 Right"},
2577 {"Input Boost Channel 1 Mux", "D2S", "D2S 2"},
2579 {"ADC Channel 0 Mux", "Input 3 Boost Bypass", "Line In 3 Left"},
2580 {"ADC Channel 0 Mux", "Input 2 Boost Bypass", "Line In 2 Left"},
2581 {"ADC Channel 0 Mux", "Input 1 Boost Bypass", "Line In 1 Left"},
2582 {"ADC Channel 0 Mux", "Input Boost", "Input Boost Channel 0 Mux"},
2584 {"ADC Channel 1 Mux", "Input 3 Boost Bypass", "Line In 3 Right"},
2585 {"ADC Channel 1 Mux", "Input 2 Boost Bypass", "Line In 2 Right"},
2586 {"ADC Channel 1 Mux", "Input 1 Boost Bypass", "Line In 1 Right"},
2587 {"ADC Channel 1 Mux", "Input Boost", "Input Boost Channel 1 Mux"},
2589 {"Input Processor Channel 0 Mux", "ADC", "ADC Channel 0 Mux"},
2590 {"Input Processor Channel 0 Mux", "DMic", "DMic 1"},
2592 {"Input Processor Channel 0", NULL, "PLLs"},
2593 {"Input Processor Channel 0", NULL, "Input Processor Channel 0 Mux"},
2595 {"Input Processor Channel 1 Mux", "ADC", "ADC Channel 1 Mux"},
2596 {"Input Processor Channel 1 Mux", "DMic", "DMic 1"},
2598 {"Input Processor Channel 1", NULL, "PLLs"},
2599 {"Input Processor Channel 1", NULL, "Input Processor Channel 1 Mux"},
2601 {"Input Processor Channel 2", NULL, "PLLs"},
2602 {"Input Processor Channel 2", NULL, "DMic 2"},
2604 {"Input Processor Channel 3", NULL, "PLLs"},
2605 {"Input Processor Channel 3", NULL, "DMic 2"},
2607 {"DAI 1 Out Mux", "ADC/DMic 1", "Input Processor Channel 0"},
2608 {"DAI 1 Out Mux", "ADC/DMic 1", "Input Processor Channel 1"},
2609 {"DAI 1 Out Mux", "DMic 2", "Input Processor Channel 2"},
2610 {"DAI 1 Out Mux", "DMic 2", "Input Processor Channel 3"},
2612 {"DAI 2 Out Mux", "ADC/DMic 1", "Input Processor Channel 0"},
2613 {"DAI 2 Out Mux", "ADC/DMic 1", "Input Processor Channel 1"},
2614 {"DAI 2 Out Mux", "DMic 2", "Input Processor Channel 2"},
2615 {"DAI 2 Out Mux", "DMic 2", "Input Processor Channel 3"},
2617 {"DAI 3 Out Mux", "ADC/DMic 1", "Input Processor Channel 0"},
2618 {"DAI 3 Out Mux", "ADC/DMic 1", "Input Processor Channel 1"},
2619 {"DAI 3 Out Mux", "DMic 2", "Input Processor Channel 2"},
2620 {"DAI 3 Out Mux", "DMic 2", "Input Processor Channel 3"},
2631 struct snd_soc_component *component = dai->component; in tscs454_set_sysclk()
2636 dev_dbg(component->dev, "%s(): freq = %u\n", __func__, freq); in tscs454_set_sysclk()
2641 if (bclk_dai != dai->id) in tscs454_set_sysclk()
2644 tscs454->bclk_freq = freq; in tscs454_set_sysclk()
2653 struct snd_soc_component *component = dai->component; in tscs454_set_bclk_ratio()
2657 dev_dbg(component->dev, "set_bclk_ratio() id = %d ratio = %u\n", in tscs454_set_bclk_ratio()
2658 dai->id, ratio); in tscs454_set_bclk_ratio()
2660 switch (dai->id) { in tscs454_set_bclk_ratio()
2674 ret = -EINVAL; in tscs454_set_bclk_ratio()
2675 dev_err(component->dev, "Unknown audio interface (%d)\n", ret); in tscs454_set_bclk_ratio()
2690 ret = -EINVAL; in tscs454_set_bclk_ratio()
2691 dev_err(component->dev, "Unsupported bclk ratio (%d)\n", ret); in tscs454_set_bclk_ratio()
2698 dev_err(component->dev, in tscs454_set_bclk_ratio()
2713 aif->master = true; in set_aif_master_from_fmt()
2716 aif->master = false; in set_aif_master_from_fmt()
2719 ret = -EINVAL; in set_aif_master_from_fmt()
2720 dev_err(component->dev, "Unsupported format (%d)\n", ret); in set_aif_master_from_fmt()
2744 ret = -EINVAL; in set_aif_tdm_delay()
2745 dev_err(component->dev, in set_aif_tdm_delay()
2752 dev_err(component->dev, "Failed to setup tdm format (%d)\n", in set_aif_tdm_delay()
2778 ret = -EINVAL; in set_aif_format_from_fmt()
2779 dev_err(component->dev, in set_aif_format_from_fmt()
2807 ret = -EINVAL; in set_aif_format_from_fmt()
2808 dev_err(component->dev, "Format unsupported (%d)\n", ret); in set_aif_format_from_fmt()
2815 dev_err(component->dev, "Failed to set DAI %d format (%d)\n", in set_aif_format_from_fmt()
2842 ret = -EINVAL; in set_aif_clock_format_from_fmt()
2843 dev_err(component->dev, in set_aif_clock_format_from_fmt()
2862 ret = -EINVAL; in set_aif_clock_format_from_fmt()
2863 dev_err(component->dev, "Format unknown (%d)\n", ret); in set_aif_clock_format_from_fmt()
2870 dev_err(component->dev, in set_aif_clock_format_from_fmt()
2881 struct snd_soc_component *component = dai->component; in tscs454_set_dai_fmt()
2883 struct aif *aif = &tscs454->aifs[dai->id]; in tscs454_set_dai_fmt()
2890 ret = set_aif_format_from_fmt(component, dai->id, fmt); in tscs454_set_dai_fmt()
2894 ret = set_aif_clock_format_from_fmt(component, dai->id, fmt); in tscs454_set_dai_fmt()
2905 struct snd_soc_component *component = dai->component; in tscs454_dai1_set_tdm_slot()
2913 ret = -EINVAL; in tscs454_dai1_set_tdm_slot()
2914 dev_err(component->dev, "Invalid TDM slot mask (%d)\n", ret); in tscs454_dai1_set_tdm_slot()
2929 ret = -EINVAL; in tscs454_dai1_set_tdm_slot()
2930 dev_err(component->dev, "Invalid number of slots (%d)\n", ret); in tscs454_dai1_set_tdm_slot()
2945 ret = -EINVAL; in tscs454_dai1_set_tdm_slot()
2946 dev_err(component->dev, "Invalid TDM slot width (%d)\n", ret); in tscs454_dai1_set_tdm_slot()
2951 dev_err(component->dev, "Failed to set slots (%d)\n", ret); in tscs454_dai1_set_tdm_slot()
2962 struct snd_soc_component *component = dai->component; in tscs454_dai23_set_tdm_slot()
2971 ret = -EINVAL; in tscs454_dai23_set_tdm_slot()
2972 dev_err(component->dev, "Invalid TDM slot mask (%d)\n", ret); in tscs454_dai23_set_tdm_slot()
2976 switch (dai->id) { in tscs454_dai23_set_tdm_slot()
2984 ret = -EINVAL; in tscs454_dai23_set_tdm_slot()
2985 dev_err(component->dev, "Unrecognized interface %d (%d)\n", in tscs454_dai23_set_tdm_slot()
2986 dai->id, ret); in tscs454_dai23_set_tdm_slot()
2998 ret = -EINVAL; in tscs454_dai23_set_tdm_slot()
2999 dev_err(component->dev, "Invalid number of slots (%d)\n", ret); in tscs454_dai23_set_tdm_slot()
3014 ret = -EINVAL; in tscs454_dai23_set_tdm_slot()
3015 dev_err(component->dev, "Invalid TDM slot width (%d)\n", ret); in tscs454_dai23_set_tdm_slot()
3020 dev_err(component->dev, "Failed to set slots (%d)\n", ret); in tscs454_dai23_set_tdm_slot()
3078 ret = -EINVAL; in set_aif_fs()
3079 dev_err(component->dev, "Unsupported sample rate (%d)\n", ret); in set_aif_fs()
3094 ret = -EINVAL; in set_aif_fs()
3095 dev_err(component->dev, "DAI ID not recognized (%d)\n", ret); in set_aif_fs()
3102 dev_err(component->dev, in set_aif_fs()
3133 ret = -EINVAL; in set_aif_sample_format()
3134 dev_err(component->dev, "Unsupported format width (%d)\n", ret); in set_aif_sample_format()
3149 ret = -EINVAL; in set_aif_sample_format()
3150 dev_err(component->dev, "AIF ID not recognized (%d)\n", ret); in set_aif_sample_format()
3157 dev_err(component->dev, in set_aif_sample_format()
3169 struct snd_soc_component *component = dai->component; in tscs454_hw_params()
3172 struct aif *aif = &tscs454->aifs[dai->id]; in tscs454_hw_params()
3176 mutex_lock(&tscs454->aifs_status_lock); in tscs454_hw_params()
3178 dev_dbg(component->dev, "%s(): aif %d fs = %u\n", __func__, in tscs454_hw_params()
3179 aif->id, fs); in tscs454_hw_params()
3181 if (!aif_active(&tscs454->aifs_status, aif->id)) { in tscs454_hw_params()
3183 aif->pll = &tscs454->pll1; in tscs454_hw_params()
3185 aif->pll = &tscs454->pll2; in tscs454_hw_params()
3187 dev_dbg(component->dev, "Reserving pll %d for aif %d\n", in tscs454_hw_params()
3188 aif->pll->id, aif->id); in tscs454_hw_params()
3190 reserve_pll(aif->pll); in tscs454_hw_params()
3193 if (!aifs_active(&tscs454->aifs_status)) { /* First active aif */ in tscs454_hw_params()
3196 tscs454->internal_rate.pll = &tscs454->pll1; in tscs454_hw_params()
3198 tscs454->internal_rate.pll = &tscs454->pll2; in tscs454_hw_params()
3200 dev_dbg(component->dev, "Reserving pll %d for ir\n", in tscs454_hw_params()
3201 tscs454->internal_rate.pll->id); in tscs454_hw_params()
3203 reserve_pll(tscs454->internal_rate.pll); in tscs454_hw_params()
3206 ret = set_aif_fs(component, aif->id, fs); in tscs454_hw_params()
3208 dev_err(component->dev, "Failed to set aif fs (%d)\n", ret); in tscs454_hw_params()
3212 ret = set_aif_sample_format(component, params_format(params), aif->id); in tscs454_hw_params()
3214 dev_err(component->dev, in tscs454_hw_params()
3219 set_aif_status_active(&tscs454->aifs_status, aif->id, in tscs454_hw_params()
3220 substream->stream == SNDRV_PCM_STREAM_PLAYBACK); in tscs454_hw_params()
3222 dev_dbg(component->dev, "Set aif %d active. Streams status is 0x%x\n", in tscs454_hw_params()
3223 aif->id, tscs454->aifs_status.streams); in tscs454_hw_params()
3227 mutex_unlock(&tscs454->aifs_status_lock); in tscs454_hw_params()
3235 struct snd_soc_component *component = dai->component; in tscs454_hw_free()
3237 struct aif *aif = &tscs454->aifs[dai->id]; in tscs454_hw_free()
3240 substream->stream == SNDRV_PCM_STREAM_PLAYBACK); in tscs454_hw_free()
3247 struct snd_soc_component *component = dai->component; in tscs454_prepare()
3249 struct aif *aif = &tscs454->aifs[dai->id]; in tscs454_prepare()
3284 switch (tscs454->sysclk_src_id) { in tscs454_probe()
3298 ret = -EINVAL; in tscs454_probe()
3299 dev_err(component->dev, "Invalid sysclk src id (%d)\n", ret); in tscs454_probe()
3306 dev_err(component->dev, "Failed to set PLL input (%d)\n", ret); in tscs454_probe()
3310 if (tscs454->sysclk_src_id < PLL_INPUT_BCLK) in tscs454_probe()
3334 .name = "tscs454-dai1",
3354 .name = "tscs454-dai2",
3374 .name = "tscs454-dai3",
3402 int src; in tscs454_i2c_probe() local
3405 tscs454 = devm_kzalloc(&i2c->dev, sizeof(*tscs454), GFP_KERNEL); in tscs454_i2c_probe()
3407 return -ENOMEM; in tscs454_i2c_probe()
3415 for (src = PLL_INPUT_XTAL; src < PLL_INPUT_BCLK; src++) { in tscs454_i2c_probe()
3416 tscs454->sysclk = devm_clk_get(&i2c->dev, src_names[src]); in tscs454_i2c_probe()
3417 if (!IS_ERR(tscs454->sysclk)) { in tscs454_i2c_probe()
3419 } else if (PTR_ERR(tscs454->sysclk) != -ENOENT) { in tscs454_i2c_probe()
3420 ret = PTR_ERR(tscs454->sysclk); in tscs454_i2c_probe()
3421 dev_err(&i2c->dev, "Failed to get sysclk (%d)\n", ret); in tscs454_i2c_probe()
3425 dev_dbg(&i2c->dev, "PLL input is %s\n", src_names[src]); in tscs454_i2c_probe()
3426 tscs454->sysclk_src_id = src; in tscs454_i2c_probe()
3428 ret = regmap_write(tscs454->regmap, in tscs454_i2c_probe()
3431 dev_err(&i2c->dev, "Failed to reset the component (%d)\n", ret); in tscs454_i2c_probe()
3434 regcache_mark_dirty(tscs454->regmap); in tscs454_i2c_probe()
3436 ret = regmap_register_patch(tscs454->regmap, tscs454_patch, in tscs454_i2c_probe()
3439 dev_err(&i2c->dev, "Failed to apply patch (%d)\n", ret); in tscs454_i2c_probe()
3443 regmap_write(tscs454->regmap, R_PAGESEL, 0x00); in tscs454_i2c_probe()
3445 ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_tscs454, in tscs454_i2c_probe()
3448 dev_err(&i2c->dev, "Failed to register component (%d)\n", ret); in tscs454_i2c_probe()