• 高通开发笔记---yukon worknote


    点击打开链接

    daily build
    http://android-ci-platform.cnbj.sonyericsson.net/job/daily_build_jb-mr2-yukon/
    DL-CNBJ-TianChi-SWCM: tianchi gina jb 的 CM

    一. msm8226-tianchi_dsds.dtsi; msm-pm8226.dtsi

    二、. Audio Jack
       NC 和 NO的选择改成了dts里面设置
       @kernel/arch/arm/boot/dts/Msm8226-tianchi_dsds.dtsi
     &soc {
      sound {
       qcom,headset-jack-type-NO; ---> qcom,headset-jack-type-NC 后来改成这个了 !!!!!!!
      } 
     }
       msm8226_asoc_machine_probe@kernel/sound/soc/msm/Msm8226.c
     mbhc_cfg.gpio_level_insert = of_property_read_bool(pdev->dev.of_node,"qcom,headset-jack-type-NO");
     //该处设置是否NC和NO
       http://review.sonyericsson.net/#/c/560971/

       micbias 设置 @kernel/arch/arm/boot/dts/msm8226.dtsi
     tapan_codec {
       qcom,cdc-micbias-cfilt1-mv = <1800>;
       qcom,cdc-micbias-cfilt2-mv = <2700>;
       qcom,cdc-micbias-cfilt3-mv = <1800>;
     } 
        
        识别耳机类型出错,需要 mbhc_cfg.cs_enable_flags = 0 @kernel/sound/soc/msm/msm8226.c
      
    三. Vibrator
       @kernel/arch/arm/boot/dts/msm8226-tianchi_dsds.dtsi 
      qcom,vibrator@c000 {
       status = "okay";
       compatible = "qcom,qpnp-vibrator";
       reg = <0xc000 0x100>;
       label = "vibrator";
       qcom,vib-timeout-ms = <15000>;
       qcom,vib-vtg-level-mV = <3100>;
      };
       然后可以工作了
       源代码@kernel/drivers/platform/msm/qpnp-vibrator.c
       检查是否工作 #echo 1000 > /sys/class/timed_output/vibrator/enable

    四、如何查看qcom release for VI
    1. CM关于该项目的wiki: https://wiki.sonyericsson.net/androiki/PLD_CM/yukon
     ->Vendor integration -->Yukon VI History
     查看 Current Deliveries -> VI Info,选择相应版本进入
          ->QC subsystem components
      ->Opensource (LINUX) 该项为kernel版本 LNX.LA.3.2-01520-8x26.0
    2. 高通的kernel代码 https://www.codeaurora.org/cgit/quic/la//kernel/msm/
     ->Tag 中找到对应的版本号 比如:LNX.LA.3.2.1-01520-8x26.0
     ->进入后选择 上边的 tree 页签 可以找到具体的文件,比如 driver/power/qpnp-charger.c
     ->如果想看修改记录,则在进入具体文件前,也就是文件列表中,选择文件后面的log 打开浏览

    五、Charge only
    1. 插PC USB不能进入charge only mode
     misc ta 2002  01-->00

    六、tsubasa audio jack porting for jb-blue-mr2
    1. kernel/input/misc/simple_remote.c
     static int simple_remote_probe(struct platform_device *pdev)
     {
      /* device name */ 用于耳机检测 上报uevent事件给framewore
      jack->swdev.name = "h2w";
      /* print function name */
      jack->swdev.print_name = simple_remote_print_name;
      ret = switch_dev_register(&jack->swdev);

      /* Create input device for normal key events. */
      jack->indev = input_allocate_device();
      ...
      ret = input_register_device(jack->indev);

      /* Create input device for application key events. */
      jack->indev_appkey = input_allocate_device();
      ...  
      ret = input_register_device(jack->indev_appkey);
     
     }

     static void simple_remote_report_accessory_type
     { 
      ...
      switch_set_state(&jack->swdev, jack->new_accessory_state); //当耳机插入或拔出时,发送switch uevent 到framework
     }
    2. 检测 耳机插入switch uevent
     /sys/class/switch/h2w/state  0:没有耳机; 1:headset; 2:headphone;
    3. 相关的gerrit
     http://review.sonyericsson.net/#/c/565711
     http://review.sonyericsson.net/#/c/470796

    七、BMS 设置参数的说明
    1. @qpnp-adc-voltage.c 中注册各个channel sysfs
     在该qpnp_vadc_init_hwmon函数中会读取所有的pm8226_vadc的child node,然后逐个device_create_file, 这样在手机/sys/devices/qpnp-vadc-e4b43000路径下就注册了与 pm8226_vadc@kernel/arch/arm/boot/dts/msm-pm8226.dtsipm8226_vadc@kernel/arch/arm/boot/dts/msm8226.dtsi中 所有channel(child node) 一致的sys fs;
     比如 die-temp 
     pm8226_vadc: vadc@3100 {
       chan@8 {
        label = "die_temp";
        reg = <8>;
        qcom,decimation = <0>;
        qcom,pre-div-channel-scaling = <0>;
        qcom,calibration-type = "absolute";
        qcom,scale-function = <3>;
        qcom,hw-settle-time = <0>;
        qcom,fast-avg-setup = <0>;
       };
     }
    2. tm-temp-margin : 如果新的die-temp温度超过预先设置 的[上一次die-temp - tm-temp-margin, 上一次die-temp + tm-temp-margin] 则会触发
     btm_notify_die_temp@qpnp-bms.c
     ->schedule_work(&chip->recalc_work); //重新计算soc,这时候因为温度有变化,所以计算的值与上次就不一样了,实际上是温度变化超过了一定范围,需要重新校准soc的计算;
     ->refresh_die_temp_monitor(chip); //再次用最新的die-temp重新设置trigger范围。

    3. low-ocv-correction-limit-uv和high-ocv-correction-limit-uv和hold-soc-est 主要用于adjust_soc中new_soc的调整出错而限制一个合理的调整范围。
       主要用于调整soc @adjust_soc, 由于有温度的影响,所以需要调整,重新获取电池的电压和电流,计算出soc_est, 再根据soc和soc_est计算出delta_ocv_uv, 也就是ocv的微小变化, 这个delta_ocv_uv变化范围应该在[low-ocv-correction-limit-uv,high-ocv-correction-limit-uv],随后调整last_ocv_uv,基于新的ocv计算新的soc;
       如果根据电池电压,电流和温度,计算出来的soc_est >= hold-soc-est, 则尽管根据新的ocv计算出来soc_new=0, 也认为计算有些误差,则强制改变为1,因为毕竟还有少许电池电量

    4. enable-fcc-learning-soc
       主要是用于生成chip->adjusted_fcc_temp_lut@readjust_fcc_table, 如果再fcc时,则会用新的调整过的adjusted_fcc_temp_lut做插值计算
       电池最初的设置fcc_temp_lut,如下
     static struct single_row_lut fcc_temp = {
      .x = {-20, 0, 25, 40, 65},
      .y = {2300, 2318, 2347, 2390, 2400},
      .cols = 5,
     };   
        adjusted_fcc_temp_lut是根据新的电池chip->fcc_new_batt_temp和chip->fcc_new_mah来调整不同温度下的fcc
        什么时候触发readjust_fcc_table? 在fcc_learning_config中计算的new_fcc_uah和fcc_uah 相差比较大时(is_new_fcc_valid)则触发

    八、检测AICL功能
      qpnp_chg_aicl_work

    九、miscTA 2227, 55->50

    十、耳机检测
       echo -n "file wcd9xxx-mbhc.c +p" > /sys/kernel/debug/dynamic_debug/control
    1. wcd9xxx_cs_find_plug_type@wcd9xxx-mbhc.c,中门限电压的设置, 
     #define WCD9XXX_V_CS_HS_MAX 700
     #define WCD9XXX_V_CS_NO_MIC 5
     
     def_tapan_mbhc_cal@msm8226.c 
     S(v_no_mic, 30);
     S(v_hs_max, 2450);

     hs_max:
     no_mic:
       wcd9xxx_codec_cs_get_plug_type@wcd9xxx-mbhc.c设置是否用mic_bias, 和检测电压门限
     0 false WCD9XXX_V_CS_NO_MIC WCD9XXX_V_CS_HS_MAX
     1 false WCD9XXX_V_CS_NO_MIC WCD9XXX_V_CS_HS_MAX
     2 false WCD9XXX_V_CS_NO_MIC WCD9XXX_V_CS_HS_MAX
     3 false WCD9XXX_V_CS_NO_MIC  WCD9XXX_V_CS_HS_MAX
    2. Audio button 电压设置区间 def_tapan_mbhc_cal@msm8226.c, 一共8个buttons
     btn_cfg = WCD9XXX_MBHC_CAL_BTN_DET_PTR(tapan_cal);
     btn_low = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_V_BTN_LOW);
     btn_high = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_D_V_BTN_HIGH);
     btn_low[0] = -50;
     btn_high[0] = 10;
     btn_low[1] = 11;
     btn_high[1] = 52;
     btn_low[2] = 53;
     btn_high[2] = 94;
     btn_low[3] = 95;
     btn_high[3] = 133;
     btn_low[4] = 134;
     btn_high[4] = 171;
     btn_low[5] = 172;
     btn_high[5] = 208;
     btn_low[6] = 209;
     btn_high[6] = 244;
     btn_low[7] = 245;
     btn_high[7] = 330;

     @kernel/include/linux/input.h 中定义了上报key的键值 
       初始化 audio button对应的键值 wcd9xxx_mbhc_init@wcd9xxx-mbhc.c
      ret = snd_jack_set_key(mbhc->button_jack.jack,
               SND_JACK_BTN_0,
               KEY_MEDIA);
       Huashan对应上报的键值
       接听键 --> BTN_MISC/BTN_0  0x100
       音量上键 --> BTN_1  0x101
       音量下键 --> BTN_2  0x102
       smart键 --> BTN_3  0x103

    3. wcd9xxx_determine_button@wcd9xxx-mbhc.c 根据电压确认按下的是那个键
       wcd9xxx_dce_handler 是audio button 按键处理的中断回调函数
    4. wcd9xxx_release_handler@wcd9xxx-mbhc.c 

    vbatdet irq storm
    http://review.sonyericsson.net/#/c/511317
    http://review.sonyericsson.net/#/c/511314


    *************************************************************************************
    Sim card detect
    /jb-viskan/kernel/arch/arm/mach-msm/board-sony_viskan_huashan-pmic.c 
    struct gpio_event_platform_data pmic_keypad_data = {
     .name       = "sim-detection",
     .info       = pmic_keypad_info,
     .info_count = ARRAY_SIZE(pmic_keypad_info),
    };

    十一、如何添加msm_thermal
    1. 需要和硬件确认用的是那个 vadc channel,用于配置@msm8226-tianchi_dsds.dtsi
     &pm8226_vadc {
      chan@16 {   //0x16 = MPP 7 + 15 = 22,  可参考80-ND928-26_C 文档的 50 page
       label = "msm_therm";
       reg = <0x16>;
       qcom,decimation = <0>;
       qcom,pre-div-channel-scaling = <0>;
       qcom,calibration-type = "ratiometric";
       qcom,scale-function = <2>; 
       //用的是static struct qpnp_vadc_scale_fn vadc_scale_fn[]中的[SCALE_THERM_100K_PULLUP] = {qpnp_adc_scale_therm_pu2},
       // SCALE_THERM_100K_PULLUP = 2
       qcom,hw-settle-time = <2>;
       qcom,fast-avg-setup = <0>;
      };
     }
     由MPP计算channel的偏移15的来源,enum qpnp_vadc_channels@kernel/include/linux/qpnp/qpnp-adc.h 在P_MUX1_1_1前正好偏移15
    2. 需要和硬件确认用的是那个MPP, 这个从电路图上可以确认msm_thermal 用的是 MMP 7
     &pm8226_mpps {
      mpp@a600 { /* MPP 7 */
       /* MSM_THERM config */
       qcom,mode = <4>; /* AIN input */
       qcom,invert = <1>; /* Enable MPP */
       qcom,ain-route = <2>; /* AMUX 7 */
       qcom,master-en = <1>;
       qcom,src-sel = <0>; /* Function constant */
      }; 
     }
    3. 详细分析pa_therm0 的设计流程
     a. 查看电路图 pa_therm用的是MPP_5, 所以@msm8226-tianchi_dsds.dtsi设置
      &pm8226_mpps {
       mpp@a400 { /* MPP 5 */
        /* PA_THERM0 config */
        qcom,mode = <4>; /* AIN input */
        qcom,invert = <1>; /* Enable MPP */
        qcom,ain-route = <0>; /* AMUX 5 */
        qcom,master-en = <1>;
        qcom,src-sel = <0>; /* Function constant */
       };   
      }
     b. 如何配置pm8226_vadc的channel,计算是那个channel; MPP 5 + 15 = 20 = 0x14, 所以@msm8226-tianchi_dsds.dtsi设置
      &pm8226_vadc {
       chan@14 {
        label = "pa_therm0";
        reg = <0x14>;
        qcom,decimation = <0>;
        qcom,pre-div-channel-scaling = <0>;
        qcom,calibration-type = "ratiometric";
        qcom,scale-function = <2>;
        qcom,hw-settle-time = <2>;
        qcom,fast-avg-setup = <0>;
       };
      }

    十二、增加audio jack 的button的映射关系
    1. @device/somc/yukon/AndroidBoard.mk中添加 
     include $(CLEAR_VARS) 
     LOCAL_MODULE := msm8226-tapan-snd-card_Button_Jack.kl
     LOCAL_MODULE_TAGS := optional
     LOCAL_MODULE_CLASS := ETC 
     LOCAL_SRC_FILES := $(LOCAL_MODULE) 
     LOCAL_MODULE_PATH := $(TARGET_OUT_KEYLAYOUT) 
     include $(BUILD_PREBUILT)
        则会在手机 system/usr/keylayout 目录下增加文件 msm8226-tapan-snd-card_Button_Jack.kl
    2. @device/somc/yukon/platform.mk中增加
     PRODUCT_PACKAGES +=  
      msm8226-tapan-snd-card_Button_Jack.kl
    3. @device/somc/yukon目录下增加文件msm8226-tapan-snd-card_Button_Jack.kl
    4. 特别注意 msm8226-tapan-snd-card_Button_Jack.kl的文件名不是随意写的。
     status_t KeyMap::load@frameworks/base/libs/androidfw/keyboard.cpp 
     {
      if (deviceConfiguration) {
       String8 keyLayoutName;
       if (deviceConfiguration->tryGetProperty(String8("keyboard.layout"),
        ....
      }
      // Try searching by device identifier.
      if (probeKeyMap(deviceIdenfifier, String8::empty())) {
      return OK;
      }

      // Fall back on the Generic key map.
      // TODO Apply some additional heuristics here to figure out what kind of
      //      generic key map to use (US English, etc.) for typical external keyboards.
      if (probeKeyMap(deviceIdenfifier, String8("Generic"))) {
      return OK;
      }

      // Try the Virtual key map as a last resort.
      if (probeKeyMap(deviceIdenfifier, String8("Virtual"))) {
      return OK;
      }
     }
         #getevent -i
     add device 2: /dev/input/event7
       bus:      0000
       vendor    0000
       product   0000
       version   0000
       name:     "msm8226-tapan-snd-card Button Jack"
       location: "ALSA"
       id:       ""
       version:  1.0.1
       events:
         KEY (0001): 00e2  0101  0102  0103  0104  0105  0106  0107 
       input props:
         <none>
        读取*.kl的名字组合顺序为 
     a. 首先查看 props中是否有keyboard.layout的参数,如果有则读取该名字的kl文件
     b. 如果 该设备的vendor,product和version都不全为0,则通过它们的组合成 kl的文件名
      Vendor_%04x_Product_%04x_Version_%04x.kl
      Vendor_%04x_Product_%04x.kl
      最终形成文件路径system/usr/keylayout/Vendor_xxxx_Product_xxxx.kl或system/usr/keylayout/Vendor_xxxx_Product_xxxx_Version_xxxx.kl
     c. 如果vendor,product,version都为0,则通过该设备的name: "msm8226-tapan-snd-card Button Jack"来组合kl文件名
      appendInputDeviceConfigurationFileRelativePath中会把其中的空格转换成'_'
      最终形成文件路径system/usr/keylayout/msm8226-tapan-snd-card_Button_Jack.kl
    5.还可以直接用 snd_jack_set_key 映射
     ret = snd_jack_set_key(button_jack.jack,SND_JACK_BTN_0,KEY_MEDIA);

    十三、GPIO 4 控制 external OVP FET
    1. gpio_set_value 或 gpio_set_value_cansleep
    2. gpio_direction_output
     if (gpio_is_valid(ext_spk_amp_gpio))
     gpio_get_value_cansleep
    3. 最新GPIO的设置 http://review.sonyericsson.net/#/c/616064
    4. 检测gpio状态 cat sys/kernel/debug/gpio


    十四、thermal 的路径 
    1. msm_therm, pa_therm0, pa_therm1, batt_therm, xo_therm_pu2 位于/sys/devices/qpnp-vadc-e4943c00 
    2. tsens_tz_sensor0/1/2/3/4/5 位于 /sys/class/thermal/thermal_zone0/1/2/3/4/5

    十五、audio jack 中判断 HW_ID 和 RF_ID
    static bool msm8226_change_audiojack_type_to_nc(void)
    {
     int hw_id[3], rf_id[3];

     hw_id[0] = gpio_get_value_cansleep(109);
     hw_id[1] = gpio_get_value_cansleep(2);
     hw_id[2] = gpio_get_value_cansleep(3);

     rf_id[0] = gpio_get_value_cansleep(50);
     rf_id[1] = gpio_get_value_cansleep(51);
     rf_id[2] = gpio_get_value_cansleep(52);
     

     pr_info("%s: hw_id: %d %d %d ", __func__, hw_id[0], hw_id[1], hw_id[2]);
     if( hw_id[0] == 1 && hw_id[1] == 1 && hw_id[2] == 0 ) {
      return true;
     }

     return false;
    }

    十六、safey timer of charger
    1. 
     &pm8226_chg {
      qcom,tchg-mins = <4>; //4min -- 512min
     }
    2. Set safety timer to minimum value (4 minutes)
     $ adb shell
     $ cd /sys/kernel/debug/spmi/spmi-0/
     $ echo 0x1061 > address
     $ echo 0 > data
     Attach charger to start charging.
     Wait for 4 minutes

    十七、几个关键电压 
    1. 3.2V关机电压,kernel 设置
    2. 3.3v 没有充电时的开机电压, 3.42v 充电时的开机电压


    十八、msm_therm 精度不够 
    1. msm_therm 用的vadc_scale_fn是 [SCALE_THERM_100K_PULLUP] = {qpnp_adc_scale_therm_pu2},
     adcmap_100k_104ef_104fb 是温度和电压的对应关系
     
    2. @vendor/semc/hardware/device/yukon/sysmon/Android.mk

     143 # msm_therm
     144 ifeq ($(SEMC_CFG_SYSMON_SENSOR_PM8X26_MSM_THERM),yes)
     145 include $(CLEAR_VARS)
     146 LOCAL_CFLAGS := -DTZ_USE_NORMAL_UNIT   //不需要再定义TZ_USE_NORMAL_UNIT
     147 LOCAL_CFLAGS += -DPM8X26_SENSOR_NAME="msm_therm"
     148 LOCAL_SRC_FILES := pm8X26_sensor.c tz_function.c
     149 LOCAL_MODULE := sysmon_msm_therm
     150 include $(LOCAL_PATH)/main.mk
     151 endif
    3. 精度在sensor_work@vendor/semc/hardware/device/yukon/sysmon/pm8X26_sensor.c 分析
    4. pa_therm1和pa_therm0的 LOCAL_CFLAGS := -DTZ_USE_NORMAL_UNIT 也需要去掉,因为用的是msm_therm同一套数据

    十九、msm_therm 会调整cpu frequency?
    1. @kernel/drivers/thermal/Kconfig
      76 config THERMAL_MONITOR
      77         bool "Monitor thermal state and limit CPU Frequency"
    2. @kernel/arch/arm/configs/yukon_tianchi_defconfig
     325 CONFIG_THERMAL_MONITOR=y

    3. @kernel/drivers/thermal/msm_thermal.c
     module_param_cb(enabled, &module_ops, &enabled, 0644);
     
    4. @kernel/arch/arm/boot/dts/msm8226.dtsi
     qcom,msm-thermal
    5. @vendor/semc/hardware/device/yukon/sysmon/Android.mk中需要生成sysmon_msm_thermal_disable
     msm_thermal_disable.c
       @vendor/semc/hardware/device/yukon/sysmon_cfg.mk中添加
     SEMC_CFG_SYSMON_MITIGATION_MSM_THERMAL_DISABLE = yes
    6. http://review.sonyericsson.net/#/c/590035/


    二十、
    手动设置电池容量
    echo 50 > sys/modules/qpnp_bms/parameters/bms_fake_battery

    regulator_set_optimum_mode

    usbin_valid: /sys/devices/qpnp-charger-e4942e00/usbin_valid
    vbat_sns: /sys/devices/qpnp-vadc-e4943c00/vbat_sns
    xo_therm_pu2: /sys/devices/qpnp-vadc-e4943c00/xo_therm_pu2
    msm_thermal:
    batt_therm:


    while true; do ls -l; sleep 10; done;


    adb shell am start -n com.semc.sensorlogger/com.semc.sensorlogger.SensorLoggerActivity
    1. echo -n "file qpnp-charger.c +p" > /sys/kernel/debug/dynamic_debug/control
    echo -n "file wcd9xxx-mbhc.c +p" > /sys/kernel/debug/dynamic_debug/control
    adb logcat -s sysmon-msm_therm system_monitor
    adb logcat | grep -E "sysmon|system_monitor"

    msm_thermal: Limitling cpu0 max frequency to 1305600

  • 相关阅读:
    jni ndk 入门
    Activity 四种启动模式
    广播接收者 BroadcastReceiver
    android 焦点 ListView 点击事件获取失败
    android 动画效果
    JAVA 配置
    python 1:列表和字典
    poj1595 水题
    hdu 1181 深搜
    poj3264 划分树
  • 原文地址:https://www.cnblogs.com/liang123/p/6325131.html
Copyright © 2020-2023  润新知