summaryrefslogtreecommitdiff
path: root/driver/charger/bd9995x.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/charger/bd9995x.c')
-rw-r--r--driver/charger/bd9995x.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c
index 82bbd675fd..7f1a023830 100644
--- a/driver/charger/bd9995x.c
+++ b/driver/charger/bd9995x.c
@@ -60,7 +60,31 @@ static enum usb_switch usb_switch_state[BD9995X_CHARGE_PORT_COUNT] = {
USB_SWITCH_DISCONNECT,
USB_SWITCH_DISCONNECT,
};
+
+static int bd9995x_get_bc12_ilim(int charge_supplier)
+{
+ switch (charge_supplier) {
+ case CHARGE_SUPPLIER_BC12_CDP:
+ return 1500;
+ case CHARGE_SUPPLIER_BC12_DCP:
+ return 2000;
+ case CHARGE_SUPPLIER_BC12_SDP:
+ return 900;
+ case CHARGE_SUPPLIER_OTHER:
+#ifdef CONFIG_CHARGE_RAMP_SW
+ return 2400;
+#else
+ /*
+ * Setting the higher limit of current may result in an
+ * anti-collapse hence limiting the current to 1A.
+ */
+ return 1000;
#endif
+ default:
+ return 500;
+ }
+}
+#endif /* HAS_TASK_USB_CHG */
static inline int ch_raw_read16(int cmd, int *param,
enum bd9995x_command map_cmd)
@@ -482,6 +506,21 @@ static int usb_charger_process(enum bd9995x_charge_port port)
/* No need for the task to schedule a wait event */
return 0;
}
+
+#ifdef CONFIG_CHARGE_RAMP_SW
+int usb_charger_ramp_allowed(int supplier)
+{
+ return supplier == CHARGE_SUPPLIER_BC12_DCP ||
+ supplier == CHARGE_SUPPLIER_BC12_SDP ||
+ supplier == CHARGE_SUPPLIER_BC12_CDP ||
+ supplier == CHARGE_SUPPLIER_OTHER;
+}
+
+int usb_charger_ramp_max(int supplier, int sup_curr)
+{
+ return bd9995x_get_bc12_ilim(supplier);
+}
+#endif /* CONFIG_CHARGE_RAMP_SW */
#endif /* HAS_TASK_USB_CHG */
/* chip specific interfaces */
@@ -1036,30 +1075,6 @@ int bd9995x_get_battery_voltage(void)
}
#ifdef HAS_TASK_USB_CHG
-int bd9995x_get_bc12_ilim(int charge_supplier)
-{
- switch (charge_supplier) {
- case CHARGE_SUPPLIER_BC12_CDP:
- return 1500;
- case CHARGE_SUPPLIER_BC12_DCP:
- return 2000;
- case CHARGE_SUPPLIER_BC12_SDP:
- return 900;
- case CHARGE_SUPPLIER_OTHER:
-#ifdef CONFIG_CHARGE_RAMP
- return 2400;
-#else
- /*
- * Setting the higher limit of current may result in an
- * anti-collapse hence limiting the current to 1A.
- */
- return 1000;
-#endif
- default:
- return 500;
- }
-}
-
int bd9995x_bc12_enable_charging(enum bd9995x_charge_port port, int enable)
{
int rv;