diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2009-01-27 04:29:43 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-01-27 05:43:02 -0500 |
commit | 006f367e38fb45e2f161c0f500c74449ae63e866 (patch) | |
tree | 36693e3d314b8b789cb91071843d0dd3e4a63604 /sound/soc/codecs/twl4030.c | |
parent | fb2a2f84908460c18c3894963990518b224dd9ff (diff) |
ASoC: TWL4030: Move the twl4030_power_up and _power_down function
Move the twl4030_power_up and twl4030_power_down function
earlier to facilitate the analog bypass implementation.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r-- | sound/soc/codecs/twl4030.c | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 8fe059e3e9ab..f985bef40a39 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -184,6 +184,48 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
184 | 184 | ||
185 | } | 185 | } |
186 | 186 | ||
187 | static void twl4030_power_up(struct snd_soc_codec *codec) | ||
188 | { | ||
189 | u8 anamicl, regmisc1, byte; | ||
190 | int i = 0; | ||
191 | |||
192 | /* set CODECPDZ to turn on codec */ | ||
193 | twl4030_codec_enable(codec, 1); | ||
194 | |||
195 | /* initiate offset cancellation */ | ||
196 | anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); | ||
197 | twl4030_write(codec, TWL4030_REG_ANAMICL, | ||
198 | anamicl | TWL4030_CNCL_OFFSET_START); | ||
199 | |||
200 | /* wait for offset cancellation to complete */ | ||
201 | do { | ||
202 | /* this takes a little while, so don't slam i2c */ | ||
203 | udelay(2000); | ||
204 | twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, | ||
205 | TWL4030_REG_ANAMICL); | ||
206 | } while ((i++ < 100) && | ||
207 | ((byte & TWL4030_CNCL_OFFSET_START) == | ||
208 | TWL4030_CNCL_OFFSET_START)); | ||
209 | |||
210 | /* Make sure that the reg_cache has the same value as the HW */ | ||
211 | twl4030_write_reg_cache(codec, TWL4030_REG_ANAMICL, byte); | ||
212 | |||
213 | /* anti-pop when changing analog gain */ | ||
214 | regmisc1 = twl4030_read_reg_cache(codec, TWL4030_REG_MISC_SET_1); | ||
215 | twl4030_write(codec, TWL4030_REG_MISC_SET_1, | ||
216 | regmisc1 | TWL4030_SMOOTH_ANAVOL_EN); | ||
217 | |||
218 | /* toggle CODECPDZ as per TRM */ | ||
219 | twl4030_codec_enable(codec, 0); | ||
220 | twl4030_codec_enable(codec, 1); | ||
221 | } | ||
222 | |||
223 | static void twl4030_power_down(struct snd_soc_codec *codec) | ||
224 | { | ||
225 | /* power down */ | ||
226 | twl4030_codec_enable(codec, 0); | ||
227 | } | ||
228 | |||
187 | /* Earpiece */ | 229 | /* Earpiece */ |
188 | static const char *twl4030_earpiece_texts[] = | 230 | static const char *twl4030_earpiece_texts[] = |
189 | {"Off", "DACL1", "DACL2", "DACR1"}; | 231 | {"Off", "DACL1", "DACL2", "DACR1"}; |
@@ -922,49 +964,6 @@ static int twl4030_add_widgets(struct snd_soc_codec *codec) | |||
922 | return 0; | 964 | return 0; |
923 | } | 965 | } |
924 | 966 | ||
925 | static void twl4030_power_up(struct snd_soc_codec *codec) | ||
926 | { | ||
927 | u8 anamicl, regmisc1, byte; | ||
928 | int i = 0; | ||
929 | |||
930 | /* set CODECPDZ to turn on codec */ | ||
931 | twl4030_codec_enable(codec, 1); | ||
932 | |||
933 | /* initiate offset cancellation */ | ||
934 | anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); | ||
935 | twl4030_write(codec, TWL4030_REG_ANAMICL, | ||
936 | anamicl | TWL4030_CNCL_OFFSET_START); | ||
937 | |||
938 | |||
939 | /* wait for offset cancellation to complete */ | ||
940 | do { | ||
941 | /* this takes a little while, so don't slam i2c */ | ||
942 | udelay(2000); | ||
943 | twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, | ||
944 | TWL4030_REG_ANAMICL); | ||
945 | } while ((i++ < 100) && | ||
946 | ((byte & TWL4030_CNCL_OFFSET_START) == | ||
947 | TWL4030_CNCL_OFFSET_START)); | ||
948 | |||
949 | /* Make sure that the reg_cache has the same value as the HW */ | ||
950 | twl4030_write_reg_cache(codec, TWL4030_REG_ANAMICL, byte); | ||
951 | |||
952 | /* anti-pop when changing analog gain */ | ||
953 | regmisc1 = twl4030_read_reg_cache(codec, TWL4030_REG_MISC_SET_1); | ||
954 | twl4030_write(codec, TWL4030_REG_MISC_SET_1, | ||
955 | regmisc1 | TWL4030_SMOOTH_ANAVOL_EN); | ||
956 | |||
957 | /* toggle CODECPDZ as per TRM */ | ||
958 | twl4030_codec_enable(codec, 0); | ||
959 | twl4030_codec_enable(codec, 1); | ||
960 | } | ||
961 | |||
962 | static void twl4030_power_down(struct snd_soc_codec *codec) | ||
963 | { | ||
964 | /* power down */ | ||
965 | twl4030_codec_enable(codec, 0); | ||
966 | } | ||
967 | |||
968 | static int twl4030_set_bias_level(struct snd_soc_codec *codec, | 967 | static int twl4030_set_bias_level(struct snd_soc_codec *codec, |
969 | enum snd_soc_bias_level level) | 968 | enum snd_soc_bias_level level) |
970 | { | 969 | { |