hc
2024-03-26 e0728245c89800c2038c23308f2d88969d5b41c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * (C) Copyright 2017 Rockchip Electronics Co., Ltd
 *
 * SPDX-License-Identifier:     GPL-2.0+
 */
 
#include <errno.h>
#include <dm.h>
#include <power/fuel_gauge.h>
 
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);
 
   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);
 
   if (!ops || !ops->get_current)
       return -ENOSYS;
 
   return ops->get_current(dev);
}
 
int fuel_gauge_get_voltage(struct udevice *dev)
{
   const struct dm_fuel_gauge_ops *ops = dev_get_driver_ops(dev);
 
   if (!ops || !ops->get_voltage)
       return -ENOSYS;
 
   return ops->get_voltage(dev);
}
 
int fuel_gauge_update_get_soc(struct udevice *dev)
{
   const struct dm_fuel_gauge_ops *ops = dev_get_driver_ops(dev);
 
   if (!ops || !ops->get_soc)
       return -ENOSYS;
 
   return ops->get_soc(dev);
}
 
bool fuel_gauge_get_chrg_online(struct udevice *dev)
{
   const struct dm_fuel_gauge_ops *ops = dev_get_driver_ops(dev);
 
   if (!ops || !ops->get_chrg_online)
       return -ENOSYS;
 
   return ops->get_chrg_online(dev);
}
 
UCLASS_DRIVER(fuel_guage) = {
   .id        = UCLASS_FG,
   .name        = "fuel_gauge",
};