@@ -34,6 +34,7 @@ struct tas2764_priv {
3434 struct snd_soc_component * component ;
3535 struct gpio_desc * reset_gpio ;
3636 struct gpio_desc * sdz_gpio ;
37+ struct regulator * sdz_reg ;
3738 struct regmap * regmap ;
3839 struct device * dev ;
3940 int irq ;
@@ -157,6 +158,8 @@ static int tas2764_codec_suspend(struct snd_soc_component *component)
157158 if (tas2764 -> sdz_gpio )
158159 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 0 );
159160
161+ regulator_disable (tas2764 -> sdz_reg );
162+
160163 regcache_cache_only (tas2764 -> regmap , true);
161164 regcache_mark_dirty (tas2764 -> regmap );
162165
@@ -168,19 +171,26 @@ static int tas2764_codec_resume(struct snd_soc_component *component)
168171 struct tas2764_priv * tas2764 = snd_soc_component_get_drvdata (component );
169172 int ret ;
170173
174+ ret = regulator_enable (tas2764 -> sdz_reg );
175+
176+ if (ret ) {
177+ dev_err (tas2764 -> dev , "Failed to enable regulator\n" );
178+ return ret ;
179+ }
180+
171181 if (tas2764 -> sdz_gpio ) {
172182 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 1 );
173- usleep_range (1000 , 2000 );
174183 }
175184
176- ret = tas2764_update_pwr_ctrl ( tas2764 );
185+ usleep_range ( 1000 , 2000 );
177186
187+ regcache_cache_only (tas2764 -> regmap , false);
188+
189+ ret = regcache_sync (tas2764 -> regmap );
178190 if (ret < 0 )
179191 return ret ;
180192
181- regcache_cache_only (tas2764 -> regmap , false);
182-
183- return regcache_sync (tas2764 -> regmap );
193+ return tas2764_update_pwr_ctrl (tas2764 );
184194}
185195#else
186196#define tas2764_codec_suspend NULL
@@ -213,7 +223,7 @@ static const struct snd_soc_dapm_widget tas2764_dapm_widgets[] = {
213223 SND_SOC_DAPM_DAC ("DAC" , NULL , SND_SOC_NOPM , 0 , 0 ),
214224 SND_SOC_DAPM_OUTPUT ("OUT" ),
215225 SND_SOC_DAPM_SIGGEN ("VMON" ),
216- SND_SOC_DAPM_SIGGEN ("IMON" )
226+ SND_SOC_DAPM_SIGGEN ("IMON" ),
217227};
218228
219229static const struct snd_soc_dapm_route tas2764_audio_map [] = {
@@ -640,11 +650,18 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
640650
641651 tas2764 -> component = component ;
642652
653+ ret = regulator_enable (tas2764 -> sdz_reg );
654+ if (ret != 0 ) {
655+ dev_err (tas2764 -> dev , "Failed to enable regulator: %d\n" , ret );
656+ return ret ;
657+ }
658+
643659 if (tas2764 -> sdz_gpio ) {
644660 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 1 );
645- usleep_range (1000 , 2000 );
646661 }
647662
663+ usleep_range (1000 , 2000 );
664+
648665 tas2764_reset (tas2764 );
649666 regmap_reinit_cache (tas2764 -> regmap , & tas2764_i2c_regmap );
650667
@@ -716,6 +733,9 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
716733
717734static void tas2764_codec_remove (struct snd_soc_component * component )
718735{
736+ struct tas2764_priv * tas2764 = snd_soc_component_get_drvdata (component );
737+
738+ regulator_disable (tas2764 -> sdz_reg );
719739 sysfs_remove_groups (& component -> dev -> kobj , tas2764_sysfs_groups );
720740}
721741
@@ -818,6 +838,11 @@ static int tas2764_parse_dt(struct device *dev, struct tas2764_priv *tas2764)
818838{
819839 int ret = 0 ;
820840
841+ tas2764 -> sdz_reg = devm_regulator_get (dev , "SDZ" );
842+ if (IS_ERR (tas2764 -> sdz_reg ))
843+ return dev_err_probe (dev , PTR_ERR (tas2764 -> sdz_reg ),
844+ "Failed to get SDZ supply\n" );
845+
821846 tas2764 -> reset_gpio = devm_gpiod_get_optional (tas2764 -> dev , "reset" ,
822847 GPIOD_OUT_HIGH );
823848 if (IS_ERR (tas2764 -> reset_gpio )) {
0 commit comments