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