]> git.baikalelectronics.ru Git - kernel.git/commit
power: supply: axp20x_usb_power: Only poll while offline
authorSamuel Holland <samuel@sholland.org>
Wed, 15 Jan 2020 03:40:48 +0000 (21:40 -0600)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 15 Jan 2020 20:41:38 +0000 (21:41 +0100)
commit118a5a998d62cf69e9414ec9929f83f51b4b8f9d
treee6b2b47487a7f4aaf6db2fd08f4e605e643b0348
parentaf6011b51e6bacd82ceb818c9ba0f042920ae1b5
power: supply: axp20x_usb_power: Only poll while offline

Investigation on the AXP803 shows that VBUS_PLUGIN/VBUS_REMOVAL IRQs are
triggered on the rising/falling edge of AXP20X_PWR_STATUS_VBUS_USED. The
reason IRQs do not arrive while N_VBUSEN/DRIVEVBUS is high is because
AXP20X_PWR_STATUS_VBUS_USED also never goes high.

This also means that if VBUS is online, a VBUS_REMOVAL IRQ is received
immediately on setting N_VBUSEN/DRIVEVBUS high (and VBUS_PLUGIN shortly
after it is set back low). This was also verified to be the case when
manually offlining VBUS through AXP20X_VBUS_PATH_SELECT.

As long as VBUS is online, a present->absent transition necessarily
implies an online->offline transition. Since will cause an IRQ, there is
no need to poll while VBUS is online.

To ensure the driver's view of VBUS online status remains accurate,
unconditionally poll once when receiving an IRQ and when resuming. If
VBUS is still online at that time, polling will cease until the next
VBUS_REMOVAL IRQ.

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_usb_power.c