diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2010-10-25 04:34:23 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-10-26 06:07:28 -0400 |
commit | 7e6120c57cf92f005f72c6345c0961415099881e (patch) | |
tree | 27108cc67807bcd2a6aa959d8fd3d02b47e0b04e | |
parent | 506ecbca71d07fa327dd986be1682e90885678ee (diff) |
ASoC: TWL4030: Use usleep_range when appropriate
Change the busy loop delays with usleep_range or msleep calls.
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 | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index cbebec6ba1ba..a6ceddb0bb7d 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -233,6 +233,16 @@ static int twl4030_write(struct snd_soc_codec *codec, | |||
233 | return 0; | 233 | return 0; |
234 | } | 234 | } |
235 | 235 | ||
236 | static inline void twl4030_wait_ms(int time) | ||
237 | { | ||
238 | if (time < 60) { | ||
239 | time *= 1000; | ||
240 | usleep_range(time, time + 500); | ||
241 | } else { | ||
242 | msleep(time); | ||
243 | } | ||
244 | } | ||
245 | |||
236 | static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) | 246 | static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) |
237 | { | 247 | { |
238 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); | 248 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); |
@@ -338,10 +348,14 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
338 | twl4030_write(codec, TWL4030_REG_ANAMICL, | 348 | twl4030_write(codec, TWL4030_REG_ANAMICL, |
339 | reg | TWL4030_CNCL_OFFSET_START); | 349 | reg | TWL4030_CNCL_OFFSET_START); |
340 | 350 | ||
341 | /* wait for offset cancellation to complete */ | 351 | /* |
352 | * Wait for offset cancellation to complete. | ||
353 | * Since this takes a while, do not slam the i2c. | ||
354 | * Start polling the status after ~20ms. | ||
355 | */ | ||
356 | msleep(20); | ||
342 | do { | 357 | do { |
343 | /* this takes a little while, so don't slam i2c */ | 358 | usleep_range(1000, 2000); |
344 | udelay(2000); | ||
345 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, | 359 | twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, |
346 | TWL4030_REG_ANAMICL); | 360 | TWL4030_REG_ANAMICL); |
347 | } while ((i++ < 100) && | 361 | } while ((i++ < 100) && |
@@ -725,9 +739,12 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) | |||
725 | /* Base values for ramp delay calculation: 2^19 - 2^26 */ | 739 | /* Base values for ramp delay calculation: 2^19 - 2^26 */ |
726 | unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304, | 740 | unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304, |
727 | 8388608, 16777216, 33554432, 67108864}; | 741 | 8388608, 16777216, 33554432, 67108864}; |
742 | unsigned int delay; | ||
728 | 743 | ||
729 | hs_gain = twl4030_read_reg_cache(codec, TWL4030_REG_HS_GAIN_SET); | 744 | hs_gain = twl4030_read_reg_cache(codec, TWL4030_REG_HS_GAIN_SET); |
730 | hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); | 745 | hs_pop = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); |
746 | delay = (ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / | ||
747 | twl4030->sysclk) + 1; | ||
731 | 748 | ||
732 | /* Enable external mute control, this dramatically reduces | 749 | /* Enable external mute control, this dramatically reduces |
733 | * the pop-noise */ | 750 | * the pop-noise */ |
@@ -751,16 +768,14 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) | |||
751 | hs_pop |= TWL4030_RAMP_EN; | 768 | hs_pop |= TWL4030_RAMP_EN; |
752 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); | 769 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); |
753 | /* Wait ramp delay time + 1, so the VMID can settle */ | 770 | /* Wait ramp delay time + 1, so the VMID can settle */ |
754 | mdelay((ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / | 771 | twl4030_wait_ms(delay); |
755 | twl4030->sysclk) + 1); | ||
756 | } else { | 772 | } else { |
757 | /* Headset ramp-down _not_ according to | 773 | /* Headset ramp-down _not_ according to |
758 | * the TRM, but in a way that it is working */ | 774 | * the TRM, but in a way that it is working */ |
759 | hs_pop &= ~TWL4030_RAMP_EN; | 775 | hs_pop &= ~TWL4030_RAMP_EN; |
760 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); | 776 | twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); |
761 | /* Wait ramp delay time + 1, so the VMID can settle */ | 777 | /* Wait ramp delay time + 1, so the VMID can settle */ |
762 | mdelay((ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / | 778 | twl4030_wait_ms(delay); |
763 | twl4030->sysclk) + 1); | ||
764 | /* Bypass the reg_cache to mute the headset */ | 779 | /* Bypass the reg_cache to mute the headset */ |
765 | twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | 780 | twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, |
766 | hs_gain & (~0x0f), | 781 | hs_gain & (~0x0f), |
@@ -835,7 +850,7 @@ static int digimic_event(struct snd_soc_dapm_widget *w, | |||
835 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); | 850 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); |
836 | 851 | ||
837 | if (twl4030->digimic_delay) | 852 | if (twl4030->digimic_delay) |
838 | mdelay(twl4030->digimic_delay); | 853 | twl4030_wait_ms(twl4030->digimic_delay); |
839 | return 0; | 854 | return 0; |
840 | } | 855 | } |
841 | 856 | ||