@@ -73,23 +73,21 @@ static int tas2770_codec_suspend(struct snd_soc_component *component)
7373 struct tas2770_priv * tas2770 = snd_soc_component_get_drvdata (component );
7474 int ret = 0 ;
7575
76- regcache_cache_only (tas2770 -> regmap , true);
77- regcache_mark_dirty (tas2770 -> regmap );
76+ ret = snd_soc_component_update_bits (component , TAS2770_PWR_CTRL ,
77+ TAS2770_PWR_CTRL_MASK ,
78+ TAS2770_PWR_CTRL_SHUTDOWN );
79+ if (ret < 0 )
80+ return ret ;
7881
79- if (tas2770 -> sdz_gpio ) {
82+ if (tas2770 -> sdz_gpio )
8083 gpiod_set_value_cansleep (tas2770 -> sdz_gpio , 0 );
81- } else {
82- ret = snd_soc_component_update_bits (component , TAS2770_PWR_CTRL ,
83- TAS2770_PWR_CTRL_MASK ,
84- TAS2770_PWR_CTRL_SHUTDOWN );
85- if (ret < 0 ) {
86- regcache_cache_only (tas2770 -> regmap , false);
87- regcache_sync (tas2770 -> regmap );
88- return ret ;
89- }
9084
91- ret = 0 ;
92- }
85+ regulator_disable (tas2770 -> sdz_reg );
86+
87+ regcache_cache_only (tas2770 -> regmap , true);
88+ regcache_mark_dirty (tas2770 -> regmap );
89+
90+ usleep_range (6000 , 7000 );
9391
9492 return ret ;
9593}
@@ -99,18 +97,26 @@ static int tas2770_codec_resume(struct snd_soc_component *component)
9997 struct tas2770_priv * tas2770 = snd_soc_component_get_drvdata (component );
10098 int ret ;
10199
102- if (tas2770 -> sdz_gpio ) {
103- gpiod_set_value_cansleep (tas2770 -> sdz_gpio , 1 );
104- usleep_range (1000 , 2000 );
105- } else {
106- ret = tas2770_update_pwr_ctrl (tas2770 );
107- if (ret < 0 )
108- return ret ;
100+ ret = regulator_enable (tas2770 -> sdz_reg );
101+
102+ if (ret ) {
103+ dev_err (tas2770 -> dev , "Failed to enable regulator\n" );
104+ return ret ;
109105 }
110106
107+ if (tas2770 -> sdz_gpio )
108+ gpiod_set_value_cansleep (tas2770 -> sdz_gpio , 1 );
109+
110+
111+ usleep_range (1000 , 2000 );
112+
111113 regcache_cache_only (tas2770 -> regmap , false);
112114
113- return regcache_sync (tas2770 -> regmap );
115+ ret = regcache_sync (tas2770 -> regmap );
116+ if (ret < 0 )
117+ return ret ;
118+
119+ return tas2770_update_pwr_ctrl (tas2770 );
114120}
115121#else
116122#define tas2770_codec_suspend NULL
@@ -545,6 +551,12 @@ static int tas2770_codec_probe(struct snd_soc_component *component)
545551
546552 tas2770 -> component = component ;
547553
554+ ret = regulator_enable (tas2770 -> sdz_reg );
555+ if (ret != 0 ) {
556+ dev_err (tas2770 -> dev , "Failed to enable regulator: %d\n" , ret );
557+ return ret ;
558+ }
559+
548560 if (tas2770 -> sdz_gpio ) {
549561 gpiod_set_value_cansleep (tas2770 -> sdz_gpio , 1 );
550562 usleep_range (1000 , 2000 );
@@ -569,6 +581,13 @@ static int tas2770_codec_probe(struct snd_soc_component *component)
569581 return 0 ;
570582}
571583
584+ static void tas2770_codec_remove (struct snd_soc_component * component )
585+ {
586+ struct tas2770_priv * tas2770 = snd_soc_component_get_drvdata (component );
587+
588+ regulator_disable (tas2770 -> sdz_reg );
589+ }
590+
572591static DECLARE_TLV_DB_SCALE (tas2770_digital_tlv , 1100 , 50 , 0 ) ;
573592static DECLARE_TLV_DB_SCALE (tas2770_playback_volume , -12750 , 50 , 0 ) ;
574593
@@ -581,6 +600,7 @@ static const struct snd_kcontrol_new tas2770_snd_controls[] = {
581600
582601static const struct snd_soc_component_driver soc_component_driver_tas2770 = {
583602 .probe = tas2770_codec_probe ,
603+ .remove = tas2770_codec_remove ,
584604 .suspend = tas2770_codec_suspend ,
585605 .resume = tas2770_codec_resume ,
586606 .controls = tas2770_snd_controls ,
@@ -705,6 +725,11 @@ static int tas2770_parse_dt(struct device *dev, struct tas2770_priv *tas2770)
705725 tas2770 -> v_sense_slot = -1 ;
706726 }
707727
728+ tas2770 -> sdz_reg = devm_regulator_get (dev , "SDZ" );
729+ if (IS_ERR (tas2770 -> sdz_reg ))
730+ return dev_err_probe (dev , PTR_ERR (tas2770 -> sdz_reg ),
731+ "Failed to get SDZ supply\n" );
732+
708733 tas2770 -> sdz_gpio = devm_gpiod_get_optional (dev , "shutdown" , GPIOD_OUT_HIGH );
709734 if (IS_ERR (tas2770 -> sdz_gpio )) {
710735 if (PTR_ERR (tas2770 -> sdz_gpio ) == - EPROBE_DEFER )
0 commit comments