From patchwork Mon Oct 18 14:33:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12566697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5DB0C433FE for ; Mon, 18 Oct 2021 14:33:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D12F060FC3 for ; Mon, 18 Oct 2021 14:33:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbhJROfv (ORCPT ); Mon, 18 Oct 2021 10:35:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55288 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232070AbhJROft (ORCPT ); Mon, 18 Oct 2021 10:35:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634567618; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MtOt2G1AbFPCyxAIQiN50xyT2qR4olmNXpVpaio5XjY=; b=RSmqoZj9JxFwGJZz2swhoZ//HPNMDxAyda9UBulL4tNvpx0XK/7oxAVlDyJLya3XUXnBuu 6C6gZnz7nxbgrHQwWBtuTfSnYUY7N7ItXNNoGpKcfOAcYLO5tRVUnfutTtr1++19S5IwXL VWrX/dwvsKG3SJL39RgRg2CsZDGsVfs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-OiA0BEUJMDe5QDn69uqnBQ-1; Mon, 18 Oct 2021 10:33:34 -0400 X-MC-Unique: OiA0BEUJMDe5QDn69uqnBQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2DD1EC1A1; Mon, 18 Oct 2021 14:33:31 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72473100E809; Mon, 18 Oct 2021 14:33:29 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov , Mark Gross , Andy Shevchenko , Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Mark Brown Cc: Hans de Goede , linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, alsa-devel@alsa-project.org, Andy Shevchenko Subject: [PATCH 1/3] ASoC: Intel: Move soc_intel_is_foo() helpers to a generic header Date: Mon, 18 Oct 2021 16:33:22 +0200 Message-Id: <20211018143324.296961-2-hdegoede@redhat.com> In-Reply-To: <20211018143324.296961-1-hdegoede@redhat.com> References: <20211018143324.296961-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The soc_intel_is_foo() helpers from sound/soc/intel/common/soc-intel-quirks.h are useful outside of the sound subsystem too. Move these to include/linux/platform_data/x86/soc.h, so that other code can use them too. Suggested-by: Andy Shevchenko Signed-off-by: Hans de Goede Acked-by: Mark Brown --- include/linux/platform_data/x86/soc.h | 65 +++++++++++++++++++++++ sound/soc/intel/common/soc-intel-quirks.h | 51 ++---------------- 2 files changed, 68 insertions(+), 48 deletions(-) create mode 100644 include/linux/platform_data/x86/soc.h diff --git a/include/linux/platform_data/x86/soc.h b/include/linux/platform_data/x86/soc.h new file mode 100644 index 000000000000..8d710834e87a --- /dev/null +++ b/include/linux/platform_data/x86/soc.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * soc.h - helpers for Intel SoC model detection + * + * Copyright (c) 2019, Intel Corporation. + */ + +#ifndef __PLATFORM_DATA_X86_SOC_H +#define __PLATFORM_DATA_X86_SOC_H + +#if IS_ENABLED(CONFIG_X86) + +#include +#include + +#define SOC_INTEL_IS_CPU(soc, type) \ +static inline bool soc_intel_is_##soc(void) \ +{ \ + static const struct x86_cpu_id soc##_cpu_ids[] = { \ + X86_MATCH_INTEL_FAM6_MODEL(type, NULL), \ + {} \ + }; \ + const struct x86_cpu_id *id; \ + \ + id = x86_match_cpu(soc##_cpu_ids); \ + if (id) \ + return true; \ + return false; \ +} + +SOC_INTEL_IS_CPU(byt, ATOM_SILVERMONT); +SOC_INTEL_IS_CPU(cht, ATOM_AIRMONT); +SOC_INTEL_IS_CPU(apl, ATOM_GOLDMONT); +SOC_INTEL_IS_CPU(glk, ATOM_GOLDMONT_PLUS); +SOC_INTEL_IS_CPU(cml, KABYLAKE_L); + +#else /* IS_ENABLED(CONFIG_X86) */ + +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; +} + +static inline bool soc_intel_is_cml(void) +{ + return false; +} +#endif /* IS_ENABLED(CONFIG_X86) */ + +#endif /* __PLATFORM_DATA_X86_SOC_H */ diff --git a/sound/soc/intel/common/soc-intel-quirks.h b/sound/soc/intel/common/soc-intel-quirks.h index a93987ab7f4d..de4e550c5b34 100644 --- a/sound/soc/intel/common/soc-intel-quirks.h +++ b/sound/soc/intel/common/soc-intel-quirks.h @@ -9,34 +9,13 @@ #ifndef _SND_SOC_INTEL_QUIRKS_H #define _SND_SOC_INTEL_QUIRKS_H +#include + #if IS_ENABLED(CONFIG_X86) #include -#include -#include #include -#define SOC_INTEL_IS_CPU(soc, type) \ -static inline bool soc_intel_is_##soc(void) \ -{ \ - static const struct x86_cpu_id soc##_cpu_ids[] = { \ - X86_MATCH_INTEL_FAM6_MODEL(type, NULL), \ - {} \ - }; \ - const struct x86_cpu_id *id; \ - \ - id = x86_match_cpu(soc##_cpu_ids); \ - if (id) \ - return true; \ - return false; \ -} - -SOC_INTEL_IS_CPU(byt, ATOM_SILVERMONT); -SOC_INTEL_IS_CPU(cht, ATOM_AIRMONT); -SOC_INTEL_IS_CPU(apl, ATOM_GOLDMONT); -SOC_INTEL_IS_CPU(glk, ATOM_GOLDMONT_PLUS); -SOC_INTEL_IS_CPU(cml, KABYLAKE_L); - static inline bool soc_intel_is_byt_cr(struct platform_device *pdev) { /* @@ -114,30 +93,6 @@ 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; -} - -static inline bool soc_intel_is_cml(void) -{ - return false; -} #endif - #endif /* _SND_SOC_INTEL_QUIRKS_H */ +#endif /* _SND_SOC_INTEL_QUIRKS_H */ From patchwork Mon Oct 18 14:33:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12566699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9D16C4332F for ; Mon, 18 Oct 2021 14:33:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A45DC60F93 for ; Mon, 18 Oct 2021 14:33:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232085AbhJROfv (ORCPT ); Mon, 18 Oct 2021 10:35:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45564 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232006AbhJROfs (ORCPT ); Mon, 18 Oct 2021 10:35:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634567616; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fUHl/wiNGmL1WcumGPQQzjf2AYhwqIpOf+nBqQEoFos=; b=ayA/4r/gKACmV/IiV9EGnVo+85SNcz4r9ddvDfuPMx/fEffV241BP4sFIzsAyZ/mPqXoLL XqNLW+8j8SU94UA+FzEEFZQ8k13xpTwweZhxdA+uFG2asTnYJ4D/7TS4bqLzkzTM9B5ffC m3iShPUDwQo4zH+5ok9bcP4Y8VfpkR0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-354-tbuaPWhaPt-Aq6-I7kK5xw-1; Mon, 18 Oct 2021 10:33:35 -0400 X-MC-Unique: tbuaPWhaPt-Aq6-I7kK5xw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17A6810168D0; Mon, 18 Oct 2021 14:33:34 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AAC2100EA05; Mon, 18 Oct 2021 14:33:31 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov , Mark Gross , Andy Shevchenko , Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Mark Brown Cc: Hans de Goede , linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 2/3] platform/x86: intel_int0002_vgpio: Use the new soc_intel_is_byt/cht helpers Date: Mon, 18 Oct 2021 16:33:23 +0200 Message-Id: <20211018143324.296961-3-hdegoede@redhat.com> In-Reply-To: <20211018143324.296961-1-hdegoede@redhat.com> References: <20211018143324.296961-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Use the new soc_intel_is_byt/cht helpers to clean things up a bit. Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int0002_vgpio.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/intel/int0002_vgpio.c b/drivers/platform/x86/intel/int0002_vgpio.c index 569342aa8926..617dbf98980e 100644 --- a/drivers/platform/x86/intel/int0002_vgpio.c +++ b/drivers/platform/x86/intel/int0002_vgpio.c @@ -34,13 +34,11 @@ #include #include #include +#include #include #include #include -#include -#include - #define DRV_NAME "INT0002 Virtual GPIO" /* For some reason the virtual GPIO pin tied to the GPE is numbered pin 2 */ @@ -151,12 +149,6 @@ static struct irq_chip int0002_irqchip = { .irq_set_wake = int0002_irq_set_wake, }; -static const struct x86_cpu_id int0002_cpu_ids[] = { - X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, NULL), - X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, NULL), - {} -}; - static void int0002_init_irq_valid_mask(struct gpio_chip *chip, unsigned long *valid_mask, unsigned int ngpios) @@ -167,15 +159,13 @@ static void int0002_init_irq_valid_mask(struct gpio_chip *chip, static int int0002_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - const struct x86_cpu_id *cpu_id; struct int0002_data *int0002; struct gpio_irq_chip *girq; struct gpio_chip *chip; int irq, ret; /* Menlow has a different INT0002 device? */ - cpu_id = x86_match_cpu(int0002_cpu_ids); - if (!cpu_id) + if (!soc_intel_is_byt() && !soc_intel_is_cht()) return -ENODEV; irq = platform_get_irq(pdev, 0); From patchwork Mon Oct 18 14:33:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12566701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6184BC433EF for ; Mon, 18 Oct 2021 14:33:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4980860FED for ; Mon, 18 Oct 2021 14:33:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232079AbhJROfx (ORCPT ); Mon, 18 Oct 2021 10:35:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58231 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbhJROfx (ORCPT ); Mon, 18 Oct 2021 10:35:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634567621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PHKzH/wajaDyRcGRKJtdJRiyxCohYfbn/RZQ0IVry88=; b=HgwesVgWWbnkfrQeQ4pE+//sweBZ83azsU4p7gEs1Asssy9vFH6Eu0wu9NTu4R4Ke0KUzS YE7WPDm8orhVUK9/EPjXRKg5GRvoWlM3KwL9A4LR6C/bMPP03AEabdBsv4zHpWHTneSjPl 8oqQkjNzMLVw2CTV3HdU9zQf/yvcboo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-506-nhARz-PKMzSzGCKpsEchYw-1; Mon, 18 Oct 2021 10:33:38 -0400 X-MC-Unique: nhARz-PKMzSzGCKpsEchYw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F33FB10168D0; Mon, 18 Oct 2021 14:33:36 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76EE4100E809; Mon, 18 Oct 2021 14:33:34 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov , Mark Gross , Andy Shevchenko , Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Mark Brown Cc: Hans de Goede , linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 3/3] Input: axp20x-pek - Use new soc_intel_is_cht() helper Date: Mon, 18 Oct 2021 16:33:24 +0200 Message-Id: <20211018143324.296961-4-hdegoede@redhat.com> In-Reply-To: <20211018143324.296961-1-hdegoede@redhat.com> References: <20211018143324.296961-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Use the new soc_intel_is_cht() helper to find out if we are running on a CHT device rather then checking the ACPI _HRV field. This is more reliable (some CHT devices have been found where the _HRV for the PMIC is 2 rather then 3) and leads to a nice cleanup. Signed-off-by: Hans de Goede Acked-by: Dmitry Torokhov --- drivers/input/misc/axp20x-pek.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c index 9c6386b2af33..e09b1fae42e1 100644 --- a/drivers/input/misc/axp20x-pek.c +++ b/drivers/input/misc/axp20x-pek.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -255,41 +256,24 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek, return 0; } -#ifdef CONFIG_ACPI -static bool axp20x_pek_should_register_input(struct axp20x_pek *axp20x_pek, - struct platform_device *pdev) +static bool axp20x_pek_should_register_input(struct axp20x_pek *axp20x_pek) { - unsigned long long hrv = 0; - acpi_status status; - if (IS_ENABLED(CONFIG_INPUT_SOC_BUTTON_ARRAY) && axp20x_pek->axp20x->variant == AXP288_ID) { - status = acpi_evaluate_integer(ACPI_HANDLE(pdev->dev.parent), - "_HRV", NULL, &hrv); - if (ACPI_FAILURE(status)) - dev_err(&pdev->dev, "Failed to get PMIC hardware revision\n"); - /* * On Cherry Trail platforms (hrv == 3), do not register the * input device if there is an "INTCFD9" or "ACPI0011" gpio * button ACPI device, as that handles the power button too, * and otherwise we end up reporting all presses twice. */ - if (hrv == 3 && (acpi_dev_present("INTCFD9", NULL, -1) || + if (soc_intel_is_cht() && + (acpi_dev_present("INTCFD9", NULL, -1) || acpi_dev_present("ACPI0011", NULL, -1))) return false; - } return true; } -#else -static bool axp20x_pek_should_register_input(struct axp20x_pek *axp20x_pek, - struct platform_device *pdev) -{ - return true; -} -#endif static int axp20x_pek_probe(struct platform_device *pdev) { @@ -321,7 +305,7 @@ static int axp20x_pek_probe(struct platform_device *pdev) axp20x_pek->irq_dbf = regmap_irq_get_virq( axp20x_pek->axp20x->regmap_irqc, axp20x_pek->irq_dbf); - if (axp20x_pek_should_register_input(axp20x_pek, pdev)) { + if (axp20x_pek_should_register_input(axp20x_pek)) { error = axp20x_pek_probe_input_device(axp20x_pek, pdev); if (error) return error;