linux-stable/drivers/acpi/pmic
Hans de Goede 009a789443 ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses
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>
2021-11-03 19:28:32 +01:00
..
Kconfig mfd: tps68470: Remove tps68470 MFD driver 2021-06-17 13:12:18 +02:00
Makefile ACPI / PMIC: Move TPS68470 OpRegion driver to drivers/acpi/pmic/ 2020-09-15 19:40:59 +02:00
intel_pmic.c ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses 2021-11-03 19:28:32 +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
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: fix various typos in comments 2021-03-19 17:45:49 +01:00
intel_pmic_chtdc_ti.c ACPI: scan: Extend acpi_walk_dep_device_list() 2021-06-07 16:45:05 +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 ACPI / PMIC: XPower: optimize MIPI PMIQ sequence I2C-bus accesses 2021-07-16 19:05:59 +02:00
tps68470_pmic.c ACPI / PMIC: Sort headers alphabetically 2018-09-10 12:57:04 +02:00