[alsa-devel] [PATCH v3 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 v3: - fixed typo in patch 5 (Jonathan) - returned back to if {} else {} condition in ASoC driver (Mark) - added Mark's Ack tag
Changelog v2: - removed RTC patches for now (the fix will be independent to this series) - 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 | 28 +----- 6 files changed, 93 insertions(+), 90 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 3867f81baae7..88675844b1ab 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 Acked-by: Mark Brown broonie@kernel.org --- 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);
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 Acked-by: Mark Brown broonie@kernel.org --- .../intel/common/soc-acpi-intel-cht-match.c | 28 ++----------------- 1 file changed, 3 insertions(+), 25 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..833d2e130e6e 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", @@ -43,9 +23,7 @@ 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) + if (x86_microsoft_surface_3_machine) return &cht_surface_mach; else return mach;
On Wed, Jan 22, 2020 at 01:22:57PM +0200, Andy Shevchenko wrote:
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.
Any comments on this?
Changelog v3:
- fixed typo in patch 5 (Jonathan)
- returned back to if {} else {} condition in ASoC driver (Mark)
- added Mark's Ack tag
Changelog v2:
- removed RTC patches for now (the fix will be independent to this series)
- 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 | 28 +----- 6 files changed, 93 insertions(+), 90 deletions(-) create mode 100644 include/linux/platform_data/x86/machine.h
-- 2.24.1
Andy Shevchenko andriy.shevchenko@linux.intel.com writes:
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.
[...]
x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper x86/quirks: Join string literals back
These two don't seem to be related to the Surface 3 cause of the rest of the patchset, or am I missing something?
Regards, -- Alex
On Mon, Mar 16, 2020 at 05:33:02PM +0200, Alexander Shishkin wrote:
Andy Shevchenko andriy.shevchenko@linux.intel.com writes:
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.
[...]
x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper x86/quirks: Join string literals back
These two don't seem to be related to the Surface 3 cause of the rest of the patchset, or am I missing something?
No, they are not. I think it's suitable to have them in the bunch nevertheless.
participants (2)
-
Alexander Shishkin
-
Andy Shevchenko