aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/power
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/linux/power
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'include/linux/power')
-rw-r--r--include/linux/power/bq2415x_charger.h95
-rw-r--r--include/linux/power/charger-manager.h283
-rw-r--r--include/linux/power/generic-adc-battery.h29
-rw-r--r--include/linux/power/max17042_battery.h110
-rw-r--r--include/linux/power/sbs-battery.h42
-rw-r--r--include/linux/power/smartreflex.h318
-rw-r--r--include/linux/power/smb347-charger.h117
7 files changed, 9 insertions, 985 deletions
diff --git a/include/linux/power/bq2415x_charger.h b/include/linux/power/bq2415x_charger.h
deleted file mode 100644
index 97a1665eaea..00000000000
--- a/include/linux/power/bq2415x_charger.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * bq2415x charger driver
3 *
4 * Copyright (C) 2011-2012 Pali Rohár <pali.rohar@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#ifndef BQ2415X_CHARGER_H
22#define BQ2415X_CHARGER_H
23
24/*
25 * This is platform data for bq2415x chip. It contains default board
26 * voltages and currents which can be also later configured via sysfs. If
27 * value is -1 then default chip value (specified in datasheet) will be
28 * used.
29 *
30 * Value resistor_sense is needed for for configuring charge and
31 * termination current. It it is less or equal to zero, configuring charge
32 * and termination current will not be possible.
33 *
34 * Function set_mode_hook is needed for automode (setting correct current
35 * limit when charger is connected/disconnected or setting boost mode).
36 * When is NULL, automode function is disabled. When is not NULL, it must
37 * have this prototype:
38 *
39 * int (*set_mode_hook)(
40 * void (*hook)(enum bq2415x_mode mode, void *data),
41 * void *data)
42 *
43 * hook is hook function (see below) and data is pointer to driver private
44 * data
45 *
46 * bq2415x driver will call it as:
47 *
48 * platform_data->set_mode_hook(bq2415x_hook_function, bq2415x_device);
49 *
50 * Board/platform function set_mode_hook return non zero value when hook
51 * function was successful registered. Platform code should call that hook
52 * function (which get from pointer, with data) every time when charger
53 * was connected/disconnected or require to enable boost mode. bq2415x
54 * driver then will set correct current limit, enable/disable charger or
55 * boost mode.
56 *
57 * Hook function has this prototype:
58 *
59 * void hook(enum bq2415x_mode mode, void *data);
60 *
61 * mode is bq2415x mode (charger or boost)
62 * data is pointer to driver private data (which get from
63 * set_charger_type_hook)
64 *
65 * When bq driver is being unloaded, it call function:
66 *
67 * platform_data->set_mode_hook(NULL, NULL);
68 *
69 * (hook function and driver private data are NULL)
70 *
71 * After that board/platform code must not call driver hook function! It
72 * is possible that pointer to hook function will not be valid and calling
73 * will cause undefined result.
74 */
75
76/* Supported modes with maximal current limit */
77enum bq2415x_mode {
78 BQ2415X_MODE_NONE, /* unknown or no charger (100mA) */
79 BQ2415X_MODE_HOST_CHARGER, /* usb host/hub charger (500mA) */
80 BQ2415X_MODE_DEDICATED_CHARGER, /* dedicated charger (unlimited) */
81 BQ2415X_MODE_BOOST, /* boost mode (charging disabled) */
82};
83
84struct bq2415x_platform_data {
85 int current_limit; /* mA */
86 int weak_battery_voltage; /* mV */
87 int battery_regulation_voltage; /* mV */
88 int charge_current; /* mA */
89 int termination_current; /* mA */
90 int resistor_sense; /* m ohm */
91 int (*set_mode_hook)(void (*hook)(enum bq2415x_mode mode, void *data),
92 void *data);
93};
94
95#endif
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
deleted file mode 100644
index 0e86840eb60..00000000000
--- a/include/linux/power/charger-manager.h
+++ /dev/null
@@ -1,283 +0,0 @@
1/*
2 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
3 * MyungJoo.Ham <myungjoo.ham@samsung.com>
4 *
5 * Charger Manager.
6 * This framework enables to control and multiple chargers and to
7 * monitor charging even in the context of suspend-to-RAM with
8 * an interface combining the chargers.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13**/
14
15#ifndef _CHARGER_MANAGER_H
16#define _CHARGER_MANAGER_H
17
18#include <linux/power_supply.h>
19#include <linux/extcon.h>
20
21enum data_source {
22 CM_BATTERY_PRESENT,
23 CM_NO_BATTERY,
24 CM_FUEL_GAUGE,
25 CM_CHARGER_STAT,
26};
27
28enum polling_modes {
29 CM_POLL_DISABLE = 0,
30 CM_POLL_ALWAYS,
31 CM_POLL_EXTERNAL_POWER_ONLY,
32 CM_POLL_CHARGING_ONLY,
33};
34
35enum cm_event_types {
36 CM_EVENT_UNKNOWN = 0,
37 CM_EVENT_BATT_FULL,
38 CM_EVENT_BATT_IN,
39 CM_EVENT_BATT_OUT,
40 CM_EVENT_EXT_PWR_IN_OUT,
41 CM_EVENT_CHG_START_STOP,
42 CM_EVENT_OTHERS,
43};
44
45/**
46 * struct charger_global_desc
47 * @rtc_name: the name of RTC used to wake up the system from suspend.
48 * @rtc_only_wakeup:
49 * If the system is woken up by waekup-sources other than the RTC or
50 * callbacks, Charger Manager should recognize with
51 * rtc_only_wakeup() returning false.
52 * If the RTC given to CM is the only wakeup reason,
53 * rtc_only_wakeup should return true.
54 * @assume_timer_stops_in_suspend:
55 * Assume that the jiffy timer stops in suspend-to-RAM.
56 * When enabled, CM does not rely on jiffies value in
57 * suspend_again and assumes that jiffies value does not
58 * change during suspend.
59 */
60struct charger_global_desc {
61 char *rtc_name;
62
63 bool (*rtc_only_wakeup)(void);
64
65 bool assume_timer_stops_in_suspend;
66};
67
68/**
69 * struct charger_cable
70 * @extcon_name: the name of extcon device.
71 * @name: the name of charger cable(external connector).
72 * @extcon_dev: the extcon device.
73 * @wq: the workqueue to control charger according to the state of
74 * charger cable. If charger cable is attached, enable charger.
75 * But if charger cable is detached, disable charger.
76 * @nb: the notifier block to receive changed state from EXTCON
77 * (External Connector) when charger cable is attached/detached.
78 * @attached: the state of charger cable.
79 * true: the charger cable is attached
80 * false: the charger cable is detached
81 * @charger: the instance of struct charger_regulator.
82 * @cm: the Charger Manager representing the battery.
83 */
84struct charger_cable {
85 const char *extcon_name;
86 const char *name;
87
88 /* The charger-manager use Exton framework*/
89 struct extcon_specific_cable_nb extcon_dev;
90 struct work_struct wq;
91 struct notifier_block nb;
92
93 /* The state of charger cable */
94 bool attached;
95
96 struct charger_regulator *charger;
97
98 /*
99 * Set min/max current of regulator to protect over-current issue
100 * according to a kind of charger cable when cable is attached.
101 */
102 int min_uA;
103 int max_uA;
104
105 struct charger_manager *cm;
106};
107
108/**
109 * struct charger_regulator
110 * @regulator_name: the name of regulator for using charger.
111 * @consumer: the regulator consumer for the charger.
112 * @externally_control:
113 * Set if the charger-manager cannot control charger,
114 * the charger will be maintained with disabled state.
115 * @cables:
116 * the array of charger cables to enable/disable charger
117 * and set current limit according to constratint data of
118 * struct charger_cable if only charger cable included
119 * in the array of charger cables is attached/detached.
120 * @num_cables: the number of charger cables.
121 * @attr_g: Attribute group for the charger(regulator)
122 * @attr_name: "name" sysfs entry
123 * @attr_state: "state" sysfs entry
124 * @attr_externally_control: "externally_control" sysfs entry
125 * @attrs: Arrays pointing to attr_name/state/externally_control for attr_g
126 */
127struct charger_regulator {
128 /* The name of regulator for charging */
129 const char *regulator_name;
130 struct regulator *consumer;
131
132 /* charger never on when system is on */
133 int externally_control;
134
135 /*
136 * Store constraint information related to current limit,
137 * each cable have different condition for charging.
138 */
139 struct charger_cable *cables;
140 int num_cables;
141
142 struct attribute_group attr_g;
143 struct device_attribute attr_name;
144 struct device_attribute attr_state;
145 struct device_attribute attr_externally_control;
146 struct attribute *attrs[4];
147
148 struct charger_manager *cm;
149};
150
151/**
152 * struct charger_desc
153 * @psy_name: the name of power-supply-class for charger manager
154 * @polling_mode:
155 * Determine which polling mode will be used
156 * @fullbatt_vchkdrop_ms:
157 * @fullbatt_vchkdrop_uV:
158 * Check voltage drop after the battery is fully charged.
159 * If it has dropped more than fullbatt_vchkdrop_uV after
160 * fullbatt_vchkdrop_ms, CM will restart charging.
161 * @fullbatt_uV: voltage in microvolt
162 * If VBATT >= fullbatt_uV, it is assumed to be full.
163 * @fullbatt_soc: state of Charge in %
164 * If state of Charge >= fullbatt_soc, it is assumed to be full.
165 * @fullbatt_full_capacity: full capacity measure
166 * If full capacity of battery >= fullbatt_full_capacity,
167 * it is assumed to be full.
168 * @polling_interval_ms: interval in millisecond at which
169 * charger manager will monitor battery health
170 * @battery_present:
171 * Specify where information for existance of battery can be obtained
172 * @psy_charger_stat: the names of power-supply for chargers
173 * @num_charger_regulator: the number of entries in charger_regulators
174 * @charger_regulators: array of charger regulators
175 * @psy_fuel_gauge: the name of power-supply for fuel gauge
176 * @temperature_out_of_range:
177 * Determine whether the status is overheat or cold or normal.
178 * return_value > 0: overheat
179 * return_value == 0: normal
180 * return_value < 0: cold
181 * @measure_battery_temp:
182 * true: measure battery temperature
183 * false: measure ambient temperature
184 * @charging_max_duration_ms: Maximum possible duration for charging
185 * If whole charging duration exceed 'charging_max_duration_ms',
186 * cm stop charging.
187 * @discharging_max_duration_ms:
188 * Maximum possible duration for discharging with charger cable
189 * after full-batt. If discharging duration exceed 'discharging
190 * max_duration_ms', cm start charging.
191 */
192struct charger_desc {
193 char *psy_name;
194
195 enum polling_modes polling_mode;
196 unsigned int polling_interval_ms;
197
198 unsigned int fullbatt_vchkdrop_ms;
199 unsigned int fullbatt_vchkdrop_uV;
200 unsigned int fullbatt_uV;
201 unsigned int fullbatt_soc;
202 unsigned int fullbatt_full_capacity;
203
204 enum data_source battery_present;
205
206 char **psy_charger_stat;
207
208 int num_charger_regulators;
209 struct charger_regulator *charger_regulators;
210
211 char *psy_fuel_gauge;
212
213 int (*temperature_out_of_range)(int *mC);
214 bool measure_battery_temp;
215
216 u64 charging_max_duration_ms;
217 u64 discharging_max_duration_ms;
218};
219
220#define PSY_NAME_MAX 30
221
222/**
223 * struct charger_manager
224 * @entry: entry for list
225 * @dev: device pointer
226 * @desc: instance of charger_desc
227 * @fuel_gauge: power_supply for fuel gauge
228 * @charger_stat: array of power_supply for chargers
229 * @charger_enabled: the state of charger
230 * @fullbatt_vchk_jiffies_at:
231 * jiffies at the time full battery check will occur.
232 * @fullbatt_vchk_work: work queue for full battery check
233 * @emergency_stop:
234 * When setting true, stop charging
235 * @last_temp_mC: the measured temperature in milli-Celsius
236 * @psy_name_buf: the name of power-supply-class for charger manager
237 * @charger_psy: power_supply for charger manager
238 * @status_save_ext_pwr_inserted:
239 * saved status of external power before entering suspend-to-RAM
240 * @status_save_batt:
241 * saved status of battery before entering suspend-to-RAM
242 * @charging_start_time: saved start time of enabling charging
243 * @charging_end_time: saved end time of disabling charging
244 */
245struct charger_manager {
246 struct list_head entry;
247 struct device *dev;
248 struct charger_desc *desc;
249
250 struct power_supply *fuel_gauge;
251 struct power_supply **charger_stat;
252
253 bool charger_enabled;
254
255 unsigned long fullbatt_vchk_jiffies_at;
256 struct delayed_work fullbatt_vchk_work;
257
258 int emergency_stop;
259 int last_temp_mC;
260
261 char psy_name_buf[PSY_NAME_MAX + 1];
262 struct power_supply charger_psy;
263
264 bool status_save_ext_pwr_inserted;
265 bool status_save_batt;
266
267 u64 charging_start_time;
268 u64 charging_end_time;
269};
270
271#ifdef CONFIG_CHARGER_MANAGER
272extern int setup_charger_manager(struct charger_global_desc *gd);
273extern bool cm_suspend_again(void);
274extern void cm_notify_event(struct power_supply *psy,
275 enum cm_event_types type, char *msg);
276#else
277static inline int setup_charger_manager(struct charger_global_desc *gd)
278{ return 0; }
279static inline bool cm_suspend_again(void) { return false; }
280static inline void cm_notify_event(struct power_supply *psy,
281 enum cm_event_types type, char *msg) { }
282#endif
283#endif /* _CHARGER_MANAGER_H */
diff --git a/include/linux/power/generic-adc-battery.h b/include/linux/power/generic-adc-battery.h
deleted file mode 100644
index b1ebe08533b..00000000000
--- a/include/linux/power/generic-adc-battery.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Copyright (C) 2012, Anish Kumar <anish198519851985@gmail.com>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation.
6 */
7
8#ifndef GENERIC_ADC_BATTERY_H
9#define GENERIC_ADC_BATTERY_H
10
11/**
12 * struct gab_platform_data - platform_data for generic adc iio battery driver.
13 * @battery_info: recommended structure to specify static power supply
14 * parameters
15 * @cal_charge: calculate charge level.
16 * @gpio_charge_finished: gpio for the charger.
17 * @gpio_inverted: Should be 1 if the GPIO is active low otherwise 0
18 * @jitter_delay: delay required after the interrupt to check battery
19 * status.Default set is 10ms.
20 */
21struct gab_platform_data {
22 struct power_supply_info battery_info;
23 int (*cal_charge)(long value);
24 int gpio_charge_finished;
25 bool gpio_inverted;
26 int jitter_delay;
27};
28
29#endif /* GENERIC_ADC_BATTERY_H */
diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
index 89dd84f47c6..fe99211fb2b 100644
--- a/include/linux/power/max17042_battery.h
+++ b/include/linux/power/max17042_battery.h
@@ -27,8 +27,6 @@
27#define MAX17042_BATTERY_FULL (100) 27#define MAX17042_BATTERY_FULL (100)
28#define MAX17042_DEFAULT_SNS_RESISTOR (10000) 28#define MAX17042_DEFAULT_SNS_RESISTOR (10000)
29 29
30#define MAX17042_CHARACTERIZATION_DATA_SIZE 48
31
32enum max17042_register { 30enum max17042_register {
33 MAX17042_STATUS = 0x00, 31 MAX17042_STATUS = 0x00,
34 MAX17042_VALRT_Th = 0x01, 32 MAX17042_VALRT_Th = 0x01,
@@ -42,11 +40,11 @@ enum max17042_register {
42 MAX17042_VCELL = 0x09, 40 MAX17042_VCELL = 0x09,
43 MAX17042_Current = 0x0A, 41 MAX17042_Current = 0x0A,
44 MAX17042_AvgCurrent = 0x0B, 42 MAX17042_AvgCurrent = 0x0B,
45 43 MAX17042_Qresidual = 0x0C,
46 MAX17042_SOC = 0x0D, 44 MAX17042_SOC = 0x0D,
47 MAX17042_AvSOC = 0x0E, 45 MAX17042_AvSOC = 0x0E,
48 MAX17042_RemCap = 0x0F, 46 MAX17042_RemCap = 0x0F,
49 MAX17042_FullCAP = 0x10, 47 MAX17402_FullCAP = 0x10,
50 MAX17042_TTE = 0x11, 48 MAX17042_TTE = 0x11,
51 MAX17042_V_empty = 0x12, 49 MAX17042_V_empty = 0x12,
52 50
@@ -64,14 +62,14 @@ enum max17042_register {
64 MAX17042_AvCap = 0x1F, 62 MAX17042_AvCap = 0x1F,
65 MAX17042_ManName = 0x20, 63 MAX17042_ManName = 0x20,
66 MAX17042_DevName = 0x21, 64 MAX17042_DevName = 0x21,
65 MAX17042_DevChem = 0x22,
67 66
68 MAX17042_FullCAPNom = 0x23,
69 MAX17042_TempNom = 0x24, 67 MAX17042_TempNom = 0x24,
70 MAX17042_TempLim = 0x25, 68 MAX17042_TempCold = 0x25,
71 MAX17042_TempHot = 0x26, 69 MAX17042_TempHot = 0x26,
72 MAX17042_AIN = 0x27, 70 MAX17042_AIN = 0x27,
73 MAX17042_LearnCFG = 0x28, 71 MAX17042_LearnCFG = 0x28,
74 MAX17042_FilterCFG = 0x29, 72 MAX17042_SHFTCFG = 0x29,
75 MAX17042_RelaxCFG = 0x2A, 73 MAX17042_RelaxCFG = 0x2A,
76 MAX17042_MiscCFG = 0x2B, 74 MAX17042_MiscCFG = 0x2B,
77 MAX17042_TGAIN = 0x2C, 75 MAX17042_TGAIN = 0x2C,
@@ -79,55 +77,24 @@ enum max17042_register {
79 MAX17042_CGAIN = 0x2E, 77 MAX17042_CGAIN = 0x2E,
80 MAX17042_COFF = 0x2F, 78 MAX17042_COFF = 0x2F,
81 79
82 MAX17042_MaskSOC = 0x32, 80 MAX17042_Q_empty = 0x33,
83 MAX17042_SOC_empty = 0x33,
84 MAX17042_T_empty = 0x34, 81 MAX17042_T_empty = 0x34,
85 82
86 MAX17042_FullCAP0 = 0x35,
87 MAX17042_LAvg_empty = 0x36,
88 MAX17042_FCTC = 0x37,
89 MAX17042_RCOMP0 = 0x38, 83 MAX17042_RCOMP0 = 0x38,
90 MAX17042_TempCo = 0x39, 84 MAX17042_TempCo = 0x39,
91 MAX17042_EmptyTempCo = 0x3A, 85 MAX17042_Rx = 0x3A,
92 MAX17042_K_empty0 = 0x3B, 86 MAX17042_T_empty0 = 0x3B,
93 MAX17042_TaskPeriod = 0x3C, 87 MAX17042_TaskPeriod = 0x3C,
94 MAX17042_FSTAT = 0x3D, 88 MAX17042_FSTAT = 0x3D,
95 89
96 MAX17042_SHDNTIMER = 0x3F, 90 MAX17042_SHDNTIMER = 0x3F,
97 91
98 MAX17042_dQacc = 0x45, 92 MAX17042_VFRemCap = 0x4A,
99 MAX17042_dPacc = 0x46,
100
101 MAX17042_VFSOC0 = 0x48,
102 93
103 MAX17042_QH = 0x4D, 94 MAX17042_QH = 0x4D,
104 MAX17042_QL = 0x4E, 95 MAX17042_QL = 0x4E,
105
106 MAX17042_VFSOC0Enable = 0x60,
107 MAX17042_MLOCKReg1 = 0x62,
108 MAX17042_MLOCKReg2 = 0x63,
109
110 MAX17042_MODELChrTbl = 0x80,
111
112 MAX17042_OCV = 0xEE,
113
114 MAX17042_OCVInternal = 0xFB,
115
116 MAX17042_VFSOC = 0xFF,
117};
118
119/* Registers specific to max17047/50 */
120enum max17047_register {
121 MAX17047_QRTbl00 = 0x12,
122 MAX17047_FullSOCThr = 0x13,
123 MAX17047_QRTbl10 = 0x22,
124 MAX17047_QRTbl20 = 0x32,
125 MAX17047_V_empty = 0x3A,
126 MAX17047_QRTbl30 = 0x42,
127}; 96};
128 97
129enum max170xx_chip_type {MAX17042, MAX17047};
130
131/* 98/*
132 * used for setting a register to a desired value 99 * used for setting a register to a desired value
133 * addr : address for a register 100 * addr : address for a register
@@ -138,69 +105,10 @@ struct max17042_reg_data {
138 u16 data; 105 u16 data;
139}; 106};
140 107
141struct max17042_config_data {
142 /* External current sense resistor value in milli-ohms */
143 u32 cur_sense_val;
144
145 /* A/D measurement */
146 u16 tgain; /* 0x2C */
147 u16 toff; /* 0x2D */
148 u16 cgain; /* 0x2E */
149 u16 coff; /* 0x2F */
150
151 /* Alert / Status */
152 u16 valrt_thresh; /* 0x01 */
153 u16 talrt_thresh; /* 0x02 */
154 u16 soc_alrt_thresh; /* 0x03 */
155 u16 config; /* 0x01D */
156 u16 shdntimer; /* 0x03F */
157
158 /* App data */
159 u16 full_soc_thresh; /* 0x13 */
160 u16 design_cap; /* 0x18 */
161 u16 ichgt_term; /* 0x1E */
162
163 /* MG3 config */
164 u16 at_rate; /* 0x04 */
165 u16 learn_cfg; /* 0x28 */
166 u16 filter_cfg; /* 0x29 */
167 u16 relax_cfg; /* 0x2A */
168 u16 misc_cfg; /* 0x2B */
169 u16 masksoc; /* 0x32 */
170
171 /* MG3 save and restore */
172 u16 fullcap; /* 0x10 */
173 u16 fullcapnom; /* 0x23 */
174 u16 socempty; /* 0x33 */
175 u16 lavg_empty; /* 0x36 */
176 u16 dqacc; /* 0x45 */
177 u16 dpacc; /* 0x46 */
178 u16 qrtbl00; /* 0x12 */
179 u16 qrtbl10; /* 0x22 */
180 u16 qrtbl20; /* 0x32 */
181 u16 qrtbl30; /* 0x42 */
182
183 /* Cell technology from power_supply.h */
184 u16 cell_technology;
185
186 /* Cell Data */
187 u16 vempty; /* 0x12 */
188 u16 temp_nom; /* 0x24 */
189 u16 temp_lim; /* 0x25 */
190 u16 fctc; /* 0x37 */
191 u16 rcomp0; /* 0x38 */
192 u16 tcompc0; /* 0x39 */
193 u16 empty_tempco; /* 0x3A */
194 u16 kempty0; /* 0x3B */
195 u16 cell_char_tbl[MAX17042_CHARACTERIZATION_DATA_SIZE];
196} __packed;
197
198struct max17042_platform_data { 108struct max17042_platform_data {
199 struct max17042_reg_data *init_data; 109 struct max17042_reg_data *init_data;
200 struct max17042_config_data *config_data;
201 int num_init_data; /* Number of enties in init_data array */ 110 int num_init_data; /* Number of enties in init_data array */
202 bool enable_current_sense; 111 bool enable_current_sense;
203 bool enable_por_init; /* Use POR init from Maxim appnote */
204 112
205 /* 113 /*
206 * R_sns in micro-ohms. 114 * R_sns in micro-ohms.
diff --git a/include/linux/power/sbs-battery.h b/include/linux/power/sbs-battery.h
deleted file mode 100644
index 2b0a9d9ff57..00000000000
--- a/include/linux/power/sbs-battery.h
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * Gas Gauge driver for SBS Compliant Gas Gauges
3 *
4 * Copyright (c) 2010, NVIDIA Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef __LINUX_POWER_SBS_BATTERY_H_
22#define __LINUX_POWER_SBS_BATTERY_H_
23
24#include <linux/power_supply.h>
25#include <linux/types.h>
26
27/**
28 * struct sbs_platform_data - platform data for sbs devices
29 * @battery_detect: GPIO which is used to detect battery presence
30 * @battery_detect_present: gpio state when battery is present (0 / 1)
31 * @i2c_retry_count: # of times to retry on i2c IO failure
32 * @poll_retry_count: # of times to retry looking for new status after
33 * external change notification
34 */
35struct sbs_platform_data {
36 int battery_detect;
37 int battery_detect_present;
38 int i2c_retry_count;
39 int poll_retry_count;
40};
41
42#endif
diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
deleted file mode 100644
index c0f44c2b006..00000000000
--- a/include/linux/power/smartreflex.h
+++ /dev/null
@@ -1,318 +0,0 @@
1/*
2 * OMAP Smartreflex Defines and Routines
3 *
4 * Author: Thara Gopinath <thara@ti.com>
5 *
6 * Copyright (C) 2010 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
8 *
9 * Copyright (C) 2008 Nokia Corporation
10 * Kalle Jokiniemi
11 *
12 * Copyright (C) 2007 Texas Instruments, Inc.
13 * Lesly A M <x0080970@ti.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2 as
17 * published by the Free Software Foundation.
18 */
19
20#ifndef __POWER_SMARTREFLEX_H
21#define __POWER_SMARTREFLEX_H
22
23#include <linux/types.h>
24#include <linux/platform_device.h>
25#include <linux/delay.h>
26#include <linux/platform_data/voltage-omap.h>
27
28/*
29 * Different Smartreflex IPs version. The v1 is the 65nm version used in
30 * OMAP3430. The v2 is the update for the 45nm version of the IP
31 * used in OMAP3630 and OMAP4430
32 */
33#define SR_TYPE_V1 1
34#define SR_TYPE_V2 2
35
36/* SMART REFLEX REG ADDRESS OFFSET */
37#define SRCONFIG 0x00
38#define SRSTATUS 0x04
39#define SENVAL 0x08
40#define SENMIN 0x0C
41#define SENMAX 0x10
42#define SENAVG 0x14
43#define AVGWEIGHT 0x18
44#define NVALUERECIPROCAL 0x1c
45#define SENERROR_V1 0x20
46#define ERRCONFIG_V1 0x24
47#define IRQ_EOI 0x20
48#define IRQSTATUS_RAW 0x24
49#define IRQSTATUS 0x28
50#define IRQENABLE_SET 0x2C
51#define IRQENABLE_CLR 0x30
52#define SENERROR_V2 0x34
53#define ERRCONFIG_V2 0x38
54
55/* Bit/Shift Positions */
56
57/* SRCONFIG */
58#define SRCONFIG_ACCUMDATA_SHIFT 22
59#define SRCONFIG_SRCLKLENGTH_SHIFT 12
60#define SRCONFIG_SENNENABLE_V1_SHIFT 5
61#define SRCONFIG_SENPENABLE_V1_SHIFT 3
62#define SRCONFIG_SENNENABLE_V2_SHIFT 1
63#define SRCONFIG_SENPENABLE_V2_SHIFT 0
64#define SRCONFIG_CLKCTRL_SHIFT 0
65
66#define SRCONFIG_ACCUMDATA_MASK (0x3ff << 22)
67
68#define SRCONFIG_SRENABLE BIT(11)
69#define SRCONFIG_SENENABLE BIT(10)
70#define SRCONFIG_ERRGEN_EN BIT(9)
71#define SRCONFIG_MINMAXAVG_EN BIT(8)
72#define SRCONFIG_DELAYCTRL BIT(2)
73
74/* AVGWEIGHT */
75#define AVGWEIGHT_SENPAVGWEIGHT_SHIFT 2
76#define AVGWEIGHT_SENNAVGWEIGHT_SHIFT 0
77
78/* NVALUERECIPROCAL */
79#define NVALUERECIPROCAL_SENPGAIN_SHIFT 20
80#define NVALUERECIPROCAL_SENNGAIN_SHIFT 16
81#define NVALUERECIPROCAL_RNSENP_SHIFT 8
82#define NVALUERECIPROCAL_RNSENN_SHIFT 0
83
84/* ERRCONFIG */
85#define ERRCONFIG_ERRWEIGHT_SHIFT 16
86#define ERRCONFIG_ERRMAXLIMIT_SHIFT 8
87#define ERRCONFIG_ERRMINLIMIT_SHIFT 0
88
89#define SR_ERRWEIGHT_MASK (0x07 << 16)
90#define SR_ERRMAXLIMIT_MASK (0xff << 8)
91#define SR_ERRMINLIMIT_MASK (0xff << 0)
92
93#define ERRCONFIG_VPBOUNDINTEN_V1 BIT(31)
94#define ERRCONFIG_VPBOUNDINTST_V1 BIT(30)
95#define ERRCONFIG_MCUACCUMINTEN BIT(29)
96#define ERRCONFIG_MCUACCUMINTST BIT(28)
97#define ERRCONFIG_MCUVALIDINTEN BIT(27)
98#define ERRCONFIG_MCUVALIDINTST BIT(26)
99#define ERRCONFIG_MCUBOUNDINTEN BIT(25)
100#define ERRCONFIG_MCUBOUNDINTST BIT(24)
101#define ERRCONFIG_MCUDISACKINTEN BIT(23)
102#define ERRCONFIG_VPBOUNDINTST_V2 BIT(23)
103#define ERRCONFIG_MCUDISACKINTST BIT(22)
104#define ERRCONFIG_VPBOUNDINTEN_V2 BIT(22)
105
106#define ERRCONFIG_STATUS_V1_MASK (ERRCONFIG_VPBOUNDINTST_V1 | \
107 ERRCONFIG_MCUACCUMINTST | \
108 ERRCONFIG_MCUVALIDINTST | \
109 ERRCONFIG_MCUBOUNDINTST | \
110 ERRCONFIG_MCUDISACKINTST)
111/* IRQSTATUS */
112#define IRQSTATUS_MCUACCUMINT BIT(3)
113#define IRQSTATUS_MCVALIDINT BIT(2)
114#define IRQSTATUS_MCBOUNDSINT BIT(1)
115#define IRQSTATUS_MCUDISABLEACKINT BIT(0)
116
117/* IRQENABLE_SET and IRQENABLE_CLEAR */
118#define IRQENABLE_MCUACCUMINT BIT(3)
119#define IRQENABLE_MCUVALIDINT BIT(2)
120#define IRQENABLE_MCUBOUNDSINT BIT(1)
121#define IRQENABLE_MCUDISABLEACKINT BIT(0)
122
123/* Common Bit values */
124
125#define SRCLKLENGTH_12MHZ_SYSCLK 0x3c
126#define SRCLKLENGTH_13MHZ_SYSCLK 0x41
127#define SRCLKLENGTH_19MHZ_SYSCLK 0x60
128#define SRCLKLENGTH_26MHZ_SYSCLK 0x82
129#define SRCLKLENGTH_38MHZ_SYSCLK 0xC0
130
131/*
132 * 3430 specific values. Maybe these should be passed from board file or
133 * pmic structures.
134 */
135#define OMAP3430_SR_ACCUMDATA 0x1f4
136
137#define OMAP3430_SR1_SENPAVGWEIGHT 0x03
138#define OMAP3430_SR1_SENNAVGWEIGHT 0x03
139
140#define OMAP3430_SR2_SENPAVGWEIGHT 0x01
141#define OMAP3430_SR2_SENNAVGWEIGHT 0x01
142
143#define OMAP3430_SR_ERRWEIGHT 0x04
144#define OMAP3430_SR_ERRMAXLIMIT 0x02
145
146struct omap_sr {
147 char *name;
148 struct list_head node;
149 struct platform_device *pdev;
150 struct omap_sr_nvalue_table *nvalue_table;
151 struct voltagedomain *voltdm;
152 struct dentry *dbg_dir;
153 unsigned int irq;
154 int srid;
155 int ip_type;
156 int nvalue_count;
157 bool autocomp_active;
158 u32 clk_length;
159 u32 err_weight;
160 u32 err_minlimit;
161 u32 err_maxlimit;
162 u32 accum_data;
163 u32 senn_avgweight;
164 u32 senp_avgweight;
165 u32 senp_mod;
166 u32 senn_mod;
167 void __iomem *base;
168};
169
170/**
171 * test_cond_timeout - busy-loop, testing a condition
172 * @cond: condition to test until it evaluates to true
173 * @timeout: maximum number of microseconds in the timeout
174 * @index: loop index (integer)
175 *
176 * Loop waiting for @cond to become true or until at least @timeout
177 * microseconds have passed. To use, define some integer @index in the
178 * calling code. After running, if @index == @timeout, then the loop has
179 * timed out.
180 *
181 * Copied from omap_test_timeout */
182#define sr_test_cond_timeout(cond, timeout, index) \
183({ \
184 for (index = 0; index < timeout; index++) { \
185 if (cond) \
186 break; \
187 udelay(1); \
188 } \
189})
190
191/**
192 * struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass
193 * pmic specific info to smartreflex driver
194 *
195 * @sr_pmic_init: API to initialize smartreflex on the PMIC side.
196 */
197struct omap_sr_pmic_data {
198 void (*sr_pmic_init) (void);
199};
200
201/**
202 * struct omap_smartreflex_dev_attr - Smartreflex Device attribute.
203 *
204 * @sensor_voltdm_name: Name of voltdomain of SR instance
205 */
206struct omap_smartreflex_dev_attr {
207 const char *sensor_voltdm_name;
208};
209
210#ifdef CONFIG_POWER_AVS_OMAP
211/*
212 * The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR.
213 * The smartreflex class driver should pass the class type.
214 * Should be used to populate the class_type field of the
215 * omap_smartreflex_class_data structure.
216 */
217#define SR_CLASS1 0x1
218#define SR_CLASS2 0x2
219#define SR_CLASS3 0x3
220
221/**
222 * struct omap_sr_class_data - Smartreflex class driver info
223 *
224 * @enable: API to enable a particular class smaartreflex.
225 * @disable: API to disable a particular class smartreflex.
226 * @configure: API to configure a particular class smartreflex.
227 * @notify: API to notify the class driver about an event in SR.
228 * Not needed for class3.
229 * @notify_flags: specify the events to be notified to the class driver
230 * @class_type: specify which smartreflex class.
231 * Can be used by the SR driver to take any class
232 * based decisions.
233 */
234struct omap_sr_class_data {
235 int (*enable)(struct omap_sr *sr);
236 int (*disable)(struct omap_sr *sr, int is_volt_reset);
237 int (*configure)(struct omap_sr *sr);
238 int (*notify)(struct omap_sr *sr, u32 status);
239 u8 notify_flags;
240 u8 class_type;
241};
242
243/**
244 * struct omap_sr_nvalue_table - Smartreflex n-target value info
245 *
246 * @efuse_offs: The offset of the efuse where n-target values are stored.
247 * @nvalue: The n-target value.
248 * @errminlimit: The value of the ERRMINLIMIT bitfield for this n-target
249 * @volt_nominal: microvolts DC that the VDD is initially programmed to
250 */
251struct omap_sr_nvalue_table {
252 u32 efuse_offs;
253 u32 nvalue;
254 u32 errminlimit;
255 unsigned long volt_nominal;
256};
257
258/**
259 * struct omap_sr_data - Smartreflex platform data.
260 *
261 * @name: instance name
262 * @ip_type: Smartreflex IP type.
263 * @senp_mod: SENPENABLE value of the sr CONFIG register
264 * @senn_mod: SENNENABLE value for sr CONFIG register
265 * @err_weight ERRWEIGHT value of the sr ERRCONFIG register
266 * @err_maxlimit ERRMAXLIMIT value of the sr ERRCONFIG register
267 * @accum_data ACCUMDATA value of the sr CONFIG register
268 * @senn_avgweight SENNAVGWEIGHT value of the sr AVGWEIGHT register
269 * @senp_avgweight SENPAVGWEIGHT value of the sr AVGWEIGHT register
270 * @nvalue_count: Number of distinct nvalues in the nvalue table
271 * @enable_on_init: whether this sr module needs to enabled at
272 * boot up or not.
273 * @nvalue_table: table containing the efuse offsets and nvalues
274 * corresponding to them.
275 * @voltdm: Pointer to the voltage domain associated with the SR
276 */
277struct omap_sr_data {
278 const char *name;
279 int ip_type;
280 u32 senp_mod;
281 u32 senn_mod;
282 u32 err_weight;
283 u32 err_maxlimit;
284 u32 accum_data;
285 u32 senn_avgweight;
286 u32 senp_avgweight;
287 int nvalue_count;
288 bool enable_on_init;
289 struct omap_sr_nvalue_table *nvalue_table;
290 struct voltagedomain *voltdm;
291};
292
293/* Smartreflex module enable/disable interface */
294void omap_sr_enable(struct voltagedomain *voltdm);
295void omap_sr_disable(struct voltagedomain *voltdm);
296void omap_sr_disable_reset_volt(struct voltagedomain *voltdm);
297
298/* API to register the pmic specific data with the smartreflex driver. */
299void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data);
300
301/* Smartreflex driver hooks to be called from Smartreflex class driver */
302int sr_enable(struct voltagedomain *voltdm, unsigned long volt);
303void sr_disable(struct voltagedomain *voltdm);
304int sr_configure_errgen(struct voltagedomain *voltdm);
305int sr_disable_errgen(struct voltagedomain *voltdm);
306int sr_configure_minmax(struct voltagedomain *voltdm);
307
308/* API to register the smartreflex class driver with the smartreflex driver */
309int sr_register_class(struct omap_sr_class_data *class_data);
310#else
311static inline void omap_sr_enable(struct voltagedomain *voltdm) {}
312static inline void omap_sr_disable(struct voltagedomain *voltdm) {}
313static inline void omap_sr_disable_reset_volt(
314 struct voltagedomain *voltdm) {}
315static inline void omap_sr_register_pmic(
316 struct omap_sr_pmic_data *pmic_data) {}
317#endif
318#endif
diff --git a/include/linux/power/smb347-charger.h b/include/linux/power/smb347-charger.h
deleted file mode 100644
index b3cb20dab55..00000000000
--- a/include/linux/power/smb347-charger.h
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 * Summit Microelectronics SMB347 Battery Charger Driver
3 *
4 * Copyright (C) 2011, Intel Corporation
5 *
6 * Authors: Bruce E. Robertson <bruce.e.robertson@intel.com>
7 * Mika Westerberg <mika.westerberg@linux.intel.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef SMB347_CHARGER_H
15#define SMB347_CHARGER_H
16
17#include <linux/types.h>
18#include <linux/power_supply.h>
19
20enum {
21 /* use the default compensation method */
22 SMB347_SOFT_TEMP_COMPENSATE_DEFAULT = -1,
23
24 SMB347_SOFT_TEMP_COMPENSATE_NONE,
25 SMB347_SOFT_TEMP_COMPENSATE_CURRENT,
26 SMB347_SOFT_TEMP_COMPENSATE_VOLTAGE,
27};
28
29/* Use default factory programmed value for hard/soft temperature limit */
30#define SMB347_TEMP_USE_DEFAULT -273
31
32/*
33 * Charging enable can be controlled by software (via i2c) by
34 * smb347-charger driver or by EN pin (active low/high).
35 */
36enum smb347_chg_enable {
37 SMB347_CHG_ENABLE_SW,
38 SMB347_CHG_ENABLE_PIN_ACTIVE_LOW,
39 SMB347_CHG_ENABLE_PIN_ACTIVE_HIGH,
40};
41
42/**
43 * struct smb347_charger_platform_data - platform data for SMB347 charger
44 * @battery_info: Information about the battery
45 * @max_charge_current: maximum current (in uA) the battery can be charged
46 * @max_charge_voltage: maximum voltage (in uV) the battery can be charged
47 * @pre_charge_current: current (in uA) to use in pre-charging phase
48 * @termination_current: current (in uA) used to determine when the
49 * charging cycle terminates
50 * @pre_to_fast_voltage: voltage (in uV) treshold used for transitioning to
51 * pre-charge to fast charge mode
52 * @mains_current_limit: maximum input current drawn from AC/DC input (in uA)
53 * @usb_hc_current_limit: maximum input high current (in uA) drawn from USB
54 * input
55 * @chip_temp_threshold: die temperature where device starts limiting charge
56 * current [%100 - %130] (in degree C)
57 * @soft_cold_temp_limit: soft cold temperature limit [%0 - %15] (in degree C),
58 * granularity is 5 deg C.
59 * @soft_hot_temp_limit: soft hot temperature limit [%40 - %55] (in degree C),
60 * granularity is 5 deg C.
61 * @hard_cold_temp_limit: hard cold temperature limit [%-5 - %10] (in degree C),
62 * granularity is 5 deg C.
63 * @hard_hot_temp_limit: hard hot temperature limit [%50 - %65] (in degree C),
64 * granularity is 5 deg C.
65 * @suspend_on_hard_temp_limit: suspend charging when hard limit is hit
66 * @soft_temp_limit_compensation: compensation method when soft temperature
67 * limit is hit
68 * @charge_current_compensation: current (in uA) for charging compensation
69 * current when temperature hits soft limits
70 * @use_mains: AC/DC input can be used
71 * @use_usb: USB input can be used
72 * @use_usb_otg: USB OTG output can be used (not implemented yet)
73 * @irq_gpio: GPIO number used for interrupts (%-1 if not used)
74 * @enable_control: how charging enable/disable is controlled
75 * (driver/pin controls)
76 *
77 * @use_main, @use_usb, and @use_usb_otg are means to enable/disable
78 * hardware support for these. This is useful when we want to have for
79 * example OTG charging controlled via OTG transceiver driver and not by
80 * the SMB347 hardware.
81 *
82 * Hard and soft temperature limit values are given as described in the
83 * device data sheet and assuming NTC beta value is %3750. Even if this is
84 * not the case, these values should be used. They can be mapped to the
85 * corresponding NTC beta values with the help of table %2 in the data
86 * sheet. So for example if NTC beta is %3375 and we want to program hard
87 * hot limit to be %53 deg C, @hard_hot_temp_limit should be set to %50.
88 *
89 * If zero value is given in any of the current and voltage values, the
90 * factory programmed default will be used. For soft/hard temperature
91 * values, pass in %SMB347_TEMP_USE_DEFAULT instead.
92 */
93struct smb347_charger_platform_data {
94 struct power_supply_info battery_info;
95 unsigned int max_charge_current;
96 unsigned int max_charge_voltage;
97 unsigned int pre_charge_current;
98 unsigned int termination_current;
99 unsigned int pre_to_fast_voltage;
100 unsigned int mains_current_limit;
101 unsigned int usb_hc_current_limit;
102 unsigned int chip_temp_threshold;
103 int soft_cold_temp_limit;
104 int soft_hot_temp_limit;
105 int hard_cold_temp_limit;
106 int hard_hot_temp_limit;
107 bool suspend_on_hard_temp_limit;
108 unsigned int soft_temp_limit_compensation;
109 unsigned int charge_current_compensation;
110 bool use_mains;
111 bool use_usb;
112 bool use_usb_otg;
113 int irq_gpio;
114 enum smb347_chg_enable enable_control;
115};
116
117#endif /* SMB347_CHARGER_H */