@@ -35,6 +35,7 @@ struct tas2764_priv {
3535 struct snd_soc_component * component ;
3636 struct gpio_desc * reset_gpio ;
3737 struct gpio_desc * sdz_gpio ;
38+ struct regulator * sdz_reg ;
3839 struct regmap * regmap ;
3940 struct device * dev ;
4041 int irq ;
@@ -158,6 +159,8 @@ static int tas2764_codec_suspend(struct snd_soc_component *component)
158159 if (tas2764 -> sdz_gpio )
159160 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 0 );
160161
162+ regulator_disable (tas2764 -> sdz_reg );
163+
161164 regcache_cache_only (tas2764 -> regmap , true);
162165 regcache_mark_dirty (tas2764 -> regmap );
163166
@@ -169,19 +172,26 @@ static int tas2764_codec_resume(struct snd_soc_component *component)
169172 struct tas2764_priv * tas2764 = snd_soc_component_get_drvdata (component );
170173 int ret ;
171174
175+ ret = regulator_enable (tas2764 -> sdz_reg );
176+
177+ if (ret ) {
178+ dev_err (tas2764 -> dev , "Failed to enable regulator\n" );
179+ return ret ;
180+ }
181+
172182 if (tas2764 -> sdz_gpio ) {
173183 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 1 );
174- usleep_range (1000 , 2000 );
175184 }
176185
177- ret = tas2764_update_pwr_ctrl ( tas2764 );
186+ usleep_range ( 1000 , 2000 );
178187
188+ regcache_cache_only (tas2764 -> regmap , false);
189+
190+ ret = regcache_sync (tas2764 -> regmap );
179191 if (ret < 0 )
180192 return ret ;
181193
182- regcache_cache_only (tas2764 -> regmap , false);
183-
184- return regcache_sync (tas2764 -> regmap );
194+ return tas2764_update_pwr_ctrl (tas2764 );
185195}
186196#else
187197#define tas2764_codec_suspend NULL
@@ -214,7 +224,7 @@ static const struct snd_soc_dapm_widget tas2764_dapm_widgets[] = {
214224 SND_SOC_DAPM_DAC ("DAC" , NULL , SND_SOC_NOPM , 0 , 0 ),
215225 SND_SOC_DAPM_OUTPUT ("OUT" ),
216226 SND_SOC_DAPM_SIGGEN ("VMON" ),
217- SND_SOC_DAPM_SIGGEN ("IMON" )
227+ SND_SOC_DAPM_SIGGEN ("IMON" ),
218228};
219229
220230static const struct snd_soc_dapm_route tas2764_audio_map [] = {
@@ -633,11 +643,18 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
633643
634644 tas2764 -> component = component ;
635645
646+ ret = regulator_enable (tas2764 -> sdz_reg );
647+ if (ret != 0 ) {
648+ dev_err (tas2764 -> dev , "Failed to enable regulator: %d\n" , ret );
649+ return ret ;
650+ }
651+
636652 if (tas2764 -> sdz_gpio ) {
637653 gpiod_set_value_cansleep (tas2764 -> sdz_gpio , 1 );
638- usleep_range (1000 , 2000 );
639654 }
640655
656+ usleep_range (1000 , 2000 );
657+
641658 tas2764_reset (tas2764 );
642659 regmap_reinit_cache (tas2764 -> regmap , & tas2764_i2c_regmap );
643660
@@ -709,6 +726,9 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
709726
710727static void tas2764_codec_remove (struct snd_soc_component * component )
711728{
729+ struct tas2764_priv * tas2764 = snd_soc_component_get_drvdata (component );
730+
731+ regulator_disable (tas2764 -> sdz_reg );
712732 sysfs_remove_groups (& component -> dev -> kobj , tas2764_sysfs_groups );
713733}
714734
@@ -811,6 +831,11 @@ static int tas2764_parse_dt(struct device *dev, struct tas2764_priv *tas2764)
811831{
812832 int ret = 0 ;
813833
834+ tas2764 -> sdz_reg = devm_regulator_get (dev , "SDZ" );
835+ if (IS_ERR (tas2764 -> sdz_reg ))
836+ return dev_err_probe (dev , PTR_ERR (tas2764 -> sdz_reg ),
837+ "Failed to get SDZ supply\n" );
838+
814839 tas2764 -> reset_gpio = devm_gpiod_get_optional (tas2764 -> dev , "reset" ,
815840 GPIOD_OUT_HIGH );
816841 if (IS_ERR (tas2764 -> reset_gpio )) {
0 commit comments