Lines Matching +full:clkdiv +full:- +full:-
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
100 #define ADAU1707_CLKDIV_UNSET (-1U)
192 size = adau1701_register_size(&client->dev, reg); in adau1701_reg_write()
194 return -EINVAL; in adau1701_reg_write()
199 for (i = size + 1; i >= 2; --i) { in adau1701_reg_write()
210 return -EIO; in adau1701_reg_write()
223 size = adau1701_register_size(&client->dev, reg); in adau1701_reg_read()
225 return -EINVAL; in adau1701_reg_read()
230 msgs[0].addr = client->addr; in adau1701_reg_read()
235 msgs[1].addr = client->addr; in adau1701_reg_read()
240 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in adau1701_reg_read()
244 return -EIO; in adau1701_reg_read()
259 struct i2c_client *client = to_i2c_client(sigmadsp->dev); in adau1701_safeload()
266 ret = regmap_read(adau1701->regmap, ADAU1701_DSPCTRL, &val); in adau1701_safeload()
281 return -EIO; in adau1701_safeload()
289 return -EIO; in adau1701_safeload()
292 return regmap_update_bits(adau1701->regmap, ADAU1701_DSPCTRL, in adau1701_safeload()
300 static int adau1701_reset(struct snd_soc_component *component, unsigned int clkdiv, in adau1701_reset() argument
307 sigmadsp_reset(adau1701->sigmadsp); in adau1701_reset()
309 if (clkdiv != ADAU1707_CLKDIV_UNSET && adau1701->gpio_pll_mode) { in adau1701_reset()
310 switch (clkdiv) { in adau1701_reset()
329 gpiod_set_array_value_cansleep(adau1701->gpio_pll_mode->ndescs, in adau1701_reset()
330 adau1701->gpio_pll_mode->desc, adau1701->gpio_pll_mode->info, in adau1701_reset()
334 adau1701->pll_clkdiv = clkdiv; in adau1701_reset()
336 if (adau1701->gpio_nreset) { in adau1701_reset()
337 gpiod_set_value_cansleep(adau1701->gpio_nreset, 0); in adau1701_reset()
340 gpiod_set_value_cansleep(adau1701->gpio_nreset, 1); in adau1701_reset()
341 /* power-up time may be as long as 85ms */ in adau1701_reset()
349 if (clkdiv != ADAU1707_CLKDIV_UNSET) { in adau1701_reset()
350 ret = sigmadsp_setup(adau1701->sigmadsp, rate); in adau1701_reset()
352 dev_warn(component->dev, "Failed to load firmware\n"); in adau1701_reset()
357 regmap_write(adau1701->regmap, ADAU1701_DACSET, ADAU1701_DACSET_DACINIT); in adau1701_reset()
358 regmap_write(adau1701->regmap, ADAU1701_DSPCTRL, ADAU1701_DSPCTRL_CR); in adau1701_reset()
360 regcache_mark_dirty(adau1701->regmap); in adau1701_reset()
361 regcache_sync(adau1701->regmap); in adau1701_reset()
384 return -EINVAL; in adau1701_set_capture_pcm_format()
387 if (adau1701->dai_fmt == SND_SOC_DAIFMT_RIGHT_J) { in adau1701_set_capture_pcm_format()
402 regmap_update_bits(adau1701->regmap, ADAU1701_SEROCTL, mask, val); in adau1701_set_capture_pcm_format()
413 if (adau1701->dai_fmt != SND_SOC_DAIFMT_RIGHT_J) in adau1701_set_playback_pcm_format()
427 return -EINVAL; in adau1701_set_playback_pcm_format()
430 regmap_update_bits(adau1701->regmap, ADAU1701_SERICTL, in adau1701_set_playback_pcm_format()
439 struct snd_soc_component *component = dai->component; in adau1701_hw_params()
441 unsigned int clkdiv = adau1701->sysclk / params_rate(params); in adau1701_hw_params() local
450 if (clkdiv != adau1701->pll_clkdiv) { in adau1701_hw_params()
451 ret = adau1701_reset(component, clkdiv, params_rate(params)); in adau1701_hw_params()
467 return -EINVAL; in adau1701_hw_params()
470 regmap_update_bits(adau1701->regmap, ADAU1701_DSPCTRL, in adau1701_hw_params()
473 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in adau1701_hw_params()
482 struct snd_soc_component *component = codec_dai->component; in adau1701_set_dai_fmt()
489 /* master, 64-bits per sample, 1 frame per sample */ in adau1701_set_dai_fmt()
496 return -EINVAL; in adau1701_set_dai_fmt()
518 return -EINVAL; in adau1701_set_dai_fmt()
535 return -EINVAL; in adau1701_set_dai_fmt()
543 adau1701->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in adau1701_set_dai_fmt()
545 regmap_write(adau1701->regmap, ADAU1701_SERICTL, serictl); in adau1701_set_dai_fmt()
546 regmap_update_bits(adau1701->regmap, ADAU1701_SEROCTL, in adau1701_set_dai_fmt()
565 regmap_update_bits(adau1701->regmap, in adau1701_set_bias_level()
570 regmap_update_bits(adau1701->regmap, in adau1701_set_bias_level()
580 struct snd_soc_component *component = dai->component; in adau1701_mute_stream()
590 regmap_update_bits(adau1701->regmap, ADAU1701_DSPCTRL, mask, val); in adau1701_mute_stream()
609 return -EINVAL; in adau1701_set_sysclk()
612 regmap_update_bits(adau1701->regmap, ADAU1701_OSCIPOW, in adau1701_set_sysclk()
614 adau1701->sysclk = freq; in adau1701_set_sysclk()
622 struct adau1701 *adau1701 = snd_soc_component_get_drvdata(dai->component); in adau1701_startup()
624 return sigmadsp_restrict_params(adau1701->sigmadsp, substream); in adau1701_startup()
675 ret = sigmadsp_attach(adau1701->sigmadsp, component); in adau1701_probe()
679 ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), in adau1701_probe()
680 adau1701->supplies); in adau1701_probe()
682 dev_err(component->dev, "Failed to enable regulators: %d\n", ret); in adau1701_probe()
692 adau1701->pll_clkdiv = ADAU1707_CLKDIV_UNSET; in adau1701_probe()
694 /* initalize with pre-configured pll mode settings */ in adau1701_probe()
695 ret = adau1701_reset(component, adau1701->pll_clkdiv, 0); in adau1701_probe()
702 val |= adau1701->pin_config[i] << (i * 4); in adau1701_probe()
704 regmap_write(adau1701->regmap, ADAU1701_PINCONF_0, val); in adau1701_probe()
708 val |= adau1701->pin_config[i + 6] << (i * 4); in adau1701_probe()
710 regmap_write(adau1701->regmap, ADAU1701_PINCONF_1, val); in adau1701_probe()
716 regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); in adau1701_probe()
724 if (adau1701->gpio_nreset) in adau1701_remove()
725 gpiod_set_value_cansleep(adau1701->gpio_nreset, 0); in adau1701_remove()
727 regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); in adau1701_remove()
735 regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), in adau1701_suspend()
736 adau1701->supplies); in adau1701_suspend()
746 ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), in adau1701_resume()
747 adau1701->supplies); in adau1701_resume()
749 dev_err(component->dev, "Failed to enable regulators: %d\n", ret); in adau1701_resume()
753 return adau1701_reset(component, adau1701->pll_clkdiv, 0); in adau1701_resume()
790 struct device *dev = &client->dev; in adau1701_i2c_probe()
795 return -ENOMEM; in adau1701_i2c_probe()
798 adau1701->supplies[i].supply = supply_names[i]; in adau1701_i2c_probe()
800 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(adau1701->supplies), in adau1701_i2c_probe()
801 adau1701->supplies); in adau1701_i2c_probe()
807 ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), in adau1701_i2c_probe()
808 adau1701->supplies); in adau1701_i2c_probe()
814 adau1701->client = client; in adau1701_i2c_probe()
815 adau1701->regmap = devm_regmap_init(dev, NULL, client, in adau1701_i2c_probe()
817 if (IS_ERR(adau1701->regmap)) { in adau1701_i2c_probe()
818 ret = PTR_ERR(adau1701->regmap); in adau1701_i2c_probe()
823 if (dev->of_node) { in adau1701_i2c_probe()
824 of_property_read_u32(dev->of_node, "adi,pll-clkdiv", in adau1701_i2c_probe()
825 &adau1701->pll_clkdiv); in adau1701_i2c_probe()
827 of_property_read_u8_array(dev->of_node, "adi,pin-config", in adau1701_i2c_probe()
828 adau1701->pin_config, in adau1701_i2c_probe()
829 ARRAY_SIZE(adau1701->pin_config)); in adau1701_i2c_probe()
832 adau1701->gpio_nreset = devm_gpiod_get_optional(dev, "reset", GPIOD_IN); in adau1701_i2c_probe()
834 if (IS_ERR(adau1701->gpio_nreset)) { in adau1701_i2c_probe()
835 ret = PTR_ERR(adau1701->gpio_nreset); in adau1701_i2c_probe()
839 adau1701->gpio_pll_mode = devm_gpiod_get_array_optional(dev, "adi,pll-mode", GPIOD_OUT_LOW); in adau1701_i2c_probe()
841 if (IS_ERR(adau1701->gpio_pll_mode)) { in adau1701_i2c_probe()
842 ret = PTR_ERR(adau1701->gpio_pll_mode); in adau1701_i2c_probe()
848 adau1701->sigmadsp = devm_sigmadsp_init_i2c(client, in adau1701_i2c_probe()
850 if (IS_ERR(adau1701->sigmadsp)) { in adau1701_i2c_probe()
851 ret = PTR_ERR(adau1701->sigmadsp); in adau1701_i2c_probe()
855 ret = devm_snd_soc_register_component(&client->dev, in adau1701_i2c_probe()
861 regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); in adau1701_i2c_probe()
887 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");