aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2011-10-14 02:30:05 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-10-14 15:29:05 -0400
commit79d07265137c166cf298d74a29038a76458ec46a (patch)
treeb191e95f2d794af56390d39fea188eae7c3f4877 /sound/soc
parent790f932500061ce49c52ef9dbd48fbfbdeb631c5 (diff)
ASoC: wm8990: Use snd_soc_update_bits for read-modify-write
Use snd_soc_update_bits for read-modify-write register access instead of open-coding it using snd_soc_read and snd_soc_write This patch also includes a comment fix in wm8990_set_dai_pll(), if freq_in and freq_out are 0, what we do is to clear WM8990_PLL_ENA bit. Thus the comment should be "Turn off PLL". Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/wm8990.c67
1 files changed, 27 insertions, 40 deletions
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index b9c5ecc026f0..d29a9622964c 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -981,7 +981,6 @@ static void pll_factors(struct _pll_div *pll_div, unsigned int target,
981static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 981static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
982 int source, unsigned int freq_in, unsigned int freq_out) 982 int source, unsigned int freq_in, unsigned int freq_out)
983{ 983{
984 u16 reg;
985 struct snd_soc_codec *codec = codec_dai->codec; 984 struct snd_soc_codec *codec = codec_dai->codec;
986 struct _pll_div pll_div; 985 struct _pll_div pll_div;
987 986
@@ -989,13 +988,12 @@ static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
989 pll_factors(&pll_div, freq_out * 4, freq_in); 988 pll_factors(&pll_div, freq_out * 4, freq_in);
990 989
991 /* Turn on PLL */ 990 /* Turn on PLL */
992 reg = snd_soc_read(codec, WM8990_POWER_MANAGEMENT_2); 991 snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2,
993 reg |= WM8990_PLL_ENA; 992 WM8990_PLL_ENA, WM8990_PLL_ENA);
994 snd_soc_write(codec, WM8990_POWER_MANAGEMENT_2, reg);
995 993
996 /* sysclk comes from PLL */ 994 /* sysclk comes from PLL */
997 reg = snd_soc_read(codec, WM8990_CLOCKING_2); 995 snd_soc_update_bits(codec, WM8990_CLOCKING_2,
998 snd_soc_write(codec, WM8990_CLOCKING_2, reg | WM8990_SYSCLK_SRC); 996 WM8990_SYSCLK_SRC, WM8990_SYSCLK_SRC);
999 997
1000 /* set up N , fractional mode and pre-divisor if necessary */ 998 /* set up N , fractional mode and pre-divisor if necessary */
1001 snd_soc_write(codec, WM8990_PLL1, pll_div.n | WM8990_SDM | 999 snd_soc_write(codec, WM8990_PLL1, pll_div.n | WM8990_SDM |
@@ -1003,10 +1001,9 @@ static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
1003 snd_soc_write(codec, WM8990_PLL2, (u8)(pll_div.k>>8)); 1001 snd_soc_write(codec, WM8990_PLL2, (u8)(pll_div.k>>8));
1004 snd_soc_write(codec, WM8990_PLL3, (u8)(pll_div.k & 0xFF)); 1002 snd_soc_write(codec, WM8990_PLL3, (u8)(pll_div.k & 0xFF));
1005 } else { 1003 } else {
1006 /* Turn on PLL */ 1004 /* Turn off PLL */
1007 reg = snd_soc_read(codec, WM8990_POWER_MANAGEMENT_2); 1005 snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2,
1008 reg &= ~WM8990_PLL_ENA; 1006 WM8990_PLL_ENA, 0);
1009 snd_soc_write(codec, WM8990_POWER_MANAGEMENT_2, reg);
1010 } 1007 }
1011 return 0; 1008 return 0;
1012} 1009}
@@ -1084,28 +1081,23 @@ static int wm8990_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
1084 int div_id, int div) 1081 int div_id, int div)
1085{ 1082{
1086 struct snd_soc_codec *codec = codec_dai->codec; 1083 struct snd_soc_codec *codec = codec_dai->codec;
1087 u16 reg;
1088 1084
1089 switch (div_id) { 1085 switch (div_id) {
1090 case WM8990_MCLK_DIV: 1086 case WM8990_MCLK_DIV:
1091 reg = snd_soc_read(codec, WM8990_CLOCKING_2) & 1087 snd_soc_update_bits(codec, WM8990_CLOCKING_2,
1092 ~WM8990_MCLK_DIV_MASK; 1088 WM8990_MCLK_DIV_MASK, div);
1093 snd_soc_write(codec, WM8990_CLOCKING_2, reg | div);
1094 break; 1089 break;
1095 case WM8990_DACCLK_DIV: 1090 case WM8990_DACCLK_DIV:
1096 reg = snd_soc_read(codec, WM8990_CLOCKING_2) & 1091 snd_soc_update_bits(codec, WM8990_CLOCKING_2,
1097 ~WM8990_DAC_CLKDIV_MASK; 1092 WM8990_DAC_CLKDIV_MASK, div);
1098 snd_soc_write(codec, WM8990_CLOCKING_2, reg | div);
1099 break; 1093 break;
1100 case WM8990_ADCCLK_DIV: 1094 case WM8990_ADCCLK_DIV:
1101 reg = snd_soc_read(codec, WM8990_CLOCKING_2) & 1095 snd_soc_update_bits(codec, WM8990_CLOCKING_2,
1102 ~WM8990_ADC_CLKDIV_MASK; 1096 WM8990_ADC_CLKDIV_MASK, div);
1103 snd_soc_write(codec, WM8990_CLOCKING_2, reg | div);
1104 break; 1097 break;
1105 case WM8990_BCLK_DIV: 1098 case WM8990_BCLK_DIV:
1106 reg = snd_soc_read(codec, WM8990_CLOCKING_1) & 1099 snd_soc_update_bits(codec, WM8990_CLOCKING_1,
1107 ~WM8990_BCLK_DIV_MASK; 1100 WM8990_BCLK_DIV_MASK, div);
1108 snd_soc_write(codec, WM8990_CLOCKING_1, reg | div);
1109 break; 1101 break;
1110 default: 1102 default:
1111 return -EINVAL; 1103 return -EINVAL;
@@ -1164,7 +1156,6 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec,
1164 enum snd_soc_bias_level level) 1156 enum snd_soc_bias_level level)
1165{ 1157{
1166 int ret; 1158 int ret;
1167 u16 val;
1168 1159
1169 switch (level) { 1160 switch (level) {
1170 case SND_SOC_BIAS_ON: 1161 case SND_SOC_BIAS_ON:
@@ -1172,9 +1163,8 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec,
1172 1163
1173 case SND_SOC_BIAS_PREPARE: 1164 case SND_SOC_BIAS_PREPARE:
1174 /* VMID=2*50k */ 1165 /* VMID=2*50k */
1175 val = snd_soc_read(codec, WM8990_POWER_MANAGEMENT_1) & 1166 snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_1,
1176 ~WM8990_VMID_MODE_MASK; 1167 WM8990_VMID_MODE_MASK, 0x2);
1177 snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, val | 0x2);
1178 break; 1168 break;
1179 1169
1180 case SND_SOC_BIAS_STANDBY: 1170 case SND_SOC_BIAS_STANDBY:
@@ -1239,9 +1229,8 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec,
1239 } 1229 }
1240 1230
1241 /* VMID=2*250k */ 1231 /* VMID=2*250k */
1242 val = snd_soc_read(codec, WM8990_POWER_MANAGEMENT_1) & 1232 snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_1,
1243 ~WM8990_VMID_MODE_MASK; 1233 WM8990_VMID_MODE_MASK, 0x4);
1244 snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, val | 0x4);
1245 break; 1234 break;
1246 1235
1247 case SND_SOC_BIAS_OFF: 1236 case SND_SOC_BIAS_OFF:
@@ -1255,8 +1244,8 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec,
1255 WM8990_BUFIOEN); 1244 WM8990_BUFIOEN);
1256 1245
1257 /* mute DAC */ 1246 /* mute DAC */
1258 val = snd_soc_read(codec, WM8990_DAC_CTRL); 1247 snd_soc_update_bits(codec, WM8990_DAC_CTRL,
1259 snd_soc_write(codec, WM8990_DAC_CTRL, val | WM8990_DAC_MUTE); 1248 WM8990_DAC_MUTE, WM8990_DAC_MUTE);
1260 1249
1261 /* Enable any disabled outputs */ 1250 /* Enable any disabled outputs */
1262 snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f03); 1251 snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f03);
@@ -1344,7 +1333,6 @@ static int wm8990_resume(struct snd_soc_codec *codec)
1344static int wm8990_probe(struct snd_soc_codec *codec) 1333static int wm8990_probe(struct snd_soc_codec *codec)
1345{ 1334{
1346 int ret; 1335 int ret;
1347 u16 reg;
1348 1336
1349 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); 1337 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C);
1350 if (ret < 0) { 1338 if (ret < 0) {
@@ -1357,15 +1345,14 @@ static int wm8990_probe(struct snd_soc_codec *codec)
1357 /* charge output caps */ 1345 /* charge output caps */
1358 wm8990_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1346 wm8990_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1359 1347
1360 reg = snd_soc_read(codec, WM8990_AUDIO_INTERFACE_4); 1348 snd_soc_update_bits(codec, WM8990_AUDIO_INTERFACE_4,
1361 snd_soc_write(codec, WM8990_AUDIO_INTERFACE_4, reg | WM8990_ALRCGPIO1); 1349 WM8990_ALRCGPIO1, WM8990_ALRCGPIO1);
1362 1350
1363 reg = snd_soc_read(codec, WM8990_GPIO1_GPIO2) & 1351 snd_soc_update_bits(codec, WM8990_GPIO1_GPIO2,
1364 ~WM8990_GPIO1_SEL_MASK; 1352 WM8990_GPIO1_SEL_MASK, 1);
1365 snd_soc_write(codec, WM8990_GPIO1_GPIO2, reg | 1);
1366 1353
1367 reg = snd_soc_read(codec, WM8990_POWER_MANAGEMENT_2); 1354 snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2,
1368 snd_soc_write(codec, WM8990_POWER_MANAGEMENT_2, reg | WM8990_OPCLK_ENA); 1355 WM8990_OPCLK_ENA, WM8990_OPCLK_ENA);
1369 1356
1370 snd_soc_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); 1357 snd_soc_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8));
1371 snd_soc_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); 1358 snd_soc_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8));