Input: axp20x-pek - Use new soc_intel_is_cht() helper

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.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211018143324.296961-4-hdegoede@redhat.com
This commit is contained in:
Hans de Goede 2021-10-18 16:33:24 +02:00
parent 693841b742
commit 5ecc1e9478

View File

@ -22,6 +22,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mfd/axp20x.h> #include <linux/mfd/axp20x.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_data/x86/soc.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
@ -255,41 +256,24 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
return 0; return 0;
} }
#ifdef CONFIG_ACPI static bool axp20x_pek_should_register_input(struct axp20x_pek *axp20x_pek)
static bool axp20x_pek_should_register_input(struct axp20x_pek *axp20x_pek,
struct platform_device *pdev)
{ {
unsigned long long hrv = 0;
acpi_status status;
if (IS_ENABLED(CONFIG_INPUT_SOC_BUTTON_ARRAY) && if (IS_ENABLED(CONFIG_INPUT_SOC_BUTTON_ARRAY) &&
axp20x_pek->axp20x->variant == AXP288_ID) { 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 * On Cherry Trail platforms (hrv == 3), do not register the
* input device if there is an "INTCFD9" or "ACPI0011" gpio * input device if there is an "INTCFD9" or "ACPI0011" gpio
* button ACPI device, as that handles the power button too, * button ACPI device, as that handles the power button too,
* and otherwise we end up reporting all presses twice. * 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))) acpi_dev_present("ACPI0011", NULL, -1)))
return false; return false;
} }
return true; 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) 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->irq_dbf = regmap_irq_get_virq(
axp20x_pek->axp20x->regmap_irqc, axp20x_pek->irq_dbf); 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); error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
if (error) if (error)
return error; return error;