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 POWER_SUPPLY_TYPE_WIRELESS, /* Wireless */ 190 }; 191 192 enum power_supply_usb_type { 193 POWER_SUPPLY_USB_TYPE_UNKNOWN = 0, 194 POWER_SUPPLY_USB_TYPE_SDP, /* Standard Downstream Port */ 195 POWER_SUPPLY_USB_TYPE_DCP, /* Dedicated Charging Port */ 196 POWER_SUPPLY_USB_TYPE_CDP, /* Charging Downstream Port */ 197 POWER_SUPPLY_USB_TYPE_ACA, /* Accessory Charger Adapters */ 198 POWER_SUPPLY_USB_TYPE_C, /* Type C Port */ 199 POWER_SUPPLY_USB_TYPE_PD, /* Power Delivery Port */ 200 POWER_SUPPLY_USB_TYPE_PD_DRP, /* PD Dual Role Port */ 201 POWER_SUPPLY_USB_TYPE_PD_PPS, /* PD Programmable Power Supply */ 202 POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */ 203 }; 204 205 enum power_supply_notifier_events { 206 PSY_EVENT_PROP_CHANGED, 207 }; 208 209 union power_supply_propval { 210 int intval; 211 const char *strval; 212 }; 213 214 struct device_node; 215 struct power_supply; 216 217 /* Run-time specific power supply configuration */ 218 struct power_supply_config { 219 struct device_node *of_node; 220 struct fwnode_handle *fwnode; 221 222 /* Driver private data */ 223 void *drv_data; 224 225 /* Device specific sysfs attributes */ 226 const struct attribute_group **attr_grp; 227 228 char **supplied_to; 229 size_t num_supplicants; 230 }; 231 232 /* Description of power supply */ 233 struct power_supply_desc { 234 const char *name; 235 enum power_supply_type type; 236 const enum power_supply_usb_type *usb_types; 237 size_t num_usb_types; 238 const enum power_supply_property *properties; 239 size_t num_properties; 240 241 /* 242 * Functions for drivers implementing power supply class. 243 * These shouldn't be called directly by other drivers for accessing 244 * this power supply. Instead use power_supply_*() functions (for 245 * example power_supply_get_property()). 246 */ 247 int (*get_property)(struct power_supply *psy, 248 enum power_supply_property psp, 249 union power_supply_propval *val); 250 int (*set_property)(struct power_supply *psy, 251 enum power_supply_property psp, 252 const union power_supply_propval *val); 253 /* 254 * property_is_writeable() will be called during registration 255 * of power supply. If this happens during device probe then it must 256 * not access internal data of device (because probe did not end). 257 */ 258 int (*property_is_writeable)(struct power_supply *psy, 259 enum power_supply_property psp); 260 void (*external_power_changed)(struct power_supply *psy); 261 void (*set_charged)(struct power_supply *psy); 262 263 /* 264 * Set if thermal zone should not be created for this power supply. 265 * For example for virtual supplies forwarding calls to actual 266 * sensors or other supplies. 267 */ 268 bool no_thermal; 269 /* For APM emulation, think legacy userspace. */ 270 int use_for_apm; 271 }; 272 273 struct power_supply { 274 const struct power_supply_desc *desc; 275 276 char **supplied_to; 277 size_t num_supplicants; 278 279 char **supplied_from; 280 size_t num_supplies; 281 struct device_node *of_node; 282 283 /* Driver private data */ 284 void *drv_data; 285 286 /* private */ 287 struct device dev; 288 struct work_struct changed_work; 289 struct delayed_work deferred_register_work; 290 spinlock_t changed_lock; 291 bool changed; 292 bool initialized; 293 bool removing; 294 atomic_t use_cnt; 295 #ifdef CONFIG_THERMAL 296 struct thermal_zone_device *tzd; 297 struct thermal_cooling_device *tcd; 298 #endif 299 300 #ifdef CONFIG_LEDS_TRIGGERS 301 struct led_trigger *charging_full_trig; 302 char *charging_full_trig_name; 303 struct led_trigger *charging_trig; 304 char *charging_trig_name; 305 struct led_trigger *full_trig; 306 char *full_trig_name; 307 struct led_trigger *online_trig; 308 char *online_trig_name; 309 struct led_trigger *charging_blink_full_solid_trig; 310 char *charging_blink_full_solid_trig_name; 311 #endif 312 }; 313 314 /* 315 * This is recommended structure to specify static power supply parameters. 316 * Generic one, parametrizable for different power supplies. Power supply 317 * class itself does not use it, but that's what implementing most platform 318 * drivers, should try reuse for consistency. 319 */ 320 321 struct power_supply_info { 322 const char *name; 323 int technology; 324 int voltage_max_design; 325 int voltage_min_design; 326 int charge_full_design; 327 int charge_empty_design; 328 int energy_full_design; 329 int energy_empty_design; 330 int use_for_apm; 331 }; 332 333 struct power_supply_battery_ocv_table { 334 int ocv; /* microVolts */ 335 int capacity; /* percent */ 336 }; 337 338 struct power_supply_resistance_temp_table { 339 int temp; /* celsius */ 340 int resistance; /* internal resistance percent */ 341 }; 342 343 #define POWER_SUPPLY_OCV_TEMP_MAX 20 344 345 /* 346 * This is the recommended struct to manage static battery parameters, 347 * populated by power_supply_get_battery_info(). Most platform drivers should 348 * use these for consistency. 349 * Its field names must correspond to elements in enum power_supply_property. 350 * The default field value is -EINVAL. 351 * Power supply class itself doesn't use this. 352 */ 353 354 struct power_supply_battery_info { 355 int energy_full_design_uwh; /* microWatt-hours */ 356 int charge_full_design_uah; /* microAmp-hours */ 357 int voltage_min_design_uv; /* microVolts */ 358 int voltage_max_design_uv; /* microVolts */ 359 int tricklecharge_current_ua; /* microAmps */ 360 int precharge_current_ua; /* microAmps */ 361 int precharge_voltage_max_uv; /* microVolts */ 362 int charge_term_current_ua; /* microAmps */ 363 int charge_restart_voltage_uv; /* microVolts */ 364 int overvoltage_limit_uv; /* microVolts */ 365 int constant_charge_current_max_ua; /* microAmps */ 366 int constant_charge_voltage_max_uv; /* microVolts */ 367 int factory_internal_resistance_uohm; /* microOhms */ 368 int ocv_temp[POWER_SUPPLY_OCV_TEMP_MAX];/* celsius */ 369 int temp_ambient_alert_min; /* celsius */ 370 int temp_ambient_alert_max; /* celsius */ 371 int temp_alert_min; /* celsius */ 372 int temp_alert_max; /* celsius */ 373 int temp_min; /* celsius */ 374 int temp_max; /* celsius */ 375 struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX]; 376 int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX]; 377 struct power_supply_resistance_temp_table *resist_table; 378 int resist_table_size; 379 }; 380 381 extern struct atomic_notifier_head power_supply_notifier; 382 extern int power_supply_reg_notifier(struct notifier_block *nb); 383 extern void power_supply_unreg_notifier(struct notifier_block *nb); 384 extern struct power_supply *power_supply_get_by_name(const char *name); 385 extern void power_supply_put(struct power_supply *psy); 386 #ifdef CONFIG_OF 387 extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, 388 const char *property); 389 extern struct power_supply *devm_power_supply_get_by_phandle( 390 struct device *dev, const char *property); 391 #else /* !CONFIG_OF */ 392 static inline struct power_supply * 393 power_supply_get_by_phandle(struct device_node *np, const char *property) 394 { return NULL; } 395 static inline struct power_supply * 396 devm_power_supply_get_by_phandle(struct device *dev, const char *property) 397 { return NULL; } 398 #endif /* CONFIG_OF */ 399 400 extern int power_supply_get_battery_info(struct power_supply *psy, 401 struct power_supply_battery_info *info); 402 extern void power_supply_put_battery_info(struct power_supply *psy, 403 struct power_supply_battery_info *info); 404 extern int power_supply_ocv2cap_simple(struct power_supply_battery_ocv_table *table, 405 int table_len, int ocv); 406 extern struct power_supply_battery_ocv_table * 407 power_supply_find_ocv2cap_table(struct power_supply_battery_info *info, 408 int temp, int *table_len); 409 extern int power_supply_batinfo_ocv2cap(struct power_supply_battery_info *info, 410 int ocv, int temp); 411 extern int 412 power_supply_temp2resist_simple(struct power_supply_resistance_temp_table *table, 413 int table_len, int temp); 414 extern void power_supply_changed(struct power_supply *psy); 415 extern int power_supply_am_i_supplied(struct power_supply *psy); 416 extern int power_supply_set_input_current_limit_from_supplier( 417 struct power_supply *psy); 418 extern int power_supply_set_battery_charged(struct power_supply *psy); 419 420 #ifdef CONFIG_POWER_SUPPLY 421 extern int power_supply_is_system_supplied(void); 422 #else 423 static inline int power_supply_is_system_supplied(void) { return -ENOSYS; } 424 #endif 425 426 extern int power_supply_get_property(struct power_supply *psy, 427 enum power_supply_property psp, 428 union power_supply_propval *val); 429 extern int power_supply_set_property(struct power_supply *psy, 430 enum power_supply_property psp, 431 const union power_supply_propval *val); 432 extern int power_supply_property_is_writeable(struct power_supply *psy, 433 enum power_supply_property psp); 434 extern void power_supply_external_power_changed(struct power_supply *psy); 435 436 extern struct power_supply *__must_check 437 power_supply_register(struct device *parent, 438 const struct power_supply_desc *desc, 439 const struct power_supply_config *cfg); 440 extern struct power_supply *__must_check 441 power_supply_register_no_ws(struct device *parent, 442 const struct power_supply_desc *desc, 443 const struct power_supply_config *cfg); 444 extern struct power_supply *__must_check 445 devm_power_supply_register(struct device *parent, 446 const struct power_supply_desc *desc, 447 const struct power_supply_config *cfg); 448 extern struct power_supply *__must_check 449 devm_power_supply_register_no_ws(struct device *parent, 450 const struct power_supply_desc *desc, 451 const struct power_supply_config *cfg); 452 extern void power_supply_unregister(struct power_supply *psy); 453 extern int power_supply_powers(struct power_supply *psy, struct device *dev); 454 455 #define to_power_supply(device) container_of(device, struct power_supply, dev) 456 457 extern void *power_supply_get_drvdata(struct power_supply *psy); 458 /* For APM emulation, think legacy userspace. */ 459 extern struct class *power_supply_class; 460 461 static inline bool power_supply_is_amp_property(enum power_supply_property psp) 462 { 463 switch (psp) { 464 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 465 case POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN: 466 case POWER_SUPPLY_PROP_CHARGE_FULL: 467 case POWER_SUPPLY_PROP_CHARGE_EMPTY: 468 case POWER_SUPPLY_PROP_CHARGE_NOW: 469 case POWER_SUPPLY_PROP_CHARGE_AVG: 470 case POWER_SUPPLY_PROP_CHARGE_COUNTER: 471 case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: 472 case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: 473 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: 474 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: 475 case POWER_SUPPLY_PROP_CURRENT_MAX: 476 case POWER_SUPPLY_PROP_CURRENT_NOW: 477 case POWER_SUPPLY_PROP_CURRENT_AVG: 478 case POWER_SUPPLY_PROP_CURRENT_BOOT: 479 return 1; 480 default: 481 break; 482 } 483 484 return 0; 485 } 486 487 static inline bool power_supply_is_watt_property(enum power_supply_property psp) 488 { 489 switch (psp) { 490 case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: 491 case POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN: 492 case POWER_SUPPLY_PROP_ENERGY_FULL: 493 case POWER_SUPPLY_PROP_ENERGY_EMPTY: 494 case POWER_SUPPLY_PROP_ENERGY_NOW: 495 case POWER_SUPPLY_PROP_ENERGY_AVG: 496 case POWER_SUPPLY_PROP_VOLTAGE_MAX: 497 case POWER_SUPPLY_PROP_VOLTAGE_MIN: 498 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: 499 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 500 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 501 case POWER_SUPPLY_PROP_VOLTAGE_AVG: 502 case POWER_SUPPLY_PROP_VOLTAGE_OCV: 503 case POWER_SUPPLY_PROP_VOLTAGE_BOOT: 504 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 505 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: 506 case POWER_SUPPLY_PROP_POWER_NOW: 507 return 1; 508 default: 509 break; 510 } 511 512 return 0; 513 } 514 515 #ifdef CONFIG_POWER_SUPPLY_HWMON 516 int power_supply_add_hwmon_sysfs(struct power_supply *psy); 517 void power_supply_remove_hwmon_sysfs(struct power_supply *psy); 518 #else 519 static inline int power_supply_add_hwmon_sysfs(struct power_supply *psy) 520 { 521 return 0; 522 } 523 524 static inline 525 void power_supply_remove_hwmon_sysfs(struct power_supply *psy) {} 526 #endif 527 528 #endif /* __LINUX_POWER_SUPPLY_H__ */ 529