Lars-Peter Clausen | 7fb7ba5 | 2010-05-24 19:55:27 +0200 | [diff] [blame] | 1 | #ifndef __LINUX_BQ27X00_BATTERY_H__ |
| 2 | #define __LINUX_BQ27X00_BATTERY_H__ |
| 3 | |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 4 | enum bq27xxx_chip { |
| 5 | BQ27000 = 1, /* bq27000, bq27200 */ |
| 6 | BQ27010, /* bq27010, bq27210 */ |
Chris Lapa | 818e301 | 2017-01-11 12:44:38 +1100 | [diff] [blame] | 7 | BQ2750X, /* bq27500 deprecated alias */ |
Chris Lapa | 6da6e4b | 2017-01-11 12:44:39 +1100 | [diff] [blame] | 8 | BQ2751X, /* bq27510, bq27520 deprecated alias */ |
Liam Breck | 3a731c6 | 2017-08-23 20:36:14 -0700 | [diff] [blame] | 9 | BQ2752X, |
Chris Lapa | 3283363 | 2017-01-11 12:44:40 +1100 | [diff] [blame] | 10 | BQ27500, /* bq27500/1 */ |
Chris Lapa | bd28177 | 2017-01-11 12:44:41 +1100 | [diff] [blame] | 11 | BQ27510G1, /* bq27510G1 */ |
Chris Lapa | 698a2bf | 2017-01-11 12:44:42 +1100 | [diff] [blame] | 12 | BQ27510G2, /* bq27510G2 */ |
Chris Lapa | 71375aa | 2017-01-11 12:44:43 +1100 | [diff] [blame] | 13 | BQ27510G3, /* bq27510G3 */ |
Chris Lapa | 68f2a81 | 2017-01-11 12:44:44 +1100 | [diff] [blame] | 14 | BQ27520G1, /* bq27520G1 */ |
Chris Lapa | a5deb9a | 2017-01-11 12:44:45 +1100 | [diff] [blame] | 15 | BQ27520G2, /* bq27520G2 */ |
Chris Lapa | 825e915 | 2017-01-11 12:44:46 +1100 | [diff] [blame] | 16 | BQ27520G3, /* bq27520G3 */ |
Chris Lapa | 8835cae | 2017-01-11 12:44:47 +1100 | [diff] [blame] | 17 | BQ27520G4, /* bq27520G4 */ |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 18 | BQ27530, /* bq27530, bq27531 */ |
Liam Breck | 3a731c6 | 2017-08-23 20:36:14 -0700 | [diff] [blame] | 19 | BQ27531, |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 20 | BQ27541, /* bq27541, bq27542, bq27546, bq27742 */ |
Liam Breck | 3a731c6 | 2017-08-23 20:36:14 -0700 | [diff] [blame] | 21 | BQ27542, |
| 22 | BQ27546, |
| 23 | BQ27742, |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 24 | BQ27545, /* bq27545 */ |
| 25 | BQ27421, /* bq27421, bq27425, bq27441, bq27621 */ |
Liam Breck | 3a731c6 | 2017-08-23 20:36:14 -0700 | [diff] [blame] | 26 | BQ27425, |
| 27 | BQ27441, |
| 28 | BQ27621, |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 29 | }; |
| 30 | |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 31 | struct bq27xxx_device_info; |
| 32 | struct bq27xxx_access_methods { |
| 33 | int (*read)(struct bq27xxx_device_info *di, u8 reg, bool single); |
Matt Ranostay | 14073f6 | 2017-06-07 11:37:54 -0700 | [diff] [blame] | 34 | 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. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | struct 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 | |
| 53 | struct bq27xxx_device_info { |
| 54 | struct device *dev; |
Ivaylo Dimitrov | 9aafabc | 2016-02-02 14:47:37 +0200 | [diff] [blame] | 55 | int id; |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 56 | enum bq27xxx_chip chip; |
Liam Breck | 3a731c6 | 2017-08-23 20:36:14 -0700 | [diff] [blame] | 57 | u32 opts; |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 58 | const char *name; |
Liam Breck | ccce440 | 2017-06-07 11:37:56 -0700 | [diff] [blame] | 59 | struct bq27xxx_dm_reg *dm_regs; |
Liam Breck | 0670c9b | 2017-06-07 11:37:55 -0700 | [diff] [blame] | 60 | u32 unseal_key; |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 61 | 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 Ranostay | 1d72706 | 2016-09-19 20:43:02 -0700 | [diff] [blame] | 67 | struct list_head list; |
Andrew F. Davis | 703df6c | 2015-11-23 10:53:51 -0600 | [diff] [blame] | 68 | struct mutex lock; |
| 69 | u8 *regs; |
| 70 | }; |
| 71 | |
| 72 | void bq27xxx_battery_update(struct bq27xxx_device_info *di); |
| 73 | int bq27xxx_battery_setup(struct bq27xxx_device_info *di); |
| 74 | void bq27xxx_battery_teardown(struct bq27xxx_device_info *di); |
| 75 | |
Lars-Peter Clausen | 7fb7ba5 | 2010-05-24 19:55:27 +0200 | [diff] [blame] | 76 | #endif |