From f3026cd07221b45079952546a94631e25908f4fc Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 2 Nov 2024 20:53:46 -0400 Subject: xduoox3: Try to distinguish between "USB Plugged in" and "Charging" Change-Id: I1879dbe6a95df215afa32012a72e1431c03a8653 --- .../target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c | 12 ++++++++---- 1 file 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 @@ #include "power.h" #include "cpu.h" -#define CHARGE_STAT_GPIO (32*1+6) /* STAT port */ +#define CHARGE_STAT_GPIO (32*1+6) /* STAT port */ +#define PIN_USB_DET (32*4+19) /* USB connected */ /* Detect which power sources are present. */ unsigned int power_input_status(void) { + int rval = POWER_INPUT_NONE; + if(!__gpio_get_pin(PIN_USB_DET)) + rval |= POWER_INPUT_USB; if(!__gpio_get_pin(CHARGE_STAT_GPIO)) - return POWER_INPUT_USB_CHARGER; + rval |= POWER_INPUT_USB_CHARGER; - return POWER_INPUT_NONE; + return rval; } void power_init(void) @@ -42,5 +46,5 @@ void power_init(void) bool charging_state(void) { - return (power_input_status() == POWER_INPUT_USB_CHARGER); + return (power_input_status() & POWER_INPUT_USB_CHARGER); } -- cgit v1.2.3