]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/power/bq27xxx_battery.h
UBUNTU: Ubuntu-4.13.0-45.50
[mirror_ubuntu-artful-kernel.git] / include / linux / power / bq27xxx_battery.h
CommitLineData
7fb7ba58
LPC
1#ifndef __LINUX_BQ27X00_BATTERY_H__
2#define __LINUX_BQ27X00_BATTERY_H__
3
703df6c0
AD
4enum bq27xxx_chip {
5 BQ27000 = 1, /* bq27000, bq27200 */
6 BQ27010, /* bq27010, bq27210 */
818e3012 7 BQ2750X, /* bq27500 deprecated alias */
6da6e4bd 8 BQ2751X, /* bq27510, bq27520 deprecated alias */
32833635 9 BQ27500, /* bq27500/1 */
bd28177f 10 BQ27510G1, /* bq27510G1 */
698a2bf5 11 BQ27510G2, /* bq27510G2 */
71375aa7 12 BQ27510G3, /* bq27510G3 */
68f2a813 13 BQ27520G1, /* bq27520G1 */
a5deb9a9 14 BQ27520G2, /* bq27520G2 */
825e915b 15 BQ27520G3, /* bq27520G3 */
8835cae5 16 BQ27520G4, /* bq27520G4 */
703df6c0
AD
17 BQ27530, /* bq27530, bq27531 */
18 BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
19 BQ27545, /* bq27545 */
20 BQ27421, /* bq27421, bq27425, bq27441, bq27621 */
21};
22
7fb7ba58 23/**
081bab21 24 * struct bq27xxx_plaform_data - Platform data for bq27xxx devices
424cfde4
AD
25 * @name: Name of the battery.
26 * @chip: Chip class number of this device.
7fb7ba58
LPC
27 * @read: HDQ read callback.
28 * This function should provide access to the HDQ bus the battery is
29 * connected to.
30 * The first parameter is a pointer to the battery device, the second the
31 * register to be read. The return value should either be the content of
32 * the passed register or an error value.
33 */
081bab21 34struct bq27xxx_platform_data {
7fb7ba58 35 const char *name;
424cfde4 36 enum bq27xxx_chip chip;
7fb7ba58
LPC
37 int (*read)(struct device *dev, unsigned int);
38};
39
703df6c0
AD
40struct bq27xxx_device_info;
41struct bq27xxx_access_methods {
42 int (*read)(struct bq27xxx_device_info *di, u8 reg, bool single);
14073f66
MR
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);
703df6c0
AD
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;
9aafabc7 64 int id;
703df6c0 65 enum bq27xxx_chip chip;
ccce4409 66 bool ram_chip;
703df6c0 67 const char *name;
ccce4409 68 struct bq27xxx_dm_reg *dm_regs;
0670c9b3 69 u32 unseal_key;
703df6c0
AD
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;
1d72706f 76 struct list_head list;
703df6c0
AD
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
7fb7ba58 85#endif