Merge remote-tracking branches 'asoc/topic/rl6231', 'asoc/topic/rt5514', 'asoc/topic...
authorMark Brown <broonie@kernel.org>
Thu, 18 Jan 2018 11:56:11 +0000 (11:56 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 18 Jan 2018 11:56:11 +0000 (11:56 +0000)
include/sound/rt5514.h
include/sound/rt5645.h
sound/soc/codecs/rl6231.c
sound/soc/codecs/rt5514-spi.c
sound/soc/codecs/rt5514.c
sound/soc/codecs/rt5514.h
sound/soc/codecs/rt5645.c
sound/soc/codecs/rt5645.h
sound/soc/intel/boards/cht_bsw_rt5645.c
sound/soc/samsung/bells.c

index ef18494769ee1d9be57a2e973af3417e5df57ce4..64d027dbaaca9637cb230e3de22c153bbb4b26b6 100644 (file)
@@ -14,6 +14,8 @@
 
 struct rt5514_platform_data {
        unsigned int dmic_init_delay;
+       const char *dsp_calib_clk_name;
+       unsigned int dsp_calib_clk_rate;
 };
 
 #endif
index d0c33a9972b917c2f1b4e91aebfc35d9540102f8..f218c742f08ebddda4a900010001b3844e13182d 100644 (file)
@@ -25,6 +25,9 @@ struct rt5645_platform_data {
        bool level_trigger_irq;
        /* Invert JD1_1 status polarity */
        bool inv_jd1_1;
+
+       /* Value to asign to snd_soc_card.long_name */
+       const char *long_name;
 };
 
 #endif
index 974a9040651db37da519ccb1e2cf5e2ff8d55ac2..7ef3b5476bcc2ecc3f291d151e99ce534230183e 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/regmap.h>
 
+#include <linux/gcd.h>
 #include "rl6231.h"
 
 /**
@@ -106,6 +107,25 @@ static const struct pll_calc_map pll_preset_table[] = {
        {19200000,  24576000,  3, 30, 3, false},
 };
 
+static unsigned int find_best_div(unsigned int in,
+       unsigned int max, unsigned int div)
+{
+       unsigned int d;
+
+       if (in <= max)
+               return 1;
+
+       d = in / max;
+       if (in % max)
+               d++;
+
+       while (div % d != 0)
+               d++;
+
+
+       return d;
+}
+
 /**
  * rl6231_pll_calc - Calcualte PLL M/N/K code.
  * @freq_in: external clock provided to codec.
@@ -120,9 +140,11 @@ int rl6231_pll_calc(const unsigned int freq_in,
        const unsigned int freq_out, struct rl6231_pll_code *pll_code)
 {
        int max_n = RL6231_PLL_N_MAX, max_m = RL6231_PLL_M_MAX;
-       int i, k, red, n_t, pll_out, in_t, out_t;
-       int n = 0, m = 0, m_t = 0;
-       int red_t = abs(freq_out - freq_in);
+       int i, k, n_t;
+       int k_t, min_k, max_k, n = 0, m = 0, m_t = 0;
+       unsigned int red, pll_out, in_t, out_t, div, div_t;
+       unsigned int red_t = abs(freq_out - freq_in);
+       unsigned int f_in, f_out, f_max;
        bool bypass = false;
 
        if (RL6231_PLL_INP_MAX < freq_in || RL6231_PLL_INP_MIN > freq_in)
@@ -140,39 +162,52 @@ int rl6231_pll_calc(const unsigned int freq_in,
                }
        }
 
-       k = 100000000 / freq_out - 2;
-       if (k > RL6231_PLL_K_MAX)
-               k = RL6231_PLL_K_MAX;
-       for (n_t = 0; n_t <= max_n; n_t++) {
-               in_t = freq_in / (k + 2);
-               pll_out = freq_out / (n_t + 2);
-               if (in_t < 0)
-                       continue;
-               if (in_t == pll_out) {
-                       bypass = true;
-                       n = n_t;
-                       goto code_find;
-               }
-               red = abs(in_t - pll_out);
-               if (red < red_t) {
-                       bypass = true;
-                       n = n_t;
-                       m = m_t;
-                       if (red == 0)
+       min_k = 80000000 / freq_out - 2;
+       max_k = 150000000 / freq_out - 2;
+       if (max_k > RL6231_PLL_K_MAX)
+               max_k = RL6231_PLL_K_MAX;
+       if (min_k > RL6231_PLL_K_MAX)
+               min_k = max_k = RL6231_PLL_K_MAX;
+       div_t = gcd(freq_in, freq_out);
+       f_max = 0xffffffff / RL6231_PLL_N_MAX;
+       div = find_best_div(freq_in, f_max, div_t);
+       f_in = freq_in / div;
+       f_out = freq_out / div;
+       k = min_k;
+       for (k_t = min_k; k_t <= max_k; k_t++) {
+               for (n_t = 0; n_t <= max_n; n_t++) {
+                       in_t = f_in * (n_t + 2);
+                       pll_out = f_out * (k_t + 2);
+                       if (in_t == pll_out) {
+                               bypass = true;
+                               n = n_t;
+                               k = k_t;
                                goto code_find;
-                       red_t = red;
-               }
-               for (m_t = 0; m_t <= max_m; m_t++) {
-                       out_t = in_t / (m_t + 2);
-                       red = abs(out_t - pll_out);
+                       }
+                       out_t = in_t / (k_t + 2);
+                       red = abs(f_out - out_t);
                        if (red < red_t) {
-                               bypass = false;
+                               bypass = true;
                                n = n_t;
-                               m = m_t;
+                               m = 0;
+                               k = k_t;
                                if (red == 0)
                                        goto code_find;
                                red_t = red;
                        }
+                       for (m_t = 0; m_t <= max_m; m_t++) {
+                               out_t = in_t / ((m_t + 2) * (k_t + 2));
+                               red = abs(f_out - out_t);
+                               if (red < red_t) {
+                                       bypass = false;
+                                       n = n_t;
+                                       m = m_t;
+                                       k = k_t;
+                                       if (red == 0)
+                                               goto code_find;
+                                       red_t = red;
+                               }
+                       }
                }
        }
        pr_debug("Only get approximation about PLL\n");
index 64bf26cec20d535314551ae542f8c28ed25352dc..2144edca97b0959430be176feeec47ad0c6f265b 100644 (file)
@@ -381,6 +381,7 @@ int rt5514_spi_burst_read(unsigned int addr, u8 *rxbuf, size_t len)
 
        return true;
 }
+EXPORT_SYMBOL_GPL(rt5514_spi_burst_read);
 
 /**
  * rt5514_spi_burst_write - Write data to SPI by rt5514 address.
index 2dd6e9f990a4c4c7a2377c5f159987a046220b7a..198df016802f826dff3681d5f6496c4484d3e431 100644 (file)
@@ -295,6 +295,33 @@ static int rt5514_dsp_voice_wake_up_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
+static int rt5514_calibration(struct rt5514_priv *rt5514, bool on)
+{
+       if (on) {
+               regmap_write(rt5514->regmap, RT5514_ANA_CTRL_PLL3, 0x0000000a);
+               regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL, 0xf,
+                       0xa);
+               regmap_update_bits(rt5514->regmap, RT5514_PWR_ANA1, 0x301,
+                       0x301);
+               regmap_write(rt5514->regmap, RT5514_PLL3_CALIB_CTRL4,
+                       0x80000000 | rt5514->pll3_cal_value);
+               regmap_write(rt5514->regmap, RT5514_PLL3_CALIB_CTRL1,
+                       0x8bb80800);
+               regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
+                       0xc0000000, 0x80000000);
+               regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
+                       0xc0000000, 0xc0000000);
+       } else {
+               regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
+                       0xc0000000, 0x40000000);
+               regmap_update_bits(rt5514->regmap, RT5514_PWR_ANA1, 0x301, 0);
+               regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL, 0xf,
+                       0x4);
+       }
+
+       return 0;
+}
+
 static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
 {
@@ -302,6 +329,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
        struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
        struct snd_soc_codec *codec = rt5514->codec;
        const struct firmware *fw = NULL;
+       u8 buf[8];
 
        if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled)
                return 0;
@@ -310,6 +338,35 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
                rt5514->dsp_enabled = ucontrol->value.integer.value[0];
 
                if (rt5514->dsp_enabled) {
+                       if (rt5514->pdata.dsp_calib_clk_name &&
+                               !IS_ERR(rt5514->dsp_calib_clk)) {
+                               if (clk_set_rate(rt5514->dsp_calib_clk,
+                                       rt5514->pdata.dsp_calib_clk_rate))
+                                       dev_err(codec->dev,
+                                               "Can't set rate for mclk");
+
+                               if (clk_prepare_enable(rt5514->dsp_calib_clk))
+                                       dev_err(codec->dev,
+                                               "Can't enable dsp_calib_clk");
+
+                               rt5514_calibration(rt5514, true);
+
+                               msleep(20);
+#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
+                               rt5514_spi_burst_read(RT5514_PLL3_CALIB_CTRL6 |
+                                       RT5514_DSP_MAPPING,
+                                       (u8 *)&buf, sizeof(buf));
+#else
+                               dev_err(codec->dev, "There is no SPI driver for"
+                                       " loading the firmware\n");
+#endif
+                               rt5514->pll3_cal_value = buf[0] | buf[1] << 8 |
+                                       buf[2] << 16 | buf[3] << 24;
+
+                               rt5514_calibration(rt5514, false);
+                               clk_disable_unprepare(rt5514->dsp_calib_clk);
+                       }
+
                        rt5514_enable_dsp_prepare(rt5514);
 
                        request_firmware(&fw, RT5514_FIRMWARE1, codec->dev);
@@ -341,6 +398,20 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
                        /* DSP run */
                        regmap_write(rt5514->i2c_regmap, 0x18002f00,
                                0x00055148);
+
+                       if (rt5514->pdata.dsp_calib_clk_name &&
+                               !IS_ERR(rt5514->dsp_calib_clk)) {
+                               msleep(20);
+
+                               regmap_write(rt5514->i2c_regmap, 0x1800211c,
+                                       rt5514->pll3_cal_value);
+                               regmap_write(rt5514->i2c_regmap, 0x18002124,
+                                       0x00220012);
+                               regmap_write(rt5514->i2c_regmap, 0x18002124,
+                                       0x80220042);
+                               regmap_write(rt5514->i2c_regmap, 0x18002124,
+                                       0xe0220042);
+                       }
                } else {
                        regmap_multi_reg_write(rt5514->i2c_regmap,
                                rt5514_i2c_patch, ARRAY_SIZE(rt5514_i2c_patch));
@@ -1024,12 +1095,22 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec,
 static int rt5514_probe(struct snd_soc_codec *codec)
 {
        struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec);
+       struct platform_device *pdev = container_of(codec->dev,
+                                                  struct platform_device, dev);
 
        rt5514->mclk = devm_clk_get(codec->dev, "mclk");
        if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER)
                return -EPROBE_DEFER;
 
+       if (rt5514->pdata.dsp_calib_clk_name) {
+               rt5514->dsp_calib_clk = devm_clk_get(&pdev->dev,
+                               rt5514->pdata.dsp_calib_clk_name);
+               if (PTR_ERR(rt5514->dsp_calib_clk) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+       }
+
        rt5514->codec = codec;
+       rt5514->pll3_cal_value = 0x0078b000;
 
        return 0;
 }
@@ -1147,6 +1228,10 @@ static int rt5514_parse_dp(struct rt5514_priv *rt5514, struct device *dev)
 {
        device_property_read_u32(dev, "realtek,dmic-init-delay-ms",
                &rt5514->pdata.dmic_init_delay);
+       device_property_read_string(dev, "realtek,dsp-calib-clk-name",
+               &rt5514->pdata.dsp_calib_clk_name);
+       device_property_read_u32(dev, "realtek,dsp-calib-clk-rate",
+               &rt5514->pdata.dsp_calib_clk_rate);
 
        return 0;
 }
index 2dc40e6d8b3f69835ded69ac71012cb765ac0a36..f0f3400ce6b15174dc5037274f372c615f8fa3d5 100644 (file)
@@ -34,7 +34,9 @@
 #define RT5514_CLK_CTRL1                       0x2104
 #define RT5514_CLK_CTRL2                       0x2108
 #define RT5514_PLL3_CALIB_CTRL1                        0x2110
+#define RT5514_PLL3_CALIB_CTRL4                        0x2120
 #define RT5514_PLL3_CALIB_CTRL5                        0x2124
+#define RT5514_PLL3_CALIB_CTRL6                        0x2128
 #define RT5514_DELAY_BUF_CTRL1                 0x2140
 #define RT5514_DELAY_BUF_CTRL3                 0x2148
 #define RT5514_ASRC_IN_CTRL1                   0x2180
@@ -272,7 +274,7 @@ struct rt5514_priv {
        struct rt5514_platform_data pdata;
        struct snd_soc_codec *codec;
        struct regmap *i2c_regmap, *regmap;
-       struct clk *mclk;
+       struct clk *mclk, *dsp_calib_clk;
        int sysclk;
        int sysclk_src;
        int lrck;
@@ -281,6 +283,7 @@ struct rt5514_priv {
        int pll_in;
        int pll_out;
        int dsp_enabled;
+       unsigned int pll3_cal_value;
 };
 
 #endif /* __RT5514_H__ */
index edc152c8a1fe7596e9bbc5760574d973a9185d16..8f140c8b93acd3e4ba14fb1f1a9dc6a19b2916f7 100644 (file)
@@ -1943,6 +1943,56 @@ static int rt5650_hp_event(struct snd_soc_dapm_widget *w,
        return 0;
 }
 
+static int rt5645_set_micbias1_event(struct snd_soc_dapm_widget *w,
+               struct snd_kcontrol *k, int  event)
+{
+       struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+
+       switch (event) {
+       case SND_SOC_DAPM_PRE_PMU:
+               snd_soc_update_bits(codec, RT5645_GEN_CTRL2,
+                       RT5645_MICBIAS1_POW_CTRL_SEL_MASK,
+                       RT5645_MICBIAS1_POW_CTRL_SEL_M);
+               break;
+
+       case SND_SOC_DAPM_POST_PMD:
+               snd_soc_update_bits(codec, RT5645_GEN_CTRL2,
+                       RT5645_MICBIAS1_POW_CTRL_SEL_MASK,
+                       RT5645_MICBIAS1_POW_CTRL_SEL_A);
+               break;
+
+       default:
+               return 0;
+       }
+
+       return 0;
+}
+
+static int rt5645_set_micbias2_event(struct snd_soc_dapm_widget *w,
+               struct snd_kcontrol *k, int  event)
+{
+       struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+
+       switch (event) {
+       case SND_SOC_DAPM_PRE_PMU:
+               snd_soc_update_bits(codec, RT5645_GEN_CTRL2,
+                       RT5645_MICBIAS2_POW_CTRL_SEL_MASK,
+                       RT5645_MICBIAS2_POW_CTRL_SEL_M);
+               break;
+
+       case SND_SOC_DAPM_POST_PMD:
+               snd_soc_update_bits(codec, RT5645_GEN_CTRL2,
+                       RT5645_MICBIAS2_POW_CTRL_SEL_MASK,
+                       RT5645_MICBIAS2_POW_CTRL_SEL_A);
+               break;
+
+       default:
+               return 0;
+       }
+
+       return 0;
+}
+
 static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
        SND_SOC_DAPM_SUPPLY("LDO2", RT5645_PWR_MIXER,
                RT5645_PWR_LDO2_BIT, 0, NULL, 0),
@@ -1980,10 +2030,12 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
 
        /* Input Side */
        /* micbias */
-       SND_SOC_DAPM_MICBIAS("micbias1", RT5645_PWR_ANLG2,
-                       RT5645_PWR_MB1_BIT, 0),
-       SND_SOC_DAPM_MICBIAS("micbias2", RT5645_PWR_ANLG2,
-                       RT5645_PWR_MB2_BIT, 0),
+       SND_SOC_DAPM_SUPPLY("micbias1", RT5645_PWR_ANLG2,
+                       RT5645_PWR_MB1_BIT, 0, rt5645_set_micbias1_event,
+                       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
+       SND_SOC_DAPM_SUPPLY("micbias2", RT5645_PWR_ANLG2,
+                       RT5645_PWR_MB2_BIT, 0, rt5645_set_micbias2_event,
+                       SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
        /* Input Lines */
        SND_SOC_DAPM_INPUT("DMIC L1"),
        SND_SOC_DAPM_INPUT("DMIC R1"),
@@ -3394,6 +3446,9 @@ static int rt5645_probe(struct snd_soc_codec *codec)
                snd_soc_dapm_sync(dapm);
        }
 
+       if (rt5645->pdata.long_name)
+               codec->component.card->long_name = rt5645->pdata.long_name;
+
        rt5645->eq_param = devm_kzalloc(codec->dev,
                RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s), GFP_KERNEL);
 
@@ -3570,63 +3625,74 @@ static const struct acpi_device_id rt5645_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, rt5645_acpi_match);
 #endif
 
-static const struct rt5645_platform_data general_platform_data = {
+static const struct rt5645_platform_data intel_braswell_platform_data = {
        .dmic1_data_pin = RT5645_DMIC1_DISABLE,
        .dmic2_data_pin = RT5645_DMIC_DATA_IN2P,
        .jd_mode = 3,
 };
 
-static const struct dmi_system_id dmi_platform_intel_braswell[] = {
+static const struct rt5645_platform_data buddy_platform_data = {
+       .dmic1_data_pin = RT5645_DMIC_DATA_GPIO5,
+       .dmic2_data_pin = RT5645_DMIC_DATA_IN2P,
+       .jd_mode = 3,
+       .level_trigger_irq = true,
+};
+
+static const struct rt5645_platform_data gpd_win_platform_data = {
+       .jd_mode = 3,
+       .inv_jd1_1 = true,
+       .long_name = "gpd-win-pocket-rt5645",
+       /* The GPD pocket has a diff. mic, for the win this does not matter. */
+       .in2_diff = true,
+};
+
+static const struct rt5645_platform_data asus_t100ha_platform_data = {
+       .dmic1_data_pin = RT5645_DMIC_DATA_IN2N,
+       .dmic2_data_pin = RT5645_DMIC2_DISABLE,
+       .jd_mode = 3,
+       .inv_jd1_1 = true,
+};
+
+static const struct rt5645_platform_data jd_mode3_platform_data = {
+       .jd_mode = 3,
+};
+
+static const struct dmi_system_id dmi_platform_data[] = {
+       {
+               .ident = "Chrome Buddy",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Buddy"),
+               },
+               .driver_data = (void *)&buddy_platform_data,
+       },
        {
                .ident = "Intel Strago",
                .matches = {
                        DMI_MATCH(DMI_PRODUCT_NAME, "Strago"),
                },
+               .driver_data = (void *)&intel_braswell_platform_data,
        },
        {
                .ident = "Google Chrome",
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
                },
+               .driver_data = (void *)&intel_braswell_platform_data,
        },
        {
                .ident = "Google Setzer",
                .matches = {
                        DMI_MATCH(DMI_PRODUCT_NAME, "Setzer"),
                },
+               .driver_data = (void *)&intel_braswell_platform_data,
        },
        {
                .ident = "Microsoft Surface 3",
                .matches = {
                        DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
                },
+               .driver_data = (void *)&intel_braswell_platform_data,
        },
-       { }
-};
-
-static const struct rt5645_platform_data buddy_platform_data = {
-       .dmic1_data_pin = RT5645_DMIC_DATA_GPIO5,
-       .dmic2_data_pin = RT5645_DMIC_DATA_IN2P,
-       .jd_mode = 3,
-       .level_trigger_irq = true,
-};
-
-static const struct dmi_system_id dmi_platform_intel_broadwell[] = {
-       {
-               .ident = "Chrome Buddy",
-               .matches = {
-                       DMI_MATCH(DMI_PRODUCT_NAME, "Buddy"),
-               },
-       },
-       { }
-};
-
-static const struct rt5645_platform_data gpd_win_platform_data = {
-       .jd_mode = 3,
-       .inv_jd1_1 = true,
-};
-
-static const struct dmi_system_id dmi_platform_gpd_win[] = {
        {
                /*
                 * Match for the GPDwin which unfortunately uses somewhat
@@ -3637,46 +3703,38 @@ static const struct dmi_system_id dmi_platform_gpd_win[] = {
                 * the same default product_name. Also the GPDwin is the
                 * only device to have both board_ and product_name not set.
                 */
-               .ident = "GPD Win",
+               .ident = "GPD Win / Pocket",
                .matches = {
                        DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
                        DMI_MATCH(DMI_BOARD_NAME, "Default string"),
                        DMI_MATCH(DMI_BOARD_SERIAL, "Default string"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
                },
+               .driver_data = (void *)&gpd_win_platform_data,
        },
-       {}
-};
-
-static const struct rt5645_platform_data general_platform_data2 = {
-       .dmic1_data_pin = RT5645_DMIC_DATA_IN2N,
-       .dmic2_data_pin = RT5645_DMIC2_DISABLE,
-       .jd_mode = 3,
-       .inv_jd1_1 = true,
-};
-
-static const struct dmi_system_id dmi_platform_asus_t100ha[] = {
        {
                .ident = "ASUS T100HAN",
                .matches = {
                        DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
                        DMI_MATCH(DMI_PRODUCT_NAME, "T100HAN"),
                },
+               .driver_data = (void *)&asus_t100ha_platform_data,
        },
-       { }
-};
-
-static const struct rt5645_platform_data minix_z83_4_platform_data = {
-       .jd_mode = 3,
-};
-
-static const struct dmi_system_id dmi_platform_minix_z83_4[] = {
        {
                .ident = "MINIX Z83-4",
                .matches = {
                        DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MINIX"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
                },
+               .driver_data = (void *)&jd_mode3_platform_data,
+       },
+       {
+               .ident = "Teclast X80 Pro",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "TECLAST"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "X80 Pro"),
+               },
+               .driver_data = (void *)&jd_mode3_platform_data,
        },
        { }
 };
@@ -3684,9 +3742,9 @@ static const struct dmi_system_id dmi_platform_minix_z83_4[] = {
 static bool rt5645_check_dp(struct device *dev)
 {
        if (device_property_present(dev, "realtek,in2-differential") ||
-               device_property_present(dev, "realtek,dmic1-data-pin") ||
-               device_property_present(dev, "realtek,dmic2-data-pin") ||
-               device_property_present(dev, "realtek,jd-mode"))
+           device_property_present(dev, "realtek,dmic1-data-pin") ||
+           device_property_present(dev, "realtek,dmic2-data-pin") ||
+           device_property_present(dev, "realtek,jd-mode"))
                return true;
 
        return false;
@@ -3710,6 +3768,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
                    const struct i2c_device_id *id)
 {
        struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev);
+       const struct dmi_system_id *dmi_data;
        struct rt5645_priv *rt5645;
        int ret, i;
        unsigned int val;
@@ -3723,20 +3782,18 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
        rt5645->i2c = i2c;
        i2c_set_clientdata(i2c, rt5645);
 
+       dmi_data = dmi_first_match(dmi_platform_data);
+       if (dmi_data) {
+               dev_info(&i2c->dev, "Detected %s platform\n", dmi_data->ident);
+               pdata = dmi_data->driver_data;
+       }
+
        if (pdata)
                rt5645->pdata = *pdata;
-       else if (dmi_check_system(dmi_platform_intel_broadwell))
-               rt5645->pdata = buddy_platform_data;
        else if (rt5645_check_dp(&i2c->dev))
                rt5645_parse_dt(rt5645, &i2c->dev);
-       else if (dmi_check_system(dmi_platform_intel_braswell))
-               rt5645->pdata = general_platform_data;
-       else if (dmi_check_system(dmi_platform_gpd_win))
-               rt5645->pdata = gpd_win_platform_data;
-       else if (dmi_check_system(dmi_platform_asus_t100ha))
-               rt5645->pdata = general_platform_data2;
-       else if (dmi_check_system(dmi_platform_minix_z83_4))
-               rt5645->pdata = minix_z83_4_platform_data;
+       else
+               rt5645->pdata = jd_mode3_platform_data;
 
        if (quirk != -1) {
                rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk);
index cfc5f97549eb656b9b861a612e0d60b40c2e93be..940325b28c299daa7d3b2b4dafda5e059a85b679 100644 (file)
@@ -2117,6 +2117,12 @@ enum {
 #define RT5645_RXDC_SRC_STO                    (0x0 << 7)
 #define RT5645_RXDC_SRC_MONO                   (0x1 << 7)
 #define RT5645_RXDC_SRC_SFT                    (7)
+#define RT5645_MICBIAS1_POW_CTRL_SEL_MASK      (0x1 << 5)
+#define RT5645_MICBIAS1_POW_CTRL_SEL_A         (0x0 << 5)
+#define RT5645_MICBIAS1_POW_CTRL_SEL_M         (0x1 << 5)
+#define RT5645_MICBIAS2_POW_CTRL_SEL_MASK      (0x1 << 4)
+#define RT5645_MICBIAS2_POW_CTRL_SEL_A         (0x0 << 4)
+#define RT5645_MICBIAS2_POW_CTRL_SEL_M         (0x1 << 4)
 #define RT5645_RXDP2_SEL_MASK                  (0x1 << 3)
 #define RT5645_RXDP2_SEL_IF2                   (0x0 << 3)
 #define RT5645_RXDP2_SEL_ADC                   (0x1 << 3)
index 976ea6bf9539cb75a988ba000d9740689bfb3da1..31641aab62cd17eef48c1ac85cb98726a532d807 100644 (file)
@@ -118,6 +118,7 @@ static const struct snd_soc_dapm_widget cht_dapm_widgets[] = {
        SND_SOC_DAPM_HP("Headphone", NULL),
        SND_SOC_DAPM_MIC("Headset Mic", NULL),
        SND_SOC_DAPM_MIC("Int Mic", NULL),
+       SND_SOC_DAPM_MIC("Int Analog Mic", NULL),
        SND_SOC_DAPM_SPK("Ext Spk", NULL),
        SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
                        platform_clock_control, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
@@ -128,6 +129,8 @@ static const struct snd_soc_dapm_route cht_rt5645_audio_map[] = {
        {"IN1N", NULL, "Headset Mic"},
        {"DMIC L1", NULL, "Int Mic"},
        {"DMIC R1", NULL, "Int Mic"},
+       {"IN2P", NULL, "Int Analog Mic"},
+       {"IN2N", NULL, "Int Analog Mic"},
        {"Headphone", NULL, "HPOL"},
        {"Headphone", NULL, "HPOR"},
        {"Ext Spk", NULL, "SPOL"},
@@ -135,6 +138,9 @@ static const struct snd_soc_dapm_route cht_rt5645_audio_map[] = {
        {"Headphone", NULL, "Platform Clock"},
        {"Headset Mic", NULL, "Platform Clock"},
        {"Int Mic", NULL, "Platform Clock"},
+       {"Int Analog Mic", NULL, "Platform Clock"},
+       {"Int Analog Mic", NULL, "micbias1"},
+       {"Int Analog Mic", NULL, "micbias2"},
        {"Ext Spk", NULL, "Platform Clock"},
 };
 
@@ -189,6 +195,7 @@ static const struct snd_kcontrol_new cht_mc_controls[] = {
        SOC_DAPM_PIN_SWITCH("Headphone"),
        SOC_DAPM_PIN_SWITCH("Headset Mic"),
        SOC_DAPM_PIN_SWITCH("Int Mic"),
+       SOC_DAPM_PIN_SWITCH("Int Analog Mic"),
        SOC_DAPM_PIN_SWITCH("Ext Spk"),
 };
 
index 34deba461ae18b7218b55fb78709da5886ea4974..0e66cd8ef2f908261a34c992f5eca7143aac9039 100644 (file)
@@ -60,13 +60,13 @@ static int bells_set_bias_level(struct snd_soc_card *card,
 {
        struct snd_soc_pcm_runtime *rtd;
        struct snd_soc_dai *codec_dai;
-       struct snd_soc_codec *codec;
+       struct snd_soc_component *component;
        struct bells_drvdata *bells = card->drvdata;
        int ret;
 
        rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
        codec_dai = rtd->codec_dai;
-       codec = codec_dai->codec;
+       component = codec_dai->component;
 
        if (dapm->dev != codec_dai->dev)
                return 0;
@@ -76,7 +76,7 @@ static int bells_set_bias_level(struct snd_soc_card *card,
                if (dapm->bias_level != SND_SOC_BIAS_STANDBY)
                        break;
 
-               ret = snd_soc_codec_set_pll(codec, WM5102_FLL1,
+               ret = snd_soc_component_set_pll(component, WM5102_FLL1,
                                            ARIZONA_FLL_SRC_MCLK1,
                                            MCLK_RATE,
                                            bells->sysclk_rate);
@@ -84,7 +84,7 @@ static int bells_set_bias_level(struct snd_soc_card *card,
                        pr_err("Failed to start FLL: %d\n", ret);
 
                if (bells->asyncclk_rate) {
-                       ret = snd_soc_codec_set_pll(codec, WM5102_FLL2,
+                       ret = snd_soc_component_set_pll(component, WM5102_FLL2,
                                                    ARIZONA_FLL_SRC_AIF2BCLK,
                                                    BCLK2_RATE,
                                                    bells->asyncclk_rate);
@@ -106,27 +106,27 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
 {
        struct snd_soc_pcm_runtime *rtd;
        struct snd_soc_dai *codec_dai;
-       struct snd_soc_codec *codec;
+       struct snd_soc_component *component;
        struct bells_drvdata *bells = card->drvdata;
        int ret;
 
        rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
        codec_dai = rtd->codec_dai;
-       codec = codec_dai->codec;
+       component = codec_dai->component;
 
        if (dapm->dev != codec_dai->dev)
                return 0;
 
        switch (level) {
        case SND_SOC_BIAS_STANDBY:
-               ret = snd_soc_codec_set_pll(codec, WM5102_FLL1, 0, 0, 0);
+               ret = snd_soc_component_set_pll(component, WM5102_FLL1, 0, 0, 0);
                if (ret < 0) {
                        pr_err("Failed to stop FLL: %d\n", ret);
                        return ret;
                }
 
                if (bells->asyncclk_rate) {
-                       ret = snd_soc_codec_set_pll(codec, WM5102_FLL2,
+                       ret = snd_soc_component_set_pll(component, WM5102_FLL2,
                                                    0, 0, 0);
                        if (ret < 0) {
                                pr_err("Failed to stop FLL: %d\n", ret);
@@ -148,8 +148,8 @@ static int bells_late_probe(struct snd_soc_card *card)
 {
        struct bells_drvdata *bells = card->drvdata;
        struct snd_soc_pcm_runtime *rtd;
-       struct snd_soc_codec *wm0010;
-       struct snd_soc_codec *codec;
+       struct snd_soc_component *wm0010;
+       struct snd_soc_component *component;
        struct snd_soc_dai *aif1_dai;
        struct snd_soc_dai *aif2_dai;
        struct snd_soc_dai *aif3_dai;
@@ -157,22 +157,22 @@ static int bells_late_probe(struct snd_soc_card *card)
        int ret;
 
        rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_AP_DSP].name);
-       wm0010 = rtd->codec;
+       wm0010 = rtd->codec_dai->component;
 
        rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
-       codec = rtd->codec;
+       component = rtd->codec_dai->component;
        aif1_dai = rtd->codec_dai;
 
-       ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK,
+       ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_SYSCLK,
                                       ARIZONA_CLK_SRC_FLL1,
                                       bells->sysclk_rate,
                                       SND_SOC_CLOCK_IN);
        if (ret != 0) {
-               dev_err(codec->dev, "Failed to set SYSCLK: %d\n", ret);
+               dev_err(component->dev, "Failed to set SYSCLK: %d\n", ret);
                return ret;
        }
 
-       ret = snd_soc_codec_set_sysclk(wm0010, 0, 0, SYS_MCLK_RATE, 0);
+       ret = snd_soc_component_set_sysclk(wm0010, 0, 0, SYS_MCLK_RATE, 0);
        if (ret != 0) {
                dev_err(wm0010->dev, "Failed to set WM0010 clock: %d\n", ret);
                return ret;
@@ -182,20 +182,20 @@ static int bells_late_probe(struct snd_soc_card *card)
        if (ret != 0)
                dev_err(aif1_dai->dev, "Failed to set AIF1 clock: %d\n", ret);
 
-       ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_OPCLK, 0,
+       ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_OPCLK, 0,
                                       SYS_MCLK_RATE, SND_SOC_CLOCK_OUT);
        if (ret != 0)
-               dev_err(codec->dev, "Failed to set OPCLK: %d\n", ret);
+               dev_err(component->dev, "Failed to set OPCLK: %d\n", ret);
 
        if (card->num_rtd == DAI_CODEC_CP)
                return 0;
 
-       ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_ASYNCCLK,
+       ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_ASYNCCLK,
                                       ARIZONA_CLK_SRC_FLL2,
                                       bells->asyncclk_rate,
                                       SND_SOC_CLOCK_IN);
        if (ret != 0) {
-               dev_err(codec->dev, "Failed to set ASYNCCLK: %d\n", ret);
+               dev_err(component->dev, "Failed to set ASYNCCLK: %d\n", ret);
                return ret;
        }
 
@@ -221,7 +221,7 @@ static int bells_late_probe(struct snd_soc_card *card)
                return ret;
        }
 
-       ret = snd_soc_codec_set_sysclk(wm9081_dai->codec, WM9081_SYSCLK_MCLK,
+       ret = snd_soc_component_set_sysclk(wm9081_dai->component, WM9081_SYSCLK_MCLK,
                                       0, SYS_MCLK_RATE, 0);
        if (ret != 0) {
                dev_err(wm9081_dai->dev, "Failed to set MCLK: %d\n", ret);