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