2007-05-03 22:27:45 +02:00
|
|
|
/*
|
|
|
|
* Universal power supply monitor class
|
|
|
|
*
|
|
|
|
* Copyright © 2007 Anton Vorontsov <cbou@mail.ru>
|
|
|
|
* Copyright © 2004 Szabolcs Gyurko
|
|
|
|
* Copyright © 2003 Ian Molton <spyro@f2s.com>
|
|
|
|
*
|
|
|
|
* Modified: 2004, Oct Szabolcs Gyurko
|
|
|
|
*
|
|
|
|
* You may use this code as per GPL version 2
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_POWER_SUPPLY_H__
|
|
|
|
#define __LINUX_POWER_SUPPLY_H__
|
|
|
|
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/leds.h>
|
2013-12-13 00:59:09 +01:00
|
|
|
#include <linux/types.h>
|
2007-05-03 22:27:45 +02:00
|
|
|
|
2012-01-30 17:46:54 +01:00
|
|
|
struct device;
|
|
|
|
|
2007-05-03 22:27:45 +02:00
|
|
|
/*
|
|
|
|
* All voltages, currents, charges, energies, time and temperatures in uV,
|
|
|
|
* µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
|
|
|
|
* stated. It's driver's job to convert its raw values to units in which
|
|
|
|
* this class operates.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For systems where the charger determines the maximum battery capacity
|
|
|
|
* the min and max fields should be used to present these values to user
|
|
|
|
* space. Unused/unknown fields will not appear in sysfs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum {
|
|
|
|
POWER_SUPPLY_STATUS_UNKNOWN = 0,
|
|
|
|
POWER_SUPPLY_STATUS_CHARGING,
|
|
|
|
POWER_SUPPLY_STATUS_DISCHARGING,
|
|
|
|
POWER_SUPPLY_STATUS_NOT_CHARGING,
|
|
|
|
POWER_SUPPLY_STATUS_FULL,
|
|
|
|
};
|
|
|
|
|
2009-07-02 15:45:18 +02:00
|
|
|
enum {
|
|
|
|
POWER_SUPPLY_CHARGE_TYPE_UNKNOWN = 0,
|
|
|
|
POWER_SUPPLY_CHARGE_TYPE_NONE,
|
|
|
|
POWER_SUPPLY_CHARGE_TYPE_TRICKLE,
|
|
|
|
POWER_SUPPLY_CHARGE_TYPE_FAST,
|
2014-03-31 12:09:45 +02:00
|
|
|
POWER_SUPPLY_CHARGE_TYPE_TAPER,
|
2009-07-02 15:45:18 +02:00
|
|
|
};
|
|
|
|
|
2007-05-03 22:27:45 +02:00
|
|
|
enum {
|
|
|
|
POWER_SUPPLY_HEALTH_UNKNOWN = 0,
|
|
|
|
POWER_SUPPLY_HEALTH_GOOD,
|
|
|
|
POWER_SUPPLY_HEALTH_OVERHEAT,
|
2013-06-10 20:09:11 +02:00
|
|
|
POWER_SUPPLY_HEALTH_WARM,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_HEALTH_DEAD,
|
|
|
|
POWER_SUPPLY_HEALTH_OVERVOLTAGE,
|
|
|
|
POWER_SUPPLY_HEALTH_UNSPEC_FAILURE,
|
2008-11-30 22:43:21 +01:00
|
|
|
POWER_SUPPLY_HEALTH_COLD,
|
2013-06-10 20:09:11 +02:00
|
|
|
POWER_SUPPLY_HEALTH_COOL,
|
2012-11-30 09:27:46 +01:00
|
|
|
POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE,
|
|
|
|
POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE,
|
2007-05-03 22:27:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0,
|
|
|
|
POWER_SUPPLY_TECHNOLOGY_NiMH,
|
|
|
|
POWER_SUPPLY_TECHNOLOGY_LION,
|
|
|
|
POWER_SUPPLY_TECHNOLOGY_LIPO,
|
|
|
|
POWER_SUPPLY_TECHNOLOGY_LiFe,
|
|
|
|
POWER_SUPPLY_TECHNOLOGY_NiCd,
|
2008-01-07 02:12:41 +01:00
|
|
|
POWER_SUPPLY_TECHNOLOGY_LiMn,
|
2007-05-03 22:27:45 +02:00
|
|
|
};
|
|
|
|
|
2009-06-30 08:13:01 +02:00
|
|
|
enum {
|
|
|
|
POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0,
|
|
|
|
POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL,
|
|
|
|
POWER_SUPPLY_CAPACITY_LEVEL_LOW,
|
|
|
|
POWER_SUPPLY_CAPACITY_LEVEL_NORMAL,
|
|
|
|
POWER_SUPPLY_CAPACITY_LEVEL_HIGH,
|
|
|
|
POWER_SUPPLY_CAPACITY_LEVEL_FULL,
|
|
|
|
};
|
|
|
|
|
2011-12-07 20:24:20 +01:00
|
|
|
enum {
|
|
|
|
POWER_SUPPLY_SCOPE_UNKNOWN = 0,
|
|
|
|
POWER_SUPPLY_SCOPE_SYSTEM,
|
|
|
|
POWER_SUPPLY_SCOPE_DEVICE,
|
|
|
|
};
|
|
|
|
|
2007-05-03 22:27:45 +02:00
|
|
|
enum power_supply_property {
|
|
|
|
/* Properties of type `int' */
|
|
|
|
POWER_SUPPLY_PROP_STATUS = 0,
|
2009-07-02 15:45:18 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_TYPE,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_HEALTH,
|
|
|
|
POWER_SUPPLY_PROP_PRESENT,
|
|
|
|
POWER_SUPPLY_PROP_ONLINE,
|
2012-08-23 03:20:21 +02:00
|
|
|
POWER_SUPPLY_PROP_AUTHENTIC,
|
2015-01-13 19:14:17 +01:00
|
|
|
POWER_SUPPLY_PROP_BATTERY_CHARGING_ENABLED,
|
2012-10-15 19:41:16 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGING_ENABLED,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_TECHNOLOGY,
|
2009-10-15 12:31:30 +02:00
|
|
|
POWER_SUPPLY_PROP_CYCLE_COUNT,
|
2008-01-07 02:12:41 +01:00
|
|
|
POWER_SUPPLY_PROP_VOLTAGE_MAX,
|
|
|
|
POWER_SUPPLY_PROP_VOLTAGE_MIN,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
|
|
|
|
POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
|
|
|
|
POWER_SUPPLY_PROP_VOLTAGE_NOW,
|
|
|
|
POWER_SUPPLY_PROP_VOLTAGE_AVG,
|
2012-04-10 12:51:20 +02:00
|
|
|
POWER_SUPPLY_PROP_VOLTAGE_OCV,
|
2013-07-16 06:42:58 +02:00
|
|
|
POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION,
|
2010-10-04 09:51:38 +02:00
|
|
|
POWER_SUPPLY_PROP_CURRENT_MAX,
|
2013-07-16 06:42:58 +02:00
|
|
|
POWER_SUPPLY_PROP_INPUT_CURRENT_MAX,
|
2013-08-20 19:02:26 +02:00
|
|
|
POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM,
|
2013-10-22 02:14:25 +02:00
|
|
|
POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED,
|
2014-08-22 07:47:34 +02:00
|
|
|
POWER_SUPPLY_PROP_VCHG_LOOP_DBC_BYPASS,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_CURRENT_NOW,
|
|
|
|
POWER_SUPPLY_PROP_CURRENT_AVG,
|
2009-03-28 03:23:52 +01:00
|
|
|
POWER_SUPPLY_PROP_POWER_NOW,
|
|
|
|
POWER_SUPPLY_PROP_POWER_AVG,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
|
|
|
|
POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN,
|
|
|
|
POWER_SUPPLY_PROP_CHARGE_FULL,
|
|
|
|
POWER_SUPPLY_PROP_CHARGE_EMPTY,
|
|
|
|
POWER_SUPPLY_PROP_CHARGE_NOW,
|
2015-03-31 00:03:46 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_NOW_RAW,
|
|
|
|
POWER_SUPPLY_PROP_CHARGE_NOW_ERROR,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_AVG,
|
2008-05-13 03:46:29 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_COUNTER,
|
2013-05-03 00:54:27 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_COUNTER_SHADOW,
|
2012-05-06 14:46:44 +02:00
|
|
|
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
|
2012-07-30 09:19:21 +02:00
|
|
|
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
|
2012-05-06 14:46:44 +02:00
|
|
|
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
|
2012-07-30 09:19:21 +02:00
|
|
|
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
|
2012-10-09 18:55:29 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
|
|
|
|
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
|
|
|
|
POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN,
|
|
|
|
POWER_SUPPLY_PROP_ENERGY_FULL,
|
|
|
|
POWER_SUPPLY_PROP_ENERGY_EMPTY,
|
|
|
|
POWER_SUPPLY_PROP_ENERGY_NOW,
|
|
|
|
POWER_SUPPLY_PROP_ENERGY_AVG,
|
2014-04-30 15:11:31 +02:00
|
|
|
POWER_SUPPLY_PROP_HI_POWER,
|
|
|
|
POWER_SUPPLY_PROP_LOW_POWER,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_CAPACITY, /* in percents! */
|
2012-07-05 13:29:12 +02:00
|
|
|
POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, /* in percents! */
|
|
|
|
POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX, /* in percents! */
|
2009-06-30 08:13:01 +02:00
|
|
|
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
|
2015-03-31 00:03:46 +02:00
|
|
|
POWER_SUPPLY_PROP_CAPACITY_RAW,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_TEMP,
|
2012-07-05 13:29:12 +02:00
|
|
|
POWER_SUPPLY_PROP_TEMP_ALERT_MIN,
|
|
|
|
POWER_SUPPLY_PROP_TEMP_ALERT_MAX,
|
2013-06-13 22:05:30 +02:00
|
|
|
POWER_SUPPLY_PROP_COOL_TEMP,
|
|
|
|
POWER_SUPPLY_PROP_WARM_TEMP,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_TEMP_AMBIENT,
|
2012-07-05 13:29:12 +02:00
|
|
|
POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN,
|
|
|
|
POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
|
|
|
|
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
|
|
|
|
POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
|
|
|
|
POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
|
2010-05-18 21:49:51 +02:00
|
|
|
POWER_SUPPLY_PROP_TYPE, /* use power_supply.type instead */
|
2011-12-07 20:24:20 +01:00
|
|
|
POWER_SUPPLY_PROP_SCOPE,
|
2013-01-31 23:49:25 +01:00
|
|
|
POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL,
|
2013-05-03 00:54:27 +02:00
|
|
|
POWER_SUPPLY_PROP_RESISTANCE,
|
2014-01-30 07:11:29 +01:00
|
|
|
POWER_SUPPLY_PROP_RESISTANCE_CAPACITIVE,
|
2014-07-23 03:33:20 +02:00
|
|
|
/* unit is in ohms due to ID being typically in kohm range */
|
|
|
|
POWER_SUPPLY_PROP_RESISTANCE_ID,
|
2015-02-05 09:59:54 +01:00
|
|
|
POWER_SUPPLY_PROP_RESISTANCE_NOW,
|
2012-07-13 05:27:16 +02:00
|
|
|
/* Local extensions */
|
|
|
|
POWER_SUPPLY_PROP_USB_HC,
|
2012-07-13 22:30:04 +02:00
|
|
|
POWER_SUPPLY_PROP_USB_OTG,
|
2012-07-19 01:28:50 +02:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_ENABLED,
|
2014-08-01 00:04:04 +02:00
|
|
|
POWER_SUPPLY_PROP_FLASH_CURRENT_MAX,
|
2014-10-09 21:34:49 +02:00
|
|
|
POWER_SUPPLY_PROP_UPDATE_NOW,
|
2014-11-04 16:17:15 +01:00
|
|
|
POWER_SUPPLY_PROP_ESR_COUNT,
|
2015-01-08 04:55:52 +01:00
|
|
|
POWER_SUPPLY_PROP_SAFETY_TIMER_ENABLE,
|
2015-03-06 00:40:56 +01:00
|
|
|
POWER_SUPPLY_PROP_CHARGE_DONE,
|
2015-03-18 23:51:38 +01:00
|
|
|
POWER_SUPPLY_PROP_FLASH_ACTIVE,
|
2015-08-08 00:49:24 +02:00
|
|
|
POWER_SUPPLY_PROP_FORCE_TLIM,
|
2015-03-13 20:58:47 +01:00
|
|
|
POWER_SUPPLY_PROP_ALLOW_DETECTION,
|
2015-06-17 04:46:04 +02:00
|
|
|
POWER_SUPPLY_PROP_CYCLE_COUNT_ID,
|
2013-12-13 00:59:09 +01:00
|
|
|
/* Local extensions of type int64_t */
|
|
|
|
POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT,
|
2007-05-03 22:27:45 +02:00
|
|
|
/* Properties of type `const char *' */
|
|
|
|
POWER_SUPPLY_PROP_MODEL_NAME,
|
|
|
|
POWER_SUPPLY_PROP_MANUFACTURER,
|
2008-01-22 18:46:50 +01:00
|
|
|
POWER_SUPPLY_PROP_SERIAL_NUMBER,
|
2013-12-20 14:21:50 +01:00
|
|
|
POWER_SUPPLY_PROP_BATTERY_TYPE,
|
2007-05-03 22:27:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum power_supply_type {
|
2011-12-01 08:08:33 +01:00
|
|
|
POWER_SUPPLY_TYPE_UNKNOWN = 0,
|
|
|
|
POWER_SUPPLY_TYPE_BATTERY,
|
2007-05-03 22:27:45 +02:00
|
|
|
POWER_SUPPLY_TYPE_UPS,
|
|
|
|
POWER_SUPPLY_TYPE_MAINS,
|
2010-10-04 09:51:37 +02:00
|
|
|
POWER_SUPPLY_TYPE_USB, /* Standard Downstream Port */
|
|
|
|
POWER_SUPPLY_TYPE_USB_DCP, /* Dedicated Charging Port */
|
|
|
|
POWER_SUPPLY_TYPE_USB_CDP, /* Charging Downstream Port */
|
|
|
|
POWER_SUPPLY_TYPE_USB_ACA, /* Accessory Charger Adapters */
|
2015-01-07 19:48:36 +01:00
|
|
|
POWER_SUPPLY_TYPE_USB_HVDCP, /* High Voltage DCP */
|
2013-08-19 03:02:28 +02:00
|
|
|
POWER_SUPPLY_TYPE_WIRELESS, /* Accessory Charger Adapters */
|
2012-09-05 20:19:37 +02:00
|
|
|
POWER_SUPPLY_TYPE_BMS, /* Battery Monitor System */
|
2014-05-06 00:49:47 +02:00
|
|
|
POWER_SUPPLY_TYPE_USB_PARALLEL, /* USB Parallel Path */
|
2014-09-29 22:21:46 +02:00
|
|
|
POWER_SUPPLY_TYPE_WIPOWER, /* Wipower */
|
2007-05-03 22:27:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
union power_supply_propval {
|
|
|
|
int intval;
|
|
|
|
const char *strval;
|
2013-12-13 00:59:09 +01:00
|
|
|
int64_t int64val;
|
2007-05-03 22:27:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct power_supply {
|
|
|
|
const char *name;
|
|
|
|
enum power_supply_type type;
|
|
|
|
enum power_supply_property *properties;
|
|
|
|
size_t num_properties;
|
|
|
|
|
|
|
|
char **supplied_to;
|
|
|
|
size_t num_supplicants;
|
|
|
|
|
2013-04-01 23:45:54 +02:00
|
|
|
char **supplied_from;
|
|
|
|
size_t num_supplies;
|
2013-04-01 23:45:55 +02:00
|
|
|
#ifdef CONFIG_OF
|
|
|
|
struct device_node *of_node;
|
|
|
|
#endif
|
2013-04-01 23:45:54 +02:00
|
|
|
|
2007-05-03 22:27:45 +02:00
|
|
|
int (*get_property)(struct power_supply *psy,
|
|
|
|
enum power_supply_property psp,
|
|
|
|
union power_supply_propval *val);
|
2010-05-18 21:49:52 +02:00
|
|
|
int (*set_property)(struct power_supply *psy,
|
|
|
|
enum power_supply_property psp,
|
|
|
|
const union power_supply_propval *val);
|
|
|
|
int (*property_is_writeable)(struct power_supply *psy,
|
|
|
|
enum power_supply_property psp);
|
2007-05-03 22:27:45 +02:00
|
|
|
void (*external_power_changed)(struct power_supply *psy);
|
2009-07-23 20:35:53 +02:00
|
|
|
void (*set_charged)(struct power_supply *psy);
|
2007-05-03 22:27:45 +02:00
|
|
|
|
|
|
|
/* For APM emulation, think legacy userspace. */
|
|
|
|
int use_for_apm;
|
|
|
|
|
|
|
|
/* private */
|
|
|
|
struct device *dev;
|
|
|
|
struct work_struct changed_work;
|
2009-09-22 02:26:47 +02:00
|
|
|
spinlock_t changed_lock;
|
|
|
|
bool changed;
|
2012-05-09 17:06:47 +02:00
|
|
|
#ifdef CONFIG_THERMAL
|
|
|
|
struct thermal_zone_device *tzd;
|
2012-10-09 18:55:59 +02:00
|
|
|
struct thermal_cooling_device *tcd;
|
2012-05-09 17:06:47 +02:00
|
|
|
#endif
|
2007-05-03 22:27:45 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_LEDS_TRIGGERS
|
|
|
|
struct led_trigger *charging_full_trig;
|
|
|
|
char *charging_full_trig_name;
|
|
|
|
struct led_trigger *charging_trig;
|
|
|
|
char *charging_trig_name;
|
|
|
|
struct led_trigger *full_trig;
|
|
|
|
char *full_trig_name;
|
|
|
|
struct led_trigger *online_trig;
|
|
|
|
char *online_trig_name;
|
2011-01-07 17:28:17 +01:00
|
|
|
struct led_trigger *charging_blink_full_solid_trig;
|
|
|
|
char *charging_blink_full_solid_trig_name;
|
2007-05-03 22:27:45 +02:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is recommended structure to specify static power supply parameters.
|
|
|
|
* Generic one, parametrizable for different power supplies. Power supply
|
|
|
|
* class itself does not use it, but that's what implementing most platform
|
|
|
|
* drivers, should try reuse for consistency.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct power_supply_info {
|
|
|
|
const char *name;
|
|
|
|
int technology;
|
|
|
|
int voltage_max_design;
|
|
|
|
int voltage_min_design;
|
|
|
|
int charge_full_design;
|
|
|
|
int charge_empty_design;
|
|
|
|
int energy_full_design;
|
|
|
|
int energy_empty_design;
|
|
|
|
int use_for_apm;
|
|
|
|
};
|
|
|
|
|
2012-06-02 03:14:50 +02:00
|
|
|
#if defined(CONFIG_POWER_SUPPLY)
|
2013-02-01 20:40:17 +01:00
|
|
|
extern struct power_supply *power_supply_get_by_name(const char *name);
|
2007-05-03 22:27:45 +02:00
|
|
|
extern void power_supply_changed(struct power_supply *psy);
|
|
|
|
extern int power_supply_am_i_supplied(struct power_supply *psy);
|
2009-07-23 20:35:53 +02:00
|
|
|
extern int power_supply_set_battery_charged(struct power_supply *psy);
|
2011-11-07 00:52:52 +01:00
|
|
|
extern int power_supply_set_current_limit(struct power_supply *psy, int limit);
|
2014-04-01 00:00:36 +02:00
|
|
|
extern int power_supply_set_voltage_limit(struct power_supply *psy, int limit);
|
2012-01-11 20:59:41 +01:00
|
|
|
extern int power_supply_set_online(struct power_supply *psy, bool enable);
|
2013-09-09 13:15:06 +02:00
|
|
|
extern int power_supply_set_health_state(struct power_supply *psy, int health);
|
2012-08-18 01:25:24 +02:00
|
|
|
extern int power_supply_set_present(struct power_supply *psy, bool enable);
|
2012-06-26 20:19:17 +02:00
|
|
|
extern int power_supply_set_scope(struct power_supply *psy, int scope);
|
2014-05-15 22:42:37 +02:00
|
|
|
extern int power_supply_set_usb_otg(struct power_supply *psy, int otg);
|
2012-01-11 20:59:41 +01:00
|
|
|
extern int power_supply_set_charge_type(struct power_supply *psy, int type);
|
2012-06-02 03:14:50 +02:00
|
|
|
extern int power_supply_set_supply_type(struct power_supply *psy,
|
|
|
|
enum power_supply_type supply_type);
|
2014-04-30 15:11:31 +02:00
|
|
|
extern int power_supply_set_hi_power_state(struct power_supply *psy, int value);
|
|
|
|
extern int power_supply_set_low_power_state(struct power_supply *psy,
|
|
|
|
int value);
|
2015-03-13 20:58:47 +01:00
|
|
|
extern int power_supply_set_allow_detection(struct power_supply *psy,
|
|
|
|
int value);
|
2008-08-26 22:09:59 +02:00
|
|
|
extern int power_supply_is_system_supplied(void);
|
2012-09-26 06:37:03 +02:00
|
|
|
extern int power_supply_register(struct device *parent,
|
|
|
|
struct power_supply *psy);
|
|
|
|
extern void power_supply_unregister(struct power_supply *psy);
|
|
|
|
extern int power_supply_powers(struct power_supply *psy, struct device *dev);
|
2008-08-26 22:09:59 +02:00
|
|
|
#else
|
2012-06-02 03:14:50 +02:00
|
|
|
static inline struct power_supply *power_supply_get_by_name(char *name)
|
2012-09-26 06:37:03 +02:00
|
|
|
{ return NULL; }
|
|
|
|
static inline void power_supply_changed(struct power_supply *psy) { }
|
2012-06-02 03:14:50 +02:00
|
|
|
static inline int power_supply_am_i_supplied(struct power_supply *psy)
|
|
|
|
{ return -ENOSYS; }
|
|
|
|
static inline int power_supply_set_battery_charged(struct power_supply *psy)
|
|
|
|
{ return -ENOSYS; }
|
2014-04-01 00:00:36 +02:00
|
|
|
static inline int power_supply_set_voltage_limit(struct power_supply *psy,
|
|
|
|
int limit)
|
|
|
|
{ return -ENOSYS; }
|
2012-06-02 03:14:50 +02:00
|
|
|
static inline int power_supply_set_current_limit(struct power_supply *psy,
|
|
|
|
int limit)
|
|
|
|
{ return -ENOSYS; }
|
|
|
|
static inline int power_supply_set_online(struct power_supply *psy,
|
|
|
|
bool enable)
|
|
|
|
{ return -ENOSYS; }
|
2013-09-09 13:15:06 +02:00
|
|
|
static inline int power_supply_set_health_state(struct power_supply *psy,
|
|
|
|
int health)
|
|
|
|
{ return -ENOSYS; }
|
2012-08-18 01:25:24 +02:00
|
|
|
static inline int power_supply_set_present(struct power_supply *psy,
|
|
|
|
bool enable)
|
|
|
|
{ return -ENOSYS; }
|
2012-06-02 03:14:50 +02:00
|
|
|
static inline int power_supply_set_scope(struct power_supply *psy,
|
|
|
|
int scope)
|
|
|
|
{ return -ENOSYS; }
|
2014-05-15 22:42:37 +02:00
|
|
|
static inline int power_supply_set_usb_otg(struct power_supply *psy, int otg)
|
|
|
|
{ return -ENOSYS; }
|
2012-06-02 03:14:50 +02:00
|
|
|
static inline int power_supply_set_charge_type(struct power_supply *psy,
|
|
|
|
int type)
|
|
|
|
{ return -ENOSYS; }
|
|
|
|
static inline int power_supply_set_supply_type(struct power_supply *psy,
|
2012-09-26 06:37:03 +02:00
|
|
|
enum power_supply_type supply_type)
|
2012-06-02 03:14:50 +02:00
|
|
|
{ return -ENOSYS; }
|
2014-04-30 15:11:31 +02:00
|
|
|
static inline int power_supply_set_hi_power_state(struct power_supply *psy,
|
|
|
|
int value)
|
|
|
|
{ return -ENOSYS; }
|
|
|
|
static inline int power_supply_set_low_power_state(struct power_supply *psy,
|
|
|
|
int value)
|
|
|
|
{ return -ENOSYS; }
|
2015-03-13 20:58:47 +01:00
|
|
|
static inline int power_supply_set_allow_detection(struct power_supply *psy,
|
|
|
|
int value)
|
|
|
|
{ return -ENOSYS; }
|
2008-08-26 22:09:59 +02:00
|
|
|
static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
|
2012-09-26 06:37:03 +02:00
|
|
|
static inline int power_supply_register(struct device *parent,
|
|
|
|
struct power_supply *psy)
|
|
|
|
{ return -ENOSYS; }
|
|
|
|
static inline void power_supply_unregister(struct power_supply *psy) { }
|
|
|
|
static inline int power_supply_powers(struct power_supply *psy,
|
|
|
|
struct device *dev)
|
|
|
|
{ return -ENOSYS; }
|
2008-08-26 22:09:59 +02:00
|
|
|
#endif
|
|
|
|
|
2007-05-03 22:27:45 +02:00
|
|
|
/* For APM emulation, think legacy userspace. */
|
|
|
|
extern struct class *power_supply_class;
|
|
|
|
|
2011-01-25 20:10:06 +01:00
|
|
|
static inline bool power_supply_is_amp_property(enum power_supply_property psp)
|
|
|
|
{
|
|
|
|
switch (psp) {
|
|
|
|
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
|
|
|
|
case POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN:
|
|
|
|
case POWER_SUPPLY_PROP_CHARGE_FULL:
|
|
|
|
case POWER_SUPPLY_PROP_CHARGE_EMPTY:
|
|
|
|
case POWER_SUPPLY_PROP_CHARGE_NOW:
|
|
|
|
case POWER_SUPPLY_PROP_CHARGE_AVG:
|
|
|
|
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
|
2013-05-03 00:54:27 +02:00
|
|
|
case POWER_SUPPLY_PROP_CHARGE_COUNTER_SHADOW:
|
2012-05-06 14:46:44 +02:00
|
|
|
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
|
2012-07-30 09:19:21 +02:00
|
|
|
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
|
2011-01-25 20:10:06 +01:00
|
|
|
case POWER_SUPPLY_PROP_CURRENT_MAX:
|
2013-07-16 06:42:58 +02:00
|
|
|
case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX:
|
2011-01-25 20:10:06 +01:00
|
|
|
case POWER_SUPPLY_PROP_CURRENT_NOW:
|
|
|
|
case POWER_SUPPLY_PROP_CURRENT_AVG:
|
2014-08-01 00:04:04 +02:00
|
|
|
case POWER_SUPPLY_PROP_FLASH_CURRENT_MAX:
|
2011-01-25 20:10:06 +01:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool power_supply_is_watt_property(enum power_supply_property psp)
|
|
|
|
{
|
|
|
|
switch (psp) {
|
|
|
|
case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
|
|
|
|
case POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN:
|
|
|
|
case POWER_SUPPLY_PROP_ENERGY_FULL:
|
|
|
|
case POWER_SUPPLY_PROP_ENERGY_EMPTY:
|
|
|
|
case POWER_SUPPLY_PROP_ENERGY_NOW:
|
|
|
|
case POWER_SUPPLY_PROP_ENERGY_AVG:
|
|
|
|
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
|
|
|
|
case POWER_SUPPLY_PROP_VOLTAGE_MIN:
|
|
|
|
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
|
|
|
|
case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
|
|
|
|
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
|
|
|
|
case POWER_SUPPLY_PROP_VOLTAGE_AVG:
|
2012-04-10 12:51:20 +02:00
|
|
|
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
|
2012-05-06 14:46:44 +02:00
|
|
|
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
|
2012-07-30 09:19:21 +02:00
|
|
|
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
|
2011-03-01 01:55:31 +01:00
|
|
|
case POWER_SUPPLY_PROP_POWER_NOW:
|
2011-01-25 20:10:06 +01:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-05-03 22:27:45 +02:00
|
|
|
#endif /* __LINUX_POWER_SUPPLY_H__ */
|