]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
power: supply: axp20x_ac_power: Add wakeup control
authorSamuel Holland <samuel@sholland.org>
Mon, 13 Jan 2020 03:53:05 +0000 (21:53 -0600)
committerSebastian Reichel <sre@kernel.org>
Tue, 14 Jan 2020 00:00:41 +0000 (01:00 +0100)
commitca4c77bb43151e6569e7aae689a69b65a48c85f0
tree5cb19729e3d59d97caf71b5161c50ae93d1021d4
parentddfec18b42c44c4792071d67ae139e5b1f211410
power: supply: axp20x_ac_power: Add wakeup control

The AC power supply input can be used as a wakeup source. Hook up the
ACIN_PLUGIN IRQ to trigger wakeup based on userspace configuration.

To do this, we must remember the list of IRQs for the life of the
device. To know how much space to allocate for the flexible array
member, we switch from using a NULL sentinel to using an array length.

Because we now depend on the specific order of the IRQs (we assume
ACIN_PLUGIN is first and always present), failing to acquire an IRQ
during probe must be a fatal error.

To avoid spuriously waking up the system when the AC power supply is
not configured as a wakeup source, we must explicitly disable all non-
wake IRQs during system suspend. This is because the SoC's NMI input is
shared among all IRQs on the AXP PMIC. Due to the use of regmap-irq, the
individual IRQs within the PMIC are nested threaded interrupts, and are
therefore not automatically disabled during system suspend.

The upshot is that if any other device within the MFD (such as the power
key) is an enabled wakeup source, all enabled IRQs within the PMIC will
cause wakeup. We still need to call enable_irq_wake() when we *do* want
wakeup, in case those other wakeup sources on the PMIC are all disabled.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/axp20x_ac_power.c