linux/drivers/acpi
Hans de Goede dce69e0a06 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-17 09:48:47 +01:00
..
acpica ACPICA: Avoid evaluating methods too early during system resume 2021-11-17 09:48:30 +01:00
apei
arm64 acpi/arm64: fix next_platform_timer() section mismatch error 2021-10-20 11:40:17 +02:00
dptf
hmat
nfit ACPI: NFIT: Fix support for virtual SPA ranges 2021-08-18 08:56:57 +02:00
pmic ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses 2021-11-17 09:48:47 +01:00
x86
ac.c
acpi_adxl.c
acpi_amba.c
acpi_apd.c
acpi_cmos_rtc.c
acpi_configfs.c
acpi_dbg.c
acpi_extlog.c
acpi_ipmi.c
acpi_lpat.c
acpi_lpit.c
acpi_lpss.c
acpi_memhotplug.c
acpi_pad.c
acpi_platform.c
acpi_pnp.c
acpi_processor.c
acpi_tad.c
acpi_video.c
acpi_watchdog.c
battery.c ACPI: battery: Accept charges over the design capacity as full 2021-11-17 09:48:30 +01:00
bgrt.c
blacklist.c
bus.c
button.c
cm_sbs.c
container.c
cppc_acpi.c
custom_method.c
debugfs.c
device_pm.c
device_sysfs.c
dock.c
ec_sys.c
ec.c
event.c
evged.c
fan.c
glue.c
hed.c
internal.h
ioapic.c
irq.c
Kconfig
Makefile
numa.c
nvs.c
osi.c
osl.c
pci_irq.c
pci_link.c
pci_mcfg.c PCI/ACPI: Add Ampere Altra SOC MCFG quirk 2021-09-26 14:07:05 +02:00
pci_root.c
pci_slot.c
power.c
pptt.c
proc.c
processor_core.c
processor_driver.c
processor_idle.c
processor_pdc.c
processor_perflib.c
processor_thermal.c
processor_throttling.c
property.c
reboot.c
resource.c Revert "ACPI: resources: Add checks for ACPI IRQ override" 2021-08-04 12:27:37 +02:00
sbs.c
sbshc.c
sbshc.h
scan.c
sleep.c
sleep.h
spcr.c
sysfs.c
tables.c
thermal.c
utils.c
video_detect.c
wakeup.c