[U-Boot] [PATCH 1/2] power: axp209: VBUS detect

Paul Kocialkowski contact at paulk.fr
Sun Mar 15 18:29:21 CET 2015


Signed-off-by: Paul Kocialkowski <contact at paulk.fr>
---
 drivers/power/axp209.c | 13 +++++++++++++
 include/axp209.h       |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c
index 4565398..11fe9d7 100644
--- a/drivers/power/axp209.c
+++ b/drivers/power/axp209.c
@@ -31,6 +31,7 @@ enum axp209_reg {
 };
 
 #define AXP209_POWER_STATUS_ON_BY_DC	(1 << 0)
+#define AXP209_POWER_STATUS_VBUS_USABLE	(1 << 4)
 
 #define AXP209_IRQ5_PEK_UP		(1 << 6)
 #define AXP209_IRQ5_PEK_DOWN		(1 << 5)
@@ -249,3 +250,15 @@ int axp_gpio_set_value(unsigned int pin, unsigned int val)
 {
 	return axp_gpio_direction_output(pin, val);
 }
+
+int axp_get_vbus(void)
+{
+	u8 val;
+	int rc;
+
+	rc = axp209_read(AXP209_POWER_STATUS, &val);
+	if (rc)
+		return rc;
+
+	return (val & AXP209_POWER_STATUS_VBUS_USABLE) ? 1 : 0;
+}
diff --git a/include/axp209.h b/include/axp209.h
index 0436249..a007958 100644
--- a/include/axp209.h
+++ b/include/axp209.h
@@ -5,6 +5,7 @@
  */
 
 #define AXP_GPIO
+#define AXP_VBUS_DETECT
 
 extern int axp209_set_dcdc2(int mvolt);
 extern int axp209_set_dcdc3(int mvolt);
@@ -19,3 +20,5 @@ extern int axp_gpio_direction_input(unsigned int pin);
 extern int axp_gpio_direction_output(unsigned int pin, unsigned int val);
 extern int axp_gpio_get_value(unsigned int pin);
 extern int axp_gpio_set_value(unsigned int pin, unsigned int val);
+
+extern int axp_get_vbus(void);
-- 
1.9.1



More information about the U-Boot mailing list