ハイパスkernel充電パラメータ定義
1.logからkernel初期化充電モジュールsubsys_initcall(batterydata_init);開始します.
[ 2.818350] BATTERY: batterydata_init: Battery-data device created!
2.batterydata_Initは何をしましたか?
コードを見て
主に充填構造体struct battery_data *battery;その他は、通常のシステム呼び出しモジュール、デバイス登録、ノードロードです.
構造体を見てみましょうdataの中に何がありますか?
*profile;この構造体は、他のものはすべて通用します.
bmsを見てbattery_dataの中身は何ですか?
ここには充電に関するパラメータ定義がたくさんあります.私たちが探しているパラメータです.具体的なパラメータの意味にはコメントがあります.
[ 2.818350] BATTERY: batterydata_init: Battery-data device created!
2.batterydata_Initは何をしましたか?
コードを見て
int batterydata_init(void)
{
int rc;
struct battery_data *battery;
battery = kzalloc(sizeof(*battery), GFP_KERNEL);
if (!battery) {
pr_err("Unable to allocate memory
");
return -ENOMEM;
}
/* character device to access the battery-data from userspace */
rc = alloc_chrdev_region(&battery->dev_no, 0, 1, "battery_data");
if (rc) {
pr_err("Unable to allocate chrdev rc=%d
", rc);
return rc;
}
cdev_init(&battery->battery_cdev, &battery_data_fops);
rc = cdev_add(&battery->battery_cdev, battery->dev_no, 1);
if (rc) {
pr_err("Unable to add battery_cdev rc=%d
", rc);
goto unregister_chrdev;
}
battery->battery_class = class_create(THIS_MODULE, "battery_data");
if (IS_ERR_OR_NULL(battery->battery_class)) {
pr_err("Fail to create battery class
");
rc = -ENODEV;
goto delete_cdev;
}
battery->battery_device = device_create(battery->battery_class,
NULL, battery->dev_no,
NULL, "battery_data");
if (IS_ERR(battery->battery_device)) {
pr_err("Fail to create battery_device device
");
rc = -ENODEV;
goto delete_cdev;
}
the_battery = battery;
pr_info("Battery-data device created!
");
return 0;
delete_cdev:
cdev_del(&battery->battery_cdev);
unregister_chrdev:
unregister_chrdev_region(battery->dev_no, 1);
the_battery = NULL;
return rc;
}
主に充填構造体struct battery_data *battery;その他は、通常のシステム呼び出しモジュール、デバイス登録、ノードロードです.
構造体を見てみましょうdataの中に何がありますか?
struct battery_data {
dev_t dev_no;
struct class *battery_class;
struct device *battery_device;
struct cdev battery_cdev;
struct bms_battery_data *profile;
};
は主にstruct bms_battery_data *profile;この構造体は、他のものはすべて通用します.
bmsを見てbattery_dataの中身は何ですか?
/**
* struct bms_battery_data -
* @fcc: full charge capacity (mAmpHour)
* @fcc_temp_lut: table to get fcc at a given temp
* @pc_temp_ocv_lut: table to get percent charge given batt temp and cycles
* @pc_sf_lut: table to get percent charge scaling factor given cycles
* and percent charge
* @rbatt_sf_lut: table to get battery resistance scaling factor given
* temperature and percent charge
* @default_rbatt_mohm: the default value of battery resistance to use when
* readings from bms are not available.
* @delta_rbatt_mohm: the resistance to be added towards lower soc to
* compensate for battery capacitance.
* @rbatt_capacitve_mohm: the resistance to be added to compensate for
* battery capacitance
* @flat_ocv_threshold_uv: the voltage where the battery's discharge curve
* starts flattening out.
* @max_voltage_uv: max voltage of the battery
* @cutoff_uv: cutoff voltage of the battery
* @iterm_ua: termination current of the battery when charging
* to 100%
* @batt_id_kohm: the best matched battery id resistor value
* @fastchg_current_ma: maximum fast charge current
* @fg_cc_cv_threshold_mv: CC to CV threashold voltage
*/
struct bms_battery_data {
unsigned int fcc;
struct single_row_lut *fcc_temp_lut;
struct single_row_lut *fcc_sf_lut;
struct pc_temp_ocv_lut *pc_temp_ocv_lut;
struct ibat_temp_acc_lut *ibat_acc_lut;
struct sf_lut *pc_sf_lut;
struct sf_lut *rbatt_sf_lut;
int default_rbatt_mohm;
int delta_rbatt_mohm;
int rbatt_capacitive_mohm;
int flat_ocv_threshold_uv;
int max_voltage_uv;
int cutoff_uv;
int iterm_ua;
int batt_id_kohm;
int fastchg_current_ma;
int fg_cc_cv_threshold_mv;
const char *battery_type;
};
ここには充電に関するパラメータ定義がたくさんあります.私たちが探しているパラメータです.具体的なパラメータの意味にはコメントがあります.