diff options
Diffstat (limited to 'sound/soc/codecs/sgtl5000.c')
-rw-r--r-- | sound/soc/codecs/sgtl5000.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 29cf7ce610f4..e182e6569bbd 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c | |||
@@ -155,18 +155,19 @@ struct sgtl5000_priv { | |||
155 | static int mic_bias_event(struct snd_soc_dapm_widget *w, | 155 | static int mic_bias_event(struct snd_soc_dapm_widget *w, |
156 | struct snd_kcontrol *kcontrol, int event) | 156 | struct snd_kcontrol *kcontrol, int event) |
157 | { | 157 | { |
158 | struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(w->codec); | 158 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); |
159 | struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); | ||
159 | 160 | ||
160 | switch (event) { | 161 | switch (event) { |
161 | case SND_SOC_DAPM_POST_PMU: | 162 | case SND_SOC_DAPM_POST_PMU: |
162 | /* change mic bias resistor */ | 163 | /* change mic bias resistor */ |
163 | snd_soc_update_bits(w->codec, SGTL5000_CHIP_MIC_CTRL, | 164 | snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, |
164 | SGTL5000_BIAS_R_MASK, | 165 | SGTL5000_BIAS_R_MASK, |
165 | sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); | 166 | sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); |
166 | break; | 167 | break; |
167 | 168 | ||
168 | case SND_SOC_DAPM_PRE_PMD: | 169 | case SND_SOC_DAPM_PRE_PMD: |
169 | snd_soc_update_bits(w->codec, SGTL5000_CHIP_MIC_CTRL, | 170 | snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, |
170 | SGTL5000_BIAS_R_MASK, 0); | 171 | SGTL5000_BIAS_R_MASK, 0); |
171 | break; | 172 | break; |
172 | } | 173 | } |
@@ -181,11 +182,12 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, | |||
181 | static int power_vag_event(struct snd_soc_dapm_widget *w, | 182 | static int power_vag_event(struct snd_soc_dapm_widget *w, |
182 | struct snd_kcontrol *kcontrol, int event) | 183 | struct snd_kcontrol *kcontrol, int event) |
183 | { | 184 | { |
185 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | ||
184 | const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP; | 186 | const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP; |
185 | 187 | ||
186 | switch (event) { | 188 | switch (event) { |
187 | case SND_SOC_DAPM_POST_PMU: | 189 | case SND_SOC_DAPM_POST_PMU: |
188 | snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, | 190 | snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, |
189 | SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); | 191 | SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); |
190 | break; | 192 | break; |
191 | 193 | ||
@@ -195,9 +197,9 @@ static int power_vag_event(struct snd_soc_dapm_widget *w, | |||
195 | * operational to prevent inadvertently starving the | 197 | * operational to prevent inadvertently starving the |
196 | * other one of them. | 198 | * other one of them. |
197 | */ | 199 | */ |
198 | if ((snd_soc_read(w->codec, SGTL5000_CHIP_ANA_POWER) & | 200 | if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) & |
199 | mask) != mask) { | 201 | mask) != mask) { |
200 | snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, | 202 | snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, |
201 | SGTL5000_VAG_POWERUP, 0); | 203 | SGTL5000_VAG_POWERUP, 0); |
202 | msleep(400); | 204 | msleep(400); |
203 | } | 205 | } |
@@ -483,21 +485,21 @@ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
483 | /* setting i2s data format */ | 485 | /* setting i2s data format */ |
484 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | 486 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
485 | case SND_SOC_DAIFMT_DSP_A: | 487 | case SND_SOC_DAIFMT_DSP_A: |
486 | i2sctl |= SGTL5000_I2S_MODE_PCM; | 488 | i2sctl |= SGTL5000_I2S_MODE_PCM << SGTL5000_I2S_MODE_SHIFT; |
487 | break; | 489 | break; |
488 | case SND_SOC_DAIFMT_DSP_B: | 490 | case SND_SOC_DAIFMT_DSP_B: |
489 | i2sctl |= SGTL5000_I2S_MODE_PCM; | 491 | i2sctl |= SGTL5000_I2S_MODE_PCM << SGTL5000_I2S_MODE_SHIFT; |
490 | i2sctl |= SGTL5000_I2S_LRALIGN; | 492 | i2sctl |= SGTL5000_I2S_LRALIGN; |
491 | break; | 493 | break; |
492 | case SND_SOC_DAIFMT_I2S: | 494 | case SND_SOC_DAIFMT_I2S: |
493 | i2sctl |= SGTL5000_I2S_MODE_I2S_LJ; | 495 | i2sctl |= SGTL5000_I2S_MODE_I2S_LJ << SGTL5000_I2S_MODE_SHIFT; |
494 | break; | 496 | break; |
495 | case SND_SOC_DAIFMT_RIGHT_J: | 497 | case SND_SOC_DAIFMT_RIGHT_J: |
496 | i2sctl |= SGTL5000_I2S_MODE_RJ; | 498 | i2sctl |= SGTL5000_I2S_MODE_RJ << SGTL5000_I2S_MODE_SHIFT; |
497 | i2sctl |= SGTL5000_I2S_LRPOL; | 499 | i2sctl |= SGTL5000_I2S_LRPOL; |
498 | break; | 500 | break; |
499 | case SND_SOC_DAIFMT_LEFT_J: | 501 | case SND_SOC_DAIFMT_LEFT_J: |
500 | i2sctl |= SGTL5000_I2S_MODE_I2S_LJ; | 502 | i2sctl |= SGTL5000_I2S_MODE_I2S_LJ << SGTL5000_I2S_MODE_SHIFT; |
501 | i2sctl |= SGTL5000_I2S_LRALIGN; | 503 | i2sctl |= SGTL5000_I2S_LRALIGN; |
502 | break; | 504 | break; |
503 | default: | 505 | default: |
@@ -1462,6 +1464,9 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, | |||
1462 | if (ret) | 1464 | if (ret) |
1463 | return ret; | 1465 | return ret; |
1464 | 1466 | ||
1467 | /* Need 8 clocks before I2C accesses */ | ||
1468 | udelay(1); | ||
1469 | |||
1465 | /* read chip information */ | 1470 | /* read chip information */ |
1466 | ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, ®); | 1471 | ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, ®); |
1467 | if (ret) | 1472 | if (ret) |