Android Qcom USB Driver学习(五)

该系列文章总目录链接与各部分简介: Android Qcom USB Driver学习(零)

前面的几篇都有涉及,所以本文学习一下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,
  },

高通pmic voter机制

/*
** 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
  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值