Lines Matching +full:vccda1 +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
42 "VCCDA1",
109 static const char *const pcm3168a_con[] = { "Differential", "Single-Ended" };
127 /* -100db to 0db, register values 0-54 cause mute */
128 static const DECLARE_TLV_DB_SCALE(pcm3168a_dac_tlv, -10050, 50, 1);
130 /* -100db to 20db, register values 0-14 cause mute */
131 static const DECLARE_TLV_DB_SCALE(pcm3168a_adc_tlv, -10050, 50, 1);
134 SOC_SINGLE("DAC Power-Save Switch", PCM3168A_DAC_PWR_MST_FMT,
136 SOC_ENUM("DAC1 Digital Filter roll-off", pcm3168a_d1_roll_off),
137 SOC_ENUM("DAC2 Digital Filter roll-off", pcm3168a_d2_roll_off),
138 SOC_ENUM("DAC3 Digital Filter roll-off", pcm3168a_d3_roll_off),
139 SOC_ENUM("DAC4 Digital Filter roll-off", pcm3168a_d4_roll_off),
146 SOC_ENUM("DAC De-Emphasis", pcm3168a_dac_demp),
168 SOC_SINGLE("ADC1 High-Pass Filter Switch", PCM3168A_ADC_PWR_HPFB,
170 SOC_SINGLE("ADC2 High-Pass Filter Switch", PCM3168A_ADC_PWR_HPFB,
172 SOC_SINGLE("ADC3 High-Pass Filter Switch", PCM3168A_ADC_PWR_HPFB,
272 #define PCM3168A_NUM_SCKI_RATIOS_ADC (ARRAY_SIZE(pcm3168a_scki_ratios) - 2)
280 ret = regmap_write(pcm3168a->regmap, PCM3168A_RST_SMODE, 0); in pcm3168a_reset()
284 /* Internal reset is de-asserted after 3846 SCKI cycles */ in pcm3168a_reset()
285 msleep(DIV_ROUND_UP(3846 * 1000, pcm3168a->sysclk)); in pcm3168a_reset()
287 return regmap_write(pcm3168a->regmap, PCM3168A_RST_SMODE, in pcm3168a_reset()
293 struct snd_soc_component *component = dai->component; in pcm3168a_mute()
296 regmap_write(pcm3168a->regmap, PCM3168A_DAC_MUTE, mute ? 0xff : 0); in pcm3168a_mute()
304 struct pcm3168a_priv *pcm3168a = snd_soc_component_get_drvdata(dai->component); in pcm3168a_set_dai_sysclk()
315 return -EINVAL; in pcm3168a_set_dai_sysclk()
317 ret = clk_set_rate(pcm3168a->scki, freq); in pcm3168a_set_dai_sysclk()
321 pcm3168a->sysclk = freq; in pcm3168a_set_dai_sysclk()
328 struct snd_soc_component *component = dai->component; in pcm3168a_update_fixup_pcm_stream()
330 struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id]; in pcm3168a_update_fixup_pcm_stream()
332 unsigned int channel_max = dai->id == PCM3168A_DAI_DAC ? 8 : 6; in pcm3168a_update_fixup_pcm_stream()
334 if (io_params->format == SND_SOC_DAIFMT_RIGHT_J) { in pcm3168a_update_fixup_pcm_stream()
342 if (io_params->tdm_slots != 2) in pcm3168a_update_fixup_pcm_stream()
346 if (dai->id == PCM3168A_DAI_DAC) { in pcm3168a_update_fixup_pcm_stream()
347 dai->driver->playback.channels_max = channel_max; in pcm3168a_update_fixup_pcm_stream()
348 dai->driver->playback.formats = formats; in pcm3168a_update_fixup_pcm_stream()
350 dai->driver->capture.channels_max = channel_max; in pcm3168a_update_fixup_pcm_stream()
351 dai->driver->capture.formats = formats; in pcm3168a_update_fixup_pcm_stream()
357 struct snd_soc_component *component = dai->component; in pcm3168a_set_dai_fmt()
359 struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id]; in pcm3168a_set_dai_fmt()
370 dev_err(component->dev, "unsupported dai format\n"); in pcm3168a_set_dai_fmt()
371 return -EINVAL; in pcm3168a_set_dai_fmt()
382 dev_err(component->dev, "unsupported provider mode\n"); in pcm3168a_set_dai_fmt()
383 return -EINVAL; in pcm3168a_set_dai_fmt()
390 return -EINVAL; in pcm3168a_set_dai_fmt()
393 io_params->provider_mode = provider_mode; in pcm3168a_set_dai_fmt()
394 io_params->format = format & SND_SOC_DAIFMT_FORMAT_MASK; in pcm3168a_set_dai_fmt()
405 struct snd_soc_component *component = dai->component; in pcm3168a_set_tdm_slot()
407 struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id]; in pcm3168a_set_tdm_slot()
410 dev_err(component->dev, in pcm3168a_set_tdm_slot()
413 return -EINVAL; in pcm3168a_set_tdm_slot()
418 dev_err(component->dev, "Unsupported slot_width %d\n", in pcm3168a_set_tdm_slot()
420 return -EINVAL; in pcm3168a_set_tdm_slot()
423 io_params->tdm_slots = slots; in pcm3168a_set_tdm_slot()
424 io_params->slot_width = slot_width; in pcm3168a_set_tdm_slot()
426 if (dai->id == PCM3168A_DAI_DAC) in pcm3168a_set_tdm_slot()
427 io_params->tdm_mask = tx_mask; in pcm3168a_set_tdm_slot()
429 io_params->tdm_mask = rx_mask; in pcm3168a_set_tdm_slot()
440 struct snd_soc_component *component = dai->component; in pcm3168a_hw_params()
442 struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id]; in pcm3168a_hw_params()
448 if (dai->id == PCM3168A_DAI_DAC) { in pcm3168a_hw_params()
462 provider_mode = io_params->provider_mode; in pcm3168a_hw_params()
465 ratio = pcm3168a->sysclk / params_rate(params); in pcm3168a_hw_params()
473 dev_err(component->dev, "unsupported sysclk ratio\n"); in pcm3168a_hw_params()
474 return -EINVAL; in pcm3168a_hw_params()
482 format = io_params->format; in pcm3168a_hw_params()
484 if (io_params->slot_width) in pcm3168a_hw_params()
485 slot_width = io_params->slot_width; in pcm3168a_hw_params()
492 …dev_err(component->dev, "16-bit slots are supported only for consumer mode using right justified\n… in pcm3168a_hw_params()
493 return -EINVAL; in pcm3168a_hw_params()
499 …dev_err(component->dev, "24-bit slots not supported in provider mode, or consumer mode using DSP\n… in pcm3168a_hw_params()
500 return -EINVAL; in pcm3168a_hw_params()
506 dev_err(component->dev, "unsupported frame size: %d\n", slot_width); in pcm3168a_hw_params()
507 return -EINVAL; in pcm3168a_hw_params()
510 if (io_params->tdm_slots) in pcm3168a_hw_params()
511 tdm_slots = io_params->tdm_slots; in pcm3168a_hw_params()
518 * If pcm3168a->tdm_slots is not set or set to more than 2 (8/6 usually) in pcm3168a_hw_params()
520 * If pcm3168a->tdm_slots is set to 2 then DIN1/2/3/4 and DOUT1/2/3 is in pcm3168a_hw_params()
533 dev_err(component->dev, in pcm3168a_hw_params()
535 return -EINVAL; in pcm3168a_hw_params()
557 return -EINVAL; in pcm3168a_hw_params()
560 regmap_update_bits(pcm3168a->regmap, reg, mask, in pcm3168a_hw_params()
603 .name = "pcm3168a-dac",
615 .name = "pcm3168a-adc",
728 return -ENOMEM; in pcm3168a_probe()
740 pcm3168a->gpio_rst = devm_gpiod_get_optional(dev, "reset", in pcm3168a_probe()
743 if (IS_ERR(pcm3168a->gpio_rst)) in pcm3168a_probe()
744 return dev_err_probe(dev, PTR_ERR(pcm3168a->gpio_rst), in pcm3168a_probe()
747 pcm3168a->scki = devm_clk_get(dev, "scki"); in pcm3168a_probe()
748 if (IS_ERR(pcm3168a->scki)) in pcm3168a_probe()
749 return dev_err_probe(dev, PTR_ERR(pcm3168a->scki), in pcm3168a_probe()
752 ret = clk_prepare_enable(pcm3168a->scki); in pcm3168a_probe()
758 pcm3168a->sysclk = clk_get_rate(pcm3168a->scki); in pcm3168a_probe()
760 for (i = 0; i < ARRAY_SIZE(pcm3168a->supplies); i++) in pcm3168a_probe()
761 pcm3168a->supplies[i].supply = pcm3168a_supply_names[i]; in pcm3168a_probe()
764 ARRAY_SIZE(pcm3168a->supplies), pcm3168a->supplies); in pcm3168a_probe()
770 ret = regulator_bulk_enable(ARRAY_SIZE(pcm3168a->supplies), in pcm3168a_probe()
771 pcm3168a->supplies); in pcm3168a_probe()
777 pcm3168a->regmap = regmap; in pcm3168a_probe()
778 if (IS_ERR(pcm3168a->regmap)) { in pcm3168a_probe()
779 ret = PTR_ERR(pcm3168a->regmap); in pcm3168a_probe()
784 if (pcm3168a->gpio_rst) { in pcm3168a_probe()
787 * 3846 SCKI clock cycles for the internal reset de-assertion in pcm3168a_probe()
789 msleep(DIV_ROUND_UP(3846 * 1000, pcm3168a->sysclk)); in pcm3168a_probe()
802 memcpy(pcm3168a->dai_drv, pcm3168a_dais, sizeof(pcm3168a->dai_drv)); in pcm3168a_probe()
804 pcm3168a->dai_drv, in pcm3168a_probe()
805 ARRAY_SIZE(pcm3168a->dai_drv)); in pcm3168a_probe()
814 regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies), in pcm3168a_probe()
815 pcm3168a->supplies); in pcm3168a_probe()
817 clk_disable_unprepare(pcm3168a->scki); in pcm3168a_probe()
827 regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies), in pcm3168a_disable()
828 pcm3168a->supplies); in pcm3168a_disable()
829 clk_disable_unprepare(pcm3168a->scki); in pcm3168a_disable()
842 gpiod_set_value_cansleep(pcm3168a->gpio_rst, 1); in pcm3168a_remove()
856 ret = clk_prepare_enable(pcm3168a->scki); in pcm3168a_rt_resume()
862 ret = regulator_bulk_enable(ARRAY_SIZE(pcm3168a->supplies), in pcm3168a_rt_resume()
863 pcm3168a->supplies); in pcm3168a_rt_resume()
875 regcache_cache_only(pcm3168a->regmap, false); in pcm3168a_rt_resume()
877 regcache_mark_dirty(pcm3168a->regmap); in pcm3168a_rt_resume()
879 ret = regcache_sync(pcm3168a->regmap); in pcm3168a_rt_resume()
888 regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies), in pcm3168a_rt_resume()
889 pcm3168a->supplies); in pcm3168a_rt_resume()
891 clk_disable_unprepare(pcm3168a->scki); in pcm3168a_rt_resume()
900 regcache_cache_only(pcm3168a->regmap, true); in pcm3168a_rt_suspend()