xref: /openbmc/linux/include/linux/power_supply.h (revision 5fa1f768)
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 	POWER_SUPPLY_CHARGE_TYPE_LONGLIFE,	/* slow speed, longer life */
52 };
53 
54 enum {
55 	POWER_SUPPLY_HEALTH_UNKNOWN = 0,
56 	POWER_SUPPLY_HEALTH_GOOD,
57 	POWER_SUPPLY_HEALTH_OVERHEAT,
58 	POWER_SUPPLY_HEALTH_DEAD,
59 	POWER_SUPPLY_HEALTH_OVERVOLTAGE,
60 	POWER_SUPPLY_HEALTH_UNSPEC_FAILURE,
61 	POWER_SUPPLY_HEALTH_COLD,
62 	POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE,
63 	POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE,
64 	POWER_SUPPLY_HEALTH_OVERCURRENT,
65 	POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED,
66 	POWER_SUPPLY_HEALTH_WARM,
67 	POWER_SUPPLY_HEALTH_COOL,
68 	POWER_SUPPLY_HEALTH_HOT,
69 };
70 
71 enum {
72 	POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0,
73 	POWER_SUPPLY_TECHNOLOGY_NiMH,
74 	POWER_SUPPLY_TECHNOLOGY_LION,
75 	POWER_SUPPLY_TECHNOLOGY_LIPO,
76 	POWER_SUPPLY_TECHNOLOGY_LiFe,
77 	POWER_SUPPLY_TECHNOLOGY_NiCd,
78 	POWER_SUPPLY_TECHNOLOGY_LiMn,
79 };
80 
81 enum {
82 	POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0,
83 	POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL,
84 	POWER_SUPPLY_CAPACITY_LEVEL_LOW,
85 	POWER_SUPPLY_CAPACITY_LEVEL_NORMAL,
86 	POWER_SUPPLY_CAPACITY_LEVEL_HIGH,
87 	POWER_SUPPLY_CAPACITY_LEVEL_FULL,
88 };
89 
90 enum {
91 	POWER_SUPPLY_SCOPE_UNKNOWN = 0,
92 	POWER_SUPPLY_SCOPE_SYSTEM,
93 	POWER_SUPPLY_SCOPE_DEVICE,
94 };
95 
96 enum power_supply_property {
97 	/* Properties of type `int' */
98 	POWER_SUPPLY_PROP_STATUS = 0,
99 	POWER_SUPPLY_PROP_CHARGE_TYPE,
100 	POWER_SUPPLY_PROP_HEALTH,
101 	POWER_SUPPLY_PROP_PRESENT,
102 	POWER_SUPPLY_PROP_ONLINE,
103 	POWER_SUPPLY_PROP_AUTHENTIC,
104 	POWER_SUPPLY_PROP_TECHNOLOGY,
105 	POWER_SUPPLY_PROP_CYCLE_COUNT,
106 	POWER_SUPPLY_PROP_VOLTAGE_MAX,
107 	POWER_SUPPLY_PROP_VOLTAGE_MIN,
108 	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
109 	POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
110 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
111 	POWER_SUPPLY_PROP_VOLTAGE_AVG,
112 	POWER_SUPPLY_PROP_VOLTAGE_OCV,
113 	POWER_SUPPLY_PROP_VOLTAGE_BOOT,
114 	POWER_SUPPLY_PROP_CURRENT_MAX,
115 	POWER_SUPPLY_PROP_CURRENT_NOW,
116 	POWER_SUPPLY_PROP_CURRENT_AVG,
117 	POWER_SUPPLY_PROP_CURRENT_BOOT,
118 	POWER_SUPPLY_PROP_POWER_NOW,
119 	POWER_SUPPLY_PROP_POWER_AVG,
120 	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
121 	POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN,
122 	POWER_SUPPLY_PROP_CHARGE_FULL,
123 	POWER_SUPPLY_PROP_CHARGE_EMPTY,
124 	POWER_SUPPLY_PROP_CHARGE_NOW,
125 	POWER_SUPPLY_PROP_CHARGE_AVG,
126 	POWER_SUPPLY_PROP_CHARGE_COUNTER,
127 	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
128 	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
129 	POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
130 	POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
131 	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
132 	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
133 	POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD, /* in percents! */
134 	POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD, /* in percents! */
135 	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
136 	POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT,
137 	POWER_SUPPLY_PROP_INPUT_POWER_LIMIT,
138 	POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
139 	POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN,
140 	POWER_SUPPLY_PROP_ENERGY_FULL,
141 	POWER_SUPPLY_PROP_ENERGY_EMPTY,
142 	POWER_SUPPLY_PROP_ENERGY_NOW,
143 	POWER_SUPPLY_PROP_ENERGY_AVG,
144 	POWER_SUPPLY_PROP_CAPACITY, /* in percents! */
145 	POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, /* in percents! */
146 	POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX, /* in percents! */
147 	POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, /* in percents! */
148 	POWER_SUPPLY_PROP_CAPACITY_LEVEL,
149 	POWER_SUPPLY_PROP_TEMP,
150 	POWER_SUPPLY_PROP_TEMP_MAX,
151 	POWER_SUPPLY_PROP_TEMP_MIN,
152 	POWER_SUPPLY_PROP_TEMP_ALERT_MIN,
153 	POWER_SUPPLY_PROP_TEMP_ALERT_MAX,
154 	POWER_SUPPLY_PROP_TEMP_AMBIENT,
155 	POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN,
156 	POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX,
157 	POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
158 	POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
159 	POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
160 	POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
161 	POWER_SUPPLY_PROP_TYPE, /* use power_supply.type instead */
162 	POWER_SUPPLY_PROP_USB_TYPE,
163 	POWER_SUPPLY_PROP_SCOPE,
164 	POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
165 	POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
166 	POWER_SUPPLY_PROP_CALIBRATE,
167 	POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
168 	POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
169 	POWER_SUPPLY_PROP_MANUFACTURE_DAY,
170 	/* Properties of type `const char *' */
171 	POWER_SUPPLY_PROP_MODEL_NAME,
172 	POWER_SUPPLY_PROP_MANUFACTURER,
173 	POWER_SUPPLY_PROP_SERIAL_NUMBER,
174 };
175 
176 enum power_supply_type {
177 	POWER_SUPPLY_TYPE_UNKNOWN = 0,
178 	POWER_SUPPLY_TYPE_BATTERY,
179 	POWER_SUPPLY_TYPE_UPS,
180 	POWER_SUPPLY_TYPE_MAINS,
181 	POWER_SUPPLY_TYPE_USB,			/* Standard Downstream Port */
182 	POWER_SUPPLY_TYPE_USB_DCP,		/* Dedicated Charging Port */
183 	POWER_SUPPLY_TYPE_USB_CDP,		/* Charging Downstream Port */
184 	POWER_SUPPLY_TYPE_USB_ACA,		/* Accessory Charger Adapters */
185 	POWER_SUPPLY_TYPE_USB_TYPE_C,		/* Type C Port */
186 	POWER_SUPPLY_TYPE_USB_PD,		/* Power Delivery Port */
187 	POWER_SUPPLY_TYPE_USB_PD_DRP,		/* PD Dual Role Port */
188 	POWER_SUPPLY_TYPE_APPLE_BRICK_ID,	/* Apple Charging Method */
189 };
190 
191 enum power_supply_usb_type {
192 	POWER_SUPPLY_USB_TYPE_UNKNOWN = 0,
193 	POWER_SUPPLY_USB_TYPE_SDP,		/* Standard Downstream Port */
194 	POWER_SUPPLY_USB_TYPE_DCP,		/* Dedicated Charging Port */
195 	POWER_SUPPLY_USB_TYPE_CDP,		/* Charging Downstream Port */
196 	POWER_SUPPLY_USB_TYPE_ACA,		/* Accessory Charger Adapters */
197 	POWER_SUPPLY_USB_TYPE_C,		/* Type C Port */
198 	POWER_SUPPLY_USB_TYPE_PD,		/* Power Delivery Port */
199 	POWER_SUPPLY_USB_TYPE_PD_DRP,		/* PD Dual Role Port */
200 	POWER_SUPPLY_USB_TYPE_PD_PPS,		/* PD Programmable Power Supply */
201 	POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID,	/* Apple Charging Method */
202 };
203 
204 enum power_supply_notifier_events {
205 	PSY_EVENT_PROP_CHANGED,
206 };
207 
208 union power_supply_propval {
209 	int intval;
210 	const char *strval;
211 };
212 
213 struct device_node;
214 struct power_supply;
215 
216 /* Run-time specific power supply configuration */
217 struct power_supply_config {
218 	struct device_node *of_node;
219 	struct fwnode_handle *fwnode;
220 
221 	/* Driver private data */
222 	void *drv_data;
223 
224 	/* Device specific sysfs attributes */
225 	const struct attribute_group **attr_grp;
226 
227 	char **supplied_to;
228 	size_t num_supplicants;
229 };
230 
231 /* Description of power supply */
232 struct power_supply_desc {
233 	const char *name;
234 	enum power_supply_type type;
235 	const enum power_supply_usb_type *usb_types;
236 	size_t num_usb_types;
237 	const enum power_supply_property *properties;
238 	size_t num_properties;
239 
240 	/*
241 	 * Functions for drivers implementing power supply class.
242 	 * These shouldn't be called directly by other drivers for accessing
243 	 * this power supply. Instead use power_supply_*() functions (for
244 	 * example power_supply_get_property()).
245 	 */
246 	int (*get_property)(struct power_supply *psy,
247 			    enum power_supply_property psp,
248 			    union power_supply_propval *val);
249 	int (*set_property)(struct power_supply *psy,
250 			    enum power_supply_property psp,
251 			    const union power_supply_propval *val);
252 	/*
253 	 * property_is_writeable() will be called during registration
254 	 * of power supply. If this happens during device probe then it must
255 	 * not access internal data of device (because probe did not end).
256 	 */
257 	int (*property_is_writeable)(struct power_supply *psy,
258 				     enum power_supply_property psp);
259 	void (*external_power_changed)(struct power_supply *psy);
260 	void (*set_charged)(struct power_supply *psy);
261 
262 	/*
263 	 * Set if thermal zone should not be created for this power supply.
264 	 * For example for virtual supplies forwarding calls to actual
265 	 * sensors or other supplies.
266 	 */
267 	bool no_thermal;
268 	/* For APM emulation, think legacy userspace. */
269 	int use_for_apm;
270 };
271 
272 struct power_supply {
273 	const struct power_supply_desc *desc;
274 
275 	char **supplied_to;
276 	size_t num_supplicants;
277 
278 	char **supplied_from;
279 	size_t num_supplies;
280 	struct device_node *of_node;
281 
282 	/* Driver private data */
283 	void *drv_data;
284 
285 	/* private */
286 	struct device dev;
287 	struct work_struct changed_work;
288 	struct delayed_work deferred_register_work;
289 	spinlock_t changed_lock;
290 	bool changed;
291 	bool initialized;
292 	bool removing;
293 	atomic_t use_cnt;
294 #ifdef CONFIG_THERMAL
295 	struct thermal_zone_device *tzd;
296 	struct thermal_cooling_device *tcd;
297 #endif
298 
299 #ifdef CONFIG_LEDS_TRIGGERS
300 	struct led_trigger *charging_full_trig;
301 	char *charging_full_trig_name;
302 	struct led_trigger *charging_trig;
303 	char *charging_trig_name;
304 	struct led_trigger *full_trig;
305 	char *full_trig_name;
306 	struct led_trigger *online_trig;
307 	char *online_trig_name;
308 	struct led_trigger *charging_blink_full_solid_trig;
309 	char *charging_blink_full_solid_trig_name;
310 #endif
311 };
312 
313 /*
314  * This is recommended structure to specify static power supply parameters.
315  * Generic one, parametrizable for different power supplies. Power supply
316  * class itself does not use it, but that's what implementing most platform
317  * drivers, should try reuse for consistency.
318  */
319 
320 struct power_supply_info {
321 	const char *name;
322 	int technology;
323 	int voltage_max_design;
324 	int voltage_min_design;
325 	int charge_full_design;
326 	int charge_empty_design;
327 	int energy_full_design;
328 	int energy_empty_design;
329 	int use_for_apm;
330 };
331 
332 struct power_supply_battery_ocv_table {
333 	int ocv;	/* microVolts */
334 	int capacity;	/* percent */
335 };
336 
337 struct power_supply_resistance_temp_table {
338 	int temp;	/* celsius */
339 	int resistance;	/* internal resistance percent */
340 };
341 
342 #define POWER_SUPPLY_OCV_TEMP_MAX 20
343 
344 /*
345  * This is the recommended struct to manage static battery parameters,
346  * populated by power_supply_get_battery_info(). Most platform drivers should
347  * use these for consistency.
348  * Its field names must correspond to elements in enum power_supply_property.
349  * The default field value is -EINVAL.
350  * Power supply class itself doesn't use this.
351  */
352 
353 struct power_supply_battery_info {
354 	int energy_full_design_uwh;	    /* microWatt-hours */
355 	int charge_full_design_uah;	    /* microAmp-hours */
356 	int voltage_min_design_uv;	    /* microVolts */
357 	int voltage_max_design_uv;	    /* microVolts */
358 	int tricklecharge_current_ua;	    /* microAmps */
359 	int precharge_current_ua;	    /* microAmps */
360 	int precharge_voltage_max_uv;	    /* microVolts */
361 	int charge_term_current_ua;	    /* microAmps */
362 	int charge_restart_voltage_uv;	    /* microVolts */
363 	int overvoltage_limit_uv;	    /* microVolts */
364 	int constant_charge_current_max_ua; /* microAmps */
365 	int constant_charge_voltage_max_uv; /* microVolts */
366 	int factory_internal_resistance_uohm;   /* microOhms */
367 	int ocv_temp[POWER_SUPPLY_OCV_TEMP_MAX];/* celsius */
368 	struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX];
369 	int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX];
370 	struct power_supply_resistance_temp_table *resist_table;
371 	int resist_table_size;
372 };
373 
374 extern struct atomic_notifier_head power_supply_notifier;
375 extern int power_supply_reg_notifier(struct notifier_block *nb);
376 extern void power_supply_unreg_notifier(struct notifier_block *nb);
377 extern struct power_supply *power_supply_get_by_name(const char *name);
378 extern void power_supply_put(struct power_supply *psy);
379 #ifdef CONFIG_OF
380 extern struct power_supply *power_supply_get_by_phandle(struct device_node *np,
381 							const char *property);
382 extern struct power_supply *devm_power_supply_get_by_phandle(
383 				    struct device *dev, const char *property);
384 #else /* !CONFIG_OF */
385 static inline struct power_supply *
386 power_supply_get_by_phandle(struct device_node *np, const char *property)
387 { return NULL; }
388 static inline struct power_supply *
389 devm_power_supply_get_by_phandle(struct device *dev, const char *property)
390 { return NULL; }
391 #endif /* CONFIG_OF */
392 
393 extern int power_supply_get_battery_info(struct power_supply *psy,
394 					 struct power_supply_battery_info *info);
395 extern void power_supply_put_battery_info(struct power_supply *psy,
396 					  struct power_supply_battery_info *info);
397 extern int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table,
398 				       int table_len, int ocv);
399 extern struct power_supply_battery_ocv_table *
400 power_supply_find_ocv2cap_table(struct power_supply_battery_info *info,
401 				int temp, int *table_len);
402 extern int power_supply_batinfo_ocv2cap(struct power_supply_battery_info *info,
403 					int ocv, int temp);
404 extern int
405 power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *table,
406 				int table_len, int temp);
407 extern void power_supply_changed(struct power_supply *psy);
408 extern int power_supply_am_i_supplied(struct power_supply *psy);
409 extern int power_supply_set_input_current_limit_from_supplier(
410 					 struct power_supply *psy);
411 extern int power_supply_set_battery_charged(struct power_supply *psy);
412 
413 #ifdef CONFIG_POWER_SUPPLY
414 extern int power_supply_is_system_supplied(void);
415 #else
416 static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
417 #endif
418 
419 extern int power_supply_get_property(struct power_supply *psy,
420 			    enum power_supply_property psp,
421 			    union power_supply_propval *val);
422 extern int power_supply_set_property(struct power_supply *psy,
423 			    enum power_supply_property psp,
424 			    const union power_supply_propval *val);
425 extern int power_supply_property_is_writeable(struct power_supply *psy,
426 					enum power_supply_property psp);
427 extern void power_supply_external_power_changed(struct power_supply *psy);
428 
429 extern struct power_supply *__must_check
430 power_supply_register(struct device *parent,
431 				 const struct power_supply_desc *desc,
432 				 const struct power_supply_config *cfg);
433 extern struct power_supply *__must_check
434 power_supply_register_no_ws(struct device *parent,
435 				 const struct power_supply_desc *desc,
436 				 const struct power_supply_config *cfg);
437 extern struct power_supply *__must_check
438 devm_power_supply_register(struct device *parent,
439 				 const struct power_supply_desc *desc,
440 				 const struct power_supply_config *cfg);
441 extern struct power_supply *__must_check
442 devm_power_supply_register_no_ws(struct device *parent,
443 				 const struct power_supply_desc *desc,
444 				 const struct power_supply_config *cfg);
445 extern void power_supply_unregister(struct power_supply *psy);
446 extern int power_supply_powers(struct power_supply *psy, struct device *dev);
447 
448 #define to_power_supply(device) container_of(device, struct power_supply, dev)
449 
450 extern void *power_supply_get_drvdata(struct power_supply *psy);
451 /* For APM emulation, think legacy userspace. */
452 extern struct class *power_supply_class;
453 
454 static inline bool power_supply_is_amp_property(enum power_supply_property psp)
455 {
456 	switch (psp) {
457 	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
458 	case POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN:
459 	case POWER_SUPPLY_PROP_CHARGE_FULL:
460 	case POWER_SUPPLY_PROP_CHARGE_EMPTY:
461 	case POWER_SUPPLY_PROP_CHARGE_NOW:
462 	case POWER_SUPPLY_PROP_CHARGE_AVG:
463 	case POWER_SUPPLY_PROP_CHARGE_COUNTER:
464 	case POWER_SUPPLY_PROP_PRECHARGE_CURRENT:
465 	case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
466 	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
467 	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
468 	case POWER_SUPPLY_PROP_CURRENT_MAX:
469 	case POWER_SUPPLY_PROP_CURRENT_NOW:
470 	case POWER_SUPPLY_PROP_CURRENT_AVG:
471 	case POWER_SUPPLY_PROP_CURRENT_BOOT:
472 		return 1;
473 	default:
474 		break;
475 	}
476 
477 	return 0;
478 }
479 
480 static inline bool power_supply_is_watt_property(enum power_supply_property psp)
481 {
482 	switch (psp) {
483 	case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
484 	case POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN:
485 	case POWER_SUPPLY_PROP_ENERGY_FULL:
486 	case POWER_SUPPLY_PROP_ENERGY_EMPTY:
487 	case POWER_SUPPLY_PROP_ENERGY_NOW:
488 	case POWER_SUPPLY_PROP_ENERGY_AVG:
489 	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
490 	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
491 	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
492 	case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
493 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
494 	case POWER_SUPPLY_PROP_VOLTAGE_AVG:
495 	case POWER_SUPPLY_PROP_VOLTAGE_OCV:
496 	case POWER_SUPPLY_PROP_VOLTAGE_BOOT:
497 	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
498 	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
499 	case POWER_SUPPLY_PROP_POWER_NOW:
500 		return 1;
501 	default:
502 		break;
503 	}
504 
505 	return 0;
506 }
507 
508 #ifdef CONFIG_POWER_SUPPLY_HWMON
509 int power_supply_add_hwmon_sysfs(struct power_supply *psy);
510 void power_supply_remove_hwmon_sysfs(struct power_supply *psy);
511 #else
512 static inline int power_supply_add_hwmon_sysfs(struct power_supply *psy)
513 {
514 	return 0;
515 }
516 
517 static inline
518 void power_supply_remove_hwmon_sysfs(struct power_supply *psy) {}
519 #endif
520 
521 #endif /* __LINUX_POWER_SUPPLY_H__ */
522