skl_nau88l25_ssm4567.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. /*
  2. * Intel Skylake I2S Machine Driver for NAU88L25+SSM4567
  3. *
  4. * Copyright (C) 2015, Intel Corporation. All rights reserved.
  5. *
  6. * Modified from:
  7. * Intel Skylake I2S Machine Driver for NAU88L25 and SSM4567
  8. *
  9. * Copyright (C) 2015, Intel Corporation. All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License version
  13. * 2 as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. */
  20. #include <linux/module.h>
  21. #include <linux/platform_device.h>
  22. #include <sound/core.h>
  23. #include <sound/pcm.h>
  24. #include <sound/soc.h>
  25. #include <sound/jack.h>
  26. #include <sound/pcm_params.h>
  27. #include "../../codecs/nau8825.h"
  28. #include "../../codecs/hdac_hdmi.h"
  29. #include "../skylake/skl.h"
  30. #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
  31. #define SKL_SSM_CODEC_DAI "ssm4567-hifi"
  32. #define DMIC_CH(p) p->list[p->count-1]
  33. static struct snd_soc_jack skylake_headset;
  34. static struct snd_soc_card skylake_audio_card;
  35. static const struct snd_pcm_hw_constraint_list *dmic_constraints;
  36. struct skl_hdmi_pcm {
  37. struct list_head head;
  38. struct snd_soc_dai *codec_dai;
  39. int device;
  40. };
  41. struct skl_nau88125_private {
  42. struct list_head hdmi_pcm_list;
  43. };
  44. enum {
  45. SKL_DPCM_AUDIO_PB = 0,
  46. SKL_DPCM_AUDIO_CP,
  47. SKL_DPCM_AUDIO_REF_CP,
  48. SKL_DPCM_AUDIO_DMIC_CP,
  49. SKL_DPCM_AUDIO_HDMI1_PB,
  50. SKL_DPCM_AUDIO_HDMI2_PB,
  51. SKL_DPCM_AUDIO_HDMI3_PB,
  52. };
  53. static inline struct snd_soc_dai *skl_get_codec_dai(struct snd_soc_card *card)
  54. {
  55. struct snd_soc_pcm_runtime *rtd;
  56. list_for_each_entry(rtd, &card->rtd_list, list) {
  57. if (!strncmp(rtd->codec_dai->name, SKL_NUVOTON_CODEC_DAI,
  58. strlen(SKL_NUVOTON_CODEC_DAI)))
  59. return rtd->codec_dai;
  60. }
  61. return NULL;
  62. }
  63. static const struct snd_kcontrol_new skylake_controls[] = {
  64. SOC_DAPM_PIN_SWITCH("Headphone Jack"),
  65. SOC_DAPM_PIN_SWITCH("Headset Mic"),
  66. SOC_DAPM_PIN_SWITCH("Left Speaker"),
  67. SOC_DAPM_PIN_SWITCH("Right Speaker"),
  68. };
  69. static int platform_clock_control(struct snd_soc_dapm_widget *w,
  70. struct snd_kcontrol *k, int event)
  71. {
  72. struct snd_soc_dapm_context *dapm = w->dapm;
  73. struct snd_soc_card *card = dapm->card;
  74. struct snd_soc_dai *codec_dai;
  75. int ret;
  76. codec_dai = skl_get_codec_dai(card);
  77. if (!codec_dai) {
  78. dev_err(card->dev, "Codec dai not found\n");
  79. return -EIO;
  80. }
  81. if (SND_SOC_DAPM_EVENT_ON(event)) {
  82. ret = snd_soc_dai_set_sysclk(codec_dai,
  83. NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN);
  84. if (ret < 0) {
  85. dev_err(card->dev, "set sysclk err = %d\n", ret);
  86. return -EIO;
  87. }
  88. } else {
  89. ret = snd_soc_dai_set_sysclk(codec_dai,
  90. NAU8825_CLK_INTERNAL, 0, SND_SOC_CLOCK_IN);
  91. if (ret < 0) {
  92. dev_err(card->dev, "set sysclk err = %d\n", ret);
  93. return -EIO;
  94. }
  95. }
  96. return ret;
  97. }
  98. static const struct snd_soc_dapm_widget skylake_widgets[] = {
  99. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  100. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  101. SND_SOC_DAPM_SPK("Left Speaker", NULL),
  102. SND_SOC_DAPM_SPK("Right Speaker", NULL),
  103. SND_SOC_DAPM_MIC("SoC DMIC", NULL),
  104. SND_SOC_DAPM_SPK("DP", NULL),
  105. SND_SOC_DAPM_SPK("HDMI", NULL),
  106. SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
  107. platform_clock_control, SND_SOC_DAPM_PRE_PMU |
  108. SND_SOC_DAPM_POST_PMD),
  109. };
  110. static const struct snd_soc_dapm_route skylake_map[] = {
  111. /* HP jack connectors - unknown if we have jack detection */
  112. {"Headphone Jack", NULL, "HPOL"},
  113. {"Headphone Jack", NULL, "HPOR"},
  114. /* speaker */
  115. {"Left Speaker", NULL, "Left OUT"},
  116. {"Right Speaker", NULL, "Right OUT"},
  117. /* other jacks */
  118. {"MIC", NULL, "Headset Mic"},
  119. {"DMic", NULL, "SoC DMIC"},
  120. {"HDMI", NULL, "hif5 Output"},
  121. {"DP", NULL, "hif6 Output"},
  122. /* CODEC BE connections */
  123. { "Left Playback", NULL, "ssp0 Tx"},
  124. { "Right Playback", NULL, "ssp0 Tx"},
  125. { "ssp0 Tx", NULL, "codec0_out"},
  126. /* IV feedback path */
  127. { "codec0_lp_in", NULL, "ssp0 Rx"},
  128. { "ssp0 Rx", NULL, "Left Capture Sense" },
  129. { "ssp0 Rx", NULL, "Right Capture Sense" },
  130. { "Playback", NULL, "ssp1 Tx"},
  131. { "ssp1 Tx", NULL, "codec1_out"},
  132. { "codec0_in", NULL, "ssp1 Rx" },
  133. { "ssp1 Rx", NULL, "Capture" },
  134. /* DMIC */
  135. { "dmic01_hifi", NULL, "DMIC01 Rx" },
  136. { "DMIC01 Rx", NULL, "DMIC AIF" },
  137. { "hifi3", NULL, "iDisp3 Tx"},
  138. { "iDisp3 Tx", NULL, "iDisp3_out"},
  139. { "hifi2", NULL, "iDisp2 Tx"},
  140. { "iDisp2 Tx", NULL, "iDisp2_out"},
  141. { "hifi1", NULL, "iDisp1 Tx"},
  142. { "iDisp1 Tx", NULL, "iDisp1_out"},
  143. { "Headphone Jack", NULL, "Platform Clock" },
  144. { "Headset Mic", NULL, "Platform Clock" },
  145. };
  146. static struct snd_soc_codec_conf ssm4567_codec_conf[] = {
  147. {
  148. .dev_name = "i2c-INT343B:00",
  149. .name_prefix = "Left",
  150. },
  151. {
  152. .dev_name = "i2c-INT343B:01",
  153. .name_prefix = "Right",
  154. },
  155. };
  156. static struct snd_soc_dai_link_component ssm4567_codec_components[] = {
  157. { /* Left */
  158. .name = "i2c-INT343B:00",
  159. .dai_name = SKL_SSM_CODEC_DAI,
  160. },
  161. { /* Right */
  162. .name = "i2c-INT343B:01",
  163. .dai_name = SKL_SSM_CODEC_DAI,
  164. },
  165. };
  166. static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd)
  167. {
  168. int ret;
  169. /* Slot 1 for left */
  170. ret = snd_soc_dai_set_tdm_slot(rtd->codec_dais[0], 0x01, 0x01, 2, 48);
  171. if (ret < 0)
  172. return ret;
  173. /* Slot 2 for right */
  174. ret = snd_soc_dai_set_tdm_slot(rtd->codec_dais[1], 0x02, 0x02, 2, 48);
  175. if (ret < 0)
  176. return ret;
  177. return ret;
  178. }
  179. static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
  180. {
  181. int ret;
  182. struct snd_soc_codec *codec = rtd->codec;
  183. /*
  184. * 4 buttons here map to the google Reference headset
  185. * The use of these buttons can be decided by the user space.
  186. */
  187. ret = snd_soc_card_jack_new(&skylake_audio_card, "Headset Jack",
  188. SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
  189. SND_JACK_BTN_2 | SND_JACK_BTN_3, &skylake_headset,
  190. NULL, 0);
  191. if (ret) {
  192. dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret);
  193. return ret;
  194. }
  195. nau8825_enable_jack_detect(codec, &skylake_headset);
  196. snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
  197. return ret;
  198. }
  199. static int skylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)
  200. {
  201. struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  202. struct snd_soc_dai *dai = rtd->codec_dai;
  203. struct skl_hdmi_pcm *pcm;
  204. pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
  205. if (!pcm)
  206. return -ENOMEM;
  207. pcm->device = SKL_DPCM_AUDIO_HDMI1_PB;
  208. pcm->codec_dai = dai;
  209. list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
  210. return 0;
  211. }
  212. static int skylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd)
  213. {
  214. struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  215. struct snd_soc_dai *dai = rtd->codec_dai;
  216. struct skl_hdmi_pcm *pcm;
  217. pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
  218. if (!pcm)
  219. return -ENOMEM;
  220. pcm->device = SKL_DPCM_AUDIO_HDMI2_PB;
  221. pcm->codec_dai = dai;
  222. list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
  223. return 0;
  224. }
  225. static int skylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd)
  226. {
  227. struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(rtd->card);
  228. struct snd_soc_dai *dai = rtd->codec_dai;
  229. struct skl_hdmi_pcm *pcm;
  230. pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
  231. if (!pcm)
  232. return -ENOMEM;
  233. pcm->device = SKL_DPCM_AUDIO_HDMI3_PB;
  234. pcm->codec_dai = dai;
  235. list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
  236. return 0;
  237. }
  238. static int skylake_nau8825_fe_init(struct snd_soc_pcm_runtime *rtd)
  239. {
  240. struct snd_soc_dapm_context *dapm;
  241. struct snd_soc_component *component = rtd->cpu_dai->component;
  242. dapm = snd_soc_component_get_dapm(component);
  243. snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
  244. return 0;
  245. }
  246. static unsigned int rates[] = {
  247. 48000,
  248. };
  249. static struct snd_pcm_hw_constraint_list constraints_rates = {
  250. .count = ARRAY_SIZE(rates),
  251. .list = rates,
  252. .mask = 0,
  253. };
  254. static unsigned int channels[] = {
  255. 2,
  256. };
  257. static struct snd_pcm_hw_constraint_list constraints_channels = {
  258. .count = ARRAY_SIZE(channels),
  259. .list = channels,
  260. .mask = 0,
  261. };
  262. static int skl_fe_startup(struct snd_pcm_substream *substream)
  263. {
  264. struct snd_pcm_runtime *runtime = substream->runtime;
  265. /*
  266. * on this platform for PCM device we support,
  267. * 48Khz
  268. * stereo
  269. * 16 bit audio
  270. */
  271. runtime->hw.channels_max = 2;
  272. snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
  273. &constraints_channels);
  274. runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
  275. snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16);
  276. snd_pcm_hw_constraint_list(runtime, 0,
  277. SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
  278. return 0;
  279. }
  280. static const struct snd_soc_ops skylake_nau8825_fe_ops = {
  281. .startup = skl_fe_startup,
  282. };
  283. static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
  284. struct snd_pcm_hw_params *params)
  285. {
  286. struct snd_interval *rate = hw_param_interval(params,
  287. SNDRV_PCM_HW_PARAM_RATE);
  288. struct snd_interval *channels = hw_param_interval(params,
  289. SNDRV_PCM_HW_PARAM_CHANNELS);
  290. struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
  291. /* The ADSP will covert the FE rate to 48k, stereo */
  292. rate->min = rate->max = 48000;
  293. channels->min = channels->max = 2;
  294. /* set SSP0 to 24 bit */
  295. snd_mask_none(fmt);
  296. snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
  297. return 0;
  298. }
  299. static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
  300. struct snd_pcm_hw_params *params)
  301. {
  302. struct snd_interval *channels = hw_param_interval(params,
  303. SNDRV_PCM_HW_PARAM_CHANNELS);
  304. if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2)
  305. channels->min = channels->max = 2;
  306. else
  307. channels->min = channels->max = 4;
  308. return 0;
  309. }
  310. static int skylake_nau8825_hw_params(struct snd_pcm_substream *substream,
  311. struct snd_pcm_hw_params *params)
  312. {
  313. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  314. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  315. int ret;
  316. ret = snd_soc_dai_set_sysclk(codec_dai,
  317. NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN);
  318. if (ret < 0)
  319. dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
  320. return ret;
  321. }
  322. static struct snd_soc_ops skylake_nau8825_ops = {
  323. .hw_params = skylake_nau8825_hw_params,
  324. };
  325. static unsigned int channels_dmic[] = {
  326. 2, 4,
  327. };
  328. static struct snd_pcm_hw_constraint_list constraints_dmic_channels = {
  329. .count = ARRAY_SIZE(channels_dmic),
  330. .list = channels_dmic,
  331. .mask = 0,
  332. };
  333. static const unsigned int dmic_2ch[] = {
  334. 2,
  335. };
  336. static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
  337. .count = ARRAY_SIZE(dmic_2ch),
  338. .list = dmic_2ch,
  339. .mask = 0,
  340. };
  341. static int skylake_dmic_startup(struct snd_pcm_substream *substream)
  342. {
  343. struct snd_pcm_runtime *runtime = substream->runtime;
  344. runtime->hw.channels_max = DMIC_CH(dmic_constraints);
  345. snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
  346. dmic_constraints);
  347. return snd_pcm_hw_constraint_list(substream->runtime, 0,
  348. SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
  349. }
  350. static struct snd_soc_ops skylake_dmic_ops = {
  351. .startup = skylake_dmic_startup,
  352. };
  353. static unsigned int rates_16000[] = {
  354. 16000,
  355. };
  356. static struct snd_pcm_hw_constraint_list constraints_16000 = {
  357. .count = ARRAY_SIZE(rates_16000),
  358. .list = rates_16000,
  359. };
  360. static const unsigned int ch_mono[] = {
  361. 1,
  362. };
  363. static const struct snd_pcm_hw_constraint_list constraints_refcap = {
  364. .count = ARRAY_SIZE(ch_mono),
  365. .list = ch_mono,
  366. };
  367. static int skylake_refcap_startup(struct snd_pcm_substream *substream)
  368. {
  369. substream->runtime->hw.channels_max = 1;
  370. snd_pcm_hw_constraint_list(substream->runtime, 0,
  371. SNDRV_PCM_HW_PARAM_CHANNELS,
  372. &constraints_refcap);
  373. return snd_pcm_hw_constraint_list(substream->runtime, 0,
  374. SNDRV_PCM_HW_PARAM_RATE,
  375. &constraints_16000);
  376. }
  377. static struct snd_soc_ops skylaye_refcap_ops = {
  378. .startup = skylake_refcap_startup,
  379. };
  380. /* skylake digital audio interface glue - connects codec <--> CPU */
  381. static struct snd_soc_dai_link skylake_dais[] = {
  382. /* Front End DAI links */
  383. [SKL_DPCM_AUDIO_PB] = {
  384. .name = "Skl Audio Port",
  385. .stream_name = "Audio",
  386. .cpu_dai_name = "System Pin",
  387. .platform_name = "0000:00:1f.3",
  388. .dynamic = 1,
  389. .codec_name = "snd-soc-dummy",
  390. .codec_dai_name = "snd-soc-dummy-dai",
  391. .nonatomic = 1,
  392. .init = skylake_nau8825_fe_init,
  393. .trigger = {
  394. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  395. .dpcm_playback = 1,
  396. .ops = &skylake_nau8825_fe_ops,
  397. },
  398. [SKL_DPCM_AUDIO_CP] = {
  399. .name = "Skl Audio Capture Port",
  400. .stream_name = "Audio Record",
  401. .cpu_dai_name = "System Pin",
  402. .platform_name = "0000:00:1f.3",
  403. .dynamic = 1,
  404. .codec_name = "snd-soc-dummy",
  405. .codec_dai_name = "snd-soc-dummy-dai",
  406. .nonatomic = 1,
  407. .trigger = {
  408. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  409. .dpcm_capture = 1,
  410. .ops = &skylake_nau8825_fe_ops,
  411. },
  412. [SKL_DPCM_AUDIO_REF_CP] = {
  413. .name = "Skl Audio Reference cap",
  414. .stream_name = "Wake on Voice",
  415. .cpu_dai_name = "Reference Pin",
  416. .codec_name = "snd-soc-dummy",
  417. .codec_dai_name = "snd-soc-dummy-dai",
  418. .platform_name = "0000:00:1f.3",
  419. .init = NULL,
  420. .dpcm_capture = 1,
  421. .nonatomic = 1,
  422. .dynamic = 1,
  423. .ops = &skylaye_refcap_ops,
  424. },
  425. [SKL_DPCM_AUDIO_DMIC_CP] = {
  426. .name = "Skl Audio DMIC cap",
  427. .stream_name = "dmiccap",
  428. .cpu_dai_name = "DMIC Pin",
  429. .codec_name = "snd-soc-dummy",
  430. .codec_dai_name = "snd-soc-dummy-dai",
  431. .platform_name = "0000:00:1f.3",
  432. .init = NULL,
  433. .dpcm_capture = 1,
  434. .nonatomic = 1,
  435. .dynamic = 1,
  436. .ops = &skylake_dmic_ops,
  437. },
  438. [SKL_DPCM_AUDIO_HDMI1_PB] = {
  439. .name = "Skl HDMI Port1",
  440. .stream_name = "Hdmi1",
  441. .cpu_dai_name = "HDMI1 Pin",
  442. .codec_name = "snd-soc-dummy",
  443. .codec_dai_name = "snd-soc-dummy-dai",
  444. .platform_name = "0000:00:1f.3",
  445. .dpcm_playback = 1,
  446. .init = NULL,
  447. .trigger = {
  448. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  449. .nonatomic = 1,
  450. .dynamic = 1,
  451. },
  452. [SKL_DPCM_AUDIO_HDMI2_PB] = {
  453. .name = "Skl HDMI Port2",
  454. .stream_name = "Hdmi2",
  455. .cpu_dai_name = "HDMI2 Pin",
  456. .codec_name = "snd-soc-dummy",
  457. .codec_dai_name = "snd-soc-dummy-dai",
  458. .platform_name = "0000:00:1f.3",
  459. .dpcm_playback = 1,
  460. .init = NULL,
  461. .trigger = {
  462. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  463. .nonatomic = 1,
  464. .dynamic = 1,
  465. },
  466. [SKL_DPCM_AUDIO_HDMI3_PB] = {
  467. .name = "Skl HDMI Port3",
  468. .stream_name = "Hdmi3",
  469. .cpu_dai_name = "HDMI3 Pin",
  470. .codec_name = "snd-soc-dummy",
  471. .codec_dai_name = "snd-soc-dummy-dai",
  472. .platform_name = "0000:00:1f.3",
  473. .trigger = {
  474. SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  475. .dpcm_playback = 1,
  476. .init = NULL,
  477. .nonatomic = 1,
  478. .dynamic = 1,
  479. },
  480. /* Back End DAI links */
  481. {
  482. /* SSP0 - Codec */
  483. .name = "SSP0-Codec",
  484. .id = 0,
  485. .cpu_dai_name = "SSP0 Pin",
  486. .platform_name = "0000:00:1f.3",
  487. .no_pcm = 1,
  488. .codecs = ssm4567_codec_components,
  489. .num_codecs = ARRAY_SIZE(ssm4567_codec_components),
  490. .dai_fmt = SND_SOC_DAIFMT_DSP_A |
  491. SND_SOC_DAIFMT_IB_NF |
  492. SND_SOC_DAIFMT_CBS_CFS,
  493. .init = skylake_ssm4567_codec_init,
  494. .ignore_pmdown_time = 1,
  495. .be_hw_params_fixup = skylake_ssp_fixup,
  496. .dpcm_playback = 1,
  497. .dpcm_capture = 1,
  498. },
  499. {
  500. /* SSP1 - Codec */
  501. .name = "SSP1-Codec",
  502. .id = 1,
  503. .cpu_dai_name = "SSP1 Pin",
  504. .platform_name = "0000:00:1f.3",
  505. .no_pcm = 1,
  506. .codec_name = "i2c-10508825:00",
  507. .codec_dai_name = SKL_NUVOTON_CODEC_DAI,
  508. .init = skylake_nau8825_codec_init,
  509. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  510. SND_SOC_DAIFMT_CBS_CFS,
  511. .ignore_pmdown_time = 1,
  512. .be_hw_params_fixup = skylake_ssp_fixup,
  513. .ops = &skylake_nau8825_ops,
  514. .dpcm_playback = 1,
  515. .dpcm_capture = 1,
  516. },
  517. {
  518. .name = "dmic01",
  519. .id = 2,
  520. .cpu_dai_name = "DMIC01 Pin",
  521. .codec_name = "dmic-codec",
  522. .codec_dai_name = "dmic-hifi",
  523. .platform_name = "0000:00:1f.3",
  524. .ignore_suspend = 1,
  525. .be_hw_params_fixup = skylake_dmic_fixup,
  526. .dpcm_capture = 1,
  527. .no_pcm = 1,
  528. },
  529. {
  530. .name = "iDisp1",
  531. .id = 3,
  532. .cpu_dai_name = "iDisp1 Pin",
  533. .codec_name = "ehdaudio0D2",
  534. .codec_dai_name = "intel-hdmi-hifi1",
  535. .platform_name = "0000:00:1f.3",
  536. .dpcm_playback = 1,
  537. .init = skylake_hdmi1_init,
  538. .no_pcm = 1,
  539. },
  540. {
  541. .name = "iDisp2",
  542. .id = 4,
  543. .cpu_dai_name = "iDisp2 Pin",
  544. .codec_name = "ehdaudio0D2",
  545. .codec_dai_name = "intel-hdmi-hifi2",
  546. .platform_name = "0000:00:1f.3",
  547. .init = skylake_hdmi2_init,
  548. .dpcm_playback = 1,
  549. .no_pcm = 1,
  550. },
  551. {
  552. .name = "iDisp3",
  553. .id = 5,
  554. .cpu_dai_name = "iDisp3 Pin",
  555. .codec_name = "ehdaudio0D2",
  556. .codec_dai_name = "intel-hdmi-hifi3",
  557. .platform_name = "0000:00:1f.3",
  558. .init = skylake_hdmi3_init,
  559. .dpcm_playback = 1,
  560. .no_pcm = 1,
  561. },
  562. };
  563. static int skylake_card_late_probe(struct snd_soc_card *card)
  564. {
  565. struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card);
  566. struct skl_hdmi_pcm *pcm;
  567. int err;
  568. list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
  569. err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device);
  570. if (err < 0)
  571. return err;
  572. }
  573. return 0;
  574. }
  575. /* skylake audio machine driver for SPT + NAU88L25 */
  576. static struct snd_soc_card skylake_audio_card = {
  577. .name = "sklnau8825adi",
  578. .owner = THIS_MODULE,
  579. .dai_link = skylake_dais,
  580. .num_links = ARRAY_SIZE(skylake_dais),
  581. .controls = skylake_controls,
  582. .num_controls = ARRAY_SIZE(skylake_controls),
  583. .dapm_widgets = skylake_widgets,
  584. .num_dapm_widgets = ARRAY_SIZE(skylake_widgets),
  585. .dapm_routes = skylake_map,
  586. .num_dapm_routes = ARRAY_SIZE(skylake_map),
  587. .codec_conf = ssm4567_codec_conf,
  588. .num_configs = ARRAY_SIZE(ssm4567_codec_conf),
  589. .fully_routed = true,
  590. .late_probe = skylake_card_late_probe,
  591. };
  592. static int skylake_audio_probe(struct platform_device *pdev)
  593. {
  594. struct skl_nau88125_private *ctx;
  595. struct skl_machine_pdata *pdata;
  596. ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC);
  597. if (!ctx)
  598. return -ENOMEM;
  599. INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
  600. skylake_audio_card.dev = &pdev->dev;
  601. snd_soc_card_set_drvdata(&skylake_audio_card, ctx);
  602. pdata = dev_get_drvdata(&pdev->dev);
  603. if (pdata)
  604. dmic_constraints = pdata->dmic_num == 2 ?
  605. &constraints_dmic_2ch : &constraints_dmic_channels;
  606. return devm_snd_soc_register_card(&pdev->dev, &skylake_audio_card);
  607. }
  608. static const struct platform_device_id skl_board_ids[] = {
  609. { .name = "skl_n88l25_s4567" },
  610. { .name = "kbl_n88l25_s4567" },
  611. { }
  612. };
  613. static struct platform_driver skylake_audio = {
  614. .probe = skylake_audio_probe,
  615. .driver = {
  616. .name = "skl_n88l25_s4567",
  617. .pm = &snd_soc_pm_ops,
  618. },
  619. .id_table = skl_board_ids,
  620. };
  621. module_platform_driver(skylake_audio)
  622. /* Module information */
  623. MODULE_AUTHOR("Conrad Cooke <conrad.cooke@intel.com>");
  624. MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
  625. MODULE_AUTHOR("Naveen M <naveen.m@intel.com>");
  626. MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>");
  627. MODULE_AUTHOR("Yong Zhi <yong.zhi@intel.com>");
  628. MODULE_DESCRIPTION("Intel Audio Machine driver for SKL with NAU88L25 and SSM4567 in I2S Mode");
  629. MODULE_LICENSE("GPL v2");
  630. MODULE_ALIAS("platform:skl_n88l25_s4567");
  631. MODULE_ALIAS("platform:kbl_n88l25_s4567");