bytcr_rt5640.c 54 KB

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