MSM USB插入流程代码分析
生活随笔
收集整理的這篇文章主要介紹了
MSM USB插入流程代码分析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
點擊打開鏈接
代碼路徑:kernel\msm-3.18\drivers\power\qpnp-smbcharger.c
src_detect_handler -->update_usb_status(chip, usb_present, 0);-->handle_usb_insertion(chip);read_usb_type(chip, &usb_type_name, &usb_supply_type);//讀寄存器獲得充電器類型smbchg_change_usb_supply_type(chip, usb_supply_type);//根據充電器類型設置輸入電流門限,下面單獨分析power_supply_set_present(chip->usb_psy, chip->usb_present);//設置usb在位的屬性schedule_work(&chip->usb_set_online_work);//調度USB online工作隊列 if (!chip->hvdcp_not_supported && (usb_supply_type == POWER_SUPPLY_TYPE_USB_DCP)) {//如果芯片支持快充且充電器類型為DCP,則啟動HVDCP檢測,其中 PMI8937/PMI8940 不支持HVDCPsmbchg_stay_awake(chip, PM_DETECT_HVDCP); schedule_delayed_work(&chip->hvdcp_det_work, msecs_to_jiffies(HVDCP_NOTIFY_MS));}smbchg_detect_parallel_charger(chip);//并充相關檢測read_usb_type -->smbchg_read(chip, ®, chip->misc_base + IDEV_STS, 1);//讀寄存器1608獲得類型 type = get_type(reg);//獲得相應的bit位的值 *usb_type_name = get_usb_type_name(type);//獲得類型名 *usb_supply_type = get_usb_supply_type(type);//獲得類型type- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Bit7位1,充電器類型為CDP?
Bit6位1,充電器類型為DCP,即通常說的AC adapter?
Bit5位1,充電器類型為other,可以認為是非標充電器??
Bit4位1,充電器類型為SDP
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
輸入端限流設置代碼流程
代碼路徑:/kernel/msm-3.18/drivers/power/qpnp_smbcharger.c
handle_usb_insertion -->smbchg_change_usb_supply_type(chip, usb_supply_type);-->rc = vote(chip->usb_icl_votable, PSY_ICL_VOTER, true,current_limit_ma);//投票機制實際是調用他的毀掉函數-->set_usb_current_limit_vote_cb(struct device *dev,int icl_ma,int client,int last_icl_ma, int last_client)-->rc = smbchg_set_usb_current_max(chip, icl_ma); switch (chip->usb_supply_type) {//根據充電器配置最大電流case POWER_SUPPLY_TYPE_USB: case POWER_SUPPLY_TYPE_USB_CDP: default:rc = smbchg_set_high_usb_chg_current(chip, current_ma);//dcp類型默認走這個default設置 smbchg_set_high_usb_chg_current(struct smbchg_chip *chip,int current_ma) ? i = find_smaller_in_array(chip->tables.usb_ilim_ma_table, current_ma, chip->tables.usb_ilim_ma_len);//該函數返回數組中最接近設定值的數值/* finds the index of the closest smaller value in the array. */ if (i < 0) {dev_err(chip->dev,"Cannot find %dma current_table using %d\n",current_ma, CURRENT_150_MA); }//如果找不到就設置150ma usb_cur_val = i & USBIN_INPUT_MASK; rc = smbchg_sec_masked_write(chip, chip->usb_chgpth_base + IL_CFG,USBIN_INPUT_MASK, usb_cur_val);//設置寄存器13f2- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀
總結
以上是生活随笔為你收集整理的MSM USB插入流程代码分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 高通平台:USB充电
- 下一篇: How to use USB to do