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