rtlwifi: rtl8723ae: Fix W=1 compile warnings
[linux-2.6-block.git] / include / linux / mfd / abx500.h
CommitLineData
14fa5691
LW
1/*
2 * Copyright (C) 2007-2009 ST-Ericsson AB
3 * License terms: GNU General Public License (GPL) version 2
fa661258
MW
4 *
5 * ABX500 core access functions.
0fd0013c 6 * The abx500 interface is used for the Analog Baseband chips.
fa661258
MW
7 *
8 * Author: Mattias Wallin <mattias.wallin@stericsson.com>
9 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com>
10 * Author: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
11 * Author: Rickard Andersson <rickard.andersson@stericsson.com>
14fa5691
LW
12 */
13
d619bc14 14#include <linux/regulator/machine.h>
14fa5691 15
313162d0
PG
16struct device;
17
fa661258
MW
18#ifndef MFD_ABX500_H
19#define MFD_ABX500_H
14fa5691 20
fa661258
MW
21/**
22 * struct abx500_init_setting
23 * Initial value of the registers for driver to use during setup.
24 */
25struct abx500_init_settings {
26 u8 bank;
27 u8 reg;
28 u8 setting;
29};
30
1668f811
AM
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 */
39enum 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 Celcius
49 * @resist: NTC resistor net total resistance
50 */
51struct 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 */
61struct abx500_v_to_cap {
62 int voltage;
63 int capacity;
64};
65
66/* Forward declaration */
67struct 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 */
93struct abx500_fg_parameters {
94 int recovery_sleep_timer;
95 int recovery_total_time;
96 int init_timer;
97 int init_discard_time;
98 int init_total_time;
99 int high_curr_time;
100 int accu_charging;
101 int accu_high_curr;
102 int high_curr_threshold;
103 int lowbat_threshold;
104 int overbat_threshold;
105 int battok_falling_th_sel0;
106 int battok_raising_th_sel1;
107 int user_cap_limit;
108 int maint_thres;
109};
110
111/**
112 * struct abx500_charger_maximization - struct used by the board config.
113 * @use_maxi: Enable maximization for this battery type
114 * @maxi_chg_curr: Maximum charger current allowed
115 * @maxi_wait_cycles: cycles to wait before setting charger current
116 * @charger_curr_step delta between two charger current settings (mA)
117 */
118struct abx500_maxim_parameters {
119 bool ena_maxi;
120 int chg_curr;
121 int wait_cycles;
122 int charger_curr_step;
123};
124
125/**
126 * struct abx500_battery_type - different batteries supported
127 * @name: battery technology
128 * @resis_high: battery upper resistance limit
129 * @resis_low: battery lower resistance limit
130 * @charge_full_design: Maximum battery capacity in mAh
131 * @nominal_voltage: Nominal voltage of the battery in mV
132 * @termination_vol: max voltage upto which battery can be charged
133 * @termination_curr battery charging termination current in mA
134 * @recharge_vol battery voltage limit that will trigger a new
135 * full charging cycle in the case where maintenan-
136 * -ce charging has been disabled
137 * @normal_cur_lvl: charger current in normal state in mA
138 * @normal_vol_lvl: charger voltage in normal state in mV
139 * @maint_a_cur_lvl: charger current in maintenance A state in mA
140 * @maint_a_vol_lvl: charger voltage in maintenance A state in mV
141 * @maint_a_chg_timer_h: charge time in maintenance A state
142 * @maint_b_cur_lvl: charger current in maintenance B state in mA
143 * @maint_b_vol_lvl: charger voltage in maintenance B state in mV
144 * @maint_b_chg_timer_h: charge time in maintenance B state
145 * @low_high_cur_lvl: charger current in temp low/high state in mA
146 * @low_high_vol_lvl: charger voltage in temp low/high state in mV'
147 * @battery_resistance: battery inner resistance in mOhm.
148 * @n_r_t_tbl_elements: number of elements in r_to_t_tbl
149 * @r_to_t_tbl: table containing resistance to temp points
150 * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl
151 * @v_to_cap_tbl: Voltage to capacity (in %) table
152 * @n_batres_tbl_elements number of elements in the batres_tbl
153 * @batres_tbl battery internal resistance vs temperature table
154 */
155struct abx500_battery_type {
156 int name;
157 int resis_high;
158 int resis_low;
159 int charge_full_design;
160 int nominal_voltage;
161 int termination_vol;
162 int termination_curr;
163 int recharge_vol;
164 int normal_cur_lvl;
165 int normal_vol_lvl;
166 int maint_a_cur_lvl;
167 int maint_a_vol_lvl;
168 int maint_a_chg_timer_h;
169 int maint_b_cur_lvl;
170 int maint_b_vol_lvl;
171 int maint_b_chg_timer_h;
172 int low_high_cur_lvl;
173 int low_high_vol_lvl;
174 int battery_resistance;
175 int n_temp_tbl_elements;
176 struct abx500_res_to_temp *r_to_t_tbl;
177 int n_v_cap_tbl_elements;
178 struct abx500_v_to_cap *v_to_cap_tbl;
179 int n_batres_tbl_elements;
180 struct batres_vs_temp *batres_tbl;
181};
182
183/**
184 * struct abx500_bm_capacity_levels - abx500 capacity level data
185 * @critical: critical capacity level in percent
186 * @low: low capacity level in percent
187 * @normal: normal capacity level in percent
188 * @high: high capacity level in percent
189 * @full: full capacity level in percent
190 */
191struct abx500_bm_capacity_levels {
192 int critical;
193 int low;
194 int normal;
195 int high;
196 int full;
197};
198
199/**
200 * struct abx500_bm_charger_parameters - Charger specific parameters
201 * @usb_volt_max: maximum allowed USB charger voltage in mV
202 * @usb_curr_max: maximum allowed USB charger current in mA
203 * @ac_volt_max: maximum allowed AC charger voltage in mV
204 * @ac_curr_max: maximum allowed AC charger current in mA
205 */
206struct abx500_bm_charger_parameters {
207 int usb_volt_max;
208 int usb_curr_max;
209 int ac_volt_max;
210 int ac_curr_max;
211};
212
213/**
214 * struct abx500_bm_data - abx500 battery management data
215 * @temp_under under this temp, charging is stopped
216 * @temp_low between this temp and temp_under charging is reduced
217 * @temp_high between this temp and temp_over charging is reduced
218 * @temp_over over this temp, charging is stopped
219 * @temp_now present battery temperature
220 * @temp_interval_chg temperature measurement interval in s when charging
221 * @temp_interval_nochg temperature measurement interval in s when not charging
222 * @main_safety_tmr_h safety timer for main charger
223 * @usb_safety_tmr_h safety timer for usb charger
224 * @bkup_bat_v voltage which we charge the backup battery with
225 * @bkup_bat_i current which we charge the backup battery with
226 * @no_maintenance indicates that maintenance charging is disabled
227 * @abx500_adc_therm placement of thermistor, batctrl or battemp adc
228 * @chg_unknown_bat flag to enable charging of unknown batteries
229 * @enable_overshoot flag to enable VBAT overshoot control
230 * @auto_trig flag to enable auto adc trigger
231 * @fg_res resistance of FG resistor in 0.1mOhm
232 * @n_btypes number of elements in array bat_type
233 * @batt_id index of the identified battery in array bat_type
234 * @interval_charging charge alg cycle period time when charging (sec)
235 * @interval_not_charging charge alg cycle period time when not charging (sec)
236 * @temp_hysteresis temperature hysteresis
237 * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm)
238 * @maxi: maximization parameters
239 * @cap_levels capacity in percent for the different capacity levels
240 * @bat_type table of supported battery types
241 * @chg_params charger parameters
242 * @fg_params fuel gauge parameters
243 */
244struct abx500_bm_data {
245 int temp_under;
246 int temp_low;
247 int temp_high;
248 int temp_over;
249 int temp_now;
250 int temp_interval_chg;
251 int temp_interval_nochg;
252 int main_safety_tmr_h;
253 int usb_safety_tmr_h;
254 int bkup_bat_v;
255 int bkup_bat_i;
256 bool no_maintenance;
257 bool chg_unknown_bat;
258 bool enable_overshoot;
259 bool auto_trig;
260 enum abx500_adc_therm adc_therm;
261 int fg_res;
262 int n_btypes;
263 int batt_id;
264 int interval_charging;
265 int interval_not_charging;
266 int temp_hysteresis;
267 int gnd_lift_resistance;
268 const struct abx500_maxim_parameters *maxi;
269 const struct abx500_bm_capacity_levels *cap_levels;
e0f1abeb 270 struct abx500_battery_type *bat_type;
1668f811
AM
271 const struct abx500_bm_charger_parameters *chg_params;
272 const struct abx500_fg_parameters *fg_params;
273};
274
e0f1abeb 275extern struct abx500_bm_data ab8500_bm_data;
1668f811 276
e0f1abeb
R
277enum {
278 NTC_EXTERNAL = 0,
279 NTC_INTERNAL,
1668f811
AM
280};
281
e0f1abeb
R
282int bmdevs_of_probe(struct device *dev,
283 struct device_node *np,
284 struct abx500_bm_data **battery);
1668f811 285
fa661258
MW
286int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg,
287 u8 value);
288int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg,
289 u8 *value);
290int abx500_get_register_page_interruptible(struct device *dev, u8 bank,
291 u8 first_reg, u8 *regvals, u8 numregs);
292int abx500_set_register_page_interruptible(struct device *dev, u8 bank,
293 u8 first_reg, u8 *regvals, u8 numregs);
294/**
295 * abx500_mask_and_set_register_inerruptible() - Modifies selected bits of a
296 * target register
297 *
298 * @dev: The AB sub device.
299 * @bank: The i2c bank number.
300 * @bitmask: The bit mask to use.
301 * @bitvalues: The new bit values.
302 *
303 * Updates the value of an AB register:
304 * value -> ((value & ~bitmask) | (bitvalues & bitmask))
305 */
306int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank,
307 u8 reg, u8 bitmask, u8 bitvalues);
308int abx500_get_chip_id(struct device *dev);
309int abx500_event_registers_startup_state_get(struct device *dev, u8 *event);
310int abx500_startup_irq_enabled(struct device *dev, unsigned int irq);
311
312struct abx500_ops {
313 int (*get_chip_id) (struct device *);
314 int (*get_register) (struct device *, u8, u8, u8 *);
315 int (*set_register) (struct device *, u8, u8, u8);
316 int (*get_register_page) (struct device *, u8, u8, u8 *, u8);
317 int (*set_register_page) (struct device *, u8, u8, u8 *, u8);
318 int (*mask_and_set_register) (struct device *, u8, u8, u8, u8);
319 int (*event_registers_startup_state_get) (struct device *, u8 *);
320 int (*startup_irq_enabled) (struct device *, unsigned int);
321};
322
323int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops);
c6252e9c 324void abx500_remove_ops(struct device *dev);
14fa5691 325#endif