License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[sfrench/cifs-2.6.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         BQ27530, /* bq27530, bq27531 */
20         BQ27531,
21         BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
22         BQ27542,
23         BQ27546,
24         BQ27742,
25         BQ27545, /* bq27545 */
26         BQ27421, /* bq27421, bq27425, bq27441, bq27621 */
27         BQ27425,
28         BQ27441,
29         BQ27621,
30 };
31
32 struct bq27xxx_device_info;
33 struct bq27xxx_access_methods {
34         int (*read)(struct bq27xxx_device_info *di, u8 reg, bool single);
35         int (*write)(struct bq27xxx_device_info *di, u8 reg, int value, bool single);
36         int (*read_bulk)(struct bq27xxx_device_info *di, u8 reg, u8 *data, int len);
37         int (*write_bulk)(struct bq27xxx_device_info *di, u8 reg, u8 *data, int len);
38 };
39
40 struct bq27xxx_reg_cache {
41         int temperature;
42         int time_to_empty;
43         int time_to_empty_avg;
44         int time_to_full;
45         int charge_full;
46         int cycle_count;
47         int capacity;
48         int energy;
49         int flags;
50         int power_avg;
51         int health;
52 };
53
54 struct bq27xxx_device_info {
55         struct device *dev;
56         int id;
57         enum bq27xxx_chip chip;
58         u32 opts;
59         const char *name;
60         struct bq27xxx_dm_reg *dm_regs;
61         u32 unseal_key;
62         struct bq27xxx_access_methods bus;
63         struct bq27xxx_reg_cache cache;
64         int charge_design_full;
65         unsigned long last_update;
66         struct delayed_work work;
67         struct power_supply *bat;
68         struct list_head list;
69         struct mutex lock;
70         u8 *regs;
71 };
72
73 void bq27xxx_battery_update(struct bq27xxx_device_info *di);
74 int bq27xxx_battery_setup(struct bq27xxx_device_info *di);
75 void bq27xxx_battery_teardown(struct bq27xxx_device_info *di);
76
77 #endif