Lines Matching refs:sta32x
274 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_coefficient_get() local
280 mutex_lock(&sta32x->coeff_lock); in sta32x_coefficient_get()
283 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_coefficient_get()
289 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_coefficient_get()
291 regmap_write(sta32x->regmap, STA32X_CFADDR2, index); in sta32x_coefficient_get()
293 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x04); in sta32x_coefficient_get()
295 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x08); in sta32x_coefficient_get()
302 regmap_read(sta32x->regmap, STA32X_B1CF1 + i, &val); in sta32x_coefficient_get()
307 mutex_unlock(&sta32x->coeff_lock); in sta32x_coefficient_get()
316 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_coefficient_put() local
323 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_coefficient_put()
329 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_coefficient_put()
331 regmap_write(sta32x->regmap, STA32X_CFADDR2, index); in sta32x_coefficient_put()
333 sta32x->coef_shadow[index + i] = in sta32x_coefficient_put()
338 regmap_write(sta32x->regmap, STA32X_B1CF1 + i, in sta32x_coefficient_put()
341 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); in sta32x_coefficient_put()
343 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x02); in sta32x_coefficient_put()
352 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_sync_coef_shadow() local
357 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud); in sta32x_sync_coef_shadow()
361 regmap_write(sta32x->regmap, STA32X_CFADDR2, i); in sta32x_sync_coef_shadow()
362 regmap_write(sta32x->regmap, STA32X_B1CF1, in sta32x_sync_coef_shadow()
363 (sta32x->coef_shadow[i] >> 16) & 0xff); in sta32x_sync_coef_shadow()
364 regmap_write(sta32x->regmap, STA32X_B1CF2, in sta32x_sync_coef_shadow()
365 (sta32x->coef_shadow[i] >> 8) & 0xff); in sta32x_sync_coef_shadow()
366 regmap_write(sta32x->regmap, STA32X_B1CF3, in sta32x_sync_coef_shadow()
367 (sta32x->coef_shadow[i]) & 0xff); in sta32x_sync_coef_shadow()
372 regmap_write(sta32x->regmap, STA32X_CFUD, cfud); in sta32x_sync_coef_shadow()
373 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01); in sta32x_sync_coef_shadow()
380 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_cache_sync() local
385 regmap_read(sta32x->regmap, STA32X_MMUTE, &mute); in sta32x_cache_sync()
386 regmap_write(sta32x->regmap, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE); in sta32x_cache_sync()
388 rc = regcache_sync(sta32x->regmap); in sta32x_cache_sync()
389 regmap_write(sta32x->regmap, STA32X_MMUTE, mute); in sta32x_cache_sync()
396 struct sta32x_priv *sta32x = container_of(work, struct sta32x_priv, in sta32x_watchdog() local
398 struct snd_soc_codec *codec = sta32x->codec; in sta32x_watchdog()
403 regcache_cache_bypass(sta32x->regmap, true); in sta32x_watchdog()
405 regcache_cache_bypass(sta32x->regmap, false); in sta32x_watchdog()
407 regcache_mark_dirty(sta32x->regmap); in sta32x_watchdog()
411 if (!sta32x->shutdown) in sta32x_watchdog()
413 &sta32x->watchdog_work, in sta32x_watchdog()
417 static void sta32x_watchdog_start(struct sta32x_priv *sta32x) in sta32x_watchdog_start() argument
419 if (sta32x->pdata->needs_esd_watchdog) { in sta32x_watchdog_start()
420 sta32x->shutdown = 0; in sta32x_watchdog_start()
422 &sta32x->watchdog_work, in sta32x_watchdog_start()
427 static void sta32x_watchdog_stop(struct sta32x_priv *sta32x) in sta32x_watchdog_stop() argument
429 if (sta32x->pdata->needs_esd_watchdog) { in sta32x_watchdog_stop()
430 sta32x->shutdown = 1; in sta32x_watchdog_stop()
431 cancel_delayed_work_sync(&sta32x->watchdog_work); in sta32x_watchdog_stop()
586 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_set_dai_sysclk() local
589 sta32x->mclk = freq; in sta32x_set_dai_sysclk()
606 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_set_dai_fmt() local
620 sta32x->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in sta32x_set_dai_fmt()
637 return regmap_update_bits(sta32x->regmap, STA32X_CONFB, in sta32x_set_dai_fmt()
655 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_hw_params() local
661 if (!sta32x->mclk) { in sta32x_hw_params()
668 ratio = sta32x->mclk / rate; in sta32x_hw_params()
705 switch (sta32x->format) { in sta32x_hw_params()
720 switch (sta32x->format) { in sta32x_hw_params()
735 switch (sta32x->format) { in sta32x_hw_params()
750 switch (sta32x->format) { in sta32x_hw_params()
767 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFA, in sta32x_hw_params()
773 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFB, in sta32x_hw_params()
782 static int sta32x_startup_sequence(struct sta32x_priv *sta32x) in sta32x_startup_sequence() argument
784 if (sta32x->gpiod_nreset) { in sta32x_startup_sequence()
785 gpiod_set_value(sta32x->gpiod_nreset, 0); in sta32x_startup_sequence()
787 gpiod_set_value(sta32x->gpiod_nreset, 1); in sta32x_startup_sequence()
807 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_set_bias_level() local
816 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
823 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), in sta32x_set_bias_level()
824 sta32x->supplies); in sta32x_set_bias_level()
831 sta32x_startup_sequence(sta32x); in sta32x_set_bias_level()
833 sta32x_watchdog_start(sta32x); in sta32x_set_bias_level()
837 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
845 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_set_bias_level()
848 sta32x_watchdog_stop(sta32x); in sta32x_set_bias_level()
850 if (sta32x->gpiod_nreset) in sta32x_set_bias_level()
851 gpiod_set_value(sta32x->gpiod_nreset, 0); in sta32x_set_bias_level()
853 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), in sta32x_set_bias_level()
854 sta32x->supplies); in sta32x_set_bias_level()
880 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_probe() local
881 struct sta32x_platform_data *pdata = sta32x->pdata; in sta32x_probe()
883 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), in sta32x_probe()
884 sta32x->supplies); in sta32x_probe()
890 ret = sta32x_startup_sequence(sta32x); in sta32x_probe()
903 regmap_update_bits(sta32x->regmap, STA32X_CONFA, in sta32x_probe()
909 regmap_update_bits(sta32x->regmap, STA32X_CONFC, in sta32x_probe()
915 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
919 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
923 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
927 regmap_update_bits(sta32x->regmap, STA32X_CONFE, in sta32x_probe()
933 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_probe()
939 regmap_update_bits(sta32x->regmap, STA32X_CONFF, in sta32x_probe()
945 regmap_update_bits(sta32x->regmap, STA32X_C1CFG, in sta32x_probe()
949 regmap_update_bits(sta32x->regmap, STA32X_C2CFG, in sta32x_probe()
953 regmap_update_bits(sta32x->regmap, STA32X_C3CFG, in sta32x_probe()
960 sta32x->coef_shadow[i] = 0x400000; in sta32x_probe()
962 sta32x->coef_shadow[i] = 0x7fffff; in sta32x_probe()
963 sta32x->coef_shadow[55] = 0x5a9df7; in sta32x_probe()
964 sta32x->coef_shadow[56] = 0x7fffff; in sta32x_probe()
965 sta32x->coef_shadow[59] = 0x7fffff; in sta32x_probe()
966 sta32x->coef_shadow[60] = 0x400000; in sta32x_probe()
967 sta32x->coef_shadow[61] = 0x400000; in sta32x_probe()
969 if (sta32x->pdata->needs_esd_watchdog) in sta32x_probe()
970 INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog); in sta32x_probe()
974 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_probe()
981 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); in sta32x_remove() local
983 sta32x_watchdog_stop(sta32x); in sta32x_remove()
984 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); in sta32x_remove()
1021 static int sta32x_probe_dt(struct device *dev, struct sta32x_priv *sta32x) in sta32x_probe_dt() argument
1068 sta32x->pdata = pdata; in sta32x_probe_dt()
1078 struct sta32x_priv *sta32x; in sta32x_i2c_probe() local
1081 sta32x = devm_kzalloc(&i2c->dev, sizeof(struct sta32x_priv), in sta32x_i2c_probe()
1083 if (!sta32x) in sta32x_i2c_probe()
1086 mutex_init(&sta32x->coeff_lock); in sta32x_i2c_probe()
1087 sta32x->pdata = dev_get_platdata(dev); in sta32x_i2c_probe()
1091 ret = sta32x_probe_dt(dev, sta32x); in sta32x_i2c_probe()
1098 sta32x->gpiod_nreset = devm_gpiod_get_optional(dev, "reset", in sta32x_i2c_probe()
1100 if (IS_ERR(sta32x->gpiod_nreset)) in sta32x_i2c_probe()
1101 return PTR_ERR(sta32x->gpiod_nreset); in sta32x_i2c_probe()
1104 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) in sta32x_i2c_probe()
1105 sta32x->supplies[i].supply = sta32x_supply_names[i]; in sta32x_i2c_probe()
1107 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(sta32x->supplies), in sta32x_i2c_probe()
1108 sta32x->supplies); in sta32x_i2c_probe()
1114 sta32x->regmap = devm_regmap_init_i2c(i2c, &sta32x_regmap); in sta32x_i2c_probe()
1115 if (IS_ERR(sta32x->regmap)) { in sta32x_i2c_probe()
1116 ret = PTR_ERR(sta32x->regmap); in sta32x_i2c_probe()
1121 i2c_set_clientdata(i2c, sta32x); in sta32x_i2c_probe()