@@ -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 [] = {
@@ -632,11 +642,18 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
632642
633643 tas2764 -> component = component ;
634644
645+ ret = regulator_enable (tas2764 -> sdz_reg );
646+ if (ret != 0 ) {
647+ dev_err (tas2764 -> dev , "Failed to enable regulator: %d\n" , ret );
648+ return ret ;
649+ }
650+
635651 if (tas2764 -> sdz_gpio ) {
636652 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 1 );
637- usleep_range (1000 , 2000 );
638653 }
639654
655+ usleep_range (1000 , 2000 );
656+
640657 tas2764_reset (tas2764 );
641658 regmap_reinit_cache (tas2764 -> regmap , & tas2764_i2c_regmap );
642659
@@ -708,6 +725,9 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
708725
709726static void tas2764_codec_remove (struct snd_soc_component * component )
710727{
728+ struct tas2764_priv * tas2764 = snd_soc_component_get_drvdata (component );
729+
730+ regulator_disable (tas2764 -> sdz_reg );
711731 sysfs_remove_groups (& component -> dev -> kobj , tas2764_sysfs_groups );
712732}
713733
@@ -810,6 +830,11 @@ static int tas2764_parse_dt(struct device *dev, struct tas2764_priv *tas2764)
810830{
811831 int ret = 0 ;
812832
833+ tas2764 -> sdz_reg = devm_regulator_get (dev , "SDZ" );
834+ if (IS_ERR (tas2764 -> sdz_reg ))
835+ return dev_err_probe (dev , PTR_ERR (tas2764 -> sdz_reg ),
836+ "Failed to get SDZ supply\n" );
837+
813838 tas2764 -> reset_gpio = devm_gpiod_get_optional (tas2764 -> dev , "reset" ,
814839 GPIOD_OUT_HIGH );
815840 if (IS_ERR (tas2764 -> reset_gpio )) {
0 commit comments