ec_kb3310b.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * KB3310B Embedded Controller
  3. *
  4. * Copyright (C) 2008 Lemote Inc.
  5. * Author: liujl <liujl@lemote.com>, 2008-03-14
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #ifndef _EC_KB3310B_H
  13. #define _EC_KB3310B_H
  14. extern unsigned char ec_read(unsigned short addr);
  15. extern void ec_write(unsigned short addr, unsigned char val);
  16. extern int ec_query_seq(unsigned char cmd);
  17. extern int ec_query_event_num(void);
  18. extern int ec_get_event_num(void);
  19. typedef int (*sci_handler) (int status);
  20. extern sci_handler yeeloong_report_lid_status;
  21. #define SCI_IRQ_NUM 0x0A
  22. /*
  23. * The following registers are determined by the EC index configuration.
  24. * 1, fill the PORT_HIGH as EC register high part.
  25. * 2, fill the PORT_LOW as EC register low part.
  26. * 3, fill the PORT_DATA as EC register write data or get the data from it.
  27. */
  28. #define EC_IO_PORT_HIGH 0x0381
  29. #define EC_IO_PORT_LOW 0x0382
  30. #define EC_IO_PORT_DATA 0x0383
  31. /*
  32. * EC delay time is 500us for register and status access
  33. */
  34. #define EC_REG_DELAY 500 /* unit : us */
  35. #define EC_CMD_TIMEOUT 0x1000
  36. /*
  37. * EC access port for SCI communication
  38. */
  39. #define EC_CMD_PORT 0x66
  40. #define EC_STS_PORT 0x66
  41. #define EC_DAT_PORT 0x62
  42. #define CMD_INIT_IDLE_MODE 0xdd
  43. #define CMD_EXIT_IDLE_MODE 0xdf
  44. #define CMD_INIT_RESET_MODE 0xd8
  45. #define CMD_REBOOT_SYSTEM 0x8c
  46. #define CMD_GET_EVENT_NUM 0x84
  47. #define CMD_PROGRAM_PIECE 0xda
  48. /* temperature & fan registers */
  49. #define REG_TEMPERATURE_VALUE 0xF458
  50. #define REG_FAN_AUTO_MAN_SWITCH 0xF459
  51. #define BIT_FAN_AUTO 0
  52. #define BIT_FAN_MANUAL 1
  53. #define REG_FAN_CONTROL 0xF4D2
  54. #define BIT_FAN_CONTROL_ON (1 << 0)
  55. #define BIT_FAN_CONTROL_OFF (0 << 0)
  56. #define REG_FAN_STATUS 0xF4DA
  57. #define BIT_FAN_STATUS_ON (1 << 0)
  58. #define BIT_FAN_STATUS_OFF (0 << 0)
  59. #define REG_FAN_SPEED_HIGH 0xFE22
  60. #define REG_FAN_SPEED_LOW 0xFE23
  61. #define REG_FAN_SPEED_LEVEL 0xF4CC
  62. /* fan speed divider */
  63. #define FAN_SPEED_DIVIDER 480000 /* (60*1000*1000/62.5/2)*/
  64. /* battery registers */
  65. #define REG_BAT_DESIGN_CAP_HIGH 0xF77D
  66. #define REG_BAT_DESIGN_CAP_LOW 0xF77E
  67. #define REG_BAT_FULLCHG_CAP_HIGH 0xF780
  68. #define REG_BAT_FULLCHG_CAP_LOW 0xF781
  69. #define REG_BAT_DESIGN_VOL_HIGH 0xF782
  70. #define REG_BAT_DESIGN_VOL_LOW 0xF783
  71. #define REG_BAT_CURRENT_HIGH 0xF784
  72. #define REG_BAT_CURRENT_LOW 0xF785
  73. #define REG_BAT_VOLTAGE_HIGH 0xF786
  74. #define REG_BAT_VOLTAGE_LOW 0xF787
  75. #define REG_BAT_TEMPERATURE_HIGH 0xF788
  76. #define REG_BAT_TEMPERATURE_LOW 0xF789
  77. #define REG_BAT_RELATIVE_CAP_HIGH 0xF492
  78. #define REG_BAT_RELATIVE_CAP_LOW 0xF493
  79. #define REG_BAT_VENDOR 0xF4C4
  80. #define FLAG_BAT_VENDOR_SANYO 0x01
  81. #define FLAG_BAT_VENDOR_SIMPLO 0x02
  82. #define REG_BAT_CELL_COUNT 0xF4C6
  83. #define FLAG_BAT_CELL_3S1P 0x03
  84. #define FLAG_BAT_CELL_3S2P 0x06
  85. #define REG_BAT_CHARGE 0xF4A2
  86. #define FLAG_BAT_CHARGE_DISCHARGE 0x01
  87. #define FLAG_BAT_CHARGE_CHARGE 0x02
  88. #define FLAG_BAT_CHARGE_ACPOWER 0x00
  89. #define REG_BAT_STATUS 0xF4B0
  90. #define BIT_BAT_STATUS_LOW (1 << 5)
  91. #define BIT_BAT_STATUS_DESTROY (1 << 2)
  92. #define BIT_BAT_STATUS_FULL (1 << 1)
  93. #define BIT_BAT_STATUS_IN (1 << 0)
  94. #define REG_BAT_CHARGE_STATUS 0xF4B1
  95. #define BIT_BAT_CHARGE_STATUS_OVERTEMP (1 << 2)
  96. #define BIT_BAT_CHARGE_STATUS_PRECHG (1 << 1)
  97. #define REG_BAT_STATE 0xF482
  98. #define BIT_BAT_STATE_CHARGING (1 << 1)
  99. #define BIT_BAT_STATE_DISCHARGING (1 << 0)
  100. #define REG_BAT_POWER 0xF440
  101. #define BIT_BAT_POWER_S3 (1 << 2)
  102. #define BIT_BAT_POWER_ON (1 << 1)
  103. #define BIT_BAT_POWER_ACIN (1 << 0)
  104. /* other registers */
  105. /* Audio: rd/wr */
  106. #define REG_AUDIO_VOLUME 0xF46C
  107. #define REG_AUDIO_MUTE 0xF4E7
  108. #define REG_AUDIO_BEEP 0xF4D0
  109. /* USB port power or not: rd/wr */
  110. #define REG_USB0_FLAG 0xF461
  111. #define REG_USB1_FLAG 0xF462
  112. #define REG_USB2_FLAG 0xF463
  113. #define BIT_USB_FLAG_ON 1
  114. #define BIT_USB_FLAG_OFF 0
  115. /* LID */
  116. #define REG_LID_DETECT 0xF4BD
  117. #define BIT_LID_DETECT_ON 1
  118. #define BIT_LID_DETECT_OFF 0
  119. /* CRT */
  120. #define REG_CRT_DETECT 0xF4AD
  121. #define BIT_CRT_DETECT_PLUG 1
  122. #define BIT_CRT_DETECT_UNPLUG 0
  123. /* LCD backlight brightness adjust: 9 levels */
  124. #define REG_DISPLAY_BRIGHTNESS 0xF4F5
  125. /* Black screen Status */
  126. #define BIT_DISPLAY_LCD_ON 1
  127. #define BIT_DISPLAY_LCD_OFF 0
  128. /* LCD backlight control: off/restore */
  129. #define REG_BACKLIGHT_CTRL 0xF7BD
  130. #define BIT_BACKLIGHT_ON 1
  131. #define BIT_BACKLIGHT_OFF 0
  132. /* Reset the machine auto-clear: rd/wr */
  133. #define REG_RESET 0xF4EC
  134. #define BIT_RESET_ON 1
  135. /* Light the led: rd/wr */
  136. #define REG_LED 0xF4C8
  137. #define BIT_LED_RED_POWER (1 << 0)
  138. #define BIT_LED_ORANGE_POWER (1 << 1)
  139. #define BIT_LED_GREEN_CHARGE (1 << 2)
  140. #define BIT_LED_RED_CHARGE (1 << 3)
  141. #define BIT_LED_NUMLOCK (1 << 4)
  142. /* Test led mode, all led on/off */
  143. #define REG_LED_TEST 0xF4C2
  144. #define BIT_LED_TEST_IN 1
  145. #define BIT_LED_TEST_OUT 0
  146. /* Camera on/off */
  147. #define REG_CAMERA_STATUS 0xF46A
  148. #define BIT_CAMERA_STATUS_ON 1
  149. #define BIT_CAMERA_STATUS_OFF 0
  150. #define REG_CAMERA_CONTROL 0xF7B7
  151. #define BIT_CAMERA_CONTROL_OFF 0
  152. #define BIT_CAMERA_CONTROL_ON 1
  153. /* Wlan Status */
  154. #define REG_WLAN 0xF4FA
  155. #define BIT_WLAN_ON 1
  156. #define BIT_WLAN_OFF 0
  157. #define REG_DISPLAY_LCD 0xF79F
  158. /* SCI Event Number from EC */
  159. enum {
  160. EVENT_LID = 0x23, /* LID open/close */
  161. EVENT_DISPLAY_TOGGLE, /* Fn+F3 for display switch */
  162. EVENT_SLEEP, /* Fn+F1 for entering sleep mode */
  163. EVENT_OVERTEMP, /* Over-temperature happened */
  164. EVENT_CRT_DETECT, /* CRT is connected */
  165. EVENT_CAMERA, /* Camera on/off */
  166. EVENT_USB_OC2, /* USB2 Over Current occurred */
  167. EVENT_USB_OC0, /* USB0 Over Current occurred */
  168. EVENT_BLACK_SCREEN, /* Turn on/off backlight */
  169. EVENT_AUDIO_MUTE, /* Mute on/off */
  170. EVENT_DISPLAY_BRIGHTNESS,/* LCD backlight brightness adjust */
  171. EVENT_AC_BAT, /* AC & Battery relative issue */
  172. EVENT_AUDIO_VOLUME, /* Volume adjust */
  173. EVENT_WLAN, /* Wlan on/off */
  174. EVENT_END
  175. };
  176. #endif /* !_EC_KB3310B_H */