Charger&FuelGauge (Riogande platform)

1. *#*#4636#*#* 可查看 手机信息,电池信息
2. https://wiki.sonyericsson.net/androiki/Fuel_Gauge_FAQ 如何抓fuel gauge 的log
    a. How to save kernel logs to phone memory
        $ adb shell
mkdir /data/debugfs
mount -t debugfs none /data/debugfs
echo -n 'file ab8500_charger.c +p' > /data/debugfs/dynamic_debug/control
echo -n 'file ab8500_chargalg.c +p' > /data/debugfs/dynamic_debug/control
echo -n 'file ab8500_fg.c +p' > /data/debugfs/dynamic_debug/control
echo -n 'file ab8500_btemp.c +p' > /data/debugfs/dynamic_debug/control
exit
adb remount
adb shell chmod 6755 /system/bin/klogger
adb shell setprop persist.kernel.log uart
adb shell klogger &
    b. And to run klogger on every boot up, you should run this
adb shell
mkdir /data/data/com.sonyericsson.android.logalong
mkdir /data/data/com.sonyericsson.android.logalong/files
echo -e "kernel;" >> /data/data/com.sonyericsson.android.logalong/files/logalongBootCompleted
    c. Kernel logs will be saved either at
        /data/data/kernel0.txt
        /data/data/kernel1.txt
        or at
        /sdcard/kernel0.txt
        /sdcard/kernel1.txt
用以上方法有时候抓不到代码中,dev_dbg的log, 另外我们可以在你需要输出dev_dbg的*.c文件中定义#define DEBUG即可
3. Riogrande 平台上 charge only(电池电量不够,不能开机,只能进入开机充电画面)的程序在vendor/semc/hardware/power/chargemon 下面
3.1 在手机上init.st-ericsson.rc中有
    on early-boot
        # Start the offline charging (This blocks booting further in some cases)
        exec /system/bin/chargemon
3.2 分析main@vendor/semc/hardware/power/chargemon/main.c

4. 关于充电的驱动代码位于/kernel/drivers/power/ab8500_btemp.c, ab8500_chargalg.c(charge algorithm),ab8500_charger.c(charge driver),  ab8500_fg.c, power_supply_core.c, power_supply_sysfs.c, power_supply_leds.c, power_supply.c ;
5. DMS01203256
6. 手机中/sys/class/power_supply/包含相关的 充电信息
7. ab8500_charger_set_vbus_in_curr@kernel/drivers/power/ab8500_charger.c ,该函数会设置充电电流限制
8. kernel/arch/arm/mach-ux500/charger-lotus.c中有充电电流限制的定义
    struct device_data device_data = {
        .charge_full_design = 1500, /* C */
        .normal_cur_lvl = 1050, /* 0.7C */
    };
9. 在kernel/drivers/power/ab8500_charger.c中,ab8500_charger_irq结构设置(中断处理函数)-->ab8500_charger_usb_link_status_work-->ab8500_charger_detect_chargers(区分charger类型:USB_PW_CONN/USB charger;AC_PW_CONN/AC charger);
    a. 如果是USB charger则 ab8500_charger_read_usb_type->ab8500_charger_max_usb_curr->ab8500_charger_set_vbus_in_curr[usb charger]和ab8500_charger_set_output_curr[wall charger]-->ab8500_charger_set_current,该函数根据识别的USB type规定充电的最大电流;
    b. 如果是AC charger则ab8500_charger_psy_changed ????-->ab8500_charger_usb_en(当用wall charger连上手机时)
10. Read USB charge current now: adb shell cat /sys/class/power_supply/ab8500_usb/current_now; //估计应该是charger的最大限流
    Read battery current now: adb shell cat /sys/class/power_supply/ab8500_fg/current_now;//是从电池流入或者流出的电流;如果正在充电,则是充电器的电流减去系统消耗的电流(可正可负,比如如果系统耗电> 500mA,而用PC USB充电的限流又是500mA,则这时候电池也会提供部分电流给系统用);如果没有充电,则是电池提供给系统的电流(为负)
11. adb8500_charger_probe@ad8500_charger.c中有当手机启动就连着usb cable的处理,通过charger_status = ab8500_charger_detect_chargers(di, true);识别连着的charger类型
12. 分析几种USB充电的类型
12.1 手机startup完后,用wall charger充电
   a. ab8500_charger_vbusdetr_handler中断处理函数检测到usb cable插入,VBUS rise信号会触发(log: VBUS rising detected)
   b. ab8500_charger_detect_usb_type_work-->ab8500_charger_detect_chargers, 有AB8500_CH_USBCH_STAT1_REG=3 (log: AB8500_CH_USBCH_STAT1_REG 3)
   c. ab8500_charger_usb_notifier_call(log: not a standard host, returning),谁触发的?
   d. ab8500_charger_usblinkstatus_handler(log: USB link status changed)->ab8500_charger_usb_link_status_work->ab8500_charger_detect_chargers->ab8500_charger_read_usb_type->ab8500_charger_max_usb_curr[get usb type = USB_STAT_DEDICATED_CHG](log: USB Type - 0x07 MaxCurr: 1500)->启动ab8500_charger_usb_link_attach_work
   e. ab8500_charger_usb_link_attach_work->ab8500_charger_set_usb_connected(log: connected 1)->???
   f. ab8500_charger_usb_en(log: Enable USB: 4000mV 400mA)->ab8500_charger_set_vbus_in_curr(log: VBUS input current limit set to 1500 mA
)->ab8500_charger_set_current(log: Auto VBUS curr is 50 mA 和 curr change_2 to: 10 for 0xc2 ...逐步100mA调整,0x0BC2寄存器是UsbChCurrLevel,是充电控制器的输入,可以设置充电器的输入电流)
   g. 接上,ab8500_charger_set_output_curr[设置充电器输出电流,寄存器0x0B42 ChOutCurrLevel],另外ab8500_charger_usb_en在此期间还会被触发,谁干的呢?
   h. 触发ab8500_charger_vbuschdropend_handler(谁触发?log: VBUS charger drop ended)->ab8500_charger_vbus_drop_end_work->ab8500_charger_set_vbus_in_curr->ab8500_charger_set_current 会调整充电电流,ab8500的charger有自己的充电算法控制充电电流,我们可以通过读取0xBC2得到当前的充电电流(有log输出VBUS input current limit), 再读取0xB03获取可自动调整的输入充电电流(有log输出setAuto VBUS curr),为防止电压下降;比较两者0xBC2[实际的充电电流]和0xB03寄存器是UsbChStatus2用于读取当前充电器的输入电流[ab8500的HW 计算出来的最优输入电流,防止压降] 然后逐步调整(100mA)
   i. 充电器的USB cable被拔掉(VBUS falling),触发ab8500_charger_vbusdetf_handler->ab8500_charger_detect_usb_type_work
   j. 主要的几个控制寄存器,
    UsbChStatus2(0xB03): Result of automatic input current limitation (to avoid to Vbus voltage to drop). Input current limitation can be from 90mA to 1.3A by about 100mA steps
    UsbChCurrLevel(0x0BC2): USB charger current control
    ChOutCurrLevel(0xB42):Defined charger output current when Btemp above Medium threshold and below High threshold. Setting from 100mA to 1.5A by 100mA steps

12.2 手机startup完后,用USB charger充电

你可能感兴趣的:(shell,File,input,手机,output,returning)