Fork me on GitHub

Android Qcom USB Driver学习(八)

因为要看usb charging的问题,所以需要补充一下battery的相关知识,算是入门吧

BAT SCH

(1)VBATT_VSNS_P

(2)BAT_THERM

(3)I2C_SDA

(4)I2C_SCL

(5)VBATT_VSNS_M

sbl1_hw_pre_ddr_init: (1)pm_device_init (2)pm_driver_init (3) pm_sbl_chg_init 

(1)
pm_device_init没有研究过,也是一些初始化
(2)
pm_sbl_boot_oem.c -> pm_driver_post_init  (通过write register的方法来配置jeita)
	err_flag |= pm_comm_write_byte(0x2 , 0x1094, 0x0F, 0x0); //warm 45
	err_flag |= pm_comm_write_byte(0x2 , 0x1095, 0xDC, 0x0); //warm 45
依据各项目ic pmic的datasheet找到对应寄存器进行修改
(3)
pm_config_target.c -> strcut sbl_schg_specific_data  (charger parameters chg_param_ptr)
包括usb输出电流(USBIN Input Current Limit),开机电压(bootup_battery_theshold_mv),jeita限制(Enable/Disable JEITA Hard Temp Limit Check in SBL)等等
pm_sbl_schg_specific_data_type
  sbl_schg_specific_data[1] =
  {
     {
        //Configuration Value,                             Enable config
        {PM_SCHG_BATIF_LOW_BATTERY_THRESH_3P2,             PM_DISABLE_CONFIG },  //Vlowbatt Threshold
        {PM_SCHG_BATIF_LOW_BATTERY_THRESH_2P8,             PM_ENABLE_CONFIG  },  //APSD rerun Vlowbatt Threshold
        {70,                                               PM_ENABLE_CONFIG  },  //Fg skin hot threshold: valid range is -30 to 97 degree C
        {80,                                               PM_ENABLE_CONFIG  },  //Fg skin too hot threshold: valid range is -30 to 97 degree C
        {80,                                               PM_ENABLE_CONFIG  },  //Fg charge hot threshold: valid range is -30 to 97 degree C
        {90,                                               PM_ENABLE_CONFIG  },  //Fg charge too hot threshold: valid range is -30 to 97 degree C
        {TRUE,                                             PM_DISABLE_CONFIG },  //Use BATID and/or THERM pin for battery missing detection
        {{TRUE, PM_SCHG_MISC_SNARL_WDOG_TMOUT_62P5MS, PM_SCHG_MISC_BARK_WDOG_TMOUT_128S, PM_SCHG_MISC_BITE_WDOG_TMOUT_8S}, PM_ENABLE_CONFIG },  //Enable/Disable and Timeout WDog Config
        {2000,                                             PM_ENABLE_CONFIG },  //FAST Charging Current
        {300,                                              PM_ENABLE_CONFIG },  //PRE Charge Current
        {4400,                                             PM_ENABLE_CONFIG },  //Float Voltage
        {2500,                                             PM_ENABLE_CONFIG  },  //USBIN Input Current Limit
        {1000,                                             PM_DISABLE_CONFIG },  //DCIN Input Current Limit
        {6750, 8250,                                       PM_ENABLE_CONFIG  },  //Fake battery detection range: Battery will be detected as fake battery if BATT ID in this range. unit: Ohms
        {2000, 14000},                                                           //Debug Board detect: BATT_ID PD Resistor ADC Min/Max Read Value range; unit: Ohms
        PM_BATT_ID_PU_30K,                                                       //battery ID pull up resistor value
        3300,                                                                    //bootup_battery_theshold_mv
        3300,                                                                    //wipowr bootup battery thesholdmv
        2800,                                                                    //apsd_reset_threshold_mv:  APSD reset only applicable if initial Vbatt level is less than this threshold
        2800,                                                                    //apsd_reset_theshold_no_uvlo_mv: Used if last reset reason is NOT UVLO
        3200,                                                                    //apsd_reset_theshold_uvlo_mv: Used if last reset reason is UVLO
        TRUE,                                                                    //Enable/Disable JEITA Hard Temp Limit Check in SBL
        TRUE,                                                                    //dbc_usb_500_mode
        TRUE,                                                                   //Verbose SBL CHG UART logging
  	  1,																	   //Pmic index of charger
     }
  };


pm_sbl_boot.c  -> pm_app_chgr.c -> pm_sbl_config_chg_parameters ↓↓↓
pm_sbl_boot.c  -> pm_app_chgr.c -> pm_sbl_chg_check_weak_battery_status
应用上述的chg_param_ptr, 在weak battery的状态下不会开机(即SBL Charging in progress....) + 闪红灯(Toggle Red LED)

XBL Core

QcomChargerConfig_VbattTh.cfg	
BootToHLOSThresholdInMv = 3300 
JeitaHardColdLimit = 0
JeitaSoftColdLimit = 10
JeitaSoftHotLimit  = 45
JeitaHardHotLimit  = 60


QcomChargerPlatform.c -> ChargerPlatform_ReadCfgParams -> ChargerPlatform_Init
if (CurrentBatteryStatus.BatteryVoltage >= gThresholdVbatt)
     *pActionType = EFI_QCOM_CHARGER_ACTION_GOOD_TO_BOOT;

Kernel

qcom,fastchg-current-ma = <2000>;          //最大快充电流
/* COOL = 10 degc, WARM = 40 degC*/        //jeita配置
qcom,jeita-soft-thresholds = <0x2ed8 0x1045>; <SOFT_COLD_ADC_CODE, SOFT_HOT_ADC_CODE>
/* COLD = 0 degC, HOT = 45 degC*/
qcom,jeita-hard-thresholds = <0x3e3d 0x0D85>; <HARD_COLD_ADC_CODE, HARD_HOT_ADC_CODE>
qcom,jeita-fcc-ranges = <                  //各jeita范围内电流
                        0 100 800000
                        101 400 2000000
                        401 450 2000000>;
qcom,jeita-fv-ranges = <                   //各jeita范围内电压
                        0 100 4180000
                        101 400 4350000
                        401 450 4350000>;

Charging phases

image

(1) Trickle-charge  < 2.1V 45mA
(2) Preconditioning(precharge) > 2.1V + PRE Charge Current
(3) Constant current(fast charge) < Float Voltage + Fast Charging Current
(4) Constatnt voltage(taper charge) = Float Voltage
Chargint phase的配置还是发生在SBL1/XBL阶段,在高通平台上除了(1)Trigckle_charge都是可配置的,配置可见上述sbl_schg_specific_data

pm_sbl_boot.c  -> pm_app_chgr.c -> pm_sbl_config_chg_parameters
                                       -> pm_schg_chgr_set_charge_current(PRE Charge Current(2))
									   -> pm_schg_chgr_set_charge_current(FAST Charging Current(3))
									   -> pm_schg_chgr_set_float_volt(Float Voltage(4))
posted @ 2024-08-23 14:30  yooooooo  阅读(33)  评论(0编辑  收藏  举报