intel-dsp-config.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (c) 2019 Jaroslav Kysela <perex@perex.cz>
  3. #include <linux/acpi.h>
  4. #include <linux/bits.h>
  5. #include <linux/dmi.h>
  6. #include <linux/module.h>
  7. #include <linux/pci.h>
  8. #include <linux/soundwire/sdw.h>
  9. #include <linux/soundwire/sdw_intel.h>
  10. #include <sound/core.h>
  11. #include <sound/intel-dsp-config.h>
  12. #include <sound/intel-nhlt.h>
  13. #include <sound/soc-acpi.h>
  14. #include <acpi/nhlt.h>
  15. static int dsp_driver;
  16. module_param(dsp_driver, int, 0444);
  17. MODULE_PARM_DESC(dsp_driver, "Force the DSP driver for Intel DSP (0=auto, 1=legacy, 2=SST, 3=SOF, 4=AVS)");
  18. #define FLAG_SST BIT(0)
  19. #define FLAG_SOF BIT(1)
  20. #define FLAG_SST_ONLY_IF_DMIC BIT(15)
  21. #define FLAG_SOF_ONLY_IF_DMIC BIT(16)
  22. #define FLAG_SOF_ONLY_IF_SOUNDWIRE BIT(17)
  23. #define FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE (FLAG_SOF_ONLY_IF_DMIC | \
  24. FLAG_SOF_ONLY_IF_SOUNDWIRE)
  25. struct config_entry {
  26. u32 flags;
  27. u16 device;
  28. u8 acpi_hid[ACPI_ID_LEN];
  29. const struct dmi_system_id *dmi_table;
  30. const struct snd_soc_acpi_codecs *codec_hid;
  31. };
  32. static const struct snd_soc_acpi_codecs __maybe_unused essx_83x6 = {
  33. .num_codecs = 3,
  34. .codecs = { "ESSX8316", "ESSX8326", "ESSX8336"},
  35. };
  36. /*
  37. * configuration table
  38. * - the order of similar PCI ID entries is important!
  39. * - the first successful match will win
  40. */
  41. static const struct config_entry config_table[] = {
  42. /* Merrifield */
  43. #if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD)
  44. {
  45. .flags = FLAG_SOF,
  46. .device = PCI_DEVICE_ID_INTEL_SST_TNG,
  47. },
  48. #endif
  49. /*
  50. * Skylake, Kabylake, Apollolake
  51. * the legacy HDAudio driver is used except on Up Squared (SOF) and
  52. * Chromebooks (SST), as well as devices based on the ES8336 codec
  53. */
  54. #if IS_ENABLED(CONFIG_SND_SOC_INTEL_AVS)
  55. {
  56. .flags = FLAG_SST,
  57. .device = PCI_DEVICE_ID_INTEL_HDA_SKL_LP,
  58. .dmi_table = (const struct dmi_system_id []) {
  59. {
  60. .ident = "Google Chromebooks",
  61. .matches = {
  62. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  63. }
  64. },
  65. {}
  66. }
  67. },
  68. {
  69. .flags = FLAG_SST | FLAG_SST_ONLY_IF_DMIC,
  70. .device = PCI_DEVICE_ID_INTEL_HDA_SKL_LP,
  71. },
  72. {
  73. .flags = FLAG_SST,
  74. .device = PCI_DEVICE_ID_INTEL_HDA_KBL_LP,
  75. .dmi_table = (const struct dmi_system_id []) {
  76. {
  77. .ident = "Google Chromebooks",
  78. .matches = {
  79. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  80. }
  81. },
  82. {}
  83. }
  84. },
  85. {
  86. .flags = FLAG_SST | FLAG_SST_ONLY_IF_DMIC,
  87. .device = PCI_DEVICE_ID_INTEL_HDA_KBL_LP,
  88. },
  89. {
  90. .flags = FLAG_SST,
  91. .device = PCI_DEVICE_ID_INTEL_HDA_APL,
  92. .dmi_table = (const struct dmi_system_id []) {
  93. {
  94. .ident = "Google Chromebooks",
  95. .matches = {
  96. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  97. }
  98. },
  99. {}
  100. }
  101. },
  102. #endif
  103. #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
  104. {
  105. .flags = FLAG_SOF,
  106. .device = PCI_DEVICE_ID_INTEL_HDA_APL,
  107. .dmi_table = (const struct dmi_system_id []) {
  108. {
  109. .ident = "Up Squared",
  110. .matches = {
  111. DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
  112. DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"),
  113. }
  114. },
  115. {}
  116. }
  117. },
  118. {
  119. .flags = FLAG_SOF,
  120. .device = PCI_DEVICE_ID_INTEL_HDA_APL,
  121. .codec_hid = &essx_83x6,
  122. },
  123. #endif
  124. /*
  125. * Geminilake uses legacy HDAudio driver except for Google
  126. * Chromebooks and devices based on the ES8336 codec
  127. */
  128. /* Geminilake */
  129. #if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE)
  130. {
  131. .flags = FLAG_SOF,
  132. .device = PCI_DEVICE_ID_INTEL_HDA_GML,
  133. .dmi_table = (const struct dmi_system_id []) {
  134. {
  135. .ident = "Google Chromebooks",
  136. .matches = {
  137. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  138. }
  139. },
  140. {}
  141. }
  142. },
  143. {
  144. .flags = FLAG_SOF,
  145. .device = PCI_DEVICE_ID_INTEL_HDA_GML,
  146. .codec_hid = &essx_83x6,
  147. },
  148. #endif
  149. /*
  150. * CoffeeLake, CannonLake, CometLake, IceLake, TigerLake, AlderLake,
  151. * RaptorLake use legacy HDAudio driver except for Google Chromebooks
  152. * and when DMICs are present. Two cases are required since Coreboot
  153. * does not expose NHLT tables.
  154. *
  155. * When the Chromebook quirk is not present, it's based on information
  156. * that no such device exists. When the quirk is present, it could be
  157. * either based on product information or a placeholder.
  158. */
  159. /* Cannonlake */
  160. #if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE)
  161. {
  162. .flags = FLAG_SOF,
  163. .device = PCI_DEVICE_ID_INTEL_HDA_CNL_LP,
  164. .dmi_table = (const struct dmi_system_id []) {
  165. {
  166. .ident = "Google Chromebooks",
  167. .matches = {
  168. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  169. }
  170. },
  171. {
  172. .ident = "UP-WHL",
  173. .matches = {
  174. DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
  175. }
  176. },
  177. {}
  178. }
  179. },
  180. {
  181. .flags = FLAG_SOF,
  182. .device = PCI_DEVICE_ID_INTEL_HDA_CNL_LP,
  183. .codec_hid = &essx_83x6,
  184. },
  185. {
  186. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  187. .device = PCI_DEVICE_ID_INTEL_HDA_CNL_LP,
  188. },
  189. #endif
  190. /* Coffelake */
  191. #if IS_ENABLED(CONFIG_SND_SOC_SOF_COFFEELAKE)
  192. {
  193. .flags = FLAG_SOF,
  194. .device = PCI_DEVICE_ID_INTEL_HDA_CNL_H,
  195. .dmi_table = (const struct dmi_system_id []) {
  196. {
  197. .ident = "Google Chromebooks",
  198. .matches = {
  199. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  200. }
  201. },
  202. {}
  203. }
  204. },
  205. {
  206. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  207. .device = PCI_DEVICE_ID_INTEL_HDA_CNL_H,
  208. },
  209. #endif
  210. #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE)
  211. /* Cometlake-LP */
  212. {
  213. .flags = FLAG_SOF,
  214. .device = PCI_DEVICE_ID_INTEL_HDA_CML_LP,
  215. .dmi_table = (const struct dmi_system_id []) {
  216. {
  217. .ident = "Google Chromebooks",
  218. .matches = {
  219. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  220. }
  221. },
  222. {
  223. .matches = {
  224. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
  225. DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "09C6")
  226. },
  227. },
  228. {
  229. /* early version of SKU 09C6 */
  230. .matches = {
  231. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
  232. DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0983")
  233. },
  234. },
  235. {}
  236. }
  237. },
  238. {
  239. .flags = FLAG_SOF,
  240. .device = PCI_DEVICE_ID_INTEL_HDA_CML_LP,
  241. .codec_hid = &essx_83x6,
  242. },
  243. {
  244. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  245. .device = PCI_DEVICE_ID_INTEL_HDA_CML_LP,
  246. },
  247. /* Cometlake-H */
  248. {
  249. .flags = FLAG_SOF,
  250. .device = PCI_DEVICE_ID_INTEL_HDA_CML_H,
  251. .dmi_table = (const struct dmi_system_id []) {
  252. {
  253. .matches = {
  254. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
  255. DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "098F"),
  256. },
  257. },
  258. {
  259. .matches = {
  260. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
  261. DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0990"),
  262. },
  263. },
  264. {}
  265. }
  266. },
  267. {
  268. .flags = FLAG_SOF,
  269. .device = PCI_DEVICE_ID_INTEL_HDA_CML_H,
  270. .codec_hid = &essx_83x6,
  271. },
  272. {
  273. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  274. .device = PCI_DEVICE_ID_INTEL_HDA_CML_H,
  275. },
  276. #endif
  277. /* Icelake */
  278. #if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE)
  279. {
  280. .flags = FLAG_SOF,
  281. .device = PCI_DEVICE_ID_INTEL_HDA_ICL_LP,
  282. .dmi_table = (const struct dmi_system_id []) {
  283. {
  284. .ident = "Google Chromebooks",
  285. .matches = {
  286. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  287. }
  288. },
  289. {}
  290. }
  291. },
  292. {
  293. .flags = FLAG_SOF,
  294. .device = PCI_DEVICE_ID_INTEL_HDA_ICL_LP,
  295. .codec_hid = &essx_83x6,
  296. },
  297. {
  298. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  299. .device = PCI_DEVICE_ID_INTEL_HDA_ICL_LP,
  300. },
  301. #endif
  302. /* Jasper Lake */
  303. #if IS_ENABLED(CONFIG_SND_SOC_SOF_JASPERLAKE)
  304. {
  305. .flags = FLAG_SOF,
  306. .device = PCI_DEVICE_ID_INTEL_HDA_JSL_N,
  307. .dmi_table = (const struct dmi_system_id []) {
  308. {
  309. .ident = "Google Chromebooks",
  310. .matches = {
  311. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  312. }
  313. },
  314. {
  315. .ident = "Google firmware",
  316. .matches = {
  317. DMI_MATCH(DMI_BIOS_VERSION, "Google"),
  318. }
  319. },
  320. {}
  321. }
  322. },
  323. {
  324. .flags = FLAG_SOF,
  325. .device = PCI_DEVICE_ID_INTEL_HDA_JSL_N,
  326. .codec_hid = &essx_83x6,
  327. },
  328. {
  329. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
  330. .device = PCI_DEVICE_ID_INTEL_HDA_JSL_N,
  331. },
  332. #endif
  333. /* Tigerlake */
  334. #if IS_ENABLED(CONFIG_SND_SOC_SOF_TIGERLAKE)
  335. {
  336. .flags = FLAG_SOF,
  337. .device = PCI_DEVICE_ID_INTEL_HDA_TGL_LP,
  338. .dmi_table = (const struct dmi_system_id []) {
  339. {
  340. .ident = "Google Chromebooks",
  341. .matches = {
  342. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  343. }
  344. },
  345. {
  346. .ident = "UPX-TGL",
  347. .matches = {
  348. DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
  349. }
  350. },
  351. {}
  352. }
  353. },
  354. {
  355. .flags = FLAG_SOF,
  356. .device = PCI_DEVICE_ID_INTEL_HDA_TGL_LP,
  357. .codec_hid = &essx_83x6,
  358. },
  359. {
  360. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  361. .device = PCI_DEVICE_ID_INTEL_HDA_TGL_LP,
  362. },
  363. {
  364. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  365. .device = PCI_DEVICE_ID_INTEL_HDA_TGL_H,
  366. },
  367. #endif
  368. /* Elkhart Lake */
  369. #if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE)
  370. {
  371. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
  372. .device = PCI_DEVICE_ID_INTEL_HDA_EHL_0,
  373. },
  374. {
  375. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
  376. .device = PCI_DEVICE_ID_INTEL_HDA_EHL_3,
  377. },
  378. #endif
  379. /* Alder Lake / Raptor Lake */
  380. #if IS_ENABLED(CONFIG_SND_SOC_SOF_ALDERLAKE)
  381. {
  382. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  383. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_S,
  384. },
  385. {
  386. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  387. .device = PCI_DEVICE_ID_INTEL_HDA_RPL_S,
  388. },
  389. {
  390. .flags = FLAG_SOF,
  391. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_P,
  392. .dmi_table = (const struct dmi_system_id []) {
  393. {
  394. .ident = "Google Chromebooks",
  395. .matches = {
  396. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  397. }
  398. },
  399. {}
  400. }
  401. },
  402. {
  403. .flags = FLAG_SOF,
  404. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_P,
  405. .codec_hid = &essx_83x6,
  406. },
  407. {
  408. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  409. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_P,
  410. },
  411. {
  412. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  413. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_PX,
  414. },
  415. {
  416. .flags = FLAG_SOF,
  417. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_PS,
  418. .codec_hid = &essx_83x6,
  419. },
  420. {
  421. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  422. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_PS,
  423. },
  424. {
  425. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  426. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_M,
  427. },
  428. {
  429. .flags = FLAG_SOF,
  430. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_N,
  431. .dmi_table = (const struct dmi_system_id []) {
  432. {
  433. .ident = "Google Chromebooks",
  434. .matches = {
  435. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  436. }
  437. },
  438. {}
  439. }
  440. },
  441. {
  442. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  443. .device = PCI_DEVICE_ID_INTEL_HDA_ADL_N,
  444. },
  445. {
  446. .flags = FLAG_SOF,
  447. .device = PCI_DEVICE_ID_INTEL_HDA_RPL_P_0,
  448. .dmi_table = (const struct dmi_system_id []) {
  449. {
  450. .ident = "Google Chromebooks",
  451. .matches = {
  452. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  453. }
  454. },
  455. {}
  456. }
  457. },
  458. {
  459. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  460. .device = PCI_DEVICE_ID_INTEL_HDA_RPL_P_0,
  461. },
  462. {
  463. .flags = FLAG_SOF,
  464. .device = PCI_DEVICE_ID_INTEL_HDA_RPL_P_1,
  465. .dmi_table = (const struct dmi_system_id []) {
  466. {
  467. .ident = "Google Chromebooks",
  468. .matches = {
  469. DMI_MATCH(DMI_SYS_VENDOR, "Google"),
  470. }
  471. },
  472. {}
  473. }
  474. },
  475. {
  476. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  477. .device = PCI_DEVICE_ID_INTEL_HDA_RPL_P_1,
  478. },
  479. {
  480. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  481. .device = PCI_DEVICE_ID_INTEL_HDA_RPL_M,
  482. },
  483. {
  484. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  485. .device = PCI_DEVICE_ID_INTEL_HDA_RPL_PX,
  486. },
  487. #endif
  488. /* Meteor Lake */
  489. #if IS_ENABLED(CONFIG_SND_SOC_SOF_METEORLAKE)
  490. /* Meteorlake-P */
  491. {
  492. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  493. .device = PCI_DEVICE_ID_INTEL_HDA_MTL,
  494. },
  495. /* ArrowLake-S */
  496. {
  497. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  498. .device = PCI_DEVICE_ID_INTEL_HDA_ARL_S,
  499. },
  500. /* ArrowLake */
  501. {
  502. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  503. .device = PCI_DEVICE_ID_INTEL_HDA_ARL,
  504. },
  505. #endif
  506. /* Lunar Lake */
  507. #if IS_ENABLED(CONFIG_SND_SOC_SOF_LUNARLAKE)
  508. /* Lunarlake-P */
  509. {
  510. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  511. .device = PCI_DEVICE_ID_INTEL_HDA_LNL_P,
  512. },
  513. #endif
  514. /* Panther Lake */
  515. #if IS_ENABLED(CONFIG_SND_SOC_SOF_PANTHERLAKE)
  516. {
  517. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  518. .device = PCI_DEVICE_ID_INTEL_HDA_PTL,
  519. },
  520. #endif
  521. };
  522. static const struct config_entry *snd_intel_dsp_find_config
  523. (struct pci_dev *pci, const struct config_entry *table, u32 len)
  524. {
  525. u16 device;
  526. device = pci->device;
  527. for (; len > 0; len--, table++) {
  528. if (table->device != device)
  529. continue;
  530. if (table->dmi_table && !dmi_check_system(table->dmi_table))
  531. continue;
  532. if (table->codec_hid) {
  533. int i;
  534. for (i = 0; i < table->codec_hid->num_codecs; i++) {
  535. struct nhlt_acpi_table *nhlt;
  536. bool ssp_found = false;
  537. if (!acpi_dev_present(table->codec_hid->codecs[i], NULL, -1))
  538. continue;
  539. nhlt = intel_nhlt_init(&pci->dev);
  540. if (!nhlt) {
  541. dev_warn(&pci->dev, "%s: NHLT table not found, skipped HID %s\n",
  542. __func__, table->codec_hid->codecs[i]);
  543. continue;
  544. }
  545. if (intel_nhlt_has_endpoint_type(nhlt, NHLT_LINK_SSP) &&
  546. intel_nhlt_ssp_endpoint_mask(nhlt, NHLT_DEVICE_I2S))
  547. ssp_found = true;
  548. intel_nhlt_free(nhlt);
  549. if (ssp_found)
  550. break;
  551. dev_warn(&pci->dev, "%s: no valid SSP found for HID %s, skipped\n",
  552. __func__, table->codec_hid->codecs[i]);
  553. }
  554. if (i == table->codec_hid->num_codecs)
  555. continue;
  556. }
  557. return table;
  558. }
  559. return NULL;
  560. }
  561. static int snd_intel_dsp_check_dmic(struct pci_dev *pci)
  562. {
  563. int ret = 0;
  564. acpi_nhlt_get_gbl_table();
  565. if (acpi_nhlt_find_endpoint(ACPI_NHLT_LINKTYPE_PDM, -1, -1, -1))
  566. ret = 1;
  567. acpi_nhlt_put_gbl_table();
  568. return ret;
  569. }
  570. #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
  571. static int snd_intel_dsp_check_soundwire(struct pci_dev *pci)
  572. {
  573. struct sdw_intel_acpi_info info;
  574. acpi_handle handle;
  575. int ret;
  576. handle = ACPI_HANDLE(&pci->dev);
  577. ret = sdw_intel_acpi_scan(handle, &info);
  578. if (ret < 0)
  579. return ret;
  580. return info.link_mask;
  581. }
  582. #else
  583. static int snd_intel_dsp_check_soundwire(struct pci_dev *pci)
  584. {
  585. return 0;
  586. }
  587. #endif
  588. int snd_intel_dsp_driver_probe(struct pci_dev *pci)
  589. {
  590. const struct config_entry *cfg;
  591. /* Intel vendor only */
  592. if (pci->vendor != PCI_VENDOR_ID_INTEL)
  593. return SND_INTEL_DSP_DRIVER_ANY;
  594. /*
  595. * Legacy devices don't have a PCI-based DSP and use HDaudio
  596. * for HDMI/DP support, ignore kernel parameter
  597. */
  598. switch (pci->device) {
  599. case PCI_DEVICE_ID_INTEL_HDA_BDW:
  600. case PCI_DEVICE_ID_INTEL_HDA_HSW_0:
  601. case PCI_DEVICE_ID_INTEL_HDA_HSW_2:
  602. case PCI_DEVICE_ID_INTEL_HDA_HSW_3:
  603. case PCI_DEVICE_ID_INTEL_HDA_BYT:
  604. case PCI_DEVICE_ID_INTEL_HDA_BSW:
  605. return SND_INTEL_DSP_DRIVER_ANY;
  606. }
  607. if (dsp_driver > 0 && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
  608. return dsp_driver;
  609. /*
  610. * detect DSP by checking class/subclass/prog-id information
  611. * class=04 subclass 03 prog-if 00: no DSP, use legacy driver
  612. * class=04 subclass 01 prog-if 00: DSP is present
  613. * (and may be required e.g. for DMIC or SSP support)
  614. * class=04 subclass 03 prog-if 80: use DSP or legacy mode
  615. */
  616. if (pci->class == 0x040300)
  617. return SND_INTEL_DSP_DRIVER_LEGACY;
  618. if (pci->class != 0x040100 && pci->class != 0x040380) {
  619. dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, selecting HDAudio legacy driver\n", pci->class);
  620. return SND_INTEL_DSP_DRIVER_LEGACY;
  621. }
  622. dev_dbg(&pci->dev, "DSP detected with PCI class/subclass/prog-if info 0x%06x\n", pci->class);
  623. /* find the configuration for the specific device */
  624. cfg = snd_intel_dsp_find_config(pci, config_table, ARRAY_SIZE(config_table));
  625. if (!cfg)
  626. return SND_INTEL_DSP_DRIVER_ANY;
  627. if (cfg->flags & FLAG_SOF) {
  628. if (cfg->flags & FLAG_SOF_ONLY_IF_SOUNDWIRE &&
  629. snd_intel_dsp_check_soundwire(pci) > 0) {
  630. dev_info_once(&pci->dev, "SoundWire enabled on CannonLake+ platform, using SOF driver\n");
  631. return SND_INTEL_DSP_DRIVER_SOF;
  632. }
  633. if (cfg->flags & FLAG_SOF_ONLY_IF_DMIC &&
  634. snd_intel_dsp_check_dmic(pci)) {
  635. dev_info_once(&pci->dev, "Digital mics found on Skylake+ platform, using SOF driver\n");
  636. return SND_INTEL_DSP_DRIVER_SOF;
  637. }
  638. if (!(cfg->flags & FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE))
  639. return SND_INTEL_DSP_DRIVER_SOF;
  640. }
  641. if (cfg->flags & FLAG_SST) {
  642. if (cfg->flags & FLAG_SST_ONLY_IF_DMIC) {
  643. if (snd_intel_dsp_check_dmic(pci)) {
  644. dev_info_once(&pci->dev, "Digital mics found on Skylake+ platform, using SST driver\n");
  645. return SND_INTEL_DSP_DRIVER_SST;
  646. }
  647. } else {
  648. return SND_INTEL_DSP_DRIVER_SST;
  649. }
  650. }
  651. return SND_INTEL_DSP_DRIVER_LEGACY;
  652. }
  653. EXPORT_SYMBOL_GPL(snd_intel_dsp_driver_probe);
  654. /* Should we default to SOF or SST for BYT/CHT ? */
  655. #if IS_ENABLED(CONFIG_SND_INTEL_BYT_PREFER_SOF) || \
  656. !IS_ENABLED(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_ACPI)
  657. #define FLAG_SST_OR_SOF_BYT FLAG_SOF
  658. #else
  659. #define FLAG_SST_OR_SOF_BYT FLAG_SST
  660. #endif
  661. /*
  662. * configuration table
  663. * - the order of similar ACPI ID entries is important!
  664. * - the first successful match will win
  665. */
  666. static const struct config_entry acpi_config_table[] = {
  667. #if IS_ENABLED(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_ACPI) || \
  668. IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
  669. /* BayTrail */
  670. {
  671. .flags = FLAG_SST_OR_SOF_BYT,
  672. .acpi_hid = "LPE0F28",
  673. },
  674. {
  675. .flags = FLAG_SST_OR_SOF_BYT,
  676. .acpi_hid = "80860F28",
  677. },
  678. /* CherryTrail */
  679. {
  680. .flags = FLAG_SST_OR_SOF_BYT,
  681. .acpi_hid = "808622A8",
  682. },
  683. #endif
  684. /* Broadwell */
  685. #if IS_ENABLED(CONFIG_SND_SOC_INTEL_CATPT)
  686. {
  687. .flags = FLAG_SST,
  688. .acpi_hid = "INT3438"
  689. },
  690. #endif
  691. #if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
  692. {
  693. .flags = FLAG_SOF,
  694. .acpi_hid = "INT3438"
  695. },
  696. #endif
  697. /* Haswell - not supported by SOF but added for consistency */
  698. #if IS_ENABLED(CONFIG_SND_SOC_INTEL_CATPT)
  699. {
  700. .flags = FLAG_SST,
  701. .acpi_hid = "INT33C8"
  702. },
  703. #endif
  704. };
  705. static const struct config_entry *snd_intel_acpi_dsp_find_config(const u8 acpi_hid[ACPI_ID_LEN],
  706. const struct config_entry *table,
  707. u32 len)
  708. {
  709. for (; len > 0; len--, table++) {
  710. if (memcmp(table->acpi_hid, acpi_hid, ACPI_ID_LEN))
  711. continue;
  712. if (table->dmi_table && !dmi_check_system(table->dmi_table))
  713. continue;
  714. return table;
  715. }
  716. return NULL;
  717. }
  718. int snd_intel_acpi_dsp_driver_probe(struct device *dev, const u8 acpi_hid[ACPI_ID_LEN])
  719. {
  720. const struct config_entry *cfg;
  721. if (dsp_driver > SND_INTEL_DSP_DRIVER_LEGACY && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
  722. return dsp_driver;
  723. if (dsp_driver == SND_INTEL_DSP_DRIVER_LEGACY) {
  724. dev_warn(dev, "dsp_driver parameter %d not supported, using automatic detection\n",
  725. SND_INTEL_DSP_DRIVER_LEGACY);
  726. }
  727. /* find the configuration for the specific device */
  728. cfg = snd_intel_acpi_dsp_find_config(acpi_hid, acpi_config_table,
  729. ARRAY_SIZE(acpi_config_table));
  730. if (!cfg)
  731. return SND_INTEL_DSP_DRIVER_ANY;
  732. if (cfg->flags & FLAG_SST)
  733. return SND_INTEL_DSP_DRIVER_SST;
  734. if (cfg->flags & FLAG_SOF)
  735. return SND_INTEL_DSP_DRIVER_SOF;
  736. return SND_INTEL_DSP_DRIVER_SST;
  737. }
  738. EXPORT_SYMBOL_GPL(snd_intel_acpi_dsp_driver_probe);
  739. MODULE_LICENSE("GPL v2");
  740. MODULE_DESCRIPTION("Intel DSP config driver");
  741. MODULE_IMPORT_NS(SND_INTEL_SOUNDWIRE_ACPI);