18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * soc-intel-quirks.h - prototypes for quirk autodetection 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2019, Intel Corporation. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef _SND_SOC_INTEL_QUIRKS_H 108c2ecf20Sopenharmony_ci#define _SND_SOC_INTEL_QUIRKS_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/platform_data/x86/soc.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_X86) 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/dmi.h> 178c2ecf20Sopenharmony_ci#include <asm/iosf_mbi.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cistatic inline bool soc_intel_is_byt_cr(struct platform_device *pdev) 208c2ecf20Sopenharmony_ci{ 218c2ecf20Sopenharmony_ci /* 228c2ecf20Sopenharmony_ci * List of systems which: 238c2ecf20Sopenharmony_ci * 1. Use a non CR version of the Bay Trail SoC 248c2ecf20Sopenharmony_ci * 2. Contain at least 6 interrupt resources so that the 258c2ecf20Sopenharmony_ci * platform_get_resource(pdev, IORESOURCE_IRQ, 5) check below 268c2ecf20Sopenharmony_ci * succeeds 278c2ecf20Sopenharmony_ci * 3. Despite 1. and 2. still have their IPC IRQ at index 0 rather then 5 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * This needs to be here so that it can be shared between the SST and 308c2ecf20Sopenharmony_ci * SOF drivers. We rely on the compiler to optimize this out in files 318c2ecf20Sopenharmony_ci * where soc_intel_is_byt_cr is not used. 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_ci static const struct dmi_system_id force_bytcr_table[] = { 348c2ecf20Sopenharmony_ci { /* Lenovo Yoga Tablet 2 series */ 358c2ecf20Sopenharmony_ci .matches = { 368c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 378c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_FAMILY, "YOGATablet2"), 388c2ecf20Sopenharmony_ci }, 398c2ecf20Sopenharmony_ci }, 408c2ecf20Sopenharmony_ci {} 418c2ecf20Sopenharmony_ci }; 428c2ecf20Sopenharmony_ci struct device *dev = &pdev->dev; 438c2ecf20Sopenharmony_ci int status = 0; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci if (!soc_intel_is_byt()) 468c2ecf20Sopenharmony_ci return false; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci if (dmi_check_system(force_bytcr_table)) 498c2ecf20Sopenharmony_ci return true; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci if (iosf_mbi_available()) { 528c2ecf20Sopenharmony_ci u32 bios_status; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci status = iosf_mbi_read(BT_MBI_UNIT_PMC, /* 0x04 PUNIT */ 558c2ecf20Sopenharmony_ci MBI_REG_READ, /* 0x10 */ 568c2ecf20Sopenharmony_ci 0x006, /* BIOS_CONFIG */ 578c2ecf20Sopenharmony_ci &bios_status); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci if (status) { 608c2ecf20Sopenharmony_ci dev_err(dev, "could not read PUNIT BIOS_CONFIG\n"); 618c2ecf20Sopenharmony_ci } else { 628c2ecf20Sopenharmony_ci /* bits 26:27 mirror PMIC options */ 638c2ecf20Sopenharmony_ci bios_status = (bios_status >> 26) & 3; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci if (bios_status == 1 || bios_status == 3) { 668c2ecf20Sopenharmony_ci dev_info(dev, "Detected Baytrail-CR platform\n"); 678c2ecf20Sopenharmony_ci return true; 688c2ecf20Sopenharmony_ci } 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci dev_info(dev, "BYT-CR not detected\n"); 718c2ecf20Sopenharmony_ci } 728c2ecf20Sopenharmony_ci } else { 738c2ecf20Sopenharmony_ci dev_info(dev, "IOSF_MBI not available, no BYT-CR detection\n"); 748c2ecf20Sopenharmony_ci } 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci if (!platform_get_resource(pdev, IORESOURCE_IRQ, 5)) { 778c2ecf20Sopenharmony_ci /* 788c2ecf20Sopenharmony_ci * Some devices detected as BYT-T have only a single IRQ listed, 798c2ecf20Sopenharmony_ci * causing platform_get_irq with index 5 to return -ENXIO. 808c2ecf20Sopenharmony_ci * The correct IRQ in this case is at index 0, as on BYT-CR. 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci dev_info(dev, "Falling back to Baytrail-CR platform\n"); 838c2ecf20Sopenharmony_ci return true; 848c2ecf20Sopenharmony_ci } 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci return false; 878c2ecf20Sopenharmony_ci} 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#else 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic inline bool soc_intel_is_byt_cr(struct platform_device *pdev) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci return false; 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#endif 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#endif /* _SND_SOC_INTEL_QUIRKS_H */ 99