Lines Matching refs:sta32x

269 	struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);  in sta32x_coefficient_get()  local
275 mutex_lock(&sta32x->coeff_lock); in sta32x_coefficient_get()
278 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_coefficient_get()
284 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_coefficient_get()
286 regmap_write(sta32x->regmap, STA32X_CFADDR2, index); in sta32x_coefficient_get()
288 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x04); in sta32x_coefficient_get()
290 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x08); in sta32x_coefficient_get()
297 regmap_read(sta32x->regmap, STA32X_B1CF1 + i, &val); in sta32x_coefficient_get()
302 mutex_unlock(&sta32x->coeff_lock); in sta32x_coefficient_get()
311 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_coefficient_put() local
318 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_coefficient_put()
324 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_coefficient_put()
326 regmap_write(sta32x->regmap, STA32X_CFADDR2, index); in sta32x_coefficient_put()
328 sta32x->coef_shadow[index + i] = in sta32x_coefficient_put()
333 regmap_write(sta32x->regmap, STA32X_B1CF1 + i, in sta32x_coefficient_put()
336 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); in sta32x_coefficient_put()
338 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x02); in sta32x_coefficient_put()
347 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_sync_coef_shadow() local
352 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_sync_coef_shadow()
356 regmap_write(sta32x->regmap, STA32X_CFADDR2, i); in sta32x_sync_coef_shadow()
357 regmap_write(sta32x->regmap, STA32X_B1CF1, in sta32x_sync_coef_shadow()
358 (sta32x->coef_shadow[i] >> 16) & 0xff); in sta32x_sync_coef_shadow()
359 regmap_write(sta32x->regmap, STA32X_B1CF2, in sta32x_sync_coef_shadow()
360 (sta32x->coef_shadow[i] >> 8) & 0xff); in sta32x_sync_coef_shadow()
361 regmap_write(sta32x->regmap, STA32X_B1CF3, in sta32x_sync_coef_shadow()
362 (sta32x->coef_shadow[i]) & 0xff); in sta32x_sync_coef_shadow()
367 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_sync_coef_shadow()
368 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); in sta32x_sync_coef_shadow()
375 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_cache_sync() local
380 regmap_read(sta32x->regmap, STA32X_MMUTE, &mute); in sta32x_cache_sync()
381 regmap_write(sta32x->regmap, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE); in sta32x_cache_sync()
383 rc = regcache_sync(sta32x->regmap); in sta32x_cache_sync()
384 regmap_write(sta32x->regmap, STA32X_MMUTE, mute); in sta32x_cache_sync()
391 struct sta32x_priv *sta32x = container_of(work, struct sta32x_priv, in sta32x_watchdog() local
393 struct snd_soc_component *component = sta32x->component; in sta32x_watchdog()
398 regcache_cache_bypass(sta32x->regmap, true); in sta32x_watchdog()
400 regcache_cache_bypass(sta32x->regmap, false); in sta32x_watchdog()
402 regcache_mark_dirty(sta32x->regmap); in sta32x_watchdog()
406 if (!sta32x->shutdown) in sta32x_watchdog()
408 &sta32x->watchdog_work, in sta32x_watchdog()
412 static void sta32x_watchdog_start(struct sta32x_priv *sta32x) in sta32x_watchdog_start() argument
414 if (sta32x->pdata->needs_esd_watchdog) { in sta32x_watchdog_start()
415 sta32x->shutdown = 0; in sta32x_watchdog_start()
417 &sta32x->watchdog_work, in sta32x_watchdog_start()
422 static void sta32x_watchdog_stop(struct sta32x_priv *sta32x) in sta32x_watchdog_stop() argument
424 if (sta32x->pdata->needs_esd_watchdog) { in sta32x_watchdog_stop()
425 sta32x->shutdown = 1; in sta32x_watchdog_stop()
426 cancel_delayed_work_sync(&sta32x->watchdog_work); in sta32x_watchdog_stop()
581 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_set_dai_sysclk() local
584 sta32x->mclk = freq; in sta32x_set_dai_sysclk()
601 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_set_dai_fmt() local
615 sta32x->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in sta32x_set_dai_fmt()
632 return regmap_update_bits(sta32x->regmap, STA32X_CONFB, in sta32x_set_dai_fmt()
650 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_hw_params() local
656 if (!sta32x->mclk) { in sta32x_hw_params()
663 ratio = sta32x->mclk / rate; in sta32x_hw_params()
700 switch (sta32x->format) { in sta32x_hw_params()
715 switch (sta32x->format) { in sta32x_hw_params()
730 switch (sta32x->format) { in sta32x_hw_params()
745 switch (sta32x->format) { in sta32x_hw_params()
762 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFA, in sta32x_hw_params()
768 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFB, in sta32x_hw_params()
777 static int sta32x_startup_sequence(struct sta32x_priv *sta32x) in sta32x_startup_sequence() argument
779 if (sta32x->gpiod_nreset) { in sta32x_startup_sequence()
780 gpiod_set_value(sta32x->gpiod_nreset, 0); in sta32x_startup_sequence()
782 gpiod_set_value(sta32x->gpiod_nreset, 1); in sta32x_startup_sequence()
802 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_set_bias_level() local
811 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
818 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), in sta32x_set_bias_level()
819 sta32x->supplies); in sta32x_set_bias_level()
826 sta32x_startup_sequence(sta32x); in sta32x_set_bias_level()
828 sta32x_watchdog_start(sta32x); in sta32x_set_bias_level()
832 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
840 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
843 sta32x_watchdog_stop(sta32x); in sta32x_set_bias_level()
845 gpiod_set_value(sta32x->gpiod_nreset, 0); in sta32x_set_bias_level()
847 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), in sta32x_set_bias_level()
848 sta32x->supplies); in sta32x_set_bias_level()
874 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_probe() local
875 struct sta32x_platform_data *pdata = sta32x->pdata; in sta32x_probe()
878 sta32x->component = component; in sta32x_probe()
880 if (sta32x->xti_clk) { in sta32x_probe()
881 ret = clk_prepare_enable(sta32x->xti_clk); in sta32x_probe()
889 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), in sta32x_probe()
890 sta32x->supplies); in sta32x_probe()
896 ret = sta32x_startup_sequence(sta32x); in sta32x_probe()
909 regmap_update_bits(sta32x->regmap, STA32X_CONFA, in sta32x_probe()
915 regmap_update_bits(sta32x->regmap, STA32X_CONFC, in sta32x_probe()
921 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
925 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
929 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
933 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
939 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_probe()
945 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_probe()
951 regmap_update_bits(sta32x->regmap, STA32X_C1CFG, in sta32x_probe()
955 regmap_update_bits(sta32x->regmap, STA32X_C2CFG, in sta32x_probe()
959 regmap_update_bits(sta32x->regmap, STA32X_C3CFG, in sta32x_probe()
966 sta32x->coef_shadow[i] = 0x400000; in sta32x_probe()
968 sta32x->coef_shadow[i] = 0x7fffff; in sta32x_probe()
969 sta32x->coef_shadow[55] = 0x5a9df7; in sta32x_probe()
970 sta32x->coef_shadow[56] = 0x7fffff; in sta32x_probe()
971 sta32x->coef_shadow[59] = 0x7fffff; in sta32x_probe()
972 sta32x->coef_shadow[60] = 0x400000; in sta32x_probe()
973 sta32x->coef_shadow[61] = 0x400000; in sta32x_probe()
975 if (sta32x->pdata->needs_esd_watchdog) in sta32x_probe()
976 INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog); in sta32x_probe()
980 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_probe()
985 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_probe()
987 if (sta32x->xti_clk) in sta32x_probe()
988 clk_disable_unprepare(sta32x->xti_clk); in sta32x_probe()
994 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); in sta32x_remove() local
996 sta32x_watchdog_stop(sta32x); in sta32x_remove()
997 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_remove()
999 if (sta32x->xti_clk) in sta32x_remove()
1000 clk_disable_unprepare(sta32x->xti_clk); in sta32x_remove()
1038 static int sta32x_probe_dt(struct device *dev, struct sta32x_priv *sta32x) in sta32x_probe_dt() argument
1084 sta32x->pdata = pdata; in sta32x_probe_dt()
1093 struct sta32x_priv *sta32x; in sta32x_i2c_probe() local
1096 sta32x = devm_kzalloc(&i2c->dev, sizeof(struct sta32x_priv), in sta32x_i2c_probe()
1098 if (!sta32x) in sta32x_i2c_probe()
1101 mutex_init(&sta32x->coeff_lock); in sta32x_i2c_probe()
1102 sta32x->pdata = dev_get_platdata(dev); in sta32x_i2c_probe()
1106 ret = sta32x_probe_dt(dev, sta32x); in sta32x_i2c_probe()
1113 sta32x->xti_clk = devm_clk_get(dev, "xti"); in sta32x_i2c_probe()
1114 if (IS_ERR(sta32x->xti_clk)) { in sta32x_i2c_probe()
1115 ret = PTR_ERR(sta32x->xti_clk); in sta32x_i2c_probe()
1120 sta32x->xti_clk = NULL; in sta32x_i2c_probe()
1124 sta32x->gpiod_nreset = devm_gpiod_get_optional(dev, "reset", in sta32x_i2c_probe()
1126 if (IS_ERR(sta32x->gpiod_nreset)) in sta32x_i2c_probe()
1127 return PTR_ERR(sta32x->gpiod_nreset); in sta32x_i2c_probe()
1130 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) in sta32x_i2c_probe()
1131 sta32x->supplies[i].supply = sta32x_supply_names[i]; in sta32x_i2c_probe()
1133 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(sta32x->supplies), in sta32x_i2c_probe()
1134 sta32x->supplies); in sta32x_i2c_probe()
1140 sta32x->regmap = devm_regmap_init_i2c(i2c, &sta32x_regmap); in sta32x_i2c_probe()
1141 if (IS_ERR(sta32x->regmap)) { in sta32x_i2c_probe()
1142 ret = PTR_ERR(sta32x->regmap); in sta32x_i2c_probe()
1147 i2c_set_clientdata(i2c, sta32x); in sta32x_i2c_probe()