1 /* SPDX-License-Identifier: GPL-2.0-only */ << 2 /* 1 /* 3 * Copyright (C) 2007-2009 ST-Ericsson AB 2 * Copyright (C) 2007-2009 ST-Ericsson AB >> 3 * License terms: GNU General Public License (GPL) version 2 4 * 4 * 5 * ABX500 core access functions. 5 * ABX500 core access functions. 6 * The abx500 interface is used for the Analog 6 * The abx500 interface is used for the Analog Baseband chips. 7 * 7 * 8 * Author: Mattias Wallin <mattias.wallin@ster 8 * Author: Mattias Wallin <mattias.wallin@stericsson.com> 9 * Author: Mattias Nilsson <mattias.i.nilsson@ 9 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> 10 * Author: Bengt Jonsson <bengt.g.jonsson@ster 10 * Author: Bengt Jonsson <bengt.g.jonsson@stericsson.com> 11 * Author: Rickard Andersson <rickard.andersso 11 * Author: Rickard Andersson <rickard.andersson@stericsson.com> 12 */ 12 */ 13 13 14 #include <linux/regulator/machine.h> 14 #include <linux/regulator/machine.h> 15 15 16 struct device; 16 struct device; 17 17 18 #ifndef MFD_ABX500_H 18 #ifndef MFD_ABX500_H 19 #define MFD_ABX500_H 19 #define MFD_ABX500_H 20 20 21 /** 21 /** 22 * struct abx500_init_setting 22 * struct abx500_init_setting 23 * Initial value of the registers for driver t 23 * Initial value of the registers for driver to use during setup. 24 */ 24 */ 25 struct abx500_init_settings { 25 struct abx500_init_settings { 26 u8 bank; 26 u8 bank; 27 u8 reg; 27 u8 reg; 28 u8 setting; 28 u8 setting; 29 }; 29 }; >> 30 >> 31 /* Battery driver related data */ >> 32 /* >> 33 * ADC for the battery thermistor. >> 34 * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined >> 35 * with a NTC resistor to both identify the battery and to measure its >> 36 * temperature. Different phone manufactures uses different techniques to both >> 37 * identify the battery and to read its temperature. >> 38 */ >> 39 enum abx500_adc_therm { >> 40 ABx500_ADC_THERM_BATCTRL, >> 41 ABx500_ADC_THERM_BATTEMP, >> 42 }; >> 43 >> 44 /** >> 45 * struct abx500_res_to_temp - defines one point in a temp to res curve. To >> 46 * be used in battery packs that combines the identification resistor with a >> 47 * NTC resistor. >> 48 * @temp: battery pack temperature in Celsius >> 49 * @resist: NTC resistor net total resistance >> 50 */ >> 51 struct abx500_res_to_temp { >> 52 int temp; >> 53 int resist; >> 54 }; >> 55 >> 56 /** >> 57 * struct abx500_v_to_cap - Table for translating voltage to capacity >> 58 * @voltage: Voltage in mV >> 59 * @capacity: Capacity in percent >> 60 */ >> 61 struct abx500_v_to_cap { >> 62 int voltage; >> 63 int capacity; >> 64 }; >> 65 >> 66 /* Forward declaration */ >> 67 struct abx500_fg; >> 68 >> 69 /** >> 70 * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds >> 71 * if not specified >> 72 * @recovery_sleep_timer: Time between measurements while recovering >> 73 * @recovery_total_time: Total recovery time >> 74 * @init_timer: Measurement interval during startup >> 75 * @init_discard_time: Time we discard voltage measurement at startup >> 76 * @init_total_time: Total init time during startup >> 77 * @high_curr_time: Time current has to be high to go to recovery >> 78 * @accu_charging: FG accumulation time while charging >> 79 * @accu_high_curr: FG accumulation time in high current mode >> 80 * @high_curr_threshold: High current threshold, in mA >> 81 * @lowbat_threshold: Low battery threshold, in mV >> 82 * @overbat_threshold: Over battery threshold, in mV >> 83 * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 >> 84 * Resolution in 50 mV step. >> 85 * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 >> 86 * Resolution in 50 mV step. >> 87 * @user_cap_limit Capacity reported from user must be within this >> 88 * limit to be considered as sane, in percentage >> 89 * points. >> 90 * @maint_thres This is the threshold where we stop reporting >> 91 * battery full while in maintenance, in per cent >> 92 * @pcut_enable: Enable power cut feature in ab8505 >> 93 * @pcut_max_time: Max time threshold >> 94 * @pcut_flag_time: Flagtime threshold >> 95 * @pcut_max_restart: Max number of restarts >> 96 * @pcut_debounce_time: Sets battery debounce time >> 97 */ >> 98 struct abx500_fg_parameters { >> 99 int recovery_sleep_timer; >> 100 int recovery_total_time; >> 101 int init_timer; >> 102 int init_discard_time; >> 103 int init_total_time; >> 104 int high_curr_time; >> 105 int accu_charging; >> 106 int accu_high_curr; >> 107 int high_curr_threshold; >> 108 int lowbat_threshold; >> 109 int overbat_threshold; >> 110 int battok_falling_th_sel0; >> 111 int battok_raising_th_sel1; >> 112 int user_cap_limit; >> 113 int maint_thres; >> 114 bool pcut_enable; >> 115 u8 pcut_max_time; >> 116 u8 pcut_flag_time; >> 117 u8 pcut_max_restart; >> 118 u8 pcut_debounce_time; >> 119 }; >> 120 >> 121 /** >> 122 * struct abx500_charger_maximization - struct used by the board config. >> 123 * @use_maxi: Enable maximization for this battery type >> 124 * @maxi_chg_curr: Maximum charger current allowed >> 125 * @maxi_wait_cycles: cycles to wait before setting charger current >> 126 * @charger_curr_step delta between two charger current settings (mA) >> 127 */ >> 128 struct abx500_maxim_parameters { >> 129 bool ena_maxi; >> 130 int chg_curr; >> 131 int wait_cycles; >> 132 int charger_curr_step; >> 133 }; >> 134 >> 135 /** >> 136 * struct abx500_battery_type - different batteries supported >> 137 * @name: battery technology >> 138 * @resis_high: battery upper resistance limit >> 139 * @resis_low: battery lower resistance limit >> 140 * @charge_full_design: Maximum battery capacity in mAh >> 141 * @nominal_voltage: Nominal voltage of the battery in mV >> 142 * @termination_vol: max voltage upto which battery can be charged >> 143 * @termination_curr battery charging termination current in mA >> 144 * @recharge_cap battery capacity limit that will trigger a new >> 145 * full charging cycle in the case where maintenan- >> 146 * -ce charging has been disabled >> 147 * @normal_cur_lvl: charger current in normal state in mA >> 148 * @normal_vol_lvl: charger voltage in normal state in mV >> 149 * @maint_a_cur_lvl: charger current in maintenance A state in mA >> 150 * @maint_a_vol_lvl: charger voltage in maintenance A state in mV >> 151 * @maint_a_chg_timer_h: charge time in maintenance A state >> 152 * @maint_b_cur_lvl: charger current in maintenance B state in mA >> 153 * @maint_b_vol_lvl: charger voltage in maintenance B state in mV >> 154 * @maint_b_chg_timer_h: charge time in maintenance B state >> 155 * @low_high_cur_lvl: charger current in temp low/high state in mA >> 156 * @low_high_vol_lvl: charger voltage in temp low/high state in mV' >> 157 * @battery_resistance: battery inner resistance in mOhm. >> 158 * @n_r_t_tbl_elements: number of elements in r_to_t_tbl >> 159 * @r_to_t_tbl: table containing resistance to temp points >> 160 * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl >> 161 * @v_to_cap_tbl: Voltage to capacity (in %) table >> 162 * @n_batres_tbl_elements number of elements in the batres_tbl >> 163 * @batres_tbl battery internal resistance vs temperature table >> 164 */ >> 165 struct abx500_battery_type { >> 166 int name; >> 167 int resis_high; >> 168 int resis_low; >> 169 int charge_full_design; >> 170 int nominal_voltage; >> 171 int termination_vol; >> 172 int termination_curr; >> 173 int recharge_cap; >> 174 int normal_cur_lvl; >> 175 int normal_vol_lvl; >> 176 int maint_a_cur_lvl; >> 177 int maint_a_vol_lvl; >> 178 int maint_a_chg_timer_h; >> 179 int maint_b_cur_lvl; >> 180 int maint_b_vol_lvl; >> 181 int maint_b_chg_timer_h; >> 182 int low_high_cur_lvl; >> 183 int low_high_vol_lvl; >> 184 int battery_resistance; >> 185 int n_temp_tbl_elements; >> 186 const struct abx500_res_to_temp *r_to_t_tbl; >> 187 int n_v_cap_tbl_elements; >> 188 const struct abx500_v_to_cap *v_to_cap_tbl; >> 189 int n_batres_tbl_elements; >> 190 const struct batres_vs_temp *batres_tbl; >> 191 }; >> 192 >> 193 /** >> 194 * struct abx500_bm_capacity_levels - abx500 capacity level data >> 195 * @critical: critical capacity level in percent >> 196 * @low: low capacity level in percent >> 197 * @normal: normal capacity level in percent >> 198 * @high: high capacity level in percent >> 199 * @full: full capacity level in percent >> 200 */ >> 201 struct abx500_bm_capacity_levels { >> 202 int critical; >> 203 int low; >> 204 int normal; >> 205 int high; >> 206 int full; >> 207 }; >> 208 >> 209 /** >> 210 * struct abx500_bm_charger_parameters - Charger specific parameters >> 211 * @usb_volt_max: maximum allowed USB charger voltage in mV >> 212 * @usb_curr_max: maximum allowed USB charger current in mA >> 213 * @ac_volt_max: maximum allowed AC charger voltage in mV >> 214 * @ac_curr_max: maximum allowed AC charger current in mA >> 215 */ >> 216 struct abx500_bm_charger_parameters { >> 217 int usb_volt_max; >> 218 int usb_curr_max; >> 219 int ac_volt_max; >> 220 int ac_curr_max; >> 221 }; >> 222 >> 223 /** >> 224 * struct abx500_bm_data - abx500 battery management data >> 225 * @temp_under under this temp, charging is stopped >> 226 * @temp_low between this temp and temp_under charging is reduced >> 227 * @temp_high between this temp and temp_over charging is reduced >> 228 * @temp_over over this temp, charging is stopped >> 229 * @temp_now present battery temperature >> 230 * @temp_interval_chg temperature measurement interval in s when charging >> 231 * @temp_interval_nochg temperature measurement interval in s when not charging >> 232 * @main_safety_tmr_h safety timer for main charger >> 233 * @usb_safety_tmr_h safety timer for usb charger >> 234 * @bkup_bat_v voltage which we charge the backup battery with >> 235 * @bkup_bat_i current which we charge the backup battery with >> 236 * @no_maintenance indicates that maintenance charging is disabled >> 237 * @capacity_scaling indicates whether capacity scaling is to be used >> 238 * @abx500_adc_therm placement of thermistor, batctrl or battemp adc >> 239 * @chg_unknown_bat flag to enable charging of unknown batteries >> 240 * @enable_overshoot flag to enable VBAT overshoot control >> 241 * @auto_trig flag to enable auto adc trigger >> 242 * @fg_res resistance of FG resistor in 0.1mOhm >> 243 * @n_btypes number of elements in array bat_type >> 244 * @batt_id index of the identified battery in array bat_type >> 245 * @interval_charging charge alg cycle period time when charging (sec) >> 246 * @interval_not_charging charge alg cycle period time when not charging (sec) >> 247 * @temp_hysteresis temperature hysteresis >> 248 * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) >> 249 * @n_chg_out_curr number of elements in array chg_output_curr >> 250 * @n_chg_in_curr number of elements in array chg_input_curr >> 251 * @chg_output_curr charger output current level map >> 252 * @chg_input_curr charger input current level map >> 253 * @maxi maximization parameters >> 254 * @cap_levels capacity in percent for the different capacity levels >> 255 * @bat_type table of supported battery types >> 256 * @chg_params charger parameters >> 257 * @fg_params fuel gauge parameters >> 258 */ >> 259 struct abx500_bm_data { >> 260 int temp_under; >> 261 int temp_low; >> 262 int temp_high; >> 263 int temp_over; >> 264 int temp_now; >> 265 int temp_interval_chg; >> 266 int temp_interval_nochg; >> 267 int main_safety_tmr_h; >> 268 int usb_safety_tmr_h; >> 269 int bkup_bat_v; >> 270 int bkup_bat_i; >> 271 bool autopower_cfg; >> 272 bool ac_enabled; >> 273 bool usb_enabled; >> 274 bool no_maintenance; >> 275 bool capacity_scaling; >> 276 bool chg_unknown_bat; >> 277 bool enable_overshoot; >> 278 bool auto_trig; >> 279 enum abx500_adc_therm adc_therm; >> 280 int fg_res; >> 281 int n_btypes; >> 282 int batt_id; >> 283 int interval_charging; >> 284 int interval_not_charging; >> 285 int temp_hysteresis; >> 286 int gnd_lift_resistance; >> 287 int n_chg_out_curr; >> 288 int n_chg_in_curr; >> 289 int *chg_output_curr; >> 290 int *chg_input_curr; >> 291 const struct abx500_maxim_parameters *maxi; >> 292 const struct abx500_bm_capacity_levels *cap_levels; >> 293 struct abx500_battery_type *bat_type; >> 294 const struct abx500_bm_charger_parameters *chg_params; >> 295 const struct abx500_fg_parameters *fg_params; >> 296 }; >> 297 >> 298 enum { >> 299 NTC_EXTERNAL = 0, >> 300 NTC_INTERNAL, >> 301 }; >> 302 >> 303 int ab8500_bm_of_probe(struct device *dev, >> 304 struct device_node *np, >> 305 struct abx500_bm_data *bm); 30 306 31 int abx500_set_register_interruptible(struct d 307 int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, 32 u8 value); 308 u8 value); 33 int abx500_get_register_interruptible(struct d 309 int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg, 34 u8 *value); 310 u8 *value); 35 int abx500_get_register_page_interruptible(str 311 int abx500_get_register_page_interruptible(struct device *dev, u8 bank, 36 u8 first_reg, u8 *regvals, u8 numregs) 312 u8 first_reg, u8 *regvals, u8 numregs); 37 int abx500_set_register_page_interruptible(str 313 int abx500_set_register_page_interruptible(struct device *dev, u8 bank, 38 u8 first_reg, u8 *regvals, u8 numregs) 314 u8 first_reg, u8 *regvals, u8 numregs); 39 /** 315 /** 40 * abx500_mask_and_set_register_inerruptible() 316 * abx500_mask_and_set_register_inerruptible() - Modifies selected bits of a 41 * target register 317 * target register 42 * 318 * 43 * @dev: The AB sub device. 319 * @dev: The AB sub device. 44 * @bank: The i2c bank number. 320 * @bank: The i2c bank number. 45 * @bitmask: The bit mask to use. 321 * @bitmask: The bit mask to use. 46 * @bitvalues: The new bit values. 322 * @bitvalues: The new bit values. 47 * 323 * 48 * Updates the value of an AB register: 324 * Updates the value of an AB register: 49 * value -> ((value & ~bitmask) | (bitvalues & 325 * value -> ((value & ~bitmask) | (bitvalues & bitmask)) 50 */ 326 */ 51 int abx500_mask_and_set_register_interruptible 327 int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank, 52 u8 reg, u8 bitmask, u8 bitvalues); 328 u8 reg, u8 bitmask, u8 bitvalues); 53 int abx500_get_chip_id(struct device *dev); 329 int abx500_get_chip_id(struct device *dev); 54 int abx500_event_registers_startup_state_get(s 330 int abx500_event_registers_startup_state_get(struct device *dev, u8 *event); 55 int abx500_startup_irq_enabled(struct device * 331 int abx500_startup_irq_enabled(struct device *dev, unsigned int irq); 56 332 57 struct abx500_ops { 333 struct abx500_ops { 58 int (*get_chip_id) (struct device *); 334 int (*get_chip_id) (struct device *); 59 int (*get_register) (struct device *, 335 int (*get_register) (struct device *, u8, u8, u8 *); 60 int (*set_register) (struct device *, 336 int (*set_register) (struct device *, u8, u8, u8); 61 int (*get_register_page) (struct devic 337 int (*get_register_page) (struct device *, u8, u8, u8 *, u8); 62 int (*set_register_page) (struct devic 338 int (*set_register_page) (struct device *, u8, u8, u8 *, u8); 63 int (*mask_and_set_register) (struct d 339 int (*mask_and_set_register) (struct device *, u8, u8, u8, u8); 64 int (*event_registers_startup_state_ge 340 int (*event_registers_startup_state_get) (struct device *, u8 *); 65 int (*startup_irq_enabled) (struct dev 341 int (*startup_irq_enabled) (struct device *, unsigned int); 66 void (*dump_all_banks) (struct device 342 void (*dump_all_banks) (struct device *); 67 }; 343 }; 68 344 69 int abx500_register_ops(struct device *core_de 345 int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops); 70 void abx500_remove_ops(struct device *dev); 346 void abx500_remove_ops(struct device *dev); 71 #endif 347 #endif 72 348
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.