summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2024-11-02 20:53:46 -0400
committerSolomon Peachy <pizza@shaftnet.org>2024-11-02 20:54:17 -0400
commitf3026cd07221b45079952546a94631e25908f4fc (patch)
tree5a5e812c5770142fd6744eaa6966d4a23ee1e0eb
parent06986d27f06528c8eb9f672a8f4913d3e3e7a307 (diff)
downloadrockbox-f3026cd07221b45079952546a94631e25908f4fc.tar.gz
rockbox-f3026cd07221b45079952546a94631e25908f4fc.zip
xduoox3: Try to distinguish between "USB Plugged in" and "Charging"
Change-Id: I1879dbe6a95df215afa32012a72e1431c03a8653
-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}