of_batterydata.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/of.h>
  13. #include <linux/batterydata-lib.h>
  14. #ifdef CONFIG_OF_BATTERYDATA
  15. /**
  16. * of_batterydata_read_data() - Populate battery data from the device tree
  17. * @container_node: pointer to the battery-data container device node
  18. * containing the profile nodes.
  19. * @batt_data: pointer to an allocated bms_battery_data structure that the
  20. * loaded profile will be written to.
  21. * @batt_id_uv: ADC voltage of the battery id line used to differentiate
  22. * between different battery profiles. If there are multiple
  23. * battery data in the device tree, the one with the closest
  24. * battery id resistance will be automatically loaded.
  25. *
  26. * This routine loads the closest match battery data from device tree based on
  27. * the battery id reading. Then, it will try to load all the relevant data from
  28. * the device tree battery data profile.
  29. *
  30. * If any of the lookup table pointers are NULL, this routine will skip trying
  31. * to read them.
  32. */
  33. int of_batterydata_read_data(struct device_node *container_node,
  34. struct bms_battery_data *batt_data,
  35. int batt_id_uv);
  36. #else
  37. static inline int of_batterydata_read_data(struct device_node *container_node,
  38. struct bms_battery_data *batt_data,
  39. int batt_id_uv);
  40. {
  41. return -ENXIO;
  42. }
  43. #endif /* CONFIG_OF_QPNP */