Commit 536cfd2f authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: Intel: use common helpers to detect CPUs

We have duplicated code in multiple locations (atom, machine drivers,
SOF) to detect Baytrail, Cherrytrail and other SOCs. This is not very
elegant, and introduces dependencies on CONFIG_X86 that prevent
COMPILE_TEST from working.

Add common helpers to provide same functionality in a cleaner
way. This will also help support the DMI-based quirks being introduced
to handle SOF/SST autodetection.
Reviewed-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent f499edf9
...@@ -38,12 +38,11 @@ ...@@ -38,12 +38,11 @@
#include <acpi/platform/aclinux.h> #include <acpi/platform/aclinux.h>
#include <acpi/actypes.h> #include <acpi/actypes.h>
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <asm/cpu_device_id.h>
#include <asm/iosf_mbi.h>
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h> #include <sound/soc-acpi-intel-match.h>
#include "../sst-mfld-platform.h" #include "../sst-mfld-platform.h"
#include "../../common/sst-dsp.h" #include "../../common/sst-dsp.h"
#include "../../common/soc-intel-quirks.h"
#include "sst.h" #include "sst.h"
/* LPE viewpoint addresses */ /* LPE viewpoint addresses */
...@@ -243,64 +242,6 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx) ...@@ -243,64 +242,6 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx)
return 0; return 0;
} }
static int is_byt(void)
{
bool status = false;
static const struct x86_cpu_id cpu_ids[] = {
{ X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
{}
};
if (x86_match_cpu(cpu_ids))
status = true;
return status;
}
static bool is_byt_cr(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
int status = 0;
if (!is_byt())
return false;
if (iosf_mbi_available()) {
u32 bios_status;
status = iosf_mbi_read(BT_MBI_UNIT_PMC, /* 0x04 PUNIT */
MBI_REG_READ, /* 0x10 */
0x006, /* BIOS_CONFIG */
&bios_status);
if (status) {
dev_err(dev, "could not read PUNIT BIOS_CONFIG\n");
} else {
/* bits 26:27 mirror PMIC options */
bios_status = (bios_status >> 26) & 3;
if (bios_status == 1 || bios_status == 3) {
dev_info(dev, "Detected Baytrail-CR platform\n");
return true;
}
dev_info(dev, "BYT-CR not detected\n");
}
} else {
dev_info(dev, "IOSF_MBI not available, no BYT-CR detection\n");
}
if (platform_get_resource(pdev, IORESOURCE_IRQ, 5) == NULL) {
/*
* Some devices detected as BYT-T have only a single IRQ listed,
* causing platform_get_irq with index 5 to return -ENXIO.
* The correct IRQ in this case is at index 0, as on BYT-CR.
*/
dev_info(dev, "Falling back to Baytrail-CR platform\n");
return true;
}
return false;
}
static int sst_acpi_probe(struct platform_device *pdev) static int sst_acpi_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
...@@ -325,7 +266,7 @@ static int sst_acpi_probe(struct platform_device *pdev) ...@@ -325,7 +266,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
if (is_byt()) if (soc_intel_is_byt())
mach->pdata = &byt_rvp_platform_data; mach->pdata = &byt_rvp_platform_data;
else else
mach->pdata = &chv_platform_data; mach->pdata = &chv_platform_data;
...@@ -343,7 +284,7 @@ static int sst_acpi_probe(struct platform_device *pdev) ...@@ -343,7 +284,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
return ret; return ret;
if (is_byt_cr(pdev)) { if (soc_intel_is_byt_cr(pdev)) {
/* override resource info */ /* override resource info */
byt_rvp_platform_data.res_info = &bytcr_res_info; byt_rvp_platform_data.res_info = &bytcr_res_info;
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <asm/cpu_device_id.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -29,6 +28,7 @@ ...@@ -29,6 +28,7 @@
#include "../../codecs/hdac_hdmi.h" #include "../../codecs/hdac_hdmi.h"
#include "../../codecs/da7219.h" #include "../../codecs/da7219.h"
#include "../../codecs/da7219-aad.h" #include "../../codecs/da7219-aad.h"
#include "../common/soc-intel-quirks.h"
#define BXT_DIALOG_CODEC_DAI "da7219-hifi" #define BXT_DIALOG_CODEC_DAI "da7219-hifi"
#define BXT_MAXIM_CODEC_DAI "HiFi" #define BXT_MAXIM_CODEC_DAI "HiFi"
...@@ -568,11 +568,6 @@ static struct snd_soc_dai_link broxton_dais[] = { ...@@ -568,11 +568,6 @@ static struct snd_soc_dai_link broxton_dais[] = {
}, },
}; };
static const struct x86_cpu_id glk_ids[] = {
{ X86_VENDOR_INTEL, 6, 0x7A }, /* Geminilake CPU_ID */
{}
};
#define NAME_SIZE 32 #define NAME_SIZE 32
static int bxt_card_late_probe(struct snd_soc_card *card) static int bxt_card_late_probe(struct snd_soc_card *card)
{ {
...@@ -582,7 +577,7 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -582,7 +577,7 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
if (x86_match_cpu(glk_ids)) if (soc_intel_is_glk())
snd_soc_dapm_add_routes(&card->dapm, gemini_map, snd_soc_dapm_add_routes(&card->dapm, gemini_map,
ARRAY_SIZE(gemini_map)); ARRAY_SIZE(gemini_map));
else else
...@@ -645,7 +640,7 @@ static int broxton_audio_probe(struct platform_device *pdev) ...@@ -645,7 +640,7 @@ static int broxton_audio_probe(struct platform_device *pdev)
broxton_audio_card.dev = &pdev->dev; broxton_audio_card.dev = &pdev->dev;
snd_soc_card_set_drvdata(&broxton_audio_card, ctx); snd_soc_card_set_drvdata(&broxton_audio_card, ctx);
if (x86_match_cpu(glk_ids)) { if (soc_intel_is_glk()) {
unsigned int i; unsigned int i;
broxton_audio_card.name = "glkda7219max"; broxton_audio_card.name = "glkda7219max";
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/cpu_device_id.h>
#include <asm/intel-family.h>
#include <asm/platform_sst_audio.h> #include <asm/platform_sst_audio.h>
#include <sound/jack.h> #include <sound/jack.h>
#include <sound/pcm.h> #include <sound/pcm.h>
...@@ -40,6 +38,7 @@ ...@@ -40,6 +38,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include "../atom/sst-atom-controls.h" #include "../atom/sst-atom-controls.h"
#include "../common/sst-dsp.h" #include "../common/sst-dsp.h"
#include "../common/soc-intel-quirks.h"
/* jd-inv + terminating entry */ /* jd-inv + terminating entry */
#define MAX_NO_PROPS 2 #define MAX_NO_PROPS 2
...@@ -430,11 +429,6 @@ static struct snd_soc_card byt_cht_es8316_card = { ...@@ -430,11 +429,6 @@ static struct snd_soc_card byt_cht_es8316_card = {
.resume_post = byt_cht_es8316_resume, .resume_post = byt_cht_es8316_resume,
}; };
static const struct x86_cpu_id baytrail_cpu_ids[] = {
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT }, /* Valleyview */
{}
};
static const struct acpi_gpio_params first_gpio = { 0, 0, false }; static const struct acpi_gpio_params first_gpio = { 0, 0, false };
static const struct acpi_gpio_mapping byt_cht_es8316_gpios[] = { static const struct acpi_gpio_mapping byt_cht_es8316_gpios[] = {
...@@ -506,8 +500,8 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) ...@@ -506,8 +500,8 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
dmi_id = dmi_first_match(byt_cht_es8316_quirk_table); dmi_id = dmi_first_match(byt_cht_es8316_quirk_table);
if (dmi_id) { if (dmi_id) {
quirk = (unsigned long)dmi_id->driver_data; quirk = (unsigned long)dmi_id->driver_data;
} else if (x86_match_cpu(baytrail_cpu_ids) && } else if (soc_intel_is_byt() &&
mach->mach_params.acpi_ipc_irq_index == 0) { mach->mach_params.acpi_ipc_irq_index == 0) {
/* On BYTCR default to SSP0, internal-mic-in2-map, mono-spk */ /* On BYTCR default to SSP0, internal-mic-in2-map, mono-spk */
quirk = BYT_CHT_ES8316_SSP0 | BYT_CHT_ES8316_INTMIC_IN2_MAP | quirk = BYT_CHT_ES8316_SSP0 | BYT_CHT_ES8316_INTMIC_IN2_MAP |
BYT_CHT_ES8316_MONO_SPEAKER; BYT_CHT_ES8316_MONO_SPEAKER;
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <linux/dmi.h> #include <linux/dmi.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/cpu_device_id.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
...@@ -38,6 +37,7 @@ ...@@ -38,6 +37,7 @@
#include "../../codecs/rt5640.h" #include "../../codecs/rt5640.h"
#include "../atom/sst-atom-controls.h" #include "../atom/sst-atom-controls.h"
#include "../common/sst-dsp.h" #include "../common/sst-dsp.h"
#include "../common/soc-intel-quirks.h"
enum { enum {
BYT_RT5640_DMIC1_MAP, BYT_RT5640_DMIC1_MAP,
...@@ -1130,18 +1130,6 @@ static struct snd_soc_card byt_rt5640_card = { ...@@ -1130,18 +1130,6 @@ static struct snd_soc_card byt_rt5640_card = {
.resume_post = byt_rt5640_resume, .resume_post = byt_rt5640_resume,
}; };
static bool is_valleyview(void)
{
static const struct x86_cpu_id cpu_ids[] = {
{ X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
{}
};
if (!x86_match_cpu(cpu_ids))
return false;
return true;
}
struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
u64 aif_value; /* 1: AIF1, 2: AIF2 */ u64 aif_value; /* 1: AIF1, 2: AIF2 */
u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */ u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */
...@@ -1190,7 +1178,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) ...@@ -1190,7 +1178,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
* swap SSP0 if bytcr is detected * swap SSP0 if bytcr is detected
* (will be overridden if DMI quirk is detected) * (will be overridden if DMI quirk is detected)
*/ */
if (is_valleyview()) { if (soc_intel_is_byt()) {
if (mach->mach_params.acpi_ipc_irq_index == 0) if (mach->mach_params.acpi_ipc_irq_index == 0)
is_bytcr = true; is_bytcr = true;
} }
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/gpio/machine.h> #include <linux/gpio/machine.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/cpu_device_id.h>
#include <asm/intel-family.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
...@@ -39,6 +37,7 @@ ...@@ -39,6 +37,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include "../../codecs/rt5651.h" #include "../../codecs/rt5651.h"
#include "../atom/sst-atom-controls.h" #include "../atom/sst-atom-controls.h"
#include "../common/soc-intel-quirks.h"
enum { enum {
BYT_RT5651_DMIC_MAP, BYT_RT5651_DMIC_MAP,
...@@ -852,16 +851,6 @@ static struct snd_soc_card byt_rt5651_card = { ...@@ -852,16 +851,6 @@ static struct snd_soc_card byt_rt5651_card = {
.resume_post = byt_rt5651_resume, .resume_post = byt_rt5651_resume,
}; };
static const struct x86_cpu_id baytrail_cpu_ids[] = {
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT }, /* Valleyview */
{}
};
static const struct x86_cpu_id cherrytrail_cpu_ids[] = {
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT }, /* Braswell */
{}
};
static const struct acpi_gpio_params ext_amp_enable_gpios = { 0, 0, false }; static const struct acpi_gpio_params ext_amp_enable_gpios = { 0, 0, false };
static const struct acpi_gpio_mapping cht_rt5651_gpios[] = { static const struct acpi_gpio_mapping cht_rt5651_gpios[] = {
...@@ -932,7 +921,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) ...@@ -932,7 +921,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
* swap SSP0 if bytcr is detected * swap SSP0 if bytcr is detected
* (will be overridden if DMI quirk is detected) * (will be overridden if DMI quirk is detected)
*/ */
if (x86_match_cpu(baytrail_cpu_ids)) { if (soc_intel_is_byt()) {
if (mach->mach_params.acpi_ipc_irq_index == 0) if (mach->mach_params.acpi_ipc_irq_index == 0)
is_bytcr = true; is_bytcr = true;
} }
...@@ -1001,7 +990,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) ...@@ -1001,7 +990,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
} }
/* Cherry Trail devices use an external amplifier enable gpio */ /* Cherry Trail devices use an external amplifier enable gpio */
if (x86_match_cpu(cherrytrail_cpu_ids) && !byt_rt5651_gpios) if (soc_intel_is_cht() && !byt_rt5651_gpios)
byt_rt5651_gpios = cht_rt5651_gpios; byt_rt5651_gpios = cht_rt5651_gpios;
if (byt_rt5651_gpios) { if (byt_rt5651_gpios) {
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/cpu_device_id.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
...@@ -34,6 +33,7 @@ ...@@ -34,6 +33,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include "../../codecs/rt5645.h" #include "../../codecs/rt5645.h"
#include "../atom/sst-atom-controls.h" #include "../atom/sst-atom-controls.h"
#include "../common/soc-intel-quirks.h"
#define CHT_PLAT_CLK_3_HZ 19200000 #define CHT_PLAT_CLK_3_HZ 19200000
#define CHT_CODEC_DAI1 "rt5645-aif1" #define CHT_CODEC_DAI1 "rt5645-aif1"
...@@ -509,18 +509,6 @@ static char cht_rt5645_codec_name[SND_ACPI_I2C_ID_LEN]; ...@@ -509,18 +509,6 @@ static char cht_rt5645_codec_name[SND_ACPI_I2C_ID_LEN];
static char cht_rt5645_codec_aif_name[12]; /* = "rt5645-aif[1|2]" */ static char cht_rt5645_codec_aif_name[12]; /* = "rt5645-aif[1|2]" */
static char cht_rt5645_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ static char cht_rt5645_cpu_dai_name[10]; /* = "ssp[0|2]-port" */
static bool is_valleyview(void)
{
static const struct x86_cpu_id cpu_ids[] = {
{ X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
{}
};
if (!x86_match_cpu(cpu_ids))
return false;
return true;
}
struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
u64 aif_value; /* 1: AIF1, 2: AIF2 */ u64 aif_value; /* 1: AIF1, 2: AIF2 */
u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */ u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */
...@@ -585,7 +573,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev) ...@@ -585,7 +573,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
* swap SSP0 if bytcr is detected * swap SSP0 if bytcr is detected
* (will be overridden if DMI quirk is detected) * (will be overridden if DMI quirk is detected)
*/ */
if (is_valleyview()) { if (soc_intel_is_byt()) {
if (mach->mach_params.acpi_ipc_irq_index == 0) if (mach->mach_params.acpi_ipc_irq_index == 0)
is_bytcr = true; is_bytcr = true;
} }
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <asm/cpu_device_id.h>
#include <asm/intel-family.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/jack.h> #include <sound/jack.h>
#include <sound/pcm.h> #include <sound/pcm.h>
...@@ -21,6 +19,7 @@ ...@@ -21,6 +19,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include "../../codecs/rt5682.h" #include "../../codecs/rt5682.h"
#include "../../codecs/hdac_hdmi.h" #include "../../codecs/hdac_hdmi.h"
#include "../common/soc-intel-quirks.h"
#define NAME_SIZE 32 #define NAME_SIZE 32
...@@ -304,12 +303,6 @@ static struct snd_soc_card sof_audio_card_rt5682 = { ...@@ -304,12 +303,6 @@ static struct snd_soc_card sof_audio_card_rt5682 = {
.late_probe = sof_card_late_probe, .late_probe = sof_card_late_probe,
}; };
static const struct x86_cpu_id legacy_cpi_ids[] = {
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT }, /* Baytrail */
{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT }, /* Cherrytrail */
{}
};
static struct snd_soc_dai_link_component rt5682_component[] = { static struct snd_soc_dai_link_component rt5682_component[] = {
{ {
.name = "i2c-10EC5682:00", .name = "i2c-10EC5682:00",
...@@ -498,7 +491,7 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -498,7 +491,7 @@ static int sof_audio_probe(struct platform_device *pdev)
if (!ctx) if (!ctx)
return -ENOMEM; return -ENOMEM;
if (x86_match_cpu(legacy_cpi_ids)) { if (soc_intel_is_byt() || soc_intel_is_cht()) {
is_legacy_cpu = 1; is_legacy_cpu = 1;
dmic_num = 0; dmic_num = 0;
hdmi_num = 0; hdmi_num = 0;
......
/* SPDX-License-Identifier: GPL-2.0 */
/*
* soc-intel-quirks.h - prototypes for quirk autodetection
*
* Copyright (c) 2019, Intel Corporation.
*
*/
#ifndef _SND_SOC_INTEL_QUIRKS_H
#define _SND_SOC_INTEL_QUIRKS_H
#if IS_ENABLED(CONFIG_X86)
#include <asm/cpu_device_id.h>
#include <asm/intel-family.h>
#include <asm/iosf_mbi.h>
#define ICPU(model) { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
#define SOC_INTEL_IS_CPU(soc, type) \
static inline bool soc_intel_is_##soc(void) \
{ \
static const struct x86_cpu_id soc##_cpu_ids[] = { \
ICPU(type), \
{} \
}; \
const struct x86_cpu_id *id; \
\
id = x86_match_cpu(soc##_cpu_ids); \
if (id) \
return true; \
return false; \
}
SOC_INTEL_IS_CPU(byt, INTEL_FAM6_ATOM_SILVERMONT);
SOC_INTEL_IS_CPU(cht, INTEL_FAM6_ATOM_AIRMONT);
SOC_INTEL_IS_CPU(apl, INTEL_FAM6_ATOM_GOLDMONT);
SOC_INTEL_IS_CPU(glk, INTEL_FAM6_ATOM_GOLDMONT_PLUS);
static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
int status = 0;
if (!soc_intel_is_byt())
return false;
if (iosf_mbi_available()) {
u32 bios_status;
status = iosf_mbi_read(BT_MBI_UNIT_PMC, /* 0x04 PUNIT */
MBI_REG_READ, /* 0x10 */
0x006, /* BIOS_CONFIG */
&bios_status);
if (status) {
dev_err(dev, "could not read PUNIT BIOS_CONFIG\n");
} else {
/* bits 26:27 mirror PMIC options */
bios_status = (bios_status >> 26) & 3;
if (bios_status == 1 || bios_status == 3) {
dev_info(dev, "Detected Baytrail-CR platform\n");
return true;
}
dev_info(dev, "BYT-CR not detected\n");
}
} else {
dev_info(dev, "IOSF_MBI not available, no BYT-CR detection\n");
}
if (!platform_get_resource(pdev, IORESOURCE_IRQ, 5)) {
/*
* Some devices detected as BYT-T have only a single IRQ listed,
* causing platform_get_irq with index 5 to return -ENXIO.
* The correct IRQ in this case is at index 0, as on BYT-CR.
*/
dev_info(dev, "Falling back to Baytrail-CR platform\n");
return true;
}
return false;
}
#else
static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
{
return false;
}
static inline bool soc_intel_is_byt(void)
{
return false;
}
static inline bool soc_intel_is_cht(void)
{
return false;
}
static inline bool soc_intel_is_apl(void)
{
return false;
}
static inline bool soc_intel_is_glk(void)
{
return false;
}
#endif
#endif /* _SND_SOC_INTEL_QUIRKS_H */
...@@ -15,10 +15,7 @@ ...@@ -15,10 +15,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h> #include <sound/soc-acpi-intel-match.h>
#include <sound/sof.h> #include <sound/sof.h>
#ifdef CONFIG_X86 #include "../intel/common/soc-intel-quirks.h"
#include <asm/iosf_mbi.h>
#endif
#include "ops.h" #include "ops.h"
/* platform specific devices */ /* platform specific devices */
...@@ -99,56 +96,6 @@ static const struct sof_dev_desc sof_acpi_baytrail_desc = { ...@@ -99,56 +96,6 @@ static const struct sof_dev_desc sof_acpi_baytrail_desc = {
.arch_ops = &sof_xtensa_arch_ops .arch_ops = &sof_xtensa_arch_ops
}; };
#ifdef CONFIG_X86 /* TODO: move this to common helper */
static bool is_byt_cr(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
int status;
if (iosf_mbi_available()) {
u32 bios_status;
status = iosf_mbi_read(BT_MBI_UNIT_PMC, /* 0x04 PUNIT */
MBI_REG_READ, /* 0x10 */
0x006, /* BIOS_CONFIG */
&bios_status);
if (status) {
dev_err(dev, "could not read PUNIT BIOS_CONFIG\n");
} else {
/* bits 26:27 mirror PMIC options */
bios_status = (bios_status >> 26) & 3;
if (bios_status == 1 || bios_status == 3) {
dev_info(dev, "Detected Baytrail-CR platform\n");
return true;
}
dev_info(dev, "BYT-CR not detected\n");
}
} else {
dev_info(dev, "IOSF_MBI not available, no BYT-CR detection\n");
}
if (platform_get_resource(pdev, IORESOURCE_IRQ, 5) == NULL) {
/*
* Some devices detected as BYT-T have only a single IRQ listed,
* causing platform_get_irq with index 5 to return -ENXIO.
* The correct IRQ in this case is at index 0, as on BYT-CR.
*/
dev_info(dev, "Falling back to Baytrail-CR platform\n");
return true;
}
return false;
}
#else
static int is_byt_cr(struct platform_device *pdev)
{
return 0;
}
#endif
static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { static const struct sof_dev_desc sof_acpi_cherrytrail_desc = {
.machines = snd_soc_acpi_intel_cherrytrail_machines, .machines = snd_soc_acpi_intel_cherrytrail_machines,
.resindex_lpe_base = 0, .resindex_lpe_base = 0,
...@@ -200,7 +147,7 @@ static int sof_acpi_probe(struct platform_device *pdev) ...@@ -200,7 +147,7 @@ static int sof_acpi_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL) #if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
if (desc == &sof_acpi_baytrail_desc && is_byt_cr(pdev)) if (desc == &sof_acpi_baytrail_desc && soc_intel_is_byt_cr(pdev))
desc = &sof_acpi_baytrailcr_desc; desc = &sof_acpi_baytrailcr_desc;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment