power: charge animation: add battery existence check
Change-Id: I8451d3069c11faa91d6b0087a764685cdf4f1bbf Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
d60cbc66d7
commit
61a7a6d6a1
|
|
@ -342,6 +342,11 @@ static int charge_animation_show(struct udevice *dev)
|
|||
* 6. Enter charge !
|
||||
*
|
||||
*/
|
||||
if (!fuel_gauge_bat_is_exist(fg)) {
|
||||
printf("Exit charge: battery is not exist\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Extrem low power charge */
|
||||
ret = charge_extrem_low_power(dev);
|
||||
if (ret < 0) {
|
||||
|
|
@ -350,7 +355,7 @@ static int charge_animation_show(struct udevice *dev)
|
|||
}
|
||||
|
||||
/* If there is preboot command, exit */
|
||||
if (preboot) {
|
||||
if (preboot && !strstr(preboot, "dvfs")) {
|
||||
printf("Exit charge: due to preboot cmd '%s'\n", preboot);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,16 @@
|
|||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
int fuel_gauge_bat_is_exist(struct udevice *dev)
|
||||
{
|
||||
const struct dm_fuel_gauge_ops *ops = dev_get_driver_ops(dev);
|
||||
|
||||
if (!ops || !ops->bat_is_exist)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->bat_is_exist(dev);
|
||||
}
|
||||
|
||||
int fuel_gauge_get_current(struct udevice *dev)
|
||||
{
|
||||
const struct dm_fuel_gauge_ops *ops = dev_get_driver_ops(dev);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@
|
|||
#define _FUEL_GAUGE_H_
|
||||
|
||||
struct dm_fuel_gauge_ops {
|
||||
int (*bat_is_exist)(struct udevice *dev);
|
||||
int (*get_soc)(struct udevice *dev);
|
||||
int (*get_voltage)(struct udevice *dev);
|
||||
int (*get_current)(struct udevice *dev);
|
||||
bool (*get_chrg_online)(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);
|
||||
int fuel_gauge_get_current(struct udevice *dev);
|
||||
|
|
|
|||
Loading…
Reference in New Issue