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