intel-dsp-config.c 16 KB

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