qbg-profile.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __QBG_PROFILE_H__
  7. #define __QBG_PROFILE_H__
  8. #include <linux/types.h>
  9. #define MAX_BP_LUT_ROWS 35
  10. #define MAX_BP_LUT_COLS 8
  11. #define MAX_PROFILE_NAME_LENGTH 256
  12. #define QBG_BPIOCXBP 0x1
  13. #define QBG_BPIOCXBPTABLE 0x2
  14. enum profile_table_type {
  15. CHARGE_TABLE = 0,
  16. DISCHARGE_TABLE,
  17. };
  18. struct battery_data_table {
  19. unsigned short int table[MAX_BP_LUT_ROWS][MAX_BP_LUT_COLS];
  20. int unit_conv_factor[MAX_BP_LUT_COLS];
  21. unsigned short int nrows;
  22. unsigned short int ncols;
  23. } __attribute__ ((__packed__));
  24. struct battery_config {
  25. char bp_profile_name[MAX_PROFILE_NAME_LENGTH];
  26. int bp_batt_id;
  27. int capacity;
  28. int bp_checksum;
  29. int soh_range_high;
  30. int soh_range_low;
  31. int normal_impedance;
  32. int aged_impedance;
  33. int normal_capacity;
  34. int aged_capacity;
  35. int recharge_soc_delta;
  36. int recharge_vflt_delta;
  37. int recharge_iterm;
  38. } __attribute__ ((__packed__));
  39. struct battery_profile_table {
  40. enum profile_table_type table_type;
  41. int table_index;
  42. struct battery_data_table *table;
  43. } __attribute__ ((__packed__));
  44. /* IOCTLs to query battery profile data */
  45. #define BPIOCXBP _IOWR('B', 0x01, struct battery_config) /* Battery configuration */
  46. #define BPIOCXBPTABLE _IOWR('B', 0x02, struct battery_profile_table) /* Battery profile table */
  47. #endif