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