Thomas Gleixner | 8e8e69d | 2019-05-29 07:17:59 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 2 | /* |
| 3 | * byt_cr_dpcm_rt5640.c - ASoc Machine driver for Intel Byt CR platform |
| 4 | * |
| 5 | * Copyright (C) 2014 Intel Corp |
| 6 | * Author: Subhransu S. Prusty <subhransu.s.prusty@intel.com> |
| 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 8 | * |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 9 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 | */ |
| 11 | |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 12 | #include <linux/i2c.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 13 | #include <linux/init.h> |
| 14 | #include <linux/module.h> |
Takashi Iwai | 9f2cf73 | 2017-04-23 09:22:56 +0200 | [diff] [blame] | 15 | #include <linux/moduleparam.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 16 | #include <linux/platform_device.h> |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 17 | #include <linux/acpi.h> |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 18 | #include <linux/clk.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 19 | #include <linux/device.h> |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 20 | #include <linux/dmi.h> |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 21 | #include <linux/input.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 22 | #include <linux/slab.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 23 | #include <sound/pcm.h> |
| 24 | #include <sound/pcm_params.h> |
| 25 | #include <sound/soc.h> |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 26 | #include <sound/jack.h> |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 27 | #include <sound/soc-acpi.h> |
Hans de Goede | a3ad291 | 2018-05-13 09:24:26 +0200 | [diff] [blame] | 28 | #include <dt-bindings/sound/rt5640.h> |
Jie Yang | e56c72d | 2015-04-02 15:37:02 +0800 | [diff] [blame] | 29 | #include "../../codecs/rt5640.h" |
Jie Yang | b97169d | 2015-04-02 15:37:04 +0800 | [diff] [blame] | 30 | #include "../atom/sst-atom-controls.h" |
Pierre-Louis Bossart | 536cfd2 | 2019-05-30 06:50:11 -0500 | [diff] [blame] | 31 | #include "../common/soc-intel-quirks.h" |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 32 | |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 33 | enum { |
| 34 | BYT_RT5640_DMIC1_MAP, |
| 35 | BYT_RT5640_DMIC2_MAP, |
| 36 | BYT_RT5640_IN1_MAP, |
Pierre-Louis Bossart | 59e8b65 | 2016-08-12 16:27:54 -0500 | [diff] [blame] | 37 | BYT_RT5640_IN3_MAP, |
Hans de Goede | 46466ab | 2021-01-09 22:01:18 +0100 | [diff] [blame] | 38 | BYT_RT5640_NO_INTERNAL_MIC_MAP, |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 39 | }; |
| 40 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 41 | enum { |
| 42 | BYT_RT5640_JD_SRC_GPIO1 = (RT5640_JD_SRC_GPIO1 << 4), |
| 43 | BYT_RT5640_JD_SRC_JD1_IN4P = (RT5640_JD_SRC_JD1_IN4P << 4), |
| 44 | BYT_RT5640_JD_SRC_JD2_IN4N = (RT5640_JD_SRC_JD2_IN4N << 4), |
| 45 | BYT_RT5640_JD_SRC_GPIO2 = (RT5640_JD_SRC_GPIO2 << 4), |
| 46 | BYT_RT5640_JD_SRC_GPIO3 = (RT5640_JD_SRC_GPIO3 << 4), |
| 47 | BYT_RT5640_JD_SRC_GPIO4 = (RT5640_JD_SRC_GPIO4 << 4), |
| 48 | }; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 49 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 50 | enum { |
| 51 | BYT_RT5640_OVCD_TH_600UA = (6 << 8), |
| 52 | BYT_RT5640_OVCD_TH_1500UA = (15 << 8), |
| 53 | BYT_RT5640_OVCD_TH_2000UA = (20 << 8), |
| 54 | }; |
| 55 | |
| 56 | enum { |
| 57 | BYT_RT5640_OVCD_SF_0P5 = (RT5640_OVCD_SF_0P5 << 13), |
| 58 | BYT_RT5640_OVCD_SF_0P75 = (RT5640_OVCD_SF_0P75 << 13), |
| 59 | BYT_RT5640_OVCD_SF_1P0 = (RT5640_OVCD_SF_1P0 << 13), |
| 60 | BYT_RT5640_OVCD_SF_1P5 = (RT5640_OVCD_SF_1P5 << 13), |
| 61 | }; |
| 62 | |
| 63 | #define BYT_RT5640_MAP(quirk) ((quirk) & GENMASK(3, 0)) |
| 64 | #define BYT_RT5640_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4) |
| 65 | #define BYT_RT5640_OVCD_TH(quirk) (((quirk) & GENMASK(12, 8)) >> 8) |
| 66 | #define BYT_RT5640_OVCD_SF(quirk) (((quirk) & GENMASK(14, 13)) >> 13) |
| 67 | #define BYT_RT5640_JD_NOT_INV BIT(16) |
| 68 | #define BYT_RT5640_MONO_SPEAKER BIT(17) |
| 69 | #define BYT_RT5640_DIFF_MIC BIT(18) /* default is single-ended */ |
| 70 | #define BYT_RT5640_SSP2_AIF2 BIT(19) /* default is using AIF1 */ |
| 71 | #define BYT_RT5640_SSP0_AIF1 BIT(20) |
| 72 | #define BYT_RT5640_SSP0_AIF2 BIT(21) |
| 73 | #define BYT_RT5640_MCLK_EN BIT(22) |
| 74 | #define BYT_RT5640_MCLK_25MHZ BIT(23) |
Hans de Goede | 1851ccf | 2021-01-09 22:01:17 +0100 | [diff] [blame] | 75 | #define BYT_RT5640_NO_SPEAKERS BIT(24) |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 76 | |
Hans de Goede | 96a388fe | 2018-05-13 09:24:30 +0200 | [diff] [blame] | 77 | #define BYTCR_INPUT_DEFAULTS \ |
| 78 | (BYT_RT5640_IN3_MAP | \ |
Hans de Goede | 56ff440 | 2018-05-13 09:24:31 +0200 | [diff] [blame] | 79 | BYT_RT5640_JD_SRC_JD1_IN4P | \ |
| 80 | BYT_RT5640_OVCD_TH_2000UA | \ |
| 81 | BYT_RT5640_OVCD_SF_0P75 | \ |
Hans de Goede | 96a388fe | 2018-05-13 09:24:30 +0200 | [diff] [blame] | 82 | BYT_RT5640_DIFF_MIC) |
| 83 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 84 | /* in-diff or dmic-pin + jdsrc + ovcd-th + -sf + jd-inv + terminating entry */ |
| 85 | #define MAX_NO_PROPS 6 |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 86 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 87 | struct byt_rt5640_private { |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 88 | struct snd_soc_jack jack; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 89 | struct clk *mclk; |
| 90 | }; |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 91 | static bool is_bytcr; |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 92 | |
Pierre-Louis Bossart | bf46241 | 2016-11-12 18:07:46 -0600 | [diff] [blame] | 93 | static unsigned long byt_rt5640_quirk = BYT_RT5640_MCLK_EN; |
Pierre-Louis Bossart | 2fb2a19 | 2019-04-19 15:12:17 -0500 | [diff] [blame] | 94 | static int quirk_override = -1; |
| 95 | module_param_named(quirk, quirk_override, int, 0444); |
Takashi Iwai | 9f2cf73 | 2017-04-23 09:22:56 +0200 | [diff] [blame] | 96 | MODULE_PARM_DESC(quirk, "Board-specific quirk override"); |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 97 | |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 98 | static void log_quirks(struct device *dev) |
| 99 | { |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 100 | int map; |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 101 | bool has_mclk = false; |
| 102 | bool has_ssp0 = false; |
| 103 | bool has_ssp0_aif1 = false; |
| 104 | bool has_ssp0_aif2 = false; |
| 105 | bool has_ssp2_aif2 = false; |
| 106 | |
| 107 | map = BYT_RT5640_MAP(byt_rt5640_quirk); |
| 108 | switch (map) { |
| 109 | case BYT_RT5640_DMIC1_MAP: |
| 110 | dev_info(dev, "quirk DMIC1_MAP enabled\n"); |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 111 | break; |
| 112 | case BYT_RT5640_DMIC2_MAP: |
| 113 | dev_info(dev, "quirk DMIC2_MAP enabled\n"); |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 114 | break; |
| 115 | case BYT_RT5640_IN1_MAP: |
| 116 | dev_info(dev, "quirk IN1_MAP enabled\n"); |
| 117 | break; |
| 118 | case BYT_RT5640_IN3_MAP: |
| 119 | dev_info(dev, "quirk IN3_MAP enabled\n"); |
| 120 | break; |
Hans de Goede | 46466ab | 2021-01-09 22:01:18 +0100 | [diff] [blame] | 121 | case BYT_RT5640_NO_INTERNAL_MIC_MAP: |
| 122 | dev_info(dev, "quirk NO_INTERNAL_MIC_MAP enabled\n"); |
| 123 | break; |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 124 | default: |
| 125 | dev_err(dev, "quirk map 0x%x is not supported, microphone input will not work\n", map); |
| 126 | break; |
| 127 | } |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 128 | if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) { |
| 129 | dev_info(dev, "quirk realtek,jack-detect-source %ld\n", |
| 130 | BYT_RT5640_JDSRC(byt_rt5640_quirk)); |
| 131 | dev_info(dev, "quirk realtek,over-current-threshold-microamp %ld\n", |
| 132 | BYT_RT5640_OVCD_TH(byt_rt5640_quirk) * 100); |
| 133 | dev_info(dev, "quirk realtek,over-current-scale-factor %ld\n", |
| 134 | BYT_RT5640_OVCD_SF(byt_rt5640_quirk)); |
| 135 | } |
| 136 | if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV) |
| 137 | dev_info(dev, "quirk JD_NOT_INV enabled\n"); |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 138 | if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 139 | dev_info(dev, "quirk MONO_SPEAKER enabled\n"); |
Hans de Goede | 1851ccf | 2021-01-09 22:01:17 +0100 | [diff] [blame] | 140 | if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS) |
| 141 | dev_info(dev, "quirk NO_SPEAKERS enabled\n"); |
Hans de Goede | a3ad291 | 2018-05-13 09:24:26 +0200 | [diff] [blame] | 142 | if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) |
| 143 | dev_info(dev, "quirk DIFF_MIC enabled\n"); |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 144 | if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) { |
| 145 | dev_info(dev, "quirk SSP0_AIF1 enabled\n"); |
| 146 | has_ssp0 = true; |
| 147 | has_ssp0_aif1 = true; |
| 148 | } |
| 149 | if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) { |
| 150 | dev_info(dev, "quirk SSP0_AIF2 enabled\n"); |
| 151 | has_ssp0 = true; |
| 152 | has_ssp0_aif2 = true; |
| 153 | } |
| 154 | if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) { |
| 155 | dev_info(dev, "quirk SSP2_AIF2 enabled\n"); |
| 156 | has_ssp2_aif2 = true; |
| 157 | } |
| 158 | if (is_bytcr && !has_ssp0) |
| 159 | dev_err(dev, "Invalid routing, bytcr detected but no SSP0-based quirk, audio cannot work with SSP2 on bytcr\n"); |
| 160 | if (has_ssp0_aif1 && has_ssp0_aif2) |
| 161 | dev_err(dev, "Invalid routing, SSP0 cannot be connected to both AIF1 and AIF2\n"); |
| 162 | if (has_ssp0 && has_ssp2_aif2) |
| 163 | dev_err(dev, "Invalid routing, cannot have both SSP0 and SSP2 connected to codec\n"); |
| 164 | |
| 165 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { |
| 166 | dev_info(dev, "quirk MCLK_EN enabled\n"); |
| 167 | has_mclk = true; |
| 168 | } |
| 169 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) { |
| 170 | if (has_mclk) |
| 171 | dev_info(dev, "quirk MCLK_25MHZ enabled\n"); |
| 172 | else |
| 173 | dev_err(dev, "quirk MCLK_25MHZ enabled but quirk MCLK not selected, will be ignored\n"); |
| 174 | } |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 175 | } |
| 176 | |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 177 | static int byt_rt5640_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, |
| 178 | int rate) |
| 179 | { |
| 180 | int ret; |
| 181 | |
| 182 | /* Configure the PLL before selecting it */ |
| 183 | if (!(byt_rt5640_quirk & BYT_RT5640_MCLK_EN)) { |
| 184 | /* use bitclock as PLL input */ |
| 185 | if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) || |
| 186 | (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { |
| 187 | /* 2x16 bit slots on SSP0 */ |
| 188 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
| 189 | RT5640_PLL1_S_BCLK1, |
| 190 | rate * 32, rate * 512); |
| 191 | } else { |
| 192 | /* 2x15 bit slots on SSP2 */ |
| 193 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
| 194 | RT5640_PLL1_S_BCLK1, |
| 195 | rate * 50, rate * 512); |
| 196 | } |
| 197 | } else { |
| 198 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) { |
| 199 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
| 200 | RT5640_PLL1_S_MCLK, |
| 201 | 25000000, rate * 512); |
| 202 | } else { |
| 203 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
| 204 | RT5640_PLL1_S_MCLK, |
| 205 | 19200000, rate * 512); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | if (ret < 0) { |
Hans de Goede | a3a956a | 2018-05-11 11:52:16 +0200 | [diff] [blame] | 210 | dev_err(codec_dai->component->dev, "can't set pll: %d\n", ret); |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 211 | return ret; |
| 212 | } |
| 213 | |
| 214 | ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1, |
| 215 | rate * 512, SND_SOC_CLOCK_IN); |
| 216 | if (ret < 0) { |
Hans de Goede | a3a956a | 2018-05-11 11:52:16 +0200 | [diff] [blame] | 217 | dev_err(codec_dai->component->dev, "can't set clock %d\n", ret); |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 218 | return ret; |
| 219 | } |
| 220 | |
| 221 | return 0; |
| 222 | } |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 223 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 224 | #define BYT_CODEC_DAI1 "rt5640-aif1" |
| 225 | #define BYT_CODEC_DAI2 "rt5640-aif2" |
| 226 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 227 | static int platform_clock_control(struct snd_soc_dapm_widget *w, |
| 228 | struct snd_kcontrol *k, int event) |
| 229 | { |
| 230 | struct snd_soc_dapm_context *dapm = w->dapm; |
| 231 | struct snd_soc_card *card = dapm->card; |
| 232 | struct snd_soc_dai *codec_dai; |
| 233 | struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); |
| 234 | int ret; |
| 235 | |
Pierre-Louis Bossart | dfb6ec7 | 2017-10-12 18:38:03 -0500 | [diff] [blame] | 236 | codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1); |
| 237 | if (!codec_dai) |
| 238 | codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2); |
| 239 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 240 | if (!codec_dai) { |
| 241 | dev_err(card->dev, |
| 242 | "Codec dai not found; Unable to set platform clock\n"); |
| 243 | return -EIO; |
| 244 | } |
| 245 | |
| 246 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 247 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 248 | ret = clk_prepare_enable(priv->mclk); |
| 249 | if (ret < 0) { |
| 250 | dev_err(card->dev, |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 251 | "could not configure MCLK state\n"); |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 252 | return ret; |
| 253 | } |
| 254 | } |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 255 | ret = byt_rt5640_prepare_and_enable_pll1(codec_dai, 48000); |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 256 | } else { |
| 257 | /* |
| 258 | * Set codec clock source to internal clock before |
| 259 | * turning off the platform clock. Codec needs clock |
| 260 | * for Jack detection and button press |
| 261 | */ |
| 262 | ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_RCCLK, |
Pierre-Louis Bossart | 60448b0 | 2017-01-04 15:44:52 -0600 | [diff] [blame] | 263 | 48000 * 512, |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 264 | SND_SOC_CLOCK_IN); |
| 265 | if (!ret) { |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 266 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 267 | clk_disable_unprepare(priv->mclk); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | if (ret < 0) { |
| 272 | dev_err(card->dev, "can't set codec sysclk: %d\n", ret); |
| 273 | return ret; |
| 274 | } |
| 275 | |
| 276 | return 0; |
| 277 | } |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 278 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 279 | static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 280 | SND_SOC_DAPM_HP("Headphone", NULL), |
| 281 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
Pierre-Louis Bossart | e2be1da | 2015-12-17 20:35:40 -0600 | [diff] [blame] | 282 | SND_SOC_DAPM_MIC("Internal Mic", NULL), |
| 283 | SND_SOC_DAPM_SPK("Speaker", NULL), |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 284 | SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, |
| 285 | platform_clock_control, SND_SOC_DAPM_PRE_PMU | |
| 286 | SND_SOC_DAPM_POST_PMD), |
| 287 | |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 288 | }; |
| 289 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 290 | static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 291 | {"Headphone", NULL, "Platform Clock"}, |
| 292 | {"Headset Mic", NULL, "Platform Clock"}, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 293 | {"Headset Mic", NULL, "MICBIAS1"}, |
Pierre-Louis Bossart | e2be1da | 2015-12-17 20:35:40 -0600 | [diff] [blame] | 294 | {"IN2P", NULL, "Headset Mic"}, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 295 | {"Headphone", NULL, "HPOL"}, |
| 296 | {"Headphone", NULL, "HPOR"}, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 297 | }; |
| 298 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 299 | static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = { |
Hans de Goede | dccd1df | 2021-08-02 16:24:56 +0200 | [diff] [blame^] | 300 | {"Internal Mic", NULL, "Platform Clock"}, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 301 | {"DMIC1", NULL, "Internal Mic"}, |
| 302 | }; |
| 303 | |
| 304 | static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic2_map[] = { |
Hans de Goede | dccd1df | 2021-08-02 16:24:56 +0200 | [diff] [blame^] | 305 | {"Internal Mic", NULL, "Platform Clock"}, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 306 | {"DMIC2", NULL, "Internal Mic"}, |
| 307 | }; |
| 308 | |
| 309 | static const struct snd_soc_dapm_route byt_rt5640_intmic_in1_map[] = { |
Hans de Goede | dccd1df | 2021-08-02 16:24:56 +0200 | [diff] [blame^] | 310 | {"Internal Mic", NULL, "Platform Clock"}, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 311 | {"Internal Mic", NULL, "MICBIAS1"}, |
| 312 | {"IN1P", NULL, "Internal Mic"}, |
| 313 | }; |
| 314 | |
Pierre-Louis Bossart | 59e8b65 | 2016-08-12 16:27:54 -0500 | [diff] [blame] | 315 | static const struct snd_soc_dapm_route byt_rt5640_intmic_in3_map[] = { |
Hans de Goede | dccd1df | 2021-08-02 16:24:56 +0200 | [diff] [blame^] | 316 | {"Internal Mic", NULL, "Platform Clock"}, |
Pierre-Louis Bossart | 59e8b65 | 2016-08-12 16:27:54 -0500 | [diff] [blame] | 317 | {"Internal Mic", NULL, "MICBIAS1"}, |
| 318 | {"IN3P", NULL, "Internal Mic"}, |
| 319 | }; |
| 320 | |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 321 | static const struct snd_soc_dapm_route byt_rt5640_ssp2_aif1_map[] = { |
| 322 | {"ssp2 Tx", NULL, "codec_out0"}, |
| 323 | {"ssp2 Tx", NULL, "codec_out1"}, |
| 324 | {"codec_in0", NULL, "ssp2 Rx"}, |
| 325 | {"codec_in1", NULL, "ssp2 Rx"}, |
| 326 | |
| 327 | {"AIF1 Playback", NULL, "ssp2 Tx"}, |
| 328 | {"ssp2 Rx", NULL, "AIF1 Capture"}, |
| 329 | }; |
| 330 | |
| 331 | static const struct snd_soc_dapm_route byt_rt5640_ssp2_aif2_map[] = { |
| 332 | {"ssp2 Tx", NULL, "codec_out0"}, |
| 333 | {"ssp2 Tx", NULL, "codec_out1"}, |
| 334 | {"codec_in0", NULL, "ssp2 Rx"}, |
| 335 | {"codec_in1", NULL, "ssp2 Rx"}, |
| 336 | |
| 337 | {"AIF2 Playback", NULL, "ssp2 Tx"}, |
| 338 | {"ssp2 Rx", NULL, "AIF2 Capture"}, |
| 339 | }; |
| 340 | |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 341 | static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif1_map[] = { |
| 342 | {"ssp0 Tx", NULL, "modem_out"}, |
| 343 | {"modem_in", NULL, "ssp0 Rx"}, |
| 344 | |
| 345 | {"AIF1 Playback", NULL, "ssp0 Tx"}, |
| 346 | {"ssp0 Rx", NULL, "AIF1 Capture"}, |
| 347 | }; |
| 348 | |
| 349 | static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif2_map[] = { |
| 350 | {"ssp0 Tx", NULL, "modem_out"}, |
| 351 | {"modem_in", NULL, "ssp0 Rx"}, |
| 352 | |
| 353 | {"AIF2 Playback", NULL, "ssp0 Tx"}, |
| 354 | {"ssp0 Rx", NULL, "AIF2 Capture"}, |
| 355 | }; |
| 356 | |
Pierre-Louis Bossart | 68817cd | 2016-08-12 16:27:45 -0500 | [diff] [blame] | 357 | static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = { |
Hans de Goede | dccd1df | 2021-08-02 16:24:56 +0200 | [diff] [blame^] | 358 | {"Speaker", NULL, "Platform Clock"}, |
Pierre-Louis Bossart | 68817cd | 2016-08-12 16:27:45 -0500 | [diff] [blame] | 359 | {"Speaker", NULL, "SPOLP"}, |
| 360 | {"Speaker", NULL, "SPOLN"}, |
| 361 | {"Speaker", NULL, "SPORP"}, |
| 362 | {"Speaker", NULL, "SPORN"}, |
| 363 | }; |
| 364 | |
| 365 | static const struct snd_soc_dapm_route byt_rt5640_mono_spk_map[] = { |
Hans de Goede | dccd1df | 2021-08-02 16:24:56 +0200 | [diff] [blame^] | 366 | {"Speaker", NULL, "Platform Clock"}, |
Pierre-Louis Bossart | 68817cd | 2016-08-12 16:27:45 -0500 | [diff] [blame] | 367 | {"Speaker", NULL, "SPOLP"}, |
| 368 | {"Speaker", NULL, "SPOLN"}, |
| 369 | }; |
| 370 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 371 | static const struct snd_kcontrol_new byt_rt5640_controls[] = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 372 | SOC_DAPM_PIN_SWITCH("Headphone"), |
| 373 | SOC_DAPM_PIN_SWITCH("Headset Mic"), |
Pierre-Louis Bossart | e2be1da | 2015-12-17 20:35:40 -0600 | [diff] [blame] | 374 | SOC_DAPM_PIN_SWITCH("Internal Mic"), |
| 375 | SOC_DAPM_PIN_SWITCH("Speaker"), |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 376 | }; |
| 377 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 378 | static struct snd_soc_jack_pin rt5640_pins[] = { |
| 379 | { |
| 380 | .pin = "Headphone", |
| 381 | .mask = SND_JACK_HEADPHONE, |
| 382 | }, |
| 383 | { |
| 384 | .pin = "Headset Mic", |
| 385 | .mask = SND_JACK_MICROPHONE, |
| 386 | }, |
| 387 | }; |
| 388 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 389 | static int byt_rt5640_aif1_hw_params(struct snd_pcm_substream *substream, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 390 | struct snd_pcm_hw_params *params) |
| 391 | { |
Kuninori Morimoto | 2207b93 | 2020-07-27 10:08:29 +0900 | [diff] [blame] | 392 | struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
Kuninori Morimoto | 0d1571c | 2020-03-23 14:19:05 +0900 | [diff] [blame] | 393 | struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 394 | |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 395 | return byt_rt5640_prepare_and_enable_pll1(dai, params_rate(params)); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 396 | } |
| 397 | |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 398 | /* Please keep this list alphabetically sorted */ |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 399 | static const struct dmi_system_id byt_rt5640_quirk_table[] = { |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 400 | { /* Acer Iconia Tab 8 W1-810 */ |
| 401 | .matches = { |
| 402 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 403 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Iconia W1-810"), |
| 404 | }, |
| 405 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 406 | BYT_RT5640_JD_SRC_JD1_IN4P | |
Hans de Goede | f12a0a3 | 2018-06-03 15:42:32 +0200 | [diff] [blame] | 407 | BYT_RT5640_OVCD_TH_1500UA | |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 408 | BYT_RT5640_OVCD_SF_0P75 | |
| 409 | BYT_RT5640_SSP0_AIF1 | |
| 410 | BYT_RT5640_MCLK_EN), |
| 411 | }, |
Hans de Goede | c58947a | 2021-02-16 22:35:55 +0100 | [diff] [blame] | 412 | { /* Acer One 10 S1002 */ |
| 413 | .matches = { |
| 414 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 415 | DMI_MATCH(DMI_PRODUCT_NAME, "One S1002"), |
| 416 | }, |
| 417 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 418 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 419 | BYT_RT5640_OVCD_TH_2000UA | |
| 420 | BYT_RT5640_OVCD_SF_0P75 | |
| 421 | BYT_RT5640_DIFF_MIC | |
| 422 | BYT_RT5640_SSP0_AIF2 | |
| 423 | BYT_RT5640_MCLK_EN), |
| 424 | }, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 425 | { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 426 | .matches = { |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 427 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 428 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"), |
| 429 | }, |
Hans de Goede | 0bb8877 | 2019-11-19 15:51:38 +0100 | [diff] [blame] | 430 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 431 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 432 | BYT_RT5640_OVCD_TH_2000UA | |
| 433 | BYT_RT5640_OVCD_SF_0P75 | |
| 434 | BYT_RT5640_SSP0_AIF1 | |
| 435 | BYT_RT5640_MCLK_EN), |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 436 | }, |
| 437 | { |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 438 | .matches = { |
Hans de Goede | bcf441a | 2018-05-28 22:26:49 +0200 | [diff] [blame] | 439 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"), |
| 440 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 80 Cesium"), |
| 441 | }, |
| 442 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 443 | BYT_RT5640_MONO_SPEAKER | |
| 444 | BYT_RT5640_SSP0_AIF1 | |
| 445 | BYT_RT5640_MCLK_EN), |
| 446 | }, |
| 447 | { |
| 448 | .matches = { |
Chris Chiu | 1bea225 | 2020-12-08 14:04:14 +0800 | [diff] [blame] | 449 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"), |
| 450 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 140 CESIUM"), |
| 451 | }, |
| 452 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 453 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 454 | BYT_RT5640_OVCD_TH_2000UA | |
| 455 | BYT_RT5640_OVCD_SF_0P75 | |
| 456 | BYT_RT5640_SSP0_AIF1 | |
| 457 | BYT_RT5640_MCLK_EN), |
| 458 | }, |
| 459 | { |
| 460 | .matches = { |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 461 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
Stephan Gerhold | 51a13e4 | 2019-01-02 20:39:08 +0100 | [diff] [blame] | 462 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"), |
| 463 | }, |
| 464 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 465 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 466 | BYT_RT5640_OVCD_TH_2000UA | |
| 467 | BYT_RT5640_OVCD_SF_0P75 | |
| 468 | BYT_RT5640_SSP0_AIF1 | |
| 469 | BYT_RT5640_MCLK_EN), |
| 470 | }, |
| 471 | { |
| 472 | .matches = { |
| 473 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 474 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"), |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 475 | }, |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 476 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 477 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 478 | BYT_RT5640_OVCD_TH_2000UA | |
| 479 | BYT_RT5640_OVCD_SF_0P75 | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 480 | BYT_RT5640_MCLK_EN), |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 481 | }, |
| 482 | { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 483 | .matches = { |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 484 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
| 485 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TAF"), |
| 486 | }, |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 487 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
Hans de Goede | b7c7203 | 2021-03-12 12:48:50 +0100 | [diff] [blame] | 488 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 489 | BYT_RT5640_OVCD_TH_2000UA | |
| 490 | BYT_RT5640_OVCD_SF_0P75 | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 491 | BYT_RT5640_MONO_SPEAKER | |
| 492 | BYT_RT5640_DIFF_MIC | |
| 493 | BYT_RT5640_SSP0_AIF2 | |
| 494 | BYT_RT5640_MCLK_EN), |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 495 | }, |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 496 | { /* Chuwi Vi8 (CWI506) */ |
| 497 | .matches = { |
| 498 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| 499 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "i86"), |
| 500 | /* The above are too generic, also match BIOS info */ |
| 501 | DMI_MATCH(DMI_BIOS_VERSION, "CHUWI.D86JLBNR"), |
| 502 | }, |
| 503 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 504 | BYT_RT5640_MONO_SPEAKER | |
| 505 | BYT_RT5640_SSP0_AIF1 | |
| 506 | BYT_RT5640_MCLK_EN), |
| 507 | }, |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 508 | { |
Hans de Goede | d5a1826 | 2018-06-08 10:19:25 +0200 | [diff] [blame] | 509 | /* Chuwi Vi10 (CWI505) */ |
| 510 | .matches = { |
| 511 | DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"), |
| 512 | DMI_MATCH(DMI_BOARD_NAME, "BYT-PF02"), |
| 513 | DMI_MATCH(DMI_SYS_VENDOR, "ilife"), |
| 514 | DMI_MATCH(DMI_PRODUCT_NAME, "S165"), |
| 515 | }, |
| 516 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 517 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 518 | BYT_RT5640_OVCD_TH_2000UA | |
| 519 | BYT_RT5640_OVCD_SF_0P75 | |
| 520 | BYT_RT5640_DIFF_MIC | |
| 521 | BYT_RT5640_SSP0_AIF1 | |
| 522 | BYT_RT5640_MCLK_EN), |
| 523 | }, |
| 524 | { |
Hans de Goede | 875c40e | 2021-03-25 23:10:54 +0100 | [diff] [blame] | 525 | /* Chuwi Hi8 (CWI509) */ |
| 526 | .matches = { |
| 527 | DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"), |
| 528 | DMI_MATCH(DMI_BOARD_NAME, "BYT-PA03C"), |
| 529 | DMI_MATCH(DMI_SYS_VENDOR, "ilife"), |
| 530 | DMI_MATCH(DMI_PRODUCT_NAME, "S806"), |
| 531 | }, |
| 532 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 533 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 534 | BYT_RT5640_OVCD_TH_2000UA | |
| 535 | BYT_RT5640_OVCD_SF_0P75 | |
| 536 | BYT_RT5640_MONO_SPEAKER | |
| 537 | BYT_RT5640_DIFF_MIC | |
| 538 | BYT_RT5640_SSP0_AIF1 | |
| 539 | BYT_RT5640_MCLK_EN), |
| 540 | }, |
| 541 | { |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 542 | .matches = { |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 543 | DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), |
| 544 | DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"), |
| 545 | }, |
| 546 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP), |
| 547 | }, |
Hans de Goede | 9ee6f8a | 2018-07-01 11:30:23 +0200 | [diff] [blame] | 548 | { /* Connect Tablet 9 */ |
| 549 | .matches = { |
| 550 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Connect"), |
| 551 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Tablet 9"), |
| 552 | }, |
| 553 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 554 | BYT_RT5640_MONO_SPEAKER | |
| 555 | BYT_RT5640_SSP0_AIF1 | |
| 556 | BYT_RT5640_MCLK_EN), |
| 557 | }, |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 558 | { |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 559 | .matches = { |
Hans de Goede | 6748fb7 | 2018-05-13 09:24:27 +0200 | [diff] [blame] | 560 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 561 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Venue 8 Pro 5830"), |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 562 | }, |
Hans de Goede | 6748fb7 | 2018-05-13 09:24:27 +0200 | [diff] [blame] | 563 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 564 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 565 | BYT_RT5640_OVCD_TH_2000UA | |
| 566 | BYT_RT5640_OVCD_SF_0P75 | |
Hans de Goede | 6748fb7 | 2018-05-13 09:24:27 +0200 | [diff] [blame] | 567 | BYT_RT5640_MONO_SPEAKER | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 568 | BYT_RT5640_MCLK_EN), |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 569 | }, |
Hans de Goede | bdea43f | 2021-02-16 22:35:52 +0100 | [diff] [blame] | 570 | { /* Estar Beauty HD MID 7316R */ |
| 571 | .matches = { |
| 572 | DMI_MATCH(DMI_SYS_VENDOR, "Estar"), |
| 573 | DMI_MATCH(DMI_PRODUCT_NAME, "eSTAR BEAUTY HD Intel Quad core"), |
| 574 | }, |
| 575 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 576 | BYT_RT5640_MONO_SPEAKER | |
| 577 | BYT_RT5640_SSP0_AIF1 | |
| 578 | BYT_RT5640_MCLK_EN), |
| 579 | }, |
Hans de Goede | 28c268d | 2021-05-08 17:01:45 +0200 | [diff] [blame] | 580 | { /* Glavey TM800A550L */ |
| 581 | .matches = { |
| 582 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 583 | DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 584 | /* Above strings are too generic, also match on BIOS version */ |
| 585 | DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"), |
| 586 | }, |
| 587 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 588 | BYT_RT5640_SSP0_AIF1 | |
| 589 | BYT_RT5640_MCLK_EN), |
| 590 | }, |
Jorge Fernandez Monteagudo | 55fc205 | 2016-01-04 17:20:30 -0600 | [diff] [blame] | 591 | { |
Jorge Fernandez Monteagudo | 55fc205 | 2016-01-04 17:20:30 -0600 | [diff] [blame] | 592 | .matches = { |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 593 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 594 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP ElitePad 1000 G2"), |
Jorge Fernandez Monteagudo | 55fc205 | 2016-01-04 17:20:30 -0600 | [diff] [blame] | 595 | }, |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 596 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 597 | BYT_RT5640_MCLK_EN), |
Jorge Fernandez Monteagudo | 55fc205 | 2016-01-04 17:20:30 -0600 | [diff] [blame] | 598 | }, |
Hans de Goede | fbdae7d | 2020-11-18 13:15:15 +0100 | [diff] [blame] | 599 | { /* HP Pavilion x2 10-k0XX, 10-n0XX */ |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 600 | .matches = { |
Hans de Goede | fbdae7d | 2020-11-18 13:15:15 +0100 | [diff] [blame] | 601 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 602 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"), |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 603 | }, |
| 604 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 605 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 606 | BYT_RT5640_OVCD_TH_1500UA | |
| 607 | BYT_RT5640_OVCD_SF_0P75 | |
| 608 | BYT_RT5640_SSP0_AIF1 | |
| 609 | BYT_RT5640_MCLK_EN), |
| 610 | }, |
Hans de Goede | fbdae7d | 2020-11-18 13:15:15 +0100 | [diff] [blame] | 611 | { /* HP Pavilion x2 10-p0XX */ |
| 612 | .matches = { |
| 613 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 614 | DMI_MATCH(DMI_PRODUCT_NAME, "HP x2 Detachable 10-p0XX"), |
| 615 | }, |
| 616 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 617 | BYT_RT5640_JD_SRC_JD1_IN4P | |
Hans de Goede | ca08ddf | 2021-02-24 11:50:52 +0100 | [diff] [blame] | 618 | BYT_RT5640_OVCD_TH_2000UA | |
Hans de Goede | fbdae7d | 2020-11-18 13:15:15 +0100 | [diff] [blame] | 619 | BYT_RT5640_OVCD_SF_0P75 | |
| 620 | BYT_RT5640_MCLK_EN), |
| 621 | }, |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 622 | { /* HP Stream 7 */ |
| 623 | .matches = { |
| 624 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 625 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP Stream 7 Tablet"), |
| 626 | }, |
| 627 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 628 | BYT_RT5640_MONO_SPEAKER | |
| 629 | BYT_RT5640_JD_NOT_INV | |
| 630 | BYT_RT5640_SSP0_AIF1 | |
| 631 | BYT_RT5640_MCLK_EN), |
| 632 | }, |
| 633 | { /* I.T.Works TW891 */ |
| 634 | .matches = { |
| 635 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."), |
| 636 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TW891"), |
| 637 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."), |
| 638 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "TW891"), |
| 639 | }, |
| 640 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 641 | BYT_RT5640_MONO_SPEAKER | |
| 642 | BYT_RT5640_SSP0_AIF1 | |
| 643 | BYT_RT5640_MCLK_EN), |
| 644 | }, |
| 645 | { /* Lamina I8270 / T701BR.SE */ |
| 646 | .matches = { |
| 647 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Lamina"), |
| 648 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "T701BR.SE"), |
| 649 | }, |
| 650 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 651 | BYT_RT5640_MONO_SPEAKER | |
| 652 | BYT_RT5640_JD_NOT_INV | |
| 653 | BYT_RT5640_SSP0_AIF1 | |
| 654 | BYT_RT5640_MCLK_EN), |
| 655 | }, |
Hans de Goede | 81583af | 2018-07-07 12:22:10 +0200 | [diff] [blame] | 656 | { /* Lenovo Miix 2 8 */ |
| 657 | .matches = { |
| 658 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 659 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "20326"), |
| 660 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Hiking"), |
| 661 | }, |
| 662 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 663 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 664 | BYT_RT5640_OVCD_TH_2000UA | |
| 665 | BYT_RT5640_OVCD_SF_0P75 | |
| 666 | BYT_RT5640_MONO_SPEAKER | |
| 667 | BYT_RT5640_MCLK_EN), |
| 668 | }, |
Hans de Goede | f0353e1 | 2021-05-08 17:01:46 +0200 | [diff] [blame] | 669 | { /* Lenovo Miix 3-830 */ |
| 670 | .matches = { |
| 671 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
| 672 | DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 3-830"), |
| 673 | }, |
| 674 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 675 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 676 | BYT_RT5640_OVCD_TH_2000UA | |
| 677 | BYT_RT5640_OVCD_SF_0P75 | |
| 678 | BYT_RT5640_MONO_SPEAKER | |
| 679 | BYT_RT5640_DIFF_MIC | |
| 680 | BYT_RT5640_SSP0_AIF1 | |
| 681 | BYT_RT5640_MCLK_EN), |
| 682 | }, |
Hans de Goede | 260c48b | 2018-08-12 13:42:06 +0200 | [diff] [blame] | 683 | { /* Linx Linx7 tablet */ |
| 684 | .matches = { |
| 685 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LINX"), |
| 686 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "LINX7"), |
| 687 | }, |
| 688 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 689 | BYT_RT5640_MONO_SPEAKER | |
| 690 | BYT_RT5640_JD_NOT_INV | |
| 691 | BYT_RT5640_SSP0_AIF1 | |
| 692 | BYT_RT5640_MCLK_EN), |
| 693 | }, |
Hans de Goede | df33032 | 2021-01-09 22:01:19 +0100 | [diff] [blame] | 694 | { /* Mele PCG03 Mini PC */ |
| 695 | .matches = { |
| 696 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"), |
| 697 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Mini PC"), |
| 698 | }, |
| 699 | .driver_data = (void *)(BYT_RT5640_NO_INTERNAL_MIC_MAP | |
| 700 | BYT_RT5640_NO_SPEAKERS | |
| 701 | BYT_RT5640_SSP0_AIF1), |
| 702 | }, |
Hans de Goede | 6a01371 | 2020-09-01 10:06:23 +0200 | [diff] [blame] | 703 | { /* MPMAN Converter 9, similar hw as the I.T.Works TW891 2-in-1 */ |
| 704 | .matches = { |
| 705 | DMI_MATCH(DMI_SYS_VENDOR, "MPMAN"), |
| 706 | DMI_MATCH(DMI_PRODUCT_NAME, "Converter9"), |
| 707 | }, |
| 708 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 709 | BYT_RT5640_MONO_SPEAKER | |
| 710 | BYT_RT5640_SSP0_AIF1 | |
| 711 | BYT_RT5640_MCLK_EN), |
| 712 | }, |
Hans de Goede | c8b78f2 | 2020-04-05 15:37:26 +0200 | [diff] [blame] | 713 | { |
| 714 | /* MPMAN MPWIN895CL */ |
| 715 | .matches = { |
| 716 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MPMAN"), |
| 717 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MPWIN8900CL"), |
| 718 | }, |
| 719 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 720 | BYT_RT5640_MONO_SPEAKER | |
| 721 | BYT_RT5640_SSP0_AIF1 | |
| 722 | BYT_RT5640_MCLK_EN), |
| 723 | }, |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 724 | { /* MSI S100 tablet */ |
| 725 | .matches = { |
| 726 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Micro-Star International Co., Ltd."), |
| 727 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "S100"), |
| 728 | }, |
| 729 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 730 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 731 | BYT_RT5640_OVCD_TH_2000UA | |
| 732 | BYT_RT5640_OVCD_SF_0P75 | |
| 733 | BYT_RT5640_MONO_SPEAKER | |
| 734 | BYT_RT5640_DIFF_MIC | |
| 735 | BYT_RT5640_MCLK_EN), |
| 736 | }, |
Hans de Goede | 6cea359 | 2018-06-03 15:42:31 +0200 | [diff] [blame] | 737 | { /* Nuvison/TMax TM800W560 */ |
| 738 | .matches = { |
| 739 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TMAX"), |
| 740 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TM800W560L"), |
| 741 | }, |
| 742 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 743 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 744 | BYT_RT5640_OVCD_TH_2000UA | |
| 745 | BYT_RT5640_OVCD_SF_0P75 | |
| 746 | BYT_RT5640_JD_NOT_INV | |
| 747 | BYT_RT5640_DIFF_MIC | |
| 748 | BYT_RT5640_SSP0_AIF1 | |
| 749 | BYT_RT5640_MCLK_EN), |
| 750 | }, |
Hans de Goede | 260c48b | 2018-08-12 13:42:06 +0200 | [diff] [blame] | 751 | { /* Onda v975w */ |
| 752 | .matches = { |
| 753 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 754 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 755 | /* The above are too generic, also match BIOS info */ |
| 756 | DMI_EXACT_MATCH(DMI_BIOS_VERSION, "5.6.5"), |
| 757 | DMI_EXACT_MATCH(DMI_BIOS_DATE, "07/25/2014"), |
| 758 | }, |
| 759 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 760 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 761 | BYT_RT5640_OVCD_TH_2000UA | |
| 762 | BYT_RT5640_OVCD_SF_0P75 | |
| 763 | BYT_RT5640_DIFF_MIC | |
| 764 | BYT_RT5640_MCLK_EN), |
| 765 | }, |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 766 | { /* Pipo W4 */ |
| 767 | .matches = { |
| 768 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 769 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 770 | /* The above are too generic, also match BIOS info */ |
| 771 | DMI_MATCH(DMI_BIOS_VERSION, "V8L_WIN32_CHIPHD"), |
| 772 | }, |
| 773 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 774 | BYT_RT5640_MONO_SPEAKER | |
| 775 | BYT_RT5640_SSP0_AIF1 | |
| 776 | BYT_RT5640_MCLK_EN), |
| 777 | }, |
| 778 | { /* Point of View Mobii TAB-P800W (V2.0) */ |
| 779 | .matches = { |
| 780 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 781 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 782 | /* The above are too generic, also match BIOS info */ |
| 783 | DMI_EXACT_MATCH(DMI_BIOS_VERSION, "3BAIR1014"), |
| 784 | DMI_EXACT_MATCH(DMI_BIOS_DATE, "10/24/2014"), |
| 785 | }, |
| 786 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 787 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 788 | BYT_RT5640_OVCD_TH_2000UA | |
| 789 | BYT_RT5640_OVCD_SF_0P75 | |
| 790 | BYT_RT5640_MONO_SPEAKER | |
| 791 | BYT_RT5640_DIFF_MIC | |
| 792 | BYT_RT5640_SSP0_AIF2 | |
| 793 | BYT_RT5640_MCLK_EN), |
| 794 | }, |
| 795 | { /* Point of View Mobii TAB-P800W (V2.1) */ |
| 796 | .matches = { |
| 797 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 798 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 799 | /* The above are too generic, also match BIOS info */ |
| 800 | DMI_EXACT_MATCH(DMI_BIOS_VERSION, "3BAIR1013"), |
| 801 | DMI_EXACT_MATCH(DMI_BIOS_DATE, "08/22/2014"), |
| 802 | }, |
| 803 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 804 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 805 | BYT_RT5640_OVCD_TH_2000UA | |
| 806 | BYT_RT5640_OVCD_SF_0P75 | |
| 807 | BYT_RT5640_MONO_SPEAKER | |
| 808 | BYT_RT5640_DIFF_MIC | |
| 809 | BYT_RT5640_SSP0_AIF2 | |
| 810 | BYT_RT5640_MCLK_EN), |
| 811 | }, |
Hans de Goede | 02e5af6 | 2018-12-08 14:01:14 +0100 | [diff] [blame] | 812 | { /* Point of View Mobii TAB-P1005W-232 (V2.0) */ |
| 813 | .matches = { |
| 814 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "POV"), |
| 815 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "I102A"), |
| 816 | }, |
| 817 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 818 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 819 | BYT_RT5640_OVCD_TH_2000UA | |
| 820 | BYT_RT5640_OVCD_SF_0P75 | |
| 821 | BYT_RT5640_DIFF_MIC | |
| 822 | BYT_RT5640_SSP0_AIF1 | |
| 823 | BYT_RT5640_MCLK_EN), |
| 824 | }, |
Irina Tirdea | 0565e77 | 2016-08-12 16:27:58 -0500 | [diff] [blame] | 825 | { |
Hans de Goede | 271248f | 2018-12-08 14:01:13 +0100 | [diff] [blame] | 826 | /* Prowise PT301 */ |
| 827 | .matches = { |
| 828 | DMI_MATCH(DMI_SYS_VENDOR, "Prowise"), |
| 829 | DMI_MATCH(DMI_PRODUCT_NAME, "PT301"), |
| 830 | }, |
| 831 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 832 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 833 | BYT_RT5640_OVCD_TH_2000UA | |
| 834 | BYT_RT5640_OVCD_SF_0P75 | |
| 835 | BYT_RT5640_DIFF_MIC | |
| 836 | BYT_RT5640_SSP0_AIF1 | |
| 837 | BYT_RT5640_MCLK_EN), |
| 838 | }, |
| 839 | { |
Hans de Goede | 7eccc05 | 2019-12-03 23:14:42 +0100 | [diff] [blame] | 840 | /* Teclast X89 */ |
Irina Tirdea | 0565e77 | 2016-08-12 16:27:58 -0500 | [diff] [blame] | 841 | .matches = { |
Pierre-Louis Bossart | ec1c90e | 2016-08-12 16:27:59 -0500 | [diff] [blame] | 842 | DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"), |
| 843 | DMI_MATCH(DMI_BOARD_NAME, "tPAD"), |
| 844 | }, |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 845 | .driver_data = (void *)(BYT_RT5640_IN3_MAP | |
Hans de Goede | 7eccc05 | 2019-12-03 23:14:42 +0100 | [diff] [blame] | 846 | BYT_RT5640_JD_SRC_JD1_IN4P | |
| 847 | BYT_RT5640_OVCD_TH_2000UA | |
| 848 | BYT_RT5640_OVCD_SF_1P0 | |
| 849 | BYT_RT5640_SSP0_AIF1 | |
| 850 | BYT_RT5640_MCLK_EN), |
Pierre-Louis Bossart | ec1c90e | 2016-08-12 16:27:59 -0500 | [diff] [blame] | 851 | }, |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame] | 852 | { /* Toshiba Satellite Click Mini L9W-B */ |
| 853 | .matches = { |
| 854 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), |
| 855 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SATELLITE Click Mini L9W-B"), |
| 856 | }, |
| 857 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 858 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 859 | BYT_RT5640_OVCD_TH_1500UA | |
| 860 | BYT_RT5640_OVCD_SF_0P75 | |
| 861 | BYT_RT5640_SSP0_AIF1 | |
| 862 | BYT_RT5640_MCLK_EN), |
| 863 | }, |
Hans de Goede | 0e0e10f | 2020-05-18 09:24:16 +0200 | [diff] [blame] | 864 | { /* Toshiba Encore WT8-A */ |
| 865 | .matches = { |
| 866 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), |
| 867 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT8-A"), |
| 868 | }, |
| 869 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 870 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 871 | BYT_RT5640_OVCD_TH_2000UA | |
| 872 | BYT_RT5640_OVCD_SF_0P75 | |
| 873 | BYT_RT5640_JD_NOT_INV | |
| 874 | BYT_RT5640_MCLK_EN), |
| 875 | }, |
Hans de Goede | 199a5e8 | 2020-06-08 22:46:33 +0200 | [diff] [blame] | 876 | { /* Toshiba Encore WT10-A */ |
| 877 | .matches = { |
| 878 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), |
| 879 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT10-A-103"), |
| 880 | }, |
| 881 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 882 | BYT_RT5640_JD_SRC_JD1_IN4P | |
| 883 | BYT_RT5640_OVCD_TH_2000UA | |
| 884 | BYT_RT5640_OVCD_SF_0P75 | |
| 885 | BYT_RT5640_SSP0_AIF2 | |
| 886 | BYT_RT5640_MCLK_EN), |
| 887 | }, |
Hans de Goede | e1317cc | 2021-02-16 22:35:53 +0100 | [diff] [blame] | 888 | { /* Voyo Winpad A15 */ |
| 889 | .matches = { |
| 890 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 891 | DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 892 | /* Above strings are too generic, also match on BIOS date */ |
| 893 | DMI_MATCH(DMI_BIOS_DATE, "11/20/2014"), |
| 894 | }, |
| 895 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 896 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 897 | BYT_RT5640_OVCD_TH_2000UA | |
| 898 | BYT_RT5640_OVCD_SF_0P75 | |
| 899 | BYT_RT5640_DIFF_MIC | |
| 900 | BYT_RT5640_MCLK_EN), |
| 901 | }, |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 902 | { /* Catch-all for generic Insyde tablets, must be last */ |
youling257 | 5718004 | 2017-01-04 15:44:53 -0600 | [diff] [blame] | 903 | .matches = { |
| 904 | DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| 905 | }, |
Hans de Goede | 96a388fe | 2018-05-13 09:24:30 +0200 | [diff] [blame] | 906 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 907 | BYT_RT5640_MCLK_EN | |
| 908 | BYT_RT5640_SSP0_AIF1), |
youling257 | 5718004 | 2017-01-04 15:44:53 -0600 | [diff] [blame] | 909 | |
| 910 | }, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 911 | {} |
| 912 | }; |
| 913 | |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 914 | /* |
| 915 | * Note this MUST be called before snd_soc_register_card(), so that the props |
| 916 | * are in place before the codec component driver's probe function parses them. |
| 917 | */ |
| 918 | static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name) |
| 919 | { |
| 920 | struct property_entry props[MAX_NO_PROPS] = {}; |
| 921 | struct device *i2c_dev; |
| 922 | int ret, cnt = 0; |
| 923 | |
| 924 | i2c_dev = bus_find_device_by_name(&i2c_bus_type, NULL, i2c_dev_name); |
| 925 | if (!i2c_dev) |
| 926 | return -EPROBE_DEFER; |
| 927 | |
| 928 | switch (BYT_RT5640_MAP(byt_rt5640_quirk)) { |
Hans de Goede | a3ad291 | 2018-05-13 09:24:26 +0200 | [diff] [blame] | 929 | case BYT_RT5640_DMIC1_MAP: |
| 930 | props[cnt++] = PROPERTY_ENTRY_U32("realtek,dmic1-data-pin", |
| 931 | RT5640_DMIC1_DATA_PIN_IN1P); |
| 932 | break; |
| 933 | case BYT_RT5640_DMIC2_MAP: |
| 934 | props[cnt++] = PROPERTY_ENTRY_U32("realtek,dmic2-data-pin", |
| 935 | RT5640_DMIC2_DATA_PIN_IN1N); |
| 936 | break; |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 937 | case BYT_RT5640_IN1_MAP: |
| 938 | if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) |
| 939 | props[cnt++] = |
| 940 | PROPERTY_ENTRY_BOOL("realtek,in1-differential"); |
| 941 | break; |
| 942 | case BYT_RT5640_IN3_MAP: |
| 943 | if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) |
| 944 | props[cnt++] = |
| 945 | PROPERTY_ENTRY_BOOL("realtek,in3-differential"); |
| 946 | break; |
| 947 | } |
| 948 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 949 | if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) { |
| 950 | props[cnt++] = PROPERTY_ENTRY_U32( |
| 951 | "realtek,jack-detect-source", |
| 952 | BYT_RT5640_JDSRC(byt_rt5640_quirk)); |
| 953 | |
| 954 | props[cnt++] = PROPERTY_ENTRY_U32( |
| 955 | "realtek,over-current-threshold-microamp", |
| 956 | BYT_RT5640_OVCD_TH(byt_rt5640_quirk) * 100); |
| 957 | |
| 958 | props[cnt++] = PROPERTY_ENTRY_U32( |
| 959 | "realtek,over-current-scale-factor", |
| 960 | BYT_RT5640_OVCD_SF(byt_rt5640_quirk)); |
| 961 | } |
| 962 | |
| 963 | if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV) |
| 964 | props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); |
| 965 | |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 966 | ret = device_add_properties(i2c_dev, props); |
| 967 | put_device(i2c_dev); |
| 968 | |
| 969 | return ret; |
| 970 | } |
| 971 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 972 | static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) |
| 973 | { |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 974 | struct snd_soc_card *card = runtime->card; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 975 | struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); |
Kuninori Morimoto | 0d1571c | 2020-03-23 14:19:05 +0900 | [diff] [blame] | 976 | struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component; |
Hans de Goede | 46466ab | 2021-01-09 22:01:18 +0100 | [diff] [blame] | 977 | const struct snd_soc_dapm_route *custom_map = NULL; |
| 978 | int num_routes = 0; |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 979 | int ret; |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 980 | |
| 981 | card->dapm.idle_bias_off = true; |
| 982 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 983 | /* Start with RC clk for jack-detect (we disable MCLK below) */ |
| 984 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) |
| 985 | snd_soc_component_update_bits(component, RT5640_GLB_CLK, |
| 986 | RT5640_SCLK_SRC_MASK, RT5640_SCLK_SRC_RCCLK); |
| 987 | |
Kuninori Morimoto | d5a41b5 | 2018-01-29 03:42:46 +0000 | [diff] [blame] | 988 | rt5640_sel_asrc_clk_src(component, |
Pierre-Louis Bossart | 0ec66e2d | 2016-01-04 17:20:27 -0600 | [diff] [blame] | 989 | RT5640_DA_STEREO_FILTER | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 990 | RT5640_DA_MONO_L_FILTER | |
| 991 | RT5640_DA_MONO_R_FILTER | |
| 992 | RT5640_AD_STEREO_FILTER | |
| 993 | RT5640_AD_MONO_L_FILTER | |
| 994 | RT5640_AD_MONO_R_FILTER, |
Pierre-Louis Bossart | 0ec66e2d | 2016-01-04 17:20:27 -0600 | [diff] [blame] | 995 | RT5640_CLK_SEL_ASRC); |
| 996 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 997 | ret = snd_soc_add_card_controls(card, byt_rt5640_controls, |
| 998 | ARRAY_SIZE(byt_rt5640_controls)); |
| 999 | if (ret) { |
| 1000 | dev_err(card->dev, "unable to add card controls\n"); |
| 1001 | return ret; |
| 1002 | } |
| 1003 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1004 | switch (BYT_RT5640_MAP(byt_rt5640_quirk)) { |
| 1005 | case BYT_RT5640_IN1_MAP: |
| 1006 | custom_map = byt_rt5640_intmic_in1_map; |
| 1007 | num_routes = ARRAY_SIZE(byt_rt5640_intmic_in1_map); |
| 1008 | break; |
Pierre-Louis Bossart | 59e8b65 | 2016-08-12 16:27:54 -0500 | [diff] [blame] | 1009 | case BYT_RT5640_IN3_MAP: |
| 1010 | custom_map = byt_rt5640_intmic_in3_map; |
| 1011 | num_routes = ARRAY_SIZE(byt_rt5640_intmic_in3_map); |
| 1012 | break; |
Hans de Goede | 46466ab | 2021-01-09 22:01:18 +0100 | [diff] [blame] | 1013 | case BYT_RT5640_DMIC1_MAP: |
| 1014 | custom_map = byt_rt5640_intmic_dmic1_map; |
| 1015 | num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map); |
| 1016 | break; |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1017 | case BYT_RT5640_DMIC2_MAP: |
| 1018 | custom_map = byt_rt5640_intmic_dmic2_map; |
| 1019 | num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic2_map); |
| 1020 | break; |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1021 | } |
| 1022 | |
| 1023 | ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); |
| 1024 | if (ret) |
| 1025 | return ret; |
| 1026 | |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 1027 | if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) { |
| 1028 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 1029 | byt_rt5640_ssp2_aif2_map, |
| 1030 | ARRAY_SIZE(byt_rt5640_ssp2_aif2_map)); |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 1031 | } else if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) { |
| 1032 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 1033 | byt_rt5640_ssp0_aif1_map, |
| 1034 | ARRAY_SIZE(byt_rt5640_ssp0_aif1_map)); |
| 1035 | } else if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) { |
| 1036 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 1037 | byt_rt5640_ssp0_aif2_map, |
| 1038 | ARRAY_SIZE(byt_rt5640_ssp0_aif2_map)); |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 1039 | } else { |
| 1040 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 1041 | byt_rt5640_ssp2_aif1_map, |
| 1042 | ARRAY_SIZE(byt_rt5640_ssp2_aif1_map)); |
| 1043 | } |
| 1044 | if (ret) |
| 1045 | return ret; |
| 1046 | |
Pierre-Louis Bossart | 68817cd | 2016-08-12 16:27:45 -0500 | [diff] [blame] | 1047 | if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) { |
| 1048 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 1049 | byt_rt5640_mono_spk_map, |
| 1050 | ARRAY_SIZE(byt_rt5640_mono_spk_map)); |
Hans de Goede | 1851ccf | 2021-01-09 22:01:17 +0100 | [diff] [blame] | 1051 | } else if (!(byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS)) { |
Pierre-Louis Bossart | 68817cd | 2016-08-12 16:27:45 -0500 | [diff] [blame] | 1052 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 1053 | byt_rt5640_stereo_spk_map, |
| 1054 | ARRAY_SIZE(byt_rt5640_stereo_spk_map)); |
| 1055 | } |
| 1056 | if (ret) |
| 1057 | return ret; |
| 1058 | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 1059 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1060 | /* |
| 1061 | * The firmware might enable the clock at |
| 1062 | * boot (this information may or may not |
| 1063 | * be reflected in the enable clock register). |
| 1064 | * To change the rate we must disable the clock |
| 1065 | * first to cover these cases. Due to common |
| 1066 | * clock framework restrictions that do not allow |
| 1067 | * to disable a clock that has not been enabled, |
| 1068 | * we need to enable the clock first. |
| 1069 | */ |
| 1070 | ret = clk_prepare_enable(priv->mclk); |
| 1071 | if (!ret) |
| 1072 | clk_disable_unprepare(priv->mclk); |
| 1073 | |
| 1074 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) |
| 1075 | ret = clk_set_rate(priv->mclk, 25000000); |
| 1076 | else |
| 1077 | ret = clk_set_rate(priv->mclk, 19200000); |
| 1078 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1079 | if (ret) { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1080 | dev_err(card->dev, "unable to set MCLK rate\n"); |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1081 | return ret; |
| 1082 | } |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1083 | } |
| 1084 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1085 | if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) { |
| 1086 | ret = snd_soc_card_jack_new(card, "Headset", |
| 1087 | SND_JACK_HEADSET | SND_JACK_BTN_0, |
| 1088 | &priv->jack, rt5640_pins, |
| 1089 | ARRAY_SIZE(rt5640_pins)); |
| 1090 | if (ret) { |
| 1091 | dev_err(card->dev, "Jack creation failed %d\n", ret); |
| 1092 | return ret; |
| 1093 | } |
| 1094 | snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0, |
| 1095 | KEY_PLAYPAUSE); |
| 1096 | snd_soc_component_set_jack(component, &priv->jack, NULL); |
| 1097 | } |
| 1098 | |
| 1099 | return 0; |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1100 | } |
| 1101 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1102 | static int byt_rt5640_codec_fixup(struct snd_soc_pcm_runtime *rtd, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1103 | struct snd_pcm_hw_params *params) |
| 1104 | { |
| 1105 | struct snd_interval *rate = hw_param_interval(params, |
| 1106 | SNDRV_PCM_HW_PARAM_RATE); |
| 1107 | struct snd_interval *channels = hw_param_interval(params, |
| 1108 | SNDRV_PCM_HW_PARAM_CHANNELS); |
Erik Bussing | 332719b | 2020-01-15 17:46:16 +0100 | [diff] [blame] | 1109 | int ret, bits; |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1110 | |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 1111 | /* The DSP will covert the FE rate to 48k, stereo */ |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1112 | rate->min = rate->max = 48000; |
| 1113 | channels->min = channels->max = 2; |
| 1114 | |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 1115 | if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) || |
Erik Bussing | 332719b | 2020-01-15 17:46:16 +0100 | [diff] [blame] | 1116 | (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { |
Pierre-Louis Bossart | 8f98307d | 2016-08-16 18:28:22 -0500 | [diff] [blame] | 1117 | /* set SSP0 to 16-bit */ |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 1118 | params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); |
Erik Bussing | 332719b | 2020-01-15 17:46:16 +0100 | [diff] [blame] | 1119 | bits = 16; |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 1120 | } else { |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 1121 | /* set SSP2 to 24-bit */ |
| 1122 | params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); |
Erik Bussing | 332719b | 2020-01-15 17:46:16 +0100 | [diff] [blame] | 1123 | bits = 24; |
Sebastien Guiriec | 3f27ded | 2015-12-17 20:35:39 -0600 | [diff] [blame] | 1124 | } |
Erik Bussing | 332719b | 2020-01-15 17:46:16 +0100 | [diff] [blame] | 1125 | |
| 1126 | /* |
| 1127 | * Default mode for SSP configuration is TDM 4 slot, override config |
| 1128 | * with explicit setting to I2S 2ch. The word length is set with |
| 1129 | * dai_set_tdm_slot() since there is no other API exposed |
| 1130 | */ |
Kuninori Morimoto | 0d1571c | 2020-03-23 14:19:05 +0900 | [diff] [blame] | 1131 | ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0), |
Erik Bussing | 332719b | 2020-01-15 17:46:16 +0100 | [diff] [blame] | 1132 | SND_SOC_DAIFMT_I2S | |
| 1133 | SND_SOC_DAIFMT_NB_NF | |
| 1134 | SND_SOC_DAIFMT_CBS_CFS); |
| 1135 | if (ret < 0) { |
| 1136 | dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); |
| 1137 | return ret; |
| 1138 | } |
| 1139 | |
Kuninori Morimoto | 0d1571c | 2020-03-23 14:19:05 +0900 | [diff] [blame] | 1140 | ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), 0x3, 0x3, 2, bits); |
Erik Bussing | 332719b | 2020-01-15 17:46:16 +0100 | [diff] [blame] | 1141 | if (ret < 0) { |
| 1142 | dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); |
| 1143 | return ret; |
| 1144 | } |
| 1145 | |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1146 | return 0; |
| 1147 | } |
| 1148 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1149 | static int byt_rt5640_aif1_startup(struct snd_pcm_substream *substream) |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1150 | { |
Lars-Peter Clausen | d0a1b66 | 2015-10-18 15:39:30 +0200 | [diff] [blame] | 1151 | return snd_pcm_hw_constraint_single(substream->runtime, |
| 1152 | SNDRV_PCM_HW_PARAM_RATE, 48000); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1153 | } |
| 1154 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 1155 | static const struct snd_soc_ops byt_rt5640_aif1_ops = { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1156 | .startup = byt_rt5640_aif1_startup, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1157 | }; |
| 1158 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 1159 | static const struct snd_soc_ops byt_rt5640_be_ssp2_ops = { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1160 | .hw_params = byt_rt5640_aif1_hw_params, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1161 | }; |
| 1162 | |
Kuninori Morimoto | e7a7128 | 2019-06-06 13:20:44 +0900 | [diff] [blame] | 1163 | SND_SOC_DAILINK_DEF(dummy, |
| 1164 | DAILINK_COMP_ARRAY(COMP_DUMMY())); |
| 1165 | |
| 1166 | SND_SOC_DAILINK_DEF(media, |
| 1167 | DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai"))); |
| 1168 | |
| 1169 | SND_SOC_DAILINK_DEF(deepbuffer, |
| 1170 | DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai"))); |
| 1171 | |
| 1172 | SND_SOC_DAILINK_DEF(ssp2_port, |
| 1173 | /* overwritten for ssp0 routing */ |
| 1174 | DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port"))); |
| 1175 | SND_SOC_DAILINK_DEF(ssp2_codec, |
| 1176 | DAILINK_COMP_ARRAY(COMP_CODEC( |
| 1177 | /* overwritten with HID */ "i2c-10EC5640:00", |
| 1178 | /* changed w/ quirk */ "rt5640-aif1"))); |
| 1179 | |
| 1180 | SND_SOC_DAILINK_DEF(platform, |
| 1181 | DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform"))); |
| 1182 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1183 | static struct snd_soc_dai_link byt_rt5640_dais[] = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1184 | [MERR_DPCM_AUDIO] = { |
| 1185 | .name = "Baytrail Audio Port", |
| 1186 | .stream_name = "Baytrail Audio", |
Takashi Iwai | 6e4cac2 | 2017-04-24 14:09:55 +0200 | [diff] [blame] | 1187 | .nonatomic = true, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1188 | .dynamic = 1, |
| 1189 | .dpcm_playback = 1, |
| 1190 | .dpcm_capture = 1, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1191 | .ops = &byt_rt5640_aif1_ops, |
Kuninori Morimoto | e7a7128 | 2019-06-06 13:20:44 +0900 | [diff] [blame] | 1192 | SND_SOC_DAILINK_REG(media, dummy, platform), |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1193 | }, |
Pierre-Louis Bossart | d35eb96 | 2015-12-17 20:35:45 -0600 | [diff] [blame] | 1194 | [MERR_DPCM_DEEP_BUFFER] = { |
| 1195 | .name = "Deep-Buffer Audio Port", |
| 1196 | .stream_name = "Deep-Buffer Audio", |
Pierre-Louis Bossart | d35eb96 | 2015-12-17 20:35:45 -0600 | [diff] [blame] | 1197 | .nonatomic = true, |
| 1198 | .dynamic = 1, |
| 1199 | .dpcm_playback = 1, |
| 1200 | .ops = &byt_rt5640_aif1_ops, |
Kuninori Morimoto | e7a7128 | 2019-06-06 13:20:44 +0900 | [diff] [blame] | 1201 | SND_SOC_DAILINK_REG(deepbuffer, dummy, platform), |
Pierre-Louis Bossart | d35eb96 | 2015-12-17 20:35:45 -0600 | [diff] [blame] | 1202 | }, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1203 | /* back ends */ |
| 1204 | { |
| 1205 | .name = "SSP2-Codec", |
Pierre-Louis Bossart | 149f775 | 2017-10-12 18:38:04 -0500 | [diff] [blame] | 1206 | .id = 0, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1207 | .no_pcm = 1, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1208 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 1209 | | SND_SOC_DAIFMT_CBS_CFS, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1210 | .be_hw_params_fixup = byt_rt5640_codec_fixup, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1211 | .dpcm_playback = 1, |
| 1212 | .dpcm_capture = 1, |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1213 | .init = byt_rt5640_init, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1214 | .ops = &byt_rt5640_be_ssp2_ops, |
Kuninori Morimoto | e7a7128 | 2019-06-06 13:20:44 +0900 | [diff] [blame] | 1215 | SND_SOC_DAILINK_REG(ssp2_port, ssp2_codec, platform), |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1216 | }, |
| 1217 | }; |
| 1218 | |
| 1219 | /* SoC card */ |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1220 | static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN]; |
Jaroslav Kysela | b5706f8 | 2019-12-04 15:15:46 -0600 | [diff] [blame] | 1221 | #if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) |
Hans de Goede | 063422c | 2018-05-13 09:24:35 +0200 | [diff] [blame] | 1222 | static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */ |
Jaroslav Kysela | b5706f8 | 2019-12-04 15:15:46 -0600 | [diff] [blame] | 1223 | #endif |
Jaroslav Kysela | 0d5c818 | 2019-12-04 15:15:45 -0600 | [diff] [blame] | 1224 | static char byt_rt5640_components[32]; /* = "cfg-spk:* cfg-mic:*" */ |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1225 | |
| 1226 | static int byt_rt5640_suspend(struct snd_soc_card *card) |
| 1227 | { |
| 1228 | struct snd_soc_component *component; |
| 1229 | |
| 1230 | if (!BYT_RT5640_JDSRC(byt_rt5640_quirk)) |
| 1231 | return 0; |
| 1232 | |
Kuninori Morimoto | f70f18f7 | 2018-09-18 01:29:55 +0000 | [diff] [blame] | 1233 | for_each_card_components(card, component) { |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1234 | if (!strcmp(component->name, byt_rt5640_codec_name)) { |
| 1235 | dev_dbg(component->dev, "disabling jack detect before suspend\n"); |
| 1236 | snd_soc_component_set_jack(component, NULL, NULL); |
| 1237 | break; |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | return 0; |
| 1242 | } |
| 1243 | |
| 1244 | static int byt_rt5640_resume(struct snd_soc_card *card) |
| 1245 | { |
| 1246 | struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); |
| 1247 | struct snd_soc_component *component; |
| 1248 | |
| 1249 | if (!BYT_RT5640_JDSRC(byt_rt5640_quirk)) |
| 1250 | return 0; |
| 1251 | |
Kuninori Morimoto | f70f18f7 | 2018-09-18 01:29:55 +0000 | [diff] [blame] | 1252 | for_each_card_components(card, component) { |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1253 | if (!strcmp(component->name, byt_rt5640_codec_name)) { |
| 1254 | dev_dbg(component->dev, "re-enabling jack detect after resume\n"); |
| 1255 | snd_soc_component_set_jack(component, &priv->jack, NULL); |
| 1256 | break; |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | return 0; |
| 1261 | } |
| 1262 | |
Pierre-Louis Bossart | b4ecd58 | 2020-06-17 11:56:14 -0500 | [diff] [blame] | 1263 | /* use space before codec name to simplify card ID, and simplify driver name */ |
Pierre-Louis Bossart | 41656c3 | 2020-11-12 16:38:16 -0600 | [diff] [blame] | 1264 | #define SOF_CARD_NAME "bytcht rt5640" /* card name will be 'sof-bytcht rt5640' */ |
| 1265 | #define SOF_DRIVER_NAME "SOF" |
| 1266 | |
Pierre-Louis Bossart | b4ecd58 | 2020-06-17 11:56:14 -0500 | [diff] [blame] | 1267 | #define CARD_NAME "bytcr-rt5640" |
| 1268 | #define DRIVER_NAME NULL /* card name will be used for driver name */ |
Pierre-Louis Bossart | b4ecd58 | 2020-06-17 11:56:14 -0500 | [diff] [blame] | 1269 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1270 | static struct snd_soc_card byt_rt5640_card = { |
Axel Lin | 54d8697 | 2015-08-21 20:59:21 +0800 | [diff] [blame] | 1271 | .owner = THIS_MODULE, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1272 | .dai_link = byt_rt5640_dais, |
| 1273 | .num_links = ARRAY_SIZE(byt_rt5640_dais), |
| 1274 | .dapm_widgets = byt_rt5640_widgets, |
| 1275 | .num_dapm_widgets = ARRAY_SIZE(byt_rt5640_widgets), |
| 1276 | .dapm_routes = byt_rt5640_audio_map, |
| 1277 | .num_dapm_routes = ARRAY_SIZE(byt_rt5640_audio_map), |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1278 | .fully_routed = true, |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1279 | .suspend_pre = byt_rt5640_suspend, |
| 1280 | .resume_post = byt_rt5640_resume, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1281 | }; |
| 1282 | |
Pierre-Louis Bossart | 64e8430 | 2016-11-12 18:07:45 -0600 | [diff] [blame] | 1283 | struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ |
| 1284 | u64 aif_value; /* 1: AIF1, 2: AIF2 */ |
| 1285 | u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */ |
| 1286 | }; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1287 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1288 | static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1289 | { |
Pierre-Louis Bossart | 05ff312 | 2020-11-12 16:38:17 -0600 | [diff] [blame] | 1290 | struct device *dev = &pdev->dev; |
Hans de Goede | 46466ab | 2021-01-09 22:01:18 +0100 | [diff] [blame] | 1291 | static const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3", "none" }; |
Hans de Goede | 1851ccf | 2021-01-09 22:01:17 +0100 | [diff] [blame] | 1292 | __maybe_unused const char *spk_type; |
Hans de Goede | 6d1bfcc | 2018-05-13 09:24:33 +0200 | [diff] [blame] | 1293 | const struct dmi_system_id *dmi_id; |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 1294 | struct byt_rt5640_private *priv; |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 1295 | struct snd_soc_acpi_mach *mach; |
Pierre-Louis Bossart | bd7661b | 2019-01-25 14:34:59 -0600 | [diff] [blame] | 1296 | const char *platform_name; |
Andy Shevchenko | a320d89 | 2019-03-28 19:17:25 +0200 | [diff] [blame] | 1297 | struct acpi_device *adev; |
Pierre-Louis Bossart | 41656c3 | 2020-11-12 16:38:16 -0600 | [diff] [blame] | 1298 | bool sof_parent; |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 1299 | int ret_val = 0; |
Pierre-Louis Bossart | 2193eb9 | 2017-10-12 18:38:05 -0500 | [diff] [blame] | 1300 | int dai_index = 0; |
Hans de Goede | 1851ccf | 2021-01-09 22:01:17 +0100 | [diff] [blame] | 1301 | int i, cfg_spk; |
Hans de Goede | 9f47c9c | 2021-03-07 16:05:03 +0100 | [diff] [blame] | 1302 | int aif; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1303 | |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 1304 | is_bytcr = false; |
Jia-Ju Bai | 7a3a632 | 2018-04-09 18:47:37 +0800 | [diff] [blame] | 1305 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1306 | if (!priv) |
| 1307 | return -ENOMEM; |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1308 | |
| 1309 | /* register the soc card */ |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1310 | byt_rt5640_card.dev = &pdev->dev; |
Pierre-Louis Bossart | caf94ed | 2016-01-04 17:20:28 -0600 | [diff] [blame] | 1311 | mach = byt_rt5640_card.dev->platform_data; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1312 | snd_soc_card_set_drvdata(&byt_rt5640_card, priv); |
Pierre-Louis Bossart | caf94ed | 2016-01-04 17:20:28 -0600 | [diff] [blame] | 1313 | |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1314 | /* fix index of codec dai */ |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1315 | for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) { |
Kuninori Morimoto | e7a7128 | 2019-06-06 13:20:44 +0900 | [diff] [blame] | 1316 | if (!strcmp(byt_rt5640_dais[i].codecs->name, |
| 1317 | "i2c-10EC5640:00")) { |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1318 | dai_index = i; |
| 1319 | break; |
| 1320 | } |
| 1321 | } |
| 1322 | |
Pierre-Louis Bossart | caf94ed | 2016-01-04 17:20:28 -0600 | [diff] [blame] | 1323 | /* fixup codec name based on HID */ |
Andy Shevchenko | a320d89 | 2019-03-28 19:17:25 +0200 | [diff] [blame] | 1324 | adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); |
| 1325 | if (adev) { |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1326 | snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name), |
Andy Shevchenko | a320d89 | 2019-03-28 19:17:25 +0200 | [diff] [blame] | 1327 | "i2c-%s", acpi_dev_name(adev)); |
| 1328 | put_device(&adev->dev); |
Kuninori Morimoto | e7a7128 | 2019-06-06 13:20:44 +0900 | [diff] [blame] | 1329 | byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name; |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1330 | } |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1331 | |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 1332 | /* |
| 1333 | * swap SSP0 if bytcr is detected |
| 1334 | * (will be overridden if DMI quirk is detected) |
| 1335 | */ |
Pierre-Louis Bossart | 536cfd2 | 2019-05-30 06:50:11 -0500 | [diff] [blame] | 1336 | if (soc_intel_is_byt()) { |
Pierre-Louis Bossart | 3ee1cd4 | 2018-11-01 16:34:50 -0500 | [diff] [blame] | 1337 | if (mach->mach_params.acpi_ipc_irq_index == 0) |
Pierre-Louis Bossart | 64e8430 | 2016-11-12 18:07:45 -0600 | [diff] [blame] | 1338 | is_bytcr = true; |
| 1339 | } |
| 1340 | |
| 1341 | if (is_bytcr) { |
| 1342 | /* |
| 1343 | * Baytrail CR platforms may have CHAN package in BIOS, try |
| 1344 | * to find relevant routing quirk based as done on Windows |
| 1345 | * platforms. We have to read the information directly from the |
| 1346 | * BIOS, at this stage the card is not created and the links |
| 1347 | * with the codec driver/pdata are non-existent |
| 1348 | */ |
| 1349 | |
| 1350 | struct acpi_chan_package chan_package; |
| 1351 | |
| 1352 | /* format specified: 2 64-bit integers */ |
| 1353 | struct acpi_buffer format = {sizeof("NN"), "NN"}; |
| 1354 | struct acpi_buffer state = {0, NULL}; |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 1355 | struct snd_soc_acpi_package_context pkg_ctx; |
Pierre-Louis Bossart | 64e8430 | 2016-11-12 18:07:45 -0600 | [diff] [blame] | 1356 | bool pkg_found = false; |
| 1357 | |
| 1358 | state.length = sizeof(chan_package); |
| 1359 | state.pointer = &chan_package; |
| 1360 | |
| 1361 | pkg_ctx.name = "CHAN"; |
| 1362 | pkg_ctx.length = 2; |
| 1363 | pkg_ctx.format = &format; |
| 1364 | pkg_ctx.state = &state; |
| 1365 | pkg_ctx.data_valid = false; |
| 1366 | |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 1367 | pkg_found = snd_soc_acpi_find_package_from_hid(mach->id, |
| 1368 | &pkg_ctx); |
Pierre-Louis Bossart | 64e8430 | 2016-11-12 18:07:45 -0600 | [diff] [blame] | 1369 | if (pkg_found) { |
| 1370 | if (chan_package.aif_value == 1) { |
| 1371 | dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); |
| 1372 | byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF1; |
| 1373 | } else if (chan_package.aif_value == 2) { |
| 1374 | dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n"); |
| 1375 | byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF2; |
| 1376 | } else { |
| 1377 | dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n"); |
| 1378 | pkg_found = false; |
| 1379 | } |
| 1380 | } |
| 1381 | |
| 1382 | if (!pkg_found) { |
| 1383 | /* no BIOS indications, assume SSP0-AIF2 connection */ |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 1384 | byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF2; |
| 1385 | } |
Pierre-Louis Bossart | bf46241 | 2016-11-12 18:07:46 -0600 | [diff] [blame] | 1386 | |
| 1387 | /* change defaults for Baytrail-CR capture */ |
Hans de Goede | 96a388fe | 2018-05-13 09:24:30 +0200 | [diff] [blame] | 1388 | byt_rt5640_quirk |= BYTCR_INPUT_DEFAULTS; |
Pierre-Louis Bossart | bf46241 | 2016-11-12 18:07:46 -0600 | [diff] [blame] | 1389 | } else { |
Hans de Goede | 56ff440 | 2018-05-13 09:24:31 +0200 | [diff] [blame] | 1390 | byt_rt5640_quirk |= BYT_RT5640_DMIC1_MAP | |
| 1391 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 1392 | BYT_RT5640_OVCD_TH_2000UA | |
| 1393 | BYT_RT5640_OVCD_SF_0P75; |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 1394 | } |
| 1395 | |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 1396 | /* check quirks before creating card */ |
Hans de Goede | 6d1bfcc | 2018-05-13 09:24:33 +0200 | [diff] [blame] | 1397 | dmi_id = dmi_first_match(byt_rt5640_quirk_table); |
| 1398 | if (dmi_id) |
| 1399 | byt_rt5640_quirk = (unsigned long)dmi_id->driver_data; |
Pierre-Louis Bossart | 2fb2a19 | 2019-04-19 15:12:17 -0500 | [diff] [blame] | 1400 | if (quirk_override != -1) { |
Pierre-Louis Bossart | 2697f3a | 2020-06-25 14:12:57 -0500 | [diff] [blame] | 1401 | dev_info(&pdev->dev, "Overriding quirk 0x%lx => 0x%x\n", |
| 1402 | byt_rt5640_quirk, quirk_override); |
Takashi Iwai | 9f2cf73 | 2017-04-23 09:22:56 +0200 | [diff] [blame] | 1403 | byt_rt5640_quirk = quirk_override; |
| 1404 | } |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 1405 | |
| 1406 | /* Must be called before register_card, also see declaration comment. */ |
| 1407 | ret_val = byt_rt5640_add_codec_device_props(byt_rt5640_codec_name); |
| 1408 | if (ret_val) |
| 1409 | return ret_val; |
| 1410 | |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 1411 | log_quirks(&pdev->dev); |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 1412 | |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 1413 | if ((byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) || |
Hans de Goede | 9f47c9c | 2021-03-07 16:05:03 +0100 | [diff] [blame] | 1414 | (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { |
Nariman Etemadi | 2968683 | 2020-01-15 17:46:17 +0100 | [diff] [blame] | 1415 | byt_rt5640_dais[dai_index].codecs->dai_name = "rt5640-aif2"; |
Hans de Goede | 9f47c9c | 2021-03-07 16:05:03 +0100 | [diff] [blame] | 1416 | aif = 2; |
| 1417 | } else { |
| 1418 | aif = 1; |
| 1419 | } |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 1420 | |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 1421 | if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) || |
Nariman Etemadi | 2968683 | 2020-01-15 17:46:17 +0100 | [diff] [blame] | 1422 | (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) |
| 1423 | byt_rt5640_dais[dai_index].cpus->dai_name = "ssp0-port"; |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 1424 | |
Pierre-Louis Bossart | 7735bce | 2017-09-08 12:43:52 -0500 | [diff] [blame] | 1425 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1426 | priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); |
| 1427 | if (IS_ERR(priv->mclk)) { |
Pierre-Louis Bossart | 4a8b3a6 | 2016-12-16 10:55:49 -0600 | [diff] [blame] | 1428 | ret_val = PTR_ERR(priv->mclk); |
| 1429 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1430 | dev_err(&pdev->dev, |
Pierre-Louis Bossart | 4a8b3a6 | 2016-12-16 10:55:49 -0600 | [diff] [blame] | 1431 | "Failed to get MCLK from pmc_plt_clk_3: %d\n", |
| 1432 | ret_val); |
| 1433 | |
| 1434 | /* |
| 1435 | * Fall back to bit clock usage for -ENOENT (clock not |
| 1436 | * available likely due to missing dependencies), bail |
| 1437 | * for all other errors, including -EPROBE_DEFER |
| 1438 | */ |
| 1439 | if (ret_val != -ENOENT) |
| 1440 | return ret_val; |
| 1441 | byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1442 | } |
| 1443 | } |
| 1444 | |
Hans de Goede | 1851ccf | 2021-01-09 22:01:17 +0100 | [diff] [blame] | 1445 | if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS) { |
| 1446 | cfg_spk = 0; |
| 1447 | spk_type = "none"; |
| 1448 | } else if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) { |
| 1449 | cfg_spk = 1; |
| 1450 | spk_type = "mono"; |
| 1451 | } else { |
| 1452 | cfg_spk = 2; |
| 1453 | spk_type = "stereo"; |
| 1454 | } |
| 1455 | |
Jaroslav Kysela | 0d5c818 | 2019-12-04 15:15:45 -0600 | [diff] [blame] | 1456 | snprintf(byt_rt5640_components, sizeof(byt_rt5640_components), |
Hans de Goede | 9f47c9c | 2021-03-07 16:05:03 +0100 | [diff] [blame] | 1457 | "cfg-spk:%d cfg-mic:%s aif:%d", cfg_spk, |
| 1458 | map_name[BYT_RT5640_MAP(byt_rt5640_quirk)], aif); |
Jaroslav Kysela | 0d5c818 | 2019-12-04 15:15:45 -0600 | [diff] [blame] | 1459 | byt_rt5640_card.components = byt_rt5640_components; |
Jaroslav Kysela | b5706f8 | 2019-12-04 15:15:46 -0600 | [diff] [blame] | 1460 | #if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) |
Hans de Goede | 063422c | 2018-05-13 09:24:35 +0200 | [diff] [blame] | 1461 | snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name), |
Hans de Goede | 1851ccf | 2021-01-09 22:01:17 +0100 | [diff] [blame] | 1462 | "bytcr-rt5640-%s-spk-%s-mic", spk_type, |
Hans de Goede | 063422c | 2018-05-13 09:24:35 +0200 | [diff] [blame] | 1463 | map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]); |
| 1464 | byt_rt5640_card.long_name = byt_rt5640_long_name; |
Jaroslav Kysela | b5706f8 | 2019-12-04 15:15:46 -0600 | [diff] [blame] | 1465 | #endif |
Hans de Goede | 063422c | 2018-05-13 09:24:35 +0200 | [diff] [blame] | 1466 | |
Pierre-Louis Bossart | bd7661b | 2019-01-25 14:34:59 -0600 | [diff] [blame] | 1467 | /* override plaform name, if required */ |
| 1468 | platform_name = mach->mach_params.platform; |
| 1469 | |
| 1470 | ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5640_card, |
| 1471 | platform_name); |
| 1472 | if (ret_val) |
| 1473 | return ret_val; |
| 1474 | |
Pierre-Louis Bossart | 41656c3 | 2020-11-12 16:38:16 -0600 | [diff] [blame] | 1475 | sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); |
| 1476 | |
| 1477 | /* set card and driver name */ |
| 1478 | if (sof_parent) { |
| 1479 | byt_rt5640_card.name = SOF_CARD_NAME; |
| 1480 | byt_rt5640_card.driver_name = SOF_DRIVER_NAME; |
| 1481 | } else { |
| 1482 | byt_rt5640_card.name = CARD_NAME; |
| 1483 | byt_rt5640_card.driver_name = DRIVER_NAME; |
| 1484 | } |
| 1485 | |
Pierre-Louis Bossart | 05ff312 | 2020-11-12 16:38:17 -0600 | [diff] [blame] | 1486 | /* set pm ops */ |
| 1487 | if (sof_parent) |
| 1488 | dev->driver->pm = &snd_soc_pm_ops; |
| 1489 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1490 | ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5640_card); |
| 1491 | |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1492 | if (ret_val) { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1493 | dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n", |
| 1494 | ret_val); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1495 | return ret_val; |
| 1496 | } |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1497 | platform_set_drvdata(pdev, &byt_rt5640_card); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1498 | return ret_val; |
| 1499 | } |
| 1500 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1501 | static struct platform_driver snd_byt_rt5640_mc_driver = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1502 | .driver = { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1503 | .name = "bytcr_rt5640", |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1504 | }, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1505 | .probe = snd_byt_rt5640_mc_probe, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1506 | }; |
| 1507 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1508 | module_platform_driver(snd_byt_rt5640_mc_driver); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1509 | |
| 1510 | MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver"); |
| 1511 | MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>"); |
| 1512 | MODULE_LICENSE("GPL v2"); |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1513 | MODULE_ALIAS("platform:bytcr_rt5640"); |