Commit | Line | Data |
---|---|---|
4a11b59d AV |
1 | /* |
2 | * Universal power supply monitor class | |
3 | * | |
4 | * Copyright © 2007 Anton Vorontsov <cbou@mail.ru> | |
5 | * Copyright © 2004 Szabolcs Gyurko | |
6 | * Copyright © 2003 Ian Molton <spyro@f2s.com> | |
7 | * | |
8 | * Modified: 2004, Oct Szabolcs Gyurko | |
9 | * | |
10 | * You may use this code as per GPL version 2 | |
11 | */ | |
12 | ||
13 | #ifndef __LINUX_POWER_SUPPLY_H__ | |
14 | #define __LINUX_POWER_SUPPLY_H__ | |
15 | ||
297d716f | 16 | #include <linux/device.h> |
4a11b59d AV |
17 | #include <linux/workqueue.h> |
18 | #include <linux/leds.h> | |
948dcf96 | 19 | #include <linux/spinlock.h> |
d36240d2 | 20 | #include <linux/notifier.h> |
36f70d28 | 21 | #include <linux/types.h> |
4a11b59d AV |
22 | |
23 | /* | |
24 | * All voltages, currents, charges, energies, time and temperatures in uV, | |
25 | * µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise | |
26 | * stated. It's driver's job to convert its raw values to units in which | |
27 | * this class operates. | |
28 | */ | |
29 | ||
30 | /* | |
31 | * For systems where the charger determines the maximum battery capacity | |
32 | * the min and max fields should be used to present these values to user | |
33 | * space. Unused/unknown fields will not appear in sysfs. | |
34 | */ | |
35 | ||
36 | enum { | |
37 | POWER_SUPPLY_STATUS_UNKNOWN = 0, | |
38 | POWER_SUPPLY_STATUS_CHARGING, | |
39 | POWER_SUPPLY_STATUS_DISCHARGING, | |
40 | POWER_SUPPLY_STATUS_NOT_CHARGING, | |
41 | POWER_SUPPLY_STATUS_FULL, | |
42 | }; | |
43 | ||
ee8076ed AS |
44 | enum { |
45 | POWER_SUPPLY_CHARGE_TYPE_UNKNOWN = 0, | |
46 | POWER_SUPPLY_CHARGE_TYPE_NONE, | |
47 | POWER_SUPPLY_CHARGE_TYPE_TRICKLE, | |
48 | POWER_SUPPLY_CHARGE_TYPE_FAST, | |
49 | }; | |
50 | ||
4a11b59d AV |
51 | enum { |
52 | POWER_SUPPLY_HEALTH_UNKNOWN = 0, | |
53 | POWER_SUPPLY_HEALTH_GOOD, | |
54 | POWER_SUPPLY_HEALTH_OVERHEAT, | |
55 | POWER_SUPPLY_HEALTH_DEAD, | |
56 | POWER_SUPPLY_HEALTH_OVERVOLTAGE, | |
57 | POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, | |
7e386e6e | 58 | POWER_SUPPLY_HEALTH_COLD, |
a05be991 RP |
59 | POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, |
60 | POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE, | |
1ee72d30 | 61 | POWER_SUPPLY_HEALTH_UNDERVOLTAGE, |
9df220d8 | 62 | //moto from 10 |
63 | POWER_SUPPLY_HEALTH_WARM, | |
64 | POWER_SUPPLY_HEALTH_COOL, | |
65 | POWER_SUPPLY_HEALTH_HOT, | |
66 | POWER_SUPPLY_HEALTH_SLIGHTLY_COOL, | |
4a11b59d AV |
67 | }; |
68 | ||
69 | enum { | |
70 | POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0, | |
71 | POWER_SUPPLY_TECHNOLOGY_NiMH, | |
72 | POWER_SUPPLY_TECHNOLOGY_LION, | |
73 | POWER_SUPPLY_TECHNOLOGY_LIPO, | |
74 | POWER_SUPPLY_TECHNOLOGY_LiFe, | |
75 | POWER_SUPPLY_TECHNOLOGY_NiCd, | |
c7cc930f | 76 | POWER_SUPPLY_TECHNOLOGY_LiMn, |
4a11b59d AV |
77 | }; |
78 | ||
b294a290 AS |
79 | enum { |
80 | POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0, | |
81 | POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL, | |
82 | POWER_SUPPLY_CAPACITY_LEVEL_LOW, | |
83 | POWER_SUPPLY_CAPACITY_LEVEL_NORMAL, | |
84 | POWER_SUPPLY_CAPACITY_LEVEL_HIGH, | |
85 | POWER_SUPPLY_CAPACITY_LEVEL_FULL, | |
86 | }; | |
87 | ||
25a0bc2d JF |
88 | enum { |
89 | POWER_SUPPLY_SCOPE_UNKNOWN = 0, | |
90 | POWER_SUPPLY_SCOPE_SYSTEM, | |
91 | POWER_SUPPLY_SCOPE_DEVICE, | |
92 | }; | |
93 | ||
32ba0a50 | 94 | enum { |
95 | POWER_SUPPLY_CHARGE_RATE_NONE = 0, | |
96 | POWER_SUPPLY_CHARGE_RATE_NORMAL, | |
97 | POWER_SUPPLY_CHARGE_RATE_WEAK, | |
98 | POWER_SUPPLY_CHARGE_RATE_TURBO, | |
99 | }; | |
100 | ||
4a11b59d AV |
101 | enum power_supply_property { |
102 | /* Properties of type `int' */ | |
103 | POWER_SUPPLY_PROP_STATUS = 0, | |
ee8076ed | 104 | POWER_SUPPLY_PROP_CHARGE_TYPE, |
4a11b59d AV |
105 | POWER_SUPPLY_PROP_HEALTH, |
106 | POWER_SUPPLY_PROP_PRESENT, | |
107 | POWER_SUPPLY_PROP_ONLINE, | |
b1b56872 | 108 | POWER_SUPPLY_PROP_AUTHENTIC, |
1ee72d30 | 109 | POWER_SUPPLY_PROP_CHARGING_ENABLED, |
4a11b59d | 110 | POWER_SUPPLY_PROP_TECHNOLOGY, |
c955fe8e | 111 | POWER_SUPPLY_PROP_CYCLE_COUNT, |
c7cc930f DES |
112 | POWER_SUPPLY_PROP_VOLTAGE_MAX, |
113 | POWER_SUPPLY_PROP_VOLTAGE_MIN, | |
4a11b59d AV |
114 | POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, |
115 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | |
116 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | |
117 | POWER_SUPPLY_PROP_VOLTAGE_AVG, | |
a2ebfe2f | 118 | POWER_SUPPLY_PROP_VOLTAGE_OCV, |
a8adcc90 | 119 | POWER_SUPPLY_PROP_VOLTAGE_BOOT, |
1ee72d30 | 120 | POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION, |
fe3f6d09 | 121 | POWER_SUPPLY_PROP_CURRENT_MAX, |
4a11b59d AV |
122 | POWER_SUPPLY_PROP_CURRENT_NOW, |
123 | POWER_SUPPLY_PROP_CURRENT_AVG, | |
1ee72d30 | 124 | POWER_SUPPLY_PROP_CURRENT_FULL, |
a8adcc90 | 125 | POWER_SUPPLY_PROP_CURRENT_BOOT, |
7faa144a AS |
126 | POWER_SUPPLY_PROP_POWER_NOW, |
127 | POWER_SUPPLY_PROP_POWER_AVG, | |
4a11b59d AV |
128 | POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, |
129 | POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN, | |
130 | POWER_SUPPLY_PROP_CHARGE_FULL, | |
131 | POWER_SUPPLY_PROP_CHARGE_EMPTY, | |
132 | POWER_SUPPLY_PROP_CHARGE_NOW, | |
133 | POWER_SUPPLY_PROP_CHARGE_AVG, | |
8e552c36 | 134 | POWER_SUPPLY_PROP_CHARGE_COUNTER, |
1ee72d30 KH |
135 | POWER_SUPPLY_PROP_CHARGE_OTG_CONTROL, |
136 | POWER_SUPPLY_PROP_CHARGE_POWERED_OTG_CONTROL, | |
60642433 | 137 | POWER_SUPPLY_PROP_CHARGE_TEMP, |
3824c477 | 138 | POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, |
2815b786 | 139 | POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, |
3824c477 | 140 | POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, |
2815b786 | 141 | POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, |
ea2ce92e RP |
142 | POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, |
143 | POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, | |
6bb1d272 | 144 | POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, |
4a11b59d AV |
145 | POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, |
146 | POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN, | |
147 | POWER_SUPPLY_PROP_ENERGY_FULL, | |
148 | POWER_SUPPLY_PROP_ENERGY_EMPTY, | |
149 | POWER_SUPPLY_PROP_ENERGY_NOW, | |
150 | POWER_SUPPLY_PROP_ENERGY_AVG, | |
151 | POWER_SUPPLY_PROP_CAPACITY, /* in percents! */ | |
e908c418 RP |
152 | POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, /* in percents! */ |
153 | POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX, /* in percents! */ | |
b294a290 | 154 | POWER_SUPPLY_PROP_CAPACITY_LEVEL, |
4a11b59d | 155 | POWER_SUPPLY_PROP_TEMP, |
6bb1d272 JT |
156 | POWER_SUPPLY_PROP_TEMP_MAX, |
157 | POWER_SUPPLY_PROP_TEMP_MIN, | |
e908c418 RP |
158 | POWER_SUPPLY_PROP_TEMP_ALERT_MIN, |
159 | POWER_SUPPLY_PROP_TEMP_ALERT_MAX, | |
4a11b59d | 160 | POWER_SUPPLY_PROP_TEMP_AMBIENT, |
e908c418 RP |
161 | POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN, |
162 | POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX, | |
4a11b59d AV |
163 | POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, |
164 | POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, | |
165 | POWER_SUPPLY_PROP_TIME_TO_FULL_NOW, | |
166 | POWER_SUPPLY_PROP_TIME_TO_FULL_AVG, | |
5f487cd3 | 167 | POWER_SUPPLY_PROP_TYPE, /* use power_supply.type instead */ |
25a0bc2d | 168 | POWER_SUPPLY_PROP_SCOPE, |
413de34a | 169 | POWER_SUPPLY_PROP_PRECHARGE_CURRENT, |
6bb1d272 | 170 | POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, |
a8adcc90 | 171 | POWER_SUPPLY_PROP_CALIBRATE, |
0860da93 TP |
172 | /* Local extensions */ |
173 | POWER_SUPPLY_PROP_USB_HC, | |
10c7c0e3 | 174 | POWER_SUPPLY_PROP_USB_OTG, |
2d38c8a1 | 175 | POWER_SUPPLY_PROP_CHARGE_ENABLED, |
1ee72d30 | 176 | POWER_SUPPLY_PROP_FUELGAUGE_RESET, |
60642433 | 177 | POWER_SUPPLY_PROP_SOH, |
36f70d28 TP |
178 | /* Local extensions of type int64_t */ |
179 | POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT, | |
4a11b59d AV |
180 | /* Properties of type `const char *' */ |
181 | POWER_SUPPLY_PROP_MODEL_NAME, | |
182 | POWER_SUPPLY_PROP_MANUFACTURER, | |
7c2670bb | 183 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
40798a41 JB |
184 | |
185 | POWER_SUPPLY_PROP_VCHGIN, | |
186 | POWER_SUPPLY_PROP_VWCIN, | |
187 | POWER_SUPPLY_PROP_VBYP, | |
188 | POWER_SUPPLY_PROP_VSYS, | |
189 | POWER_SUPPLY_PROP_VBAT, | |
190 | POWER_SUPPLY_PROP_VGPADC, | |
191 | POWER_SUPPLY_PROP_VCC1, | |
192 | POWER_SUPPLY_PROP_VCC2, | |
193 | POWER_SUPPLY_PROP_ICHGIN, | |
194 | POWER_SUPPLY_PROP_IWCIN, | |
195 | POWER_SUPPLY_PROP_IOTG, | |
196 | POWER_SUPPLY_PROP_ITX, | |
197 | POWER_SUPPLY_PROP_CO_ENABLE, | |
198 | POWER_SUPPLY_PROP_RR_ENABLE, | |
60642433 | 199 | POWER_SUPPLY_PROP_USBPD_RESET, |
8a38de7f | 200 | POWER_SUPPLY_PROP_USBPD_TEST_READ, |
32ba0a50 | 201 | POWER_SUPPLY_PROP_CHARGE_RATE, |
4a11b59d AV |
202 | }; |
203 | ||
204 | enum power_supply_type { | |
9b887227 KM |
205 | POWER_SUPPLY_TYPE_UNKNOWN = 0, |
206 | POWER_SUPPLY_TYPE_BATTERY, | |
4a11b59d AV |
207 | POWER_SUPPLY_TYPE_UPS, |
208 | POWER_SUPPLY_TYPE_MAINS, | |
71399aa5 BL |
209 | POWER_SUPPLY_TYPE_USB, /* Standard Downstream Port */ |
210 | POWER_SUPPLY_TYPE_USB_DCP, /* Dedicated Charging Port */ | |
211 | POWER_SUPPLY_TYPE_USB_CDP, /* Charging Downstream Port */ | |
212 | POWER_SUPPLY_TYPE_USB_ACA, /* Accessory Charger Adapters */ | |
213 | POWER_SUPPLY_TYPE_USB_TYPE_C, /* Type C Port */ | |
214 | POWER_SUPPLY_TYPE_USB_PD, /* Power Delivery Port */ | |
215 | POWER_SUPPLY_TYPE_USB_PD_DRP, /* PD Dual Role Port */ | |
216 | POWER_SUPPLY_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */ | |
1ee72d30 KH |
217 | POWER_SUPPLY_TYPE_OTG, |
218 | POWER_SUPPLY_TYPE_HV_MAINS, | |
219 | POWER_SUPPLY_TYPE_PREPARE_TA, | |
220 | POWER_SUPPLY_TYPE_SMART_NOTG, | |
221 | POWER_SUPPLY_TYPE_END, | |
4a11b59d AV |
222 | }; |
223 | ||
d36240d2 PR |
224 | enum power_supply_notifier_events { |
225 | PSY_EVENT_PROP_CHANGED, | |
60642433 | 226 | PSY_EVENT_PROP_ADDED, |
d36240d2 PR |
227 | }; |
228 | ||
4a11b59d AV |
229 | union power_supply_propval { |
230 | int intval; | |
231 | const char *strval; | |
36f70d28 | 232 | int64_t int64val; |
4a11b59d AV |
233 | }; |
234 | ||
b50df95c | 235 | struct device_node; |
297d716f | 236 | struct power_supply; |
b50df95c | 237 | |
297d716f | 238 | /* Run-time specific power supply configuration */ |
2dc9215d KK |
239 | struct power_supply_config { |
240 | struct device_node *of_node; | |
241 | /* Driver private data */ | |
242 | void *drv_data; | |
243 | ||
244 | char **supplied_to; | |
245 | size_t num_supplicants; | |
246 | }; | |
247 | ||
297d716f KK |
248 | /* Description of power supply */ |
249 | struct power_supply_desc { | |
4a11b59d AV |
250 | const char *name; |
251 | enum power_supply_type type; | |
252 | enum power_supply_property *properties; | |
253 | size_t num_properties; | |
254 | ||
bc154056 KK |
255 | /* |
256 | * Functions for drivers implementing power supply class. | |
257 | * These shouldn't be called directly by other drivers for accessing | |
258 | * this power supply. Instead use power_supply_*() functions (for | |
259 | * example power_supply_get_property()). | |
260 | */ | |
4a11b59d AV |
261 | int (*get_property)(struct power_supply *psy, |
262 | enum power_supply_property psp, | |
263 | union power_supply_propval *val); | |
0011d2d4 DM |
264 | int (*set_property)(struct power_supply *psy, |
265 | enum power_supply_property psp, | |
266 | const union power_supply_propval *val); | |
5c6e3a97 KK |
267 | /* |
268 | * property_is_writeable() will be called during registration | |
269 | * of power supply. If this happens during device probe then it must | |
270 | * not access internal data of device (because probe did not end). | |
271 | */ | |
0011d2d4 DM |
272 | int (*property_is_writeable)(struct power_supply *psy, |
273 | enum power_supply_property psp); | |
4a11b59d | 274 | void (*external_power_changed)(struct power_supply *psy); |
e5f5ccb6 | 275 | void (*set_charged)(struct power_supply *psy); |
4a11b59d | 276 | |
a69d82b9 KK |
277 | /* |
278 | * Set if thermal zone should not be created for this power supply. | |
279 | * For example for virtual supplies forwarding calls to actual | |
280 | * sensors or other supplies. | |
281 | */ | |
282 | bool no_thermal; | |
4a11b59d AV |
283 | /* For APM emulation, think legacy userspace. */ |
284 | int use_for_apm; | |
297d716f KK |
285 | }; |
286 | ||
287 | struct power_supply { | |
288 | const struct power_supply_desc *desc; | |
289 | ||
290 | char **supplied_to; | |
291 | size_t num_supplicants; | |
292 | ||
293 | char **supplied_from; | |
294 | size_t num_supplies; | |
295 | struct device_node *of_node; | |
4a11b59d | 296 | |
e44ea364 KK |
297 | /* Driver private data */ |
298 | void *drv_data; | |
299 | ||
4a11b59d | 300 | /* private */ |
297d716f | 301 | struct device dev; |
4a11b59d | 302 | struct work_struct changed_work; |
7f1a57fd | 303 | struct delayed_work deferred_register_work; |
948dcf96 ZM |
304 | spinlock_t changed_lock; |
305 | bool changed; | |
e3805385 | 306 | bool initialized; |
e70f938a | 307 | bool removing; |
bc154056 | 308 | atomic_t use_cnt; |
3be330bf JT |
309 | #ifdef CONFIG_THERMAL |
310 | struct thermal_zone_device *tzd; | |
952aeeb3 | 311 | struct thermal_cooling_device *tcd; |
3be330bf | 312 | #endif |
4a11b59d AV |
313 | |
314 | #ifdef CONFIG_LEDS_TRIGGERS | |
315 | struct led_trigger *charging_full_trig; | |
316 | char *charging_full_trig_name; | |
317 | struct led_trigger *charging_trig; | |
318 | char *charging_trig_name; | |
319 | struct led_trigger *full_trig; | |
320 | char *full_trig_name; | |
321 | struct led_trigger *online_trig; | |
322 | char *online_trig_name; | |
6501f728 VK |
323 | struct led_trigger *charging_blink_full_solid_trig; |
324 | char *charging_blink_full_solid_trig_name; | |
4a11b59d AV |
325 | #endif |
326 | }; | |
327 | ||
328 | /* | |
329 | * This is recommended structure to specify static power supply parameters. | |
330 | * Generic one, parametrizable for different power supplies. Power supply | |
331 | * class itself does not use it, but that's what implementing most platform | |
332 | * drivers, should try reuse for consistency. | |
333 | */ | |
334 | ||
335 | struct power_supply_info { | |
336 | const char *name; | |
337 | int technology; | |
338 | int voltage_max_design; | |
339 | int voltage_min_design; | |
340 | int charge_full_design; | |
341 | int charge_empty_design; | |
342 | int energy_full_design; | |
343 | int energy_empty_design; | |
344 | int use_for_apm; | |
345 | }; | |
346 | ||
c08b1f45 LB |
347 | /* |
348 | * This is the recommended struct to manage static battery parameters, | |
349 | * populated by power_supply_get_battery_info(). Most platform drivers should | |
350 | * use these for consistency. | |
351 | * Its field names must correspond to elements in enum power_supply_property. | |
352 | * The default field value is -EINVAL. | |
353 | * Power supply class itself doesn't use this. | |
354 | */ | |
355 | ||
356 | struct power_supply_battery_info { | |
357 | int energy_full_design_uwh; /* microWatt-hours */ | |
358 | int charge_full_design_uah; /* microAmp-hours */ | |
359 | int voltage_min_design_uv; /* microVolts */ | |
360 | int precharge_current_ua; /* microAmps */ | |
361 | int charge_term_current_ua; /* microAmps */ | |
362 | int constant_charge_current_max_ua; /* microAmps */ | |
363 | int constant_charge_voltage_max_uv; /* microVolts */ | |
364 | }; | |
365 | ||
d36240d2 PR |
366 | extern struct atomic_notifier_head power_supply_notifier; |
367 | extern int power_supply_reg_notifier(struct notifier_block *nb); | |
368 | extern void power_supply_unreg_notifier(struct notifier_block *nb); | |
9f3b795a | 369 | extern struct power_supply *power_supply_get_by_name(const char *name); |
1a352462 | 370 | extern void power_supply_put(struct power_supply *psy); |
abce9770 SR |
371 | #ifdef CONFIG_OF |
372 | extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, | |
373 | const char *property); | |
fe27e1df HG |
374 | extern struct power_supply *devm_power_supply_get_by_phandle( |
375 | struct device *dev, const char *property); | |
abce9770 SR |
376 | #else /* !CONFIG_OF */ |
377 | static inline struct power_supply * | |
378 | power_supply_get_by_phandle(struct device_node *np, const char *property) | |
379 | { return NULL; } | |
fe27e1df HG |
380 | static inline struct power_supply * |
381 | devm_power_supply_get_by_phandle(struct device *dev, const char *property) | |
382 | { return NULL; } | |
abce9770 | 383 | #endif /* CONFIG_OF */ |
c08b1f45 LB |
384 | |
385 | extern int power_supply_get_battery_info(struct power_supply *psy, | |
386 | struct power_supply_battery_info *info); | |
4a11b59d AV |
387 | extern void power_supply_changed(struct power_supply *psy); |
388 | extern int power_supply_am_i_supplied(struct power_supply *psy); | |
c3142dd8 HG |
389 | extern int power_supply_set_input_current_limit_from_supplier( |
390 | struct power_supply *psy); | |
e5f5ccb6 | 391 | extern int power_supply_set_battery_charged(struct power_supply *psy); |
4a11b59d | 392 | |
0d4ed4e2 | 393 | #ifdef CONFIG_POWER_SUPPLY |
942ed161 MG |
394 | extern int power_supply_is_system_supplied(void); |
395 | #else | |
396 | static inline int power_supply_is_system_supplied(void) { return -ENOSYS; } | |
397 | #endif | |
398 | ||
bc154056 KK |
399 | extern int power_supply_get_property(struct power_supply *psy, |
400 | enum power_supply_property psp, | |
401 | union power_supply_propval *val); | |
402 | extern int power_supply_set_property(struct power_supply *psy, | |
403 | enum power_supply_property psp, | |
404 | const union power_supply_propval *val); | |
405 | extern int power_supply_property_is_writeable(struct power_supply *psy, | |
406 | enum power_supply_property psp); | |
407 | extern void power_supply_external_power_changed(struct power_supply *psy); | |
297d716f KK |
408 | |
409 | extern struct power_supply *__must_check | |
410 | power_supply_register(struct device *parent, | |
411 | const struct power_supply_desc *desc, | |
2dc9215d | 412 | const struct power_supply_config *cfg); |
297d716f KK |
413 | extern struct power_supply *__must_check |
414 | power_supply_register_no_ws(struct device *parent, | |
415 | const struct power_supply_desc *desc, | |
2dc9215d | 416 | const struct power_supply_config *cfg); |
297d716f KK |
417 | extern struct power_supply *__must_check |
418 | devm_power_supply_register(struct device *parent, | |
419 | const struct power_supply_desc *desc, | |
2dc9215d | 420 | const struct power_supply_config *cfg); |
297d716f KK |
421 | extern struct power_supply *__must_check |
422 | devm_power_supply_register_no_ws(struct device *parent, | |
423 | const struct power_supply_desc *desc, | |
2dc9215d | 424 | const struct power_supply_config *cfg); |
4a11b59d | 425 | extern void power_supply_unregister(struct power_supply *psy); |
83516651 | 426 | extern int power_supply_powers(struct power_supply *psy, struct device *dev); |
4a11b59d | 427 | |
e44ea364 | 428 | extern void *power_supply_get_drvdata(struct power_supply *psy); |
4a11b59d AV |
429 | /* For APM emulation, think legacy userspace. */ |
430 | extern struct class *power_supply_class; | |
431 | ||
51d07566 RK |
432 | static inline bool power_supply_is_amp_property(enum power_supply_property psp) |
433 | { | |
434 | switch (psp) { | |
435 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: | |
436 | case POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN: | |
437 | case POWER_SUPPLY_PROP_CHARGE_FULL: | |
438 | case POWER_SUPPLY_PROP_CHARGE_EMPTY: | |
439 | case POWER_SUPPLY_PROP_CHARGE_NOW: | |
440 | case POWER_SUPPLY_PROP_CHARGE_AVG: | |
441 | case POWER_SUPPLY_PROP_CHARGE_COUNTER: | |
413de34a LB |
442 | case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: |
443 | case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: | |
3824c477 | 444 | case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: |
2815b786 | 445 | case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: |
51d07566 RK |
446 | case POWER_SUPPLY_PROP_CURRENT_MAX: |
447 | case POWER_SUPPLY_PROP_CURRENT_NOW: | |
448 | case POWER_SUPPLY_PROP_CURRENT_AVG: | |
a8adcc90 | 449 | case POWER_SUPPLY_PROP_CURRENT_BOOT: |
51d07566 RK |
450 | return 1; |
451 | default: | |
452 | break; | |
453 | } | |
454 | ||
455 | return 0; | |
456 | } | |
457 | ||
458 | static inline bool power_supply_is_watt_property(enum power_supply_property psp) | |
459 | { | |
460 | switch (psp) { | |
461 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: | |
462 | case POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN: | |
463 | case POWER_SUPPLY_PROP_ENERGY_FULL: | |
464 | case POWER_SUPPLY_PROP_ENERGY_EMPTY: | |
465 | case POWER_SUPPLY_PROP_ENERGY_NOW: | |
466 | case POWER_SUPPLY_PROP_ENERGY_AVG: | |
467 | case POWER_SUPPLY_PROP_VOLTAGE_MAX: | |
468 | case POWER_SUPPLY_PROP_VOLTAGE_MIN: | |
469 | case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: | |
470 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | |
471 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: | |
472 | case POWER_SUPPLY_PROP_VOLTAGE_AVG: | |
a2ebfe2f | 473 | case POWER_SUPPLY_PROP_VOLTAGE_OCV: |
a8adcc90 | 474 | case POWER_SUPPLY_PROP_VOLTAGE_BOOT: |
3824c477 | 475 | case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: |
2815b786 | 476 | case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: |
35c9d267 | 477 | case POWER_SUPPLY_PROP_POWER_NOW: |
51d07566 RK |
478 | return 1; |
479 | default: | |
480 | break; | |
481 | } | |
482 | ||
483 | return 0; | |
484 | } | |
485 | ||
4a11b59d | 486 | #endif /* __LINUX_POWER_SUPPLY_H__ */ |