Lines Matching refs:sta32x
272 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_coefficient_get() local
278 mutex_lock(&sta32x->coeff_lock); in sta32x_coefficient_get()
281 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_coefficient_get()
287 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_coefficient_get()
289 regmap_write(sta32x->regmap, STA32X_CFADDR2, index); in sta32x_coefficient_get()
291 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x04); in sta32x_coefficient_get()
293 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x08); in sta32x_coefficient_get()
300 regmap_read(sta32x->regmap, STA32X_B1CF1 + i, &val); in sta32x_coefficient_get()
305 mutex_unlock(&sta32x->coeff_lock); in sta32x_coefficient_get()
314 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_coefficient_put() local
321 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_coefficient_put()
327 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_coefficient_put()
329 regmap_write(sta32x->regmap, STA32X_CFADDR2, index); in sta32x_coefficient_put()
331 sta32x->coef_shadow[index + i] = in sta32x_coefficient_put()
336 regmap_write(sta32x->regmap, STA32X_B1CF1 + i, in sta32x_coefficient_put()
339 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); in sta32x_coefficient_put()
341 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x02); in sta32x_coefficient_put()
350 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_sync_coef_shadow() local
355 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_sync_coef_shadow()
359 regmap_write(sta32x->regmap, STA32X_CFADDR2, i); in sta32x_sync_coef_shadow()
360 regmap_write(sta32x->regmap, STA32X_B1CF1, in sta32x_sync_coef_shadow()
361 (sta32x->coef_shadow[i] >> 16) & 0xff); in sta32x_sync_coef_shadow()
362 regmap_write(sta32x->regmap, STA32X_B1CF2, in sta32x_sync_coef_shadow()
363 (sta32x->coef_shadow[i] >> 8) & 0xff); in sta32x_sync_coef_shadow()
364 regmap_write(sta32x->regmap, STA32X_B1CF3, in sta32x_sync_coef_shadow()
365 (sta32x->coef_shadow[i]) & 0xff); in sta32x_sync_coef_shadow()
370 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_sync_coef_shadow()
371 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); in sta32x_sync_coef_shadow()
378 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_cache_sync() local
383 regmap_read(sta32x->regmap, STA32X_MMUTE, &mute); in sta32x_cache_sync()
384 regmap_write(sta32x->regmap, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE); in sta32x_cache_sync()
386 rc = regcache_sync(sta32x->regmap); in sta32x_cache_sync()
387 regmap_write(sta32x->regmap, STA32X_MMUTE, mute); in sta32x_cache_sync()
394 struct sta32x_priv *sta32x = container_of(work, struct sta32x_priv, in sta32x_watchdog() local
396 struct snd_soc_component *component = sta32x->component; in sta32x_watchdog()
401 regcache_cache_bypass(sta32x->regmap, true); in sta32x_watchdog()
403 regcache_cache_bypass(sta32x->regmap, false); in sta32x_watchdog()
405 regcache_mark_dirty(sta32x->regmap); in sta32x_watchdog()
409 if (!sta32x->shutdown) in sta32x_watchdog()
411 &sta32x->watchdog_work, in sta32x_watchdog()
415 static void sta32x_watchdog_start(struct sta32x_priv *sta32x) in sta32x_watchdog_start() argument
417 if (sta32x->pdata->needs_esd_watchdog) { in sta32x_watchdog_start()
418 sta32x->shutdown = 0; in sta32x_watchdog_start()
420 &sta32x->watchdog_work, in sta32x_watchdog_start()
425 static void sta32x_watchdog_stop(struct sta32x_priv *sta32x) in sta32x_watchdog_stop() argument
427 if (sta32x->pdata->needs_esd_watchdog) { in sta32x_watchdog_stop()
428 sta32x->shutdown = 1; in sta32x_watchdog_stop()
429 cancel_delayed_work_sync(&sta32x->watchdog_work); in sta32x_watchdog_stop()
584 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_set_dai_sysclk() local
587 sta32x->mclk = freq; in sta32x_set_dai_sysclk()
604 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_set_dai_fmt() local
618 sta32x->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in sta32x_set_dai_fmt()
635 return regmap_update_bits(sta32x->regmap, STA32X_CONFB, in sta32x_set_dai_fmt()
653 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_hw_params() local
659 if (!sta32x->mclk) { in sta32x_hw_params()
666 ratio = sta32x->mclk / rate; in sta32x_hw_params()
703 switch (sta32x->format) { in sta32x_hw_params()
718 switch (sta32x->format) { in sta32x_hw_params()
733 switch (sta32x->format) { in sta32x_hw_params()
748 switch (sta32x->format) { in sta32x_hw_params()
765 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFA, in sta32x_hw_params()
771 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFB, in sta32x_hw_params()
780 static int sta32x_startup_sequence(struct sta32x_priv *sta32x) in sta32x_startup_sequence() argument
782 if (sta32x->gpiod_nreset) { in sta32x_startup_sequence()
783 gpiod_set_value(sta32x->gpiod_nreset, 0); in sta32x_startup_sequence()
785 gpiod_set_value(sta32x->gpiod_nreset, 1); in sta32x_startup_sequence()
805 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_set_bias_level() local
814 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
821 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), in sta32x_set_bias_level()
822 sta32x->supplies); in sta32x_set_bias_level()
829 sta32x_startup_sequence(sta32x); in sta32x_set_bias_level()
831 sta32x_watchdog_start(sta32x); in sta32x_set_bias_level()
835 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
843 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
846 sta32x_watchdog_stop(sta32x); in sta32x_set_bias_level()
848 gpiod_set_value(sta32x->gpiod_nreset, 0); in sta32x_set_bias_level()
850 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), in sta32x_set_bias_level()
851 sta32x->supplies); in sta32x_set_bias_level()
877 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_probe() local
878 struct sta32x_platform_data *pdata = sta32x->pdata; in sta32x_probe()
881 sta32x->component = component; in sta32x_probe()
883 if (sta32x->xti_clk) { in sta32x_probe()
884 ret = clk_prepare_enable(sta32x->xti_clk); in sta32x_probe()
892 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), in sta32x_probe()
893 sta32x->supplies); in sta32x_probe()
899 ret = sta32x_startup_sequence(sta32x); in sta32x_probe()
912 regmap_update_bits(sta32x->regmap, STA32X_CONFA, in sta32x_probe()
918 regmap_update_bits(sta32x->regmap, STA32X_CONFC, in sta32x_probe()
924 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
928 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
932 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
936 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
942 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_probe()
948 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_probe()
954 regmap_update_bits(sta32x->regmap, STA32X_C1CFG, in sta32x_probe()
958 regmap_update_bits(sta32x->regmap, STA32X_C2CFG, in sta32x_probe()
962 regmap_update_bits(sta32x->regmap, STA32X_C3CFG, in sta32x_probe()
969 sta32x->coef_shadow[i] = 0x400000; in sta32x_probe()
971 sta32x->coef_shadow[i] = 0x7fffff; in sta32x_probe()
972 sta32x->coef_shadow[55] = 0x5a9df7; in sta32x_probe()
973 sta32x->coef_shadow[56] = 0x7fffff; in sta32x_probe()
974 sta32x->coef_shadow[59] = 0x7fffff; in sta32x_probe()
975 sta32x->coef_shadow[60] = 0x400000; in sta32x_probe()
976 sta32x->coef_shadow[61] = 0x400000; in sta32x_probe()
978 if (sta32x->pdata->needs_esd_watchdog) in sta32x_probe()
979 INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog); in sta32x_probe()
983 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_probe()
988 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_probe()
990 if (sta32x->xti_clk) in sta32x_probe()
991 clk_disable_unprepare(sta32x->xti_clk); in sta32x_probe()
997 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_remove() local
999 sta32x_watchdog_stop(sta32x); in sta32x_remove()
1000 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_remove()
1002 if (sta32x->xti_clk) in sta32x_remove()
1003 clk_disable_unprepare(sta32x->xti_clk); in sta32x_remove()
1042 static int sta32x_probe_dt(struct device *dev, struct sta32x_priv *sta32x) in sta32x_probe_dt() argument
1091 sta32x->pdata = pdata; in sta32x_probe_dt()
1101 struct sta32x_priv *sta32x; in sta32x_i2c_probe() local
1104 sta32x = devm_kzalloc(&i2c->dev, sizeof(struct sta32x_priv), in sta32x_i2c_probe()
1106 if (!sta32x) in sta32x_i2c_probe()
1109 mutex_init(&sta32x->coeff_lock); in sta32x_i2c_probe()
1110 sta32x->pdata = dev_get_platdata(dev); in sta32x_i2c_probe()
1114 ret = sta32x_probe_dt(dev, sta32x); in sta32x_i2c_probe()
1121 sta32x->xti_clk = devm_clk_get(dev, "xti"); in sta32x_i2c_probe()
1122 if (IS_ERR(sta32x->xti_clk)) { in sta32x_i2c_probe()
1123 ret = PTR_ERR(sta32x->xti_clk); in sta32x_i2c_probe()
1128 sta32x->xti_clk = NULL; in sta32x_i2c_probe()
1132 sta32x->gpiod_nreset = devm_gpiod_get_optional(dev, "reset", in sta32x_i2c_probe()
1134 if (IS_ERR(sta32x->gpiod_nreset)) in sta32x_i2c_probe()
1135 return PTR_ERR(sta32x->gpiod_nreset); in sta32x_i2c_probe()
1138 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) in sta32x_i2c_probe()
1139 sta32x->supplies[i].supply = sta32x_supply_names[i]; in sta32x_i2c_probe()
1141 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(sta32x->supplies), in sta32x_i2c_probe()
1142 sta32x->supplies); in sta32x_i2c_probe()
1148 sta32x->regmap = devm_regmap_init_i2c(i2c, &sta32x_regmap); in sta32x_i2c_probe()
1149 if (IS_ERR(sta32x->regmap)) { in sta32x_i2c_probe()
1150 ret = PTR_ERR(sta32x->regmap); in sta32x_i2c_probe()
1155 i2c_set_clientdata(i2c, sta32x); in sta32x_i2c_probe()