Lines Matching refs:sta32x

38 #include <sound/sta32x.h>
39 #include "sta32x.h"
268 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
274 mutex_lock(&sta32x->coeff_lock);
277 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud);
283 regmap_write(sta32x->regmap, STA32X_CFUD, cfud);
285 regmap_write(sta32x->regmap, STA32X_CFADDR2, index);
287 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x04);
289 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x08);
296 regmap_read(sta32x->regmap, STA32X_B1CF1 + i, &val);
301 mutex_unlock(&sta32x->coeff_lock);
310 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
317 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud);
323 regmap_write(sta32x->regmap, STA32X_CFUD, cfud);
325 regmap_write(sta32x->regmap, STA32X_CFADDR2, index);
327 sta32x->coef_shadow[index + i] =
332 regmap_write(sta32x->regmap, STA32X_B1CF1 + i,
335 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01);
337 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x02);
346 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
351 regmap_read(sta32x->regmap, STA32X_CFUD, &cfud);
355 regmap_write(sta32x->regmap, STA32X_CFADDR2, i);
356 regmap_write(sta32x->regmap, STA32X_B1CF1,
357 (sta32x->coef_shadow[i] >> 16) & 0xff);
358 regmap_write(sta32x->regmap, STA32X_B1CF2,
359 (sta32x->coef_shadow[i] >> 8) & 0xff);
360 regmap_write(sta32x->regmap, STA32X_B1CF3,
361 (sta32x->coef_shadow[i]) & 0xff);
366 regmap_write(sta32x->regmap, STA32X_CFUD, cfud);
367 regmap_write(sta32x->regmap, STA32X_CFUD, cfud | 0x01);
374 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
379 regmap_read(sta32x->regmap, STA32X_MMUTE, &mute);
380 regmap_write(sta32x->regmap, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE);
382 rc = regcache_sync(sta32x->regmap);
383 regmap_write(sta32x->regmap, STA32X_MMUTE, mute);
387 /* work around ESD issue where sta32x resets and loses all configuration */
390 struct sta32x_priv *sta32x = container_of(work, struct sta32x_priv,
392 struct snd_soc_component *component = sta32x->component;
395 /* check if sta32x has reset itself */
397 regcache_cache_bypass(sta32x->regmap, true);
399 regcache_cache_bypass(sta32x->regmap, false);
401 regcache_mark_dirty(sta32x->regmap);
405 if (!sta32x->shutdown)
407 &sta32x->watchdog_work,
411 static void sta32x_watchdog_start(struct sta32x_priv *sta32x)
413 if (sta32x->pdata->needs_esd_watchdog) {
414 sta32x->shutdown = 0;
416 &sta32x->watchdog_work,
421 static void sta32x_watchdog_stop(struct sta32x_priv *sta32x)
423 if (sta32x->pdata->needs_esd_watchdog) {
424 sta32x->shutdown = 1;
425 cancel_delayed_work_sync(&sta32x->watchdog_work);
580 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
583 sta32x->mclk = freq;
600 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
614 sta32x->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
631 return regmap_update_bits(sta32x->regmap, STA32X_CONFB,
649 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
655 if (!sta32x->mclk) {
657 "sta32x->mclk is unset. Unable to determine ratio\n");
662 ratio = sta32x->mclk / rate;
699 switch (sta32x->format) {
714 switch (sta32x->format) {
729 switch (sta32x->format) {
744 switch (sta32x->format) {
761 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFA,
767 ret = regmap_update_bits(sta32x->regmap, STA32X_CONFB,
776 static int sta32x_startup_sequence(struct sta32x_priv *sta32x)
778 if (sta32x->gpiod_nreset) {
779 gpiod_set_value(sta32x->gpiod_nreset, 0);
781 gpiod_set_value(sta32x->gpiod_nreset, 1);
801 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
810 regmap_update_bits(sta32x->regmap, STA32X_CONFF,
817 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies),
818 sta32x->supplies);
825 sta32x_startup_sequence(sta32x);
827 sta32x_watchdog_start(sta32x);
831 regmap_update_bits(sta32x->regmap, STA32X_CONFF,
839 regmap_update_bits(sta32x->regmap, STA32X_CONFF,
842 sta32x_watchdog_stop(sta32x);
844 gpiod_set_value(sta32x->gpiod_nreset, 0);
846 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies),
847 sta32x->supplies);
860 .name = "sta32x-hifi",
873 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
874 struct sta32x_platform_data *pdata = sta32x->pdata;
877 sta32x->component = component;
879 if (sta32x->xti_clk) {
880 ret = clk_prepare_enable(sta32x->xti_clk);
888 ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies),
889 sta32x->supplies);
895 ret = sta32x_startup_sequence(sta32x);
908 regmap_update_bits(sta32x->regmap, STA32X_CONFA,
914 regmap_update_bits(sta32x->regmap, STA32X_CONFC,
920 regmap_update_bits(sta32x->regmap, STA32X_CONFE,
924 regmap_update_bits(sta32x->regmap, STA32X_CONFE,
928 regmap_update_bits(sta32x->regmap, STA32X_CONFE,
932 regmap_update_bits(sta32x->regmap, STA32X_CONFE,
938 regmap_update_bits(sta32x->regmap, STA32X_CONFF,
944 regmap_update_bits(sta32x->regmap, STA32X_CONFF,
950 regmap_update_bits(sta32x->regmap, STA32X_C1CFG,
954 regmap_update_bits(sta32x->regmap, STA32X_C2CFG,
958 regmap_update_bits(sta32x->regmap, STA32X_C3CFG,
965 sta32x->coef_shadow[i] = 0x400000;
967 sta32x->coef_shadow[i] = 0x7fffff;
968 sta32x->coef_shadow[55] = 0x5a9df7;
969 sta32x->coef_shadow[56] = 0x7fffff;
970 sta32x->coef_shadow[59] = 0x7fffff;
971 sta32x->coef_shadow[60] = 0x400000;
972 sta32x->coef_shadow[61] = 0x400000;
974 if (sta32x->pdata->needs_esd_watchdog)
975 INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog);
979 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
984 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
986 if (sta32x->xti_clk)
987 clk_disable_unprepare(sta32x->xti_clk);
993 struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component);
995 sta32x_watchdog_stop(sta32x);
996 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
998 if (sta32x->xti_clk)
999 clk_disable_unprepare(sta32x->xti_clk);
1032 { .compatible = "st,sta32x", },
1037 static int sta32x_probe_dt(struct device *dev, struct sta32x_priv *sta32x)
1083 sta32x->pdata = pdata;
1092 struct sta32x_priv *sta32x;
1095 sta32x = devm_kzalloc(&i2c->dev, sizeof(struct sta32x_priv),
1097 if (!sta32x)
1100 mutex_init(&sta32x->coeff_lock);
1101 sta32x->pdata = dev_get_platdata(dev);
1105 ret = sta32x_probe_dt(dev, sta32x);
1112 sta32x->xti_clk = devm_clk_get(dev, "xti");
1113 if (IS_ERR(sta32x->xti_clk)) {
1114 ret = PTR_ERR(sta32x->xti_clk);
1119 sta32x->xti_clk = NULL;
1123 sta32x->gpiod_nreset = devm_gpiod_get_optional(dev, "reset",
1125 if (IS_ERR(sta32x->gpiod_nreset))
1126 return PTR_ERR(sta32x->gpiod_nreset);
1129 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++)
1130 sta32x->supplies[i].supply = sta32x_supply_names[i];
1132 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(sta32x->supplies),
1133 sta32x->supplies);
1139 sta32x->regmap = devm_regmap_init_i2c(i2c, &sta32x_regmap);
1140 if (IS_ERR(sta32x->regmap)) {
1141 ret = PTR_ERR(sta32x->regmap);
1146 i2c_set_clientdata(i2c, sta32x);
1166 .name = "sta32x",