Lines Matching +full:vccad1 +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-only
39 "VCCAD1",
108 static const char *const pcm3168a_con[] = { "Differential", "Single-Ended" };
126 /* -100db to 0db, register values 0-54 cause mute */
127 static const DECLARE_TLV_DB_SCALE(pcm3168a_dac_tlv, -10050, 50, 1);
129 /* -100db to 20db, register values 0-14 cause mute */
130 static const DECLARE_TLV_DB_SCALE(pcm3168a_adc_tlv, -10050, 50, 1);
133 SOC_SINGLE("DAC Power-Save Switch", PCM3168A_DAC_PWR_MST_FMT,
135 SOC_ENUM("DAC1 Digital Filter roll-off", pcm3168a_d1_roll_off),
136 SOC_ENUM("DAC2 Digital Filter roll-off", pcm3168a_d2_roll_off),
137 SOC_ENUM("DAC3 Digital Filter roll-off", pcm3168a_d3_roll_off),
138 SOC_ENUM("DAC4 Digital Filter roll-off", pcm3168a_d4_roll_off),
145 SOC_ENUM("DAC De-Emphasis", pcm3168a_dac_demp),
167 SOC_SINGLE("ADC1 High-Pass Filter Switch", PCM3168A_ADC_PWR_HPFB,
169 SOC_SINGLE("ADC2 High-Pass Filter Switch", PCM3168A_ADC_PWR_HPFB,
171 SOC_SINGLE("ADC3 High-Pass Filter Switch", PCM3168A_ADC_PWR_HPFB,
271 #define PCM3168A_NUM_SCKI_RATIOS_ADC (ARRAY_SIZE(pcm3168a_scki_ratios) - 2)
279 ret = regmap_write(pcm3168a->regmap, PCM3168A_RST_SMODE, 0);
283 /* Internal reset is de-asserted after 3846 SCKI cycles */
284 msleep(DIV_ROUND_UP(3846 * 1000, pcm3168a->sysclk));
286 return regmap_write(pcm3168a->regmap, PCM3168A_RST_SMODE,
292 struct snd_soc_component *component = dai->component;
295 regmap_write(pcm3168a->regmap, PCM3168A_DAC_MUTE, mute ? 0xff : 0);
303 struct pcm3168a_priv *pcm3168a = snd_soc_component_get_drvdata(dai->component);
314 return -EINVAL;
316 ret = clk_set_rate(pcm3168a->scki, freq);
320 pcm3168a->sysclk = freq;
327 struct snd_soc_component *component = dai->component;
329 struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id];
331 unsigned int channel_max = dai->id == PCM3168A_DAI_DAC ? 8 : 6;
333 if (io_params->format == SND_SOC_DAIFMT_RIGHT_J) {
341 if (io_params->tdm_slots != 2)
345 if (dai->id == PCM3168A_DAI_DAC) {
346 dai->driver->playback.channels_max = channel_max;
347 dai->driver->playback.formats = formats;
349 dai->driver->capture.channels_max = channel_max;
350 dai->driver->capture.formats = formats;
356 struct snd_soc_component *component = dai->component;
358 struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id];
369 dev_err(component->dev, "unsupported dai format\n");
370 return -EINVAL;
381 dev_err(component->dev, "unsupported provider mode\n");
382 return -EINVAL;
389 return -EINVAL;
392 io_params->provider_mode = provider_mode;
393 io_params->format = format & SND_SOC_DAIFMT_FORMAT_MASK;
404 struct snd_soc_component *component = dai->component;
406 struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id];
409 dev_err(component->dev,
412 return -EINVAL;
417 dev_err(component->dev, "Unsupported slot_width %d\n",
419 return -EINVAL;
422 io_params->tdm_slots = slots;
423 io_params->slot_width = slot_width;
425 if (dai->id == PCM3168A_DAI_DAC)
426 io_params->tdm_mask = tx_mask;
428 io_params->tdm_mask = rx_mask;
439 struct snd_soc_component *component = dai->component;
441 struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id];
447 if (dai->id == PCM3168A_DAI_DAC) {
461 provider_mode = io_params->provider_mode;
464 ratio = pcm3168a->sysclk / params_rate(params);
472 dev_err(component->dev, "unsupported sysclk ratio\n");
473 return -EINVAL;
481 format = io_params->format;
483 if (io_params->slot_width)
484 slot_width = io_params->slot_width;
491 dev_err(component->dev, "16-bit slots are supported only for consumer mode using right justified\n");
492 return -EINVAL;
498 dev_err(component->dev, "24-bit slots not supported in consumer mode using DSP\n");
499 return -EINVAL;
505 dev_err(component->dev, "unsupported frame size: %d\n", slot_width);
506 return -EINVAL;
509 if (io_params->tdm_slots)
510 tdm_slots = io_params->tdm_slots;
517 * If pcm3168a->tdm_slots is not set or set to more than 2 (8/6 usually)
519 * If pcm3168a->tdm_slots is set to 2 then DIN1/2/3/4 and DOUT1/2/3 is
532 dev_err(component->dev,
534 return -EINVAL;
556 return -EINVAL;
559 regmap_update_bits(pcm3168a->regmap, reg, mask,
602 .name = "pcm3168a-dac",
614 .name = "pcm3168a-adc",
727 return -ENOMEM;
739 pcm3168a->gpio_rst = devm_gpiod_get_optional(dev, "reset",
742 if (IS_ERR(pcm3168a->gpio_rst))
743 return dev_err_probe(dev, PTR_ERR(pcm3168a->gpio_rst),
746 pcm3168a->scki = devm_clk_get_optional(dev, "scki");
747 if (IS_ERR(pcm3168a->scki))
748 return dev_err_probe(dev, PTR_ERR(pcm3168a->scki),
751 ret = clk_prepare_enable(pcm3168a->scki);
757 pcm3168a->sysclk = clk_get_rate(pcm3168a->scki);
759 if (!pcm3168a->sysclk)
760 pcm3168a->sysclk = 24576000;
762 for (i = 0; i < ARRAY_SIZE(pcm3168a->supplies); i++)
763 pcm3168a->supplies[i].supply = pcm3168a_supply_names[i];
766 ARRAY_SIZE(pcm3168a->supplies), pcm3168a->supplies);
772 ret = regulator_bulk_enable(ARRAY_SIZE(pcm3168a->supplies),
773 pcm3168a->supplies);
779 pcm3168a->regmap = regmap;
780 if (IS_ERR(pcm3168a->regmap)) {
781 ret = PTR_ERR(pcm3168a->regmap);
786 if (pcm3168a->gpio_rst) {
789 * 3846 SCKI clock cycles for the internal reset de-assertion
791 msleep(DIV_ROUND_UP(3846 * 1000, pcm3168a->sysclk));
804 memcpy(pcm3168a->dai_drv, pcm3168a_dais, sizeof(pcm3168a->dai_drv));
806 pcm3168a->dai_drv,
807 ARRAY_SIZE(pcm3168a->dai_drv));
816 regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies),
817 pcm3168a->supplies);
819 clk_disable_unprepare(pcm3168a->scki);
829 regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies),
830 pcm3168a->supplies);
831 clk_disable_unprepare(pcm3168a->scki);
844 gpiod_set_value_cansleep(pcm3168a->gpio_rst, 1);
857 ret = clk_prepare_enable(pcm3168a->scki);
863 ret = regulator_bulk_enable(ARRAY_SIZE(pcm3168a->supplies),
864 pcm3168a->supplies);
876 regcache_cache_only(pcm3168a->regmap, false);
878 regcache_mark_dirty(pcm3168a->regmap);
880 ret = regcache_sync(pcm3168a->regmap);
889 regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies),
890 pcm3168a->supplies);
892 clk_disable_unprepare(pcm3168a->scki);
901 regcache_cache_only(pcm3168a->regmap, true);