bq27xxx_battery.h 1.8 KB

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