1 /* SPDX-License-Identifier: GPL-2.0 */
3 * soc-intel-quirks.h - prototypes for quirk autodetection
5 * Copyright (c) 2019, Intel Corporation.
9 #ifndef _SND_SOC_INTEL_QUIRKS_H
10 #define _SND_SOC_INTEL_QUIRKS_H
12 #if IS_ENABLED(CONFIG_X86)
14 #include <asm/cpu_device_id.h>
15 #include <asm/intel-family.h>
16 #include <asm/iosf_mbi.h>
18 #define SOC_INTEL_IS_CPU(soc, type) \
19 static inline bool soc_intel_is_##soc(void) \
21 static const struct x86_cpu_id soc##_cpu_ids[] = { \
22 X86_MATCH_INTEL_FAM6_MODEL(type, NULL), \
25 const struct x86_cpu_id *id; \
27 id = x86_match_cpu(soc##_cpu_ids); \
33 SOC_INTEL_IS_CPU(byt, ATOM_SILVERMONT);
34 SOC_INTEL_IS_CPU(cht, ATOM_AIRMONT);
35 SOC_INTEL_IS_CPU(apl, ATOM_GOLDMONT);
36 SOC_INTEL_IS_CPU(glk, ATOM_GOLDMONT_PLUS);
37 SOC_INTEL_IS_CPU(cml, KABYLAKE_L);
39 static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
41 struct device *dev = &pdev->dev;
44 if (!soc_intel_is_byt())
47 if (iosf_mbi_available()) {
50 status = iosf_mbi_read(BT_MBI_UNIT_PMC, /* 0x04 PUNIT */
51 MBI_REG_READ, /* 0x10 */
52 0x006, /* BIOS_CONFIG */
56 dev_err(dev, "could not read PUNIT BIOS_CONFIG\n");
58 /* bits 26:27 mirror PMIC options */
59 bios_status = (bios_status >> 26) & 3;
61 if (bios_status == 1 || bios_status == 3) {
62 dev_info(dev, "Detected Baytrail-CR platform\n");
66 dev_info(dev, "BYT-CR not detected\n");
69 dev_info(dev, "IOSF_MBI not available, no BYT-CR detection\n");
72 if (!platform_get_resource(pdev, IORESOURCE_IRQ, 5)) {
74 * Some devices detected as BYT-T have only a single IRQ listed,
75 * causing platform_get_irq with index 5 to return -ENXIO.
76 * The correct IRQ in this case is at index 0, as on BYT-CR.
78 dev_info(dev, "Falling back to Baytrail-CR platform\n");
87 static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
92 static inline bool soc_intel_is_byt(void)
97 static inline bool soc_intel_is_cht(void)
102 static inline bool soc_intel_is_apl(void)
107 static inline bool soc_intel_is_glk(void)
112 static inline bool soc_intel_is_cml(void)
118 #endif /* _SND_SOC_INTEL_QUIRKS_H */