intel-dsp-config.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  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. {
  521. .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
  522. .device = PCI_DEVICE_ID_INTEL_HDA_PTL_H,
  523. },
  524. #endif
  525. };
  526. static const struct config_entry *snd_intel_dsp_find_config
  527. (struct pci_dev *pci, const struct config_entry *table, u32 len)
  528. {
  529. u16 device;
  530. device = pci->device;
  531. for (; len > 0; len--, table++) {
  532. if (table->device != device)
  533. continue;
  534. if (table->dmi_table && !dmi_check_system(table->dmi_table))
  535. continue;
  536. if (table->codec_hid) {
  537. int i;
  538. for (i = 0; i < table->codec_hid->num_codecs; i++) {
  539. struct nhlt_acpi_table *nhlt;
  540. bool ssp_found = false;
  541. if (!acpi_dev_present(table->codec_hid->codecs[i], NULL, -1))
  542. continue;
  543. nhlt = intel_nhlt_init(&pci->dev);
  544. if (!nhlt) {
  545. dev_warn(&pci->dev, "%s: NHLT table not found, skipped HID %s\n",
  546. __func__, table->codec_hid->codecs[i]);
  547. continue;
  548. }
  549. if (intel_nhlt_has_endpoint_type(nhlt, NHLT_LINK_SSP) &&
  550. intel_nhlt_ssp_endpoint_mask(nhlt, NHLT_DEVICE_I2S))
  551. ssp_found = true;
  552. intel_nhlt_free(nhlt);
  553. if (ssp_found)
  554. break;
  555. dev_warn(&pci->dev, "%s: no valid SSP found for HID %s, skipped\n",
  556. __func__, table->codec_hid->codecs[i]);
  557. }
  558. if (i == table->codec_hid->num_codecs)
  559. continue;
  560. }
  561. return table;
  562. }
  563. return NULL;
  564. }
  565. static int snd_intel_dsp_check_dmic(struct pci_dev *pci)
  566. {
  567. int ret = 0;
  568. acpi_nhlt_get_gbl_table();
  569. if (acpi_nhlt_find_endpoint(ACPI_NHLT_LINKTYPE_PDM, -1, -1, -1))
  570. ret = 1;
  571. acpi_nhlt_put_gbl_table();
  572. return ret;
  573. }
  574. #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
  575. static int snd_intel_dsp_check_soundwire(struct pci_dev *pci)
  576. {
  577. struct sdw_intel_acpi_info info;
  578. acpi_handle handle;
  579. int ret;
  580. handle = ACPI_HANDLE(&pci->dev);
  581. ret = sdw_intel_acpi_scan(handle, &info);
  582. if (ret < 0)
  583. return ret;
  584. return info.link_mask;
  585. }
  586. #else
  587. static int snd_intel_dsp_check_soundwire(struct pci_dev *pci)
  588. {
  589. return 0;
  590. }
  591. #endif
  592. int snd_intel_dsp_driver_probe(struct pci_dev *pci)
  593. {
  594. const struct config_entry *cfg;
  595. /* Intel vendor only */
  596. if (pci->vendor != PCI_VENDOR_ID_INTEL)
  597. return SND_INTEL_DSP_DRIVER_ANY;
  598. /*
  599. * Legacy devices don't have a PCI-based DSP and use HDaudio
  600. * for HDMI/DP support, ignore kernel parameter
  601. */
  602. switch (pci->device) {
  603. case PCI_DEVICE_ID_INTEL_HDA_BDW:
  604. case PCI_DEVICE_ID_INTEL_HDA_HSW_0:
  605. case PCI_DEVICE_ID_INTEL_HDA_HSW_2:
  606. case PCI_DEVICE_ID_INTEL_HDA_HSW_3:
  607. case PCI_DEVICE_ID_INTEL_HDA_BYT:
  608. case PCI_DEVICE_ID_INTEL_HDA_BSW:
  609. return SND_INTEL_DSP_DRIVER_ANY;
  610. }
  611. if (dsp_driver > 0 && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
  612. return dsp_driver;
  613. /*
  614. * detect DSP by checking class/subclass/prog-id information
  615. * class=04 subclass 03 prog-if 00: no DSP, use legacy driver
  616. * class=04 subclass 01 prog-if 00: DSP is present
  617. * (and may be required e.g. for DMIC or SSP support)
  618. * class=04 subclass 03 prog-if 80: use DSP or legacy mode
  619. */
  620. if (pci->class == 0x040300)
  621. return SND_INTEL_DSP_DRIVER_LEGACY;
  622. if (pci->class != 0x040100 && pci->class != 0x040380) {
  623. dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, selecting HDAudio legacy driver\n", pci->class);
  624. return SND_INTEL_DSP_DRIVER_LEGACY;
  625. }
  626. dev_dbg(&pci->dev, "DSP detected with PCI class/subclass/prog-if info 0x%06x\n", pci->class);
  627. /* find the configuration for the specific device */
  628. cfg = snd_intel_dsp_find_config(pci, config_table, ARRAY_SIZE(config_table));
  629. if (!cfg)
  630. return SND_INTEL_DSP_DRIVER_ANY;
  631. if (cfg->flags & FLAG_SOF) {
  632. if (cfg->flags & FLAG_SOF_ONLY_IF_SOUNDWIRE &&
  633. snd_intel_dsp_check_soundwire(pci) > 0) {
  634. dev_info_once(&pci->dev, "SoundWire enabled on CannonLake+ platform, using SOF driver\n");
  635. return SND_INTEL_DSP_DRIVER_SOF;
  636. }
  637. if (cfg->flags & FLAG_SOF_ONLY_IF_DMIC &&
  638. snd_intel_dsp_check_dmic(pci)) {
  639. dev_info_once(&pci->dev, "Digital mics found on Skylake+ platform, using SOF driver\n");
  640. return SND_INTEL_DSP_DRIVER_SOF;
  641. }
  642. if (!(cfg->flags & FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE))
  643. return SND_INTEL_DSP_DRIVER_SOF;
  644. }
  645. if (cfg->flags & FLAG_SST) {
  646. if (cfg->flags & FLAG_SST_ONLY_IF_DMIC) {
  647. if (snd_intel_dsp_check_dmic(pci)) {
  648. dev_info_once(&pci->dev, "Digital mics found on Skylake+ platform, using SST driver\n");
  649. return SND_INTEL_DSP_DRIVER_SST;
  650. }
  651. } else {
  652. return SND_INTEL_DSP_DRIVER_SST;
  653. }
  654. }
  655. return SND_INTEL_DSP_DRIVER_LEGACY;
  656. }
  657. EXPORT_SYMBOL_GPL(snd_intel_dsp_driver_probe);
  658. /* Should we default to SOF or SST for BYT/CHT ? */
  659. #if IS_ENABLED(CONFIG_SND_INTEL_BYT_PREFER_SOF) || \
  660. !IS_ENABLED(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_ACPI)
  661. #define FLAG_SST_OR_SOF_BYT FLAG_SOF
  662. #else
  663. #define FLAG_SST_OR_SOF_BYT FLAG_SST
  664. #endif
  665. /*
  666. * configuration table
  667. * - the order of similar ACPI ID entries is important!
  668. * - the first successful match will win
  669. */
  670. static const struct config_entry acpi_config_table[] = {
  671. #if IS_ENABLED(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_ACPI) || \
  672. IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
  673. /* BayTrail */
  674. {
  675. .flags = FLAG_SST_OR_SOF_BYT,
  676. .acpi_hid = "LPE0F28",
  677. },
  678. {
  679. .flags = FLAG_SST_OR_SOF_BYT,
  680. .acpi_hid = "80860F28",
  681. },
  682. /* CherryTrail */
  683. {
  684. .flags = FLAG_SST_OR_SOF_BYT,
  685. .acpi_hid = "808622A8",
  686. },
  687. #endif
  688. /* Broadwell */
  689. #if IS_ENABLED(CONFIG_SND_SOC_INTEL_CATPT)
  690. {
  691. .flags = FLAG_SST,
  692. .acpi_hid = "INT3438"
  693. },
  694. #endif
  695. #if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
  696. {
  697. .flags = FLAG_SOF,
  698. .acpi_hid = "INT3438"
  699. },
  700. #endif
  701. /* Haswell - not supported by SOF but added for consistency */
  702. #if IS_ENABLED(CONFIG_SND_SOC_INTEL_CATPT)
  703. {
  704. .flags = FLAG_SST,
  705. .acpi_hid = "INT33C8"
  706. },
  707. #endif
  708. };
  709. static const struct config_entry *snd_intel_acpi_dsp_find_config(const u8 acpi_hid[ACPI_ID_LEN],
  710. const struct config_entry *table,
  711. u32 len)
  712. {
  713. for (; len > 0; len--, table++) {
  714. if (memcmp(table->acpi_hid, acpi_hid, ACPI_ID_LEN))
  715. continue;
  716. if (table->dmi_table && !dmi_check_system(table->dmi_table))
  717. continue;
  718. return table;
  719. }
  720. return NULL;
  721. }
  722. int snd_intel_acpi_dsp_driver_probe(struct device *dev, const u8 acpi_hid[ACPI_ID_LEN])
  723. {
  724. const struct config_entry *cfg;
  725. if (dsp_driver > SND_INTEL_DSP_DRIVER_LEGACY && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
  726. return dsp_driver;
  727. if (dsp_driver == SND_INTEL_DSP_DRIVER_LEGACY) {
  728. dev_warn(dev, "dsp_driver parameter %d not supported, using automatic detection\n",
  729. SND_INTEL_DSP_DRIVER_LEGACY);
  730. }
  731. /* find the configuration for the specific device */
  732. cfg = snd_intel_acpi_dsp_find_config(acpi_hid, acpi_config_table,
  733. ARRAY_SIZE(acpi_config_table));
  734. if (!cfg)
  735. return SND_INTEL_DSP_DRIVER_ANY;
  736. if (cfg->flags & FLAG_SST)
  737. return SND_INTEL_DSP_DRIVER_SST;
  738. if (cfg->flags & FLAG_SOF)
  739. return SND_INTEL_DSP_DRIVER_SOF;
  740. return SND_INTEL_DSP_DRIVER_SST;
  741. }
  742. EXPORT_SYMBOL_GPL(snd_intel_acpi_dsp_driver_probe);
  743. MODULE_LICENSE("GPL v2");
  744. MODULE_DESCRIPTION("Intel DSP config driver");
  745. MODULE_IMPORT_NS(SND_INTEL_SOUNDWIRE_ACPI);