sgm4154x:add hawao vbus adc sample ratio

Hawao use 180 pull up and 39 pull down
hw design for vbus adc.
So we need to use specific sample ratio
to do the caculation.
This is just a debug modification to
accommodate evt/evt1 hw.

Change-Id: If062be5ac2f0586d39eb7115ab16f211c5c29d29
Signed-off-by: xieqiong2 <xieqiong2@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2147468
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Wang Wang <wangwang1@lenovo.com>
Submit-Approved: Jira Key
This commit is contained in:
xieqiong2 2021-12-17 10:49:31 +08:00 • committed by Qiong Xie
commit 0899181581
3 changed files with 20 additions and 0 deletions

View file

@ -9,6 +9,10 @@ ifeq ($(MMI_QC3P_TURBO_CHARGER),true)
KERNEL_CFLAGS += CONFIG_MMI_QC3P_TURBO_CHARGER=y
endif
ifeq ($(MMI_HAWAO_VBUS_SAMPLE_RATIO),true)
KERNEL_CFLAGS += CONFIG_MMI_HAWAO_VBUS_SAMPLE_RATIO=y
endif
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
LOCAL_ADDITIONAL_DEPENDENCIES := $(KERNEL_MODULES_OUT)/mmi_discrete_charger_class.ko

View file

@ -7,6 +7,10 @@ ifneq ($(filter m y,$(CONFIG_MMI_QC3P_TURBO_CHARGER)),)
EXTRA_CFLAGS += -DCONFIG_MMI_QC3P_TURBO_CHARGER
endif
ifneq ($(filter m y,$(CONFIG_MMI_HAWAO_VBUS_SAMPLE_RATIO)),)
EXTRA_CFLAGS += -DCONFIG_MMI_HAWAO_VBUS_SAMPLE_RATIO
endif
obj-m += sgm4154x_charger.o
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../mmi_discrete_charger/$(GKI_OBJ_MODULE_DIR)/Module.symvers

View file

@ -28,6 +28,11 @@
static bool g_qc3p_detected = false;
#endif
#ifdef CONFIG_MMI_HAWAO_VBUS_SAMPLE_RATIO
#define HAWAO_VBUS_ADC_PULL_UP_KOHM 180.0
#define HAWAO_VBUS_ADC_PULL_DOWN_KOHM 39.0
#endif
static struct power_supply_desc sgm4154x_power_supply_desc;
/* SGM4154x REG06 BOOST_LIM[5:4], uV */
@ -45,6 +50,7 @@ static const unsigned int BOOST_CURRENT_LIMIT[] = {
};
#endif
enum SGM4154x_VREG_FT {
VREG_FT_DISABLE,
VREG_FT_UP_8mV,
@ -303,6 +309,8 @@ static int sgm4154x_read_usbin_voltage_chan(struct sgm4154x_device *sgm, int *va
return rc;
}
dev_info(sgm->dev, "vbus raw voltage = %d\n", *val);
return 0;
}
@ -317,7 +325,11 @@ static int sgm4154x_get_usb_voltage_now(struct sgm4154x_device *sgm, int *val)
return rc;
}
#ifdef CONFIG_MMI_HAWAO_VBUS_SAMPLE_RATIO
*val = (int)(raw_date * (float)((HAWAO_VBUS_ADC_PULL_UP_KOHM + HAWAO_VBUS_ADC_PULL_DOWN_KOHM)/HAWAO_VBUS_ADC_PULL_DOWN_KOHM));
#else
*val = raw_date * 3;
#endif
return 0;
}