static int tas5086_probe(struct snd_soc_codec *codec) { struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); int i, ret; ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret < 0) { dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); return ret; } priv->pwm_start_mid_z = 0; priv->charge_period = 1300000; /* hardware default is 1300 ms */ if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) { struct device_node *of_node = codec->dev->of_node; of_property_read_u32(of_node, "ti,charge-period", &priv->charge_period); for (i = 0; i < 6; i++) { char name[25]; snprintf(name, sizeof(name), "ti,mid-z-channel-%d", i + 1); if (of_get_property(of_node, name, NULL) != NULL) priv->pwm_start_mid_z |= 1 << i; } } tas5086_reset(priv); ret = tas5086_init(codec->dev, priv); if (ret < 0) goto exit_disable_regulators; /* set master volume to 0 dB */ ret = regmap_write(priv->regmap, TAS5086_MASTER_VOL, 0x30); if (ret < 0) goto exit_disable_regulators; return 0; exit_disable_regulators: regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); return ret; }
static int tas5086_soc_resume(struct snd_soc_codec *codec) { struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); int ret; tas5086_reset(priv); regcache_mark_dirty(priv->regmap); ret = tas5086_init(codec->dev, priv); if (ret < 0) return ret; ret = regcache_sync(priv->regmap); if (ret < 0) return ret; return 0; }
static int tas5086_soc_resume(struct snd_soc_codec *codec) { struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret < 0) return ret; tas5086_reset(priv); regcache_mark_dirty(priv->regmap); ret = tas5086_init(codec->dev, priv); if (ret < 0) return ret; ret = regcache_sync(priv->regmap); if (ret < 0) return ret; return 0; }
static int tas5086_probe(struct snd_soc_codec *codec) { struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); int i, ret; priv->pwm_start_mid_z = 0; priv->charge_period = 1300000; /* hardware default is 1300 ms */ if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) { struct device_node *of_node = codec->dev->of_node; of_property_read_u32(of_node, "ti,charge-period", &priv->charge_period); for (i = 0; i < 6; i++) { char name[25]; snprintf(name, sizeof(name), "ti,mid-z-channel-%d", i + 1); if (of_get_property(of_node, name, NULL) != NULL) priv->pwm_start_mid_z |= 1 << i; } } ret = tas5086_init(codec->dev, priv); if (ret < 0) return ret; /* set master volume to 0 dB */ ret = regmap_write(priv->regmap, TAS5086_MASTER_VOL, 0x30); if (ret < 0) return ret; return 0; }