Lines Matching defs:sta32x

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