Lines Matching +full:adc +full:- +full:startup +full:- +full:time

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
99 #define ADAU1707_CLKDIV_UNSET (-1U)
130 SND_SOC_DAPM_ADC("ADC", "Capture", ADAU1701_AUXNPOW, 7, 1),
146 { "ADC", NULL, "IN0" },
147 { "ADC", NULL, "IN1" },
191 size = adau1701_register_size(&client->dev, reg); in adau1701_reg_write()
193 return -EINVAL; in adau1701_reg_write()
198 for (i = size + 1; i >= 2; --i) { in adau1701_reg_write()
209 return -EIO; in adau1701_reg_write()
222 size = adau1701_register_size(&client->dev, reg); in adau1701_reg_read()
224 return -EINVAL; in adau1701_reg_read()
229 msgs[0].addr = client->addr; in adau1701_reg_read()
234 msgs[1].addr = client->addr; in adau1701_reg_read()
239 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in adau1701_reg_read()
243 return -EIO; in adau1701_reg_read()
258 struct i2c_client *client = to_i2c_client(sigmadsp->dev); in adau1701_safeload()
265 ret = regmap_read(adau1701->regmap, ADAU1701_DSPCTRL, &val); in adau1701_safeload()
280 return -EIO; in adau1701_safeload()
288 return -EIO; in adau1701_safeload()
291 return regmap_update_bits(adau1701->regmap, ADAU1701_DSPCTRL, in adau1701_safeload()
306 sigmadsp_reset(adau1701->sigmadsp); in adau1701_reset()
308 if (clkdiv != ADAU1707_CLKDIV_UNSET && adau1701->gpio_pll_mode) { in adau1701_reset()
328 gpiod_set_array_value_cansleep(adau1701->gpio_pll_mode->ndescs, in adau1701_reset()
329 adau1701->gpio_pll_mode->desc, adau1701->gpio_pll_mode->info, in adau1701_reset()
333 adau1701->pll_clkdiv = clkdiv; in adau1701_reset()
335 if (adau1701->gpio_nreset) { in adau1701_reset()
336 gpiod_set_value_cansleep(adau1701->gpio_nreset, 0); in adau1701_reset()
337 /* minimum reset time is 20ns */ in adau1701_reset()
339 gpiod_set_value_cansleep(adau1701->gpio_nreset, 1); in adau1701_reset()
340 /* power-up time may be as long as 85ms */ in adau1701_reset()
345 * Postpone the firmware download to a point in time when we in adau1701_reset()
349 ret = sigmadsp_setup(adau1701->sigmadsp, rate); in adau1701_reset()
351 dev_warn(component->dev, "Failed to load firmware\n"); in adau1701_reset()
356 regmap_write(adau1701->regmap, ADAU1701_DACSET, ADAU1701_DACSET_DACINIT); in adau1701_reset()
357 regmap_write(adau1701->regmap, ADAU1701_DSPCTRL, ADAU1701_DSPCTRL_CR); in adau1701_reset()
359 regcache_mark_dirty(adau1701->regmap); in adau1701_reset()
360 regcache_sync(adau1701->regmap); in adau1701_reset()
383 return -EINVAL; in adau1701_set_capture_pcm_format()
386 if (adau1701->dai_fmt == SND_SOC_DAIFMT_RIGHT_J) { in adau1701_set_capture_pcm_format()
401 regmap_update_bits(adau1701->regmap, ADAU1701_SEROCTL, mask, val); in adau1701_set_capture_pcm_format()
412 if (adau1701->dai_fmt != SND_SOC_DAIFMT_RIGHT_J) in adau1701_set_playback_pcm_format()
426 return -EINVAL; in adau1701_set_playback_pcm_format()
429 regmap_update_bits(adau1701->regmap, ADAU1701_SERICTL, in adau1701_set_playback_pcm_format()
438 struct snd_soc_component *component = dai->component; in adau1701_hw_params()
440 unsigned int clkdiv = adau1701->sysclk / params_rate(params); in adau1701_hw_params()
449 if (clkdiv != adau1701->pll_clkdiv) { in adau1701_hw_params()
466 return -EINVAL; in adau1701_hw_params()
469 regmap_update_bits(adau1701->regmap, ADAU1701_DSPCTRL, in adau1701_hw_params()
472 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in adau1701_hw_params()
481 struct snd_soc_component *component = codec_dai->component; in adau1701_set_dai_fmt()
488 /* master, 64-bits per sample, 1 frame per sample */ in adau1701_set_dai_fmt()
495 return -EINVAL; in adau1701_set_dai_fmt()
517 return -EINVAL; in adau1701_set_dai_fmt()
534 return -EINVAL; in adau1701_set_dai_fmt()
542 adau1701->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in adau1701_set_dai_fmt()
544 regmap_write(adau1701->regmap, ADAU1701_SERICTL, serictl); in adau1701_set_dai_fmt()
545 regmap_update_bits(adau1701->regmap, ADAU1701_SEROCTL, in adau1701_set_dai_fmt()
564 regmap_update_bits(adau1701->regmap, in adau1701_set_bias_level()
569 regmap_update_bits(adau1701->regmap, in adau1701_set_bias_level()
579 struct snd_soc_component *component = dai->component; in adau1701_mute_stream()
589 regmap_update_bits(adau1701->regmap, ADAU1701_DSPCTRL, mask, val); in adau1701_mute_stream()
608 return -EINVAL; in adau1701_set_sysclk()
611 regmap_update_bits(adau1701->regmap, ADAU1701_OSCIPOW, in adau1701_set_sysclk()
613 adau1701->sysclk = freq; in adau1701_set_sysclk()
621 struct adau1701 *adau1701 = snd_soc_component_get_drvdata(dai->component); in adau1701_startup()
623 return sigmadsp_restrict_params(adau1701->sigmadsp, substream); in adau1701_startup()
636 .startup = adau1701_startup,
674 ret = sigmadsp_attach(adau1701->sigmadsp, component); in adau1701_probe()
678 ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), in adau1701_probe()
679 adau1701->supplies); in adau1701_probe()
681 dev_err(component->dev, "Failed to enable regulators: %d\n", ret); in adau1701_probe()
688 * adau1701_reset() to a point in time when we know the correct PLL in adau1701_probe()
691 adau1701->pll_clkdiv = ADAU1707_CLKDIV_UNSET; in adau1701_probe()
693 /* initalize with pre-configured pll mode settings */ in adau1701_probe()
694 ret = adau1701_reset(component, adau1701->pll_clkdiv, 0); in adau1701_probe()
701 val |= adau1701->pin_config[i] << (i * 4); in adau1701_probe()
703 regmap_write(adau1701->regmap, ADAU1701_PINCONF_0, val); in adau1701_probe()
707 val |= adau1701->pin_config[i + 6] << (i * 4); in adau1701_probe()
709 regmap_write(adau1701->regmap, ADAU1701_PINCONF_1, val); in adau1701_probe()
715 regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); in adau1701_probe()
723 if (adau1701->gpio_nreset) in adau1701_remove()
724 gpiod_set_value_cansleep(adau1701->gpio_nreset, 0); in adau1701_remove()
726 regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); in adau1701_remove()
734 regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), in adau1701_suspend()
735 adau1701->supplies); in adau1701_suspend()
745 ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), in adau1701_resume()
746 adau1701->supplies); in adau1701_resume()
748 dev_err(component->dev, "Failed to enable regulators: %d\n", ret); in adau1701_resume()
752 return adau1701_reset(component, adau1701->pll_clkdiv, 0); in adau1701_resume()
789 struct device *dev = &client->dev; in adau1701_i2c_probe()
794 return -ENOMEM; in adau1701_i2c_probe()
797 adau1701->supplies[i].supply = supply_names[i]; in adau1701_i2c_probe()
799 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(adau1701->supplies), in adau1701_i2c_probe()
800 adau1701->supplies); in adau1701_i2c_probe()
806 ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), in adau1701_i2c_probe()
807 adau1701->supplies); in adau1701_i2c_probe()
813 adau1701->client = client; in adau1701_i2c_probe()
814 adau1701->regmap = devm_regmap_init(dev, NULL, client, in adau1701_i2c_probe()
816 if (IS_ERR(adau1701->regmap)) { in adau1701_i2c_probe()
817 ret = PTR_ERR(adau1701->regmap); in adau1701_i2c_probe()
822 if (dev->of_node) { in adau1701_i2c_probe()
823 of_property_read_u32(dev->of_node, "adi,pll-clkdiv", in adau1701_i2c_probe()
824 &adau1701->pll_clkdiv); in adau1701_i2c_probe()
826 of_property_read_u8_array(dev->of_node, "adi,pin-config", in adau1701_i2c_probe()
827 adau1701->pin_config, in adau1701_i2c_probe()
828 ARRAY_SIZE(adau1701->pin_config)); in adau1701_i2c_probe()
831 adau1701->gpio_nreset = devm_gpiod_get_optional(dev, "reset", GPIOD_IN); in adau1701_i2c_probe()
833 if (IS_ERR(adau1701->gpio_nreset)) { in adau1701_i2c_probe()
834 ret = PTR_ERR(adau1701->gpio_nreset); in adau1701_i2c_probe()
838 adau1701->gpio_pll_mode = devm_gpiod_get_array_optional(dev, "adi,pll-mode", GPIOD_OUT_LOW); in adau1701_i2c_probe()
840 if (IS_ERR(adau1701->gpio_pll_mode)) { in adau1701_i2c_probe()
841 ret = PTR_ERR(adau1701->gpio_pll_mode); in adau1701_i2c_probe()
847 adau1701->sigmadsp = devm_sigmadsp_init_i2c(client, in adau1701_i2c_probe()
849 if (IS_ERR(adau1701->sigmadsp)) { in adau1701_i2c_probe()
850 ret = PTR_ERR(adau1701->sigmadsp); in adau1701_i2c_probe()
854 ret = devm_snd_soc_register_component(&client->dev, in adau1701_i2c_probe()
860 regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); in adau1701_i2c_probe()
886 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");