sunxi: axp221: Add VBUS detection support

Some of the AXP PMICs support VBUS detection, i.e. checking whether
VBUS power input is available and usable (supplied by an external
source). A few boards use this instead of a separate GPIO to detect
VBUS on USB OTG.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Chen-Yu Tsai
2015-03-09 15:44:15 +08:00
committed by Hans de Goede
parent 5112703fdd
commit 1986c4ca0b
2 changed files with 23 additions and 0 deletions

View File

@@ -385,6 +385,22 @@ int axp221_get_sid(unsigned int *sid)
return 0;
}
int axp_get_vbus(void)
{
int ret;
u8 val;
ret = axp221_init();
if (ret)
return ret;
ret = pmic_bus_read(AXP221_POWER_STATUS, &val);
if (ret)
return ret;
return (val & AXP221_POWER_STATUS_VBUS_USABLE) ? 1 : 0;
}
static int axp_drivebus_setup(void)
{
int ret;