ab8500-bm.h (417c0fc24dd4dbd60d94fa8deb36bf1176930e06) | ab8500-bm.h (ee0975c3089e1c3357ccc3ada7a94a95b61e708c) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3#ifndef _AB8500_CHARGER_H_ 4#define _AB8500_CHARGER_H_ 5 6#include <linux/kernel.h> | 1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3#ifndef _AB8500_CHARGER_H_ 4#define _AB8500_CHARGER_H_ 5 6#include <linux/kernel.h> |
7#include <linux/mfd/abx500.h> | |
8 9/* 10 * System control 2 register offsets. 11 * bank = 0x02 12 */ 13#define AB8500_MAIN_WDOG_CTRL_REG 0x01 14#define AB8500_LOW_BAT_REG 0x03 15#define AB8500_BATT_OK_REG 0x04 --- 247 unchanged lines hidden (view full) --- 263#define BUS_VSYS_VOL_SELECT_3P6V 0x00 264#define BUS_VSYS_VOL_SELECT_3P325V 0x02 265#define BUS_VSYS_VOL_SELECT_3P9V 0x04 266#define BUS_VSYS_VOL_SELECT_4P3V 0x06 267#define BUS_POWER_PATH_MODE_ENA 0x01 268#define BUS_PP_PRECHG_CURRENT_MASK 0x0E 269#define BUS_POWER_PATH_PRECHG_ENA 0x01 270 | 7 8/* 9 * System control 2 register offsets. 10 * bank = 0x02 11 */ 12#define AB8500_MAIN_WDOG_CTRL_REG 0x01 13#define AB8500_LOW_BAT_REG 0x03 14#define AB8500_BATT_OK_REG 0x04 --- 247 unchanged lines hidden (view full) --- 262#define BUS_VSYS_VOL_SELECT_3P6V 0x00 263#define BUS_VSYS_VOL_SELECT_3P325V 0x02 264#define BUS_VSYS_VOL_SELECT_3P9V 0x04 265#define BUS_VSYS_VOL_SELECT_4P3V 0x06 266#define BUS_POWER_PATH_MODE_ENA 0x01 267#define BUS_PP_PRECHG_CURRENT_MASK 0x0E 268#define BUS_POWER_PATH_PRECHG_ENA 0x01 269 |
270/* 271 * ADC for the battery thermistor. 272 * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined 273 * with a NTC resistor to both identify the battery and to measure its 274 * temperature. Different phone manufactures uses different techniques to both 275 * identify the battery and to read its temperature. 276 */ 277enum abx500_adc_therm { 278 ABx500_ADC_THERM_BATCTRL, 279 ABx500_ADC_THERM_BATTEMP, 280}; 281 |
|
271/** | 282/** |
283 * struct abx500_res_to_temp - defines one point in a temp to res curve. To 284 * be used in battery packs that combines the identification resistor with a 285 * NTC resistor. 286 * @temp: battery pack temperature in Celsius 287 * @resist: NTC resistor net total resistance 288 */ 289struct abx500_res_to_temp { 290 int temp; 291 int resist; 292}; 293 294/** 295 * struct abx500_v_to_cap - Table for translating voltage to capacity 296 * @voltage: Voltage in mV 297 * @capacity: Capacity in percent 298 */ 299struct abx500_v_to_cap { 300 int voltage; 301 int capacity; 302}; 303 304/* Forward declaration */ 305struct abx500_fg; 306 307/** 308 * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds 309 * if not specified 310 * @recovery_sleep_timer: Time between measurements while recovering 311 * @recovery_total_time: Total recovery time 312 * @init_timer: Measurement interval during startup 313 * @init_discard_time: Time we discard voltage measurement at startup 314 * @init_total_time: Total init time during startup 315 * @high_curr_time: Time current has to be high to go to recovery 316 * @accu_charging: FG accumulation time while charging 317 * @accu_high_curr: FG accumulation time in high current mode 318 * @high_curr_threshold: High current threshold, in mA 319 * @lowbat_threshold: Low battery threshold, in mV 320 * @overbat_threshold: Over battery threshold, in mV 321 * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 322 * Resolution in 50 mV step. 323 * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 324 * Resolution in 50 mV step. 325 * @user_cap_limit Capacity reported from user must be within this 326 * limit to be considered as sane, in percentage 327 * points. 328 * @maint_thres This is the threshold where we stop reporting 329 * battery full while in maintenance, in per cent 330 * @pcut_enable: Enable power cut feature in ab8505 331 * @pcut_max_time: Max time threshold 332 * @pcut_flag_time: Flagtime threshold 333 * @pcut_max_restart: Max number of restarts 334 * @pcut_debounce_time: Sets battery debounce time 335 */ 336struct abx500_fg_parameters { 337 int recovery_sleep_timer; 338 int recovery_total_time; 339 int init_timer; 340 int init_discard_time; 341 int init_total_time; 342 int high_curr_time; 343 int accu_charging; 344 int accu_high_curr; 345 int high_curr_threshold; 346 int lowbat_threshold; 347 int overbat_threshold; 348 int battok_falling_th_sel0; 349 int battok_raising_th_sel1; 350 int user_cap_limit; 351 int maint_thres; 352 bool pcut_enable; 353 u8 pcut_max_time; 354 u8 pcut_flag_time; 355 u8 pcut_max_restart; 356 u8 pcut_debounce_time; 357}; 358 359/** 360 * struct abx500_charger_maximization - struct used by the board config. 361 * @use_maxi: Enable maximization for this battery type 362 * @maxi_chg_curr: Maximum charger current allowed 363 * @maxi_wait_cycles: cycles to wait before setting charger current 364 * @charger_curr_step delta between two charger current settings (mA) 365 */ 366struct abx500_maxim_parameters { 367 bool ena_maxi; 368 int chg_curr; 369 int wait_cycles; 370 int charger_curr_step; 371}; 372 373/** 374 * struct abx500_battery_type - different batteries supported 375 * @name: battery technology 376 * @resis_high: battery upper resistance limit 377 * @resis_low: battery lower resistance limit 378 * @charge_full_design: Maximum battery capacity in mAh 379 * @nominal_voltage: Nominal voltage of the battery in mV 380 * @termination_vol: max voltage upto which battery can be charged 381 * @termination_curr battery charging termination current in mA 382 * @recharge_cap battery capacity limit that will trigger a new 383 * full charging cycle in the case where maintenan- 384 * -ce charging has been disabled 385 * @normal_cur_lvl: charger current in normal state in mA 386 * @normal_vol_lvl: charger voltage in normal state in mV 387 * @maint_a_cur_lvl: charger current in maintenance A state in mA 388 * @maint_a_vol_lvl: charger voltage in maintenance A state in mV 389 * @maint_a_chg_timer_h: charge time in maintenance A state 390 * @maint_b_cur_lvl: charger current in maintenance B state in mA 391 * @maint_b_vol_lvl: charger voltage in maintenance B state in mV 392 * @maint_b_chg_timer_h: charge time in maintenance B state 393 * @low_high_cur_lvl: charger current in temp low/high state in mA 394 * @low_high_vol_lvl: charger voltage in temp low/high state in mV' 395 * @battery_resistance: battery inner resistance in mOhm. 396 * @n_r_t_tbl_elements: number of elements in r_to_t_tbl 397 * @r_to_t_tbl: table containing resistance to temp points 398 * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl 399 * @v_to_cap_tbl: Voltage to capacity (in %) table 400 * @n_batres_tbl_elements number of elements in the batres_tbl 401 * @batres_tbl battery internal resistance vs temperature table 402 */ 403struct abx500_battery_type { 404 int name; 405 int resis_high; 406 int resis_low; 407 int charge_full_design; 408 int nominal_voltage; 409 int termination_vol; 410 int termination_curr; 411 int recharge_cap; 412 int normal_cur_lvl; 413 int normal_vol_lvl; 414 int maint_a_cur_lvl; 415 int maint_a_vol_lvl; 416 int maint_a_chg_timer_h; 417 int maint_b_cur_lvl; 418 int maint_b_vol_lvl; 419 int maint_b_chg_timer_h; 420 int low_high_cur_lvl; 421 int low_high_vol_lvl; 422 int battery_resistance; 423 int n_temp_tbl_elements; 424 const struct abx500_res_to_temp *r_to_t_tbl; 425 int n_v_cap_tbl_elements; 426 const struct abx500_v_to_cap *v_to_cap_tbl; 427 int n_batres_tbl_elements; 428 const struct batres_vs_temp *batres_tbl; 429}; 430 431/** 432 * struct abx500_bm_capacity_levels - abx500 capacity level data 433 * @critical: critical capacity level in percent 434 * @low: low capacity level in percent 435 * @normal: normal capacity level in percent 436 * @high: high capacity level in percent 437 * @full: full capacity level in percent 438 */ 439struct abx500_bm_capacity_levels { 440 int critical; 441 int low; 442 int normal; 443 int high; 444 int full; 445}; 446 447/** 448 * struct abx500_bm_charger_parameters - Charger specific parameters 449 * @usb_volt_max: maximum allowed USB charger voltage in mV 450 * @usb_curr_max: maximum allowed USB charger current in mA 451 * @ac_volt_max: maximum allowed AC charger voltage in mV 452 * @ac_curr_max: maximum allowed AC charger current in mA 453 */ 454struct abx500_bm_charger_parameters { 455 int usb_volt_max; 456 int usb_curr_max; 457 int ac_volt_max; 458 int ac_curr_max; 459}; 460 461/** 462 * struct abx500_bm_data - abx500 battery management data 463 * @temp_under under this temp, charging is stopped 464 * @temp_low between this temp and temp_under charging is reduced 465 * @temp_high between this temp and temp_over charging is reduced 466 * @temp_over over this temp, charging is stopped 467 * @temp_now present battery temperature 468 * @temp_interval_chg temperature measurement interval in s when charging 469 * @temp_interval_nochg temperature measurement interval in s when not charging 470 * @main_safety_tmr_h safety timer for main charger 471 * @usb_safety_tmr_h safety timer for usb charger 472 * @bkup_bat_v voltage which we charge the backup battery with 473 * @bkup_bat_i current which we charge the backup battery with 474 * @no_maintenance indicates that maintenance charging is disabled 475 * @capacity_scaling indicates whether capacity scaling is to be used 476 * @abx500_adc_therm placement of thermistor, batctrl or battemp adc 477 * @chg_unknown_bat flag to enable charging of unknown batteries 478 * @enable_overshoot flag to enable VBAT overshoot control 479 * @auto_trig flag to enable auto adc trigger 480 * @fg_res resistance of FG resistor in 0.1mOhm 481 * @n_btypes number of elements in array bat_type 482 * @batt_id index of the identified battery in array bat_type 483 * @interval_charging charge alg cycle period time when charging (sec) 484 * @interval_not_charging charge alg cycle period time when not charging (sec) 485 * @temp_hysteresis temperature hysteresis 486 * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) 487 * @n_chg_out_curr number of elements in array chg_output_curr 488 * @n_chg_in_curr number of elements in array chg_input_curr 489 * @chg_output_curr charger output current level map 490 * @chg_input_curr charger input current level map 491 * @maxi maximization parameters 492 * @cap_levels capacity in percent for the different capacity levels 493 * @bat_type table of supported battery types 494 * @chg_params charger parameters 495 * @fg_params fuel gauge parameters 496 */ 497struct abx500_bm_data { 498 int temp_under; 499 int temp_low; 500 int temp_high; 501 int temp_over; 502 int temp_now; 503 int temp_interval_chg; 504 int temp_interval_nochg; 505 int main_safety_tmr_h; 506 int usb_safety_tmr_h; 507 int bkup_bat_v; 508 int bkup_bat_i; 509 bool autopower_cfg; 510 bool ac_enabled; 511 bool usb_enabled; 512 bool no_maintenance; 513 bool capacity_scaling; 514 bool chg_unknown_bat; 515 bool enable_overshoot; 516 bool auto_trig; 517 enum abx500_adc_therm adc_therm; 518 int fg_res; 519 int n_btypes; 520 int batt_id; 521 int interval_charging; 522 int interval_not_charging; 523 int temp_hysteresis; 524 int gnd_lift_resistance; 525 int n_chg_out_curr; 526 int n_chg_in_curr; 527 int *chg_output_curr; 528 int *chg_input_curr; 529 const struct abx500_maxim_parameters *maxi; 530 const struct abx500_bm_capacity_levels *cap_levels; 531 struct abx500_battery_type *bat_type; 532 const struct abx500_bm_charger_parameters *chg_params; 533 const struct abx500_fg_parameters *fg_params; 534}; 535 536enum { 537 NTC_EXTERNAL = 0, 538 NTC_INTERNAL, 539}; 540 541/** |
|
272 * struct res_to_temp - defines one point in a temp to res curve. To 273 * be used in battery packs that combines the identification resistor with a 274 * NTC resistor. 275 * @temp: battery pack temperature in Celsius 276 * @resist: NTC resistor net total resistance 277 */ 278struct res_to_temp { 279 int temp; --- 162 unchanged lines hidden (view full) --- 442 int temp_hysteresis; 443 int gnd_lift_resistance; 444 const struct ab8500_maxim_parameters *maxi; 445 const struct ab8500_bm_capacity_levels *cap_levels; 446 const struct ab8500_bm_charger_parameters *chg_params; 447 const struct ab8500_fg_parameters *fg_params; 448}; 449 | 542 * struct res_to_temp - defines one point in a temp to res curve. To 543 * be used in battery packs that combines the identification resistor with a 544 * NTC resistor. 545 * @temp: battery pack temperature in Celsius 546 * @resist: NTC resistor net total resistance 547 */ 548struct res_to_temp { 549 int temp; --- 162 unchanged lines hidden (view full) --- 712 int temp_hysteresis; 713 int gnd_lift_resistance; 714 const struct ab8500_maxim_parameters *maxi; 715 const struct ab8500_bm_capacity_levels *cap_levels; 716 const struct ab8500_bm_charger_parameters *chg_params; 717 const struct ab8500_fg_parameters *fg_params; 718}; 719 |
450struct ab8500_btemp; 451struct ab8500_fg; 452 | |
453extern struct abx500_bm_data ab8500_bm_data; 454 455void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); 456struct ab8500_fg *ab8500_fg_get(void); 457int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); 458int ab8500_fg_inst_curr_start(struct ab8500_fg *di); 459int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); 460int ab8500_fg_inst_curr_started(struct ab8500_fg *di); 461int ab8500_fg_inst_curr_done(struct ab8500_fg *di); | 720extern struct abx500_bm_data ab8500_bm_data; 721 722void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); 723struct ab8500_fg *ab8500_fg_get(void); 724int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); 725int ab8500_fg_inst_curr_start(struct ab8500_fg *di); 726int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); 727int ab8500_fg_inst_curr_started(struct ab8500_fg *di); 728int ab8500_fg_inst_curr_done(struct ab8500_fg *di); |
729int ab8500_bm_of_probe(struct device *dev, 730 struct device_node *np, 731 struct abx500_bm_data *bm); |
|
462 463#endif /* _AB8500_CHARGER_H_ */ | 732 733#endif /* _AB8500_CHARGER_H_ */ |