soc-intel-quirks.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * soc-intel-quirks.h - prototypes for quirk autodetection
  4. *
  5. * Copyright (c) 2019, Intel Corporation.
  6. *
  7. */
  8. #ifndef _SND_SOC_INTEL_QUIRKS_H
  9. #define _SND_SOC_INTEL_QUIRKS_H
  10. #include <linux/platform_data/x86/soc.h>
  11. #if IS_ENABLED(CONFIG_X86)
  12. #include <linux/dmi.h>
  13. #include <asm/iosf_mbi.h>
  14. static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
  15. {
  16. /*
  17. * List of systems which:
  18. * 1. Use a non CR version of the Bay Trail SoC
  19. * 2. Contain at least 6 interrupt resources so that the
  20. * platform_get_resource(pdev, IORESOURCE_IRQ, 5) check below
  21. * succeeds
  22. * 3. Despite 1. and 2. still have their IPC IRQ at index 0 rather then 5
  23. *
  24. * This needs to be here so that it can be shared between the SST and
  25. * SOF drivers. We rely on the compiler to optimize this out in files
  26. * where soc_intel_is_byt_cr is not used.
  27. */
  28. static const struct dmi_system_id force_bytcr_table[] = {
  29. { /* Lenovo Yoga Tablet 2 series */
  30. .matches = {
  31. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  32. DMI_MATCH(DMI_PRODUCT_FAMILY, "YOGATablet2"),
  33. },
  34. },
  35. {}
  36. };
  37. struct device *dev = &pdev->dev;
  38. int status = 0;
  39. if (!soc_intel_is_byt())
  40. return false;
  41. if (dmi_check_system(force_bytcr_table))
  42. return true;
  43. if (iosf_mbi_available()) {
  44. u32 bios_status;
  45. status = iosf_mbi_read(BT_MBI_UNIT_PMC, /* 0x04 PUNIT */
  46. MBI_REG_READ, /* 0x10 */
  47. 0x006, /* BIOS_CONFIG */
  48. &bios_status);
  49. if (status) {
  50. dev_err(dev, "could not read PUNIT BIOS_CONFIG\n");
  51. } else {
  52. /* bits 26:27 mirror PMIC options */
  53. bios_status = (bios_status >> 26) & 3;
  54. if (bios_status == 1 || bios_status == 3) {
  55. dev_info(dev, "Detected Baytrail-CR platform\n");
  56. return true;
  57. }
  58. dev_info(dev, "BYT-CR not detected\n");
  59. }
  60. } else {
  61. dev_info(dev, "IOSF_MBI not available, no BYT-CR detection\n");
  62. }
  63. if (!platform_get_resource(pdev, IORESOURCE_IRQ, 5)) {
  64. /*
  65. * Some devices detected as BYT-T have only a single IRQ listed,
  66. * causing platform_get_irq with index 5 to return -ENXIO.
  67. * The correct IRQ in this case is at index 0, as on BYT-CR.
  68. */
  69. dev_info(dev, "Falling back to Baytrail-CR platform\n");
  70. return true;
  71. }
  72. return false;
  73. }
  74. #else
  75. static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
  76. {
  77. return false;
  78. }
  79. #endif
  80. #endif /* _SND_SOC_INTEL_QUIRKS_H */