kernel_optimize_test/drivers/acpi/pmic
Hans de Goede ee8a3ae48a ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses
[ Upstream commit 009a789443fe4c8e6b1ecb7c16b4865c026184cd ]

The handling of PMIC register reads through writing 0 to address 4
of the OpRegion is wrong. Instead of returning the read value
through the value64, which is a no-op for function == ACPI_WRITE calls,
store the value and then on a subsequent function == ACPI_READ with
address == 3 (the address for the value field of the OpRegion)
return the stored value.

This has been tested on a Xiaomi Mi Pad 2 and makes the ACPI battery dev
there mostly functional (unfortunately there are still other issues).

Here are the SET() / GET() functions of the PMIC ACPI device,
which use this OpRegion, which clearly show the new behavior to
be correct:

OperationRegion (REGS, 0x8F, Zero, 0x50)
Field (REGS, ByteAcc, NoLock, Preserve)
{
    CLNT,   8,
    SA,     8,
    OFF,    8,
    VAL,    8,
    RWM,    8
}

Method (GET, 3, Serialized)
{
    If ((AVBE == One))
    {
        CLNT = Arg0
        SA = Arg1
        OFF = Arg2
        RWM = Zero
        If ((AVBG == One))
        {
            GPRW = Zero
        }
    }

    Return (VAL) /* \_SB_.PCI0.I2C7.PMI5.VAL_ */
}

Method (SET, 4, Serialized)
{
    If ((AVBE == One))
    {
        CLNT = Arg0
        SA = Arg1
        OFF = Arg2
        VAL = Arg3
        RWM = One
        If ((AVBG == One))
        {
            GPRW = One
        }
    }
}

Fixes: 0afa877a56 ("ACPI / PMIC: intel: add REGS operation region support")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-18 14:04:26 +01:00
..
intel_pmic_bxtwc.c ACPI / PMIC: Convert drivers to use SPDX identifier 2018-09-10 12:57:55 +02:00
intel_pmic_bytcrc.c ACPI / PMIC: Add byt prefix to Crystal Cove PMIC OpRegion driver 2019-10-25 11:43:08 +02:00
intel_pmic_chtcrc.c ACPI / PMIC: Add Cherry Trail Crystal Cove PMIC OpRegion driver 2019-10-25 11:43:08 +02:00
intel_pmic_chtdc_ti.c ACPI / PMIC: Add i2c address for thermal control 2020-05-18 12:57:24 +02:00
intel_pmic_chtwc.c ACPI / PMIC: Implement exec_mipi_pmic_seq_element for CHT Whiskey Cove PMIC 2019-01-09 10:35:03 +01:00
intel_pmic_xpower.c Linux 5.0-rc7 2019-02-18 13:27:15 +10:00
intel_pmic.c ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses 2021-11-18 14:04:26 +01:00
intel_pmic.h ACPI / PMIC: Add generic intel_soc_pmic_exec_mipi_pmic_seq_element handling 2019-01-09 10:35:03 +01:00
Kconfig ACPI / PMIC: Move TPS68470 OpRegion driver to drivers/acpi/pmic/ 2020-09-15 19:40:59 +02:00
Makefile ACPI / PMIC: Move TPS68470 OpRegion driver to drivers/acpi/pmic/ 2020-09-15 19:40:59 +02:00
tps68470_pmic.c ACPI / PMIC: Sort headers alphabetically 2018-09-10 12:57:04 +02:00