diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2010-05-26 04:38:21 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-05-31 06:08:59 -0400 |
commit | a3a29b55c70cefaac0d6fda170ccc85bd10e78bf (patch) | |
tree | 494a600fc7586f553e12d9f67adb0286bac8b770 | |
parent | 2046f175bc7b4d37e33dbce6a867be3bacf685cc (diff) |
ASoC: TWL4030: Add functionalty to reset the registers
Machine driver can instruct the codec driver to reset the
chip registers to their default values at probe time.
If machine driver does not provide setup data, then the
registers are going to be reseted to their defaults, to
be safe.
If the developer on the platform confirms that the register
reset is not needed, than it can be skipped, saving ~20ms
time in probe.
As safety measure do the register reset at remove time also.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
-rw-r--r-- | sound/soc/codecs/twl4030.c | 17 | ||||
-rw-r--r-- | sound/soc/codecs/twl4030.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 45de2aad283c..b292c2d8f2a3 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -262,6 +262,17 @@ static inline void twl4030_check_defaults(struct snd_soc_codec *codec) | |||
262 | difference, difference ? "Not OK" : "OK"); | 262 | difference, difference ? "Not OK" : "OK"); |
263 | } | 263 | } |
264 | 264 | ||
265 | static inline void twl4030_reset_registers(struct snd_soc_codec *codec) | ||
266 | { | ||
267 | int i; | ||
268 | |||
269 | /* set all audio section registers to reasonable defaults */ | ||
270 | for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++) | ||
271 | if (i != TWL4030_REG_APLL_CTL) | ||
272 | twl4030_write(codec, i, twl4030_reg[i]); | ||
273 | |||
274 | } | ||
275 | |||
265 | static void twl4030_init_chip(struct platform_device *pdev) | 276 | static void twl4030_init_chip(struct platform_device *pdev) |
266 | { | 277 | { |
267 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 278 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
@@ -275,6 +286,10 @@ static void twl4030_init_chip(struct platform_device *pdev) | |||
275 | if (setup && setup->check_defaults) | 286 | if (setup && setup->check_defaults) |
276 | twl4030_check_defaults(codec); | 287 | twl4030_check_defaults(codec); |
277 | 288 | ||
289 | /* Reset registers, if no setup data or if instructed to do so */ | ||
290 | if (!setup || (setup && setup->reset_registers)) | ||
291 | twl4030_reset_registers(codec); | ||
292 | |||
278 | /* Refresh APLL_CTL register from HW */ | 293 | /* Refresh APLL_CTL register from HW */ |
279 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, | 294 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, |
280 | TWL4030_REG_APLL_CTL); | 295 | TWL4030_REG_APLL_CTL); |
@@ -2271,6 +2286,8 @@ static int twl4030_soc_remove(struct platform_device *pdev) | |||
2271 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 2286 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
2272 | struct snd_soc_codec *codec = socdev->card->codec; | 2287 | struct snd_soc_codec *codec = socdev->card->codec; |
2273 | 2288 | ||
2289 | /* Reset registers to their chip default before leaving */ | ||
2290 | twl4030_reset_registers(codec); | ||
2274 | twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF); | 2291 | twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF); |
2275 | snd_soc_free_pcms(socdev); | 2292 | snd_soc_free_pcms(socdev); |
2276 | snd_soc_dapm_free(socdev); | 2293 | snd_soc_dapm_free(socdev); |
diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h index c22542c2690c..788e3d125099 100644 --- a/sound/soc/codecs/twl4030.h +++ b/sound/soc/codecs/twl4030.h | |||
@@ -44,6 +44,7 @@ struct twl4030_setup_data { | |||
44 | unsigned int sysclk; | 44 | unsigned int sysclk; |
45 | unsigned int offset_cncl_path; | 45 | unsigned int offset_cncl_path; |
46 | unsigned int check_defaults:1; | 46 | unsigned int check_defaults:1; |
47 | unsigned int reset_registers:1; | ||
47 | unsigned int hs_extmute:1; | 48 | unsigned int hs_extmute:1; |
48 | void (*set_hs_extmute)(int mute); | 49 | void (*set_hs_extmute)(int mute); |
49 | }; | 50 | }; |