Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1 | /* |
| 2 | * byt_cr_dpcm_rt5640.c - ASoc Machine driver for Intel Byt CR platform |
| 3 | * |
| 4 | * Copyright (C) 2014 Intel Corp |
| 5 | * Author: Subhransu S. Prusty <subhransu.s.prusty@intel.com> |
| 6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 18 | */ |
| 19 | |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 20 | #include <linux/i2c.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 21 | #include <linux/init.h> |
| 22 | #include <linux/module.h> |
Takashi Iwai | 9f2cf73 | 2017-04-23 09:22:56 +0200 | [diff] [blame] | 23 | #include <linux/moduleparam.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 25 | #include <linux/acpi.h> |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 26 | #include <linux/clk.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 27 | #include <linux/device.h> |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 28 | #include <linux/dmi.h> |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 29 | #include <linux/input.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 30 | #include <linux/slab.h> |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 31 | #include <asm/cpu_device_id.h> |
| 32 | #include <asm/platform_sst_audio.h> |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 33 | #include <sound/pcm.h> |
| 34 | #include <sound/pcm_params.h> |
| 35 | #include <sound/soc.h> |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 36 | #include <sound/jack.h> |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 37 | #include <sound/soc-acpi.h> |
Hans de Goede | a3ad291 | 2018-05-13 09:24:26 +0200 | [diff] [blame] | 38 | #include <dt-bindings/sound/rt5640.h> |
Jie Yang | e56c72d | 2015-04-02 15:37:02 +0800 | [diff] [blame] | 39 | #include "../../codecs/rt5640.h" |
Jie Yang | b97169d | 2015-04-02 15:37:04 +0800 | [diff] [blame] | 40 | #include "../atom/sst-atom-controls.h" |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 41 | #include "../common/sst-dsp.h" |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 42 | |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 43 | enum { |
| 44 | BYT_RT5640_DMIC1_MAP, |
| 45 | BYT_RT5640_DMIC2_MAP, |
| 46 | BYT_RT5640_IN1_MAP, |
Pierre-Louis Bossart | 59e8b65 | 2016-08-12 16:27:54 -0500 | [diff] [blame] | 47 | BYT_RT5640_IN3_MAP, |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 48 | }; |
| 49 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 50 | enum { |
| 51 | BYT_RT5640_JD_SRC_GPIO1 = (RT5640_JD_SRC_GPIO1 << 4), |
| 52 | BYT_RT5640_JD_SRC_JD1_IN4P = (RT5640_JD_SRC_JD1_IN4P << 4), |
| 53 | BYT_RT5640_JD_SRC_JD2_IN4N = (RT5640_JD_SRC_JD2_IN4N << 4), |
| 54 | BYT_RT5640_JD_SRC_GPIO2 = (RT5640_JD_SRC_GPIO2 << 4), |
| 55 | BYT_RT5640_JD_SRC_GPIO3 = (RT5640_JD_SRC_GPIO3 << 4), |
| 56 | BYT_RT5640_JD_SRC_GPIO4 = (RT5640_JD_SRC_GPIO4 << 4), |
| 57 | }; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 58 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 59 | enum { |
| 60 | BYT_RT5640_OVCD_TH_600UA = (6 << 8), |
| 61 | BYT_RT5640_OVCD_TH_1500UA = (15 << 8), |
| 62 | BYT_RT5640_OVCD_TH_2000UA = (20 << 8), |
| 63 | }; |
| 64 | |
| 65 | enum { |
| 66 | BYT_RT5640_OVCD_SF_0P5 = (RT5640_OVCD_SF_0P5 << 13), |
| 67 | BYT_RT5640_OVCD_SF_0P75 = (RT5640_OVCD_SF_0P75 << 13), |
| 68 | BYT_RT5640_OVCD_SF_1P0 = (RT5640_OVCD_SF_1P0 << 13), |
| 69 | BYT_RT5640_OVCD_SF_1P5 = (RT5640_OVCD_SF_1P5 << 13), |
| 70 | }; |
| 71 | |
| 72 | #define BYT_RT5640_MAP(quirk) ((quirk) & GENMASK(3, 0)) |
| 73 | #define BYT_RT5640_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4) |
| 74 | #define BYT_RT5640_OVCD_TH(quirk) (((quirk) & GENMASK(12, 8)) >> 8) |
| 75 | #define BYT_RT5640_OVCD_SF(quirk) (((quirk) & GENMASK(14, 13)) >> 13) |
| 76 | #define BYT_RT5640_JD_NOT_INV BIT(16) |
| 77 | #define BYT_RT5640_MONO_SPEAKER BIT(17) |
| 78 | #define BYT_RT5640_DIFF_MIC BIT(18) /* default is single-ended */ |
| 79 | #define BYT_RT5640_SSP2_AIF2 BIT(19) /* default is using AIF1 */ |
| 80 | #define BYT_RT5640_SSP0_AIF1 BIT(20) |
| 81 | #define BYT_RT5640_SSP0_AIF2 BIT(21) |
| 82 | #define BYT_RT5640_MCLK_EN BIT(22) |
| 83 | #define BYT_RT5640_MCLK_25MHZ BIT(23) |
| 84 | |
Hans de Goede | 96a388fe | 2018-05-13 09:24:30 +0200 | [diff] [blame] | 85 | #define BYTCR_INPUT_DEFAULTS \ |
| 86 | (BYT_RT5640_IN3_MAP | \ |
Hans de Goede | 56ff440 | 2018-05-13 09:24:31 +0200 | [diff] [blame] | 87 | BYT_RT5640_JD_SRC_JD1_IN4P | \ |
| 88 | BYT_RT5640_OVCD_TH_2000UA | \ |
| 89 | BYT_RT5640_OVCD_SF_0P75 | \ |
Hans de Goede | 96a388fe | 2018-05-13 09:24:30 +0200 | [diff] [blame] | 90 | BYT_RT5640_DIFF_MIC) |
| 91 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 92 | /* in-diff or dmic-pin + jdsrc + ovcd-th + -sf + jd-inv + terminating entry */ |
| 93 | #define MAX_NO_PROPS 6 |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 94 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 95 | struct byt_rt5640_private { |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 96 | struct snd_soc_jack jack; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 97 | struct clk *mclk; |
| 98 | }; |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 99 | static bool is_bytcr; |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 100 | |
Pierre-Louis Bossart | bf46241 | 2016-11-12 18:07:46 -0600 | [diff] [blame] | 101 | static unsigned long byt_rt5640_quirk = BYT_RT5640_MCLK_EN; |
Takashi Iwai | 9f2cf73 | 2017-04-23 09:22:56 +0200 | [diff] [blame] | 102 | static unsigned int quirk_override; |
Takashi Iwai | 0b2c9f8 | 2017-04-24 23:34:30 +0200 | [diff] [blame] | 103 | module_param_named(quirk, quirk_override, uint, 0444); |
Takashi Iwai | 9f2cf73 | 2017-04-23 09:22:56 +0200 | [diff] [blame] | 104 | MODULE_PARM_DESC(quirk, "Board-specific quirk override"); |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 105 | |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 106 | static void log_quirks(struct device *dev) |
| 107 | { |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 108 | int map; |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 109 | bool has_mclk = false; |
| 110 | bool has_ssp0 = false; |
| 111 | bool has_ssp0_aif1 = false; |
| 112 | bool has_ssp0_aif2 = false; |
| 113 | bool has_ssp2_aif2 = false; |
| 114 | |
| 115 | map = BYT_RT5640_MAP(byt_rt5640_quirk); |
| 116 | switch (map) { |
| 117 | case BYT_RT5640_DMIC1_MAP: |
| 118 | dev_info(dev, "quirk DMIC1_MAP enabled\n"); |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 119 | break; |
| 120 | case BYT_RT5640_DMIC2_MAP: |
| 121 | dev_info(dev, "quirk DMIC2_MAP enabled\n"); |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 122 | break; |
| 123 | case BYT_RT5640_IN1_MAP: |
| 124 | dev_info(dev, "quirk IN1_MAP enabled\n"); |
| 125 | break; |
| 126 | case BYT_RT5640_IN3_MAP: |
| 127 | dev_info(dev, "quirk IN3_MAP enabled\n"); |
| 128 | break; |
| 129 | default: |
| 130 | dev_err(dev, "quirk map 0x%x is not supported, microphone input will not work\n", map); |
| 131 | break; |
| 132 | } |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 133 | if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) { |
| 134 | dev_info(dev, "quirk realtek,jack-detect-source %ld\n", |
| 135 | BYT_RT5640_JDSRC(byt_rt5640_quirk)); |
| 136 | dev_info(dev, "quirk realtek,over-current-threshold-microamp %ld\n", |
| 137 | BYT_RT5640_OVCD_TH(byt_rt5640_quirk) * 100); |
| 138 | dev_info(dev, "quirk realtek,over-current-scale-factor %ld\n", |
| 139 | BYT_RT5640_OVCD_SF(byt_rt5640_quirk)); |
| 140 | } |
| 141 | if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV) |
| 142 | dev_info(dev, "quirk JD_NOT_INV enabled\n"); |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 143 | if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 144 | dev_info(dev, "quirk MONO_SPEAKER enabled\n"); |
Hans de Goede | a3ad291 | 2018-05-13 09:24:26 +0200 | [diff] [blame] | 145 | if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) |
| 146 | dev_info(dev, "quirk DIFF_MIC enabled\n"); |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 147 | if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) { |
| 148 | dev_info(dev, "quirk SSP0_AIF1 enabled\n"); |
| 149 | has_ssp0 = true; |
| 150 | has_ssp0_aif1 = true; |
| 151 | } |
| 152 | if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) { |
| 153 | dev_info(dev, "quirk SSP0_AIF2 enabled\n"); |
| 154 | has_ssp0 = true; |
| 155 | has_ssp0_aif2 = true; |
| 156 | } |
| 157 | if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) { |
| 158 | dev_info(dev, "quirk SSP2_AIF2 enabled\n"); |
| 159 | has_ssp2_aif2 = true; |
| 160 | } |
| 161 | if (is_bytcr && !has_ssp0) |
| 162 | dev_err(dev, "Invalid routing, bytcr detected but no SSP0-based quirk, audio cannot work with SSP2 on bytcr\n"); |
| 163 | if (has_ssp0_aif1 && has_ssp0_aif2) |
| 164 | dev_err(dev, "Invalid routing, SSP0 cannot be connected to both AIF1 and AIF2\n"); |
| 165 | if (has_ssp0 && has_ssp2_aif2) |
| 166 | dev_err(dev, "Invalid routing, cannot have both SSP0 and SSP2 connected to codec\n"); |
| 167 | |
| 168 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { |
| 169 | dev_info(dev, "quirk MCLK_EN enabled\n"); |
| 170 | has_mclk = true; |
| 171 | } |
| 172 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) { |
| 173 | if (has_mclk) |
| 174 | dev_info(dev, "quirk MCLK_25MHZ enabled\n"); |
| 175 | else |
| 176 | dev_err(dev, "quirk MCLK_25MHZ enabled but quirk MCLK not selected, will be ignored\n"); |
| 177 | } |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 178 | } |
| 179 | |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 180 | static int byt_rt5640_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, |
| 181 | int rate) |
| 182 | { |
| 183 | int ret; |
| 184 | |
| 185 | /* Configure the PLL before selecting it */ |
| 186 | if (!(byt_rt5640_quirk & BYT_RT5640_MCLK_EN)) { |
| 187 | /* use bitclock as PLL input */ |
| 188 | if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) || |
| 189 | (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { |
| 190 | /* 2x16 bit slots on SSP0 */ |
| 191 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
| 192 | RT5640_PLL1_S_BCLK1, |
| 193 | rate * 32, rate * 512); |
| 194 | } else { |
| 195 | /* 2x15 bit slots on SSP2 */ |
| 196 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
| 197 | RT5640_PLL1_S_BCLK1, |
| 198 | rate * 50, rate * 512); |
| 199 | } |
| 200 | } else { |
| 201 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) { |
| 202 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
| 203 | RT5640_PLL1_S_MCLK, |
| 204 | 25000000, rate * 512); |
| 205 | } else { |
| 206 | ret = snd_soc_dai_set_pll(codec_dai, 0, |
| 207 | RT5640_PLL1_S_MCLK, |
| 208 | 19200000, rate * 512); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | if (ret < 0) { |
Hans de Goede | a3a956a | 2018-05-11 11:52:16 +0200 | [diff] [blame] | 213 | 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] | 214 | return ret; |
| 215 | } |
| 216 | |
| 217 | ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1, |
| 218 | rate * 512, SND_SOC_CLOCK_IN); |
| 219 | if (ret < 0) { |
Hans de Goede | a3a956a | 2018-05-11 11:52:16 +0200 | [diff] [blame] | 220 | 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] | 221 | return ret; |
| 222 | } |
| 223 | |
| 224 | return 0; |
| 225 | } |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 226 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 227 | #define BYT_CODEC_DAI1 "rt5640-aif1" |
| 228 | #define BYT_CODEC_DAI2 "rt5640-aif2" |
| 229 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 230 | static int platform_clock_control(struct snd_soc_dapm_widget *w, |
| 231 | struct snd_kcontrol *k, int event) |
| 232 | { |
| 233 | struct snd_soc_dapm_context *dapm = w->dapm; |
| 234 | struct snd_soc_card *card = dapm->card; |
| 235 | struct snd_soc_dai *codec_dai; |
| 236 | struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); |
| 237 | int ret; |
| 238 | |
Pierre-Louis Bossart | dfb6ec7 | 2017-10-12 18:38:03 -0500 | [diff] [blame] | 239 | codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1); |
| 240 | if (!codec_dai) |
| 241 | codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2); |
| 242 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 243 | if (!codec_dai) { |
| 244 | dev_err(card->dev, |
| 245 | "Codec dai not found; Unable to set platform clock\n"); |
| 246 | return -EIO; |
| 247 | } |
| 248 | |
| 249 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 250 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 251 | ret = clk_prepare_enable(priv->mclk); |
| 252 | if (ret < 0) { |
| 253 | dev_err(card->dev, |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 254 | "could not configure MCLK state\n"); |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 255 | return ret; |
| 256 | } |
| 257 | } |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 258 | ret = byt_rt5640_prepare_and_enable_pll1(codec_dai, 48000); |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 259 | } else { |
| 260 | /* |
| 261 | * Set codec clock source to internal clock before |
| 262 | * turning off the platform clock. Codec needs clock |
| 263 | * for Jack detection and button press |
| 264 | */ |
| 265 | 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] | 266 | 48000 * 512, |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 267 | SND_SOC_CLOCK_IN); |
| 268 | if (!ret) { |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 269 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 270 | clk_disable_unprepare(priv->mclk); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | if (ret < 0) { |
| 275 | dev_err(card->dev, "can't set codec sysclk: %d\n", ret); |
| 276 | return ret; |
| 277 | } |
| 278 | |
| 279 | return 0; |
| 280 | } |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 281 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 282 | static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 283 | SND_SOC_DAPM_HP("Headphone", NULL), |
| 284 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
Pierre-Louis Bossart | e2be1da | 2015-12-17 20:35:40 -0600 | [diff] [blame] | 285 | SND_SOC_DAPM_MIC("Internal Mic", NULL), |
| 286 | SND_SOC_DAPM_SPK("Speaker", NULL), |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 287 | SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, |
| 288 | platform_clock_control, SND_SOC_DAPM_PRE_PMU | |
| 289 | SND_SOC_DAPM_POST_PMD), |
| 290 | |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 291 | }; |
| 292 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 293 | static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 294 | {"Headphone", NULL, "Platform Clock"}, |
| 295 | {"Headset Mic", NULL, "Platform Clock"}, |
| 296 | {"Internal Mic", NULL, "Platform Clock"}, |
| 297 | {"Speaker", NULL, "Platform Clock"}, |
| 298 | |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 299 | {"Headset Mic", NULL, "MICBIAS1"}, |
Pierre-Louis Bossart | e2be1da | 2015-12-17 20:35:40 -0600 | [diff] [blame] | 300 | {"IN2P", NULL, "Headset Mic"}, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 301 | {"Headphone", NULL, "HPOL"}, |
| 302 | {"Headphone", NULL, "HPOR"}, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 303 | }; |
| 304 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 305 | static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = { |
| 306 | {"DMIC1", NULL, "Internal Mic"}, |
| 307 | }; |
| 308 | |
| 309 | static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic2_map[] = { |
| 310 | {"DMIC2", NULL, "Internal Mic"}, |
| 311 | }; |
| 312 | |
| 313 | static const struct snd_soc_dapm_route byt_rt5640_intmic_in1_map[] = { |
| 314 | {"Internal Mic", NULL, "MICBIAS1"}, |
| 315 | {"IN1P", NULL, "Internal Mic"}, |
| 316 | }; |
| 317 | |
Pierre-Louis Bossart | 59e8b65 | 2016-08-12 16:27:54 -0500 | [diff] [blame] | 318 | static const struct snd_soc_dapm_route byt_rt5640_intmic_in3_map[] = { |
| 319 | {"Internal Mic", NULL, "MICBIAS1"}, |
| 320 | {"IN3P", NULL, "Internal Mic"}, |
| 321 | }; |
| 322 | |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 323 | static const struct snd_soc_dapm_route byt_rt5640_ssp2_aif1_map[] = { |
| 324 | {"ssp2 Tx", NULL, "codec_out0"}, |
| 325 | {"ssp2 Tx", NULL, "codec_out1"}, |
| 326 | {"codec_in0", NULL, "ssp2 Rx"}, |
| 327 | {"codec_in1", NULL, "ssp2 Rx"}, |
| 328 | |
| 329 | {"AIF1 Playback", NULL, "ssp2 Tx"}, |
| 330 | {"ssp2 Rx", NULL, "AIF1 Capture"}, |
| 331 | }; |
| 332 | |
| 333 | static const struct snd_soc_dapm_route byt_rt5640_ssp2_aif2_map[] = { |
| 334 | {"ssp2 Tx", NULL, "codec_out0"}, |
| 335 | {"ssp2 Tx", NULL, "codec_out1"}, |
| 336 | {"codec_in0", NULL, "ssp2 Rx"}, |
| 337 | {"codec_in1", NULL, "ssp2 Rx"}, |
| 338 | |
| 339 | {"AIF2 Playback", NULL, "ssp2 Tx"}, |
| 340 | {"ssp2 Rx", NULL, "AIF2 Capture"}, |
| 341 | }; |
| 342 | |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 343 | static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif1_map[] = { |
| 344 | {"ssp0 Tx", NULL, "modem_out"}, |
| 345 | {"modem_in", NULL, "ssp0 Rx"}, |
| 346 | |
| 347 | {"AIF1 Playback", NULL, "ssp0 Tx"}, |
| 348 | {"ssp0 Rx", NULL, "AIF1 Capture"}, |
| 349 | }; |
| 350 | |
| 351 | static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif2_map[] = { |
| 352 | {"ssp0 Tx", NULL, "modem_out"}, |
| 353 | {"modem_in", NULL, "ssp0 Rx"}, |
| 354 | |
| 355 | {"AIF2 Playback", NULL, "ssp0 Tx"}, |
| 356 | {"ssp0 Rx", NULL, "AIF2 Capture"}, |
| 357 | }; |
| 358 | |
Pierre-Louis Bossart | 68817cd | 2016-08-12 16:27:45 -0500 | [diff] [blame] | 359 | static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = { |
| 360 | {"Speaker", NULL, "SPOLP"}, |
| 361 | {"Speaker", NULL, "SPOLN"}, |
| 362 | {"Speaker", NULL, "SPORP"}, |
| 363 | {"Speaker", NULL, "SPORN"}, |
| 364 | }; |
| 365 | |
| 366 | static const struct snd_soc_dapm_route byt_rt5640_mono_spk_map[] = { |
| 367 | {"Speaker", NULL, "SPOLP"}, |
| 368 | {"Speaker", NULL, "SPOLN"}, |
| 369 | }; |
| 370 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 371 | static const struct snd_kcontrol_new byt_rt5640_controls[] = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 372 | SOC_DAPM_PIN_SWITCH("Headphone"), |
| 373 | SOC_DAPM_PIN_SWITCH("Headset Mic"), |
Pierre-Louis Bossart | e2be1da | 2015-12-17 20:35:40 -0600 | [diff] [blame] | 374 | SOC_DAPM_PIN_SWITCH("Internal Mic"), |
| 375 | SOC_DAPM_PIN_SWITCH("Speaker"), |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 376 | }; |
| 377 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 378 | static struct snd_soc_jack_pin rt5640_pins[] = { |
| 379 | { |
| 380 | .pin = "Headphone", |
| 381 | .mask = SND_JACK_HEADPHONE, |
| 382 | }, |
| 383 | { |
| 384 | .pin = "Headset Mic", |
| 385 | .mask = SND_JACK_MICROPHONE, |
| 386 | }, |
| 387 | }; |
| 388 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 389 | static int byt_rt5640_aif1_hw_params(struct snd_pcm_substream *substream, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 390 | struct snd_pcm_hw_params *params) |
| 391 | { |
| 392 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 393 | struct snd_soc_dai *dai = rtd->codec_dai; |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 394 | |
Hans de Goede | bcd9a32 | 2018-05-08 17:35:53 +0200 | [diff] [blame] | 395 | return byt_rt5640_prepare_and_enable_pll1(dai, params_rate(params)); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 396 | } |
| 397 | |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 398 | /* Please keep this list alphabetically sorted */ |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 399 | static const struct dmi_system_id byt_rt5640_quirk_table[] = { |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame^] | 400 | { /* Acer Iconia Tab 8 W1-810 */ |
| 401 | .matches = { |
| 402 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 403 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Iconia W1-810"), |
| 404 | }, |
| 405 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 406 | BYT_RT5640_JD_SRC_JD1_IN4P | |
| 407 | BYT_RT5640_OVCD_TH_2000UA | |
| 408 | BYT_RT5640_OVCD_SF_0P75 | |
| 409 | BYT_RT5640_SSP0_AIF1 | |
| 410 | BYT_RT5640_MCLK_EN), |
| 411 | }, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 412 | { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 413 | .matches = { |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 414 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
| 415 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"), |
| 416 | }, |
| 417 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 418 | BYT_RT5640_MCLK_EN | |
| 419 | BYT_RT5640_SSP0_AIF1), |
| 420 | |
| 421 | }, |
| 422 | { |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 423 | .matches = { |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 424 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
| 425 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"), |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 426 | }, |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 427 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 428 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 429 | BYT_RT5640_OVCD_TH_2000UA | |
| 430 | BYT_RT5640_OVCD_SF_0P75 | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 431 | BYT_RT5640_MCLK_EN), |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 432 | }, |
| 433 | { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 434 | .matches = { |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 435 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), |
| 436 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TAF"), |
| 437 | }, |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 438 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 439 | BYT_RT5640_MONO_SPEAKER | |
| 440 | BYT_RT5640_DIFF_MIC | |
| 441 | BYT_RT5640_SSP0_AIF2 | |
| 442 | BYT_RT5640_MCLK_EN), |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 443 | }, |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame^] | 444 | { /* Chuwi Vi8 (CWI506) */ |
| 445 | .matches = { |
| 446 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| 447 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "i86"), |
| 448 | /* The above are too generic, also match BIOS info */ |
| 449 | DMI_MATCH(DMI_BIOS_VERSION, "CHUWI.D86JLBNR"), |
| 450 | }, |
| 451 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 452 | BYT_RT5640_MONO_SPEAKER | |
| 453 | BYT_RT5640_SSP0_AIF1 | |
| 454 | BYT_RT5640_MCLK_EN), |
| 455 | }, |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 456 | { |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 457 | .matches = { |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 458 | DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), |
| 459 | DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"), |
| 460 | }, |
| 461 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP), |
| 462 | }, |
| 463 | { |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 464 | .matches = { |
Hans de Goede | 6748fb7 | 2018-05-13 09:24:27 +0200 | [diff] [blame] | 465 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 466 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Venue 8 Pro 5830"), |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 467 | }, |
Hans de Goede | 6748fb7 | 2018-05-13 09:24:27 +0200 | [diff] [blame] | 468 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 469 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 470 | BYT_RT5640_OVCD_TH_2000UA | |
| 471 | BYT_RT5640_OVCD_SF_0P75 | |
Hans de Goede | 6748fb7 | 2018-05-13 09:24:27 +0200 | [diff] [blame] | 472 | BYT_RT5640_MONO_SPEAKER | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 473 | BYT_RT5640_MCLK_EN), |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 474 | }, |
Jorge Fernandez Monteagudo | 55fc205 | 2016-01-04 17:20:30 -0600 | [diff] [blame] | 475 | { |
Jorge Fernandez Monteagudo | 55fc205 | 2016-01-04 17:20:30 -0600 | [diff] [blame] | 476 | .matches = { |
Pierre-Louis Bossart | 73442e3 | 2016-08-12 16:27:44 -0500 | [diff] [blame] | 477 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 478 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP ElitePad 1000 G2"), |
Jorge Fernandez Monteagudo | 55fc205 | 2016-01-04 17:20:30 -0600 | [diff] [blame] | 479 | }, |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 480 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 481 | BYT_RT5640_MCLK_EN), |
Jorge Fernandez Monteagudo | 55fc205 | 2016-01-04 17:20:30 -0600 | [diff] [blame] | 482 | }, |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame^] | 483 | { /* HP Pavilion x2 10-n000nd */ |
| 484 | .matches = { |
| 485 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 486 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"), |
| 487 | }, |
| 488 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 489 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 490 | BYT_RT5640_OVCD_TH_1500UA | |
| 491 | BYT_RT5640_OVCD_SF_0P75 | |
| 492 | BYT_RT5640_SSP0_AIF1 | |
| 493 | BYT_RT5640_MCLK_EN), |
| 494 | }, |
| 495 | { /* HP Stream 7 */ |
| 496 | .matches = { |
| 497 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 498 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HP Stream 7 Tablet"), |
| 499 | }, |
| 500 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 501 | BYT_RT5640_MONO_SPEAKER | |
| 502 | BYT_RT5640_JD_NOT_INV | |
| 503 | BYT_RT5640_SSP0_AIF1 | |
| 504 | BYT_RT5640_MCLK_EN), |
| 505 | }, |
| 506 | { /* I.T.Works TW891 */ |
| 507 | .matches = { |
| 508 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "To be filled by O.E.M."), |
| 509 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TW891"), |
| 510 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."), |
| 511 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "TW891"), |
| 512 | }, |
| 513 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 514 | BYT_RT5640_MONO_SPEAKER | |
| 515 | BYT_RT5640_SSP0_AIF1 | |
| 516 | BYT_RT5640_MCLK_EN), |
| 517 | }, |
| 518 | { /* Lamina I8270 / T701BR.SE */ |
| 519 | .matches = { |
| 520 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Lamina"), |
| 521 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "T701BR.SE"), |
| 522 | }, |
| 523 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 524 | BYT_RT5640_MONO_SPEAKER | |
| 525 | BYT_RT5640_JD_NOT_INV | |
| 526 | BYT_RT5640_SSP0_AIF1 | |
| 527 | BYT_RT5640_MCLK_EN), |
| 528 | }, |
| 529 | { /* MSI S100 tablet */ |
| 530 | .matches = { |
| 531 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Micro-Star International Co., Ltd."), |
| 532 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "S100"), |
| 533 | }, |
| 534 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 535 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 536 | BYT_RT5640_OVCD_TH_2000UA | |
| 537 | BYT_RT5640_OVCD_SF_0P75 | |
| 538 | BYT_RT5640_MONO_SPEAKER | |
| 539 | BYT_RT5640_DIFF_MIC | |
| 540 | BYT_RT5640_MCLK_EN), |
| 541 | }, |
| 542 | { /* Pipo W4 */ |
| 543 | .matches = { |
| 544 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 545 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 546 | /* The above are too generic, also match BIOS info */ |
| 547 | DMI_MATCH(DMI_BIOS_VERSION, "V8L_WIN32_CHIPHD"), |
| 548 | }, |
| 549 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
| 550 | BYT_RT5640_MONO_SPEAKER | |
| 551 | BYT_RT5640_SSP0_AIF1 | |
| 552 | BYT_RT5640_MCLK_EN), |
| 553 | }, |
| 554 | { /* Point of View Mobii TAB-P800W (V2.0) */ |
| 555 | .matches = { |
| 556 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 557 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 558 | /* The above are too generic, also match BIOS info */ |
| 559 | DMI_EXACT_MATCH(DMI_BIOS_VERSION, "3BAIR1014"), |
| 560 | DMI_EXACT_MATCH(DMI_BIOS_DATE, "10/24/2014"), |
| 561 | }, |
| 562 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 563 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 564 | BYT_RT5640_OVCD_TH_2000UA | |
| 565 | BYT_RT5640_OVCD_SF_0P75 | |
| 566 | BYT_RT5640_MONO_SPEAKER | |
| 567 | BYT_RT5640_DIFF_MIC | |
| 568 | BYT_RT5640_SSP0_AIF2 | |
| 569 | BYT_RT5640_MCLK_EN), |
| 570 | }, |
| 571 | { /* Point of View Mobii TAB-P800W (V2.1) */ |
| 572 | .matches = { |
| 573 | DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 574 | DMI_EXACT_MATCH(DMI_BOARD_NAME, "Aptio CRB"), |
| 575 | /* The above are too generic, also match BIOS info */ |
| 576 | DMI_EXACT_MATCH(DMI_BIOS_VERSION, "3BAIR1013"), |
| 577 | DMI_EXACT_MATCH(DMI_BIOS_DATE, "08/22/2014"), |
| 578 | }, |
| 579 | .driver_data = (void *)(BYT_RT5640_IN1_MAP | |
| 580 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 581 | BYT_RT5640_OVCD_TH_2000UA | |
| 582 | BYT_RT5640_OVCD_SF_0P75 | |
| 583 | BYT_RT5640_MONO_SPEAKER | |
| 584 | BYT_RT5640_DIFF_MIC | |
| 585 | BYT_RT5640_SSP0_AIF2 | |
| 586 | BYT_RT5640_MCLK_EN), |
| 587 | }, |
Irina Tirdea | 0565e77 | 2016-08-12 16:27:58 -0500 | [diff] [blame] | 588 | { |
Irina Tirdea | 0565e77 | 2016-08-12 16:27:58 -0500 | [diff] [blame] | 589 | .matches = { |
Pierre-Louis Bossart | ec1c90e | 2016-08-12 16:27:59 -0500 | [diff] [blame] | 590 | DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"), |
| 591 | DMI_MATCH(DMI_BOARD_NAME, "tPAD"), |
| 592 | }, |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 593 | .driver_data = (void *)(BYT_RT5640_IN3_MAP | |
| 594 | BYT_RT5640_MCLK_EN | |
| 595 | BYT_RT5640_SSP0_AIF1), |
Pierre-Louis Bossart | ec1c90e | 2016-08-12 16:27:59 -0500 | [diff] [blame] | 596 | }, |
Hans de Goede | ec8e841 | 2018-05-13 09:24:34 +0200 | [diff] [blame^] | 597 | { /* Toshiba Satellite Click Mini L9W-B */ |
| 598 | .matches = { |
| 599 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), |
| 600 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SATELLITE Click Mini L9W-B"), |
| 601 | }, |
| 602 | .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | |
| 603 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 604 | BYT_RT5640_OVCD_TH_1500UA | |
| 605 | BYT_RT5640_OVCD_SF_0P75 | |
| 606 | BYT_RT5640_SSP0_AIF1 | |
| 607 | BYT_RT5640_MCLK_EN), |
| 608 | }, |
Hans de Goede | 3c0d011 | 2018-05-13 09:24:32 +0200 | [diff] [blame] | 609 | { /* Catch-all for generic Insyde tablets, must be last */ |
youling257 | 5718004 | 2017-01-04 15:44:53 -0600 | [diff] [blame] | 610 | .matches = { |
| 611 | DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), |
| 612 | }, |
Hans de Goede | 96a388fe | 2018-05-13 09:24:30 +0200 | [diff] [blame] | 613 | .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 614 | BYT_RT5640_MCLK_EN | |
| 615 | BYT_RT5640_SSP0_AIF1), |
youling257 | 5718004 | 2017-01-04 15:44:53 -0600 | [diff] [blame] | 616 | |
| 617 | }, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 618 | {} |
| 619 | }; |
| 620 | |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 621 | /* |
| 622 | * Note this MUST be called before snd_soc_register_card(), so that the props |
| 623 | * are in place before the codec component driver's probe function parses them. |
| 624 | */ |
| 625 | static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name) |
| 626 | { |
| 627 | struct property_entry props[MAX_NO_PROPS] = {}; |
| 628 | struct device *i2c_dev; |
| 629 | int ret, cnt = 0; |
| 630 | |
| 631 | i2c_dev = bus_find_device_by_name(&i2c_bus_type, NULL, i2c_dev_name); |
| 632 | if (!i2c_dev) |
| 633 | return -EPROBE_DEFER; |
| 634 | |
| 635 | switch (BYT_RT5640_MAP(byt_rt5640_quirk)) { |
Hans de Goede | a3ad291 | 2018-05-13 09:24:26 +0200 | [diff] [blame] | 636 | case BYT_RT5640_DMIC1_MAP: |
| 637 | props[cnt++] = PROPERTY_ENTRY_U32("realtek,dmic1-data-pin", |
| 638 | RT5640_DMIC1_DATA_PIN_IN1P); |
| 639 | break; |
| 640 | case BYT_RT5640_DMIC2_MAP: |
| 641 | props[cnt++] = PROPERTY_ENTRY_U32("realtek,dmic2-data-pin", |
| 642 | RT5640_DMIC2_DATA_PIN_IN1N); |
| 643 | break; |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 644 | case BYT_RT5640_IN1_MAP: |
| 645 | if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) |
| 646 | props[cnt++] = |
| 647 | PROPERTY_ENTRY_BOOL("realtek,in1-differential"); |
| 648 | break; |
| 649 | case BYT_RT5640_IN3_MAP: |
| 650 | if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) |
| 651 | props[cnt++] = |
| 652 | PROPERTY_ENTRY_BOOL("realtek,in3-differential"); |
| 653 | break; |
| 654 | } |
| 655 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 656 | if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) { |
| 657 | props[cnt++] = PROPERTY_ENTRY_U32( |
| 658 | "realtek,jack-detect-source", |
| 659 | BYT_RT5640_JDSRC(byt_rt5640_quirk)); |
| 660 | |
| 661 | props[cnt++] = PROPERTY_ENTRY_U32( |
| 662 | "realtek,over-current-threshold-microamp", |
| 663 | BYT_RT5640_OVCD_TH(byt_rt5640_quirk) * 100); |
| 664 | |
| 665 | props[cnt++] = PROPERTY_ENTRY_U32( |
| 666 | "realtek,over-current-scale-factor", |
| 667 | BYT_RT5640_OVCD_SF(byt_rt5640_quirk)); |
| 668 | } |
| 669 | |
| 670 | if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV) |
| 671 | props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted"); |
| 672 | |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 673 | ret = device_add_properties(i2c_dev, props); |
| 674 | put_device(i2c_dev); |
| 675 | |
| 676 | return ret; |
| 677 | } |
| 678 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 679 | static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) |
| 680 | { |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 681 | struct snd_soc_card *card = runtime->card; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 682 | struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); |
Kuninori Morimoto | d5a41b5 | 2018-01-29 03:42:46 +0000 | [diff] [blame] | 683 | struct snd_soc_component *component = runtime->codec_dai->component; |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 684 | const struct snd_soc_dapm_route *custom_map; |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 685 | int num_routes; |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 686 | int ret; |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 687 | |
| 688 | card->dapm.idle_bias_off = true; |
| 689 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 690 | /* Start with RC clk for jack-detect (we disable MCLK below) */ |
| 691 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) |
| 692 | snd_soc_component_update_bits(component, RT5640_GLB_CLK, |
| 693 | RT5640_SCLK_SRC_MASK, RT5640_SCLK_SRC_RCCLK); |
| 694 | |
Kuninori Morimoto | d5a41b5 | 2018-01-29 03:42:46 +0000 | [diff] [blame] | 695 | rt5640_sel_asrc_clk_src(component, |
Pierre-Louis Bossart | 0ec66e2d | 2016-01-04 17:20:27 -0600 | [diff] [blame] | 696 | RT5640_DA_STEREO_FILTER | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 697 | RT5640_DA_MONO_L_FILTER | |
| 698 | RT5640_DA_MONO_R_FILTER | |
| 699 | RT5640_AD_STEREO_FILTER | |
| 700 | RT5640_AD_MONO_L_FILTER | |
| 701 | RT5640_AD_MONO_R_FILTER, |
Pierre-Louis Bossart | 0ec66e2d | 2016-01-04 17:20:27 -0600 | [diff] [blame] | 702 | RT5640_CLK_SEL_ASRC); |
| 703 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 704 | ret = snd_soc_add_card_controls(card, byt_rt5640_controls, |
| 705 | ARRAY_SIZE(byt_rt5640_controls)); |
| 706 | if (ret) { |
| 707 | dev_err(card->dev, "unable to add card controls\n"); |
| 708 | return ret; |
| 709 | } |
| 710 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 711 | switch (BYT_RT5640_MAP(byt_rt5640_quirk)) { |
| 712 | case BYT_RT5640_IN1_MAP: |
| 713 | custom_map = byt_rt5640_intmic_in1_map; |
| 714 | num_routes = ARRAY_SIZE(byt_rt5640_intmic_in1_map); |
| 715 | break; |
Pierre-Louis Bossart | 59e8b65 | 2016-08-12 16:27:54 -0500 | [diff] [blame] | 716 | case BYT_RT5640_IN3_MAP: |
| 717 | custom_map = byt_rt5640_intmic_in3_map; |
| 718 | num_routes = ARRAY_SIZE(byt_rt5640_intmic_in3_map); |
| 719 | break; |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 720 | case BYT_RT5640_DMIC2_MAP: |
| 721 | custom_map = byt_rt5640_intmic_dmic2_map; |
| 722 | num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic2_map); |
| 723 | break; |
| 724 | default: |
| 725 | custom_map = byt_rt5640_intmic_dmic1_map; |
| 726 | num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map); |
| 727 | } |
| 728 | |
| 729 | ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); |
| 730 | if (ret) |
| 731 | return ret; |
| 732 | |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 733 | if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) { |
| 734 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 735 | byt_rt5640_ssp2_aif2_map, |
| 736 | ARRAY_SIZE(byt_rt5640_ssp2_aif2_map)); |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 737 | } else if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) { |
| 738 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 739 | byt_rt5640_ssp0_aif1_map, |
| 740 | ARRAY_SIZE(byt_rt5640_ssp0_aif1_map)); |
| 741 | } else if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) { |
| 742 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 743 | byt_rt5640_ssp0_aif2_map, |
| 744 | ARRAY_SIZE(byt_rt5640_ssp0_aif2_map)); |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 745 | } else { |
| 746 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 747 | byt_rt5640_ssp2_aif1_map, |
| 748 | ARRAY_SIZE(byt_rt5640_ssp2_aif1_map)); |
| 749 | } |
| 750 | if (ret) |
| 751 | return ret; |
| 752 | |
Pierre-Louis Bossart | 68817cd | 2016-08-12 16:27:45 -0500 | [diff] [blame] | 753 | if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) { |
| 754 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 755 | byt_rt5640_mono_spk_map, |
| 756 | ARRAY_SIZE(byt_rt5640_mono_spk_map)); |
| 757 | } else { |
| 758 | ret = snd_soc_dapm_add_routes(&card->dapm, |
| 759 | byt_rt5640_stereo_spk_map, |
| 760 | ARRAY_SIZE(byt_rt5640_stereo_spk_map)); |
| 761 | } |
| 762 | if (ret) |
| 763 | return ret; |
| 764 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 765 | snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone"); |
| 766 | snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker"); |
| 767 | |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 768 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 769 | /* |
| 770 | * The firmware might enable the clock at |
| 771 | * boot (this information may or may not |
| 772 | * be reflected in the enable clock register). |
| 773 | * To change the rate we must disable the clock |
| 774 | * first to cover these cases. Due to common |
| 775 | * clock framework restrictions that do not allow |
| 776 | * to disable a clock that has not been enabled, |
| 777 | * we need to enable the clock first. |
| 778 | */ |
| 779 | ret = clk_prepare_enable(priv->mclk); |
| 780 | if (!ret) |
| 781 | clk_disable_unprepare(priv->mclk); |
| 782 | |
| 783 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) |
| 784 | ret = clk_set_rate(priv->mclk, 25000000); |
| 785 | else |
| 786 | ret = clk_set_rate(priv->mclk, 19200000); |
| 787 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 788 | if (ret) { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 789 | dev_err(card->dev, "unable to set MCLK rate\n"); |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 790 | return ret; |
| 791 | } |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 792 | } |
| 793 | |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 794 | if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) { |
| 795 | ret = snd_soc_card_jack_new(card, "Headset", |
| 796 | SND_JACK_HEADSET | SND_JACK_BTN_0, |
| 797 | &priv->jack, rt5640_pins, |
| 798 | ARRAY_SIZE(rt5640_pins)); |
| 799 | if (ret) { |
| 800 | dev_err(card->dev, "Jack creation failed %d\n", ret); |
| 801 | return ret; |
| 802 | } |
| 803 | snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0, |
| 804 | KEY_PLAYPAUSE); |
| 805 | snd_soc_component_set_jack(component, &priv->jack, NULL); |
| 806 | } |
| 807 | |
| 808 | return 0; |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 809 | } |
| 810 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 811 | static const struct snd_soc_pcm_stream byt_rt5640_dai_params = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 812 | .formats = SNDRV_PCM_FMTBIT_S24_LE, |
| 813 | .rate_min = 48000, |
| 814 | .rate_max = 48000, |
| 815 | .channels_min = 2, |
| 816 | .channels_max = 2, |
| 817 | }; |
| 818 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 819 | 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] | 820 | struct snd_pcm_hw_params *params) |
| 821 | { |
| 822 | struct snd_interval *rate = hw_param_interval(params, |
| 823 | SNDRV_PCM_HW_PARAM_RATE); |
| 824 | struct snd_interval *channels = hw_param_interval(params, |
| 825 | SNDRV_PCM_HW_PARAM_CHANNELS); |
Sebastien Guiriec | 3f27ded | 2015-12-17 20:35:39 -0600 | [diff] [blame] | 826 | int ret; |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 827 | |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 828 | /* The DSP will covert the FE rate to 48k, stereo */ |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 829 | rate->min = rate->max = 48000; |
| 830 | channels->min = channels->max = 2; |
| 831 | |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 832 | if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) || |
| 833 | (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { |
Sebastien Guiriec | 3f27ded | 2015-12-17 20:35:39 -0600 | [diff] [blame] | 834 | |
Pierre-Louis Bossart | 8f98307d | 2016-08-16 18:28:22 -0500 | [diff] [blame] | 835 | /* set SSP0 to 16-bit */ |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 836 | params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); |
| 837 | |
| 838 | /* |
| 839 | * Default mode for SSP configuration is TDM 4 slot, override config |
| 840 | * with explicit setting to I2S 2ch 16-bit. The word length is set with |
| 841 | * dai_set_tdm_slot() since there is no other API exposed |
| 842 | */ |
| 843 | ret = snd_soc_dai_set_fmt(rtd->cpu_dai, |
| 844 | SND_SOC_DAIFMT_I2S | |
Pierre-Louis Bossart | f12f5c8 | 2017-01-26 14:09:29 -0600 | [diff] [blame] | 845 | SND_SOC_DAIFMT_NB_NF | |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 846 | SND_SOC_DAIFMT_CBS_CFS |
| 847 | ); |
| 848 | if (ret < 0) { |
| 849 | dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); |
| 850 | return ret; |
| 851 | } |
| 852 | |
| 853 | ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 16); |
| 854 | if (ret < 0) { |
| 855 | dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); |
| 856 | return ret; |
| 857 | } |
| 858 | |
| 859 | } else { |
| 860 | |
| 861 | /* set SSP2 to 24-bit */ |
| 862 | params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); |
| 863 | |
| 864 | /* |
| 865 | * Default mode for SSP configuration is TDM 4 slot, override config |
| 866 | * with explicit setting to I2S 2ch 24-bit. The word length is set with |
| 867 | * dai_set_tdm_slot() since there is no other API exposed |
| 868 | */ |
| 869 | ret = snd_soc_dai_set_fmt(rtd->cpu_dai, |
| 870 | SND_SOC_DAIFMT_I2S | |
Pierre-Louis Bossart | f12f5c8 | 2017-01-26 14:09:29 -0600 | [diff] [blame] | 871 | SND_SOC_DAIFMT_NB_NF | |
Pierre-Louis Bossart | 038a50e | 2016-08-12 16:27:52 -0500 | [diff] [blame] | 872 | SND_SOC_DAIFMT_CBS_CFS |
| 873 | ); |
| 874 | if (ret < 0) { |
| 875 | dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); |
| 876 | return ret; |
| 877 | } |
| 878 | |
| 879 | ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24); |
| 880 | if (ret < 0) { |
| 881 | dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); |
| 882 | return ret; |
| 883 | } |
Sebastien Guiriec | 3f27ded | 2015-12-17 20:35:39 -0600 | [diff] [blame] | 884 | } |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 885 | return 0; |
| 886 | } |
| 887 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 888 | static int byt_rt5640_aif1_startup(struct snd_pcm_substream *substream) |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 889 | { |
Lars-Peter Clausen | d0a1b66 | 2015-10-18 15:39:30 +0200 | [diff] [blame] | 890 | return snd_pcm_hw_constraint_single(substream->runtime, |
| 891 | SNDRV_PCM_HW_PARAM_RATE, 48000); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 892 | } |
| 893 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 894 | static const struct snd_soc_ops byt_rt5640_aif1_ops = { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 895 | .startup = byt_rt5640_aif1_startup, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 896 | }; |
| 897 | |
Julia Lawall | 9b6fdef | 2016-10-15 16:55:49 +0200 | [diff] [blame] | 898 | static const struct snd_soc_ops byt_rt5640_be_ssp2_ops = { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 899 | .hw_params = byt_rt5640_aif1_hw_params, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 900 | }; |
| 901 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 902 | static struct snd_soc_dai_link byt_rt5640_dais[] = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 903 | [MERR_DPCM_AUDIO] = { |
| 904 | .name = "Baytrail Audio Port", |
| 905 | .stream_name = "Baytrail Audio", |
| 906 | .cpu_dai_name = "media-cpu-dai", |
| 907 | .codec_dai_name = "snd-soc-dummy-dai", |
| 908 | .codec_name = "snd-soc-dummy", |
| 909 | .platform_name = "sst-mfld-platform", |
Takashi Iwai | 6e4cac2 | 2017-04-24 14:09:55 +0200 | [diff] [blame] | 910 | .nonatomic = true, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 911 | .dynamic = 1, |
| 912 | .dpcm_playback = 1, |
| 913 | .dpcm_capture = 1, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 914 | .ops = &byt_rt5640_aif1_ops, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 915 | }, |
Pierre-Louis Bossart | d35eb96 | 2015-12-17 20:35:45 -0600 | [diff] [blame] | 916 | [MERR_DPCM_DEEP_BUFFER] = { |
| 917 | .name = "Deep-Buffer Audio Port", |
| 918 | .stream_name = "Deep-Buffer Audio", |
| 919 | .cpu_dai_name = "deepbuffer-cpu-dai", |
| 920 | .codec_dai_name = "snd-soc-dummy-dai", |
| 921 | .codec_name = "snd-soc-dummy", |
| 922 | .platform_name = "sst-mfld-platform", |
Pierre-Louis Bossart | d35eb96 | 2015-12-17 20:35:45 -0600 | [diff] [blame] | 923 | .nonatomic = true, |
| 924 | .dynamic = 1, |
| 925 | .dpcm_playback = 1, |
| 926 | .ops = &byt_rt5640_aif1_ops, |
| 927 | }, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 928 | /* back ends */ |
| 929 | { |
| 930 | .name = "SSP2-Codec", |
Pierre-Louis Bossart | 149f775 | 2017-10-12 18:38:04 -0500 | [diff] [blame] | 931 | .id = 0, |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 932 | .cpu_dai_name = "ssp2-port", /* overwritten for ssp0 routing */ |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 933 | .platform_name = "sst-mfld-platform", |
| 934 | .no_pcm = 1, |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 935 | .codec_dai_name = "rt5640-aif1", /* changed w/ quirk */ |
Pierre-Louis Bossart | 7762ef4 | 2016-01-04 17:20:29 -0600 | [diff] [blame] | 936 | .codec_name = "i2c-10EC5640:00", /* overwritten with HID */ |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 937 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
| 938 | | SND_SOC_DAIFMT_CBS_CFS, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 939 | .be_hw_params_fixup = byt_rt5640_codec_fixup, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 940 | .ignore_suspend = 1, |
Takashi Iwai | 6e4cac2 | 2017-04-24 14:09:55 +0200 | [diff] [blame] | 941 | .nonatomic = true, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 942 | .dpcm_playback = 1, |
| 943 | .dpcm_capture = 1, |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 944 | .init = byt_rt5640_init, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 945 | .ops = &byt_rt5640_be_ssp2_ops, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 946 | }, |
| 947 | }; |
| 948 | |
| 949 | /* SoC card */ |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 950 | static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN]; |
| 951 | static char byt_rt5640_codec_aif_name[12]; /* = "rt5640-aif[1|2]" */ |
| 952 | static char byt_rt5640_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ |
| 953 | |
| 954 | static int byt_rt5640_suspend(struct snd_soc_card *card) |
| 955 | { |
| 956 | struct snd_soc_component *component; |
| 957 | |
| 958 | if (!BYT_RT5640_JDSRC(byt_rt5640_quirk)) |
| 959 | return 0; |
| 960 | |
| 961 | list_for_each_entry(component, &card->component_dev_list, card_list) { |
| 962 | if (!strcmp(component->name, byt_rt5640_codec_name)) { |
| 963 | dev_dbg(component->dev, "disabling jack detect before suspend\n"); |
| 964 | snd_soc_component_set_jack(component, NULL, NULL); |
| 965 | break; |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | return 0; |
| 970 | } |
| 971 | |
| 972 | static int byt_rt5640_resume(struct snd_soc_card *card) |
| 973 | { |
| 974 | struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); |
| 975 | struct snd_soc_component *component; |
| 976 | |
| 977 | if (!BYT_RT5640_JDSRC(byt_rt5640_quirk)) |
| 978 | return 0; |
| 979 | |
| 980 | list_for_each_entry(component, &card->component_dev_list, card_list) { |
| 981 | if (!strcmp(component->name, byt_rt5640_codec_name)) { |
| 982 | dev_dbg(component->dev, "re-enabling jack detect after resume\n"); |
| 983 | snd_soc_component_set_jack(component, &priv->jack, NULL); |
| 984 | break; |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | return 0; |
| 989 | } |
| 990 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 991 | static struct snd_soc_card byt_rt5640_card = { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 992 | .name = "bytcr-rt5640", |
Axel Lin | 54d8697 | 2015-08-21 20:59:21 +0800 | [diff] [blame] | 993 | .owner = THIS_MODULE, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 994 | .dai_link = byt_rt5640_dais, |
| 995 | .num_links = ARRAY_SIZE(byt_rt5640_dais), |
| 996 | .dapm_widgets = byt_rt5640_widgets, |
| 997 | .num_dapm_widgets = ARRAY_SIZE(byt_rt5640_widgets), |
| 998 | .dapm_routes = byt_rt5640_audio_map, |
| 999 | .num_dapm_routes = ARRAY_SIZE(byt_rt5640_audio_map), |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1000 | .fully_routed = true, |
Hans de Goede | 7732310 | 2018-05-13 09:24:28 +0200 | [diff] [blame] | 1001 | .suspend_pre = byt_rt5640_suspend, |
| 1002 | .resume_post = byt_rt5640_resume, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1003 | }; |
| 1004 | |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 1005 | static bool is_valleyview(void) |
| 1006 | { |
Pierre-Louis Bossart | cac1773 | 2016-08-16 18:28:21 -0500 | [diff] [blame] | 1007 | static const struct x86_cpu_id cpu_ids[] = { |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 1008 | { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */ |
| 1009 | {} |
| 1010 | }; |
| 1011 | |
| 1012 | if (!x86_match_cpu(cpu_ids)) |
| 1013 | return false; |
| 1014 | return true; |
| 1015 | } |
| 1016 | |
Pierre-Louis Bossart | 64e8430 | 2016-11-12 18:07:45 -0600 | [diff] [blame] | 1017 | struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ |
| 1018 | u64 aif_value; /* 1: AIF1, 2: AIF2 */ |
| 1019 | u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */ |
| 1020 | }; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1021 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1022 | static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1023 | { |
Hans de Goede | 6d1bfcc | 2018-05-13 09:24:33 +0200 | [diff] [blame] | 1024 | const struct dmi_system_id *dmi_id; |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 1025 | struct byt_rt5640_private *priv; |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 1026 | struct snd_soc_acpi_mach *mach; |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1027 | const char *i2c_name = NULL; |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 1028 | int ret_val = 0; |
Pierre-Louis Bossart | 2193eb9 | 2017-10-12 18:38:05 -0500 | [diff] [blame] | 1029 | int dai_index = 0; |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 1030 | int i; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1031 | |
Pierre-Louis Bossart | cb67d76 | 2017-04-24 16:34:33 -0500 | [diff] [blame] | 1032 | is_bytcr = false; |
Jia-Ju Bai | 7a3a632 | 2018-04-09 18:47:37 +0800 | [diff] [blame] | 1033 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1034 | if (!priv) |
| 1035 | return -ENOMEM; |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1036 | |
| 1037 | /* register the soc card */ |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1038 | byt_rt5640_card.dev = &pdev->dev; |
Pierre-Louis Bossart | caf94ed | 2016-01-04 17:20:28 -0600 | [diff] [blame] | 1039 | mach = byt_rt5640_card.dev->platform_data; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1040 | snd_soc_card_set_drvdata(&byt_rt5640_card, priv); |
Pierre-Louis Bossart | caf94ed | 2016-01-04 17:20:28 -0600 | [diff] [blame] | 1041 | |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1042 | /* fix index of codec dai */ |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1043 | for (i = 0; i < ARRAY_SIZE(byt_rt5640_dais); i++) { |
| 1044 | if (!strcmp(byt_rt5640_dais[i].codec_name, "i2c-10EC5640:00")) { |
| 1045 | dai_index = i; |
| 1046 | break; |
| 1047 | } |
| 1048 | } |
| 1049 | |
Pierre-Louis Bossart | caf94ed | 2016-01-04 17:20:28 -0600 | [diff] [blame] | 1050 | /* fixup codec name based on HID */ |
Andy Shevchenko | 3a14795 | 2018-01-12 23:16:17 +0200 | [diff] [blame] | 1051 | i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1); |
Pierre-Louis Bossart | 17b5273 | 2017-10-12 18:37:58 -0500 | [diff] [blame] | 1052 | if (i2c_name) { |
Pierre-Louis Bossart | a232b96 | 2016-03-03 21:36:38 -0600 | [diff] [blame] | 1053 | snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name), |
| 1054 | "%s%s", "i2c-", i2c_name); |
| 1055 | |
| 1056 | byt_rt5640_dais[dai_index].codec_name = byt_rt5640_codec_name; |
| 1057 | } |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1058 | |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 1059 | /* |
| 1060 | * swap SSP0 if bytcr is detected |
| 1061 | * (will be overridden if DMI quirk is detected) |
| 1062 | */ |
| 1063 | if (is_valleyview()) { |
| 1064 | struct sst_platform_info *p_info = mach->pdata; |
| 1065 | const struct sst_res_info *res_info = p_info->res_info; |
| 1066 | |
Pierre-Louis Bossart | 64e8430 | 2016-11-12 18:07:45 -0600 | [diff] [blame] | 1067 | if (res_info->acpi_ipc_irq_index == 0) |
| 1068 | is_bytcr = true; |
| 1069 | } |
| 1070 | |
| 1071 | if (is_bytcr) { |
| 1072 | /* |
| 1073 | * Baytrail CR platforms may have CHAN package in BIOS, try |
| 1074 | * to find relevant routing quirk based as done on Windows |
| 1075 | * platforms. We have to read the information directly from the |
| 1076 | * BIOS, at this stage the card is not created and the links |
| 1077 | * with the codec driver/pdata are non-existent |
| 1078 | */ |
| 1079 | |
| 1080 | struct acpi_chan_package chan_package; |
| 1081 | |
| 1082 | /* format specified: 2 64-bit integers */ |
| 1083 | struct acpi_buffer format = {sizeof("NN"), "NN"}; |
| 1084 | struct acpi_buffer state = {0, NULL}; |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 1085 | struct snd_soc_acpi_package_context pkg_ctx; |
Pierre-Louis Bossart | 64e8430 | 2016-11-12 18:07:45 -0600 | [diff] [blame] | 1086 | bool pkg_found = false; |
| 1087 | |
| 1088 | state.length = sizeof(chan_package); |
| 1089 | state.pointer = &chan_package; |
| 1090 | |
| 1091 | pkg_ctx.name = "CHAN"; |
| 1092 | pkg_ctx.length = 2; |
| 1093 | pkg_ctx.format = &format; |
| 1094 | pkg_ctx.state = &state; |
| 1095 | pkg_ctx.data_valid = false; |
| 1096 | |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 1097 | pkg_found = snd_soc_acpi_find_package_from_hid(mach->id, |
| 1098 | &pkg_ctx); |
Pierre-Louis Bossart | 64e8430 | 2016-11-12 18:07:45 -0600 | [diff] [blame] | 1099 | if (pkg_found) { |
| 1100 | if (chan_package.aif_value == 1) { |
| 1101 | dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); |
| 1102 | byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF1; |
| 1103 | } else if (chan_package.aif_value == 2) { |
| 1104 | dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n"); |
| 1105 | byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF2; |
| 1106 | } else { |
| 1107 | dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n"); |
| 1108 | pkg_found = false; |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | if (!pkg_found) { |
| 1113 | /* no BIOS indications, assume SSP0-AIF2 connection */ |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 1114 | byt_rt5640_quirk |= BYT_RT5640_SSP0_AIF2; |
| 1115 | } |
Pierre-Louis Bossart | bf46241 | 2016-11-12 18:07:46 -0600 | [diff] [blame] | 1116 | |
| 1117 | /* change defaults for Baytrail-CR capture */ |
Hans de Goede | 96a388fe | 2018-05-13 09:24:30 +0200 | [diff] [blame] | 1118 | byt_rt5640_quirk |= BYTCR_INPUT_DEFAULTS; |
Pierre-Louis Bossart | bf46241 | 2016-11-12 18:07:46 -0600 | [diff] [blame] | 1119 | } else { |
Hans de Goede | 56ff440 | 2018-05-13 09:24:31 +0200 | [diff] [blame] | 1120 | byt_rt5640_quirk |= BYT_RT5640_DMIC1_MAP | |
| 1121 | BYT_RT5640_JD_SRC_JD2_IN4N | |
| 1122 | BYT_RT5640_OVCD_TH_2000UA | |
| 1123 | BYT_RT5640_OVCD_SF_0P75; |
Pierre-Louis Bossart | e214f5e | 2016-08-12 16:27:53 -0500 | [diff] [blame] | 1124 | } |
| 1125 | |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 1126 | /* check quirks before creating card */ |
Hans de Goede | 6d1bfcc | 2018-05-13 09:24:33 +0200 | [diff] [blame] | 1127 | dmi_id = dmi_first_match(byt_rt5640_quirk_table); |
| 1128 | if (dmi_id) |
| 1129 | byt_rt5640_quirk = (unsigned long)dmi_id->driver_data; |
Takashi Iwai | 9f2cf73 | 2017-04-23 09:22:56 +0200 | [diff] [blame] | 1130 | if (quirk_override) { |
Takashi Iwai | 0b2c9f8 | 2017-04-24 23:34:30 +0200 | [diff] [blame] | 1131 | dev_info(&pdev->dev, "Overriding quirk 0x%x => 0x%x\n", |
Takashi Iwai | 9f2cf73 | 2017-04-23 09:22:56 +0200 | [diff] [blame] | 1132 | (unsigned int)byt_rt5640_quirk, quirk_override); |
| 1133 | byt_rt5640_quirk = quirk_override; |
| 1134 | } |
Hans de Goede | 6a7c05e | 2018-05-08 17:35:54 +0200 | [diff] [blame] | 1135 | |
| 1136 | /* Must be called before register_card, also see declaration comment. */ |
| 1137 | ret_val = byt_rt5640_add_codec_device_props(byt_rt5640_codec_name); |
| 1138 | if (ret_val) |
| 1139 | return ret_val; |
| 1140 | |
Pierre-Louis Bossart | d7e60d5 | 2016-08-12 16:28:00 -0500 | [diff] [blame] | 1141 | log_quirks(&pdev->dev); |
Pierre-Louis Bossart | ab738e4 | 2016-03-03 21:36:37 -0600 | [diff] [blame] | 1142 | |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 1143 | if ((byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) || |
| 1144 | (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { |
Pierre-Louis Bossart | 89b8907 | 2016-08-12 16:27:50 -0500 | [diff] [blame] | 1145 | |
| 1146 | /* fixup codec aif name */ |
| 1147 | snprintf(byt_rt5640_codec_aif_name, |
| 1148 | sizeof(byt_rt5640_codec_aif_name), |
| 1149 | "%s", "rt5640-aif2"); |
| 1150 | |
| 1151 | byt_rt5640_dais[dai_index].codec_dai_name = |
| 1152 | byt_rt5640_codec_aif_name; |
| 1153 | } |
| 1154 | |
Pierre-Louis Bossart | f47088d | 2016-08-12 16:27:51 -0500 | [diff] [blame] | 1155 | if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) || |
| 1156 | (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { |
| 1157 | |
| 1158 | /* fixup cpu dai name name */ |
| 1159 | snprintf(byt_rt5640_cpu_dai_name, |
| 1160 | sizeof(byt_rt5640_cpu_dai_name), |
| 1161 | "%s", "ssp0-port"); |
| 1162 | |
| 1163 | byt_rt5640_dais[dai_index].cpu_dai_name = |
| 1164 | byt_rt5640_cpu_dai_name; |
| 1165 | } |
| 1166 | |
Pierre-Louis Bossart | 7735bce | 2017-09-08 12:43:52 -0500 | [diff] [blame] | 1167 | if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1168 | priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); |
| 1169 | if (IS_ERR(priv->mclk)) { |
Pierre-Louis Bossart | 4a8b3a6 | 2016-12-16 10:55:49 -0600 | [diff] [blame] | 1170 | ret_val = PTR_ERR(priv->mclk); |
| 1171 | |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1172 | dev_err(&pdev->dev, |
Pierre-Louis Bossart | 4a8b3a6 | 2016-12-16 10:55:49 -0600 | [diff] [blame] | 1173 | "Failed to get MCLK from pmc_plt_clk_3: %d\n", |
| 1174 | ret_val); |
| 1175 | |
| 1176 | /* |
| 1177 | * Fall back to bit clock usage for -ENOENT (clock not |
| 1178 | * available likely due to missing dependencies), bail |
| 1179 | * for all other errors, including -EPROBE_DEFER |
| 1180 | */ |
| 1181 | if (ret_val != -ENOENT) |
| 1182 | return ret_val; |
| 1183 | byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN; |
Irina Tirdea | df1a277 | 2016-08-12 16:27:57 -0500 | [diff] [blame] | 1184 | } |
| 1185 | } |
| 1186 | |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1187 | ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5640_card); |
| 1188 | |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1189 | if (ret_val) { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1190 | dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n", |
| 1191 | ret_val); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1192 | return ret_val; |
| 1193 | } |
Pierre-Louis Bossart | 9fd5747 | 2015-12-17 20:35:42 -0600 | [diff] [blame] | 1194 | platform_set_drvdata(pdev, &byt_rt5640_card); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1195 | return ret_val; |
| 1196 | } |
| 1197 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1198 | static struct platform_driver snd_byt_rt5640_mc_driver = { |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1199 | .driver = { |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1200 | .name = "bytcr_rt5640", |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1201 | }, |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1202 | .probe = snd_byt_rt5640_mc_probe, |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1203 | }; |
| 1204 | |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1205 | module_platform_driver(snd_byt_rt5640_mc_driver); |
Subhransu S. Prusty | 996cc84 | 2014-11-19 15:13:27 +0530 | [diff] [blame] | 1206 | |
| 1207 | MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver"); |
| 1208 | MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>"); |
| 1209 | MODULE_LICENSE("GPL v2"); |
Pierre-Louis Bossart | a2d5563 | 2015-12-17 20:35:41 -0600 | [diff] [blame] | 1210 | MODULE_ALIAS("platform:bytcr_rt5640"); |