diff options
| author | Arun Murthy <arun.murthy@stericsson.com> | 2012-02-29 11:24:25 -0500 |
|---|---|---|
| committer | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-03-26 12:41:02 -0400 |
| commit | 1668f81159fb72eda2114a9c73a64ffee045cb01 (patch) | |
| tree | c93f2386110dd43f57d27343bec461f75fd31321 /include/linux/mfd | |
| parent | ed1a230f96eb4610f1f4296b8c3c067389ddf540 (diff) | |
abx500-chargalg: Add abx500 charging algorithm
This is a charging algorithm driver for abx500 variants. It is the central
entity for battery driver and is responsible for charging and monitoring
the battery driver. It is a hardware independant driver and also monitors
other abx500 power supply devices.
Signed-off-by: Arun Murthy <arun.murthy@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'include/linux/mfd')
| -rw-r--r-- | include/linux/mfd/abx500.h | 273 | ||||
| -rw-r--r-- | include/linux/mfd/abx500/ux500_chargalg.h | 38 |
2 files changed, 311 insertions, 0 deletions
diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index 9970337ff04..8344196b000 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h | |||
| @@ -152,6 +152,279 @@ struct abx500_init_settings { | |||
| 152 | u8 setting; | 152 | u8 setting; |
| 153 | }; | 153 | }; |
| 154 | 154 | ||
| 155 | /* Battery driver related data */ | ||
| 156 | /* | ||
| 157 | * ADC for the battery thermistor. | ||
| 158 | * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined | ||
| 159 | * with a NTC resistor to both identify the battery and to measure its | ||
| 160 | * temperature. Different phone manufactures uses different techniques to both | ||
| 161 | * identify the battery and to read its temperature. | ||
| 162 | */ | ||
| 163 | enum abx500_adc_therm { | ||
| 164 | ABx500_ADC_THERM_BATCTRL, | ||
| 165 | ABx500_ADC_THERM_BATTEMP, | ||
| 166 | }; | ||
| 167 | |||
| 168 | /** | ||
| 169 | * struct abx500_res_to_temp - defines one point in a temp to res curve. To | ||
| 170 | * be used in battery packs that combines the identification resistor with a | ||
| 171 | * NTC resistor. | ||
| 172 | * @temp: battery pack temperature in Celcius | ||
| 173 | * @resist: NTC resistor net total resistance | ||
| 174 | */ | ||
| 175 | struct abx500_res_to_temp { | ||
| 176 | int temp; | ||
| 177 | int resist; | ||
| 178 | }; | ||
| 179 | |||
| 180 | /** | ||
| 181 | * struct abx500_v_to_cap - Table for translating voltage to capacity | ||
| 182 | * @voltage: Voltage in mV | ||
| 183 | * @capacity: Capacity in percent | ||
| 184 | */ | ||
| 185 | struct abx500_v_to_cap { | ||
| 186 | int voltage; | ||
| 187 | int capacity; | ||
| 188 | }; | ||
| 189 | |||
| 190 | /* Forward declaration */ | ||
| 191 | struct abx500_fg; | ||
| 192 | |||
| 193 | /** | ||
| 194 | * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds | ||
| 195 | * if not specified | ||
| 196 | * @recovery_sleep_timer: Time between measurements while recovering | ||
| 197 | * @recovery_total_time: Total recovery time | ||
| 198 | * @init_timer: Measurement interval during startup | ||
| 199 | * @init_discard_time: Time we discard voltage measurement at startup | ||
| 200 | * @init_total_time: Total init time during startup | ||
| 201 | * @high_curr_time: Time current has to be high to go to recovery | ||
| 202 | * @accu_charging: FG accumulation time while charging | ||
| 203 | * @accu_high_curr: FG accumulation time in high current mode | ||
| 204 | * @high_curr_threshold: High current threshold, in mA | ||
| 205 | * @lowbat_threshold: Low battery threshold, in mV | ||
| 206 | * @overbat_threshold: Over battery threshold, in mV | ||
| 207 | * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 | ||
| 208 | * Resolution in 50 mV step. | ||
| 209 | * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 | ||
| 210 | * Resolution in 50 mV step. | ||
| 211 | * @user_cap_limit Capacity reported from user must be within this | ||
| 212 | * limit to be considered as sane, in percentage | ||
| 213 | * points. | ||
| 214 | * @maint_thres This is the threshold where we stop reporting | ||
| 215 | * battery full while in maintenance, in per cent | ||
| 216 | */ | ||
| 217 | struct abx500_fg_parameters { | ||
| 218 | int recovery_sleep_timer; | ||
| 219 | int recovery_total_time; | ||
| 220 | int init_timer; | ||
| 221 | int init_discard_time; | ||
| 222 | int init_total_time; | ||
| 223 | int high_curr_time; | ||
| 224 | int accu_charging; | ||
| 225 | int accu_high_curr; | ||
| 226 | int high_curr_threshold; | ||
| 227 | int lowbat_threshold; | ||
| 228 | int overbat_threshold; | ||
| 229 | int battok_falling_th_sel0; | ||
| 230 | int battok_raising_th_sel1; | ||
| 231 | int user_cap_limit; | ||
| 232 | int maint_thres; | ||
| 233 | }; | ||
| 234 | |||
| 235 | /** | ||
| 236 | * struct abx500_charger_maximization - struct used by the board config. | ||
| 237 | * @use_maxi: Enable maximization for this battery type | ||
| 238 | * @maxi_chg_curr: Maximum charger current allowed | ||
| 239 | * @maxi_wait_cycles: cycles to wait before setting charger current | ||
| 240 | * @charger_curr_step delta between two charger current settings (mA) | ||
| 241 | */ | ||
| 242 | struct abx500_maxim_parameters { | ||
| 243 | bool ena_maxi; | ||
| 244 | int chg_curr; | ||
| 245 | int wait_cycles; | ||
| 246 | int charger_curr_step; | ||
| 247 | }; | ||
| 248 | |||
| 249 | /** | ||
| 250 | * struct abx500_battery_type - different batteries supported | ||
| 251 | * @name: battery technology | ||
| 252 | * @resis_high: battery upper resistance limit | ||
| 253 | * @resis_low: battery lower resistance limit | ||
| 254 | * @charge_full_design: Maximum battery capacity in mAh | ||
| 255 | * @nominal_voltage: Nominal voltage of the battery in mV | ||
| 256 | * @termination_vol: max voltage upto which battery can be charged | ||
| 257 | * @termination_curr battery charging termination current in mA | ||
| 258 | * @recharge_vol battery voltage limit that will trigger a new | ||
| 259 | * full charging cycle in the case where maintenan- | ||
| 260 | * -ce charging has been disabled | ||
| 261 | * @normal_cur_lvl: charger current in normal state in mA | ||
| 262 | * @normal_vol_lvl: charger voltage in normal state in mV | ||
| 263 | * @maint_a_cur_lvl: charger current in maintenance A state in mA | ||
| 264 | * @maint_a_vol_lvl: charger voltage in maintenance A state in mV | ||
| 265 | * @maint_a_chg_timer_h: charge time in maintenance A state | ||
| 266 | * @maint_b_cur_lvl: charger current in maintenance B state in mA | ||
| 267 | * @maint_b_vol_lvl: charger voltage in maintenance B state in mV | ||
| 268 | * @maint_b_chg_timer_h: charge time in maintenance B state | ||
| 269 | * @low_high_cur_lvl: charger current in temp low/high state in mA | ||
| 270 | * @low_high_vol_lvl: charger voltage in temp low/high state in mV' | ||
| 271 | * @battery_resistance: battery inner resistance in mOhm. | ||
| 272 | * @n_r_t_tbl_elements: number of elements in r_to_t_tbl | ||
| 273 | * @r_to_t_tbl: table containing resistance to temp points | ||
| 274 | * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl | ||
| 275 | * @v_to_cap_tbl: Voltage to capacity (in %) table | ||
| 276 | * @n_batres_tbl_elements number of elements in the batres_tbl | ||
| 277 | * @batres_tbl battery internal resistance vs temperature table | ||
| 278 | */ | ||
| 279 | struct abx500_battery_type { | ||
| 280 | int name; | ||
| 281 | int resis_high; | ||
| 282 | int resis_low; | ||
| 283 | int charge_full_design; | ||
| 284 | int nominal_voltage; | ||
| 285 | int termination_vol; | ||
| 286 | int termination_curr; | ||
| 287 | int recharge_vol; | ||
| 288 | int normal_cur_lvl; | ||
| 289 | int normal_vol_lvl; | ||
| 290 | int maint_a_cur_lvl; | ||
| 291 | int maint_a_vol_lvl; | ||
| 292 | int maint_a_chg_timer_h; | ||
| 293 | int maint_b_cur_lvl; | ||
| 294 | int maint_b_vol_lvl; | ||
| 295 | int maint_b_chg_timer_h; | ||
| 296 | int low_high_cur_lvl; | ||
| 297 | int low_high_vol_lvl; | ||
| 298 | int battery_resistance; | ||
| 299 | int n_temp_tbl_elements; | ||
| 300 | struct abx500_res_to_temp *r_to_t_tbl; | ||
| 301 | int n_v_cap_tbl_elements; | ||
| 302 | struct abx500_v_to_cap *v_to_cap_tbl; | ||
| 303 | int n_batres_tbl_elements; | ||
| 304 | struct batres_vs_temp *batres_tbl; | ||
| 305 | }; | ||
| 306 | |||
| 307 | /** | ||
| 308 | * struct abx500_bm_capacity_levels - abx500 capacity level data | ||
| 309 | * @critical: critical capacity level in percent | ||
| 310 | * @low: low capacity level in percent | ||
| 311 | * @normal: normal capacity level in percent | ||
| 312 | * @high: high capacity level in percent | ||
| 313 | * @full: full capacity level in percent | ||
| 314 | */ | ||
| 315 | struct abx500_bm_capacity_levels { | ||
| 316 | int critical; | ||
| 317 | int low; | ||
| 318 | int normal; | ||
| 319 | int high; | ||
| 320 | int full; | ||
| 321 | }; | ||
| 322 | |||
| 323 | /** | ||
| 324 | * struct abx500_bm_charger_parameters - Charger specific parameters | ||
| 325 | * @usb_volt_max: maximum allowed USB charger voltage in mV | ||
| 326 | * @usb_curr_max: maximum allowed USB charger current in mA | ||
| 327 | * @ac_volt_max: maximum allowed AC charger voltage in mV | ||
| 328 | * @ac_curr_max: maximum allowed AC charger current in mA | ||
| 329 | */ | ||
| 330 | struct abx500_bm_charger_parameters { | ||
| 331 | int usb_volt_max; | ||
| 332 | int usb_curr_max; | ||
| 333 | int ac_volt_max; | ||
| 334 | int ac_curr_max; | ||
| 335 | }; | ||
| 336 | |||
| 337 | /** | ||
| 338 | * struct abx500_bm_data - abx500 battery management data | ||
| 339 | * @temp_under under this temp, charging is stopped | ||
| 340 | * @temp_low between this temp and temp_under charging is reduced | ||
| 341 | * @temp_high between this temp and temp_over charging is reduced | ||
| 342 | * @temp_over over this temp, charging is stopped | ||
| 343 | * @temp_now present battery temperature | ||
| 344 | * @temp_interval_chg temperature measurement interval in s when charging | ||
| 345 | * @temp_interval_nochg temperature measurement interval in s when not charging | ||
| 346 | * @main_safety_tmr_h safety timer for main charger | ||
| 347 | * @usb_safety_tmr_h safety timer for usb charger | ||
| 348 | * @bkup_bat_v voltage which we charge the backup battery with | ||
| 349 | * @bkup_bat_i current which we charge the backup battery with | ||
| 350 | * @no_maintenance indicates that maintenance charging is disabled | ||
| 351 | * @abx500_adc_therm placement of thermistor, batctrl or battemp adc | ||
| 352 | * @chg_unknown_bat flag to enable charging of unknown batteries | ||
| 353 | * @enable_overshoot flag to enable VBAT overshoot control | ||
| 354 | * @auto_trig flag to enable auto adc trigger | ||
| 355 | * @fg_res resistance of FG resistor in 0.1mOhm | ||
| 356 | * @n_btypes number of elements in array bat_type | ||
| 357 | * @batt_id index of the identified battery in array bat_type | ||
| 358 | * @interval_charging charge alg cycle period time when charging (sec) | ||
| 359 | * @interval_not_charging charge alg cycle period time when not charging (sec) | ||
| 360 | * @temp_hysteresis temperature hysteresis | ||
| 361 | * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) | ||
| 362 | * @maxi: maximization parameters | ||
| 363 | * @cap_levels capacity in percent for the different capacity levels | ||
| 364 | * @bat_type table of supported battery types | ||
| 365 | * @chg_params charger parameters | ||
| 366 | * @fg_params fuel gauge parameters | ||
| 367 | */ | ||
| 368 | struct abx500_bm_data { | ||
| 369 | int temp_under; | ||
| 370 | int temp_low; | ||
| 371 | int temp_high; | ||
| 372 | int temp_over; | ||
| 373 | int temp_now; | ||
| 374 | int temp_interval_chg; | ||
| 375 | int temp_interval_nochg; | ||
| 376 | int main_safety_tmr_h; | ||
| 377 | int usb_safety_tmr_h; | ||
| 378 | int bkup_bat_v; | ||
| 379 | int bkup_bat_i; | ||
| 380 | bool no_maintenance; | ||
| 381 | bool chg_unknown_bat; | ||
| 382 | bool enable_overshoot; | ||
| 383 | bool auto_trig; | ||
| 384 | enum abx500_adc_therm adc_therm; | ||
| 385 | int fg_res; | ||
| 386 | int n_btypes; | ||
| 387 | int batt_id; | ||
| 388 | int interval_charging; | ||
| 389 | int interval_not_charging; | ||
| 390 | int temp_hysteresis; | ||
| 391 | int gnd_lift_resistance; | ||
| 392 | const struct abx500_maxim_parameters *maxi; | ||
| 393 | const struct abx500_bm_capacity_levels *cap_levels; | ||
| 394 | const struct abx500_battery_type *bat_type; | ||
| 395 | const struct abx500_bm_charger_parameters *chg_params; | ||
| 396 | const struct abx500_fg_parameters *fg_params; | ||
| 397 | }; | ||
| 398 | |||
| 399 | struct abx500_chargalg_platform_data { | ||
| 400 | char **supplied_to; | ||
| 401 | size_t num_supplicants; | ||
| 402 | }; | ||
| 403 | |||
| 404 | struct abx500_charger_platform_data { | ||
| 405 | char **supplied_to; | ||
| 406 | size_t num_supplicants; | ||
| 407 | bool autopower_cfg; | ||
| 408 | }; | ||
| 409 | |||
| 410 | struct abx500_btemp_platform_data { | ||
| 411 | char **supplied_to; | ||
| 412 | size_t num_supplicants; | ||
| 413 | }; | ||
| 414 | |||
| 415 | struct abx500_fg_platform_data { | ||
| 416 | char **supplied_to; | ||
| 417 | size_t num_supplicants; | ||
| 418 | }; | ||
| 419 | |||
| 420 | struct abx500_bm_plat_data { | ||
| 421 | struct abx500_bm_data *battery; | ||
| 422 | struct abx500_charger_platform_data *charger; | ||
| 423 | struct abx500_btemp_platform_data *btemp; | ||
| 424 | struct abx500_fg_platform_data *fg; | ||
| 425 | struct abx500_chargalg_platform_data *chargalg; | ||
| 426 | }; | ||
| 427 | |||
| 155 | int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, | 428 | int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, |
| 156 | u8 value); | 429 | u8 value); |
| 157 | int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg, | 430 | int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg, |
diff --git a/include/linux/mfd/abx500/ux500_chargalg.h b/include/linux/mfd/abx500/ux500_chargalg.h new file mode 100644 index 00000000000..9b07725750c --- /dev/null +++ b/include/linux/mfd/abx500/ux500_chargalg.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) ST-Ericsson SA 2012 | ||
| 3 | * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson. | ||
| 4 | * License terms: GNU General Public License (GPL), version 2 | ||
| 5 | */ | ||
| 6 | |||
| 7 | #ifndef _UX500_CHARGALG_H | ||
| 8 | #define _UX500_CHARGALG_H | ||
| 9 | |||
| 10 | #include <linux/power_supply.h> | ||
| 11 | |||
| 12 | #define psy_to_ux500_charger(x) container_of((x), \ | ||
| 13 | struct ux500_charger, psy) | ||
| 14 | |||
| 15 | /* Forward declaration */ | ||
| 16 | struct ux500_charger; | ||
| 17 | |||
| 18 | struct ux500_charger_ops { | ||
| 19 | int (*enable) (struct ux500_charger *, int, int, int); | ||
| 20 | int (*kick_wd) (struct ux500_charger *); | ||
| 21 | int (*update_curr) (struct ux500_charger *, int); | ||
| 22 | }; | ||
| 23 | |||
| 24 | /** | ||
| 25 | * struct ux500_charger - power supply ux500 charger sub class | ||
| 26 | * @psy power supply base class | ||
| 27 | * @ops ux500 charger operations | ||
| 28 | * @max_out_volt maximum output charger voltage in mV | ||
| 29 | * @max_out_curr maximum output charger current in mA | ||
| 30 | */ | ||
| 31 | struct ux500_charger { | ||
| 32 | struct power_supply psy; | ||
| 33 | struct ux500_charger_ops ops; | ||
| 34 | int max_out_volt; | ||
| 35 | int max_out_curr; | ||
| 36 | }; | ||
| 37 | |||
| 38 | #endif | ||
