Path: blob/master/sound/soc/intel/common/soc-intel-quirks.h
26493 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* soc-intel-quirks.h - prototypes for quirk autodetection3*4* Copyright (c) 2019, Intel Corporation.5*6*/78#ifndef _SND_SOC_INTEL_QUIRKS_H9#define _SND_SOC_INTEL_QUIRKS_H1011#include <linux/platform_data/x86/soc.h>1213#if IS_REACHABLE(CONFIG_IOSF_MBI)1415#include <linux/dmi.h>16#include <asm/iosf_mbi.h>1718static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)19{20/*21* List of systems which:22* 1. Use a non CR version of the Bay Trail SoC23* 2. Contain at least 6 interrupt resources so that the24* platform_get_resource(pdev, IORESOURCE_IRQ, 5) check below25* succeeds26* 3. Despite 1. and 2. still have their IPC IRQ at index 0 rather then 527*28* This needs to be here so that it can be shared between the SST and29* SOF drivers. We rely on the compiler to optimize this out in files30* where soc_intel_is_byt_cr is not used.31*/32static const struct dmi_system_id force_bytcr_table[] = {33{ /* Lenovo Yoga Tablet 2 series */34.matches = {35DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),36DMI_MATCH(DMI_PRODUCT_FAMILY, "YOGATablet2"),37},38},39{}40};41struct device *dev = &pdev->dev;42int status = 0;4344if (!soc_intel_is_byt())45return false;4647if (dmi_check_system(force_bytcr_table))48return true;4950if (iosf_mbi_available()) {51u32 bios_status;5253status = iosf_mbi_read(BT_MBI_UNIT_PMC, /* 0x04 PUNIT */54MBI_REG_READ, /* 0x10 */550x006, /* BIOS_CONFIG */56&bios_status);5758if (status) {59dev_err(dev, "could not read PUNIT BIOS_CONFIG\n");60} else {61/* bits 26:27 mirror PMIC options */62bios_status = (bios_status >> 26) & 3;6364if (bios_status == 1 || bios_status == 3) {65dev_info(dev, "Detected Baytrail-CR platform\n");66return true;67}6869dev_info(dev, "BYT-CR not detected\n");70}71} else {72dev_info(dev, "IOSF_MBI not available, no BYT-CR detection\n");73}7475if (!platform_get_resource(pdev, IORESOURCE_IRQ, 5)) {76/*77* Some devices detected as BYT-T have only a single IRQ listed,78* causing platform_get_irq with index 5 to return -ENXIO.79* The correct IRQ in this case is at index 0, as on BYT-CR.80*/81dev_info(dev, "Falling back to Baytrail-CR platform\n");82return true;83}8485return false;86}8788#else8990static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)91{92return false;93}9495#endif9697#endif /* _SND_SOC_INTEL_QUIRKS_H */9899100