]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'asoc/topic/sgtl5000' into asoc-next
authorMark Brown <broonie@linaro.org>
Thu, 22 Aug 2013 13:28:49 +0000 (14:28 +0100)
committerMark Brown <broonie@linaro.org>
Thu, 22 Aug 2013 13:28:49 +0000 (14:28 +0100)
1  2 
sound/soc/codecs/sgtl5000.c

index 760e8bfeacaadef370eb0ce30e1ce5ad124da295,54ca169ec27ebe78114a1e3657a678c13918f1ab..1f4093f3f3a19219318eb0f3c407d8f302ce34d3
@@@ -38,7 -38,7 +38,7 @@@
  static const struct reg_default sgtl5000_reg_defaults[] = {
        { SGTL5000_CHIP_CLK_CTRL,               0x0008 },
        { SGTL5000_CHIP_I2S_CTRL,               0x0010 },
 -      { SGTL5000_CHIP_SSS_CTRL,               0x0008 },
 +      { SGTL5000_CHIP_SSS_CTRL,               0x0010 },
        { SGTL5000_CHIP_DAC_VOL,                0x3c3c },
        { SGTL5000_CHIP_PAD_STRENGTH,           0x015f },
        { SGTL5000_CHIP_ANA_HP_CTRL,            0x1818 },
@@@ -153,8 -153,6 +153,8 @@@ static int mic_bias_event(struct snd_so
  static int power_vag_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
  {
 +      const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;
 +
        switch (event) {
        case SND_SOC_DAPM_POST_PMU:
                snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
                break;
  
        case SND_SOC_DAPM_PRE_PMD:
 -              snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
 -                      SGTL5000_VAG_POWERUP, 0);
 -              msleep(400);
 +              /*
 +               * Don't clear VAG_POWERUP, when both DAC and ADC are
 +               * operational to prevent inadvertently starving the
 +               * other one of them.
 +               */
 +              if ((snd_soc_read(w->codec, SGTL5000_CHIP_ANA_POWER) &
 +                              mask) != mask) {
 +                      snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
 +                              SGTL5000_VAG_POWERUP, 0);
 +                      msleep(400);
 +              }
                break;
        default:
                break;
@@@ -398,7 -388,7 +398,7 @@@ static const struct snd_kcontrol_new sg
        SOC_DOUBLE("Capture Volume", SGTL5000_CHIP_ANA_ADC_CTRL, 0, 4, 0xf, 0),
        SOC_SINGLE_TLV("Capture Attenuate Switch (-6dB)",
                        SGTL5000_CHIP_ANA_ADC_CTRL,
 -                      8, 2, 0, capture_6db_attenuate),
 +                      8, 1, 0, capture_6db_attenuate),
        SOC_SINGLE("Capture ZC Switch", SGTL5000_CHIP_ANA_CTRL, 1, 1, 0),
  
        SOC_DOUBLE_TLV("Headphone Playback Volume",
@@@ -654,16 -644,19 +654,19 @@@ static int sgtl5000_set_clock(struct sn
                snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
                        SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP,
                        SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP);
+               /* if using pll, clk_ctrl must be set after pll power up */
+               snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
        } else {
+               /* otherwise, clk_ctrl must be set before pll power down */
+               snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
                /* power down pll */
                snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
                        SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP,
                        0);
        }
  
-       /* if using pll, clk_ctrl must be set after pll power up */
-       snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
        return 0;
  }
  
@@@ -1480,6 -1473,7 +1483,7 @@@ static struct snd_soc_codec_driver sgtl
  static const struct regmap_config sgtl5000_regmap = {
        .reg_bits = 16,
        .val_bits = 16,
+       .reg_stride = 2,
  
        .max_register = SGTL5000_MAX_REG_OFFSET,
        .volatile_reg = sgtl5000_volatile,
@@@ -1537,9 -1531,6 +1541,9 @@@ static int sgtl5000_i2c_probe(struct i2
        if (IS_ERR(sgtl5000->mclk)) {
                ret = PTR_ERR(sgtl5000->mclk);
                dev_err(&client->dev, "Failed to get mclock: %d\n", ret);
 +              /* Defer the probe to see if the clk will be provided later */
 +              if (ret == -ENOENT)
 +                      return -EPROBE_DEFER;
                return ret;
        }