summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2015-03-09 15:44:15 +0800
committerHans de Goede <hdegoede@redhat.com>2015-03-10 15:20:25 +0100
commit1986c4ca0b250c83434aae985e74e05f96ccb1a4 (patch)
tree98f67cdd2a0cf2c70a8621899e8976c3ec2b86ca /drivers
parent5112703fddb0e851a11c6bc7722973522346e503 (diff)
downloadtalos-obmc-uboot-1986c4ca0b250c83434aae985e74e05f96ccb1a4.tar.gz
talos-obmc-uboot-1986c4ca0b250c83434aae985e74e05f96ccb1a4.zip
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/axp221.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c
index 3e07f23c20..c2c3988804 100644
--- a/drivers/power/axp221.c
+++ b/drivers/power/axp221.c
@@ -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;
OpenPOWER on IntegriCloud