skl_nau88l25_ssm4567.c 19 KB

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