1#ifndef __LINUX_BQ27X00_BATTERY_H__
2#define __LINUX_BQ27X00_BATTERY_H__
3
4enum bq27xxx_chip {
5 BQ27000 = 1,
6 BQ27010,
7 BQ2750X,
8 BQ2751X,
9 BQ27500,
10 BQ27510G1,
11 BQ27510G2,
12 BQ27510G3,
13 BQ27520G1,
14 BQ27520G2,
15 BQ27520G3,
16 BQ27520G4,
17 BQ27530,
18 BQ27541,
19 BQ27545,
20 BQ27421,
21};
22
23
24
25
26
27
28
29
30
31
32
33
34struct bq27xxx_platform_data {
35 const char *name;
36 enum bq27xxx_chip chip;
37 int (*read)(struct device *dev, unsigned int);
38};
39
40struct bq27xxx_device_info;
41struct 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
48struct 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 power_avg;
59 int health;
60};
61
62struct bq27xxx_device_info {
63 struct device *dev;
64 int id;
65 enum bq27xxx_chip chip;
66 bool ram_chip;
67 const char *name;
68 struct bq27xxx_dm_reg *dm_regs;
69 u32 unseal_key;
70 struct bq27xxx_access_methods bus;
71 struct bq27xxx_reg_cache cache;
72 int charge_design_full;
73 unsigned long last_update;
74 struct delayed_work work;
75 struct power_supply *bat;
76 struct list_head list;
77 struct mutex lock;
78 u8 *regs;
79};
80
81void bq27xxx_battery_update(struct bq27xxx_device_info *di);
82int bq27xxx_battery_setup(struct bq27xxx_device_info *di);
83void bq27xxx_battery_teardown(struct bq27xxx_device_info *di);
84
85#endif
86