diff mbox series

[v5,4/4] update tas27xx.c to support either TAS2764 or TAS2780

Message ID 20220330144526.498-4-13691752556@139.com (mailing list archive)
State Superseded
Headers show
Series [v5,1/4] rename tas2764 to tas27xx | expand

Commit Message

Raphael-Xu March 30, 2022, 2:45 p.m. UTC
Signed-off-by: Raphael-Xu <13691752556@139.com>
---
 sound/soc/codecs/tas27xx.c | 378 ++++++++++++++++++++++++++-----------
 1 file changed, 263 insertions(+), 115 deletions(-)

Comments

Amadeusz Sławiński March 30, 2022, 5:25 p.m. UTC | #1
On 3/30/2022 4:45 PM, Raphael-Xu wrote:

Missing commit message in this patch and previous one. Even one sentence 
explaining what you are doing and why is better then nothing.

Overall the series looks a lot better now, I still wonder if changing 
coding style makes sense, but ultimately it's your code, so as long as 
it patches checkpatch I will leave decision to Mark.

And there are few nitpicks, below in this patch.

> Signed-off-by: Raphael-Xu <13691752556@139.com>
> ---
>   sound/soc/codecs/tas27xx.c | 378 ++++++++++++++++++++++++++-----------
>   1 file changed, 263 insertions(+), 115 deletions(-)
> 
> diff --git a/sound/soc/codecs/tas27xx.c b/sound/soc/codecs/tas27xx.c
> index 8118429bb2f5..bb845d4797ce 100644
> --- a/sound/soc/codecs/tas27xx.c
> +++ b/sound/soc/codecs/tas27xx.c

...

> @@ -146,8 +182,9 @@ static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
>   		snd_soc_dapm_to_component(w->dapm);
>   	struct tas27xx_priv *tas27xx =
>   		snd_soc_component_get_drvdata(component);
> -	int ret;
> +	int ret = 0;
>   
> +	mutex_lock(&tas27xx->codec_lock);
>   	switch (event) {
>   	case SND_SOC_DAPM_POST_PMU:
>   		ret = snd_soc_component_update_bits(component,
> @@ -163,13 +200,16 @@ static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
>   		break;
>   	default:
>   		dev_err(tas27xx->dev, "Unsupported event\n");
> -		return -EINVAL;
> +			ret = -EINVAL;

There seems to be one tab to many here.

>   	}
> -
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> +	if (ret < 0) {
> +		pr_err("%s:%u:errCode:0x%0x:PWR_CTRL error\n",
> +			__func__, __LINE__, ret);
> +	} else {
> +		ret = 0;
> +	}
> +	mutex_unlock(&tas27xx->codec_lock);
> +	return ret;
>   }
>   
>   static const struct snd_kcontrol_new isense_switch =
> @@ -207,55 +247,96 @@ static const struct snd_soc_dapm_route tas27xx_audio_map[] = {
>   static int tas27xx_mute(struct snd_soc_dai *dai, int mute, int direction)
>   {
>   	struct snd_soc_component *component = dai->component;
> -	int ret;
> +	struct tas27xx_priv *tas27xx =
> +		snd_soc_component_get_drvdata(component);
> +	int ret = 0;
> +	
> +	mutex_lock(&tas27xx->codec_lock);
>   
> +	if (mute == 0) {

alternatively if (!mute), but you can leave as is

> +		ret = snd_soc_component_update_bits(component,
> +			TAS27XX_CLK_CFG,
> +			TAS27XX_CLK_CFG_MASK,
> +			TAS27XX_CLK_CFG_ENABLE);
> +		if (ret < 0) {
> +			dev_err(tas27xx->dev,
> +				"%s:%u: Failed to CLK_CFG_ENABLE\n",
> +				__func__, __LINE__);
> +			goto EXIT;
> +		}
> +		usleep_range(2000, 2000);
> +	}
>   	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
> -					    TAS27XX_PWR_CTRL_MASK,
> -					    mute ? TAS27XX_PWR_CTRL_MUTE : 0);
> -
> -	if (ret < 0)
> -		return ret;
> +		TAS27XX_PWR_CTRL_MASK,
> +		mute ? TAS27XX_PWR_CTRL_MUTE : 0);
> +	if (ret >= 0) {
> +		tas27xx->mb_power_up = mute?false:true;
> +		ret = 0;
> +	}
>   
> -	return 0;
> +	if (ret < 0) {

You could probably just use } else { here with above if.

> +		pr_err("%s:%u: Failed to set powercontrol\n",
> +			__func__, __LINE__);
> +	}
> +EXIT:
> +	mutex_unlock(&tas27xx->codec_lock);
> +	return ret;
>   }
>   

...

>   
>   static const struct snd_soc_dai_ops tas27xx_dai_ops = {
> @@ -495,13 +615,13 @@ static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
>   		},
>   		.capture = {
>   			.stream_name    = "ASI1 Capture",
> -			.channels_min   = 0,
> +			.channels_min   = 1,
>   			.channels_max   = 2,
>   			.rates = TAS27XX_RATES,
>   			.formats = TAS27XX_FORMATS,
>   		},
>   		.ops = &tas27xx_dai_ops,
> -		.symmetric_rate = 1,
> +		.symmetric_rates = 1,

I'm pretty sure struct snd_soc_dai_driver uses .symmetric_rate, so this 
change would result in build failure?

>   	},
>   };
>   
> @@ -509,7 +629,7 @@ static int tas27xx_codec_probe(struct snd_soc_component *component)
>   {
>   	struct tas27xx_priv *tas27xx =
>   		snd_soc_component_get_drvdata(component);
> -	int ret;
> +	int ret = 0;
>   
>   	tas27xx->component = component;
>   

...

>   
>   static DECLARE_TLV_DB_SCALE(tas27xx_digital_tlv, 1100, 50, 0);
> @@ -551,8 +685,10 @@ static const struct snd_kcontrol_new tas27xx_snd_controls[] = {
>   
>   static const struct snd_soc_component_driver soc_component_driver_tas27xx = {
>   	.probe			= tas27xx_codec_probe,
> +#ifdef CONFIG_PM
>   	.suspend		= tas27xx_codec_suspend,
>   	.resume			= tas27xx_codec_resume,
> +#endif
>   	.set_bias_level		= tas27xx_set_bias_level,
>   	.controls		= tas27xx_snd_controls,
>   	.num_controls		= ARRAY_SIZE(tas27xx_snd_controls),
> @@ -590,6 +726,12 @@ static const struct regmap_range_cfg tas27xx_regmap_ranges[] = {
>   	},
>   };
>   
> +static bool tas27xx_volatile(struct device *dev,
> +	unsigned int reg)
> +{
> +		return true;
> +}
> +

This seems bit weird, are all registers considered volatile?

>   static const struct regmap_config tas27xx_i2c_regmap = {
>   	.reg_bits = 8,
>   	.val_bits = 8,
> @@ -599,6 +741,7 @@ static const struct regmap_config tas27xx_i2c_regmap = {
>   	.ranges = tas27xx_regmap_ranges,
>   	.num_ranges = ARRAY_SIZE(tas27xx_regmap_ranges),
>   	.max_register = 1 * 128,
> +	.volatile_reg = tas27xx_volatile,
>   };
>   
>   static int tas27xx_parse_dt(struct device *dev, struct tas27xx_priv *tas27xx)

...
kernel test robot March 30, 2022, 5:35 p.m. UTC | #2
Hi Raphael-Xu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on v5.17 next-20220330]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220331/202203310140.Sc6ERGdm-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5e87128eec39d187eaf11069178b39d935600c2e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
        git checkout 5e87128eec39d187eaf11069178b39d935600c2e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   sound/soc/codecs/tas27xx.c:624:18: error: 'struct snd_soc_dai_driver' has no member named 'symmetric_rates'; did you mean 'symmetric_rate'?
     624 |                 .symmetric_rates = 1,
         |                  ^~~~~~~~~~~~~~~
         |                  symmetric_rate
>> sound/soc/codecs/tas27xx.c:624:36: warning: initialization of 'const struct snd_soc_cdai_ops *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     624 |                 .symmetric_rates = 1,
         |                                    ^
   sound/soc/codecs/tas27xx.c:624:36: note: (near initialization for 'tas27xx_dai_driver[0].cops')


vim +624 sound/soc/codecs/tas27xx.c

   598	
   599	#define TAS27XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
   600				 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
   601	
   602	#define TAS27XX_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
   603			       SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200)
   604	
   605	static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
   606		{
   607			.name = "tas27xx ASI1",
   608			.id = 0,
   609			.playback = {
   610				.stream_name    = "ASI1 Playback",
   611				.channels_min   = 2,
   612				.channels_max   = 2,
   613				.rates      = TAS27XX_RATES,
   614				.formats    = TAS27XX_FORMATS,
   615			},
   616			.capture = {
   617				.stream_name    = "ASI1 Capture",
   618				.channels_min   = 1,
   619				.channels_max   = 2,
   620				.rates = TAS27XX_RATES,
   621				.formats = TAS27XX_FORMATS,
   622			},
   623			.ops = &tas27xx_dai_ops,
 > 624			.symmetric_rates = 1,
   625		},
   626	};
   627
kernel test robot March 30, 2022, 6:36 p.m. UTC | #3
Hi Raphael-Xu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on v5.17 next-20220330]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: arm-randconfig-r012-20220330 (https://download.01.org/0day-ci/archive/20220331/202203310255.mwJuw0DH-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 0f6d9501cf49ce02937099350d08f20c4af86f3d)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/5e87128eec39d187eaf11069178b39d935600c2e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
        git checkout 5e87128eec39d187eaf11069178b39d935600c2e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> sound/soc/codecs/tas27xx.c:624:4: error: field designator 'symmetric_rates' does not refer to any field in type 'struct snd_soc_dai_driver'; did you mean 'symmetric_rate'?
                   .symmetric_rates = 1,
                    ^~~~~~~~~~~~~~~
                    symmetric_rate
   include/sound/soc-dai.h:411:15: note: 'symmetric_rate' declared here
           unsigned int symmetric_rate:1;
                        ^
>> sound/soc/codecs/tas27xx.c:819:3: error: invalid application of 'sizeof' to an incomplete type 'struct snd_soc_dai_driver[]'
                   ARRAY_SIZE(tas27xx_dai_driver));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/kernel.h:55:32: note: expanded from macro 'ARRAY_SIZE'
   #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                  ^~~~~
   2 errors generated.


vim +624 sound/soc/codecs/tas27xx.c

   598	
   599	#define TAS27XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
   600				 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
   601	
   602	#define TAS27XX_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
   603			       SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200)
   604	
   605	static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
   606		{
   607			.name = "tas27xx ASI1",
   608			.id = 0,
   609			.playback = {
   610				.stream_name    = "ASI1 Playback",
   611				.channels_min   = 2,
   612				.channels_max   = 2,
   613				.rates      = TAS27XX_RATES,
   614				.formats    = TAS27XX_FORMATS,
   615			},
   616			.capture = {
   617				.stream_name    = "ASI1 Capture",
   618				.channels_min   = 1,
   619				.channels_max   = 2,
   620				.rates = TAS27XX_RATES,
   621				.formats = TAS27XX_FORMATS,
   622			},
   623			.ops = &tas27xx_dai_ops,
 > 624			.symmetric_rates = 1,
   625		},
   626	};
   627	
   628	static int tas27xx_codec_probe(struct snd_soc_component *component)
   629	{
   630		struct tas27xx_priv *tas27xx = 
   631			snd_soc_component_get_drvdata(component);
   632		int ret = 0;
   633	
   634		tas27xx->component = component;
   635	
   636		if (tas27xx->sdz_gpio)
   637			gpiod_set_value_cansleep(tas27xx->sdz_gpio, 1);
   638	
   639		tas27xx_reset(tas27xx);
   640	
   641		ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG5,
   642						    TAS27XX_TDM_CFG5_VSNS_ENABLE, 0);
   643		if (ret < 0) {
   644			dev_err(tas27xx->dev, "%s:%u: Failed to enable vSNS\n",
   645				__func__, __LINE__);
   646			goto EXIT;
   647		}
   648		ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG6,
   649						    TAS27XX_TDM_CFG6_ISNS_ENABLE, 0);
   650		if (ret < 0) {
   651			dev_err(tas27xx->dev, "%s:%u: Failed to enable iSNS\n",
   652				__func__, __LINE__);
   653			goto EXIT;
   654		}
   655		ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
   656						    TAS27XX_PWR_CTRL_MASK,
   657						    TAS27XX_PWR_CTRL_MUTE);
   658		if (ret < 0) {
   659			dev_err(tas27xx->dev, "%s:%u: Failed to PWR_CTRL_MUTE\n",
   660				__func__, __LINE__);
   661			goto EXIT;
   662		}
   663	
   664		ret = snd_soc_component_write(component, TAS27XX_PWR_CTRL, 0x02);
   665	
   666		if (ret < 0) {
   667			dev_err(tas27xx->dev, "%s:%u: Failed to initial active\n",
   668				__func__, __LINE__);
   669			goto EXIT;
   670		}
   671		ret = 0;
   672	EXIT:
   673		return ret;
   674	}
   675	
   676	static DECLARE_TLV_DB_SCALE(tas27xx_digital_tlv, 1100, 50, 0);
   677	static DECLARE_TLV_DB_SCALE(tas27xx_playback_volume, -10000, 50, 0);
   678	
   679	static const struct snd_kcontrol_new tas27xx_snd_controls[] = {
   680		SOC_SINGLE_TLV("Speaker Volume", TAS27XX_DVC, 0,
   681			       TAS27XX_DVC_MAX, 1, tas27xx_playback_volume),
   682		SOC_SINGLE_TLV("Amp Gain Volume", TAS27XX_CHNL_0, 0, 0x14, 0,
   683			       tas27xx_digital_tlv),
   684	};
   685	
   686	static const struct snd_soc_component_driver soc_component_driver_tas27xx = {
   687		.probe			= tas27xx_codec_probe,
   688	#ifdef CONFIG_PM
   689		.suspend		= tas27xx_codec_suspend,
   690		.resume			= tas27xx_codec_resume,
   691	#endif
   692		.set_bias_level		= tas27xx_set_bias_level,
   693		.controls		= tas27xx_snd_controls,
   694		.num_controls		= ARRAY_SIZE(tas27xx_snd_controls),
   695		.dapm_widgets		= tas27xx_dapm_widgets,
   696		.num_dapm_widgets	= ARRAY_SIZE(tas27xx_dapm_widgets),
   697		.dapm_routes		= tas27xx_audio_map,
   698		.num_dapm_routes	= ARRAY_SIZE(tas27xx_audio_map),
   699		.idle_bias_on		= 1,
   700		.endianness		= 1,
   701		.non_legacy_dai_naming	= 1,
   702	};
   703	
   704	static const struct reg_default tas27xx_reg_defaults[] = {
   705		{ TAS27XX_PAGE, 0x00 },
   706		{ TAS27XX_SW_RST, 0x00 },
   707		{ TAS27XX_PWR_CTRL, 0x1a },
   708		{ TAS27XX_DVC, 0x00 },
   709		{ TAS27XX_CHNL_0, 0x00 },
   710		{ TAS27XX_TDM_CFG0, 0x09 },
   711		{ TAS27XX_TDM_CFG1, 0x02 },
   712		{ TAS27XX_TDM_CFG2, 0x0a },
   713		{ TAS27XX_TDM_CFG3, 0x10 },
   714		{ TAS27XX_TDM_CFG5, 0x42 },
   715	};
   716	
   717	static const struct regmap_range_cfg tas27xx_regmap_ranges[] = {
   718		{
   719			.range_min = 0,
   720			.range_max = 1 * 128,
   721			.selector_reg = TAS27XX_PAGE,
   722			.selector_mask = 0xff,
   723			.selector_shift = 0,
   724			.window_start = 0,
   725			.window_len = 128,
   726		},
   727	};
   728	
   729	static bool tas27xx_volatile(struct device *dev,
   730		unsigned int reg)
   731	{
   732			return true;
   733	}
   734	
   735	static const struct regmap_config tas27xx_i2c_regmap = {
   736		.reg_bits = 8,
   737		.val_bits = 8,
   738		.reg_defaults = tas27xx_reg_defaults,
   739		.num_reg_defaults = ARRAY_SIZE(tas27xx_reg_defaults),
   740		.cache_type = REGCACHE_RBTREE,
   741		.ranges = tas27xx_regmap_ranges,
   742		.num_ranges = ARRAY_SIZE(tas27xx_regmap_ranges),
   743		.max_register = 1 * 128,
   744		.volatile_reg = tas27xx_volatile,
   745	};
   746	
   747	static int tas27xx_parse_dt(struct device *dev, struct tas27xx_priv *tas27xx)
   748	{
   749		int ret = 0;
   750	
   751		tas27xx->reset_gpio = devm_gpiod_get_optional(tas27xx->dev, "reset",
   752							      GPIOD_OUT_HIGH);
   753		if (IS_ERR(tas27xx->reset_gpio)) {
   754			if (PTR_ERR(tas27xx->reset_gpio) == -EPROBE_DEFER) {
   755				tas27xx->reset_gpio = NULL;
   756				return -EPROBE_DEFER;
   757			}
   758		}
   759	
   760		tas27xx->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", 
   761			GPIOD_OUT_HIGH);
   762		if (IS_ERR(tas27xx->sdz_gpio)) {
   763			if (PTR_ERR(tas27xx->sdz_gpio) == -EPROBE_DEFER)
   764				return -EPROBE_DEFER;
   765	
   766			tas27xx->sdz_gpio = NULL;
   767		}
   768	
   769		ret = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no",
   770					       &tas27xx->i_sense_slot);
   771		if (ret)
   772			tas27xx->i_sense_slot = 0;
   773	
   774		ret = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no",
   775					       &tas27xx->v_sense_slot);
   776		if (ret)
   777			tas27xx->v_sense_slot = 2;
   778	
   779		return 0;
   780	}
   781	
   782	static int tas27xx_i2c_probe(struct i2c_client *client,
   783				const struct i2c_device_id *id)
   784	{
   785		struct tas27xx_priv *tas27xx;
   786		int result;
   787	
   788		tas27xx = devm_kzalloc(&client->dev, sizeof(struct tas27xx_priv),
   789				       GFP_KERNEL);
   790		if (!tas27xx)
   791			return -ENOMEM;
   792		mutex_init(&tas27xx->codec_lock);
   793		tas27xx->dev = &client->dev;
   794		i2c_set_clientdata(client, tas27xx);
   795		dev_set_drvdata(&client->dev, tas27xx);
   796	
   797		tas27xx->regmap = devm_regmap_init_i2c(client, &tas27xx_i2c_regmap);
   798		if (IS_ERR(tas27xx->regmap)) {
   799			result = PTR_ERR(tas27xx->regmap);
   800			dev_err(&client->dev, "Failed to allocate register map: %d\n",
   801						result);
   802			return result;
   803		}
   804	
   805		if (client->dev.of_node) {
   806			result = tas27xx_parse_dt(&client->dev, tas27xx);
   807			if (result) {
   808				dev_err(tas27xx->dev, 
   809					"%s: Failed to parse devicetree\n", __func__);
   810				return result;
   811			}
   812		}
   813	
   814		tas27xx->device_id = id->driver_data;
   815		dev_info(tas27xx->dev, "chip_id: %u\n", tas27xx->device_id);
   816	
   817		return devm_snd_soc_register_component(tas27xx->dev,
   818			&soc_component_driver_tas27xx, tas27xx_dai_driver,
 > 819			ARRAY_SIZE(tas27xx_dai_driver));
   820	}
   821
kernel test robot March 31, 2022, 3:59 a.m. UTC | #4
Hi Raphael-Xu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on broonie-sound/for-next]
[also build test ERROR on v5.17 next-20220330]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20220331/202203311144.77JqF9D6-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/5e87128eec39d187eaf11069178b39d935600c2e
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Raphael-Xu/rename-tas2764-to-tas27xx/20220330-224947
        git checkout 5e87128eec39d187eaf11069178b39d935600c2e
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=m68k SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> sound/soc/codecs/tas27xx.c:624:18: error: 'struct snd_soc_dai_driver' has no member named 'symmetric_rates'; did you mean 'symmetric_rate'?
     624 |                 .symmetric_rates = 1,
         |                  ^~~~~~~~~~~~~~~
         |                  symmetric_rate
>> sound/soc/codecs/tas27xx.c:624:36: warning: initialization of 'const struct snd_soc_cdai_ops *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     624 |                 .symmetric_rates = 1,
         |                                    ^
   sound/soc/codecs/tas27xx.c:624:36: note: (near initialization for 'tas27xx_dai_driver[0].cops')


vim +624 sound/soc/codecs/tas27xx.c

   598	
   599	#define TAS27XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
   600				 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
   601	
   602	#define TAS27XX_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
   603			       SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_88200)
   604	
   605	static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
   606		{
   607			.name = "tas27xx ASI1",
   608			.id = 0,
   609			.playback = {
   610				.stream_name    = "ASI1 Playback",
   611				.channels_min   = 2,
   612				.channels_max   = 2,
   613				.rates      = TAS27XX_RATES,
   614				.formats    = TAS27XX_FORMATS,
   615			},
   616			.capture = {
   617				.stream_name    = "ASI1 Capture",
   618				.channels_min   = 1,
   619				.channels_max   = 2,
   620				.rates = TAS27XX_RATES,
   621				.formats = TAS27XX_FORMATS,
   622			},
   623			.ops = &tas27xx_dai_ops,
 > 624			.symmetric_rates = 1,
   625		},
   626	};
   627
diff mbox series

Patch

diff --git a/sound/soc/codecs/tas27xx.c b/sound/soc/codecs/tas27xx.c
index 8118429bb2f5..bb845d4797ce 100644
--- a/sound/soc/codecs/tas27xx.c
+++ b/sound/soc/codecs/tas27xx.c
@@ -1,7 +1,7 @@ 
 // SPDX-License-Identifier: GPL-2.0
-//
-// Driver for the Texas Instruments TAS27XX CODEC
-// Copyright (C) 2020 Texas Instruments Inc.
+// Driver for the Texas Instruments TAS2764/TAS2780 Mono
+//		Audio amplifier
+// Copyright (C) 2022 Texas Instruments Inc.
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -12,16 +12,15 @@ 
 #include <linux/i2c.h>
 #include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
-#include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
-#include <linux/slab.h>
 #include <sound/soc.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/initval.h>
 #include <sound/tlv.h>
+#include <linux/version.h>
 
 #include "tas27xx.h"
 
@@ -31,9 +30,16 @@  struct tas27xx_priv {
 	struct gpio_desc *sdz_gpio;
 	struct regmap *regmap;
 	struct device *dev;
-	
+	struct mutex codec_lock;
 	int v_sense_slot;
 	int i_sense_slot;
+	int device_id;
+	bool mb_power_up;
+};
+
+enum tas27xx {
+	TAS2764 = 0,
+	TAS2780 = 1,
 };
 
 static void tas27xx_reset(struct tas27xx_priv *tas27xx)
@@ -53,32 +59,52 @@  static int tas27xx_set_bias_level(struct snd_soc_component *component,
 {
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-
+	int ret = 0;
+	
+	mutex_lock(&tas27xx->codec_lock);
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
-					      TAS27XX_PWR_CTRL_MASK,
-					      TAS27XX_PWR_CTRL_ACTIVE);
+		ret = snd_soc_component_update_bits(component, 
+					TAS27XX_PWR_CTRL,
+					TAS27XX_PWR_CTRL_MASK,
+					TAS27XX_PWR_CTRL_ACTIVE);
+		if (ret >= 0) {
+			tas27xx->mb_power_up = true;
+			ret = 0;
+		}
 		break;
 	case SND_SOC_BIAS_STANDBY:
 	case SND_SOC_BIAS_PREPARE:
-		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
-					      TAS27XX_PWR_CTRL_MASK,
-					      TAS27XX_PWR_CTRL_MUTE);
+		ret = snd_soc_component_update_bits(component,
+			TAS27XX_PWR_CTRL,
+			TAS27XX_PWR_CTRL_MASK,
+			TAS27XX_PWR_CTRL_MUTE);
+		if (ret >= 0) {
+			tas27xx->mb_power_up = true;
+			ret = 0;
+		}
 		break;
 	case SND_SOC_BIAS_OFF:
-		snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
-					      TAS27XX_PWR_CTRL_MASK,
-					      TAS27XX_PWR_CTRL_SHUTDOWN);
+		ret = snd_soc_component_update_bits(component,
+			TAS27XX_PWR_CTRL,
+			TAS27XX_PWR_CTRL_MASK,
+			TAS27XX_PWR_CTRL_SHUTDOWN);
+		if (ret >= 0) {
+			tas27xx->mb_power_up = false;
+			ret = 0;
+		}
 		break;
 
 	default:
 		dev_err(tas27xx->dev,
-				"wrong power level setting %d\n", level);
-		return -EINVAL;
+			"wrong power level setting %d\n", level);
+		ret = -EINVAL;
 	}
-
-	return 0;
+	if (ret < 0)
+		pr_err("%s:%u:errCode:0x%0x:set BIAS error\n",
+			__func__, __LINE__, ret);
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 #ifdef CONFIG_PM
@@ -86,30 +112,37 @@  static int tas27xx_codec_suspend(struct snd_soc_component *component)
 {
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-	int ret;
+	int ret = 0;
 
+	mutex_lock(&tas27xx->codec_lock);
 	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
 					    TAS27XX_PWR_CTRL_MASK,
 					    TAS27XX_PWR_CTRL_SHUTDOWN);
 
-	if (ret < 0)
-		return ret;
-
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%0x:power down error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+	tas27xx->mb_power_up = false;
 	if (tas27xx->sdz_gpio)
 		gpiod_set_value_cansleep(tas27xx->sdz_gpio, 0);
 
 	regcache_cache_only(tas27xx->regmap, true);
 	regcache_mark_dirty(tas27xx->regmap);
-
-	return 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_codec_resume(struct snd_soc_component *component)
 {
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-	int ret;
+	int ret = 0;
 
+	mutex_lock(&tas27xx->codec_lock);
 	if (tas27xx->sdz_gpio)
 		gpiod_set_value_cansleep(tas27xx->sdz_gpio, 1);
 
@@ -117,16 +150,19 @@  static int tas27xx_codec_resume(struct snd_soc_component *component)
 					    TAS27XX_PWR_CTRL_MASK,
 					    TAS27XX_PWR_CTRL_ACTIVE);
 
-	if (ret < 0)
-		return ret;
-
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%0x:power down error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+	tas27xx->mb_power_up = false;
 	regcache_cache_only(tas27xx->regmap, false);
-
-	return regcache_sync(tas27xx->regmap);
+	ret = regcache_sync(tas27xx->regmap);
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
-#else
-#define tas27xx_codec_suspend NULL
-#define tas27xx_codec_resume NULL
 #endif
 
 static const char * const tas27xx_ASI1_src[] = {
@@ -146,8 +182,9 @@  static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
 		snd_soc_dapm_to_component(w->dapm);
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-	int ret;
+	int ret = 0;
 
+	mutex_lock(&tas27xx->codec_lock);
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
 		ret = snd_soc_component_update_bits(component, 
@@ -163,13 +200,16 @@  static int tas27xx_dac_event(struct snd_soc_dapm_widget *w,
 		break;
 	default:
 		dev_err(tas27xx->dev, "Unsupported event\n");
-		return -EINVAL;
+			ret = -EINVAL;
 	}
-
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%0x:PWR_CTRL error\n",
+			__func__, __LINE__, ret);
+	} else {
+		ret = 0;
+	}
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static const struct snd_kcontrol_new isense_switch =
@@ -207,55 +247,96 @@  static const struct snd_soc_dapm_route tas27xx_audio_map[] = {
 static int tas27xx_mute(struct snd_soc_dai *dai, int mute, int direction)
 {
 	struct snd_soc_component *component = dai->component;
-	int ret;
+	struct tas27xx_priv *tas27xx =
+		snd_soc_component_get_drvdata(component);
+	int ret = 0;
+	
+	mutex_lock(&tas27xx->codec_lock);
 
+	if (mute == 0) {
+		ret = snd_soc_component_update_bits(component,
+			TAS27XX_CLK_CFG,
+			TAS27XX_CLK_CFG_MASK,
+			TAS27XX_CLK_CFG_ENABLE);
+		if (ret < 0) {
+			dev_err(tas27xx->dev,
+				"%s:%u: Failed to CLK_CFG_ENABLE\n",
+				__func__, __LINE__);
+			goto EXIT;
+		}
+		usleep_range(2000, 2000);
+	}
 	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
-					    TAS27XX_PWR_CTRL_MASK,
-					    mute ? TAS27XX_PWR_CTRL_MUTE : 0);
-
-	if (ret < 0)
-		return ret;
+		TAS27XX_PWR_CTRL_MASK,
+		mute ? TAS27XX_PWR_CTRL_MUTE : 0);
+	if (ret >= 0) {
+		tas27xx->mb_power_up = mute?false:true;
+		ret = 0;
+	}
 
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u: Failed to set powercontrol\n",
+			__func__, __LINE__);
+	}
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_set_bitwidth(struct tas27xx_priv *tas27xx, int bitwidth)
 {
 	struct snd_soc_component *component = tas27xx->component;
-	int sense_en;
-	int val;
-	int ret;
+	int sense_en, val, ret, slot_size;
 
+	mutex_lock(&tas27xx->codec_lock);
 	switch (bitwidth) {
 	case SNDRV_PCM_FORMAT_S16_LE:
 		ret = snd_soc_component_update_bits(component,
-					TAS27XX_TDM_CFG2,
-					TAS27XX_TDM_CFG2_RXW_MASK,
-					TAS27XX_TDM_CFG2_RXW_16BITS);
+			TAS27XX_TDM_CFG2,
+			TAS27XX_TDM_CFG2_RXW_MASK,
+			TAS27XX_TDM_CFG2_RXW_16BITS);
+		slot_size = TAS27XX_TDM_CFG2_RXS_16BITS;
 		break;
 	case SNDRV_PCM_FORMAT_S24_LE:
 		ret = snd_soc_component_update_bits(component,
 					TAS27XX_TDM_CFG2,
 					TAS27XX_TDM_CFG2_RXW_MASK,
 					TAS27XX_TDM_CFG2_RXW_24BITS);
+		slot_size = TAS27XX_TDM_CFG2_RXS_24BITS;
 		break;
 	case SNDRV_PCM_FORMAT_S32_LE:
 		ret = snd_soc_component_update_bits(component,
 					TAS27XX_TDM_CFG2,
 					TAS27XX_TDM_CFG2_RXW_MASK,
 					TAS27XX_TDM_CFG2_RXW_32BITS);
+		slot_size = TAS27XX_TDM_CFG2_RXS_32BITS;
 		break;
 
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
 	}
 
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x set bitwidth error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG2,
+		TAS27XX_TDM_CFG2_RXS_MASK, slot_size);
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x set RX slot size error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	val = snd_soc_component_read(tas27xx->component, TAS27XX_PWR_CTRL);
-	if (val < 0)
-		return val;
+	if (val < 0) {
+		pr_err("%s:%u:errCode:0x%x read PWR_CTRL error\n",
+			__func__, __LINE__, val);
+		ret = val;
+		goto EXIT;
+	}
 
 	if (val & (1 << TAS27XX_VSENSE_POWER_EN))
 		sense_en = 0;
@@ -264,8 +345,11 @@  static int tas27xx_set_bitwidth(struct tas27xx_priv *tas27xx, int bitwidth)
 
 	ret = snd_soc_component_update_bits(tas27xx->component, 
 		TAS27XX_TDM_CFG5, TAS27XX_TDM_CFG5_VSNS_ENABLE, sense_en);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x enable vSNS error\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	if (val & (1 << TAS27XX_ISENSE_POWER_EN))
 		sense_en = 0;
@@ -274,10 +358,14 @@  static int tas27xx_set_bitwidth(struct tas27xx_priv *tas27xx, int bitwidth)
 
 	ret = snd_soc_component_update_bits(tas27xx->component, 
 		TAS27XX_TDM_CFG6, TAS27XX_TDM_CFG6_ISNS_ENABLE, sense_en);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x enable iSNS error\n",
+			__func__, __LINE__, ret);
+	}
+	ret = 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_set_samplerate(
@@ -307,15 +395,20 @@  static int tas27xx_set_samplerate(
 	default:
 		return -EINVAL;
 	}
-
+	mutex_lock(&tas27xx->codec_lock);
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG0,
 					    TAS27XX_TDM_CFG0_SMP_MASK |
 					    TAS27XX_TDM_CFG0_MASK,
 					    ramp_rate_val);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set ramp_rate_val\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_hw_params(struct snd_pcm_substream *substream,
@@ -341,7 +434,7 @@  static int tas27xx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 		snd_soc_component_get_drvdata(component);
 	u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
 	int iface;
-	int ret;
+	int ret = 0;
 
 	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
 	case SND_SOC_DAIFMT_NB_NF:
@@ -354,12 +447,15 @@  static int tas27xx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 		dev_err(tas27xx->dev, "ASI format Inverse is not found\n");
 		return -EINVAL;
 	}
-
+	mutex_lock(&tas27xx->codec_lock);
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG1,
 					    TAS27XX_TDM_CFG1_RX_MASK,
 					    asi_cfg_1);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set asi_cfg_1\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
@@ -373,23 +469,32 @@  static int tas27xx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 		tdm_rx_start_slot = 0;
 		break;
 	default:
-		dev_err(tas27xx->dev,
-			"DAI Format is not found, fmt=0x%x\n", fmt);
-		return -EINVAL;
+		pr_err("%s:%u:DAI Format is not found, fmt=0x%x\n",
+			__func__, __LINE__, fmt);
+		ret = -EINVAL;
+		goto EXIT;
 	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG1,
 		TAS27XX_TDM_CFG1_MASK,
 		(tdm_rx_start_slot << TAS27XX_TDM_CFG1_51_SHIFT));
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set tdm_rx_start_slot\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG2,
 		TAS27XX_TDM_CFG2_SCFG_MASK, iface);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set iface\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
@@ -403,7 +508,7 @@  static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
 	int left_slot, right_slot;
 	int slots_cfg;
 	int slot_size;
-	int ret;
+	int ret = 0;
 
 	if (tx_mask == 0 || rx_mask != 0)
 		return -EINVAL;
@@ -428,10 +533,13 @@  static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
 		return -EINVAL;
 
 	slots_cfg = (right_slot << TAS27XX_TDM_CFG3_RXS_SHIFT) | left_slot;
-
+	mutex_lock(&tas27xx->codec_lock);
 	ret = snd_soc_component_write(component, TAS27XX_TDM_CFG3, slots_cfg);
-	if (ret)
-		return ret;
+	if (ret) {
+		pr_err("%s:%u:errCode:0x%x Failed to set slots_cfg\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	switch (slot_width) {
 	case 16:
@@ -444,28 +552,40 @@  static int tas27xx_set_dai_tdm_slot(struct snd_soc_dai *dai,
 		slot_size = TAS27XX_TDM_CFG2_RXS_32BITS;
 		break;
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
+		goto EXIT;
 	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG2,
 					    TAS27XX_TDM_CFG2_RXS_MASK,
 					    slot_size);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set slot_size\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG5,
 					    TAS27XX_TDM_CFG5_50_MASK,
 					    tas27xx->v_sense_slot);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set v_sense_slot\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
 
 	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG6,
 					    TAS27XX_TDM_CFG6_50_MASK,
 					    tas27xx->i_sense_slot);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	if (ret < 0) {
+		pr_err("%s:%u:errCode:0x%x Failed to set i_sense_slot\n",
+			__func__, __LINE__, ret);
+		goto EXIT;
+	}
+	ret = 0;
+EXIT:
+	mutex_unlock(&tas27xx->codec_lock);
+	return ret;
 }
 
 static const struct snd_soc_dai_ops tas27xx_dai_ops = {
@@ -495,13 +615,13 @@  static struct snd_soc_dai_driver tas27xx_dai_driver[] = {
 		},
 		.capture = {
 			.stream_name    = "ASI1 Capture",
-			.channels_min   = 0,
+			.channels_min   = 1,
 			.channels_max   = 2,
 			.rates = TAS27XX_RATES,
 			.formats = TAS27XX_FORMATS,
 		},
 		.ops = &tas27xx_dai_ops,
-		.symmetric_rate = 1,
+		.symmetric_rates = 1,
 	},
 };
 
@@ -509,7 +629,7 @@  static int tas27xx_codec_probe(struct snd_soc_component *component)
 {
 	struct tas27xx_priv *tas27xx = 
 		snd_soc_component_get_drvdata(component);
-	int ret;
+	int ret = 0;
 
 	tas27xx->component = component;
 
@@ -518,25 +638,39 @@  static int tas27xx_codec_probe(struct snd_soc_component *component)
 
 	tas27xx_reset(tas27xx);
 
-	ret = snd_soc_component_update_bits(tas27xx->component, 
-						TAS27XX_TDM_CFG5,
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG5,
 					    TAS27XX_TDM_CFG5_VSNS_ENABLE, 0);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_component_update_bits(tas27xx->component, 
-						TAS27XX_TDM_CFG6,
+	if (ret < 0) {
+		dev_err(tas27xx->dev, "%s:%u: Failed to enable vSNS\n",
+			__func__, __LINE__);
+		goto EXIT;
+	}
+	ret = snd_soc_component_update_bits(component, TAS27XX_TDM_CFG6,
 					    TAS27XX_TDM_CFG6_ISNS_ENABLE, 0);
-	if (ret < 0)
-		return ret;
-
+	if (ret < 0) {
+		dev_err(tas27xx->dev, "%s:%u: Failed to enable iSNS\n",
+			__func__, __LINE__);
+		goto EXIT;
+	}
 	ret = snd_soc_component_update_bits(component, TAS27XX_PWR_CTRL,
 					    TAS27XX_PWR_CTRL_MASK,
 					    TAS27XX_PWR_CTRL_MUTE);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		dev_err(tas27xx->dev, "%s:%u: Failed to PWR_CTRL_MUTE\n",
+			__func__, __LINE__);
+		goto EXIT;
+	}
 
-	return 0;
+	ret = snd_soc_component_write(component, TAS27XX_PWR_CTRL, 0x02);
+
+	if (ret < 0) {
+		dev_err(tas27xx->dev, "%s:%u: Failed to initial active\n",
+			__func__, __LINE__);
+		goto EXIT;
+	}
+	ret = 0;
+EXIT:
+	return ret;
 }
 
 static DECLARE_TLV_DB_SCALE(tas27xx_digital_tlv, 1100, 50, 0);
@@ -551,8 +685,10 @@  static const struct snd_kcontrol_new tas27xx_snd_controls[] = {
 
 static const struct snd_soc_component_driver soc_component_driver_tas27xx = {
 	.probe			= tas27xx_codec_probe,
+#ifdef CONFIG_PM
 	.suspend		= tas27xx_codec_suspend,
 	.resume			= tas27xx_codec_resume,
+#endif
 	.set_bias_level		= tas27xx_set_bias_level,
 	.controls		= tas27xx_snd_controls,
 	.num_controls		= ARRAY_SIZE(tas27xx_snd_controls),
@@ -590,6 +726,12 @@  static const struct regmap_range_cfg tas27xx_regmap_ranges[] = {
 	},
 };
 
+static bool tas27xx_volatile(struct device *dev,
+	unsigned int reg)
+{
+		return true;
+}
+
 static const struct regmap_config tas27xx_i2c_regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
@@ -599,6 +741,7 @@  static const struct regmap_config tas27xx_i2c_regmap = {
 	.ranges = tas27xx_regmap_ranges,
 	.num_ranges = ARRAY_SIZE(tas27xx_regmap_ranges),
 	.max_register = 1 * 128,
+	.volatile_reg = tas27xx_volatile,
 };
 
 static int tas27xx_parse_dt(struct device *dev, struct tas27xx_priv *tas27xx)
@@ -646,7 +789,7 @@  static int tas27xx_i2c_probe(struct i2c_client *client,
 			       GFP_KERNEL);
 	if (!tas27xx)
 		return -ENOMEM;
-
+	mutex_init(&tas27xx->codec_lock);
 	tas27xx->dev = &client->dev;
 	i2c_set_clientdata(client, tas27xx);
 	dev_set_drvdata(&client->dev, tas27xx);
@@ -668,6 +811,9 @@  static int tas27xx_i2c_probe(struct i2c_client *client,
 		}
 	}
 
+	tas27xx->device_id = id->driver_data;
+	dev_info(tas27xx->dev, "chip_id: %u\n", tas27xx->device_id);
+
 	return devm_snd_soc_register_component(tas27xx->dev,
 		&soc_component_driver_tas27xx, tas27xx_dai_driver,
 		ARRAY_SIZE(tas27xx_dai_driver));
@@ -675,6 +821,7 @@  static int tas27xx_i2c_probe(struct i2c_client *client,
 
 static const struct i2c_device_id tas27xx_i2c_id[] = {
 	{ "tas2764", TAS2764},
+	{ "tas2780", TAS2780},
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, tas27xx_i2c_id);
@@ -682,6 +829,7 @@  MODULE_DEVICE_TABLE(i2c, tas27xx_i2c_id);
 #if defined(CONFIG_OF)
 static const struct of_device_id tas27xx_of_match[] = {
 	{ .compatible = "ti,tas2764" },
+	{ .compatible = "ti,tas2780" },
 	{},
 };
 MODULE_DEVICE_TABLE(of, tas27xx_of_match);
@@ -697,6 +845,6 @@  static struct i2c_driver tas27xx_i2c_driver = {
 };
 module_i2c_driver(tas27xx_i2c_driver);
 
-MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
+MODULE_AUTHOR("Raphael Xu <raphael-xu@ti.com>");
 MODULE_DESCRIPTION("TAS27XX I2C Smart Amplifier driver");
 MODULE_LICENSE("GPL v2");