qg-reg.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  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_REG_H__
  7. #define __QG_REG_H__
  8. #define PERPH_TYPE_REG 0x04
  9. #define PERPH_SUBTYPE_REG 0x05
  10. #define QG_ADC_IBAT_5A 0x3
  11. #define QG_ADC_IBAT_10A 0x4
  12. #define QG_TYPE 0x0D
  13. #define QG_STATUS1_REG 0x08
  14. #define QG_OK_BIT BIT(7)
  15. #define BATTERY_PRESENT_BIT BIT(0)
  16. #define ESR_MEAS_DONE_BIT BIT(4)
  17. #define QG_STATUS2_REG 0x09
  18. #define BATTERY_MISSING_BIT BIT(3)
  19. #define GOOD_OCV_BIT BIT(1)
  20. #define QG_STATUS3_REG 0x0A
  21. #define COUNT_FIFO_RT_MASK GENMASK(3, 0)
  22. #define QG_STATUS4_REG 0x0B
  23. #define ESR_MEAS_IN_PROGRESS_BIT BIT(4)
  24. #define QG_INT_RT_STS_REG 0x10
  25. #define FIFO_UPDATE_DONE_RT_STS_BIT BIT(3)
  26. #define VBAT_LOW_INT_RT_STS_BIT BIT(1)
  27. #define BATTERY_MISSING_INT_RT_STS_BIT BIT(0)
  28. #define QG_INT_LATCHED_STS_REG 0x18
  29. #define FIFO_UPDATE_DONE_INT_LAT_STS_BIT BIT(3)
  30. #define QG_STATE_TRIG_CMD_REG 0x40
  31. #define S7_PON_OCV_START BIT(3)
  32. #define QG_DATA_CTL1_REG 0x41
  33. #define MASTER_HOLD_OR_CLR_BIT BIT(0)
  34. #define QG_DATA_CTL2_REG 0x42
  35. #define BURST_AVG_HOLD_FOR_READ_BIT BIT(0)
  36. #define QG_MODE_CTL1_REG 0x43
  37. #define PARALLEL_IBAT_SENSE_EN_BIT BIT(7)
  38. #define QG_MODE_CTL2_REG 0x44
  39. #define VI_MODE_BIT BIT(0)
  40. #define QG_VBAT_EMPTY_THRESHOLD_REG 0x4B
  41. #define QG_VBAT_LOW_THRESHOLD_REG 0x4C
  42. #define QG_S2_NORMAL_MEAS_CTL2_REG 0x51
  43. #define FIFO_LENGTH_MASK GENMASK(5, 3)
  44. #define FIFO_LENGTH_SHIFT 3
  45. #define NUM_OF_ACCUM_MASK GENMASK(2, 0)
  46. #define QG_S2_NORMAL_MEAS_CTL3_REG 0x52
  47. #define QG_S3_SLEEP_OCV_MEAS_CTL4_REG 0x59
  48. #define S3_SLEEP_OCV_TIMER_MASK GENMASK(2, 0)
  49. #define QG_S3_SLEEP_OCV_TREND_CTL2_REG 0x5C
  50. #define TREND_TOL_MASK GENMASK(5, 0)
  51. #define QG_S3_SLEEP_OCV_IBAT_CTL1_REG 0x5D
  52. #define SLEEP_IBAT_QUALIFIED_LENGTH_MASK GENMASK(2, 0)
  53. #define QG_S3_ENTRY_IBAT_THRESHOLD_REG 0x5E
  54. #define QG_S3_EXIT_IBAT_THRESHOLD_REG 0x5F
  55. #define QG_S5_OCV_VALIDATE_MEAS_CTL1_REG 0x60
  56. #define ALLOW_S5_BIT BIT(7)
  57. #define QG_S7_PON_OCV_MEAS_CTL1_REG 0x64
  58. #define ADC_CONV_DLY_MASK GENMASK(3, 0)
  59. #define QG_ESR_MEAS_TRIG_REG 0x68
  60. #define HW_ESR_MEAS_START_BIT BIT(0)
  61. #define QG_S7_PON_OCV_V_DATA0_REG 0x70
  62. #define QG_S7_PON_OCV_I_DATA0_REG 0x72
  63. #define QG_S3_GOOD_OCV_V_DATA0_REG 0x74
  64. #define QG_S3_GOOD_OCV_I_DATA0_REG 0x76
  65. #define QG_PRE_ESR_V_DATA0_REG 0x78
  66. #define QG_PRE_ESR_I_DATA0_REG 0x7A
  67. #define QG_POST_ESR_V_DATA0_REG 0x7C
  68. #define QG_POST_ESR_I_DATA0_REG 0x7E
  69. #define QG_S2_NORMAL_AVG_V_DATA0_REG 0x80
  70. #define QG_S2_NORMAL_AVG_I_DATA0_REG 0x82
  71. #define QG_V_ACCUM_DATA0_RT_REG 0x88
  72. #define QG_I_ACCUM_DATA0_RT_REG 0x8B
  73. #define QG_ACCUM_CNT_RT_REG 0x8E
  74. #define QG_V_FIFO0_DATA0_REG 0x90
  75. #define QG_I_FIFO0_DATA0_REG 0xA0
  76. #define QG_SOC_MONOTONIC_REG 0xBF
  77. #define QG_LAST_ADC_V_DATA0_REG 0xC0
  78. #define QG_LAST_ADC_I_DATA0_REG 0xC2
  79. #define QG_LAST_BURST_AVG_I_DATA0_REG 0xC6
  80. #define QG_LAST_S3_SLEEP_V_DATA0_REG 0xCC
  81. /* SDAM offsets */
  82. #define QG_SDAM_VALID_OFFSET 0x46 /* 1-byte 0x46 */
  83. #define QG_SDAM_SOC_OFFSET 0x47 /* 1-byte 0x47 */
  84. #define QG_SDAM_TEMP_OFFSET 0x48 /* 2-byte 0x48-0x49 */
  85. #define QG_SDAM_RBAT_OFFSET 0x4A /* 2-byte 0x4A-0x4B */
  86. #define QG_SDAM_OCV_OFFSET 0x4C /* 4-byte 0x4C-0x4F */
  87. #define QG_SDAM_IBAT_OFFSET 0x50 /* 4-byte 0x50-0x53 */
  88. #define QG_SDAM_TIME_OFFSET 0x54 /* 4-byte 0x54-0x57 */
  89. #define QG_SDAM_CYCLE_COUNT_OFFSET 0x58 /* 16-byte 0x58-0x67 */
  90. #define QG_SDAM_LEARNED_CAPACITY_OFFSET 0x68 /* 2-byte 0x68-0x69 */
  91. #define QG_SDAM_ESR_CHARGE_DELTA_OFFSET 0x6A /* 4-byte 0x6A-0x6D */
  92. #define QG_SDAM_ESR_DISCHARGE_DELTA_OFFSET 0x6E /* 4-byte 0x6E-0x71 */
  93. #define QG_SDAM_ESR_CHARGE_SF_OFFSET 0x72 /* 2-byte 0x72-0x73 */
  94. #define QG_SDAM_ESR_DISCHARGE_SF_OFFSET 0x74 /* 2-byte 0x74-0x75 */
  95. #define QG_SDAM_BATT_AGE_LEVEL_OFFSET 0x76 /* 1-byte 0x76 */
  96. #define QG_SDAM_MAGIC_OFFSET 0x80 /* 4-byte 0x80-0x83 */
  97. #define QG_SDAM_FLASH_OCV_OFFSET 0x84 /* 1-byte 0x84 */
  98. #define QG_SDAM_MAX_OFFSET 0xA4
  99. /* Below offset is used by PBS */
  100. #define QG_SDAM_PON_OCV_OFFSET 0xBC /* 2-byte 0xBC-0xBD */
  101. #endif