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