public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] power: axp209: VBUS detect
@ 2015-03-15 17:29 Paul Kocialkowski
  2015-03-15 17:29 ` [U-Boot] [PATCH 2/2] sunxi: Ainol AW1 support Paul Kocialkowski
  2015-03-21 12:01 ` [U-Boot] [PATCH 1/2] power: axp209: VBUS detect Hans de Goede
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Kocialkowski @ 2015-03-15 17:29 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Paul Kocialkowski <contact@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-21 12:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-15 17:29 [U-Boot] [PATCH 1/2] power: axp209: VBUS detect Paul Kocialkowski
2015-03-15 17:29 ` [U-Boot] [PATCH 2/2] sunxi: Ainol AW1 support Paul Kocialkowski
2015-03-21 12:03   ` Hans de Goede
2015-03-21 12:01 ` [U-Boot] [PATCH 1/2] power: axp209: VBUS detect Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox