[alsa-devel] [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3
While working on RTC regression, I noticed that we are using the same DMI check over and over in the drivers for MS Surface 3 platform. This series dedicated for making it easier in the same way how it's done for Apple machines.
Changelog v2: - removed RTC patches for now - added couple more clean ups to arch/x86/kernel/quirks.c - redone DMI quirk to use driver_data instead of callback - simplified check in soc-acpi-intel-cht-match.c to be oneliner - added a new patch to cover rt5645 codec driver
Cc: Cezary Rojewski cezary.rojewski@intel.com Cc: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Cc: Liam Girdwood liam.r.girdwood@linux.intel.com Cc: Jie Yang yang.jie@linux.intel.com Cc: Mark Brown broonie@kernel.org Cc: alsa-devel@alsa-project.org
Andy Shevchenko (9): x86/platform: Rename x86/apple.h -> x86/machine.h x86/quirks: Add missed include to satisfy static checker x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper x86/quirks: Join string literals back x86/quirks: Convert DMI matching to use a table x86/quirks: Add a DMI quirk for Microsoft Surface 3 platform/x86: surface3_wmi: Switch DMI table match to a test of variable ASoC: rt5645: Switch DMI table match to a test of variable ASoC: Intel: Switch DMI table match to a test of variable
arch/x86/kernel/quirks.c | 91 +++++++++++++------ drivers/platform/x86/surface3-wmi.c | 16 +--- include/linux/platform_data/x86/apple.h | 14 +-- include/linux/platform_data/x86/machine.h | 20 ++++ sound/soc/codecs/rt5645.c | 14 ++- .../intel/common/soc-acpi-intel-cht-match.c | 33 +------ 6 files changed, 93 insertions(+), 95 deletions(-) create mode 100644 include/linux/platform_data/x86/machine.h
Add a DMI quirk for Microsoft Surface 3 which will be utilized by few drivers.
Cc: Cezary Rojewski cezary.rojewski@intel.com Cc: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Cc: Liam Girdwood liam.r.girdwood@linux.intel.com Cc: Jie Yang yang.jie@linux.intel.com Cc: Mark Brown broonie@kernel.org Cc: alsa-devel@alsa-project.org Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com --- arch/x86/kernel/quirks.c | 10 ++++++++++ include/linux/platform_data/x86/machine.h | 5 +++++ 2 files changed, 15 insertions(+)
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c index 78846a8dc88b..501fbcd16282 100644 --- a/arch/x86/kernel/quirks.c +++ b/arch/x86/kernel/quirks.c @@ -658,6 +658,9 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras bool x86_apple_machine; EXPORT_SYMBOL(x86_apple_machine);
+bool x86_microsoft_surface_3_machine; +EXPORT_SYMBOL(x86_microsoft_surface_3_machine); + static const struct dmi_system_id x86_machine_table[] __initconst = { { .ident = "x86 Apple Macintosh", @@ -673,6 +676,13 @@ static const struct dmi_system_id x86_machine_table[] __initconst = { }, .driver_data = &x86_apple_machine, }, + { + .ident = "Microsoft Surface 3", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"), + }, + .driver_data = &x86_microsoft_surface_3_machine, + }, {} };
diff --git a/include/linux/platform_data/x86/machine.h b/include/linux/platform_data/x86/machine.h index b1e7a560a046..9bdf5a06b490 100644 --- a/include/linux/platform_data/x86/machine.h +++ b/include/linux/platform_data/x86/machine.h @@ -8,8 +8,13 @@ * x86_apple_machine - whether the machine is an x86 Apple Macintosh */ extern bool x86_apple_machine; +/** + * x86_microsoft_surface_3_machine - whether the machine is Microsoft Surface 3 + */ +extern bool x86_microsoft_surface_3_machine; #else #define x86_apple_machine false +#define x86_microsoft_surface_3_machine false #endif
#endif /* PLATFORM_DATA_X86_MACHINE_H */
Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.
Note, arch/x86/kernel/quirks.c::early_platform_detect_quirk() prints the detected platform.
Cc: Cezary Rojewski cezary.rojewski@intel.com Cc: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Cc: Liam Girdwood liam.r.girdwood@linux.intel.com Cc: Jie Yang yang.jie@linux.intel.com Cc: Mark Brown broonie@kernel.org Cc: alsa-devel@alsa-project.org Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com --- sound/soc/codecs/rt5645.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 92d67010aeed..3ccecb81bc37 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -12,6 +12,7 @@ #include <linux/delay.h> #include <linux/pm.h> #include <linux/i2c.h> +#include <linux/platform_data/x86/machine.h> #include <linux/platform_device.h> #include <linux/spi/spi.h> #include <linux/gpio.h> @@ -3674,13 +3675,6 @@ static const struct dmi_system_id dmi_platform_data[] = { }, .driver_data = (void *)&intel_braswell_platform_data, }, - { - .ident = "Microsoft Surface 3", - .matches = { - DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"), - }, - .driver_data = (void *)&intel_braswell_platform_data, - }, { /* * Match for the GPDwin which unfortunately uses somewhat @@ -3789,7 +3783,7 @@ static int rt5645_parse_dt(struct rt5645_priv *rt5645, struct device *dev) static int rt5645_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev); + const struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev); const struct dmi_system_id *dmi_data; struct rt5645_priv *rt5645; int ret, i; @@ -3804,6 +3798,10 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, rt5645->i2c = i2c; i2c_set_clientdata(i2c, rt5645);
+ /* Put it first to allow DMI to override, if needed */ + if (x86_microsoft_surface_3_machine) + pdata = &intel_braswell_platform_data; + dmi_data = dmi_first_match(dmi_platform_data); if (dmi_data) { dev_info(&i2c->dev, "Detected %s platform\n", dmi_data->ident);
On Mon, Jan 20, 2020 at 06:08:00PM +0200, Andy Shevchenko wrote:
Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.
Acked-by: Mark Brown broonie@kernel.org
Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.
Cc: Cezary Rojewski cezary.rojewski@intel.com Cc: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Cc: Liam Girdwood liam.r.girdwood@linux.intel.com Cc: Jie Yang yang.jie@linux.intel.com Cc: Mark Brown broonie@kernel.org Cc: alsa-devel@alsa-project.org Signed-off-by: Andy Shevchenko andriy.shevchenko@linux.intel.com --- .../intel/common/soc-acpi-intel-cht-match.c | 33 ++----------------- 1 file changed, 3 insertions(+), 30 deletions(-)
diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c index d0fb43c2b9f6..c35766125d5e 100644 --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c @@ -5,31 +5,11 @@ * Copyright (c) 2017, Intel Corporation. */
-#include <linux/dmi.h> +#include <linux/platform_data/x86/machine.h> + #include <sound/soc-acpi.h> #include <sound/soc-acpi-intel-match.h>
-static unsigned long cht_machine_id; - -#define CHT_SURFACE_MACH 1 - -static int cht_surface_quirk_cb(const struct dmi_system_id *id) -{ - cht_machine_id = CHT_SURFACE_MACH; - return 1; -} - -static const struct dmi_system_id cht_table[] = { - { - .callback = cht_surface_quirk_cb, - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), - DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"), - }, - }, - { } -}; - static struct snd_soc_acpi_mach cht_surface_mach = { .id = "10EC5640", .drv_name = "cht-bsw-rt5645", @@ -41,14 +21,7 @@ static struct snd_soc_acpi_mach cht_surface_mach = {
static struct snd_soc_acpi_mach *cht_quirk(void *arg) { - struct snd_soc_acpi_mach *mach = arg; - - dmi_check_system(cht_table); - - if (cht_machine_id == CHT_SURFACE_MACH) - return &cht_surface_mach; - else - return mach; + return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg; }
/* Cherryview-based platforms: CherryTrail and Braswell */
On Mon, Jan 20, 2020 at 06:08:01PM +0200, Andy Shevchenko wrote:
Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.
Acked-by: Mark Brown broonie@kernel.org
- if (cht_machine_id == CHT_SURFACE_MACH)
return &cht_surface_mach;
- else
return mach;
- return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg;
but if you're respinning this please replace this with a normal conditional statement to improve legibility.
On Mon, Jan 20, 2020 at 05:55:54PM +0000, Mark Brown wrote:
On Mon, Jan 20, 2020 at 06:08:01PM +0200, Andy Shevchenko wrote:
Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.
Acked-by: Mark Brown broonie@kernel.org
- if (cht_machine_id == CHT_SURFACE_MACH)
return &cht_surface_mach;
- else
return mach;
- return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg;
but if you're respinning this please replace this with a normal conditional statement to improve legibility.
Okay, will do. Thanks for review!
participants (2)
-
Andy Shevchenko
-
Mark Brown