diff --git a/drivers/power/qpnp_adaptive_charge/Android.mk b/drivers/power/qpnp_adaptive_charge/Android.mk index 73e6d65df181..d55b4dfc0541 100755 --- a/drivers/power/qpnp_adaptive_charge/Android.mk +++ b/drivers/power/qpnp_adaptive_charge/Android.mk @@ -4,6 +4,12 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := qpnp_adaptive_charge.ko LOCAL_MODULE_TAGS := optional + +ifeq ($(USE_MMI_CHARGER), true) + KERNEL_CFLAGS += CONFIG_USE_MMI_CHARGER=y +LOCAL_ADDITIONAL_DEPENDENCIES := $(KERNEL_MODULES_OUT)/mmi_charger.ko +endif + LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT) include $(DLKM_DIR)/AndroidKernelModule.mk diff --git a/drivers/power/qpnp_adaptive_charge/Kbuild b/drivers/power/qpnp_adaptive_charge/Kbuild index c8fbd8bf52d7..96a0e6ba1fb8 100755 --- a/drivers/power/qpnp_adaptive_charge/Kbuild +++ b/drivers/power/qpnp_adaptive_charge/Kbuild @@ -2,4 +2,10 @@ EXTRA_CFLAGS += -Wall EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/include +ifneq ($(filter m y,$(CONFIG_USE_MMI_CHARGER)),) + EXTRA_CFLAGS += -DUSE_MMI_CHARGER + EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/power/mmi_charger + KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../mmi_charger/$(GKI_OBJ_MODULE_DIR)/Module.symvers +endif + obj-m += qpnp_adaptive_charge.o diff --git a/drivers/power/qpnp_adaptive_charge/qpnp_adaptive_charge.c b/drivers/power/qpnp_adaptive_charge/qpnp_adaptive_charge.c index cc735b8271f4..124386c3f95c 100755 --- a/drivers/power/qpnp_adaptive_charge/qpnp_adaptive_charge.c +++ b/drivers/power/qpnp_adaptive_charge/qpnp_adaptive_charge.c @@ -28,7 +28,9 @@ #define pr_fmt(fmt) "qpnp_adap_chg-[%s]: " fmt, __func__ #include #include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 61)) +#ifdef USE_MMI_CHARGER +#include "mmi_charger.h" +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 61)) #include #else #include @@ -37,7 +39,8 @@ #include #include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 61)) +#ifdef USE_MMI_CHARGER +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 61)) #define vote(votable, client_str, enabled, val) \ mmi_vote(votable, client_str, enabled, val) @@ -48,10 +51,13 @@ static struct adap_chg_data { struct power_supply *batt_psy; struct power_supply *dc_psy; struct power_supply *usb_psy; +#ifdef USE_MMI_CHARGER +#else struct votable *usb_icl_votable; struct votable *dc_suspend_votable; struct votable *fcc_votable; struct votable *chg_dis_votable; +#endif int batt_capacity; struct notifier_block ps_notif; struct work_struct update; @@ -88,15 +94,23 @@ static int get_ps_int_prop(struct power_supply *psy, enum power_supply_property static void suspend_charging(bool on) { if(!adap_chg_data.charging_suspended && on) { +#ifdef USE_MMI_CHARGER + mmi_vote_charger_suspend(ADAPTIVE_CHARGING_VOTER, on); +#else vote(adap_chg_data.usb_icl_votable, ADAPTIVE_CHARGING_VOTER, true, 0); vote(adap_chg_data.dc_suspend_votable, ADAPTIVE_CHARGING_VOTER, true, 0); +#endif adap_chg_data.charging_suspended = true; pr_info("Set suspended on\n"); } if(adap_chg_data.charging_suspended && !on) { +#ifdef USE_MMI_CHARGER + mmi_vote_charger_suspend(ADAPTIVE_CHARGING_VOTER, on); +#else vote(adap_chg_data.usb_icl_votable, ADAPTIVE_CHARGING_VOTER, false, 0); vote(adap_chg_data.dc_suspend_votable, ADAPTIVE_CHARGING_VOTER, false, 0); +#endif adap_chg_data.charging_suspended = false; pr_info("Set suspended off"); } @@ -106,15 +120,23 @@ static void suspend_charging(bool on) static void stop_charging(bool on) { if(!adap_chg_data.charging_stopped && on) { +#ifdef USE_MMI_CHARGER + mmi_vote_charging_disable(ADAPTIVE_CHARGING_VOTER, on); +#else vote(adap_chg_data.fcc_votable, ADAPTIVE_CHARGING_VOTER, true, 0); vote(adap_chg_data.chg_dis_votable, ADAPTIVE_CHARGING_VOTER, true, 0); +#endif adap_chg_data.charging_stopped = true; pr_info("Set stop charging on\n"); } if(adap_chg_data.charging_stopped && !on) { +#ifdef USE_MMI_CHARGER + mmi_vote_charging_disable(ADAPTIVE_CHARGING_VOTER, on); +#else vote(adap_chg_data.fcc_votable, ADAPTIVE_CHARGING_VOTER, false, 0); vote(adap_chg_data.chg_dis_votable, ADAPTIVE_CHARGING_VOTER, false, 0); +#endif adap_chg_data.charging_stopped = false; pr_info("Set stop charging off\n"); } @@ -337,6 +359,8 @@ static int __init qpnp_adap_chg_init(void) goto fail; } +#ifdef USE_MMI_CHARGER +#else adap_chg_data.usb_icl_votable = find_votable("USB_ICL"); if (IS_ERR(adap_chg_data.usb_icl_votable)) { pr_err("Failed to get USB_ICL votable\n"); @@ -360,7 +384,7 @@ static int __init qpnp_adap_chg_init(void) pr_err("Failed to get CHG_DISABLE votable\n"); goto fail; } - +#endif adap_chg_data.ps_notif.notifier_call = ps_notify_callback; if (power_supply_reg_notifier(&adap_chg_data.ps_notif)) { pr_err("Failed to register notifier\n");