]> asedeno.scripts.mit.edu Git - linux.git/blob - include/linux/power/bq27xxx_battery.h
power: supply: bq27xxx: adds specific support for bq27500/1 revision.
[linux.git] / include / linux / power / bq27xxx_battery.h
1 #ifndef __LINUX_BQ27X00_BATTERY_H__
2 #define __LINUX_BQ27X00_BATTERY_H__
3
4 enum bq27xxx_chip {
5         BQ27000 = 1, /* bq27000, bq27200 */
6         BQ27010, /* bq27010, bq27210 */
7         BQ2750X, /* bq27500 deprecated alias */
8         BQ2751X, /* bq27510, bq27520 deprecated alias */
9         BQ27500, /* bq27500/1 */
10         BQ27530, /* bq27530, bq27531 */
11         BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
12         BQ27545, /* bq27545 */
13         BQ27421, /* bq27421, bq27425, bq27441, bq27621 */
14 };
15
16 /**
17  * struct bq27xxx_plaform_data - Platform data for bq27xxx devices
18  * @name: Name of the battery.
19  * @chip: Chip class number of this device.
20  * @read: HDQ read callback.
21  *      This function should provide access to the HDQ bus the battery is
22  *      connected to.
23  *      The first parameter is a pointer to the battery device, the second the
24  *      register to be read. The return value should either be the content of
25  *      the passed register or an error value.
26  */
27 struct bq27xxx_platform_data {
28         const char *name;
29         enum bq27xxx_chip chip;
30         int (*read)(struct device *dev, unsigned int);
31 };
32
33 struct bq27xxx_device_info;
34 struct bq27xxx_access_methods {
35         int (*read)(struct bq27xxx_device_info *di, u8 reg, bool single);
36 };
37
38 struct bq27xxx_reg_cache {
39         int temperature;
40         int time_to_empty;
41         int time_to_empty_avg;
42         int time_to_full;
43         int charge_full;
44         int cycle_count;
45         int capacity;
46         int energy;
47         int flags;
48         int power_avg;
49         int health;
50 };
51
52 struct bq27xxx_device_info {
53         struct device *dev;
54         int id;
55         enum bq27xxx_chip chip;
56         const char *name;
57         struct bq27xxx_access_methods bus;
58         struct bq27xxx_reg_cache cache;
59         int charge_design_full;
60         unsigned long last_update;
61         struct delayed_work work;
62         struct power_supply *bat;
63         struct list_head list;
64         struct mutex lock;
65         u8 *regs;
66 };
67
68 void bq27xxx_battery_update(struct bq27xxx_device_info *di);
69 int bq27xxx_battery_setup(struct bq27xxx_device_info *di);
70 void bq27xxx_battery_teardown(struct bq27xxx_device_info *di);
71
72 #endif