前面的几篇都有涉及,所以本文学习一下pmic usb charger都相关的vote机制
OVP: Over Voltage Protection 过压保护
USB_IN: Input current limit 一般仅支持USB_IN即VBUS在输入(有些能支持DC_IN),
APSD: autonomous power source detection 运行于BC 1.2 SDP/CDP的检测完成之后
QC2.0/3.0: Qcom quick charger 运行于BC1.2 DCP的检测完成之后
AICL: automatic input current limiting 自动最大化从AC/DC适配器中汲取电流
ICL_MAX: Maximum programmed input current limit value
pmi632不支持DC_IN,OTG支持输出5v 1000mA
static struct smb_params smb5_pmi632_params{
.icl_stat = {
.name = "input current limit status",
.reg = ICL_STATUS_REG,
.min_u = 0,
.max_u = 3000000, //3A
.step_u = 50000,
},
.otg_cl = {
.name = "usb otg current limit",
.reg = DCDC_OTG_CURRENT_LIMIT_CFG_REG,
.min_u = 500000,
.max_u = 1000000,
.step_u = 250000,
},
/*
** vote 函数主要用来给 votable 添加投票选项
** votable: 投票的对象
** client_str: 投票者
** enabled: 投票者的内容(val)是否参与投票
** val: 投票内容
**/
int vote(struct votable *votable, const char *client_str, bool enabled, int val)
kernel/msm-4.19/drivers/power/supply/qcom/battery.c
votable: usb_icl_votable VOTE_MIN:取投票对象中的最小值
chip->usb_icl_votable = create_votable("USB_ICL", VOTE_MIN,
usb_icl_vote_callback,
chip);
在前面的第二期中,我们知道一些非标的USB的充电类型Floating charger,其具有和普通 DCP 相似的大电流能力,但在最初检测的时候会限制Input current limit到100mA,来进行检测是否是SDP类型,所以要支持大电流输入就需要进行vote操作,
kernel/msm-4.19/drivers/power/supply/qcom/smb5-lib.c
Floating charger:
case POWER_SUPPLY_TYPE_USB_FLOAT:
/*
* limit ICL to 100mA, the USB driver will enumerate to check
* if this is a SDP and appropriately set the current
*/
smblib_info(chg, "debug float set to %d uA\n", chg->dcp_icl_ua);
vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true,
chg->dcp_icl_ua);
break;
devicetree pmi632_charger
qcom,usb-icl-ua = <2500000>;//defualt: 3000000
kernel/msm-4.19/drivers/power/supply/qcom/qpnp-smb5.c
smb5_parse_dt_currents
of_property_read_u32(node,"qcom,usb-icl-ua", &chip->dt.usb_icl_ua);
chg->dcp_icl_ua = chip->dt.usb_icl_ua;
kernel/msm-4.19/drivers/power/supply/qcom/smb5-lib.c
vote(chg->usb_icl_votable, USB_PSY_VOTER, true, chg->dcp_icl_ua);
vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false,0);
从log中也可以看出初始input current limit为100mA,检测float类型时,对SW_ICL_MAX_VOTER进行vote取最小值仍然为100mA,所以需要对其重新进行vote操作,才可以将input current提升到2500mA
pmi632_charger: smblib_update_usb_type: APSD=FLOAT PD=0 QC3P5=0
pmi632_charger: smblib_get_charge_param: input current limit status = 100000 (0x02)
pmi632_charger: update_sw_icl_max: float set to 2500000 uA
pmi632_charger: smblib_get_charge_param: input current limit status = 100000 (0x02)
pmi632_charger: smblib_set_charge_param: usb input current limit = 2500000 (0x32)
pmi632_charger: smblib_handle_apsd_done: IRQ: apsd-done rising; FLOAT detected
标签:usb,icl,charger,Driver,limit,current,Qcom,votable,Android
From: https://www.cnblogs.com/linhaostudy/p/18371189