qci_battery.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* Header file for Quanta I2C Battery Driver
  2. *
  3. * Copyright (C) 2009 Quanta Computer Inc.
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. /*
  16. *
  17. * The Driver with I/O communications via the I2C Interface for ON2 of AP BU.
  18. * And it is only working on the nuvoTon WPCE775x Embedded Controller.
  19. *
  20. */
  21. #ifndef __QCI_BATTERY_H__
  22. #define __QCI_BATTERY_H__
  23. #define BAT_I2C_ADDRESS 0x1A
  24. #define BATTERY_ID_NAME "qci-i2cbat"
  25. #define EC_FLAG_ADAPTER_IN 0x01
  26. #define EC_FLAG_POWER_ON 0x02
  27. #define EC_FLAG_ENTER_S3 0x04
  28. #define EC_FLAG_ENTER_S4 0x08
  29. #define EC_FLAG_IN_STANDBY 0x10
  30. #define EC_FLAG_SYSTEM_ON 0x20
  31. #define EC_FLAG_WAIT_HWPG 0x40
  32. #define EC_FLAG_S5_POWER_ON 0x80
  33. #define MAIN_BATTERY_STATUS_BAT_DISCHRG 0x01
  34. #define MAIN_BATTERY_STATUS_BAT_CHARGING 0x02
  35. #define MAIN_BATTERY_STATUS_BAT_ABNORMAL 0x04
  36. #define MAIN_BATTERY_STATUS_BAT_IN 0x08
  37. #define MAIN_BATTERY_STATUS_BAT_FULL 0x10
  38. #define MAIN_BATTERY_STATUS_BAT_LOW 0x20
  39. #define MAIN_BATTERY_STATUS_BAT_SMB_VALID 0x80
  40. #define CHG_STATUS_BAT_CHARGE 0x01
  41. #define CHG_STATUS_BAT_PRECHG 0x02
  42. #define CHG_STATUS_BAT_OVERTEMP 0x04
  43. #define CHG_STATUS_BAT_TYPE 0x08
  44. #define CHG_STATUS_BAT_GWROK 0x10
  45. #define CHG_STATUS_BAT_INCHARGE 0x20
  46. #define CHG_STATUS_BAT_WAKECHRG 0x40
  47. #define CHG_STATUS_BAT_CHGTIMEOUT 0x80
  48. #define EC_ADAPTER_PRESENT 0x1
  49. #define EC_BAT_PRESENT 0x1
  50. #define EC_ADAPTER_NOT_PRESENT 0x0
  51. #define EC_BAT_NOT_PRESENT 0x0
  52. #define ECRAM_POWER_SOURCE 0x40
  53. #define ECRAM_CHARGER_ALARM 0x42
  54. #define ECRAM_BATTERY_STATUS 0x82
  55. #define ECRAM_BATTERY_CURRENT_LSB 0x83
  56. #define ECRAM_BATTERY_CURRENT_MSB 0x84
  57. #define ECRAM_BATTERY_VOLTAGE_LSB 0x87
  58. #define ECRAM_BATTERY_VOLTAGE_MSB 0x88
  59. #define ECRAM_BATTERY_CAPACITY 0x89
  60. #define ECRAM_BATTERY_TEMP_LSB 0x8C
  61. #define ECRAM_BATTERY_TEMP_MSB 0x8D
  62. #define ECRAM_BATTERY_EVENTS 0x99
  63. #define EC_EVENT_BATTERY 0x01
  64. #define EC_EVENT_CHARGER 0x02
  65. #define EC_EVENT_AC 0x10
  66. #define EC_EVENT_TIMER 0x40
  67. /* smbus access */
  68. #define SMBUS_READ_BYTE_PRTCL 0x07
  69. #define SMBUS_READ_WORD_PRTCL 0x09
  70. #define SMBUS_READ_BLOCK_PRTCL 0x0B
  71. /* smbus status code */
  72. #define SMBUS_OK 0x00
  73. #define SMBUS_DONE 0x80
  74. #define SMBUS_ALARM 0x40
  75. #define SMBUS_UNKNOW_FAILURE 0x07
  76. #define SMBUS_DEVICE_NOACK 0x10
  77. #define SMBUS_DEVICE_ERROR 0x11
  78. #define SMBUS_UNKNOW_ERROR 0x13
  79. #define SMBUS_TIME_OUT 0x18
  80. #define SMBUS_BUSY 0x1A
  81. /* ec ram mapping */
  82. #define ECRAM_SMB_PRTCL 0
  83. #define ECRAM_SMB_STS 1
  84. #define ECRAM_SMB_ADDR 2
  85. #define ECRAM_SMB_CMD 3
  86. #define ECRAM_SMB_DATA_START 4
  87. #define ECRAM_SMB_DATA0 4
  88. #define ECRAM_SMB_DATA1 5
  89. #define ECRAM_SMB_BCNT 36
  90. #define ECRAM_SMB_ALARM_ADDR 37
  91. #define ECRAM_SMB_ALARM_DATA0 38
  92. #define ECRAM_SMB_ALARM_DATA1 39
  93. /* smart battery commands */
  94. #define BATTERY_SLAVE_ADDRESS 0x16
  95. #define BATTERY_FULL_CAPACITY 0x10
  96. #define BATTERY_AVERAGE_TIME_TO_EMPTY 0x12
  97. #define BATTERY_AVERAGE_TIME_TO_FULL 0x13
  98. #define BATTERY_CYCLE_COUNT 0x17
  99. #define BATTERY_DESIGN_CAPACITY 0x18
  100. #define BATTERY_DESIGN_VOLTAGE 0x19
  101. #define BATTERY_SERIAL_NUMBER 0x1C
  102. #define BATTERY_MANUFACTURE_NAME 0x20
  103. #define BATTERY_DEVICE_NAME 0x21
  104. /* alarm bit */
  105. #define ALARM_REMAIN_CAPACITY 0x02
  106. #define ALARM_OVER_TEMP 0x10
  107. #define ALARM_OVER_CHARGE 0x80
  108. #endif