power: fuel gauge: add capability callback

Return "FG_CAP_FUEL_GAUGE | FG_CAP_CHARGER" as default value
when there's not implementation, which compatibles with all fg drivers.

Change-Id: Ie71e1271e504c63be42af41551e10e8c2c7d89ac
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-05-15 17:10:30 +08:00 committed by Shunqing Chen
parent 69cce37bfc
commit b3271e11e6
2 changed files with 16 additions and 0 deletions

View File

@ -10,6 +10,16 @@
DECLARE_GLOBAL_DATA_PTR;
int fuel_gauge_capability(struct udevice *dev)
{
const struct dm_fuel_gauge_ops *ops = dev_get_driver_ops(dev);
if (!ops || !ops->capability)
return (FG_CAP_CHARGER | FG_CAP_FUEL_GAUGE);
return ops->capability(dev);
}
int fuel_gauge_bat_is_exist(struct udevice *dev)
{
const struct dm_fuel_gauge_ops *ops = dev_get_driver_ops(dev);

View File

@ -7,7 +7,12 @@
#ifndef _FUEL_GAUGE_H_
#define _FUEL_GAUGE_H_
/* Capability */
#define FG_CAP_FUEL_GAUGE BIT(0)
#define FG_CAP_CHARGER BIT(1)
struct dm_fuel_gauge_ops {
int (*capability)(struct udevice *dev);
int (*bat_is_exist)(struct udevice *dev);
int (*get_soc)(struct udevice *dev);
int (*get_voltage)(struct udevice *dev);
@ -15,6 +20,7 @@ struct dm_fuel_gauge_ops {
bool (*get_chrg_online)(struct udevice *dev);
};
int fuel_gauge_capability(struct udevice *dev);
int fuel_gauge_bat_is_exist(struct udevice *dev);
int fuel_gauge_get_soc(struct udevice *dev);
int fuel_gauge_get_voltage(struct udevice *dev);