qg-profile.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __QG_PROFILE_H__
  7. #define __QG_PROFILE_H__
  8. #include <linux/ioctl.h>
  9. /**
  10. * enum profile_table - Table index for battery profile data
  11. */
  12. enum profile_table {
  13. TABLE_SOC_OCV1,
  14. TABLE_SOC_OCV2,
  15. TABLE_FCC1,
  16. TABLE_FCC2,
  17. TABLE_Z1,
  18. TABLE_Z2,
  19. TABLE_Z3,
  20. TABLE_Z4,
  21. TABLE_Z5,
  22. TABLE_Z6,
  23. TABLE_Y1,
  24. TABLE_Y2,
  25. TABLE_Y3,
  26. TABLE_Y4,
  27. TABLE_Y5,
  28. TABLE_Y6,
  29. TABLE_MAX,
  30. };
  31. /**
  32. * struct battery_params - Battery profile data to be exchanged
  33. * @soc: SOC (state of charge) of the battery
  34. * @ocv_uv: OCV (open circuit voltage) of the battery
  35. * @batt_temp: Battery temperature in deci-degree
  36. * @var: 'X' axis param for interpolation
  37. * @table_index:Table index to be used for interpolation
  38. */
  39. struct battery_params {
  40. int soc;
  41. int ocv_uv;
  42. int fcc_mah;
  43. int slope;
  44. int var;
  45. int batt_temp;
  46. int table_index;
  47. };
  48. /* Profile MIN / MAX values */
  49. #define QG_MIN_SOC 0
  50. #define QG_MAX_SOC 10000
  51. #define QG_MIN_OCV_UV 2000000
  52. #define QG_MAX_OCV_UV 5000000
  53. #define QG_MIN_VAR 0
  54. #define QG_MAX_VAR 65535
  55. #define QG_MIN_FCC_MAH 100
  56. #define QG_MAX_FCC_MAH 16000
  57. #define QG_MIN_SLOPE 1
  58. #define QG_MAX_SLOPE 50000
  59. #define QG_ESR_SF_MIN 5000
  60. #define QG_ESR_SF_MAX 20000
  61. /* IOCTLs to query battery profile data */
  62. #define BPIOCXSOC _IOWR('B', 0x01, struct battery_params) /* SOC */
  63. #define BPIOCXOCV _IOWR('B', 0x02, struct battery_params) /* OCV */
  64. #define BPIOCXFCC _IOWR('B', 0x03, struct battery_params) /* FCC */
  65. #define BPIOCXSLOPE _IOWR('B', 0x04, struct battery_params) /* Slope */
  66. #define BPIOCXVAR _IOWR('B', 0x05, struct battery_params) /* All-other */
  67. #endif /* __QG_PROFILE_H__ */