mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-14 08:36:12 -04:00
qpnp-adaptive-charge: use mmi_charger to contrl battery charging
In QCOM 7350/8350, the kernel doesn't provide pmic-vote to control battery charging. the mmi_charger is an intermediate layer that forwards charging control to ADSP Battmngr from the application layer. By using USE_MMI_CHARGER macro definition that qpnp-adaptive-charge can be use mmi_charger's func to control battery charging Change-Id: I4da0604eabdadfc483143360ef7b7aad174cda47 Signed-off-by: xuwt2 <xuwt2@lenovo.com> Reviewed-on: https://gerrit.mot.com/1983612 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Yonghua Yan <yanyh2@motorola.com> Reviewed-by: Jianqi Yang <yangj@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
6f4a7d98ab
commit
e7b1662f5c
3 changed files with 39 additions and 3 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@
|
|||
#define pr_fmt(fmt) "qpnp_adap_chg-[%s]: " fmt, __func__
|
||||
#include <linux/module.h>
|
||||
#include <linux/version.h>
|
||||
#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 <linux/mmi-pmic-voter.h>
|
||||
#else
|
||||
#include <linux/pmic-voter.h>
|
||||
|
|
@ -37,7 +39,8 @@
|
|||
#include <linux/notifier.h>
|
||||
#include <linux/moduleparam.h>
|
||||
|
||||
#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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue