Lines Matching refs:adau1977
111 struct adau1977 { struct
225 static int adau1977_reset(struct adau1977 *adau1977) in adau1977_reset() argument
235 regcache_cache_bypass(adau1977->regmap, true); in adau1977_reset()
236 ret = regmap_write(adau1977->regmap, ADAU1977_REG_POWER, in adau1977_reset()
238 regcache_cache_bypass(adau1977->regmap, false); in adau1977_reset()
263 static int adau1977_lookup_mcs(struct adau1977 *adau1977, unsigned int rate, in adau1977_lookup_mcs() argument
276 if (adau1977->sysclk % rate != 0) in adau1977_lookup_mcs()
279 mcs = adau1977->sysclk / rate; in adau1977_lookup_mcs()
296 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); in adau1977_hw_params() local
308 if (adau1977->sysclk_src == ADAU1977_SYSCLK_SRC_MCLK) { in adau1977_hw_params()
309 mcs = adau1977_lookup_mcs(adau1977, rate, fs); in adau1977_hw_params()
319 if (adau1977->right_j) { in adau1977_hw_params()
333 if (adau1977->clock_provider) { in adau1977_hw_params()
349 if (adau1977->slot_width) in adau1977_hw_params()
350 slot_width = adau1977->slot_width; in adau1977_hw_params()
357 ret = regmap_update_bits(adau1977->regmap, in adau1977_hw_params()
366 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_SAI_CTRL0, in adau1977_hw_params()
371 return regmap_update_bits(adau1977->regmap, ADAU1977_REG_PLL, in adau1977_hw_params()
375 static int adau1977_power_disable(struct adau1977 *adau1977) in adau1977_power_disable() argument
379 if (!adau1977->enabled) in adau1977_power_disable()
382 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_POWER, in adau1977_power_disable()
387 regcache_mark_dirty(adau1977->regmap); in adau1977_power_disable()
389 gpiod_set_value_cansleep(adau1977->reset_gpio, 0); in adau1977_power_disable()
391 regcache_cache_only(adau1977->regmap, true); in adau1977_power_disable()
393 regulator_disable(adau1977->avdd_reg); in adau1977_power_disable()
394 if (adau1977->dvdd_reg) in adau1977_power_disable()
395 regulator_disable(adau1977->dvdd_reg); in adau1977_power_disable()
397 adau1977->enabled = false; in adau1977_power_disable()
402 static int adau1977_power_enable(struct adau1977 *adau1977) in adau1977_power_enable() argument
407 if (adau1977->enabled) in adau1977_power_enable()
410 ret = regulator_enable(adau1977->avdd_reg); in adau1977_power_enable()
414 if (adau1977->dvdd_reg) { in adau1977_power_enable()
415 ret = regulator_enable(adau1977->dvdd_reg); in adau1977_power_enable()
420 gpiod_set_value_cansleep(adau1977->reset_gpio, 1); in adau1977_power_enable()
422 regcache_cache_only(adau1977->regmap, false); in adau1977_power_enable()
424 if (adau1977->switch_mode) in adau1977_power_enable()
425 adau1977->switch_mode(adau1977->dev); in adau1977_power_enable()
427 ret = adau1977_reset(adau1977); in adau1977_power_enable()
431 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_POWER, in adau1977_power_enable()
436 ret = regcache_sync(adau1977->regmap); in adau1977_power_enable()
447 ret = regmap_read(adau1977->regmap, ADAU1977_REG_PLL, &val); in adau1977_power_enable()
452 regcache_cache_bypass(adau1977->regmap, true); in adau1977_power_enable()
453 ret = regmap_write(adau1977->regmap, ADAU1977_REG_PLL, in adau1977_power_enable()
457 regcache_cache_bypass(adau1977->regmap, false); in adau1977_power_enable()
460 adau1977->enabled = true; in adau1977_power_enable()
465 if (adau1977->dvdd_reg) in adau1977_power_enable()
466 regulator_disable(adau1977->dvdd_reg); in adau1977_power_enable()
468 regulator_disable(adau1977->avdd_reg); in adau1977_power_enable()
475 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); in adau1977_set_bias_level() local
485 ret = adau1977_power_enable(adau1977); in adau1977_set_bias_level()
488 ret = adau1977_power_disable(adau1977); in adau1977_set_bias_level()
498 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); in adau1977_set_tdm_slot() local
506 adau1977->slot_width = 0; in adau1977_set_tdm_slot()
507 adau1977->max_clock_provider_fs = 192000; in adau1977_set_tdm_slot()
508 return regmap_update_bits(adau1977->regmap, in adau1977_set_tdm_slot()
536 if (adau1977->clock_provider) in adau1977_set_tdm_slot()
564 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_SAI_OVERTEMP, in adau1977_set_tdm_slot()
572 ret = regmap_write(adau1977->regmap, ADAU1977_REG_CMAP12, in adau1977_set_tdm_slot()
578 ret = regmap_write(adau1977->regmap, ADAU1977_REG_CMAP34, in adau1977_set_tdm_slot()
584 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_SAI_CTRL0, in adau1977_set_tdm_slot()
589 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_SAI_CTRL1, in adau1977_set_tdm_slot()
594 adau1977->slot_width = width; in adau1977_set_tdm_slot()
597 adau1977->max_clock_provider_fs = min(192000, 24576000 / width / slots); in adau1977_set_tdm_slot()
604 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); in adau1977_mute() local
612 return regmap_update_bits(adau1977->regmap, ADAU1977_REG_MISC_CONTROL, in adau1977_mute()
618 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); in adau1977_set_dai_fmt() local
625 adau1977->clock_provider = false; in adau1977_set_dai_fmt()
629 adau1977->clock_provider = true; in adau1977_set_dai_fmt()
654 adau1977->right_j = false; in adau1977_set_dai_fmt()
665 adau1977->right_j = true; in adau1977_set_dai_fmt()
685 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_BLOCK_POWER_SAI, in adau1977_set_dai_fmt()
691 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_SAI_CTRL0, in adau1977_set_dai_fmt()
697 return regmap_update_bits(adau1977->regmap, ADAU1977_REG_SAI_CTRL1, in adau1977_set_dai_fmt()
705 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); in adau1977_startup() local
708 if (adau1977->slot_width == 16) in adau1977_startup()
710 else if (adau1977->right_j || adau1977->slot_width == 24) in adau1977_startup()
715 SNDRV_PCM_HW_PARAM_RATE, &adau1977->constraints); in adau1977_startup()
717 if (adau1977->clock_provider) in adau1977_startup()
720 adau1977->max_clock_provider_fs); in adau1977_startup()
731 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); in adau1977_set_tristate() local
739 return regmap_update_bits(adau1977->regmap, ADAU1977_REG_SAI_OVERTEMP, in adau1977_set_tristate()
795 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); in adau1977_set_sysclk() local
834 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_PLL, in adau1977_set_sysclk()
839 adau1977->constraints.mask = mask; in adau1977_set_sysclk()
840 adau1977->sysclk_src = source; in adau1977_set_sysclk()
841 adau1977->sysclk = freq; in adau1977_set_sysclk()
849 struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); in adau1977_component_probe() local
852 switch (adau1977->type) { in adau1977_component_probe()
881 static int adau1977_setup_micbias(struct adau1977 *adau1977) in adau1977_setup_micbias() argument
885 if (device_property_read_u32(adau1977->dev, "adi,micbias", &micbias)) in adau1977_setup_micbias()
889 dev_err(adau1977->dev, "Invalid value for 'adi,micbias'\n"); in adau1977_setup_micbias()
893 return regmap_update_bits(adau1977->regmap, ADAU1977_REG_MICBIAS, in adau1977_setup_micbias()
902 struct adau1977 *adau1977; in adau1977_probe() local
908 adau1977 = devm_kzalloc(dev, sizeof(*adau1977), GFP_KERNEL); in adau1977_probe()
909 if (adau1977 == NULL) in adau1977_probe()
912 adau1977->dev = dev; in adau1977_probe()
913 adau1977->type = type; in adau1977_probe()
914 adau1977->regmap = regmap; in adau1977_probe()
915 adau1977->switch_mode = switch_mode; in adau1977_probe()
916 adau1977->max_clock_provider_fs = 192000; in adau1977_probe()
918 adau1977->constraints.list = adau1977_rates; in adau1977_probe()
919 adau1977->constraints.count = ARRAY_SIZE(adau1977_rates); in adau1977_probe()
921 adau1977->avdd_reg = devm_regulator_get(dev, "AVDD"); in adau1977_probe()
922 if (IS_ERR(adau1977->avdd_reg)) in adau1977_probe()
923 return PTR_ERR(adau1977->avdd_reg); in adau1977_probe()
925 adau1977->dvdd_reg = devm_regulator_get_optional(dev, "DVDD"); in adau1977_probe()
926 if (IS_ERR(adau1977->dvdd_reg)) { in adau1977_probe()
927 if (PTR_ERR(adau1977->dvdd_reg) != -ENODEV) in adau1977_probe()
928 return PTR_ERR(adau1977->dvdd_reg); in adau1977_probe()
929 adau1977->dvdd_reg = NULL; in adau1977_probe()
932 adau1977->reset_gpio = devm_gpiod_get_optional(dev, "reset", in adau1977_probe()
934 if (IS_ERR(adau1977->reset_gpio)) in adau1977_probe()
935 return PTR_ERR(adau1977->reset_gpio); in adau1977_probe()
937 dev_set_drvdata(dev, adau1977); in adau1977_probe()
939 if (adau1977->reset_gpio) in adau1977_probe()
942 ret = adau1977_power_enable(adau1977); in adau1977_probe()
947 ret = adau1977_setup_micbias(adau1977); in adau1977_probe()
952 if (adau1977->dvdd_reg) in adau1977_probe()
957 ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_BLOCK_POWER_SAI, in adau1977_probe()
962 ret = adau1977_power_disable(adau1977); in adau1977_probe()
970 adau1977_power_disable(adau1977); in adau1977_probe()