GNU Linux-libre 5.10.217-gnu1
[releases.git] / include / linux / power / bq27xxx_battery.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_BQ27X00_BATTERY_H__
3 #define __LINUX_BQ27X00_BATTERY_H__
4
5 #include <linux/power_supply.h>
6
7 enum bq27xxx_chip {
8         BQ27000 = 1, /* bq27000, bq27200 */
9         BQ27010, /* bq27010, bq27210 */
10         BQ2750X, /* bq27500 deprecated alias */
11         BQ2751X, /* bq27510, bq27520 deprecated alias */
12         BQ2752X,
13         BQ27500, /* bq27500/1 */
14         BQ27510G1, /* bq27510G1 */
15         BQ27510G2, /* bq27510G2 */
16         BQ27510G3, /* bq27510G3 */
17         BQ27520G1, /* bq27520G1 */
18         BQ27520G2, /* bq27520G2 */
19         BQ27520G3, /* bq27520G3 */
20         BQ27520G4, /* bq27520G4 */
21         BQ27521, /* bq27521 */
22         BQ27530, /* bq27530, bq27531 */
23         BQ27531,
24         BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
25         BQ27542,
26         BQ27546,
27         BQ27742,
28         BQ27545, /* bq27545 */
29         BQ27411,
30         BQ27421, /* bq27421, bq27441, bq27621 */
31         BQ27425,
32         BQ27426,
33         BQ27441,
34         BQ27621,
35         BQ27Z561,
36         BQ28Z610,
37         BQ34Z100,
38 };
39
40 struct bq27xxx_device_info;
41 struct bq27xxx_access_methods {
42         int (*read)(struct bq27xxx_device_info *di, u8 reg, bool single);
43         int (*write)(struct bq27xxx_device_info *di, u8 reg, int value, bool single);
44         int (*read_bulk)(struct bq27xxx_device_info *di, u8 reg, u8 *data, int len);
45         int (*write_bulk)(struct bq27xxx_device_info *di, u8 reg, u8 *data, int len);
46 };
47
48 struct bq27xxx_reg_cache {
49         int temperature;
50         int time_to_empty;
51         int time_to_empty_avg;
52         int time_to_full;
53         int charge_full;
54         int cycle_count;
55         int capacity;
56         int energy;
57         int flags;
58         int health;
59 };
60
61 struct bq27xxx_device_info {
62         struct device *dev;
63         int id;
64         enum bq27xxx_chip chip;
65         u32 opts;
66         const char *name;
67         struct bq27xxx_dm_reg *dm_regs;
68         u32 unseal_key;
69         struct bq27xxx_access_methods bus;
70         struct bq27xxx_reg_cache cache;
71         int charge_design_full;
72         bool removed;
73         unsigned long last_update;
74         union power_supply_propval last_status;
75         struct delayed_work work;
76         struct power_supply *bat;
77         struct list_head list;
78         struct mutex lock;
79         u8 *regs;
80 };
81
82 void bq27xxx_battery_update(struct bq27xxx_device_info *di);
83 int bq27xxx_battery_setup(struct bq27xxx_device_info *di);
84 void bq27xxx_battery_teardown(struct bq27xxx_device_info *di);
85
86 #endif