Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * soc-intel-quirks.h - prototypes for quirk autodetection
0004  *
0005  * Copyright (c) 2019, Intel Corporation.
0006  *
0007  */
0008 
0009 #ifndef _SND_SOC_INTEL_QUIRKS_H
0010 #define _SND_SOC_INTEL_QUIRKS_H
0011 
0012 #include <linux/platform_data/x86/soc.h>
0013 
0014 #if IS_ENABLED(CONFIG_X86)
0015 
0016 #include <linux/dmi.h>
0017 #include <asm/iosf_mbi.h>
0018 
0019 static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
0020 {
0021     /*
0022      * List of systems which:
0023      * 1. Use a non CR version of the Bay Trail SoC
0024      * 2. Contain at least 6 interrupt resources so that the
0025      *    platform_get_resource(pdev, IORESOURCE_IRQ, 5) check below
0026      *    succeeds
0027      * 3. Despite 1. and 2. still have their IPC IRQ at index 0 rather then 5
0028      *
0029      * This needs to be here so that it can be shared between the SST and
0030      * SOF drivers. We rely on the compiler to optimize this out in files
0031      * where soc_intel_is_byt_cr is not used.
0032      */
0033     static const struct dmi_system_id force_bytcr_table[] = {
0034         {   /* Lenovo Yoga Tablet 2 series */
0035             .matches = {
0036                 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
0037                 DMI_MATCH(DMI_PRODUCT_FAMILY, "YOGATablet2"),
0038             },
0039         },
0040         {}
0041     };
0042     struct device *dev = &pdev->dev;
0043     int status = 0;
0044 
0045     if (!soc_intel_is_byt())
0046         return false;
0047 
0048     if (dmi_check_system(force_bytcr_table))
0049         return true;
0050 
0051     if (iosf_mbi_available()) {
0052         u32 bios_status;
0053 
0054         status = iosf_mbi_read(BT_MBI_UNIT_PMC, /* 0x04 PUNIT */
0055                        MBI_REG_READ, /* 0x10 */
0056                        0x006, /* BIOS_CONFIG */
0057                        &bios_status);
0058 
0059         if (status) {
0060             dev_err(dev, "could not read PUNIT BIOS_CONFIG\n");
0061         } else {
0062             /* bits 26:27 mirror PMIC options */
0063             bios_status = (bios_status >> 26) & 3;
0064 
0065             if (bios_status == 1 || bios_status == 3) {
0066                 dev_info(dev, "Detected Baytrail-CR platform\n");
0067                 return true;
0068             }
0069 
0070             dev_info(dev, "BYT-CR not detected\n");
0071         }
0072     } else {
0073         dev_info(dev, "IOSF_MBI not available, no BYT-CR detection\n");
0074     }
0075 
0076     if (!platform_get_resource(pdev, IORESOURCE_IRQ, 5)) {
0077         /*
0078          * Some devices detected as BYT-T have only a single IRQ listed,
0079          * causing platform_get_irq with index 5 to return -ENXIO.
0080          * The correct IRQ in this case is at index 0, as on BYT-CR.
0081          */
0082         dev_info(dev, "Falling back to Baytrail-CR platform\n");
0083         return true;
0084     }
0085 
0086     return false;
0087 }
0088 
0089 #else
0090 
0091 static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
0092 {
0093     return false;
0094 }
0095 
0096 #endif
0097 
0098 #endif /* _SND_SOC_INTEL_QUIRKS_H */