aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/tlv320aic31xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/tlv320aic31xx.c')
-rw-r--r--sound/soc/codecs/tlv320aic31xx.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c
index e60e37b43a1b..fa158cfe9b32 100644
--- a/sound/soc/codecs/tlv320aic31xx.c
+++ b/sound/soc/codecs/tlv320aic31xx.c
@@ -129,7 +129,7 @@ static const struct regmap_range_cfg aic31xx_ranges[] = {
129 }, 129 },
130}; 130};
131 131
132struct regmap_config aic31xx_i2c_regmap = { 132static const struct regmap_config aic31xx_i2c_regmap = {
133 .reg_bits = 8, 133 .reg_bits = 8,
134 .val_bits = 8, 134 .val_bits = 8,
135 .writeable_reg = aic31xx_writeable, 135 .writeable_reg = aic31xx_writeable,
@@ -321,9 +321,9 @@ static const struct snd_kcontrol_new ldac_in_control =
321static const struct snd_kcontrol_new rdac_in_control = 321static const struct snd_kcontrol_new rdac_in_control =
322 SOC_DAPM_ENUM("DAC Right Input", rdac_in_enum); 322 SOC_DAPM_ENUM("DAC Right Input", rdac_in_enum);
323 323
324int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg, 324static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg,
325 unsigned int mask, unsigned int wbits, int sleep, 325 unsigned int mask, unsigned int wbits, int sleep,
326 int count) 326 int count)
327{ 327{
328 unsigned int bits; 328 unsigned int bits;
329 int counter = count; 329 int counter = count;
@@ -753,10 +753,9 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec,
753 753
754static int aic31xx_hw_params(struct snd_pcm_substream *substream, 754static int aic31xx_hw_params(struct snd_pcm_substream *substream,
755 struct snd_pcm_hw_params *params, 755 struct snd_pcm_hw_params *params,
756 struct snd_soc_dai *tmp) 756 struct snd_soc_dai *dai)
757{ 757{
758 struct snd_soc_pcm_runtime *rtd = substream->private_data; 758 struct snd_soc_codec *codec = dai->codec;
759 struct snd_soc_codec *codec = rtd->codec;
760 u8 data = 0; 759 u8 data = 0;
761 760
762 dev_dbg(codec->dev, "## %s: format %d width %d rate %d\n", 761 dev_dbg(codec->dev, "## %s: format %d width %d rate %d\n",
@@ -943,7 +942,6 @@ static void aic31xx_clk_on(struct snd_soc_codec *codec)
943 942
944static void aic31xx_clk_off(struct snd_soc_codec *codec) 943static void aic31xx_clk_off(struct snd_soc_codec *codec)
945{ 944{
946 struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
947 u8 mask = AIC31XX_PM_MASK; 945 u8 mask = AIC31XX_PM_MASK;
948 u8 off = 0; 946 u8 off = 0;
949 947
@@ -1021,7 +1019,8 @@ static int aic31xx_set_bias_level(struct snd_soc_codec *codec,
1021 } 1019 }
1022 break; 1020 break;
1023 case SND_SOC_BIAS_OFF: 1021 case SND_SOC_BIAS_OFF:
1024 aic31xx_power_off(codec); 1022 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY)
1023 aic31xx_power_off(codec);
1025 break; 1024 break;
1026 } 1025 }
1027 codec->dapm.bias_level = level; 1026 codec->dapm.bias_level = level;
@@ -1050,18 +1049,9 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec)
1050 dev_dbg(aic31xx->dev, "## %s\n", __func__); 1049 dev_dbg(aic31xx->dev, "## %s\n", __func__);
1051 1050
1052 aic31xx = snd_soc_codec_get_drvdata(codec); 1051 aic31xx = snd_soc_codec_get_drvdata(codec);
1053 codec->control_data = aic31xx->regmap;
1054 1052
1055 aic31xx->codec = codec; 1053 aic31xx->codec = codec;
1056 1054
1057 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
1058
1059 if (ret != 0) {
1060 dev_err(codec->dev, "snd_soc_codec_set_cache_io failed %d\n",
1061 ret);
1062 return ret;
1063 }
1064
1065 for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) { 1055 for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) {
1066 aic31xx->disable_nb[i].nb.notifier_call = 1056 aic31xx->disable_nb[i].nb.notifier_call =
1067 aic31xx_regulator_event; 1057 aic31xx_regulator_event;
@@ -1187,7 +1177,7 @@ static void aic31xx_pdata_from_of(struct aic31xx_priv *aic31xx)
1187} 1177}
1188#endif /* CONFIG_OF */ 1178#endif /* CONFIG_OF */
1189 1179
1190void aic31xx_device_init(struct aic31xx_priv *aic31xx) 1180static void aic31xx_device_init(struct aic31xx_priv *aic31xx)
1191{ 1181{
1192 int ret, i; 1182 int ret, i;
1193 1183
@@ -1238,7 +1228,6 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c,
1238 return -ENOMEM; 1228 return -ENOMEM;
1239 1229
1240 aic31xx->regmap = devm_regmap_init_i2c(i2c, regmap_config); 1230 aic31xx->regmap = devm_regmap_init_i2c(i2c, regmap_config);
1241
1242 if (IS_ERR(aic31xx->regmap)) { 1231 if (IS_ERR(aic31xx->regmap)) {
1243 ret = PTR_ERR(aic31xx->regmap); 1232 ret = PTR_ERR(aic31xx->regmap);
1244 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 1233 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
@@ -1251,18 +1240,14 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c,
1251 1240
1252 aic31xx_device_init(aic31xx); 1241 aic31xx_device_init(aic31xx);
1253 1242
1254 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_driver_aic31xx, 1243 return snd_soc_register_codec(&i2c->dev, &soc_codec_driver_aic31xx,
1255 aic31xx_dai_driver, 1244 aic31xx_dai_driver,
1256 ARRAY_SIZE(aic31xx_dai_driver)); 1245 ARRAY_SIZE(aic31xx_dai_driver));
1257
1258 return ret;
1259} 1246}
1260 1247
1261static int aic31xx_i2c_remove(struct i2c_client *i2c) 1248static int aic31xx_i2c_remove(struct i2c_client *i2c)
1262{ 1249{
1263 struct aic31xx_priv *aic31xx = dev_get_drvdata(&i2c->dev); 1250 snd_soc_unregister_codec(&i2c->dev);
1264
1265 kfree(aic31xx);
1266 return 0; 1251 return 0;
1267} 1252}
1268 1253
@@ -1284,7 +1269,7 @@ static struct i2c_driver aic31xx_i2c_driver = {
1284 .of_match_table = of_match_ptr(tlv320aic31xx_of_match), 1269 .of_match_table = of_match_ptr(tlv320aic31xx_of_match),
1285 }, 1270 },
1286 .probe = aic31xx_i2c_probe, 1271 .probe = aic31xx_i2c_probe,
1287 .remove = (aic31xx_i2c_remove), 1272 .remove = aic31xx_i2c_remove,
1288 .id_table = aic31xx_i2c_id, 1273 .id_table = aic31xx_i2c_id,
1289}; 1274};
1290 1275