1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Universal power supply monitor class
4 *
5 * Copyright © 2007 Anton Vorontsov <cbou@mail.ru>
6 * Copyright © 2004 Szabolcs Gyurko
7 * Copyright © 2003 Ian Molton <spyro@f2s.com>
8 *
9 * Modified: 2004, Oct Szabolcs Gyurko
10 */
11
12 #ifndef __LINUX_POWER_SUPPLY_H__
13 #define __LINUX_POWER_SUPPLY_H__
14
15 #include <linux/device.h>
16 #include <linux/workqueue.h>
17 #include <linux/leds.h>
18 #include <linux/spinlock.h>
19 #include <linux/notifier.h>
20 #include <linux/android_kabi.h>
21
22 /*
23 * All voltages, currents, charges, energies, time and temperatures in uV,
24 * µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
25 * stated. It's driver's job to convert its raw values to units in which
26 * this class operates.
27 */
28
29 /*
30 * For systems where the charger determines the maximum battery capacity
31 * the min and max fields should be used to present these values to user
32 * space. Unused/unknown fields will not appear in sysfs.
33 */
34
35 enum {
36 POWER_SUPPLY_STATUS_UNKNOWN = 0,
37 POWER_SUPPLY_STATUS_CHARGING,
38 POWER_SUPPLY_STATUS_DISCHARGING,
39 POWER_SUPPLY_STATUS_NOT_CHARGING,
40 POWER_SUPPLY_STATUS_FULL,
41 };
42
43 /* What algorithm is the charger using? */
44 enum {
45 POWER_SUPPLY_CHARGE_TYPE_UNKNOWN = 0,
46 POWER_SUPPLY_CHARGE_TYPE_NONE,
47 POWER_SUPPLY_CHARGE_TYPE_TRICKLE, /* slow speed */
48 POWER_SUPPLY_CHARGE_TYPE_FAST, /* fast speed */
49 POWER_SUPPLY_CHARGE_TYPE_STANDARD, /* normal speed */
50 POWER_SUPPLY_CHARGE_TYPE_ADAPTIVE, /* dynamically adjusted speed */
51 POWER_SUPPLY_CHARGE_TYPE_CUSTOM, /* use CHARGE_CONTROL_* props */
52 POWER_SUPPLY_CHARGE_TYPE_LONGLIFE, /* slow speed, longer life */
53
54 /*
55 * force to 50 to minimize the chances of userspace binary
56 * incompatibility on newer upstream kernels
57 */
58 POWER_SUPPLY_CHARGE_TYPE_TAPER_EXT = 50, /* charging in CV phase */
59 };
60
61 enum {
62 POWER_SUPPLY_HEALTH_UNKNOWN = 0,
63 POWER_SUPPLY_HEALTH_GOOD,
64 POWER_SUPPLY_HEALTH_OVERHEAT,
65 POWER_SUPPLY_HEALTH_DEAD,
66 POWER_SUPPLY_HEALTH_OVERVOLTAGE,
67 POWER_SUPPLY_HEALTH_UNSPEC_FAILURE,
68 POWER_SUPPLY_HEALTH_COLD,
69 POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE,
70 POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE,
71 POWER_SUPPLY_HEALTH_OVERCURRENT,
72 POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED,
73 POWER_SUPPLY_HEALTH_WARM,
74 POWER_SUPPLY_HEALTH_COOL,
75 POWER_SUPPLY_HEALTH_HOT,
76 };
77
78 enum {
79 POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0,
80 POWER_SUPPLY_TECHNOLOGY_NiMH,
81 POWER_SUPPLY_TECHNOLOGY_LION,
82 POWER_SUPPLY_TECHNOLOGY_LIPO,
83 POWER_SUPPLY_TECHNOLOGY_LiFe,
84 POWER_SUPPLY_TECHNOLOGY_NiCd,
85 POWER_SUPPLY_TECHNOLOGY_LiMn,
86 };
87
88 enum {
89 POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0,
90 POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL,
91 POWER_SUPPLY_CAPACITY_LEVEL_LOW,
92 POWER_SUPPLY_CAPACITY_LEVEL_NORMAL,
93 POWER_SUPPLY_CAPACITY_LEVEL_HIGH,
94 POWER_SUPPLY_CAPACITY_LEVEL_FULL,
95 };
96
97 enum {
98 POWER_SUPPLY_SCOPE_UNKNOWN = 0,
99 POWER_SUPPLY_SCOPE_SYSTEM,
100 POWER_SUPPLY_SCOPE_DEVICE,
101 };
102
103 enum power_supply_property {
104 /* Properties of type `int' */
105 POWER_SUPPLY_PROP_STATUS = 0,
106 POWER_SUPPLY_PROP_CHARGE_TYPE,
107 POWER_SUPPLY_PROP_HEALTH,
108 POWER_SUPPLY_PROP_PRESENT,
109 POWER_SUPPLY_PROP_ONLINE,
110 POWER_SUPPLY_PROP_AUTHENTIC,
111 POWER_SUPPLY_PROP_TECHNOLOGY,
112 POWER_SUPPLY_PROP_CYCLE_COUNT,
113 POWER_SUPPLY_PROP_VOLTAGE_MAX,
114 POWER_SUPPLY_PROP_VOLTAGE_MIN,
115 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
116 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
117 POWER_SUPPLY_PROP_VOLTAGE_NOW,
118 POWER_SUPPLY_PROP_VOLTAGE_AVG,
119 POWER_SUPPLY_PROP_VOLTAGE_OCV,
120 POWER_SUPPLY_PROP_VOLTAGE_BOOT,
121 POWER_SUPPLY_PROP_CURRENT_MAX,
122 POWER_SUPPLY_PROP_CURRENT_NOW,
123 POWER_SUPPLY_PROP_CURRENT_AVG,
124 POWER_SUPPLY_PROP_CURRENT_BOOT,
125 POWER_SUPPLY_PROP_POWER_NOW,
126 POWER_SUPPLY_PROP_POWER_AVG,
127 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
128 POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN,
129 POWER_SUPPLY_PROP_CHARGE_FULL,
130 POWER_SUPPLY_PROP_CHARGE_EMPTY,
131 POWER_SUPPLY_PROP_CHARGE_NOW,
132 POWER_SUPPLY_PROP_CHARGE_AVG,
133 POWER_SUPPLY_PROP_CHARGE_COUNTER,
134 POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
135 POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
136 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
137 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
138 POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
139 POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
140 POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD, /* in percents! */
141 POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD, /* in percents! */
142 POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
143 POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT,
144 POWER_SUPPLY_PROP_INPUT_POWER_LIMIT,
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! */
152 POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, /* in percents! */
153 POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX, /* in percents! */
154 POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, /* in percents! */
155 POWER_SUPPLY_PROP_CAPACITY_LEVEL,
156 POWER_SUPPLY_PROP_TEMP,
157 POWER_SUPPLY_PROP_TEMP_MAX,
158 POWER_SUPPLY_PROP_TEMP_MIN,
159 POWER_SUPPLY_PROP_TEMP_ALERT_MIN,
160 POWER_SUPPLY_PROP_TEMP_ALERT_MAX,
161 POWER_SUPPLY_PROP_TEMP_AMBIENT,
162 POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN,
163 POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX,
164 POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
165 POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
166 POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
167 POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
168 POWER_SUPPLY_PROP_TYPE, /* use power_supply.type instead */
169 POWER_SUPPLY_PROP_USB_TYPE,
170 POWER_SUPPLY_PROP_SCOPE,
171 POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
172 POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
173 POWER_SUPPLY_PROP_CALIBRATE,
174 POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
175 POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
176 POWER_SUPPLY_PROP_MANUFACTURE_DAY,
177 /* Properties of type `const char *' */
178 POWER_SUPPLY_PROP_MODEL_NAME,
179 POWER_SUPPLY_PROP_MANUFACTURER,
180 POWER_SUPPLY_PROP_SERIAL_NUMBER,
181 };
182
183 enum power_supply_type {
184 POWER_SUPPLY_TYPE_UNKNOWN = 0,
185 POWER_SUPPLY_TYPE_BATTERY,
186 POWER_SUPPLY_TYPE_UPS,
187 POWER_SUPPLY_TYPE_MAINS,
188 POWER_SUPPLY_TYPE_USB, /* Standard Downstream Port */
189 POWER_SUPPLY_TYPE_USB_DCP, /* Dedicated Charging Port */
190 POWER_SUPPLY_TYPE_USB_CDP, /* Charging Downstream Port */
191 POWER_SUPPLY_TYPE_USB_ACA, /* Accessory Charger Adapters */
192 POWER_SUPPLY_TYPE_USB_TYPE_C, /* Type C Port */
193 POWER_SUPPLY_TYPE_USB_PD, /* Power Delivery Port */
194 POWER_SUPPLY_TYPE_USB_PD_DRP, /* PD Dual Role Port */
195 POWER_SUPPLY_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */
196 POWER_SUPPLY_TYPE_WIRELESS, /* Wireless */
197 };
198
199 enum power_supply_usb_type {
200 POWER_SUPPLY_USB_TYPE_UNKNOWN = 0,
201 POWER_SUPPLY_USB_TYPE_SDP, /* Standard Downstream Port */
202 POWER_SUPPLY_USB_TYPE_DCP, /* Dedicated Charging Port */
203 POWER_SUPPLY_USB_TYPE_CDP, /* Charging Downstream Port */
204 POWER_SUPPLY_USB_TYPE_ACA, /* Accessory Charger Adapters */
205 POWER_SUPPLY_USB_TYPE_C, /* Type C Port */
206 POWER_SUPPLY_USB_TYPE_PD, /* Power Delivery Port */
207 POWER_SUPPLY_USB_TYPE_PD_DRP, /* PD Dual Role Port */
208 POWER_SUPPLY_USB_TYPE_PD_PPS, /* PD Programmable Power Supply */
209 POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */
210 };
211
212 enum power_supply_notifier_events {
213 PSY_EVENT_PROP_CHANGED,
214 };
215
216 union power_supply_propval {
217 int intval;
218 const char *strval;
219 };
220
221 struct device_node;
222 struct power_supply;
223
224 /* Run-time specific power supply configuration */
225 struct power_supply_config {
226 struct device_node *of_node;
227 struct fwnode_handle *fwnode;
228
229 /* Driver private data */
230 void *drv_data;
231
232 /* Device specific sysfs attributes */
233 const struct attribute_group **attr_grp;
234
235 char **supplied_to;
236 size_t num_supplicants;
237
238 ANDROID_KABI_RESERVE(1);
239 };
240
241 /* Description of power supply */
242 struct power_supply_desc {
243 const char *name;
244 enum power_supply_type type;
245 const enum power_supply_usb_type *usb_types;
246 size_t num_usb_types;
247 const enum power_supply_property *properties;
248 size_t num_properties;
249
250 /*
251 * Functions for drivers implementing power supply class.
252 * These shouldn't be called directly by other drivers for accessing
253 * this power supply. Instead use power_supply_*() functions (for
254 * example power_supply_get_property()).
255 */
256 int (*get_property)(struct power_supply *psy,
257 enum power_supply_property psp,
258 union power_supply_propval *val);
259 int (*set_property)(struct power_supply *psy,
260 enum power_supply_property psp,
261 const union power_supply_propval *val);
262 /*
263 * property_is_writeable() will be called during registration
264 * of power supply. If this happens during device probe then it must
265 * not access internal data of device (because probe did not end).
266 */
267 int (*property_is_writeable)(struct power_supply *psy,
268 enum power_supply_property psp);
269 void (*external_power_changed)(struct power_supply *psy);
270 void (*set_charged)(struct power_supply *psy);
271
272 /*
273 * Set if thermal zone should not be created for this power supply.
274 * For example for virtual supplies forwarding calls to actual
275 * sensors or other supplies.
276 */
277 bool no_thermal;
278 /* For APM emulation, think legacy userspace. */
279 int use_for_apm;
280
281 ANDROID_KABI_RESERVE(1);
282 };
283
284 struct power_supply {
285 const struct power_supply_desc *desc;
286
287 char **supplied_to;
288 size_t num_supplicants;
289
290 char **supplied_from;
291 size_t num_supplies;
292 struct device_node *of_node;
293
294 /* Driver private data */
295 void *drv_data;
296
297 /* private */
298 struct device dev;
299 struct work_struct changed_work;
300 struct delayed_work deferred_register_work;
301 spinlock_t changed_lock;
302 bool changed;
303 bool initialized;
304 bool removing;
305 atomic_t use_cnt;
306 #ifdef CONFIG_THERMAL
307 struct thermal_zone_device *tzd;
308 struct thermal_cooling_device *tcd;
309 #endif
310
311 #ifdef CONFIG_LEDS_TRIGGERS
312 struct led_trigger *charging_full_trig;
313 char *charging_full_trig_name;
314 struct led_trigger *charging_trig;
315 char *charging_trig_name;
316 struct led_trigger *full_trig;
317 char *full_trig_name;
318 struct led_trigger *online_trig;
319 char *online_trig_name;
320 struct led_trigger *charging_blink_full_solid_trig;
321 char *charging_blink_full_solid_trig_name;
322 #endif
323
324 ANDROID_KABI_RESERVE(1);
325 };
326
327 /*
328 * This is recommended structure to specify static power supply parameters.
329 * Generic one, parametrizable for different power supplies. Power supply
330 * class itself does not use it, but that's what implementing most platform
331 * drivers, should try reuse for consistency.
332 */
333
334 struct power_supply_info {
335 const char *name;
336 int technology;
337 int voltage_max_design;
338 int voltage_min_design;
339 int charge_full_design;
340 int charge_empty_design;
341 int energy_full_design;
342 int energy_empty_design;
343 int use_for_apm;
344 };
345
346 struct power_supply_battery_ocv_table {
347 int ocv; /* microVolts */
348 int capacity; /* percent */
349 };
350
351 struct power_supply_resistance_temp_table {
352 int temp; /* celsius */
353 int resistance; /* internal resistance percent */
354 };
355
356 #define POWER_SUPPLY_OCV_TEMP_MAX 20
357
358 /*
359 * This is the recommended struct to manage static battery parameters,
360 * populated by power_supply_get_battery_info(). Most platform drivers should
361 * use these for consistency.
362 * Its field names must correspond to elements in enum power_supply_property.
363 * The default field value is -EINVAL.
364 * Power supply class itself doesn't use this.
365 */
366
367 struct power_supply_battery_info {
368 unsigned int technology; /* from the enum above */
369 int energy_full_design_uwh; /* microWatt-hours */
370 int charge_full_design_uah; /* microAmp-hours */
371 int voltage_min_design_uv; /* microVolts */
372 int voltage_max_design_uv; /* microVolts */
373 int tricklecharge_current_ua; /* microAmps */
374 int precharge_current_ua; /* microAmps */
375 int precharge_voltage_max_uv; /* microVolts */
376 int charge_term_current_ua; /* microAmps */
377 int charge_restart_voltage_uv; /* microVolts */
378 int overvoltage_limit_uv; /* microVolts */
379 int constant_charge_current_max_ua; /* microAmps */
380 int constant_charge_voltage_max_uv; /* microVolts */
381 int factory_internal_resistance_uohm; /* microOhms */
382 int ocv_temp[POWER_SUPPLY_OCV_TEMP_MAX];/* celsius */
383 int temp_ambient_alert_min; /* celsius */
384 int temp_ambient_alert_max; /* celsius */
385 int temp_alert_min; /* celsius */
386 int temp_alert_max; /* celsius */
387 int temp_min; /* celsius */
388 int temp_max; /* celsius */
389 struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX];
390 int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX];
391 struct power_supply_resistance_temp_table *resist_table;
392 int resist_table_size;
393
394 ANDROID_KABI_RESERVE(1);
395 };
396
397 extern struct atomic_notifier_head power_supply_notifier;
398 extern int power_supply_reg_notifier(struct notifier_block *nb);
399 extern void power_supply_unreg_notifier(struct notifier_block *nb);
400 #if IS_ENABLED(CONFIG_POWER_SUPPLY)
401 extern struct power_supply *power_supply_get_by_name(const char *name);
402 extern void power_supply_put(struct power_supply *psy);
403 #else
power_supply_put(struct power_supply * psy)404 static inline void power_supply_put(struct power_supply *psy) {}
power_supply_get_by_name(const char * name)405 static inline struct power_supply *power_supply_get_by_name(const char *name)
406 { return NULL; }
407 #endif
408 #ifdef CONFIG_OF
409 extern struct power_supply *power_supply_get_by_phandle(struct device_node *np,
410 const char *property);
411 extern int power_supply_get_by_phandle_array(struct device_node *np,
412 const char *property,
413 struct power_supply **psy,
414 ssize_t size);
415 extern struct power_supply *devm_power_supply_get_by_phandle(
416 struct device *dev, const char *property);
417 #else /* !CONFIG_OF */
418 static inline struct power_supply *
power_supply_get_by_phandle(struct device_node * np,const char * property)419 power_supply_get_by_phandle(struct device_node *np, const char *property)
420 { return NULL; }
421 static inline int
power_supply_get_by_phandle_array(struct device_node * np,const char * property,struct power_supply ** psy,int size)422 power_supply_get_by_phandle_array(struct device_node *np,
423 const char *property,
424 struct power_supply **psy,
425 int size)
426 { return 0; }
427 static inline struct power_supply *
devm_power_supply_get_by_phandle(struct device * dev,const char * property)428 devm_power_supply_get_by_phandle(struct device *dev, const char *property)
429 { return NULL; }
430 #endif /* CONFIG_OF */
431
432 extern int power_supply_get_battery_info(struct power_supply *psy,
433 struct power_supply_battery_info *info);
434 extern void power_supply_put_battery_info(struct power_supply *psy,
435 struct power_supply_battery_info *info);
436 extern int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table,
437 int table_len, int ocv);
438 extern struct power_supply_battery_ocv_table *
439 power_supply_find_ocv2cap_table(struct power_supply_battery_info *info,
440 int temp, int *table_len);
441 extern int power_supply_batinfo_ocv2cap(struct power_supply_battery_info *info,
442 int ocv, int temp);
443 extern int
444 power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *table,
445 int table_len, int temp);
446 extern void power_supply_changed(struct power_supply *psy);
447 extern int power_supply_am_i_supplied(struct power_supply *psy);
448 int power_supply_get_property_from_supplier(struct power_supply *psy,
449 enum power_supply_property psp,
450 union power_supply_propval *val);
451 extern int power_supply_set_battery_charged(struct power_supply *psy);
452
453 #ifdef CONFIG_POWER_SUPPLY
454 extern int power_supply_is_system_supplied(void);
455 #else
power_supply_is_system_supplied(void)456 static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
457 #endif
458
459 extern int power_supply_get_property(struct power_supply *psy,
460 enum power_supply_property psp,
461 union power_supply_propval *val);
462 #if IS_ENABLED(CONFIG_POWER_SUPPLY)
463 extern int power_supply_set_property(struct power_supply *psy,
464 enum power_supply_property psp,
465 const union power_supply_propval *val);
466 #else
power_supply_set_property(struct power_supply * psy,enum power_supply_property psp,const union power_supply_propval * val)467 static inline int power_supply_set_property(struct power_supply *psy,
468 enum power_supply_property psp,
469 const union power_supply_propval *val)
470 { return 0; }
471 #endif
472 extern int power_supply_property_is_writeable(struct power_supply *psy,
473 enum power_supply_property psp);
474 extern void power_supply_external_power_changed(struct power_supply *psy);
475
476 extern struct power_supply *__must_check
477 power_supply_register(struct device *parent,
478 const struct power_supply_desc *desc,
479 const struct power_supply_config *cfg);
480 extern struct power_supply *__must_check
481 power_supply_register_no_ws(struct device *parent,
482 const struct power_supply_desc *desc,
483 const struct power_supply_config *cfg);
484 extern struct power_supply *__must_check
485 devm_power_supply_register(struct device *parent,
486 const struct power_supply_desc *desc,
487 const struct power_supply_config *cfg);
488 extern struct power_supply *__must_check
489 devm_power_supply_register_no_ws(struct device *parent,
490 const struct power_supply_desc *desc,
491 const struct power_supply_config *cfg);
492 extern void power_supply_unregister(struct power_supply *psy);
493 extern int power_supply_powers(struct power_supply *psy, struct device *dev);
494
495 #define to_power_supply(device) container_of(device, struct power_supply, dev)
496
497 extern void *power_supply_get_drvdata(struct power_supply *psy);
498 /* For APM emulation, think legacy userspace. */
499 extern struct class *power_supply_class;
500
power_supply_is_amp_property(enum power_supply_property psp)501 static inline bool power_supply_is_amp_property(enum power_supply_property psp)
502 {
503 switch (psp) {
504 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
505 case POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN:
506 case POWER_SUPPLY_PROP_CHARGE_FULL:
507 case POWER_SUPPLY_PROP_CHARGE_EMPTY:
508 case POWER_SUPPLY_PROP_CHARGE_NOW:
509 case POWER_SUPPLY_PROP_CHARGE_AVG:
510 case POWER_SUPPLY_PROP_CHARGE_COUNTER:
511 case POWER_SUPPLY_PROP_PRECHARGE_CURRENT:
512 case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
513 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
514 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
515 case POWER_SUPPLY_PROP_CURRENT_MAX:
516 case POWER_SUPPLY_PROP_CURRENT_NOW:
517 case POWER_SUPPLY_PROP_CURRENT_AVG:
518 case POWER_SUPPLY_PROP_CURRENT_BOOT:
519 return true;
520 default:
521 break;
522 }
523
524 return false;
525 }
526
power_supply_is_watt_property(enum power_supply_property psp)527 static inline bool power_supply_is_watt_property(enum power_supply_property psp)
528 {
529 switch (psp) {
530 case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
531 case POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN:
532 case POWER_SUPPLY_PROP_ENERGY_FULL:
533 case POWER_SUPPLY_PROP_ENERGY_EMPTY:
534 case POWER_SUPPLY_PROP_ENERGY_NOW:
535 case POWER_SUPPLY_PROP_ENERGY_AVG:
536 case POWER_SUPPLY_PROP_VOLTAGE_MAX:
537 case POWER_SUPPLY_PROP_VOLTAGE_MIN:
538 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
539 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
540 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
541 case POWER_SUPPLY_PROP_VOLTAGE_AVG:
542 case POWER_SUPPLY_PROP_VOLTAGE_OCV:
543 case POWER_SUPPLY_PROP_VOLTAGE_BOOT:
544 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
545 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
546 case POWER_SUPPLY_PROP_POWER_NOW:
547 return true;
548 default:
549 break;
550 }
551
552 return false;
553 }
554
555 #ifdef CONFIG_POWER_SUPPLY_HWMON
556 int power_supply_add_hwmon_sysfs(struct power_supply *psy);
557 void power_supply_remove_hwmon_sysfs(struct power_supply *psy);
558 #else
power_supply_add_hwmon_sysfs(struct power_supply * psy)559 static inline int power_supply_add_hwmon_sysfs(struct power_supply *psy)
560 {
561 return 0;
562 }
563
564 static inline
power_supply_remove_hwmon_sysfs(struct power_supply * psy)565 void power_supply_remove_hwmon_sysfs(struct power_supply *psy) {}
566 #endif
567
568 #endif /* __LINUX_POWER_SUPPLY_H__ */
569