Lines Matching refs:adau1372

26 struct adau1372 {  struct
575 struct adau1372 *adau1372 = snd_soc_dai_get_drvdata(dai); in adau1372_set_dai_fmt() local
581 adau1372->clock_provider = true; in adau1372_set_dai_fmt()
585 adau1372->clock_provider = false; in adau1372_set_dai_fmt()
629 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI0, ADAU1372_SAI0_DELAY_MASK, sai0); in adau1372_set_dai_fmt()
630 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI1, in adau1372_set_dai_fmt()
640 struct adau1372 *adau1372 = snd_soc_dai_get_drvdata(dai); in adau1372_hw_params() local
656 slot_width = adau1372->slot_width; in adau1372_hw_params()
672 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI0, ADAU1372_SAI0_FS_MASK, sai0); in adau1372_hw_params()
673 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI1, ADAU1372_SAI1_BCLKRATE, sai1); in adau1372_hw_params()
681 struct adau1372 *adau1372 = snd_soc_dai_get_drvdata(dai); in adau1372_set_tdm_slot() local
687 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI0, in adau1372_set_tdm_slot()
689 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM2; in adau1372_set_tdm_slot()
690 adau1372->slot_width = 0; in adau1372_set_tdm_slot()
713 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM2; in adau1372_set_tdm_slot()
717 if (adau1372->clock_provider) in adau1372_set_tdm_slot()
718 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM4_MASTER; in adau1372_set_tdm_slot()
720 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM4; in adau1372_set_tdm_slot()
724 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM8; in adau1372_set_tdm_slot()
730 adau1372->slot_width = width; in adau1372_set_tdm_slot()
732 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI0, ADAU1372_SAI0_SAI_MASK, sai0); in adau1372_set_tdm_slot()
733 regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI1, ADAU1372_SAI1_BCLK_TDMC, sai1); in adau1372_set_tdm_slot()
736 regmap_write(adau1372->regmap, ADAU1372_REG_SOUT_CTRL, ~tx_mask); in adau1372_set_tdm_slot()
743 struct adau1372 *adau1372 = snd_soc_dai_get_drvdata(dai); in adau1372_set_tristate() local
751 return regmap_update_bits(adau1372->regmap, ADAU1372_REG_SAI1, ADAU1372_SAI1_TDM_TS, sai1); in adau1372_set_tristate()
756 struct adau1372 *adau1372 = snd_soc_dai_get_drvdata(dai); in adau1372_startup() local
759 &adau1372->rate_constraints); in adau1372_startup()
764 static void adau1372_enable_pll(struct adau1372 *adau1372) in adau1372_enable_pll() argument
769 regmap_update_bits(adau1372->regmap, ADAU1372_REG_CLK_CTRL, in adau1372_enable_pll()
774 ret = regmap_read(adau1372->regmap, ADAU1372_REG_PLL(5), &val); in adau1372_enable_pll()
781 dev_err(adau1372->dev, "Failed to lock PLL\n"); in adau1372_enable_pll()
784 static void adau1372_set_power(struct adau1372 *adau1372, bool enable) in adau1372_set_power() argument
786 if (adau1372->enabled == enable) in adau1372_set_power()
792 clk_prepare_enable(adau1372->mclk); in adau1372_set_power()
793 if (adau1372->pd_gpio) in adau1372_set_power()
794 gpiod_set_value(adau1372->pd_gpio, 0); in adau1372_set_power()
796 if (adau1372->switch_mode) in adau1372_set_power()
797 adau1372->switch_mode(adau1372->dev); in adau1372_set_power()
799 regcache_cache_only(adau1372->regmap, false); in adau1372_set_power()
805 if (adau1372->use_pll) { in adau1372_set_power()
806 adau1372_enable_pll(adau1372); in adau1372_set_power()
810 regmap_update_bits(adau1372->regmap, ADAU1372_REG_CLK_CTRL, in adau1372_set_power()
812 regcache_sync(adau1372->regmap); in adau1372_set_power()
814 if (adau1372->pd_gpio) { in adau1372_set_power()
820 gpiod_set_value(adau1372->pd_gpio, 1); in adau1372_set_power()
821 regcache_mark_dirty(adau1372->regmap); in adau1372_set_power()
823 regmap_update_bits(adau1372->regmap, ADAU1372_REG_CLK_CTRL, in adau1372_set_power()
826 clk_disable_unprepare(adau1372->mclk); in adau1372_set_power()
827 regcache_cache_only(adau1372->regmap, true); in adau1372_set_power()
830 adau1372->enabled = enable; in adau1372_set_power()
836 struct adau1372 *adau1372 = snd_soc_component_get_drvdata(component); in adau1372_set_bias_level() local
844 adau1372_set_power(adau1372, true); in adau1372_set_bias_level()
847 adau1372_set_power(adau1372, false); in adau1372_set_bias_level()
899 static int adau1372_setup_pll(struct adau1372 *adau1372, unsigned int rate) in adau1372_setup_pll() argument
910 regmap_write(adau1372->regmap, ADAU1372_REG_PLL(i), regs[i]); in adau1372_setup_pll()
918 struct adau1372 *adau1372; in adau1372_probe() local
926 adau1372 = devm_kzalloc(dev, sizeof(*adau1372), GFP_KERNEL); in adau1372_probe()
927 if (!adau1372) in adau1372_probe()
930 adau1372->mclk = devm_clk_get(dev, "mclk"); in adau1372_probe()
931 if (IS_ERR(adau1372->mclk)) in adau1372_probe()
932 return PTR_ERR(adau1372->mclk); in adau1372_probe()
934 adau1372->pd_gpio = devm_gpiod_get_optional(dev, "powerdown", GPIOD_OUT_HIGH); in adau1372_probe()
935 if (IS_ERR(adau1372->pd_gpio)) in adau1372_probe()
936 return PTR_ERR(adau1372->pd_gpio); in adau1372_probe()
938 adau1372->regmap = regmap; in adau1372_probe()
939 adau1372->switch_mode = switch_mode; in adau1372_probe()
940 adau1372->dev = dev; in adau1372_probe()
941 adau1372->rate_constraints.list = adau1372_rates; in adau1372_probe()
942 adau1372->rate_constraints.count = ARRAY_SIZE(adau1372_rates); in adau1372_probe()
943 adau1372->rate_constraints.mask = ADAU1372_RATE_MASK_TDM2; in adau1372_probe()
945 dev_set_drvdata(dev, adau1372); in adau1372_probe()
952 rate = clk_get_rate(adau1372->mclk); in adau1372_probe()
963 ret = adau1372_setup_pll(adau1372, rate); in adau1372_probe()
966 adau1372->use_pll = true; in adau1372_probe()