1
2 #ifndef __LINUX_BQ27X00_BATTERY_H__
3 #define __LINUX_BQ27X00_BATTERY_H__
4
5 enum bq27xxx_chip {
6 BQ27000 = 1,
7 BQ27010,
8 BQ2750X,
9 BQ2751X,
10 BQ2752X,
11 BQ27500,
12 BQ27510G1,
13 BQ27510G2,
14 BQ27510G3,
15 BQ27520G1,
16 BQ27520G2,
17 BQ27520G3,
18 BQ27520G4,
19 BQ27521,
20 BQ27530,
21 BQ27531,
22 BQ27541,
23 BQ27542,
24 BQ27546,
25 BQ27742,
26 BQ27545,
27 BQ27411,
28 BQ27421,
29 BQ27425,
30 BQ27426,
31 BQ27441,
32 BQ27621,
33 };
34
35 struct bq27xxx_device_info;
36 struct bq27xxx_access_methods {
37 int (*read)(struct bq27xxx_device_info *di, u8 reg, bool single);
38 int (*write)(struct bq27xxx_device_info *di, u8 reg, int value, bool single);
39 int (*read_bulk)(struct bq27xxx_device_info *di, u8 reg, u8 *data, int len);
40 int (*write_bulk)(struct bq27xxx_device_info *di, u8 reg, u8 *data, int len);
41 };
42
43 struct bq27xxx_reg_cache {
44 int temperature;
45 int time_to_empty;
46 int time_to_empty_avg;
47 int time_to_full;
48 int charge_full;
49 int cycle_count;
50 int capacity;
51 int energy;
52 int flags;
53 int power_avg;
54 int health;
55 };
56
57 struct bq27xxx_device_info {
58 struct device *dev;
59 int id;
60 enum bq27xxx_chip chip;
61 u32 opts;
62 const char *name;
63 struct bq27xxx_dm_reg *dm_regs;
64 u32 unseal_key;
65 struct bq27xxx_access_methods bus;
66 struct bq27xxx_reg_cache cache;
67 int charge_design_full;
68 unsigned long last_update;
69 struct delayed_work work;
70 struct power_supply *bat;
71 struct list_head list;
72 struct mutex lock;
73 u8 *regs;
74 };
75
76 void bq27xxx_battery_update(struct bq27xxx_device_info *di);
77 int bq27xxx_battery_setup(struct bq27xxx_device_info *di);
78 void bq27xxx_battery_teardown(struct bq27xxx_device_info *di);
79
80 #endif