power: core: add power supply APIs

Rename power_supply_set_charging_by to power_supply_set_online to
more accurately reflect the intent of the API.

Add power_supply_set_charge_type to enable a charger driver to set
a POWER_SUPPLY_PROP_CHARGE_TYPE. Ultimately this is handled like
a request, the receiving charger driver then can handle the request
and report the adequate POWER_SUPPLY_PROP_CHARGE_TYPE once necessary
action has been taken.

Change-Id: Idf4760c7d6c0f61a9eccc656cd469a6ac5fdc6cd
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
This commit is contained in:
David Keitel
2012-01-11 11:59:41 -08:00
committed by Stephen Boyd
parent 556c6f2f0c
commit b33eb64fa4
2 changed files with 23 additions and 7 deletions

View File

@@ -47,11 +47,11 @@ int power_supply_set_current_limit(struct power_supply *psy, int limit)
EXPORT_SYMBOL_GPL(power_supply_set_current_limit);
/**
* power_supply_set_charging_by - set charging state of the charger
* power_supply_set_online - set online state of the power supply
* @psy: the power supply to control
* @enable: enables or disables the charger
* @enable: sets online property of power supply
*/
int power_supply_set_charging_by(struct power_supply *psy, bool enable)
int power_supply_set_online(struct power_supply *psy, bool enable)
{
const union power_supply_propval ret = {enable,};
@@ -61,7 +61,24 @@ int power_supply_set_charging_by(struct power_supply *psy, bool enable)
return -ENXIO;
}
EXPORT_SYMBOL_GPL(power_supply_set_charging_by);
EXPORT_SYMBOL_GPL(power_supply_set_online);
/**
* power_supply_set_charge_type - set charge type of the power supply
* @psy: the power supply to control
* @enable: sets charge type property of power supply
*/
int power_supply_set_charge_type(struct power_supply *psy, int charge_type)
{
const union power_supply_propval ret = {charge_type,};
if (psy->set_property)
return psy->set_property(psy, POWER_SUPPLY_PROP_CHARGE_TYPE,
&ret);
return -ENXIO;
}
EXPORT_SYMBOL_GPL(power_supply_set_charge_type);
static int __power_supply_changed_work(struct device *dev, void *data)
{

View File

@@ -166,8 +166,6 @@ struct power_supply {
enum power_supply_property psp);
void (*external_power_changed)(struct power_supply *psy);
void (*set_charged)(struct power_supply *psy);
int (*set_current_limit)(struct power_supply *psy, int limit);
int (*set_charging_by)(struct power_supply *psy, bool enable);
/* For APM emulation, think legacy userspace. */
int use_for_apm;
@@ -217,7 +215,8 @@ extern void power_supply_changed(struct power_supply *psy);
extern int power_supply_am_i_supplied(struct power_supply *psy);
extern int power_supply_set_battery_charged(struct power_supply *psy);
extern int power_supply_set_current_limit(struct power_supply *psy, int limit);
extern int power_supply_set_charging_by(struct power_supply *psy, bool enable);
extern int power_supply_set_online(struct power_supply *psy, bool enable);
extern int power_supply_set_charge_type(struct power_supply *psy, int type);
#if defined(CONFIG_POWER_SUPPLY) || defined(CONFIG_POWER_SUPPLY_MODULE)
extern int power_supply_is_system_supplied(void);