diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2014-01-03 08:27:53 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-01-08 07:48:53 -0500 |
commit | efc8acff1ffe18b981d70da7ab2525e5b3e5de85 (patch) | |
tree | 3f374a5bcacfe7012bc795eefe87d4492aef537f /sound | |
parent | 8b3bca2966985f559f9ace1effc98955006f2b05 (diff) |
ASoC: twl4030: Remove local reg cache
Depend on the regmap reg cache implementation for register caching done in
the twl-core driver.
The local register cache can be removed and we can keep only shadow copies
of certain ctl registers for pop noise reduction.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/twl4030.c | 207 |
1 files changed, 63 insertions, 144 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index f88207712d3d..dda53e8c51e5 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -48,86 +48,6 @@ | |||
48 | 48 | ||
49 | #define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1) | 49 | #define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1) |
50 | 50 | ||
51 | /* | ||
52 | * twl4030 register cache & default register settings | ||
53 | */ | ||
54 | static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { | ||
55 | 0x00, /* this register not used */ | ||
56 | 0x00, /* REG_CODEC_MODE (0x1) */ | ||
57 | 0x00, /* REG_OPTION (0x2) */ | ||
58 | 0x00, /* REG_UNKNOWN (0x3) */ | ||
59 | 0x00, /* REG_MICBIAS_CTL (0x4) */ | ||
60 | 0x00, /* REG_ANAMICL (0x5) */ | ||
61 | 0x00, /* REG_ANAMICR (0x6) */ | ||
62 | 0x00, /* REG_AVADC_CTL (0x7) */ | ||
63 | 0x00, /* REG_ADCMICSEL (0x8) */ | ||
64 | 0x00, /* REG_DIGMIXING (0x9) */ | ||
65 | 0x0f, /* REG_ATXL1PGA (0xA) */ | ||
66 | 0x0f, /* REG_ATXR1PGA (0xB) */ | ||
67 | 0x0f, /* REG_AVTXL2PGA (0xC) */ | ||
68 | 0x0f, /* REG_AVTXR2PGA (0xD) */ | ||
69 | 0x00, /* REG_AUDIO_IF (0xE) */ | ||
70 | 0x00, /* REG_VOICE_IF (0xF) */ | ||
71 | 0x3f, /* REG_ARXR1PGA (0x10) */ | ||
72 | 0x3f, /* REG_ARXL1PGA (0x11) */ | ||
73 | 0x3f, /* REG_ARXR2PGA (0x12) */ | ||
74 | 0x3f, /* REG_ARXL2PGA (0x13) */ | ||
75 | 0x25, /* REG_VRXPGA (0x14) */ | ||
76 | 0x00, /* REG_VSTPGA (0x15) */ | ||
77 | 0x00, /* REG_VRX2ARXPGA (0x16) */ | ||
78 | 0x00, /* REG_AVDAC_CTL (0x17) */ | ||
79 | 0x00, /* REG_ARX2VTXPGA (0x18) */ | ||
80 | 0x32, /* REG_ARXL1_APGA_CTL (0x19) */ | ||
81 | 0x32, /* REG_ARXR1_APGA_CTL (0x1A) */ | ||
82 | 0x32, /* REG_ARXL2_APGA_CTL (0x1B) */ | ||
83 | 0x32, /* REG_ARXR2_APGA_CTL (0x1C) */ | ||
84 | 0x00, /* REG_ATX2ARXPGA (0x1D) */ | ||
85 | 0x00, /* REG_BT_IF (0x1E) */ | ||
86 | 0x55, /* REG_BTPGA (0x1F) */ | ||
87 | 0x00, /* REG_BTSTPGA (0x20) */ | ||
88 | 0x00, /* REG_EAR_CTL (0x21) */ | ||
89 | 0x00, /* REG_HS_SEL (0x22) */ | ||
90 | 0x00, /* REG_HS_GAIN_SET (0x23) */ | ||
91 | 0x00, /* REG_HS_POPN_SET (0x24) */ | ||
92 | 0x00, /* REG_PREDL_CTL (0x25) */ | ||
93 | 0x00, /* REG_PREDR_CTL (0x26) */ | ||
94 | 0x00, /* REG_PRECKL_CTL (0x27) */ | ||
95 | 0x00, /* REG_PRECKR_CTL (0x28) */ | ||
96 | 0x00, /* REG_HFL_CTL (0x29) */ | ||
97 | 0x00, /* REG_HFR_CTL (0x2A) */ | ||
98 | 0x05, /* REG_ALC_CTL (0x2B) */ | ||
99 | 0x00, /* REG_ALC_SET1 (0x2C) */ | ||
100 | 0x00, /* REG_ALC_SET2 (0x2D) */ | ||
101 | 0x00, /* REG_BOOST_CTL (0x2E) */ | ||
102 | 0x00, /* REG_SOFTVOL_CTL (0x2F) */ | ||
103 | 0x13, /* REG_DTMF_FREQSEL (0x30) */ | ||
104 | 0x00, /* REG_DTMF_TONEXT1H (0x31) */ | ||
105 | 0x00, /* REG_DTMF_TONEXT1L (0x32) */ | ||
106 | 0x00, /* REG_DTMF_TONEXT2H (0x33) */ | ||
107 | 0x00, /* REG_DTMF_TONEXT2L (0x34) */ | ||
108 | 0x79, /* REG_DTMF_TONOFF (0x35) */ | ||
109 | 0x11, /* REG_DTMF_WANONOFF (0x36) */ | ||
110 | 0x00, /* REG_I2S_RX_SCRAMBLE_H (0x37) */ | ||
111 | 0x00, /* REG_I2S_RX_SCRAMBLE_M (0x38) */ | ||
112 | 0x00, /* REG_I2S_RX_SCRAMBLE_L (0x39) */ | ||
113 | 0x06, /* REG_APLL_CTL (0x3A) */ | ||
114 | 0x00, /* REG_DTMF_CTL (0x3B) */ | ||
115 | 0x44, /* REG_DTMF_PGA_CTL2 (0x3C) */ | ||
116 | 0x69, /* REG_DTMF_PGA_CTL1 (0x3D) */ | ||
117 | 0x00, /* REG_MISC_SET_1 (0x3E) */ | ||
118 | 0x00, /* REG_PCMBTMUX (0x3F) */ | ||
119 | 0x00, /* not used (0x40) */ | ||
120 | 0x00, /* not used (0x41) */ | ||
121 | 0x00, /* not used (0x42) */ | ||
122 | 0x00, /* REG_RX_PATH_SEL (0x43) */ | ||
123 | 0x32, /* REG_VDL_APGA_CTL (0x44) */ | ||
124 | 0x00, /* REG_VIBRA_CTL (0x45) */ | ||
125 | 0x00, /* REG_VIBRA_SET (0x46) */ | ||
126 | 0x00, /* REG_VIBRA_PWM_SET (0x47) */ | ||
127 | 0x00, /* REG_ANAMIC_GAIN (0x48) */ | ||
128 | 0x00, /* REG_MISC_SET_2 (0x49) */ | ||
129 | }; | ||
130 | |||
131 | /* codec private data */ | 51 | /* codec private data */ |
132 | struct twl4030_priv { | 52 | struct twl4030_priv { |
133 | unsigned int codec_powered; | 53 | unsigned int codec_powered; |
@@ -166,31 +86,48 @@ static void tw4030_init_ctl_cache(struct twl4030_priv *twl4030) | |||
166 | } | 86 | } |
167 | } | 87 | } |
168 | 88 | ||
169 | /* | 89 | static void twl4030_update_ctl_cache(struct snd_soc_codec *codec, |
170 | * read twl4030 register cache | 90 | unsigned int reg, unsigned int value) |
171 | */ | ||
172 | static inline unsigned int twl4030_read_reg_cache(struct snd_soc_codec *codec, | ||
173 | unsigned int reg) | ||
174 | { | 91 | { |
175 | u8 *cache = codec->reg_cache; | 92 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); |
176 | |||
177 | if (reg >= TWL4030_CACHEREGNUM) | ||
178 | return -EIO; | ||
179 | 93 | ||
180 | return cache[reg]; | 94 | switch (reg) { |
95 | case TWL4030_REG_EAR_CTL: | ||
96 | case TWL4030_REG_PREDL_CTL: | ||
97 | case TWL4030_REG_PREDR_CTL: | ||
98 | case TWL4030_REG_PRECKL_CTL: | ||
99 | case TWL4030_REG_PRECKR_CTL: | ||
100 | case TWL4030_REG_HS_GAIN_SET: | ||
101 | twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL] = value; | ||
102 | break; | ||
103 | default: | ||
104 | break; | ||
105 | } | ||
181 | } | 106 | } |
182 | 107 | ||
183 | /* | 108 | static unsigned int twl4030_read(struct snd_soc_codec *codec, unsigned int reg) |
184 | * write twl4030 register cache | ||
185 | */ | ||
186 | static inline void twl4030_write_reg_cache(struct snd_soc_codec *codec, | ||
187 | u8 reg, u8 value) | ||
188 | { | 109 | { |
189 | u8 *cache = codec->reg_cache; | 110 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); |
111 | u8 value = 0; | ||
190 | 112 | ||
191 | if (reg >= TWL4030_CACHEREGNUM) | 113 | if (reg >= TWL4030_CACHEREGNUM) |
192 | return; | 114 | return -EIO; |
193 | cache[reg] = value; | 115 | |
116 | switch (reg) { | ||
117 | case TWL4030_REG_EAR_CTL: | ||
118 | case TWL4030_REG_PREDL_CTL: | ||
119 | case TWL4030_REG_PREDR_CTL: | ||
120 | case TWL4030_REG_PRECKL_CTL: | ||
121 | case TWL4030_REG_PRECKR_CTL: | ||
122 | case TWL4030_REG_HS_GAIN_SET: | ||
123 | value = twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL]; | ||
124 | break; | ||
125 | default: | ||
126 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &value, reg); | ||
127 | break; | ||
128 | } | ||
129 | |||
130 | return value; | ||
194 | } | 131 | } |
195 | 132 | ||
196 | static bool twl4030_can_write_to_chip(struct snd_soc_codec *codec, | 133 | static bool twl4030_can_write_to_chip(struct snd_soc_codec *codec, |
@@ -234,13 +171,10 @@ static bool twl4030_can_write_to_chip(struct snd_soc_codec *codec, | |||
234 | return write_to_reg; | 171 | return write_to_reg; |
235 | } | 172 | } |
236 | 173 | ||
237 | /* | ||
238 | * write to the twl4030 register space | ||
239 | */ | ||
240 | static int twl4030_write(struct snd_soc_codec *codec, | 174 | static int twl4030_write(struct snd_soc_codec *codec, |
241 | unsigned int reg, unsigned int value) | 175 | unsigned int reg, unsigned int value) |
242 | { | 176 | { |
243 | twl4030_write_reg_cache(codec, reg, value); | 177 | twl4030_update_ctl_cache(codec, reg, value); |
244 | if (twl4030_can_write_to_chip(codec, reg)) | 178 | if (twl4030_can_write_to_chip(codec, reg)) |
245 | return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, reg); | 179 | return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, reg); |
246 | 180 | ||
@@ -270,10 +204,8 @@ static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) | |||
270 | else | 204 | else |
271 | mode = twl4030_audio_disable_resource(TWL4030_AUDIO_RES_POWER); | 205 | mode = twl4030_audio_disable_resource(TWL4030_AUDIO_RES_POWER); |
272 | 206 | ||
273 | if (mode >= 0) { | 207 | if (mode >= 0) |
274 | twl4030_write_reg_cache(codec, TWL4030_REG_CODEC_MODE, mode); | ||
275 | twl4030->codec_powered = enable; | 208 | twl4030->codec_powered = enable; |
276 | } | ||
277 | 209 | ||
278 | /* REVISIT: this delay is present in TI sample drivers */ | 210 | /* REVISIT: this delay is present in TI sample drivers */ |
279 | /* but there seems to be no TRM requirement for it */ | 211 | /* but there seems to be no TRM requirement for it */ |
@@ -363,13 +295,8 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
363 | /* Initialize the local ctl register cache */ | 295 | /* Initialize the local ctl register cache */ |
364 | tw4030_init_ctl_cache(twl4030); | 296 | tw4030_init_ctl_cache(twl4030); |
365 | 297 | ||
366 | /* Refresh APLL_CTL register from HW */ | ||
367 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, | ||
368 | TWL4030_REG_APLL_CTL); | ||
369 | twl4030_write_reg_cache(codec, TWL4030_REG_APLL_CTL, byte); | ||
370 | |||
371 | /* anti-pop when changing analog gain */ | 298 | /* anti-pop when changing analog gain */ |
372 | reg = twl4030_read_reg_cache(codec, TWL4030_REG_MISC_SET_1); | 299 | reg = twl4030_read(codec, TWL4030_REG_MISC_SET_1); |
373 | twl4030_write(codec, TWL4030_REG_MISC_SET_1, | 300 | twl4030_write(codec, TWL4030_REG_MISC_SET_1, |
374 | reg | TWL4030_SMOOTH_ANAVOL_EN); | 301 | reg | TWL4030_SMOOTH_ANAVOL_EN); |
375 | 302 | ||
@@ -386,15 +313,15 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
386 | 313 | ||
387 | twl4030->pdata = pdata; | 314 | twl4030->pdata = pdata; |
388 | 315 | ||
389 | reg = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); | 316 | reg = twl4030_read(codec, TWL4030_REG_HS_POPN_SET); |
390 | reg &= ~TWL4030_RAMP_DELAY; | 317 | reg &= ~TWL4030_RAMP_DELAY; |
391 | reg |= (pdata->ramp_delay_value << 2); | 318 | reg |= (pdata->ramp_delay_value << 2); |
392 | twl4030_write_reg_cache(codec, TWL4030_REG_HS_POPN_SET, reg); | 319 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, reg); |
393 | 320 | ||
394 | /* initiate offset cancellation */ | 321 | /* initiate offset cancellation */ |
395 | twl4030_codec_enable(codec, 1); | 322 | twl4030_codec_enable(codec, 1); |
396 | 323 | ||
397 | reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); | 324 | reg = twl4030_read(codec, TWL4030_REG_ANAMICL); |
398 | reg &= ~TWL4030_OFFSET_CNCL_SEL; | 325 | reg &= ~TWL4030_OFFSET_CNCL_SEL; |
399 | reg |= pdata->offset_cncl_path; | 326 | reg |= pdata->offset_cncl_path; |
400 | twl4030_write(codec, TWL4030_REG_ANAMICL, | 327 | twl4030_write(codec, TWL4030_REG_ANAMICL, |
@@ -408,15 +335,14 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
408 | msleep(20); | 335 | msleep(20); |
409 | do { | 336 | do { |
410 | usleep_range(1000, 2000); | 337 | usleep_range(1000, 2000); |
338 | twl_set_regcache_bypass(TWL4030_MODULE_AUDIO_VOICE, true); | ||
411 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, | 339 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, |
412 | TWL4030_REG_ANAMICL); | 340 | TWL4030_REG_ANAMICL); |
341 | twl_set_regcache_bypass(TWL4030_MODULE_AUDIO_VOICE, false); | ||
413 | } while ((i++ < 100) && | 342 | } while ((i++ < 100) && |
414 | ((byte & TWL4030_CNCL_OFFSET_START) == | 343 | ((byte & TWL4030_CNCL_OFFSET_START) == |
415 | TWL4030_CNCL_OFFSET_START)); | 344 | TWL4030_CNCL_OFFSET_START)); |
416 | 345 | ||
417 | /* Make sure that the reg_cache has the same value as the HW */ | ||
418 | twl4030_write_reg_cache(codec, TWL4030_REG_ANAMICL, byte); | ||
419 | |||
420 | twl4030_codec_enable(codec, 0); | 346 | twl4030_codec_enable(codec, 0); |
421 | } | 347 | } |
422 | 348 | ||
@@ -436,9 +362,6 @@ static void twl4030_apll_enable(struct snd_soc_codec *codec, int enable) | |||
436 | status = twl4030_audio_disable_resource( | 362 | status = twl4030_audio_disable_resource( |
437 | TWL4030_AUDIO_RES_APLL); | 363 | TWL4030_AUDIO_RES_APLL); |
438 | } | 364 | } |
439 | |||
440 | if (status >= 0) | ||
441 | twl4030_write_reg_cache(codec, TWL4030_REG_APLL_CTL, status); | ||
442 | } | 365 | } |
443 | 366 | ||
444 | /* Earpiece */ | 367 | /* Earpiece */ |
@@ -661,8 +584,7 @@ static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \ | |||
661 | switch (event) { \ | 584 | switch (event) { \ |
662 | case SND_SOC_DAPM_POST_PMU: \ | 585 | case SND_SOC_DAPM_POST_PMU: \ |
663 | twl4030->pin_name##_enabled = 1; \ | 586 | twl4030->pin_name##_enabled = 1; \ |
664 | twl4030_write(w->codec, reg, \ | 587 | twl4030_write(w->codec, reg, twl4030_read(w->codec, reg)); \ |
665 | twl4030_read_reg_cache(w->codec, reg)); \ | ||
666 | break; \ | 588 | break; \ |
667 | case SND_SOC_DAPM_POST_PMD: \ | 589 | case SND_SOC_DAPM_POST_PMD: \ |
668 | twl4030->pin_name##_enabled = 0; \ | 590 | twl4030->pin_name##_enabled = 0; \ |
@@ -683,7 +605,7 @@ static void handsfree_ramp(struct snd_soc_codec *codec, int reg, int ramp) | |||
683 | { | 605 | { |
684 | unsigned char hs_ctl; | 606 | unsigned char hs_ctl; |
685 | 607 | ||
686 | hs_ctl = twl4030_read_reg_cache(codec, reg); | 608 | hs_ctl = twl4030_read(codec, reg); |
687 | 609 | ||
688 | if (ramp) { | 610 | if (ramp) { |
689 | /* HF ramp-up */ | 611 | /* HF ramp-up */ |
@@ -763,7 +685,7 @@ static int aif_event(struct snd_soc_dapm_widget *w, | |||
763 | { | 685 | { |
764 | u8 audio_if; | 686 | u8 audio_if; |
765 | 687 | ||
766 | audio_if = twl4030_read_reg_cache(w->codec, TWL4030_REG_AUDIO_IF); | 688 | audio_if = twl4030_read(w->codec, TWL4030_REG_AUDIO_IF); |
767 | switch (event) { | 689 | switch (event) { |
768 | case SND_SOC_DAPM_PRE_PMU: | 690 | case SND_SOC_DAPM_PRE_PMU: |
769 | /* Enable AIF */ | 691 | /* Enable AIF */ |
@@ -793,8 +715,8 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) | |||
793 | 8388608, 16777216, 33554432, 67108864}; | 715 | 8388608, 16777216, 33554432, 67108864}; |
794 | unsigned int delay; | 716 | unsigned int delay; |
795 | 717 | ||
796 | hs_gain = twl4030_read_reg_cache(codec, TWL4030_REG_HS_GAIN_SET); | 718 | hs_gain = twl4030_read(codec, TWL4030_REG_HS_GAIN_SET); |
797 | hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); | 719 | hs_pop = twl4030_read(codec, TWL4030_REG_HS_POPN_SET); |
798 | delay = (ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / | 720 | delay = (ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / |
799 | twl4030->sysclk) + 1; | 721 | twl4030->sysclk) + 1; |
800 | 722 | ||
@@ -1738,7 +1660,7 @@ static void twl4030_tdm_enable(struct snd_soc_codec *codec, int direction, | |||
1738 | { | 1660 | { |
1739 | u8 reg, mask; | 1661 | u8 reg, mask; |
1740 | 1662 | ||
1741 | reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION); | 1663 | reg = twl4030_read(codec, TWL4030_REG_OPTION); |
1742 | 1664 | ||
1743 | if (direction == SNDRV_PCM_STREAM_PLAYBACK) | 1665 | if (direction == SNDRV_PCM_STREAM_PLAYBACK) |
1744 | mask = TWL4030_ARXL1_VRX_EN | TWL4030_ARXR1_EN; | 1666 | mask = TWL4030_ARXL1_VRX_EN | TWL4030_ARXR1_EN; |
@@ -1767,7 +1689,7 @@ static int twl4030_startup(struct snd_pcm_substream *substream, | |||
1767 | if (twl4030->configured) | 1689 | if (twl4030->configured) |
1768 | twl4030_constraints(twl4030, twl4030->master_substream); | 1690 | twl4030_constraints(twl4030, twl4030->master_substream); |
1769 | } else { | 1691 | } else { |
1770 | if (!(twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) & | 1692 | if (!(twl4030_read(codec, TWL4030_REG_CODEC_MODE) & |
1771 | TWL4030_OPTION_1)) { | 1693 | TWL4030_OPTION_1)) { |
1772 | /* In option2 4 channel is not supported, set the | 1694 | /* In option2 4 channel is not supported, set the |
1773 | * constraint for the first stream for channels, the | 1695 | * constraint for the first stream for channels, the |
@@ -1815,8 +1737,8 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, | |||
1815 | 1737 | ||
1816 | /* If the substream has 4 channel, do the necessary setup */ | 1738 | /* If the substream has 4 channel, do the necessary setup */ |
1817 | if (params_channels(params) == 4) { | 1739 | if (params_channels(params) == 4) { |
1818 | format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); | 1740 | format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); |
1819 | mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE); | 1741 | mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE); |
1820 | 1742 | ||
1821 | /* Safety check: are we in the correct operating mode and | 1743 | /* Safety check: are we in the correct operating mode and |
1822 | * the interface is in TDM mode? */ | 1744 | * the interface is in TDM mode? */ |
@@ -1832,8 +1754,8 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, | |||
1832 | return 0; | 1754 | return 0; |
1833 | 1755 | ||
1834 | /* bit rate */ | 1756 | /* bit rate */ |
1835 | old_mode = twl4030_read_reg_cache(codec, | 1757 | old_mode = twl4030_read(codec, |
1836 | TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; | 1758 | TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; |
1837 | mode = old_mode & ~TWL4030_APLL_RATE; | 1759 | mode = old_mode & ~TWL4030_APLL_RATE; |
1838 | 1760 | ||
1839 | switch (params_rate(params)) { | 1761 | switch (params_rate(params)) { |
@@ -1874,7 +1796,7 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, | |||
1874 | } | 1796 | } |
1875 | 1797 | ||
1876 | /* sample size */ | 1798 | /* sample size */ |
1877 | old_format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); | 1799 | old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); |
1878 | format = old_format; | 1800 | format = old_format; |
1879 | format &= ~TWL4030_DATA_WIDTH; | 1801 | format &= ~TWL4030_DATA_WIDTH; |
1880 | switch (params_format(params)) { | 1802 | switch (params_format(params)) { |
@@ -1957,7 +1879,7 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
1957 | u8 old_format, format; | 1879 | u8 old_format, format; |
1958 | 1880 | ||
1959 | /* get format */ | 1881 | /* get format */ |
1960 | old_format = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); | 1882 | old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); |
1961 | format = old_format; | 1883 | format = old_format; |
1962 | 1884 | ||
1963 | /* set master/slave audio interface */ | 1885 | /* set master/slave audio interface */ |
@@ -2007,7 +1929,7 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
2007 | static int twl4030_set_tristate(struct snd_soc_dai *dai, int tristate) | 1929 | static int twl4030_set_tristate(struct snd_soc_dai *dai, int tristate) |
2008 | { | 1930 | { |
2009 | struct snd_soc_codec *codec = dai->codec; | 1931 | struct snd_soc_codec *codec = dai->codec; |
2010 | u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_AUDIO_IF); | 1932 | u8 reg = twl4030_read(codec, TWL4030_REG_AUDIO_IF); |
2011 | 1933 | ||
2012 | if (tristate) | 1934 | if (tristate) |
2013 | reg |= TWL4030_AIF_TRI_EN; | 1935 | reg |= TWL4030_AIF_TRI_EN; |
@@ -2024,7 +1946,7 @@ static void twl4030_voice_enable(struct snd_soc_codec *codec, int direction, | |||
2024 | { | 1946 | { |
2025 | u8 reg, mask; | 1947 | u8 reg, mask; |
2026 | 1948 | ||
2027 | reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION); | 1949 | reg = twl4030_read(codec, TWL4030_REG_OPTION); |
2028 | 1950 | ||
2029 | if (direction == SNDRV_PCM_STREAM_PLAYBACK) | 1951 | if (direction == SNDRV_PCM_STREAM_PLAYBACK) |
2030 | mask = TWL4030_ARXL1_VRX_EN; | 1952 | mask = TWL4030_ARXL1_VRX_EN; |
@@ -2059,7 +1981,7 @@ static int twl4030_voice_startup(struct snd_pcm_substream *substream, | |||
2059 | /* If the codec mode is not option2, the voice PCM interface is not | 1981 | /* If the codec mode is not option2, the voice PCM interface is not |
2060 | * available. | 1982 | * available. |
2061 | */ | 1983 | */ |
2062 | mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) | 1984 | mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE) |
2063 | & TWL4030_OPT_MODE; | 1985 | & TWL4030_OPT_MODE; |
2064 | 1986 | ||
2065 | if (mode != TWL4030_OPTION_2) { | 1987 | if (mode != TWL4030_OPTION_2) { |
@@ -2091,7 +2013,7 @@ static int twl4030_voice_hw_params(struct snd_pcm_substream *substream, | |||
2091 | twl4030_voice_enable(codec, substream->stream, 1); | 2013 | twl4030_voice_enable(codec, substream->stream, 1); |
2092 | 2014 | ||
2093 | /* bit rate */ | 2015 | /* bit rate */ |
2094 | old_mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) | 2016 | old_mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE) |
2095 | & ~(TWL4030_CODECPDZ); | 2017 | & ~(TWL4030_CODECPDZ); |
2096 | mode = old_mode; | 2018 | mode = old_mode; |
2097 | 2019 | ||
@@ -2154,7 +2076,7 @@ static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
2154 | u8 old_format, format; | 2076 | u8 old_format, format; |
2155 | 2077 | ||
2156 | /* get format */ | 2078 | /* get format */ |
2157 | old_format = twl4030_read_reg_cache(codec, TWL4030_REG_VOICE_IF); | 2079 | old_format = twl4030_read(codec, TWL4030_REG_VOICE_IF); |
2158 | format = old_format; | 2080 | format = old_format; |
2159 | 2081 | ||
2160 | /* set master/slave audio interface */ | 2082 | /* set master/slave audio interface */ |
@@ -2201,7 +2123,7 @@ static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
2201 | static int twl4030_voice_set_tristate(struct snd_soc_dai *dai, int tristate) | 2123 | static int twl4030_voice_set_tristate(struct snd_soc_dai *dai, int tristate) |
2202 | { | 2124 | { |
2203 | struct snd_soc_codec *codec = dai->codec; | 2125 | struct snd_soc_codec *codec = dai->codec; |
2204 | u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_VOICE_IF); | 2126 | u8 reg = twl4030_read(codec, TWL4030_REG_VOICE_IF); |
2205 | 2127 | ||
2206 | if (tristate) | 2128 | if (tristate) |
2207 | reg |= TWL4030_VIF_TRI_EN; | 2129 | reg |= TWL4030_VIF_TRI_EN; |
@@ -2304,13 +2226,10 @@ static int twl4030_soc_remove(struct snd_soc_codec *codec) | |||
2304 | static struct snd_soc_codec_driver soc_codec_dev_twl4030 = { | 2226 | static struct snd_soc_codec_driver soc_codec_dev_twl4030 = { |
2305 | .probe = twl4030_soc_probe, | 2227 | .probe = twl4030_soc_probe, |
2306 | .remove = twl4030_soc_remove, | 2228 | .remove = twl4030_soc_remove, |
2307 | .read = twl4030_read_reg_cache, | 2229 | .read = twl4030_read, |
2308 | .write = twl4030_write, | 2230 | .write = twl4030_write, |
2309 | .set_bias_level = twl4030_set_bias_level, | 2231 | .set_bias_level = twl4030_set_bias_level, |
2310 | .idle_bias_off = true, | 2232 | .idle_bias_off = true, |
2311 | .reg_cache_size = sizeof(twl4030_reg), | ||
2312 | .reg_word_size = sizeof(u8), | ||
2313 | .reg_cache_default = twl4030_reg, | ||
2314 | 2233 | ||
2315 | .controls = twl4030_snd_controls, | 2234 | .controls = twl4030_snd_controls, |
2316 | .num_controls = ARRAY_SIZE(twl4030_snd_controls), | 2235 | .num_controls = ARRAY_SIZE(twl4030_snd_controls), |