高通開發筆記---yukon worknote

點擊打開連接
css

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

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

2、. 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/android

   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/enablegit

4、如何查看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 打開瀏覽shell

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

6、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);ide

  /* 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);
 
 }ui

 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

7、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)則觸發

8、檢測AICL功能
  qpnp_chg_aicl_work

9、miscTA 2227, 55->50

10、耳機檢測
   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),
};

11、如何添加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>;
   };
  }

12、增長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);

十3、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


十4、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

十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\n", __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;
}

十6、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

十7、幾個關鍵電壓 
1. 3.2V關機電壓,kernel 設置
2. 3.3v 沒有充電時的開機電壓, 3.42v 充電時的開機電壓


十8、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同一套數據

十9、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/


二10、
手動設置電池容量
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

相關文章
相關標籤/搜索