summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c
index 9ae602ba56..c9bcb47fcd 100644
--- a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c
+++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c
@@ -23,15 +23,19 @@
23#include "power.h" 23#include "power.h"
24#include "cpu.h" 24#include "cpu.h"
25 25
26#define CHARGE_STAT_GPIO (32*1+6) /* STAT port */ 26#define CHARGE_STAT_GPIO (32*1+6) /* STAT port */
27#define PIN_USB_DET (32*4+19) /* USB connected */
27 28
28/* Detect which power sources are present. */ 29/* Detect which power sources are present. */
29unsigned int power_input_status(void) 30unsigned int power_input_status(void)
30{ 31{
32 int rval = POWER_INPUT_NONE;
33 if(!__gpio_get_pin(PIN_USB_DET))
34 rval |= POWER_INPUT_USB;
31 if(!__gpio_get_pin(CHARGE_STAT_GPIO)) 35 if(!__gpio_get_pin(CHARGE_STAT_GPIO))
32 return POWER_INPUT_USB_CHARGER; 36 rval |= POWER_INPUT_USB_CHARGER;
33 37
34 return POWER_INPUT_NONE; 38 return rval;
35} 39}
36 40
37void power_init(void) 41void power_init(void)
@@ -42,5 +46,5 @@ void power_init(void)
42 46
43bool charging_state(void) 47bool charging_state(void)
44{ 48{
45 return (power_input_status() == POWER_INPUT_USB_CHARGER); 49 return (power_input_status() & POWER_INPUT_USB_CHARGER);
46} 50}