diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2010-05-26 04:38:18 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-05-31 06:08:58 -0400 |
commit | 9fdcc0f72af8801d8429a465a159d815774dbf6d (patch) | |
tree | 7c2d0ac449467722ebf0026003d9b56277255236 | |
parent | ee4ccac7cea0e4a4f44bbb109285129e1b293461 (diff) |
ASoC: TWL4030: Helper to check chip default registers
Since the twl4030 codec driver supports different version
of the PM chip, a helper function can come handy, which
can check the driver's default versus the chip values.
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 | 25 | ||||
-rw-r--r-- | sound/soc/codecs/twl4030.h | 1 |
2 files changed, 25 insertions, 1 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 08f24de406c2..30b7bbaf6aed 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -243,6 +243,25 @@ static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) | |||
243 | udelay(10); | 243 | udelay(10); |
244 | } | 244 | } |
245 | 245 | ||
246 | static inline void twl4030_check_defaults(struct snd_soc_codec *codec) | ||
247 | { | ||
248 | int i, difference = 0; | ||
249 | u8 val; | ||
250 | |||
251 | dev_dbg(codec->dev, "Checking TWL audio default configuration\n"); | ||
252 | for (i = 1; i <= TWL4030_REG_MISC_SET_2; i++) { | ||
253 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val, i); | ||
254 | if (val != twl4030_reg[i]) { | ||
255 | difference++; | ||
256 | dev_dbg(codec->dev, | ||
257 | "Reg 0x%02x: chip: 0x%02x driver: 0x%02x\n", | ||
258 | i, val, twl4030_reg[i]); | ||
259 | } | ||
260 | } | ||
261 | dev_dbg(codec->dev, "Found %d non maching registers. %s\n", | ||
262 | difference, difference ? "Not OK" : "OK"); | ||
263 | } | ||
264 | |||
246 | static void twl4030_init_chip(struct platform_device *pdev) | 265 | static void twl4030_init_chip(struct platform_device *pdev) |
247 | { | 266 | { |
248 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 267 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
@@ -252,8 +271,12 @@ static void twl4030_init_chip(struct platform_device *pdev) | |||
252 | u8 reg, byte; | 271 | u8 reg, byte; |
253 | int i = 0; | 272 | int i = 0; |
254 | 273 | ||
274 | /* Check defaults, if instructed before anything else */ | ||
275 | if (setup && setup->check_defaults) | ||
276 | twl4030_check_defaults(codec); | ||
277 | |||
255 | /* Refresh APLL_CTL register from HW */ | 278 | /* Refresh APLL_CTL register from HW */ |
256 | twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, | 279 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, |
257 | TWL4030_REG_APLL_CTL); | 280 | TWL4030_REG_APLL_CTL); |
258 | twl4030_write_reg_cache(codec, TWL4030_REG_APLL_CTL, byte); | 281 | twl4030_write_reg_cache(codec, TWL4030_REG_APLL_CTL, byte); |
259 | 282 | ||
diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h index c98e30347e87..c22542c2690c 100644 --- a/sound/soc/codecs/twl4030.h +++ b/sound/soc/codecs/twl4030.h | |||
@@ -43,6 +43,7 @@ struct twl4030_setup_data { | |||
43 | unsigned int ramp_delay_value; | 43 | unsigned int ramp_delay_value; |
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 hs_extmute:1; | 47 | unsigned int hs_extmute:1; |
47 | void (*set_hs_extmute)(int mute); | 48 | void (*set_hs_extmute)(int mute); |
48 | }; | 49 | }; |