Merge series "ASoC: Intel: machine driver updates for 5.9" from Pierre-Louis Bossart...
authorMark Brown <broonie@kernel.org>
Mon, 20 Jul 2020 14:34:31 +0000 (15:34 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 20 Jul 2020 14:34:31 +0000 (15:34 +0100)
Small patchset to harden the SoundWire machine driver, change bad
HIDs, update PLL settings and avoid memory leaks. Given that the
SoundWire core parts are not upstream it's probably not necessary to
provide the patches to stable branches.

Bard Liao (1):
  ASoC: Intel: sof_sdw_rt711: remove hard-coded codec name

Kai Vehmanen (2):
  ASoC: Intel: sof_sdw: add support for systems without i915 audio
  ASoC: Intel: sof_sdw: avoid crash if invalid DSP topology loaded

Libin Yang (1):
  ASoC: Intel: common: change match table ehl-rt5660

Pierre-Louis Bossart (1):
  ASoC: Intel: sof_sdw_rt711: remove properties in card remove

Yong Zhi (1):
  ASoC: intel: board: sof_rt5682: Update rt1015 pll input clk freq

 sound/soc/intel/boards/sof_rt5682.c           |  9 +++++-
 sound/soc/intel/boards/sof_sdw.c              | 31 +++++++++++++------
 sound/soc/intel/boards/sof_sdw_common.h       |  2 ++
 sound/soc/intel/boards/sof_sdw_hdmi.c         |  6 ++++
 sound/soc/intel/boards/sof_sdw_rt711.c        | 17 +++++++++-
 .../intel/common/soc-acpi-intel-ehl-match.c   |  2 +-
 6 files changed, 54 insertions(+), 13 deletions(-)

base-commit: 22e9b54307987787efa0ee534aa9e31982ec1161
--
2.25.1

1  2 
include/sound/soc-dai.h
sound/soc/codecs/max98373.c
sound/soc/codecs/rt286.c
sound/soc/codecs/rt5682.c
sound/soc/codecs/wm8974.c
sound/soc/intel/boards/bdw-rt5677.c
sound/soc/intel/boards/bytcht_es8316.c
sound/soc/soc-dai.c

diff --combined include/sound/soc-dai.h
index 7ff659e285702d1815c5f9b82701117f8f494ab1,71e178c897932863c535f00bafb0d2111b6f9784..776a60529e70a9a638cb26f50755d71b3740c388
@@@ -39,7 -39,7 +39,7 @@@ struct snd_compr_stream
  /*
   * DAI Clock gating.
   *
 - * DAI bit clocks can be be gated (disabled) when the DAI is not
 + * DAI bit clocks can be gated (disabled) when the DAI is not
   * sending or receiving PCM data in a frame. This can be used to save power.
   */
  #define SND_SOC_DAIFMT_CONT           (1 << 4) /* continuous clock */
   *
   * This is wrt the codec, the inverse is true for the interface
   * i.e. if the codec is clk and FRM master then the interface is
 - * clk and frame slave.
 + * clk and frame secondary.
   */
  #define SND_SOC_DAIFMT_CBM_CFM                (1 << 12) /* codec clk & FRM master */
 -#define SND_SOC_DAIFMT_CBS_CFM                (2 << 12) /* codec clk slave & FRM master */
 -#define SND_SOC_DAIFMT_CBM_CFS                (3 << 12) /* codec clk master & frame slave */
 -#define SND_SOC_DAIFMT_CBS_CFS                (4 << 12) /* codec clk & FRM slave */
 +#define SND_SOC_DAIFMT_CBS_CFM                (2 << 12) /* codec clk secondary & FRM master */
 +#define SND_SOC_DAIFMT_CBM_CFS                (3 << 12) /* codec clk master & frame secondary */
 +#define SND_SOC_DAIFMT_CBS_CFS                (4 << 12) /* codec clk & FRM secondary */
  
  #define SND_SOC_DAIFMT_FORMAT_MASK    0x000f
  #define SND_SOC_DAIFMT_CLOCK_MASK     0x00f0
@@@ -161,6 -161,7 +161,7 @@@ void snd_soc_dai_resume(struct snd_soc_
  int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
                             struct snd_soc_pcm_runtime *rtd, int num);
  bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
+ void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link);
  void snd_soc_dai_action(struct snd_soc_dai *dai,
                        int stream, int action);
  static inline void snd_soc_dai_activate(struct snd_soc_dai *dai,
@@@ -246,6 -247,7 +247,6 @@@ struct snd_soc_dai_ops 
         * DAI digital mute - optional.
         * Called by soc-core to minimise any pops.
         */
 -      int (*digital_mute)(struct snd_soc_dai *dai, int mute);
        int (*mute_stream)(struct snd_soc_dai *dai, int mute, int stream);
  
        /*
         */
        snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
                struct snd_soc_dai *);
 +
 +      /* bit field */
 +      unsigned int no_capture_mute:1;
  };
  
  struct snd_soc_cdai_ops {
index 67b5faa64ec3492cde0f51d305d9d500f145cd7e,d87402a86c88006379927fa08c1dd994d0ed4703..929bb1798c43f9a5c03af199052a9682aae8ae34
  #include <sound/tlv.h>
  #include "max98373.h"
  
 -static struct reg_default max98373_reg[] = {
 -      {MAX98373_R2000_SW_RESET, 0x00},
 -      {MAX98373_R2001_INT_RAW1, 0x00},
 -      {MAX98373_R2002_INT_RAW2, 0x00},
 -      {MAX98373_R2003_INT_RAW3, 0x00},
 -      {MAX98373_R2004_INT_STATE1, 0x00},
 -      {MAX98373_R2005_INT_STATE2, 0x00},
 -      {MAX98373_R2006_INT_STATE3, 0x00},
 -      {MAX98373_R2007_INT_FLAG1, 0x00},
 -      {MAX98373_R2008_INT_FLAG2, 0x00},
 -      {MAX98373_R2009_INT_FLAG3, 0x00},
 -      {MAX98373_R200A_INT_EN1, 0x00},
 -      {MAX98373_R200B_INT_EN2, 0x00},
 -      {MAX98373_R200C_INT_EN3, 0x00},
 -      {MAX98373_R200D_INT_FLAG_CLR1, 0x00},
 -      {MAX98373_R200E_INT_FLAG_CLR2, 0x00},
 -      {MAX98373_R200F_INT_FLAG_CLR3, 0x00},
 -      {MAX98373_R2010_IRQ_CTRL, 0x00},
 -      {MAX98373_R2014_THERM_WARN_THRESH, 0x10},
 -      {MAX98373_R2015_THERM_SHDN_THRESH, 0x27},
 -      {MAX98373_R2016_THERM_HYSTERESIS, 0x01},
 -      {MAX98373_R2017_THERM_FOLDBACK_SET, 0xC0},
 -      {MAX98373_R2018_THERM_FOLDBACK_EN, 0x00},
 -      {MAX98373_R201E_PIN_DRIVE_STRENGTH, 0x55},
 -      {MAX98373_R2020_PCM_TX_HIZ_EN_1, 0xFE},
 -      {MAX98373_R2021_PCM_TX_HIZ_EN_2, 0xFF},
 -      {MAX98373_R2022_PCM_TX_SRC_1, 0x00},
 -      {MAX98373_R2023_PCM_TX_SRC_2, 0x00},
 -      {MAX98373_R2024_PCM_DATA_FMT_CFG, 0xC0},
 -      {MAX98373_R2025_AUDIO_IF_MODE, 0x00},
 -      {MAX98373_R2026_PCM_CLOCK_RATIO, 0x04},
 -      {MAX98373_R2027_PCM_SR_SETUP_1, 0x08},
 -      {MAX98373_R2028_PCM_SR_SETUP_2, 0x88},
 -      {MAX98373_R2029_PCM_TO_SPK_MONO_MIX_1, 0x00},
 -      {MAX98373_R202A_PCM_TO_SPK_MONO_MIX_2, 0x00},
 -      {MAX98373_R202B_PCM_RX_EN, 0x00},
 -      {MAX98373_R202C_PCM_TX_EN, 0x00},
 -      {MAX98373_R202E_ICC_RX_CH_EN_1, 0x00},
 -      {MAX98373_R202F_ICC_RX_CH_EN_2, 0x00},
 -      {MAX98373_R2030_ICC_TX_HIZ_EN_1, 0xFF},
 -      {MAX98373_R2031_ICC_TX_HIZ_EN_2, 0xFF},
 -      {MAX98373_R2032_ICC_LINK_EN_CFG, 0x30},
 -      {MAX98373_R2034_ICC_TX_CNTL, 0x00},
 -      {MAX98373_R2035_ICC_TX_EN, 0x00},
 -      {MAX98373_R2036_SOUNDWIRE_CTRL, 0x05},
 -      {MAX98373_R203D_AMP_DIG_VOL_CTRL, 0x00},
 -      {MAX98373_R203E_AMP_PATH_GAIN, 0x08},
 -      {MAX98373_R203F_AMP_DSP_CFG, 0x02},
 -      {MAX98373_R2040_TONE_GEN_CFG, 0x00},
 -      {MAX98373_R2041_AMP_CFG, 0x03},
 -      {MAX98373_R2042_AMP_EDGE_RATE_CFG, 0x00},
 -      {MAX98373_R2043_AMP_EN, 0x00},
 -      {MAX98373_R2046_IV_SENSE_ADC_DSP_CFG, 0x04},
 -      {MAX98373_R2047_IV_SENSE_ADC_EN, 0x00},
 -      {MAX98373_R2051_MEAS_ADC_SAMPLING_RATE, 0x00},
 -      {MAX98373_R2052_MEAS_ADC_PVDD_FLT_CFG, 0x00},
 -      {MAX98373_R2053_MEAS_ADC_THERM_FLT_CFG, 0x00},
 -      {MAX98373_R2054_MEAS_ADC_PVDD_CH_READBACK, 0x00},
 -      {MAX98373_R2055_MEAS_ADC_THERM_CH_READBACK, 0x00},
 -      {MAX98373_R2056_MEAS_ADC_PVDD_CH_EN, 0x00},
 -      {MAX98373_R2090_BDE_LVL_HOLD, 0x00},
 -      {MAX98373_R2091_BDE_GAIN_ATK_REL_RATE, 0x00},
 -      {MAX98373_R2092_BDE_CLIPPER_MODE, 0x00},
 -      {MAX98373_R2097_BDE_L1_THRESH, 0x00},
 -      {MAX98373_R2098_BDE_L2_THRESH, 0x00},
 -      {MAX98373_R2099_BDE_L3_THRESH, 0x00},
 -      {MAX98373_R209A_BDE_L4_THRESH, 0x00},
 -      {MAX98373_R209B_BDE_THRESH_HYST, 0x00},
 -      {MAX98373_R20A8_BDE_L1_CFG_1, 0x00},
 -      {MAX98373_R20A9_BDE_L1_CFG_2, 0x00},
 -      {MAX98373_R20AA_BDE_L1_CFG_3, 0x00},
 -      {MAX98373_R20AB_BDE_L2_CFG_1, 0x00},
 -      {MAX98373_R20AC_BDE_L2_CFG_2, 0x00},
 -      {MAX98373_R20AD_BDE_L2_CFG_3, 0x00},
 -      {MAX98373_R20AE_BDE_L3_CFG_1, 0x00},
 -      {MAX98373_R20AF_BDE_L3_CFG_2, 0x00},
 -      {MAX98373_R20B0_BDE_L3_CFG_3, 0x00},
 -      {MAX98373_R20B1_BDE_L4_CFG_1, 0x00},
 -      {MAX98373_R20B2_BDE_L4_CFG_2, 0x00},
 -      {MAX98373_R20B3_BDE_L4_CFG_3, 0x00},
 -      {MAX98373_R20B4_BDE_INFINITE_HOLD_RELEASE, 0x00},
 -      {MAX98373_R20B5_BDE_EN, 0x00},
 -      {MAX98373_R20B6_BDE_CUR_STATE_READBACK, 0x00},
 -      {MAX98373_R20D1_DHT_CFG, 0x01},
 -      {MAX98373_R20D2_DHT_ATTACK_CFG, 0x02},
 -      {MAX98373_R20D3_DHT_RELEASE_CFG, 0x03},
 -      {MAX98373_R20D4_DHT_EN, 0x00},
 -      {MAX98373_R20E0_LIMITER_THRESH_CFG, 0x00},
 -      {MAX98373_R20E1_LIMITER_ATK_REL_RATES, 0x00},
 -      {MAX98373_R20E2_LIMITER_EN, 0x00},
 -      {MAX98373_R20FE_DEVICE_AUTO_RESTART_CFG, 0x00},
 -      {MAX98373_R20FF_GLOBAL_SHDN, 0x00},
 -      {MAX98373_R21FF_REV_ID, 0x42},
 -};
 -
 -static int max98373_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 -{
 -      struct snd_soc_component *component = codec_dai->component;
 -      struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component);
 -      unsigned int format = 0;
 -      unsigned int invert = 0;
 -
 -      dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt);
 -
 -      switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
 -      case SND_SOC_DAIFMT_NB_NF:
 -              break;
 -      case SND_SOC_DAIFMT_IB_NF:
 -              invert = MAX98373_PCM_MODE_CFG_PCM_BCLKEDGE;
 -              break;
 -      default:
 -              dev_err(component->dev, "DAI invert mode unsupported\n");
 -              return -EINVAL;
 -      }
 -
 -      regmap_update_bits(max98373->regmap,
 -              MAX98373_R2026_PCM_CLOCK_RATIO,
 -              MAX98373_PCM_MODE_CFG_PCM_BCLKEDGE,
 -              invert);
 -
 -      /* interface format */
 -      switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 -      case SND_SOC_DAIFMT_I2S:
 -              format = MAX98373_PCM_FORMAT_I2S;
 -              break;
 -      case SND_SOC_DAIFMT_LEFT_J:
 -              format = MAX98373_PCM_FORMAT_LJ;
 -              break;
 -      case SND_SOC_DAIFMT_DSP_A:
 -              format = MAX98373_PCM_FORMAT_TDM_MODE1;
 -              break;
 -      case SND_SOC_DAIFMT_DSP_B:
 -              format = MAX98373_PCM_FORMAT_TDM_MODE0;
 -              break;
 -      default:
 -              return -EINVAL;
 -      }
 -
 -      regmap_update_bits(max98373->regmap,
 -              MAX98373_R2024_PCM_DATA_FMT_CFG,
 -              MAX98373_PCM_MODE_CFG_FORMAT_MASK,
 -              format << MAX98373_PCM_MODE_CFG_FORMAT_SHIFT);
 -
 -      return 0;
 -}
 -
 -/* BCLKs per LRCLK */
 -static const int bclk_sel_table[] = {
 -      32, 48, 64, 96, 128, 192, 256, 384, 512, 320,
 -};
 -
 -static int max98373_get_bclk_sel(int bclk)
 -{
 -      int i;
 -      /* match BCLKs per LRCLK */
 -      for (i = 0; i < ARRAY_SIZE(bclk_sel_table); i++) {
 -              if (bclk_sel_table[i] == bclk)
 -                      return i + 2;
 -      }
 -      return 0;
 -}
 -
 -static int max98373_set_clock(struct snd_soc_component *component,
 -      struct snd_pcm_hw_params *params)
 -{
 -      struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component);
 -      /* BCLK/LRCLK ratio calculation */
 -      int blr_clk_ratio = params_channels(params) * max98373->ch_size;
 -      int value;
 -
 -      if (!max98373->tdm_mode) {
 -              /* BCLK configuration */
 -              value = max98373_get_bclk_sel(blr_clk_ratio);
 -              if (!value) {
 -                      dev_err(component->dev, "format unsupported %d\n",
 -                              params_format(params));
 -                      return -EINVAL;
 -              }
 -
 -              regmap_update_bits(max98373->regmap,
 -                      MAX98373_R2026_PCM_CLOCK_RATIO,
 -                      MAX98373_PCM_CLK_SETUP_BSEL_MASK,
 -                      value);
 -      }
 -      return 0;
 -}
 -
 -static int max98373_dai_hw_params(struct snd_pcm_substream *substream,
 -      struct snd_pcm_hw_params *params,
 -      struct snd_soc_dai *dai)
 -{
 -      struct snd_soc_component *component = dai->component;
 -      struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component);
 -      unsigned int sampling_rate = 0;
 -      unsigned int chan_sz = 0;
 -
 -      /* pcm mode configuration */
 -      switch (snd_pcm_format_width(params_format(params))) {
 -      case 16:
 -              chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_16;
 -              break;
 -      case 24:
 -              chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_24;
 -              break;
 -      case 32:
 -              chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_32;
 -              break;
 -      default:
 -              dev_err(component->dev, "format unsupported %d\n",
 -                      params_format(params));
 -              goto err;
 -      }
 -
 -      max98373->ch_size = snd_pcm_format_width(params_format(params));
 -
 -      regmap_update_bits(max98373->regmap,
 -              MAX98373_R2024_PCM_DATA_FMT_CFG,
 -              MAX98373_PCM_MODE_CFG_CHANSZ_MASK, chan_sz);
 -
 -      dev_dbg(component->dev, "format supported %d",
 -              params_format(params));
 -
 -      /* sampling rate configuration */
 -      switch (params_rate(params)) {
 -      case 8000:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_8000;
 -              break;
 -      case 11025:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_11025;
 -              break;
 -      case 12000:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_12000;
 -              break;
 -      case 16000:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_16000;
 -              break;
 -      case 22050:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_22050;
 -              break;
 -      case 24000:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_24000;
 -              break;
 -      case 32000:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_32000;
 -              break;
 -      case 44100:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_44100;
 -              break;
 -      case 48000:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_48000;
 -              break;
 -      case 88200:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_88200;
 -              break;
 -      case 96000:
 -              sampling_rate = MAX98373_PCM_SR_SET1_SR_96000;
 -              break;
 -      default:
 -              dev_err(component->dev, "rate %d not supported\n",
 -                      params_rate(params));
 -              goto err;
 -      }
 -
 -      /* set DAI_SR to correct LRCLK frequency */
 -      regmap_update_bits(max98373->regmap,
 -              MAX98373_R2027_PCM_SR_SETUP_1,
 -              MAX98373_PCM_SR_SET1_SR_MASK,
 -              sampling_rate);
 -      regmap_update_bits(max98373->regmap,
 -              MAX98373_R2028_PCM_SR_SETUP_2,
 -              MAX98373_PCM_SR_SET2_SR_MASK,
 -              sampling_rate << MAX98373_PCM_SR_SET2_SR_SHIFT);
 -
 -      /* set sampling rate of IV */
 -      if (max98373->interleave_mode &&
 -          sampling_rate > MAX98373_PCM_SR_SET1_SR_16000)
 -              regmap_update_bits(max98373->regmap,
 -                      MAX98373_R2028_PCM_SR_SETUP_2,
 -                      MAX98373_PCM_SR_SET2_IVADC_SR_MASK,
 -                      sampling_rate - 3);
 -      else
 -              regmap_update_bits(max98373->regmap,
 -                      MAX98373_R2028_PCM_SR_SETUP_2,
 -                      MAX98373_PCM_SR_SET2_IVADC_SR_MASK,
 -                      sampling_rate);
 -
 -      return max98373_set_clock(component, params);
 -err:
 -      return -EINVAL;
 -}
 -
 -static int max98373_dai_tdm_slot(struct snd_soc_dai *dai,
 -      unsigned int tx_mask, unsigned int rx_mask,
 -      int slots, int slot_width)
 -{
 -      struct snd_soc_component *component = dai->component;
 -      struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component);
 -      int bsel = 0;
 -      unsigned int chan_sz = 0;
 -      unsigned int mask;
 -      int x, slot_found;
 -
 -      if (!tx_mask && !rx_mask && !slots && !slot_width)
 -              max98373->tdm_mode = false;
 -      else
 -              max98373->tdm_mode = true;
 -
 -      /* BCLK configuration */
 -      bsel = max98373_get_bclk_sel(slots * slot_width);
 -      if (bsel == 0) {
 -              dev_err(component->dev, "BCLK %d not supported\n",
 -                      slots * slot_width);
 -              return -EINVAL;
 -      }
 -
 -      regmap_update_bits(max98373->regmap,
 -              MAX98373_R2026_PCM_CLOCK_RATIO,
 -              MAX98373_PCM_CLK_SETUP_BSEL_MASK,
 -              bsel);
 -
 -      /* Channel size configuration */
 -      switch (slot_width) {
 -      case 16:
 -              chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_16;
 -              break;
 -      case 24:
 -              chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_24;
 -              break;
 -      case 32:
 -              chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_32;
 -              break;
 -      default:
 -              dev_err(component->dev, "format unsupported %d\n",
 -                      slot_width);
 -              return -EINVAL;
 -      }
 -
 -      regmap_update_bits(max98373->regmap,
 -              MAX98373_R2024_PCM_DATA_FMT_CFG,
 -              MAX98373_PCM_MODE_CFG_CHANSZ_MASK, chan_sz);
 -
 -      /* Rx slot configuration */
 -      slot_found = 0;
 -      mask = rx_mask;
 -      for (x = 0 ; x < 16 ; x++, mask >>= 1) {
 -              if (mask & 0x1) {
 -                      if (slot_found == 0)
 -                              regmap_update_bits(max98373->regmap,
 -                                      MAX98373_R2029_PCM_TO_SPK_MONO_MIX_1,
 -                                      MAX98373_PCM_TO_SPK_CH0_SRC_MASK, x);
 -                      else
 -                              regmap_write(max98373->regmap,
 -                                      MAX98373_R202A_PCM_TO_SPK_MONO_MIX_2,
 -                                      x);
 -                      slot_found++;
 -                      if (slot_found > 1)
 -                              break;
 -              }
 -      }
 -
 -      /* Tx slot Hi-Z configuration */
 -      regmap_write(max98373->regmap,
 -              MAX98373_R2020_PCM_TX_HIZ_EN_1,
 -              ~tx_mask & 0xFF);
 -      regmap_write(max98373->regmap,
 -              MAX98373_R2021_PCM_TX_HIZ_EN_2,
 -              (~tx_mask & 0xFF00) >> 8);
 -
 -      return 0;
 -}
 -
 -#define MAX98373_RATES SNDRV_PCM_RATE_8000_96000
 -
 -#define MAX98373_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
 -      SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
 -
 -static const struct snd_soc_dai_ops max98373_dai_ops = {
 -      .set_fmt = max98373_dai_set_fmt,
 -      .hw_params = max98373_dai_hw_params,
 -      .set_tdm_slot = max98373_dai_tdm_slot,
 -};
 -
  static int max98373_dac_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
  {
@@@ -111,6 -493,52 +111,6 @@@ static const DECLARE_TLV_DB_RANGE(max98
        0, 60, TLV_DB_SCALE_ITEM(-1500, 25, 0),
  );
  
 -static bool max98373_readable_register(struct device *dev, unsigned int reg)
 -{
 -      switch (reg) {
 -      case MAX98373_R2000_SW_RESET:
 -      case MAX98373_R2001_INT_RAW1 ... MAX98373_R200C_INT_EN3:
 -      case MAX98373_R2010_IRQ_CTRL:
 -      case MAX98373_R2014_THERM_WARN_THRESH
 -              ... MAX98373_R2018_THERM_FOLDBACK_EN:
 -      case MAX98373_R201E_PIN_DRIVE_STRENGTH
 -              ... MAX98373_R2036_SOUNDWIRE_CTRL:
 -      case MAX98373_R203D_AMP_DIG_VOL_CTRL ... MAX98373_R2043_AMP_EN:
 -      case MAX98373_R2046_IV_SENSE_ADC_DSP_CFG
 -              ... MAX98373_R2047_IV_SENSE_ADC_EN:
 -      case MAX98373_R2051_MEAS_ADC_SAMPLING_RATE
 -              ... MAX98373_R2056_MEAS_ADC_PVDD_CH_EN:
 -      case MAX98373_R2090_BDE_LVL_HOLD ... MAX98373_R2092_BDE_CLIPPER_MODE:
 -      case MAX98373_R2097_BDE_L1_THRESH
 -              ... MAX98373_R209B_BDE_THRESH_HYST:
 -      case MAX98373_R20A8_BDE_L1_CFG_1 ... MAX98373_R20B3_BDE_L4_CFG_3:
 -      case MAX98373_R20B5_BDE_EN ... MAX98373_R20B6_BDE_CUR_STATE_READBACK:
 -      case MAX98373_R20D1_DHT_CFG ... MAX98373_R20D4_DHT_EN:
 -      case MAX98373_R20E0_LIMITER_THRESH_CFG ... MAX98373_R20E2_LIMITER_EN:
 -      case MAX98373_R20FE_DEVICE_AUTO_RESTART_CFG
 -              ... MAX98373_R20FF_GLOBAL_SHDN:
 -      case MAX98373_R21FF_REV_ID:
 -              return true;
 -      default:
 -              return false;
 -      }
 -};
 -
 -static bool max98373_volatile_reg(struct device *dev, unsigned int reg)
 -{
 -      switch (reg) {
 -      case MAX98373_R2000_SW_RESET ... MAX98373_R2009_INT_FLAG3:
 -      case MAX98373_R203E_AMP_PATH_GAIN:
 -      case MAX98373_R2054_MEAS_ADC_PVDD_CH_READBACK:
 -      case MAX98373_R2055_MEAS_ADC_THERM_CH_READBACK:
 -      case MAX98373_R20B6_BDE_CUR_STATE_READBACK:
 -      case MAX98373_R21FF_REV_ID:
 -              return true;
 -      default:
 -              return false;
 -      }
 -}
 -
  static const char * const max98373_output_voltage_lvl_text[] = {
        "5.43V", "6.09V", "6.83V", "7.67V", "8.60V",
        "9.65V", "10.83V", "12.15V", "13.63V", "15.29V"
@@@ -282,7 -710,28 +282,7 @@@ static const struct snd_soc_dapm_route 
        { "Speaker FB Sense", NULL, "SpkFB Sense" },
  };
  
 -static struct snd_soc_dai_driver max98373_dai[] = {
 -      {
 -              .name = "max98373-aif1",
 -              .playback = {
 -                      .stream_name = "HiFi Playback",
 -                      .channels_min = 1,
 -                      .channels_max = 2,
 -                      .rates = MAX98373_RATES,
 -                      .formats = MAX98373_FORMATS,
 -              },
 -              .capture = {
 -                      .stream_name = "HiFi Capture",
 -                      .channels_min = 1,
 -                      .channels_max = 2,
 -                      .rates = MAX98373_RATES,
 -                      .formats = MAX98373_FORMATS,
 -              },
 -              .ops = &max98373_dai_ops,
 -      }
 -};
 -
 -static void max98373_reset(struct max98373_priv *max98373, struct device *dev)
 +void max98373_reset(struct max98373_priv *max98373, struct device *dev)
  {
        int ret, reg, count;
  
        }
        dev_err(dev, "Reset failed. (ret:%d)\n", ret);
  }
 +EXPORT_SYMBOL_GPL(max98373_reset);
  
  static int max98373_probe(struct snd_soc_component *component)
  {
        regmap_write(max98373->regmap,
                MAX98373_R202A_PCM_TO_SPK_MONO_MIX_2,
                0x1);
-       /* Set inital volume (0dB) */
-       regmap_write(max98373->regmap,
-               MAX98373_R203D_AMP_DIG_VOL_CTRL,
-               0x00);
-       regmap_write(max98373->regmap,
-               MAX98373_R203E_AMP_PATH_GAIN,
-               0x00);
        /* Enable DC blocker */
        regmap_write(max98373->regmap,
                MAX98373_R203F_AMP_DSP_CFG,
        return 0;
  }
  
 -#ifdef CONFIG_PM_SLEEP
 -static int max98373_suspend(struct device *dev)
 -{
 -      struct max98373_priv *max98373 = dev_get_drvdata(dev);
 -
 -      regcache_cache_only(max98373->regmap, true);
 -      regcache_mark_dirty(max98373->regmap);
 -      return 0;
 -}
 -static int max98373_resume(struct device *dev)
 -{
 -      struct max98373_priv *max98373 = dev_get_drvdata(dev);
 -
 -      regcache_cache_only(max98373->regmap, false);
 -      max98373_reset(max98373, dev);
 -      regcache_sync(max98373->regmap);
 -      return 0;
 -}
 -#endif
 -
 -static const struct dev_pm_ops max98373_pm = {
 -      SET_SYSTEM_SLEEP_PM_OPS(max98373_suspend, max98373_resume)
 -};
 -
 -static const struct snd_soc_component_driver soc_codec_dev_max98373 = {
 +const struct snd_soc_component_driver soc_codec_dev_max98373 = {
        .probe                  = max98373_probe,
        .controls               = max98373_snd_controls,
        .num_controls           = ARRAY_SIZE(max98373_snd_controls),
        .num_dapm_widgets       = ARRAY_SIZE(max98373_dapm_widgets),
        .dapm_routes            = max98373_audio_map,
        .num_dapm_routes        = ARRAY_SIZE(max98373_audio_map),
-       .idle_bias_on           = 1,
        .use_pmdown_time        = 1,
        .endianness             = 1,
        .non_legacy_dai_naming  = 1,
  };
 +EXPORT_SYMBOL_GPL(soc_codec_dev_max98373);
  
 -static const struct regmap_config max98373_regmap = {
 -      .reg_bits = 16,
 -      .val_bits = 8,
 -      .max_register = MAX98373_R21FF_REV_ID,
 -      .reg_defaults  = max98373_reg,
 -      .num_reg_defaults = ARRAY_SIZE(max98373_reg),
 -      .readable_reg = max98373_readable_register,
 -      .volatile_reg = max98373_volatile_reg,
 -      .cache_type = REGCACHE_RBTREE,
 +const struct snd_soc_component_driver soc_codec_dev_max98373_sdw = {
 +      .probe                  = NULL,
 +      .controls               = max98373_snd_controls,
 +      .num_controls           = ARRAY_SIZE(max98373_snd_controls),
 +      .dapm_widgets           = max98373_dapm_widgets,
 +      .num_dapm_widgets       = ARRAY_SIZE(max98373_dapm_widgets),
 +      .dapm_routes            = max98373_audio_map,
 +      .num_dapm_routes        = ARRAY_SIZE(max98373_audio_map),
 +      .use_pmdown_time        = 1,
 +      .endianness             = 1,
 +      .non_legacy_dai_naming  = 1,
  };
 +EXPORT_SYMBOL_GPL(soc_codec_dev_max98373_sdw);
  
 -static void max98373_slot_config(struct i2c_client *i2c,
 -      struct max98373_priv *max98373)
 +void max98373_slot_config(struct device *dev,
 +                        struct max98373_priv *max98373)
  {
        int value;
 -      struct device *dev = &i2c->dev;
  
        if (!device_property_read_u32(dev, "maxim,vmon-slot-no", &value))
                max98373->v_slot = value & 0xF;
        else
                max98373->spkfb_slot = 2;
  }
 -
 -static int max98373_i2c_probe(struct i2c_client *i2c,
 -      const struct i2c_device_id *id)
 -{
 -
 -      int ret = 0;
 -      int reg = 0;
 -      struct max98373_priv *max98373 = NULL;
 -
 -      max98373 = devm_kzalloc(&i2c->dev, sizeof(*max98373), GFP_KERNEL);
 -
 -      if (!max98373) {
 -              ret = -ENOMEM;
 -              return ret;
 -      }
 -      i2c_set_clientdata(i2c, max98373);
 -
 -      /* update interleave mode info */
 -      if (device_property_read_bool(&i2c->dev, "maxim,interleave_mode"))
 -              max98373->interleave_mode = true;
 -      else
 -              max98373->interleave_mode = false;
 -
 -      /* regmap initialization */
 -      max98373->regmap
 -              = devm_regmap_init_i2c(i2c, &max98373_regmap);
 -      if (IS_ERR(max98373->regmap)) {
 -              ret = PTR_ERR(max98373->regmap);
 -              dev_err(&i2c->dev,
 -                      "Failed to allocate regmap: %d\n", ret);
 -              return ret;
 -      }
 -
 -      /* voltage/current slot & gpio configuration */
 -      max98373_slot_config(i2c, max98373);
 -
 -      /* Power on device */
 -      if (gpio_is_valid(max98373->reset_gpio)) {
 -              ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio,
 -                                      "MAX98373_RESET");
 -              if (ret) {
 -                      dev_err(&i2c->dev, "%s: Failed to request gpio %d\n",
 -                              __func__, max98373->reset_gpio);
 -                      return -EINVAL;
 -              }
 -              gpio_direction_output(max98373->reset_gpio, 0);
 -              msleep(50);
 -              gpio_direction_output(max98373->reset_gpio, 1);
 -              msleep(20);
 -      }
 -
 -      /* Check Revision ID */
 -      ret = regmap_read(max98373->regmap,
 -              MAX98373_R21FF_REV_ID, &reg);
 -      if (ret < 0) {
 -              dev_err(&i2c->dev,
 -                      "Failed to read: 0x%02X\n", MAX98373_R21FF_REV_ID);
 -              return ret;
 -      }
 -      dev_info(&i2c->dev, "MAX98373 revisionID: 0x%02X\n", reg);
 -
 -      /* codec registeration */
 -      ret = devm_snd_soc_register_component(&i2c->dev, &soc_codec_dev_max98373,
 -              max98373_dai, ARRAY_SIZE(max98373_dai));
 -      if (ret < 0)
 -              dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
 -
 -      return ret;
 -}
 -
 -static const struct i2c_device_id max98373_i2c_id[] = {
 -      { "max98373", 0},
 -      { },
 -};
 -
 -MODULE_DEVICE_TABLE(i2c, max98373_i2c_id);
 -
 -#if defined(CONFIG_OF)
 -static const struct of_device_id max98373_of_match[] = {
 -      { .compatible = "maxim,max98373", },
 -      { }
 -};
 -MODULE_DEVICE_TABLE(of, max98373_of_match);
 -#endif
 -
 -#ifdef CONFIG_ACPI
 -static const struct acpi_device_id max98373_acpi_match[] = {
 -      { "MX98373", 0 },
 -      {},
 -};
 -MODULE_DEVICE_TABLE(acpi, max98373_acpi_match);
 -#endif
 -
 -static struct i2c_driver max98373_i2c_driver = {
 -      .driver = {
 -              .name = "max98373",
 -              .of_match_table = of_match_ptr(max98373_of_match),
 -              .acpi_match_table = ACPI_PTR(max98373_acpi_match),
 -              .pm = &max98373_pm,
 -      },
 -      .probe = max98373_i2c_probe,
 -      .id_table = max98373_i2c_id,
 -};
 -
 -module_i2c_driver(max98373_i2c_driver)
 +EXPORT_SYMBOL_GPL(max98373_slot_config);
  
  MODULE_DESCRIPTION("ALSA SoC MAX98373 driver");
  MODULE_AUTHOR("Ryan Lee <ryans.lee@maximintegrated.com>");
diff --combined sound/soc/codecs/rt286.c
index 89b1c8b680047519c6f44dc5762bcb47920103b4,e8d14eefc41bb973d09a1b48a84418a49f47f77a..5fb9653d9131f313d0b4f4c00bf6107be9f9f7a4
@@@ -272,13 -272,13 +272,13 @@@ static int rt286_jack_detect(struct rt2
                regmap_read(rt286->regmap, RT286_GET_MIC1_SENSE, &buf);
                *mic = buf & 0x80000000;
        }
-       if (!*mic) {
+       if (!*hp) {
                snd_soc_dapm_disable_pin(dapm, "HV");
                snd_soc_dapm_disable_pin(dapm, "VREF");
-       }
-       if (!*hp)
                snd_soc_dapm_disable_pin(dapm, "LDO1");
-       snd_soc_dapm_sync(dapm);
+               snd_soc_dapm_sync(dapm);
+       }
  
        return 0;
  }
@@@ -1079,13 -1079,11 +1079,13 @@@ static const struct i2c_device_id rt286
  };
  MODULE_DEVICE_TABLE(i2c, rt286_i2c_id);
  
 +#ifdef CONFIG_ACPI
  static const struct acpi_device_id rt286_acpi_match[] = {
        { "INT343A", 0 },
        {},
  };
  MODULE_DEVICE_TABLE(acpi, rt286_acpi_match);
 +#endif
  
  static const struct dmi_system_id force_combo_jack_table[] = {
        {
index fab066a75ce0254772709024cc747697a9540509,d503b5bef4ba9ba62dc33c48a2660c6d2d652593..a4713bd6508d52bfed3087a97d96bd1e425fa202
@@@ -859,7 -859,7 +859,7 @@@ static int rt5682_button_detect(struct 
  {
        int btn_type, val;
  
 -      val = snd_soc_component_read32(component, RT5682_4BTN_IL_CMD_1);
 +      val = snd_soc_component_read(component, RT5682_4BTN_IL_CMD_1);
        btn_type = val & 0xfff0;
        snd_soc_component_write(component, RT5682_4BTN_IL_CMD_1, val);
        dev_dbg(component->dev, "%s btn_type=%x\n", __func__, btn_type);
@@@ -939,11 -939,11 +939,11 @@@ int rt5682_headset_detect(struct snd_so
                        RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_HIGH);
  
                count = 0;
 -              val = snd_soc_component_read32(component, RT5682_CBJ_CTRL_2)
 +              val = snd_soc_component_read(component, RT5682_CBJ_CTRL_2)
                        & RT5682_JACK_TYPE_MASK;
                while (val == 0 && count < 50) {
                        usleep_range(10000, 15000);
 -                      val = snd_soc_component_read32(component,
 +                      val = snd_soc_component_read(component,
                                RT5682_CBJ_CTRL_2) & RT5682_JACK_TYPE_MASK;
                        count++;
                }
                        RT5682_HP_CHARGE_PUMP_1,
                        RT5682_OSW_L_MASK | RT5682_OSW_R_MASK,
                        RT5682_OSW_L_EN | RT5682_OSW_R_EN);
 +              snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
 +                      RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
 +                      RT5682_PWR_CLK25M_PU | RT5682_PWR_CLK1M_PU);
        } else {
                rt5682_enable_push_button_irq(component, false);
                snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
                        RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW);
-               if (snd_soc_dapm_get_pin_status(dapm, "MICBIAS"))
+               if (!snd_soc_dapm_get_pin_status(dapm, "MICBIAS"))
                        snd_soc_component_update_bits(component,
-                               RT5682_PWR_ANLG_1, RT5682_PWR_VREF2, 0);
-               else
+                               RT5682_PWR_ANLG_1, RT5682_PWR_MB, 0);
+               if (!snd_soc_dapm_get_pin_status(dapm, "Vref2"))
                        snd_soc_component_update_bits(component,
-                               RT5682_PWR_ANLG_1,
-                               RT5682_PWR_VREF2 | RT5682_PWR_MB, 0);
+                               RT5682_PWR_ANLG_1, RT5682_PWR_VREF2, 0);
                snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
                        RT5682_PWR_CBJ, 0);
 +              snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
 +                      RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
 +                      RT5682_PWR_CLK25M_PD | RT5682_PWR_CLK1M_PD);
  
                rt5682->jack_type = 0;
        }
@@@ -1029,7 -1022,8 +1028,7 @@@ static int rt5682_set_jack_detect(struc
                                RT5682_POW_ANA, RT5682_POW_IRQ |
                                RT5682_POW_JDH | RT5682_POW_ANA);
                        regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_2,
 -                              RT5682_PWR_JDH | RT5682_PWR_JDL,
 -                              RT5682_PWR_JDH | RT5682_PWR_JDL);
 +                              RT5682_PWR_JDH, RT5682_PWR_JDH);
                        regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
                                RT5682_JD1_EN_MASK | RT5682_JD1_POL_MASK,
                                RT5682_JD1_EN | RT5682_JD1_POL_NOR);
@@@ -1080,7 -1074,7 +1079,7 @@@ void rt5682_jack_detect_handler(struct 
  
        mutex_lock(&rt5682->calibrate_mutex);
  
 -      val = snd_soc_component_read32(rt5682->component, RT5682_AJD1_CTRL)
 +      val = snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL)
                & RT5682_JDH_RS_MASK;
        if (!val) {
                /* jack in */
                        /* jack was out, report jack type */
                        rt5682->jack_type =
                                rt5682_headset_detect(rt5682->component, 1);
-               } else {
+               } else if ((rt5682->jack_type & SND_JACK_HEADSET) ==
+                       SND_JACK_HEADSET) {
                        /* jack is already in, report button event */
                        rt5682->jack_type = SND_JACK_HEADSET;
                        btn_type = rt5682_button_detect(rt5682->component);
@@@ -1245,7 -1240,7 +1245,7 @@@ static int set_filter_clk(struct snd_so
        if (rt5682->is_sdw)
                return 0;
  
 -      val = snd_soc_component_read32(component, RT5682_GPIO_CTRL_1) &
 +      val = snd_soc_component_read(component, RT5682_GPIO_CTRL_1) &
                RT5682_GP4_PIN_MASK;
        if (w->shift == RT5682_PWR_ADC_S1F_BIT &&
                val == RT5682_GP4_PIN_ADCDAT2)
@@@ -1283,7 -1278,7 +1283,7 @@@ static int is_sys_clk_from_pll1(struct 
        struct snd_soc_component *component =
                snd_soc_dapm_to_component(w->dapm);
  
 -      val = snd_soc_component_read32(component, RT5682_GLB_CLK);
 +      val = snd_soc_component_read(component, RT5682_GLB_CLK);
        val &= RT5682_SCLK_SRC_MASK;
        if (val == RT5682_SCLK_SRC_PLL1)
                return 1;
@@@ -1298,7 -1293,7 +1298,7 @@@ static int is_sys_clk_from_pll2(struct 
        struct snd_soc_component *component =
                snd_soc_dapm_to_component(w->dapm);
  
 -      val = snd_soc_component_read32(component, RT5682_GLB_CLK);
 +      val = snd_soc_component_read(component, RT5682_GLB_CLK);
        val &= RT5682_SCLK_SRC_MASK;
        if (val == RT5682_SCLK_SRC_PLL2)
                return 1;
@@@ -1326,7 -1321,7 +1326,7 @@@ static int is_using_asrc(struct snd_soc
                return 0;
        }
  
 -      val = (snd_soc_component_read32(component, reg) >> shift) & 0xf;
 +      val = (snd_soc_component_read(component, reg) >> shift) & 0xf;
        switch (val) {
        case RT5682_CLK_SEL_I2S1_ASRC:
        case RT5682_CLK_SEL_I2S2_ASRC:
@@@ -1614,8 -1609,7 +1614,7 @@@ static const struct snd_soc_dapm_widge
                0, set_filter_clk, SND_SOC_DAPM_PRE_PMU),
        SND_SOC_DAPM_SUPPLY("Vref1", RT5682_PWR_ANLG_1, RT5682_PWR_VREF1_BIT, 0,
                rt5682_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
-       SND_SOC_DAPM_SUPPLY("Vref2", RT5682_PWR_ANLG_1, RT5682_PWR_VREF2_BIT, 0,
-               NULL, 0),
+       SND_SOC_DAPM_SUPPLY("Vref2", SND_SOC_NOPM, 0, 0, NULL, 0),
        SND_SOC_DAPM_SUPPLY("MICBIAS", SND_SOC_NOPM, 0, 0, NULL, 0),
  
        /* ASRC */
@@@ -2261,7 -2255,7 +2260,7 @@@ static int rt5682_set_component_pll(str
  {
        struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
        struct rl6231_pll_code pll_code, pll2f_code, pll2b_code;
 -      unsigned int pll2_fout1;
 +      unsigned int pll2_fout1, pll2_ps_val;
        int ret;
  
        if (source == rt5682->pll_src[pll_id] &&
                        pll2b_code.n_code);
                snd_soc_component_write(component, RT5682_PLL2_CTRL_3,
                        pll2f_code.n_code << RT5682_PLL2F_N_SFT);
 +
 +              if (freq_out == 22579200)
 +                      pll2_ps_val = 1 << RT5682_PLL2B_SEL_PS_SFT;
 +              else
 +                      pll2_ps_val = 1 << RT5682_PLL2B_PS_BYP_SFT;
                snd_soc_component_update_bits(component, RT5682_PLL2_CTRL_4,
 +                      RT5682_PLL2B_SEL_PS_MASK | RT5682_PLL2B_PS_BYP_MASK |
                        RT5682_PLL2B_M_BP_MASK | RT5682_PLL2F_M_BP_MASK | 0xf,
 +                      pll2_ps_val |
                        (pll2b_code.m_bp ? 1 : 0) << RT5682_PLL2B_M_BP_SFT |
                        (pll2f_code.m_bp ? 1 : 0) << RT5682_PLL2F_M_BP_SFT |
                        0xf);
@@@ -2476,8 -2463,8 +2475,8 @@@ static int rt5682_set_bias_level(struc
  
  #ifdef CONFIG_COMMON_CLK
  #define CLK_PLL2_FIN 48000000
 -#define CLK_PLL2_FOUT 24576000
  #define CLK_48 48000
 +#define CLK_44 44100
  
  static bool rt5682_clk_check(struct rt5682_priv *rt5682)
  {
@@@ -2505,6 -2492,15 +2504,15 @@@ static int rt5682_wclk_prepare(struct c
        snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS");
        snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
                                RT5682_PWR_MB, RT5682_PWR_MB);
+       snd_soc_dapm_force_enable_pin_unlocked(dapm, "Vref2");
+       snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
+                       RT5682_PWR_VREF2 | RT5682_PWR_FV2,
+                       RT5682_PWR_VREF2);
+       usleep_range(55000, 60000);
+       snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
+                       RT5682_PWR_FV2, RT5682_PWR_FV2);
        snd_soc_dapm_force_enable_pin_unlocked(dapm, "I2S1");
        snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLL2F");
        snd_soc_dapm_force_enable_pin_unlocked(dapm, "PLL2B");
@@@ -2530,9 -2526,12 +2538,12 @@@ static void rt5682_wclk_unprepare(struc
        snd_soc_dapm_mutex_lock(dapm);
  
        snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS");
+       snd_soc_dapm_disable_pin_unlocked(dapm, "Vref2");
        if (!rt5682->jack_type)
                snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
+                               RT5682_PWR_VREF2 | RT5682_PWR_FV2 |
                                RT5682_PWR_MB, 0);
        snd_soc_dapm_disable_pin_unlocked(dapm, "I2S1");
        snd_soc_dapm_disable_pin_unlocked(dapm, "PLL2F");
        snd_soc_dapm_disable_pin_unlocked(dapm, "PLL2B");
@@@ -2547,22 -2546,13 +2558,22 @@@ static unsigned long rt5682_wclk_recalc
        struct rt5682_priv *rt5682 =
                container_of(hw, struct rt5682_priv,
                             dai_clks_hw[RT5682_DAI_WCLK_IDX]);
 +      struct snd_soc_component *component = rt5682->component;
 +      const char * const clk_name = __clk_get_name(hw->clk);
  
        if (!rt5682_clk_check(rt5682))
                return 0;
        /*
 -       * Only accept to set wclk rate to 48kHz temporarily.
 +       * Only accept to set wclk rate to 44.1k or 48kHz.
         */
 -      return CLK_48;
 +      if (rt5682->lrck[RT5682_AIF1] != CLK_48 &&
 +          rt5682->lrck[RT5682_AIF1] != CLK_44) {
 +              dev_warn(component->dev, "%s: clk %s only support %d or %d Hz output\n",
 +                      __func__, clk_name, CLK_44, CLK_48);
 +              return 0;
 +      }
 +
 +      return rt5682->lrck[RT5682_AIF1];
  }
  
  static long rt5682_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
        struct rt5682_priv *rt5682 =
                container_of(hw, struct rt5682_priv,
                             dai_clks_hw[RT5682_DAI_WCLK_IDX]);
 +      struct snd_soc_component *component = rt5682->component;
 +      const char * const clk_name = __clk_get_name(hw->clk);
  
        if (!rt5682_clk_check(rt5682))
                return -EINVAL;
        /*
 -       * Only accept to set wclk rate to 48kHz temporarily.
 +       * Only accept to set wclk rate to 44.1k or 48kHz.
 +       * It will force to 48kHz if not both.
         */
 -      return CLK_48;
 +      if (rate != CLK_48 && rate != CLK_44) {
 +              dev_warn(component->dev, "%s: clk %s only support %d or %d Hz output\n",
 +                      __func__, clk_name, CLK_44, CLK_48);
 +              rate = CLK_48;
 +      }
 +
 +      return rate;
  }
  
  static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
        struct clk *parent_clk;
        const char * const clk_name = __clk_get_name(hw->clk);
        int pre_div;
 +      unsigned int clk_pll2_out;
  
        if (!rt5682_clk_check(rt5682))
                return -EINVAL;
                        clk_name, CLK_PLL2_FIN);
  
        /*
 -       * It's a temporary limitation. Only accept to set wclk rate to 48kHz.
 -       * It will force wclk to 48kHz even it's not.
 -       */
 -      if (rate != CLK_48) {
 -              dev_warn(component->dev, "clk %s only support %d Hz output\n",
 -                      clk_name, CLK_48);
 -              rate = CLK_48;
 -      }
 -
 -      /*
 -       * To achieve the rate conversion from 48MHz to 48kHz, PLL2 is needed.
 +       * To achieve the rate conversion from 48MHz to 44.1k or 48kHz,
 +       * PLL2 is needed.
         */
 +      clk_pll2_out = rate * 512;
        rt5682_set_component_pll(component, RT5682_PLL2, RT5682_PLL2_S_MCLK,
 -              CLK_PLL2_FIN, CLK_PLL2_FOUT);
 +              CLK_PLL2_FIN, clk_pll2_out);
  
        rt5682_set_component_sysclk(component, RT5682_SCLK_S_PLL2, 0,
 -              CLK_PLL2_FOUT, SND_SOC_CLOCK_IN);
 +              clk_pll2_out, SND_SOC_CLOCK_IN);
 +
 +      rt5682->lrck[RT5682_AIF1] = rate;
  
        pre_div = rl6231_get_clk_info(rt5682->sysclk, rate);
  
@@@ -2653,7 -2639,8 +2664,7 @@@ static unsigned long rt5682_bclk_recalc
        struct snd_soc_component *component = rt5682->component;
        unsigned int bclks_per_wclk;
  
 -      snd_soc_component_read(component, RT5682_TDM_TCON_CTRL,
 -              &bclks_per_wclk);
 +      bclks_per_wclk = snd_soc_component_read(component, RT5682_TDM_TCON_CTRL);
  
        switch (bclks_per_wclk & RT5682_TDM_BCLK_MS1_MASK) {
        case RT5682_TDM_BCLK_MS1_256:
@@@ -2836,7 -2823,6 +2847,7 @@@ static int rt5682_probe(struct snd_soc_
        struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
        struct sdw_slave *slave;
        unsigned long time;
 +      struct snd_soc_dapm_context *dapm = &component->dapm;
  
  #ifdef CONFIG_COMMON_CLK
        int ret;
  #endif
        }
  
 +      snd_soc_dapm_disable_pin(dapm, "MICBIAS");
 +      snd_soc_dapm_disable_pin(dapm, "Vref2");
 +      snd_soc_dapm_sync(dapm);
        return 0;
  }
  
@@@ -3029,14 -3012,13 +3040,14 @@@ void rt5682_calibrate(struct rt5682_pri
                dev_err(rt5682->component->dev, "HP Calibration Failure\n");
  
        /* restore settings */
 -      regmap_write(rt5682->regmap, RT5682_PWR_ANLG_1, 0x02af);
 +      regmap_write(rt5682->regmap, RT5682_PWR_ANLG_1, 0x002f);
        regmap_write(rt5682->regmap, RT5682_MICBIAS_2, 0x0080);
        regmap_write(rt5682->regmap, RT5682_GLB_CLK, 0x0000);
        regmap_write(rt5682->regmap, RT5682_PWR_DIG_1, 0x0000);
        regmap_write(rt5682->regmap, RT5682_CHOP_DAC, 0x2000);
        regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005);
        regmap_write(rt5682->regmap, RT5682_STO1_ADC_MIXER, 0xc0c4);
 +      regmap_write(rt5682->regmap, RT5682_CAL_REC, 0x0c0c);
  
        mutex_unlock(&rt5682->calibrate_mutex);
  }
index 89c6507d5566be0f793ca0427824e8fd71b24f85,7cfc89602fc397bc941e3790917c9497a7efe4ce..c86231dfcf4f84d68cf127addfe704c203b4bab8
@@@ -186,7 -186,7 +186,7 @@@ SOC_DAPM_SINGLE("PCM Playback Switch", 
  
  /* Boost mixer */
  static const struct snd_kcontrol_new wm8974_boost_mixer[] = {
- SOC_DAPM_SINGLE("Aux Switch", WM8974_INPPGA, 6, 1, 0),
+ SOC_DAPM_SINGLE("Aux Switch", WM8974_INPPGA, 6, 1, 1),
  };
  
  /* Input PGA */
@@@ -318,11 -318,11 +318,11 @@@ static int wm8974_set_dai_pll(struct sn
  
        if (freq_in == 0 || freq_out == 0) {
                /* Clock CODEC directly from MCLK */
 -              reg = snd_soc_component_read32(component, WM8974_CLOCK);
 +              reg = snd_soc_component_read(component, WM8974_CLOCK);
                snd_soc_component_write(component, WM8974_CLOCK, reg & 0x0ff);
  
                /* Turn off PLL */
 -              reg = snd_soc_component_read32(component, WM8974_POWER1);
 +              reg = snd_soc_component_read(component, WM8974_POWER1);
                snd_soc_component_write(component, WM8974_POWER1, reg & 0x1df);
                return 0;
        }
        snd_soc_component_write(component, WM8974_PLLK1, pll_div.k >> 18);
        snd_soc_component_write(component, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff);
        snd_soc_component_write(component, WM8974_PLLK3, pll_div.k & 0x1ff);
 -      reg = snd_soc_component_read32(component, WM8974_POWER1);
 +      reg = snd_soc_component_read(component, WM8974_POWER1);
        snd_soc_component_write(component, WM8974_POWER1, reg | 0x020);
  
        /* Run CODEC from PLL instead of MCLK */
 -      reg = snd_soc_component_read32(component, WM8974_CLOCK);
 +      reg = snd_soc_component_read(component, WM8974_CLOCK);
        snd_soc_component_write(component, WM8974_CLOCK, reg | 0x100);
  
        return 0;
@@@ -354,15 -354,15 +354,15 @@@ static int wm8974_set_dai_clkdiv(struc
  
        switch (div_id) {
        case WM8974_OPCLKDIV:
 -              reg = snd_soc_component_read32(component, WM8974_GPIO) & 0x1cf;
 +              reg = snd_soc_component_read(component, WM8974_GPIO) & 0x1cf;
                snd_soc_component_write(component, WM8974_GPIO, reg | div);
                break;
        case WM8974_MCLKDIV:
 -              reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x11f;
 +              reg = snd_soc_component_read(component, WM8974_CLOCK) & 0x11f;
                snd_soc_component_write(component, WM8974_CLOCK, reg | div);
                break;
        case WM8974_BCLKDIV:
 -              reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1e3;
 +              reg = snd_soc_component_read(component, WM8974_CLOCK) & 0x1e3;
                snd_soc_component_write(component, WM8974_CLOCK, reg | div);
                break;
        default:
@@@ -450,7 -450,7 +450,7 @@@ static int wm8974_set_dai_fmt(struct sn
  {
        struct snd_soc_component *component = codec_dai->component;
        u16 iface = 0;
 -      u16 clk = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1fe;
 +      u16 clk = snd_soc_component_read(component, WM8974_CLOCK) & 0x1fe;
  
        /* set master/slave audio interface */
        switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
                iface |= 0x0008;
                break;
        case SND_SOC_DAIFMT_DSP_A:
+               if ((fmt & SND_SOC_DAIFMT_INV_MASK) == SND_SOC_DAIFMT_IB_IF ||
+                   (fmt & SND_SOC_DAIFMT_INV_MASK) == SND_SOC_DAIFMT_NB_IF) {
+                       return -EINVAL;
+               }
                iface |= 0x00018;
                break;
        default:
@@@ -508,8 -512,8 +512,8 @@@ static int wm8974_pcm_hw_params(struct 
  {
        struct snd_soc_component *component = dai->component;
        struct wm8974_priv *priv = snd_soc_component_get_drvdata(component);
 -      u16 iface = snd_soc_component_read32(component, WM8974_IFACE) & 0x19f;
 -      u16 adn = snd_soc_component_read32(component, WM8974_ADD) & 0x1f1;
 +      u16 iface = snd_soc_component_read(component, WM8974_IFACE) & 0x19f;
 +      u16 adn = snd_soc_component_read(component, WM8974_ADD) & 0x1f1;
        int err;
  
        priv->fs = params_rate(params);
        return 0;
  }
  
 -static int wm8974_mute(struct snd_soc_dai *dai, int mute)
 +static int wm8974_mute(struct snd_soc_dai *dai, int mute, int direction)
  {
        struct snd_soc_component *component = dai->component;
 -      u16 mute_reg = snd_soc_component_read32(component, WM8974_DAC) & 0xffbf;
 +      u16 mute_reg = snd_soc_component_read(component, WM8974_DAC) & 0xffbf;
  
        if (mute)
                snd_soc_component_write(component, WM8974_DAC, mute_reg | 0x40);
  static int wm8974_set_bias_level(struct snd_soc_component *component,
        enum snd_soc_bias_level level)
  {
 -      u16 power1 = snd_soc_component_read32(component, WM8974_POWER1) & ~0x3;
 +      u16 power1 = snd_soc_component_read(component, WM8974_POWER1) & ~0x3;
  
        switch (level) {
        case SND_SOC_BIAS_ON:
  
  static const struct snd_soc_dai_ops wm8974_ops = {
        .hw_params = wm8974_pcm_hw_params,
 -      .digital_mute = wm8974_mute,
 +      .mute_stream = wm8974_mute,
        .set_fmt = wm8974_set_dai_fmt,
        .set_clkdiv = wm8974_set_dai_clkdiv,
        .set_pll = wm8974_set_dai_pll,
        .set_sysclk = wm8974_set_dai_sysclk,
 +      .no_capture_mute = 1,
  };
  
  static struct snd_soc_dai_driver wm8974_dai = {
index c9da91147770112d5d59cdbe93d6b348137e4ad3,bed4d5f73d9cffe6887ae74aa718dd03e7d3d084..725304779426066f4261b670b99045562427ecc7
@@@ -272,8 -272,8 +272,8 @@@ static int bdw_rt5677_init(struct snd_s
                        RT5677_CLK_SEL_SYS2);
  
        /* Request rt5677 GPIO for headphone amp control */
 -      bdw_rt5677->gpio_hp_en = devm_gpiod_get(component->dev, "headphone-enable",
 -                                              GPIOD_OUT_LOW);
 +      bdw_rt5677->gpio_hp_en = gpiod_get(component->dev, "headphone-enable",
 +                                         GPIOD_OUT_LOW);
        if (IS_ERR(bdw_rt5677->gpio_hp_en)) {
                dev_err(component->dev, "Can't find HP_AMP_SHDN_L gpio\n");
                return PTR_ERR(bdw_rt5677->gpio_hp_en);
        return 0;
  }
  
 +static void bdw_rt5677_exit(struct snd_soc_pcm_runtime *rtd)
 +{
 +      struct bdw_rt5677_priv *bdw_rt5677 =
 +                      snd_soc_card_get_drvdata(rtd->card);
 +
 +      /*
 +       * The .exit() can be reached without going through the .init()
 +       * so explicitly test if the gpiod is valid
 +       */
 +      if (!IS_ERR_OR_NULL(bdw_rt5677->gpio_hp_en))
 +              gpiod_put(bdw_rt5677->gpio_hp_en);
 +}
 +
  /* broadwell digital audio interface glue - connects codec <--> CPU */
  SND_SOC_DAILINK_DEF(dummy,
        DAILINK_COMP_ARRAY(COMP_DUMMY()));
@@@ -367,6 -354,7 +367,7 @@@ static struct snd_soc_dai_link bdw_rt56
        {
                .name = "Codec DSP",
                .stream_name = "Wake on Voice",
+               .capture_only = 1,
                .ops = &bdw_rt5677_dsp_ops,
                SND_SOC_DAILINK_REG(dsp),
        },
                .dpcm_playback = 1,
                .dpcm_capture = 1,
                .init = bdw_rt5677_init,
 +              .exit = bdw_rt5677_exit,
  #if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
                SND_SOC_DAILINK_REG(dummy, be, dummy),
  #else
@@@ -418,19 -405,9 +419,19 @@@ static int bdw_rt5677_resume_post(struc
        return 0;
  }
  
 +#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
 +/* use space before codec name to simplify card ID, and simplify driver name */
 +#define CARD_NAME "bdw rt5677" /* card name will be 'sof-bdw rt5677' */
 +#define DRIVER_NAME "SOF"
 +#else
 +#define CARD_NAME "bdw-rt5677"
 +#define DRIVER_NAME NULL /* card name will be used for driver name */
 +#endif
 +
  /* ASoC machine driver for Broadwell DSP + RT5677 */
  static struct snd_soc_card bdw_rt5677_card = {
 -      .name = "bdw-rt5677",
 +      .name = CARD_NAME,
 +      .driver_name = DRIVER_NAME,
        .owner = THIS_MODULE,
        .dai_link = bdw_rt5677_dais,
        .num_links = ARRAY_SIZE(bdw_rt5677_dais),
index 71b39e579af9c280e5e85481ca765976d87a11ef,ecbc58e8a37f5cb292f951ba62f725c2c41d6800..414ae4bb5224a96d58d2586c2d2d092395ebe988
@@@ -407,18 -407,8 +407,18 @@@ static int byt_cht_es8316_resume(struc
        return 0;
  }
  
 +#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
 +/* use space before codec name to simplify card ID, and simplify driver name */
 +#define CARD_NAME "bytcht es8316" /* card name will be 'sof-bytcht es8316' */
 +#define DRIVER_NAME "SOF"
 +#else
 +#define CARD_NAME "bytcht-es8316"
 +#define DRIVER_NAME NULL /* card name will be used for driver name */
 +#endif
 +
  static struct snd_soc_card byt_cht_es8316_card = {
 -      .name = "bytcht-es8316",
 +      .name = CARD_NAME,
 +      .driver_name = DRIVER_NAME,
        .owner = THIS_MODULE,
        .dai_link = byt_cht_es8316_dais,
        .num_links = ARRAY_SIZE(byt_cht_es8316_dais),
@@@ -525,8 -515,9 +525,8 @@@ static int snd_byt_cht_es8316_mc_probe(
                        BYT_CHT_ES8316_MONO_SPEAKER;
        }
        if (quirk_override != -1) {
 -              dev_info(dev, "Overriding quirk 0x%x => 0x%x\n",
 -                       (unsigned int)quirk,
 -                       quirk_override);
 +              dev_info(dev, "Overriding quirk 0x%lx => 0x%x\n",
 +                       quirk, quirk_override);
                quirk = quirk_override;
        }
        log_quirks(dev);
  
        if (cnt) {
                ret = device_add_properties(codec_dev, props);
-               if (ret)
+               if (ret) {
+                       put_device(codec_dev);
                        return ret;
+               }
        }
  
        devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
diff --combined sound/soc/soc-dai.c
index c89a1929d141aea7ae2ed43081408c879527a36b,457159975b01a22237e81810855940e4b955618c..98f0c98b06bbd78dbe56e39d80d8ba4be5e6e24b
@@@ -298,15 -298,13 +298,15 @@@ int snd_soc_dai_digital_mute(struct snd
  {
        int ret = -ENOTSUPP;
  
 +      /*
 +       * ignore if direction was CAPTURE
 +       * and it had .no_capture_mute flag
 +       */
        if (dai->driver->ops &&
 -          dai->driver->ops->mute_stream)
 +          dai->driver->ops->mute_stream &&
 +          (direction == SNDRV_PCM_STREAM_PLAYBACK ||
 +           !dai->driver->ops->no_capture_mute))
                ret = dai->driver->ops->mute_stream(dai, mute, direction);
 -      else if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
 -               dai->driver->ops &&
 -               dai->driver->ops->digital_mute)
 -              ret = dai->driver->ops->digital_mute(dai, mute);
  
        return soc_dai_ret(dai, ret);
  }
@@@ -393,6 -391,44 +393,44 @@@ bool snd_soc_dai_stream_valid(struct sn
        return stream->channels_min;
  }
  
+ /*
+  * snd_soc_dai_link_set_capabilities() - set dai_link properties based on its DAIs
+  */
+ void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
+ {
+       struct snd_soc_dai_link_component *cpu;
+       struct snd_soc_dai_link_component *codec;
+       struct snd_soc_dai *dai;
+       bool supported[SNDRV_PCM_STREAM_LAST + 1];
+       int direction;
+       int i;
+       for_each_pcm_streams(direction) {
+               supported[direction] = true;
+               for_each_link_cpus(dai_link, i, cpu) {
+                       dai = snd_soc_find_dai(cpu);
+                       if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
+                               supported[direction] = false;
+                               break;
+                       }
+               }
+               if (!supported[direction])
+                       continue;
+               for_each_link_codecs(dai_link, i, codec) {
+                       dai = snd_soc_find_dai(codec);
+                       if (!dai || !snd_soc_dai_stream_valid(dai, direction)) {
+                               supported[direction] = false;
+                               break;
+                       }
+               }
+       }
+       dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
+       dai_link->dpcm_capture  = supported[SNDRV_PCM_STREAM_CAPTURE];
+ }
+ EXPORT_SYMBOL_GPL(snd_soc_dai_link_set_capabilities);
  void snd_soc_dai_action(struct snd_soc_dai *dai,
                        int stream, int action)
  {