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