power: supply: bq25890: Add HiZ mode support
authorMarek Vasut <marex@denx.de>
Mon, 28 Nov 2022 09:28:51 +0000 (10:28 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 2 Jan 2023 23:04:26 +0000 (00:04 +0100)
commitc688e0c436cb5292285a193134346fcdaaa3a56d
tree42de0f7fe36d8f06b4fb69f3d3cccf95d83e4d50
parentd1b25092b3dce96a69fc31b462e61291848fda9f
power: supply: bq25890: Add HiZ mode support

The bq25890 is capable of disconnecting itself from the external supply,
in which case the system is supplied only from the battery. This can be
useful e.g. to test the pure battery operation, or draw no power from
USB port.

Implement support for this mode, which can be toggled by writing 0 or
non-zero to sysfs 'online' attribute, to select either offline or online
mode.

The IRQ handler has to be triggered to update chip state, as switching
to and from HiZ mode does not generate an interrupt automatically.

The IRQ handler reinstates the HiZ mode in case a cable is replugged by
the user, the chip itself clears the HiZ mode bit when cable is plugged
in by the user and the chip detects PG bad-to-good transition.

Signed-off-by: Marek Vasut <marex@denx.de>
[hdegoede@redhat.com: Replace "&" with "&&" in a boolean check]
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/bq25890_charger.c