sof_rt5682.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. // Copyright(c) 2019-2020 Intel Corporation.
  3. /*
  4. * Intel SOF Machine Driver with Realtek rt5682 Codec
  5. * and speaker codec MAX98357A or RT1015.
  6. */
  7. #include <linux/i2c.h>
  8. #include <linux/input.h>
  9. #include <linux/module.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/clk.h>
  12. #include <linux/dmi.h>
  13. #include <sound/core.h>
  14. #include <sound/jack.h>
  15. #include <sound/pcm.h>
  16. #include <sound/pcm_params.h>
  17. #include <sound/soc.h>
  18. #include <sound/sof.h>
  19. #include <sound/rt5682.h>
  20. #include <sound/rt5682s.h>
  21. #include <sound/soc-acpi.h>
  22. #include "../../codecs/rt5682.h"
  23. #include "../../codecs/rt5682s.h"
  24. #include "../../codecs/hdac_hdmi.h"
  25. #include "../common/soc-intel-quirks.h"
  26. #include "hda_dsp_common.h"
  27. #include "sof_maxim_common.h"
  28. #include "sof_realtek_common.h"
  29. #define NAME_SIZE 32
  30. #define SOF_RT5682_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0))
  31. #define SOF_RT5682_SSP_CODEC_MASK (GENMASK(2, 0))
  32. #define SOF_RT5682_MCLK_EN BIT(3)
  33. #define SOF_RT5682_MCLK_24MHZ BIT(4)
  34. #define SOF_SPEAKER_AMP_PRESENT BIT(5)
  35. #define SOF_RT5682_SSP_AMP_SHIFT 6
  36. #define SOF_RT5682_SSP_AMP_MASK (GENMASK(8, 6))
  37. #define SOF_RT5682_SSP_AMP(quirk) \
  38. (((quirk) << SOF_RT5682_SSP_AMP_SHIFT) & SOF_RT5682_SSP_AMP_MASK)
  39. #define SOF_RT5682_MCLK_BYTCHT_EN BIT(9)
  40. #define SOF_RT5682_NUM_HDMIDEV_SHIFT 10
  41. #define SOF_RT5682_NUM_HDMIDEV_MASK (GENMASK(12, 10))
  42. #define SOF_RT5682_NUM_HDMIDEV(quirk) \
  43. ((quirk << SOF_RT5682_NUM_HDMIDEV_SHIFT) & SOF_RT5682_NUM_HDMIDEV_MASK)
  44. #define SOF_RT1011_SPEAKER_AMP_PRESENT BIT(13)
  45. #define SOF_RT1015_SPEAKER_AMP_PRESENT BIT(14)
  46. #define SOF_RT1015P_SPEAKER_AMP_PRESENT BIT(16)
  47. #define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(17)
  48. #define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(18)
  49. /* BT audio offload: reserve 3 bits for future */
  50. #define SOF_BT_OFFLOAD_SSP_SHIFT 19
  51. #define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(21, 19))
  52. #define SOF_BT_OFFLOAD_SSP(quirk) \
  53. (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
  54. #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(22)
  55. #define SOF_RT5682S_HEADPHONE_CODEC_PRESENT BIT(23)
  56. #define SOF_MAX98390_SPEAKER_AMP_PRESENT BIT(24)
  57. #define SOF_MAX98390_TWEETER_SPEAKER_PRESENT BIT(25)
  58. #define SOF_RT1019_SPEAKER_AMP_PRESENT BIT(26)
  59. /* Default: MCLK on, MCLK 19.2M, SSP0 */
  60. static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
  61. SOF_RT5682_SSP_CODEC(0);
  62. static int is_legacy_cpu;
  63. struct sof_hdmi_pcm {
  64. struct list_head head;
  65. struct snd_soc_dai *codec_dai;
  66. struct snd_soc_jack hdmi_jack;
  67. int device;
  68. };
  69. struct sof_card_private {
  70. struct clk *mclk;
  71. struct snd_soc_jack sof_headset;
  72. struct list_head hdmi_pcm_list;
  73. bool common_hdmi_codec_drv;
  74. bool idisp_codec;
  75. };
  76. static int sof_rt5682_quirk_cb(const struct dmi_system_id *id)
  77. {
  78. sof_rt5682_quirk = (unsigned long)id->driver_data;
  79. return 1;
  80. }
  81. static const struct dmi_system_id sof_rt5682_quirk_table[] = {
  82. {
  83. .callback = sof_rt5682_quirk_cb,
  84. .matches = {
  85. DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"),
  86. DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max"),
  87. },
  88. .driver_data = (void *)(SOF_RT5682_SSP_CODEC(2)),
  89. },
  90. {
  91. .callback = sof_rt5682_quirk_cb,
  92. .matches = {
  93. DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
  94. DMI_MATCH(DMI_PRODUCT_NAME, "UP-CHT01"),
  95. },
  96. .driver_data = (void *)(SOF_RT5682_SSP_CODEC(2)),
  97. },
  98. {
  99. .callback = sof_rt5682_quirk_cb,
  100. .matches = {
  101. DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
  102. DMI_MATCH(DMI_PRODUCT_NAME, "WhiskeyLake Client"),
  103. },
  104. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  105. SOF_RT5682_MCLK_24MHZ |
  106. SOF_RT5682_SSP_CODEC(1)),
  107. },
  108. {
  109. /*
  110. * Dooly is hatch family but using rt1015 amp so it
  111. * requires a quirk before "Google_Hatch".
  112. */
  113. .callback = sof_rt5682_quirk_cb,
  114. .matches = {
  115. DMI_MATCH(DMI_SYS_VENDOR, "HP"),
  116. DMI_MATCH(DMI_PRODUCT_NAME, "Dooly"),
  117. },
  118. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  119. SOF_RT5682_MCLK_24MHZ |
  120. SOF_RT5682_SSP_CODEC(0) |
  121. SOF_SPEAKER_AMP_PRESENT |
  122. SOF_RT1015_SPEAKER_AMP_PRESENT |
  123. SOF_RT5682_SSP_AMP(1)),
  124. },
  125. {
  126. .callback = sof_rt5682_quirk_cb,
  127. .matches = {
  128. DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Hatch"),
  129. },
  130. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  131. SOF_RT5682_MCLK_24MHZ |
  132. SOF_RT5682_SSP_CODEC(0) |
  133. SOF_SPEAKER_AMP_PRESENT |
  134. SOF_RT5682_SSP_AMP(1)),
  135. },
  136. {
  137. .callback = sof_rt5682_quirk_cb,
  138. .matches = {
  139. DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
  140. DMI_MATCH(DMI_PRODUCT_NAME, "Ice Lake Client"),
  141. },
  142. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  143. SOF_RT5682_SSP_CODEC(0)),
  144. },
  145. {
  146. .callback = sof_rt5682_quirk_cb,
  147. .matches = {
  148. DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Volteer"),
  149. DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98373_ALC5682I_I2S_UP4"),
  150. },
  151. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  152. SOF_RT5682_SSP_CODEC(0) |
  153. SOF_SPEAKER_AMP_PRESENT |
  154. SOF_MAX98373_SPEAKER_AMP_PRESENT |
  155. SOF_RT5682_SSP_AMP(2) |
  156. SOF_RT5682_NUM_HDMIDEV(4)),
  157. },
  158. {
  159. .callback = sof_rt5682_quirk_cb,
  160. .matches = {
  161. DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
  162. DMI_MATCH(DMI_PRODUCT_NAME, "Alder Lake Client Platform"),
  163. DMI_MATCH(DMI_OEM_STRING, "AUDIO-ADL_MAX98373_ALC5682I_I2S"),
  164. },
  165. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  166. SOF_RT5682_SSP_CODEC(0) |
  167. SOF_SPEAKER_AMP_PRESENT |
  168. SOF_MAX98373_SPEAKER_AMP_PRESENT |
  169. SOF_RT5682_SSP_AMP(2) |
  170. SOF_RT5682_NUM_HDMIDEV(4)),
  171. },
  172. {
  173. .callback = sof_rt5682_quirk_cb,
  174. .matches = {
  175. DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
  176. DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S"),
  177. },
  178. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  179. SOF_RT5682_SSP_CODEC(0) |
  180. SOF_SPEAKER_AMP_PRESENT |
  181. SOF_MAX98390_SPEAKER_AMP_PRESENT |
  182. SOF_RT5682_SSP_AMP(2) |
  183. SOF_RT5682_NUM_HDMIDEV(4)),
  184. },
  185. {
  186. .callback = sof_rt5682_quirk_cb,
  187. .matches = {
  188. DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
  189. DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S_4SPK"),
  190. },
  191. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  192. SOF_RT5682_SSP_CODEC(0) |
  193. SOF_SPEAKER_AMP_PRESENT |
  194. SOF_MAX98390_SPEAKER_AMP_PRESENT |
  195. SOF_MAX98390_TWEETER_SPEAKER_PRESENT |
  196. SOF_RT5682_SSP_AMP(1) |
  197. SOF_RT5682_NUM_HDMIDEV(4) |
  198. SOF_BT_OFFLOAD_SSP(2) |
  199. SOF_SSP_BT_OFFLOAD_PRESENT),
  200. },
  201. {
  202. .callback = sof_rt5682_quirk_cb,
  203. .matches = {
  204. DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
  205. DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98360_ALC5682I_I2S_AMP_SSP2"),
  206. },
  207. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  208. SOF_RT5682_SSP_CODEC(0) |
  209. SOF_SPEAKER_AMP_PRESENT |
  210. SOF_MAX98360A_SPEAKER_AMP_PRESENT |
  211. SOF_RT5682_SSP_AMP(2) |
  212. SOF_RT5682_NUM_HDMIDEV(4)),
  213. },
  214. {
  215. .callback = sof_rt5682_quirk_cb,
  216. .matches = {
  217. DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Rex"),
  218. },
  219. .driver_data = (void *)(SOF_RT5682_MCLK_EN |
  220. SOF_RT5682_SSP_CODEC(2) |
  221. SOF_SPEAKER_AMP_PRESENT |
  222. SOF_RT5682_SSP_AMP(0) |
  223. SOF_RT5682_NUM_HDMIDEV(4)
  224. ),
  225. },
  226. {}
  227. };
  228. static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd)
  229. {
  230. struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  231. struct snd_soc_dai *dai = asoc_rtd_to_codec(rtd, 0);
  232. struct sof_hdmi_pcm *pcm;
  233. pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
  234. if (!pcm)
  235. return -ENOMEM;
  236. /* dai_link id is 1:1 mapped to the PCM device */
  237. pcm->device = rtd->dai_link->id;
  238. pcm->codec_dai = dai;
  239. list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
  240. return 0;
  241. }
  242. static struct snd_soc_jack_pin jack_pins[] = {
  243. {
  244. .pin = "Headphone Jack",
  245. .mask = SND_JACK_HEADPHONE,
  246. },
  247. {
  248. .pin = "Headset Mic",
  249. .mask = SND_JACK_MICROPHONE,
  250. },
  251. };
  252. static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
  253. {
  254. struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  255. struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
  256. struct snd_soc_jack *jack;
  257. int ret;
  258. /* need to enable ASRC function for 24MHz mclk rate */
  259. if ((sof_rt5682_quirk & SOF_RT5682_MCLK_EN) &&
  260. (sof_rt5682_quirk & SOF_RT5682_MCLK_24MHZ)) {
  261. if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT)
  262. rt5682s_sel_asrc_clk_src(component,
  263. RT5682S_DA_STEREO1_FILTER |
  264. RT5682S_AD_STEREO1_FILTER,
  265. RT5682S_CLK_SEL_I2S1_ASRC);
  266. else
  267. rt5682_sel_asrc_clk_src(component,
  268. RT5682_DA_STEREO1_FILTER |
  269. RT5682_AD_STEREO1_FILTER,
  270. RT5682_CLK_SEL_I2S1_ASRC);
  271. }
  272. if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
  273. /*
  274. * The firmware might enable the clock at
  275. * boot (this information may or may not
  276. * be reflected in the enable clock register).
  277. * To change the rate we must disable the clock
  278. * first to cover these cases. Due to common
  279. * clock framework restrictions that do not allow
  280. * to disable a clock that has not been enabled,
  281. * we need to enable the clock first.
  282. */
  283. ret = clk_prepare_enable(ctx->mclk);
  284. if (!ret)
  285. clk_disable_unprepare(ctx->mclk);
  286. ret = clk_set_rate(ctx->mclk, 19200000);
  287. if (ret)
  288. dev_err(rtd->dev, "unable to set MCLK rate\n");
  289. }
  290. /*
  291. * Headset buttons map to the google Reference headset.
  292. * These can be configured by userspace.
  293. */
  294. ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
  295. SND_JACK_HEADSET | SND_JACK_BTN_0 |
  296. SND_JACK_BTN_1 | SND_JACK_BTN_2 |
  297. SND_JACK_BTN_3,
  298. &ctx->sof_headset,
  299. jack_pins,
  300. ARRAY_SIZE(jack_pins));
  301. if (ret) {
  302. dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
  303. return ret;
  304. }
  305. jack = &ctx->sof_headset;
  306. snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
  307. snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
  308. snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
  309. snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
  310. ret = snd_soc_component_set_jack(component, jack, NULL);
  311. if (ret) {
  312. dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
  313. return ret;
  314. }
  315. return ret;
  316. };
  317. static void sof_rt5682_codec_exit(struct snd_soc_pcm_runtime *rtd)
  318. {
  319. struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
  320. snd_soc_component_set_jack(component, NULL, NULL);
  321. }
  322. static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
  323. struct snd_pcm_hw_params *params)
  324. {
  325. struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
  326. struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  327. struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
  328. int pll_id, pll_source, pll_in, pll_out, clk_id, ret;
  329. if (sof_rt5682_quirk & SOF_RT5682_MCLK_EN) {
  330. if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
  331. ret = clk_prepare_enable(ctx->mclk);
  332. if (ret < 0) {
  333. dev_err(rtd->dev,
  334. "could not configure MCLK state");
  335. return ret;
  336. }
  337. }
  338. if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT)
  339. pll_source = RT5682S_PLL_S_MCLK;
  340. else
  341. pll_source = RT5682_PLL1_S_MCLK;
  342. /* get the tplg configured mclk. */
  343. pll_in = sof_dai_get_mclk(rtd);
  344. /* mclk from the quirk is the first choice */
  345. if (sof_rt5682_quirk & SOF_RT5682_MCLK_24MHZ) {
  346. if (pll_in != 24000000)
  347. dev_warn(rtd->dev, "configure wrong mclk in tplg, please use 24MHz.\n");
  348. pll_in = 24000000;
  349. } else if (pll_in == 0) {
  350. /* use default mclk if not specified correct in topology */
  351. pll_in = 19200000;
  352. } else if (pll_in < 0) {
  353. return pll_in;
  354. }
  355. } else {
  356. if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT)
  357. pll_source = RT5682S_PLL_S_BCLK1;
  358. else
  359. pll_source = RT5682_PLL1_S_BCLK1;
  360. pll_in = params_rate(params) * 50;
  361. }
  362. if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) {
  363. pll_id = RT5682S_PLL2;
  364. clk_id = RT5682S_SCLK_S_PLL2;
  365. } else {
  366. pll_id = RT5682_PLL1;
  367. clk_id = RT5682_SCLK_S_PLL1;
  368. }
  369. pll_out = params_rate(params) * 512;
  370. /* when MCLK is 512FS, no need to set PLL configuration additionally. */
  371. if (pll_in == pll_out)
  372. clk_id = RT5682S_SCLK_S_MCLK;
  373. else {
  374. /* Configure pll for codec */
  375. ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, pll_in,
  376. pll_out);
  377. if (ret < 0)
  378. dev_err(rtd->dev, "snd_soc_dai_set_pll err = %d\n", ret);
  379. }
  380. /* Configure sysclk for codec */
  381. ret = snd_soc_dai_set_sysclk(codec_dai, clk_id,
  382. pll_out, SND_SOC_CLOCK_IN);
  383. if (ret < 0)
  384. dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
  385. /*
  386. * slot_width should equal or large than data length, set them
  387. * be the same
  388. */
  389. ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x0, 0x0, 2,
  390. params_width(params));
  391. if (ret < 0) {
  392. dev_err(rtd->dev, "set TDM slot err:%d\n", ret);
  393. return ret;
  394. }
  395. return ret;
  396. }
  397. static struct snd_soc_ops sof_rt5682_ops = {
  398. .hw_params = sof_rt5682_hw_params,
  399. };
  400. static struct snd_soc_dai_link_component platform_component[] = {
  401. {
  402. /* name might be overridden during probe */
  403. .name = "0000:00:1f.3"
  404. }
  405. };
  406. static int sof_card_late_probe(struct snd_soc_card *card)
  407. {
  408. struct sof_card_private *ctx = snd_soc_card_get_drvdata(card);
  409. struct snd_soc_component *component = NULL;
  410. struct snd_soc_dapm_context *dapm = &card->dapm;
  411. char jack_name[NAME_SIZE];
  412. struct sof_hdmi_pcm *pcm;
  413. int err;
  414. if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) {
  415. /* Disable Left and Right Spk pin after boot */
  416. snd_soc_dapm_disable_pin(dapm, "Left Spk");
  417. snd_soc_dapm_disable_pin(dapm, "Right Spk");
  418. err = snd_soc_dapm_sync(dapm);
  419. if (err < 0)
  420. return err;
  421. }
  422. /* HDMI is not supported by SOF on Baytrail/CherryTrail */
  423. if (is_legacy_cpu || !ctx->idisp_codec)
  424. return 0;
  425. if (list_empty(&ctx->hdmi_pcm_list))
  426. return -EINVAL;
  427. if (ctx->common_hdmi_codec_drv) {
  428. pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm,
  429. head);
  430. component = pcm->codec_dai->component;
  431. return hda_dsp_hdmi_build_controls(card, component);
  432. }
  433. list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
  434. component = pcm->codec_dai->component;
  435. snprintf(jack_name, sizeof(jack_name),
  436. "HDMI/DP, pcm=%d Jack", pcm->device);
  437. err = snd_soc_card_jack_new(card, jack_name,
  438. SND_JACK_AVOUT, &pcm->hdmi_jack);
  439. if (err)
  440. return err;
  441. err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
  442. &pcm->hdmi_jack);
  443. if (err < 0)
  444. return err;
  445. }
  446. return hdac_hdmi_jack_port_init(component, &card->dapm);
  447. }
  448. static const struct snd_kcontrol_new sof_controls[] = {
  449. SOC_DAPM_PIN_SWITCH("Headphone Jack"),
  450. SOC_DAPM_PIN_SWITCH("Headset Mic"),
  451. SOC_DAPM_PIN_SWITCH("Left Spk"),
  452. SOC_DAPM_PIN_SWITCH("Right Spk"),
  453. };
  454. static const struct snd_soc_dapm_widget sof_widgets[] = {
  455. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  456. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  457. SND_SOC_DAPM_SPK("Left Spk", NULL),
  458. SND_SOC_DAPM_SPK("Right Spk", NULL),
  459. };
  460. static const struct snd_soc_dapm_widget dmic_widgets[] = {
  461. SND_SOC_DAPM_MIC("SoC DMIC", NULL),
  462. };
  463. static const struct snd_soc_dapm_route sof_map[] = {
  464. /* HP jack connectors - unknown if we have jack detection */
  465. { "Headphone Jack", NULL, "HPOL" },
  466. { "Headphone Jack", NULL, "HPOR" },
  467. /* other jacks */
  468. { "IN1P", NULL, "Headset Mic" },
  469. };
  470. static const struct snd_soc_dapm_route dmic_map[] = {
  471. /* digital mics */
  472. {"DMic", NULL, "SoC DMIC"},
  473. };
  474. static int dmic_init(struct snd_soc_pcm_runtime *rtd)
  475. {
  476. struct snd_soc_card *card = rtd->card;
  477. int ret;
  478. ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
  479. ARRAY_SIZE(dmic_widgets));
  480. if (ret) {
  481. dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
  482. /* Don't need to add routes if widget addition failed */
  483. return ret;
  484. }
  485. ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
  486. ARRAY_SIZE(dmic_map));
  487. if (ret)
  488. dev_err(card->dev, "DMic map addition failed: %d\n", ret);
  489. return ret;
  490. }
  491. /* sof audio machine driver for rt5682 codec */
  492. static struct snd_soc_card sof_audio_card_rt5682 = {
  493. .name = "rt5682", /* the sof- prefix is added by the core */
  494. .owner = THIS_MODULE,
  495. .controls = sof_controls,
  496. .num_controls = ARRAY_SIZE(sof_controls),
  497. .dapm_widgets = sof_widgets,
  498. .num_dapm_widgets = ARRAY_SIZE(sof_widgets),
  499. .dapm_routes = sof_map,
  500. .num_dapm_routes = ARRAY_SIZE(sof_map),
  501. .fully_routed = true,
  502. .late_probe = sof_card_late_probe,
  503. };
  504. static struct snd_soc_dai_link_component rt5682_component[] = {
  505. {
  506. .name = "i2c-10EC5682:00",
  507. .dai_name = "rt5682-aif1",
  508. }
  509. };
  510. static struct snd_soc_dai_link_component rt5682s_component[] = {
  511. {
  512. .name = "i2c-RTL5682:00",
  513. .dai_name = "rt5682s-aif1",
  514. }
  515. };
  516. static struct snd_soc_dai_link_component dmic_component[] = {
  517. {
  518. .name = "dmic-codec",
  519. .dai_name = "dmic-hifi",
  520. }
  521. };
  522. static struct snd_soc_dai_link_component dummy_component[] = {
  523. {
  524. .name = "snd-soc-dummy",
  525. .dai_name = "snd-soc-dummy-dai",
  526. }
  527. };
  528. #define IDISP_CODEC_MASK 0x4
  529. static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
  530. int ssp_codec,
  531. int ssp_amp,
  532. int dmic_be_num,
  533. int hdmi_num,
  534. bool idisp_codec)
  535. {
  536. struct snd_soc_dai_link_component *idisp_components;
  537. struct snd_soc_dai_link_component *cpus;
  538. struct snd_soc_dai_link *links;
  539. int i, id = 0;
  540. links = devm_kcalloc(dev, sof_audio_card_rt5682.num_links,
  541. sizeof(struct snd_soc_dai_link), GFP_KERNEL);
  542. cpus = devm_kcalloc(dev, sof_audio_card_rt5682.num_links,
  543. sizeof(struct snd_soc_dai_link_component), GFP_KERNEL);
  544. if (!links || !cpus)
  545. goto devm_err;
  546. /* codec SSP */
  547. links[id].name = devm_kasprintf(dev, GFP_KERNEL,
  548. "SSP%d-Codec", ssp_codec);
  549. if (!links[id].name)
  550. goto devm_err;
  551. links[id].id = id;
  552. if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) {
  553. links[id].codecs = rt5682s_component;
  554. links[id].num_codecs = ARRAY_SIZE(rt5682s_component);
  555. } else {
  556. links[id].codecs = rt5682_component;
  557. links[id].num_codecs = ARRAY_SIZE(rt5682_component);
  558. }
  559. links[id].platforms = platform_component;
  560. links[id].num_platforms = ARRAY_SIZE(platform_component);
  561. links[id].init = sof_rt5682_codec_init;
  562. links[id].exit = sof_rt5682_codec_exit;
  563. links[id].ops = &sof_rt5682_ops;
  564. links[id].dpcm_playback = 1;
  565. links[id].dpcm_capture = 1;
  566. links[id].no_pcm = 1;
  567. links[id].cpus = &cpus[id];
  568. links[id].num_cpus = 1;
  569. if (is_legacy_cpu) {
  570. links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
  571. "ssp%d-port",
  572. ssp_codec);
  573. if (!links[id].cpus->dai_name)
  574. goto devm_err;
  575. } else {
  576. /*
  577. * Currently, On SKL+ platforms MCLK will be turned off in sof
  578. * runtime suspended, and it will go into runtime suspended
  579. * right after playback is stop. However, rt5682 will output
  580. * static noise if sysclk turns off during playback. Set
  581. * ignore_pmdown_time to power down rt5682 immediately and
  582. * avoid the noise.
  583. * It can be removed once we can control MCLK by driver.
  584. */
  585. links[id].ignore_pmdown_time = 1;
  586. links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
  587. "SSP%d Pin",
  588. ssp_codec);
  589. if (!links[id].cpus->dai_name)
  590. goto devm_err;
  591. }
  592. id++;
  593. /* dmic */
  594. if (dmic_be_num > 0) {
  595. /* at least we have dmic01 */
  596. links[id].name = "dmic01";
  597. links[id].cpus = &cpus[id];
  598. links[id].cpus->dai_name = "DMIC01 Pin";
  599. links[id].init = dmic_init;
  600. if (dmic_be_num > 1) {
  601. /* set up 2 BE links at most */
  602. links[id + 1].name = "dmic16k";
  603. links[id + 1].cpus = &cpus[id + 1];
  604. links[id + 1].cpus->dai_name = "DMIC16k Pin";
  605. dmic_be_num = 2;
  606. }
  607. }
  608. for (i = 0; i < dmic_be_num; i++) {
  609. links[id].id = id;
  610. links[id].num_cpus = 1;
  611. links[id].codecs = dmic_component;
  612. links[id].num_codecs = ARRAY_SIZE(dmic_component);
  613. links[id].platforms = platform_component;
  614. links[id].num_platforms = ARRAY_SIZE(platform_component);
  615. links[id].ignore_suspend = 1;
  616. links[id].dpcm_capture = 1;
  617. links[id].no_pcm = 1;
  618. id++;
  619. }
  620. /* HDMI */
  621. if (hdmi_num > 0) {
  622. idisp_components = devm_kcalloc(dev,
  623. hdmi_num,
  624. sizeof(struct snd_soc_dai_link_component),
  625. GFP_KERNEL);
  626. if (!idisp_components)
  627. goto devm_err;
  628. }
  629. for (i = 1; i <= hdmi_num; i++) {
  630. links[id].name = devm_kasprintf(dev, GFP_KERNEL,
  631. "iDisp%d", i);
  632. if (!links[id].name)
  633. goto devm_err;
  634. links[id].id = id;
  635. links[id].cpus = &cpus[id];
  636. links[id].num_cpus = 1;
  637. links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
  638. "iDisp%d Pin", i);
  639. if (!links[id].cpus->dai_name)
  640. goto devm_err;
  641. if (idisp_codec) {
  642. idisp_components[i - 1].name = "ehdaudio0D2";
  643. idisp_components[i - 1].dai_name = devm_kasprintf(dev,
  644. GFP_KERNEL,
  645. "intel-hdmi-hifi%d",
  646. i);
  647. if (!idisp_components[i - 1].dai_name)
  648. goto devm_err;
  649. } else {
  650. idisp_components[i - 1].name = "snd-soc-dummy";
  651. idisp_components[i - 1].dai_name = "snd-soc-dummy-dai";
  652. }
  653. links[id].codecs = &idisp_components[i - 1];
  654. links[id].num_codecs = 1;
  655. links[id].platforms = platform_component;
  656. links[id].num_platforms = ARRAY_SIZE(platform_component);
  657. links[id].init = sof_hdmi_init;
  658. links[id].dpcm_playback = 1;
  659. links[id].no_pcm = 1;
  660. id++;
  661. }
  662. /* speaker amp */
  663. if (sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) {
  664. links[id].name = devm_kasprintf(dev, GFP_KERNEL,
  665. "SSP%d-Codec", ssp_amp);
  666. if (!links[id].name)
  667. goto devm_err;
  668. links[id].id = id;
  669. if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT) {
  670. sof_rt1015_dai_link(&links[id]);
  671. } else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) {
  672. sof_rt1015p_dai_link(&links[id]);
  673. } else if (sof_rt5682_quirk & SOF_RT1019_SPEAKER_AMP_PRESENT) {
  674. sof_rt1019p_dai_link(&links[id]);
  675. } else if (sof_rt5682_quirk &
  676. SOF_MAX98373_SPEAKER_AMP_PRESENT) {
  677. links[id].codecs = max_98373_components;
  678. links[id].num_codecs = ARRAY_SIZE(max_98373_components);
  679. links[id].init = max_98373_spk_codec_init;
  680. links[id].ops = &max_98373_ops;
  681. } else if (sof_rt5682_quirk &
  682. SOF_MAX98360A_SPEAKER_AMP_PRESENT) {
  683. max_98360a_dai_link(&links[id]);
  684. } else if (sof_rt5682_quirk &
  685. SOF_RT1011_SPEAKER_AMP_PRESENT) {
  686. sof_rt1011_dai_link(&links[id]);
  687. } else if (sof_rt5682_quirk &
  688. SOF_MAX98390_SPEAKER_AMP_PRESENT) {
  689. if (sof_rt5682_quirk &
  690. SOF_MAX98390_TWEETER_SPEAKER_PRESENT) {
  691. links[id].codecs = max_98390_4spk_components;
  692. links[id].num_codecs = ARRAY_SIZE(max_98390_4spk_components);
  693. } else {
  694. links[id].codecs = max_98390_components;
  695. links[id].num_codecs = ARRAY_SIZE(max_98390_components);
  696. }
  697. links[id].init = max_98390_spk_codec_init;
  698. links[id].ops = &max_98390_ops;
  699. links[id].dpcm_capture = 1;
  700. } else {
  701. max_98357a_dai_link(&links[id]);
  702. }
  703. links[id].platforms = platform_component;
  704. links[id].num_platforms = ARRAY_SIZE(platform_component);
  705. links[id].dpcm_playback = 1;
  706. /* feedback stream or firmware-generated echo reference */
  707. links[id].dpcm_capture = 1;
  708. links[id].no_pcm = 1;
  709. links[id].cpus = &cpus[id];
  710. links[id].num_cpus = 1;
  711. if (is_legacy_cpu) {
  712. links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
  713. "ssp%d-port",
  714. ssp_amp);
  715. if (!links[id].cpus->dai_name)
  716. goto devm_err;
  717. } else {
  718. links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
  719. "SSP%d Pin",
  720. ssp_amp);
  721. if (!links[id].cpus->dai_name)
  722. goto devm_err;
  723. }
  724. id++;
  725. }
  726. /* BT audio offload */
  727. if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) {
  728. int port = (sof_rt5682_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
  729. SOF_BT_OFFLOAD_SSP_SHIFT;
  730. links[id].id = id;
  731. links[id].cpus = &cpus[id];
  732. links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
  733. "SSP%d Pin", port);
  734. if (!links[id].cpus->dai_name)
  735. goto devm_err;
  736. links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port);
  737. if (!links[id].name)
  738. goto devm_err;
  739. links[id].codecs = dummy_component;
  740. links[id].num_codecs = ARRAY_SIZE(dummy_component);
  741. links[id].platforms = platform_component;
  742. links[id].num_platforms = ARRAY_SIZE(platform_component);
  743. links[id].dpcm_playback = 1;
  744. links[id].dpcm_capture = 1;
  745. links[id].no_pcm = 1;
  746. links[id].num_cpus = 1;
  747. }
  748. return links;
  749. devm_err:
  750. return NULL;
  751. }
  752. static int sof_audio_probe(struct platform_device *pdev)
  753. {
  754. struct snd_soc_dai_link *dai_links;
  755. struct snd_soc_acpi_mach *mach;
  756. struct sof_card_private *ctx;
  757. int dmic_be_num, hdmi_num;
  758. int ret, ssp_amp, ssp_codec;
  759. ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
  760. if (!ctx)
  761. return -ENOMEM;
  762. if (pdev->id_entry && pdev->id_entry->driver_data)
  763. sof_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data;
  764. dmi_check_system(sof_rt5682_quirk_table);
  765. mach = pdev->dev.platform_data;
  766. /* A speaker amp might not be present when the quirk claims one is.
  767. * Detect this via whether the machine driver match includes quirk_data.
  768. */
  769. if ((sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) && !mach->quirk_data)
  770. sof_rt5682_quirk &= ~SOF_SPEAKER_AMP_PRESENT;
  771. /* Detect the headset codec variant */
  772. if (acpi_dev_present("RTL5682", NULL, -1))
  773. sof_rt5682_quirk |= SOF_RT5682S_HEADPHONE_CODEC_PRESENT;
  774. /* Detect the headset codec variant to support machines in DMI quirk */
  775. if (acpi_dev_present("RTL5682", NULL, -1))
  776. sof_rt5682_quirk |= SOF_RT5682S_HEADPHONE_CODEC_PRESENT;
  777. if (soc_intel_is_byt() || soc_intel_is_cht()) {
  778. is_legacy_cpu = 1;
  779. dmic_be_num = 0;
  780. hdmi_num = 0;
  781. /* default quirk for legacy cpu */
  782. sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
  783. SOF_RT5682_MCLK_BYTCHT_EN |
  784. SOF_RT5682_SSP_CODEC(2);
  785. } else {
  786. dmic_be_num = 2;
  787. hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >>
  788. SOF_RT5682_NUM_HDMIDEV_SHIFT;
  789. /* default number of HDMI DAI's */
  790. if (!hdmi_num)
  791. hdmi_num = 3;
  792. if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
  793. ctx->idisp_codec = true;
  794. }
  795. /* need to get main clock from pmc */
  796. if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
  797. ctx->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
  798. if (IS_ERR(ctx->mclk)) {
  799. ret = PTR_ERR(ctx->mclk);
  800. dev_err(&pdev->dev,
  801. "Failed to get MCLK from pmc_plt_clk_3: %d\n",
  802. ret);
  803. return ret;
  804. }
  805. ret = clk_prepare_enable(ctx->mclk);
  806. if (ret < 0) {
  807. dev_err(&pdev->dev,
  808. "could not configure MCLK state");
  809. return ret;
  810. }
  811. }
  812. dev_dbg(&pdev->dev, "sof_rt5682_quirk = %lx\n", sof_rt5682_quirk);
  813. ssp_amp = (sof_rt5682_quirk & SOF_RT5682_SSP_AMP_MASK) >>
  814. SOF_RT5682_SSP_AMP_SHIFT;
  815. ssp_codec = sof_rt5682_quirk & SOF_RT5682_SSP_CODEC_MASK;
  816. /* compute number of dai links */
  817. sof_audio_card_rt5682.num_links = 1 + dmic_be_num + hdmi_num;
  818. if (sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT)
  819. sof_audio_card_rt5682.num_links++;
  820. if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT)
  821. max_98373_set_codec_conf(&sof_audio_card_rt5682);
  822. else if (sof_rt5682_quirk & SOF_RT1011_SPEAKER_AMP_PRESENT)
  823. sof_rt1011_codec_conf(&sof_audio_card_rt5682);
  824. else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT)
  825. sof_rt1015p_codec_conf(&sof_audio_card_rt5682);
  826. else if (sof_rt5682_quirk & SOF_MAX98390_SPEAKER_AMP_PRESENT) {
  827. if (sof_rt5682_quirk & SOF_MAX98390_TWEETER_SPEAKER_PRESENT)
  828. max_98390_set_codec_conf(&sof_audio_card_rt5682,
  829. ARRAY_SIZE(max_98390_4spk_components));
  830. else
  831. max_98390_set_codec_conf(&sof_audio_card_rt5682,
  832. ARRAY_SIZE(max_98390_components));
  833. }
  834. if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
  835. sof_audio_card_rt5682.num_links++;
  836. dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp,
  837. dmic_be_num, hdmi_num, ctx->idisp_codec);
  838. if (!dai_links)
  839. return -ENOMEM;
  840. sof_audio_card_rt5682.dai_link = dai_links;
  841. if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT)
  842. sof_rt1015_codec_conf(&sof_audio_card_rt5682);
  843. INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
  844. sof_audio_card_rt5682.dev = &pdev->dev;
  845. /* set platform name for each dailink */
  846. ret = snd_soc_fixup_dai_links_platform_name(&sof_audio_card_rt5682,
  847. mach->mach_params.platform);
  848. if (ret)
  849. return ret;
  850. ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
  851. snd_soc_card_set_drvdata(&sof_audio_card_rt5682, ctx);
  852. return devm_snd_soc_register_card(&pdev->dev,
  853. &sof_audio_card_rt5682);
  854. }
  855. static const struct platform_device_id board_ids[] = {
  856. {
  857. .name = "sof_rt5682",
  858. },
  859. {
  860. .name = "tgl_mx98357_rt5682",
  861. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  862. SOF_RT5682_SSP_CODEC(0) |
  863. SOF_SPEAKER_AMP_PRESENT |
  864. SOF_RT5682_SSP_AMP(1) |
  865. SOF_RT5682_NUM_HDMIDEV(4) |
  866. SOF_BT_OFFLOAD_SSP(2) |
  867. SOF_SSP_BT_OFFLOAD_PRESENT),
  868. },
  869. {
  870. .name = "jsl_rt5682_rt1015",
  871. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  872. SOF_RT5682_MCLK_24MHZ |
  873. SOF_RT5682_SSP_CODEC(0) |
  874. SOF_SPEAKER_AMP_PRESENT |
  875. SOF_RT1015_SPEAKER_AMP_PRESENT |
  876. SOF_RT5682_SSP_AMP(1)),
  877. },
  878. {
  879. .name = "tgl_mx98373_rt5682",
  880. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  881. SOF_RT5682_SSP_CODEC(0) |
  882. SOF_SPEAKER_AMP_PRESENT |
  883. SOF_MAX98373_SPEAKER_AMP_PRESENT |
  884. SOF_RT5682_SSP_AMP(1) |
  885. SOF_RT5682_NUM_HDMIDEV(4) |
  886. SOF_BT_OFFLOAD_SSP(2) |
  887. SOF_SSP_BT_OFFLOAD_PRESENT),
  888. },
  889. {
  890. .name = "jsl_rt5682_mx98360",
  891. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  892. SOF_RT5682_MCLK_24MHZ |
  893. SOF_RT5682_SSP_CODEC(0) |
  894. SOF_SPEAKER_AMP_PRESENT |
  895. SOF_MAX98360A_SPEAKER_AMP_PRESENT |
  896. SOF_RT5682_SSP_AMP(1)),
  897. },
  898. {
  899. .name = "cml_rt1015_rt5682",
  900. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  901. SOF_RT5682_MCLK_24MHZ |
  902. SOF_RT5682_SSP_CODEC(0) |
  903. SOF_SPEAKER_AMP_PRESENT |
  904. SOF_RT1015_SPEAKER_AMP_PRESENT |
  905. SOF_RT5682_SSP_AMP(1)),
  906. },
  907. {
  908. .name = "tgl_rt1011_rt5682",
  909. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  910. SOF_RT5682_SSP_CODEC(0) |
  911. SOF_SPEAKER_AMP_PRESENT |
  912. SOF_RT1011_SPEAKER_AMP_PRESENT |
  913. SOF_RT5682_SSP_AMP(1) |
  914. SOF_RT5682_NUM_HDMIDEV(4) |
  915. SOF_BT_OFFLOAD_SSP(2) |
  916. SOF_SSP_BT_OFFLOAD_PRESENT),
  917. },
  918. {
  919. .name = "jsl_rt5682_rt1015p",
  920. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  921. SOF_RT5682_MCLK_24MHZ |
  922. SOF_RT5682_SSP_CODEC(0) |
  923. SOF_SPEAKER_AMP_PRESENT |
  924. SOF_RT1015P_SPEAKER_AMP_PRESENT |
  925. SOF_RT5682_SSP_AMP(1)),
  926. },
  927. {
  928. .name = "adl_mx98373_rt5682",
  929. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  930. SOF_RT5682_SSP_CODEC(0) |
  931. SOF_SPEAKER_AMP_PRESENT |
  932. SOF_MAX98373_SPEAKER_AMP_PRESENT |
  933. SOF_RT5682_SSP_AMP(1) |
  934. SOF_RT5682_NUM_HDMIDEV(4) |
  935. SOF_BT_OFFLOAD_SSP(2) |
  936. SOF_SSP_BT_OFFLOAD_PRESENT),
  937. },
  938. {
  939. .name = "adl_mx98357_rt5682",
  940. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  941. SOF_RT5682_SSP_CODEC(0) |
  942. SOF_SPEAKER_AMP_PRESENT |
  943. SOF_RT5682_SSP_AMP(2) |
  944. SOF_RT5682_NUM_HDMIDEV(4)),
  945. },
  946. {
  947. .name = "adl_max98390_rt5682",
  948. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  949. SOF_RT5682_SSP_CODEC(0) |
  950. SOF_SPEAKER_AMP_PRESENT |
  951. SOF_MAX98390_SPEAKER_AMP_PRESENT |
  952. SOF_RT5682_SSP_AMP(1) |
  953. SOF_RT5682_NUM_HDMIDEV(4) |
  954. SOF_BT_OFFLOAD_SSP(2) |
  955. SOF_SSP_BT_OFFLOAD_PRESENT),
  956. },
  957. {
  958. .name = "adl_mx98360_rt5682",
  959. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  960. SOF_RT5682_SSP_CODEC(0) |
  961. SOF_SPEAKER_AMP_PRESENT |
  962. SOF_MAX98360A_SPEAKER_AMP_PRESENT |
  963. SOF_RT5682_SSP_AMP(1) |
  964. SOF_RT5682_NUM_HDMIDEV(4) |
  965. SOF_BT_OFFLOAD_SSP(2) |
  966. SOF_SSP_BT_OFFLOAD_PRESENT),
  967. },
  968. {
  969. .name = "adl_rt5682",
  970. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  971. SOF_RT5682_SSP_CODEC(0) |
  972. SOF_RT5682_NUM_HDMIDEV(4) |
  973. SOF_BT_OFFLOAD_SSP(2) |
  974. SOF_SSP_BT_OFFLOAD_PRESENT),
  975. },
  976. {
  977. .name = "adl_rt1019_rt5682s",
  978. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  979. SOF_RT5682_SSP_CODEC(0) |
  980. SOF_RT5682S_HEADPHONE_CODEC_PRESENT |
  981. SOF_SPEAKER_AMP_PRESENT |
  982. SOF_RT1019_SPEAKER_AMP_PRESENT |
  983. SOF_RT5682_SSP_AMP(1) |
  984. SOF_RT5682_NUM_HDMIDEV(4)),
  985. },
  986. {
  987. .name = "mtl_mx98357_rt5682",
  988. .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
  989. SOF_RT5682_SSP_CODEC(0) |
  990. SOF_SPEAKER_AMP_PRESENT |
  991. SOF_RT5682_SSP_AMP(1) |
  992. SOF_RT5682_NUM_HDMIDEV(4)),
  993. },
  994. { }
  995. };
  996. MODULE_DEVICE_TABLE(platform, board_ids);
  997. static struct platform_driver sof_audio = {
  998. .probe = sof_audio_probe,
  999. .driver = {
  1000. .name = "sof_rt5682",
  1001. .pm = &snd_soc_pm_ops,
  1002. },
  1003. .id_table = board_ids,
  1004. };
  1005. module_platform_driver(sof_audio)
  1006. /* Module information */
  1007. MODULE_DESCRIPTION("SOF Audio Machine driver");
  1008. MODULE_AUTHOR("Bard Liao <[email protected]>");
  1009. MODULE_AUTHOR("Sathya Prakash M R <[email protected]>");
  1010. MODULE_AUTHOR("Brent Lu <[email protected]>");
  1011. MODULE_AUTHOR("Mac Chiang <[email protected]>");
  1012. MODULE_LICENSE("GPL v2");
  1013. MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
  1014. MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
  1015. MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);