[qsd8250]: Add usb charging support in LK bootloader.
Add usb battery charging support for qsd8250_surf and qsd8250_ffa
targets in lk bootloader. USB charging is enabled only when
device goes into fastboot mode.
diff --git a/target/init.c b/target/init.c
index e6f114c..933ef19 100644
--- a/target/init.c
+++ b/target/init.c
@@ -55,3 +55,8 @@
__WEAK void reboot_device(unsigned reboot_reason)
{
}
+
+__WEAK void target_battery_charging_enable
+ (unsigned enable, unsigned disconnect)
+{
+}
diff --git a/target/msm7627_ffa/init.c b/target/msm7627_ffa/init.c
index 739beec..9331c29 100644
--- a/target/msm7627_ffa/init.c
+++ b/target/msm7627_ffa/init.c
@@ -184,3 +184,7 @@
}
return mode[0];
}
+
+void target_battery_charging_enable(unsigned enable, unsigned disconnect)
+{
+}
diff --git a/target/msm7627_surf/init.c b/target/msm7627_surf/init.c
index f1cb0b2..474a1e7 100644
--- a/target/msm7627_surf/init.c
+++ b/target/msm7627_surf/init.c
@@ -189,3 +189,7 @@
}
return mode[0];
}
+
+void target_battery_charging_enable(unsigned enable, unsigned disconnect)
+{
+}
diff --git a/target/msm7630_surf/init.c b/target/msm7630_surf/init.c
index 2527ae4..311cc9f 100644
--- a/target/msm7630_surf/init.c
+++ b/target/msm7630_surf/init.c
@@ -224,3 +224,7 @@
}
return mode[0];
}
+
+void target_battery_charging_enable(unsigned enable, unsigned disconnect)
+{
+}
diff --git a/target/qsd8250_ffa/init.c b/target/qsd8250_ffa/init.c
index 938676d..87a2e9f 100644
--- a/target/qsd8250_ffa/init.c
+++ b/target/qsd8250_ffa/init.c
@@ -84,7 +84,9 @@
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
-
+void usb_charger_change_state(void);
+void usb_charger_reset(void);
+void usb_stop_charging(unsigned);
void keypad_init(void);
void target_init(void)
@@ -174,3 +176,19 @@
}
return mode[0];
}
+
+void target_battery_charging_enable(unsigned enable, unsigned disconnect)
+{
+ if(disconnect){
+ usb_charger_reset();
+ return;
+ }
+ else
+ usb_stop_charging(!enable);
+
+ for(;;)
+ {
+ thread_sleep(10);
+ usb_charger_change_state();
+ }
+}
diff --git a/target/qsd8250_ffa/rules.mk b/target/qsd8250_ffa/rules.mk
index 3ed476f..1896ce2 100644
--- a/target/qsd8250_ffa/rules.mk
+++ b/target/qsd8250_ffa/rules.mk
@@ -16,6 +16,8 @@
KEYS_USE_GPIO_KEYPAD := 1
+DEFINES += ENABLE_BATTERY_CHARGING=1
+
MODULES += \
dev/keys \
lib/ptable
diff --git a/target/qsd8250_surf/init.c b/target/qsd8250_surf/init.c
index 03ddf23..4445ceb 100644
--- a/target/qsd8250_surf/init.c
+++ b/target/qsd8250_surf/init.c
@@ -84,7 +84,9 @@
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
-
+void usb_charger_change_state(void);
+void usb_charger_reset(void);
+void usb_stop_charging(unsigned);
void keypad_init(void);
void target_init(void)
@@ -173,3 +175,19 @@
}
return mode[0];
}
+
+void target_battery_charging_enable(unsigned enable, unsigned disconnect)
+{
+ if(disconnect){
+ usb_charger_reset();
+ return;
+ }
+ else
+ usb_stop_charging(!enable);
+
+ for(;;)
+ {
+ thread_sleep(10);
+ usb_charger_change_state();
+ }
+}
diff --git a/target/qsd8250_surf/rules.mk b/target/qsd8250_surf/rules.mk
index 3ed476f..1896ce2 100644
--- a/target/qsd8250_surf/rules.mk
+++ b/target/qsd8250_surf/rules.mk
@@ -16,6 +16,8 @@
KEYS_USE_GPIO_KEYPAD := 1
+DEFINES += ENABLE_BATTERY_CHARGING=1
+
MODULES += \
dev/keys \
lib/ptable