blob: 43194e02c1ee12f9df7d9b6d2e3f9992cf8ca893 [file] [log] [blame]
Lars-Peter Clausen7fb7ba52010-05-24 19:55:27 +02001#ifndef __LINUX_BQ27X00_BATTERY_H__
2#define __LINUX_BQ27X00_BATTERY_H__
3
Andrew F. Davis703df6c2015-11-23 10:53:51 -06004enum bq27xxx_chip {
5 BQ27000 = 1, /* bq27000, bq27200 */
6 BQ27010, /* bq27010, bq27210 */
Chris Lapa818e3012017-01-11 12:44:38 +11007 BQ2750X, /* bq27500 deprecated alias */
Chris Lapa6da6e4b2017-01-11 12:44:39 +11008 BQ2751X, /* bq27510, bq27520 deprecated alias */
Liam Breck3a731c62017-08-23 20:36:14 -07009 BQ2752X,
Chris Lapa32833632017-01-11 12:44:40 +110010 BQ27500, /* bq27500/1 */
Chris Lapabd281772017-01-11 12:44:41 +110011 BQ27510G1, /* bq27510G1 */
Chris Lapa698a2bf2017-01-11 12:44:42 +110012 BQ27510G2, /* bq27510G2 */
Chris Lapa71375aa2017-01-11 12:44:43 +110013 BQ27510G3, /* bq27510G3 */
Chris Lapa68f2a812017-01-11 12:44:44 +110014 BQ27520G1, /* bq27520G1 */
Chris Lapaa5deb9a2017-01-11 12:44:45 +110015 BQ27520G2, /* bq27520G2 */
Chris Lapa825e9152017-01-11 12:44:46 +110016 BQ27520G3, /* bq27520G3 */
Chris Lapa8835cae2017-01-11 12:44:47 +110017 BQ27520G4, /* bq27520G4 */
Andrew F. Davis703df6c2015-11-23 10:53:51 -060018 BQ27530, /* bq27530, bq27531 */
Liam Breck3a731c62017-08-23 20:36:14 -070019 BQ27531,
Andrew F. Davis703df6c2015-11-23 10:53:51 -060020 BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
Liam Breck3a731c62017-08-23 20:36:14 -070021 BQ27542,
22 BQ27546,
23 BQ27742,
Andrew F. Davis703df6c2015-11-23 10:53:51 -060024 BQ27545, /* bq27545 */
25 BQ27421, /* bq27421, bq27425, bq27441, bq27621 */
Liam Breck3a731c62017-08-23 20:36:14 -070026 BQ27425,
27 BQ27441,
28 BQ27621,
Andrew F. Davis703df6c2015-11-23 10:53:51 -060029};
30
Andrew F. Davis703df6c2015-11-23 10:53:51 -060031struct bq27xxx_device_info;
32struct bq27xxx_access_methods {
33 int (*read)(struct bq27xxx_device_info *di, u8 reg, bool single);
Matt Ranostay14073f62017-06-07 11:37:54 -070034 int (*write)(struct bq27xxx_device_info *di, u8 reg, int value, bool single);
35 int (*read_bulk)(struct bq27xxx_device_info *di, u8 reg, u8 *data, int len);
36 int (*write_bulk)(struct bq27xxx_device_info *di, u8 reg, u8 *data, int len);
Andrew F. Davis703df6c2015-11-23 10:53:51 -060037};
38
39struct bq27xxx_reg_cache {
40 int temperature;
41 int time_to_empty;
42 int time_to_empty_avg;
43 int time_to_full;
44 int charge_full;
45 int cycle_count;
46 int capacity;
47 int energy;
48 int flags;
49 int power_avg;
50 int health;
51};
52
53struct bq27xxx_device_info {
54 struct device *dev;
Ivaylo Dimitrov9aafabc2016-02-02 14:47:37 +020055 int id;
Andrew F. Davis703df6c2015-11-23 10:53:51 -060056 enum bq27xxx_chip chip;
Liam Breck3a731c62017-08-23 20:36:14 -070057 u32 opts;
Andrew F. Davis703df6c2015-11-23 10:53:51 -060058 const char *name;
Liam Breckccce4402017-06-07 11:37:56 -070059 struct bq27xxx_dm_reg *dm_regs;
Liam Breck0670c9b2017-06-07 11:37:55 -070060 u32 unseal_key;
Andrew F. Davis703df6c2015-11-23 10:53:51 -060061 struct bq27xxx_access_methods bus;
62 struct bq27xxx_reg_cache cache;
63 int charge_design_full;
64 unsigned long last_update;
65 struct delayed_work work;
66 struct power_supply *bat;
Matt Ranostay1d727062016-09-19 20:43:02 -070067 struct list_head list;
Andrew F. Davis703df6c2015-11-23 10:53:51 -060068 struct mutex lock;
69 u8 *regs;
70};
71
72void bq27xxx_battery_update(struct bq27xxx_device_info *di);
73int bq27xxx_battery_setup(struct bq27xxx_device_info *di);
74void bq27xxx_battery_teardown(struct bq27xxx_device_info *di);
75
Lars-Peter Clausen7fb7ba52010-05-24 19:55:27 +020076#endif