aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/power/charger-manager.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/power/charger-manager.h')
-rw-r--r--include/linux/power/charger-manager.h47
1 files changed, 42 insertions, 5 deletions
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
index cd22029e32aa..0e86840eb603 100644
--- a/include/linux/power/charger-manager.h
+++ b/include/linux/power/charger-manager.h
@@ -109,24 +109,43 @@ struct charger_cable {
109 * struct charger_regulator 109 * struct charger_regulator
110 * @regulator_name: the name of regulator for using charger. 110 * @regulator_name: the name of regulator for using charger.
111 * @consumer: the regulator consumer for the 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.
112 * @cables: 115 * @cables:
113 * the array of charger cables to enable/disable charger 116 * the array of charger cables to enable/disable charger
114 * and set current limit according to constratint data of 117 * and set current limit according to constratint data of
115 * struct charger_cable if only charger cable included 118 * struct charger_cable if only charger cable included
116 * in the array of charger cables is attached/detached. 119 * in the array of charger cables is attached/detached.
117 * @num_cables: the number of charger cables. 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
118 */ 126 */
119struct charger_regulator { 127struct charger_regulator {
120 /* The name of regulator for charging */ 128 /* The name of regulator for charging */
121 const char *regulator_name; 129 const char *regulator_name;
122 struct regulator *consumer; 130 struct regulator *consumer;
123 131
132 /* charger never on when system is on */
133 int externally_control;
134
124 /* 135 /*
125 * Store constraint information related to current limit, 136 * Store constraint information related to current limit,
126 * each cable have different condition for charging. 137 * each cable have different condition for charging.
127 */ 138 */
128 struct charger_cable *cables; 139 struct charger_cable *cables;
129 int num_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;
130}; 149};
131 150
132/** 151/**
@@ -140,7 +159,11 @@ struct charger_regulator {
140 * If it has dropped more than fullbatt_vchkdrop_uV after 159 * If it has dropped more than fullbatt_vchkdrop_uV after
141 * fullbatt_vchkdrop_ms, CM will restart charging. 160 * fullbatt_vchkdrop_ms, CM will restart charging.
142 * @fullbatt_uV: voltage in microvolt 161 * @fullbatt_uV: voltage in microvolt
143 * If it is not being charged and VBATT >= fullbatt_uV, 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,
144 * it is assumed to be full. 167 * it is assumed to be full.
145 * @polling_interval_ms: interval in millisecond at which 168 * @polling_interval_ms: interval in millisecond at which
146 * charger manager will monitor battery health 169 * charger manager will monitor battery health
@@ -148,7 +171,7 @@ struct charger_regulator {
148 * Specify where information for existance of battery can be obtained 171 * Specify where information for existance of battery can be obtained
149 * @psy_charger_stat: the names of power-supply for chargers 172 * @psy_charger_stat: the names of power-supply for chargers
150 * @num_charger_regulator: the number of entries in charger_regulators 173 * @num_charger_regulator: the number of entries in charger_regulators
151 * @charger_regulators: array of regulator_bulk_data for chargers 174 * @charger_regulators: array of charger regulators
152 * @psy_fuel_gauge: the name of power-supply for fuel gauge 175 * @psy_fuel_gauge: the name of power-supply for fuel gauge
153 * @temperature_out_of_range: 176 * @temperature_out_of_range:
154 * Determine whether the status is overheat or cold or normal. 177 * Determine whether the status is overheat or cold or normal.
@@ -158,6 +181,13 @@ struct charger_regulator {
158 * @measure_battery_temp: 181 * @measure_battery_temp:
159 * true: measure battery temperature 182 * true: measure battery temperature
160 * false: measure ambient 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.
161 */ 191 */
162struct charger_desc { 192struct charger_desc {
163 char *psy_name; 193 char *psy_name;
@@ -168,6 +198,8 @@ struct charger_desc {
168 unsigned int fullbatt_vchkdrop_ms; 198 unsigned int fullbatt_vchkdrop_ms;
169 unsigned int fullbatt_vchkdrop_uV; 199 unsigned int fullbatt_vchkdrop_uV;
170 unsigned int fullbatt_uV; 200 unsigned int fullbatt_uV;
201 unsigned int fullbatt_soc;
202 unsigned int fullbatt_full_capacity;
171 203
172 enum data_source battery_present; 204 enum data_source battery_present;
173 205
@@ -180,6 +212,9 @@ struct charger_desc {
180 212
181 int (*temperature_out_of_range)(int *mC); 213 int (*temperature_out_of_range)(int *mC);
182 bool measure_battery_temp; 214 bool measure_battery_temp;
215
216 u64 charging_max_duration_ms;
217 u64 discharging_max_duration_ms;
183}; 218};
184 219
185#define PSY_NAME_MAX 30 220#define PSY_NAME_MAX 30
@@ -194,8 +229,6 @@ struct charger_desc {
194 * @charger_enabled: the state of charger 229 * @charger_enabled: the state of charger
195 * @fullbatt_vchk_jiffies_at: 230 * @fullbatt_vchk_jiffies_at:
196 * jiffies at the time full battery check will occur. 231 * jiffies at the time full battery check will occur.
197 * @fullbatt_vchk_uV: voltage in microvolt
198 * criteria for full battery
199 * @fullbatt_vchk_work: work queue for full battery check 232 * @fullbatt_vchk_work: work queue for full battery check
200 * @emergency_stop: 233 * @emergency_stop:
201 * When setting true, stop charging 234 * When setting true, stop charging
@@ -206,6 +239,8 @@ struct charger_desc {
206 * saved status of external power before entering suspend-to-RAM 239 * saved status of external power before entering suspend-to-RAM
207 * @status_save_batt: 240 * @status_save_batt:
208 * saved status of battery before entering suspend-to-RAM 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
209 */ 244 */
210struct charger_manager { 245struct charger_manager {
211 struct list_head entry; 246 struct list_head entry;
@@ -218,7 +253,6 @@ struct charger_manager {
218 bool charger_enabled; 253 bool charger_enabled;
219 254
220 unsigned long fullbatt_vchk_jiffies_at; 255 unsigned long fullbatt_vchk_jiffies_at;
221 unsigned int fullbatt_vchk_uV;
222 struct delayed_work fullbatt_vchk_work; 256 struct delayed_work fullbatt_vchk_work;
223 257
224 int emergency_stop; 258 int emergency_stop;
@@ -229,6 +263,9 @@ struct charger_manager {
229 263
230 bool status_save_ext_pwr_inserted; 264 bool status_save_ext_pwr_inserted;
231 bool status_save_batt; 265 bool status_save_batt;
266
267 u64 charging_start_time;
268 u64 charging_end_time;
232}; 269};
233 270
234#ifdef CONFIG_CHARGER_MANAGER 271#ifdef CONFIG_CHARGER_MANAGER