h8.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:9k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  */
  3. #ifndef __H8_H__
  4. #define __H8_H__
  5. /*
  6.  * Register address and offsets
  7.  */
  8. #define H8_BASE_ADDR                   0x170            /* default */
  9. #define H8_IRQ        9                /* default */
  10. #define H8_STATUS_REG_OFF              0x4              
  11. #define H8_CMD_REG_OFF                 0x4
  12. #define H8_DATA_REG_OFF                0x0
  13. /* H8 register bit definitions */
  14. /* status register */
  15. #define H8_OFULL                       0x1              /* output data register full */
  16. #define H8_IFULL                       0x2              /* input data register full */
  17. #define H8_CMD                         0x8              /* command / not data */
  18. #define H8_INTR                        0xfa
  19. #define H8_NACK                        0xfc
  20. #define H8_BYTE_LEVEL_ACK              0xfd
  21. #define H8_CMD_ACK                     0xfe
  22. #define H8_SYNC_BYTE                   0x99
  23. /*
  24.  * H8 command definitions
  25.  */
  26. /* System info commands */
  27. #define H8_SYNC                         0x0
  28. #define H8_RD_SN                        0x1
  29. #define H8_RD_ENET_ADDR                 0x2
  30. #define H8_RD_HW_VER                    0x3
  31. #define H8_RD_MIC_VER                   0x4
  32. #define H8_RD_MAX_TEMP                  0x5
  33. #define H8_RD_MIN_TEMP                  0x6
  34. #define H8_RD_CURR_TEMP                 0x7
  35. #define H8_RD_SYS_VARIENT               0x8
  36. #define H8_RD_PWR_ON_CYCLES             0x9
  37. #define H8_RD_PWR_ON_SECS               0xa
  38. #define H8_RD_RESET_STATUS              0xb
  39. #define H8_RD_PWR_DN_STATUS             0xc
  40. #define H8_RD_EVENT_STATUS              0xd
  41. #define H8_RD_ROM_CKSM                  0xe
  42. #define H8_RD_EXT_STATUS                0xf
  43. #define H8_RD_USER_CFG                  0x10
  44. #define H8_RD_INT_BATT_VOLT             0x11
  45. #define H8_RD_DC_INPUT_VOLT             0x12
  46. #define H8_RD_HORIZ_PTR_VOLT            0x13
  47. #define H8_RD_VERT_PTR_VOLT             0x14
  48. #define H8_RD_EEPROM_STATUS             0x15
  49. #define H8_RD_ERR_STATUS                0x16
  50. #define H8_RD_NEW_BUSY_SPEED            0x17
  51. #define H8_RD_CONFIG_INTERFACE          0x18
  52. #define H8_RD_INT_BATT_STATUS           0x19
  53. #define H8_RD_EXT_BATT_STATUS           0x1a
  54. #define H8_RD_PWR_UP_STATUS             0x1b
  55. #define H8_RD_EVENT_STATUS_MASK         0x56
  56. /* Read/write/modify commands */
  57. #define H8_CTL_EMU_BITPORT              0x32
  58. #define H8_DEVICE_CONTROL               0x21
  59. #define H8_CTL_TFT_BRT_DC               0x22
  60. #define H8_CTL_WATCHDOG                 0x23
  61. #define H8_CTL_MIC_PROT                 0x24
  62. #define H8_CTL_INT_BATT_CHG             0x25
  63. #define H8_CTL_EXT_BATT_CHG             0x26
  64. #define H8_CTL_MARK_SPACE               0x27
  65. #define H8_CTL_MOUSE_SENSITIVITY        0x28
  66. #define H8_CTL_DIAG_MODE                0x29
  67. #define H8_CTL_IDLE_AND_BUSY_SPDS       0x2a
  68. #define H8_CTL_TFT_BRT_BATT             0x2b
  69. #define H8_CTL_UPPER_TEMP               0x2c
  70. #define H8_CTL_LOWER_TEMP               0x2d
  71. #define H8_CTL_TEMP_CUTOUT              0x2e
  72. #define H8_CTL_WAKEUP                   0x2f
  73. #define H8_CTL_CHG_THRESHOLD            0x30
  74. #define H8_CTL_TURBO_MODE               0x31
  75. #define H8_SET_DIAG_STATUS              0x40
  76. #define H8_SOFTWARE_RESET               0x41
  77. #define H8_RECAL_PTR                    0x42
  78. #define H8_SET_INT_BATT_PERCENT         0x43
  79. #define H8_WRT_CFG_INTERFACE_REG        0x45
  80. #define H8_WRT_EVENT_STATUS_MASK        0x57
  81. #define H8_ENTER_POST_MODE              0x46
  82. #define H8_EXIT_POST_MODE               0x47
  83. /* Block transfer commands */
  84. #define H8_RD_EEPROM                    0x50
  85. #define H8_WRT_EEPROM                   0x51
  86. #define H8_WRT_TO_STATUS_DISP           0x52
  87. #define H8_DEFINE_SPC_CHAR              0x53
  88.  
  89. /* Generic commands */
  90. #define H8_DEFINE_TABLE_STRING_ENTRY    0x60
  91. /* Battery control commands */
  92. #define H8_PERFORM_EMU_CMD              0x70
  93. #define H8_EMU_RD_REG                   0x71
  94. #define H8_EMU_WRT_REG                  0x72
  95. #define H8_EMU_RD_RAM                   0x73
  96. #define H8_EMU_WRT_RAM                  0x74
  97. #define H8_BQ_RD_REG                    0x75
  98. #define H8_BQ_WRT_REG                   0x76
  99. /* System admin commands */
  100. #define H8_PWR_OFF                      0x80
  101. /*
  102.  * H8 command related definitions
  103.  */
  104. /* device control argument bits */
  105. #define H8_ENAB_EXTSMI                  0x1
  106. #define H8_DISAB_IRQ                    0x2
  107. #define H8_ENAB_FLASH_WRT               0x4
  108. #define H8_ENAB_THERM                   0x8
  109. #define H8_ENAB_INT_PTR                 0x10
  110. #define H8_ENAB_LOW_SPD_IND             0x20
  111. #define H8_ENAB_EXT_PTR                 0x40
  112. #define H8_DISAB_PWR_OFF_SW             0x80
  113. #define H8_POWER_OFF 0x80
  114. /* H8 read event status bits */
  115. #define H8_DC_CHANGE                    0x1
  116. #define H8_INT_BATT_LOW                 0x2
  117. #define H8_INT_BATT_CHARGE_THRESHOLD    0x4
  118. #define H8_INT_BATT_CHARGE_STATE        0x8
  119. #define H8_INT_BATT_STATUS              0x10
  120. #define H8_EXT_BATT_CHARGE_STATE        0x20
  121. #define H8_EXT_BATT_LOW                 0x40
  122. #define H8_EXT_BATT_STATUS              0x80
  123. #define H8_THERMAL_THRESHOLD            0x100
  124. #define H8_WATCHDOG                     0x200
  125. #define H8_DOCKING_STATION_STATUS       0x400
  126. #define H8_EXT_MOUSE_OR_CASE_SWITCH     0x800
  127. #define H8_KEYBOARD                     0x1000
  128. #define H8_BATT_CHANGE_OVER             0x2000
  129. #define H8_POWER_BUTTON                 0x4000
  130. #define H8_SHUTDOWN                     0x8000
  131. /* H8 control idle and busy speeds */
  132. #define H8_SPEED_LOW                    0x1
  133. #define H8_SPEED_MED                    0x2
  134. #define H8_SPEED_HI                     0x3
  135. #define H8_SPEED_LOCKED                 0x80
  136. #define H8_MAX_CMD_SIZE                 18      
  137. #define H8_Q_ALLOC_AMOUNT               10      
  138. /* H8 state field values */
  139. #define H8_IDLE                         1
  140. #define H8_XMIT                         2
  141. #define H8_RCV                          3
  142. #define H8_RESYNC                       4
  143. #define H8_INTR_MODE                    5
  144. /* Mask values for control functions */
  145. #define UTH_HYSTERESIS                  5
  146. #define DEFAULT_UTHERMAL_THRESHOLD      115
  147. #define H8_TIMEOUT_INTERVAL 30
  148. #define H8_RUN                          4
  149. #define H8_GET_MAX_TEMP                 0x1
  150. #define H8_GET_CURR_TEMP                0x2
  151. #define H8_GET_UPPR_THRMAL_THOLD        0x4
  152. #define H8_GET_ETHERNET_ADDR            0x8
  153. #define H8_SYNC_OP                      0x10 
  154. #define H8_SET_UPPR_THRMAL_THOLD        0x20
  155. #define H8_GET_INT_BATT_STAT            0x40
  156. #define H8_GET_CPU_SPD                  0x80
  157. #define H8_MANAGE_UTHERM                0x100 
  158. #define H8_MANAGE_LTHERM                0x200 
  159. #define H8_HALT                         0x400 
  160. #define H8_CRASH                        0x800 
  161. #define H8_GET_EXT_STATUS               0x10000
  162. #define H8_MANAGE_QUIET                 0x20000
  163. #define H8_MANAGE_SPEEDUP               0x40000
  164. #define H8_MANAGE_BATTERY               0x80000
  165. #define H8_SYSTEM_DELAY_TEST            0x100000
  166. #define H8_POWER_SWITCH_TEST            0x200000
  167. /* CPU speeds and clock divisor values */
  168. #define MHZ_14                           5
  169. #define MHZ_28                           4
  170. #define MHZ_57                           3
  171. #define MHZ_115                          2
  172. #define MHZ_230                          0 
  173. /*
  174.  * H8 data
  175.  */
  176. struct h8_data {
  177.         u_int           ser_num;
  178.         u_char          ether_add[6];
  179.         u_short         hw_ver;
  180.         u_short         mic_ver;
  181.         u_short         max_tmp;
  182.         u_short         min_tmp;
  183.         u_short         cur_tmp;
  184.         u_int           sys_var;
  185.         u_int           pow_on;
  186.         u_int           pow_on_secs;
  187.         u_char          reset_status;
  188.         u_char          pwr_dn_status;
  189.         u_short         event_status;
  190.         u_short         rom_cksm;
  191.         u_short         ext_status;
  192.         u_short         u_cfg;
  193.         u_char          ibatt_volt;
  194.         u_char          dc_volt;
  195.         u_char          ptr_horiz;
  196.         u_char          ptr_vert;
  197.         u_char          eeprom_status;
  198.         u_char          error_status;
  199.         u_char          new_busy_speed;
  200.         u_char          cfg_interface;
  201.         u_short         int_batt_status;
  202.         u_short         ext_batt_status;
  203.         u_char          pow_up_status;
  204.         u_char          event_status_mask;
  205. };
  206. /*
  207.  * H8 command buffers
  208.  */
  209. typedef struct h8_cmd_q {
  210.         struct list_head link;          /* double linked list */
  211.         int             ncmd;           /* number of bytes in command */
  212.         int             nrsp;           /* number of bytes in response */
  213.         int             cnt;            /* number of bytes sent/received */
  214.         int             nacks;          /* number of byte level acks */
  215.         u_char          cmdbuf[H8_MAX_CMD_SIZE]; /* buffer to store command */
  216.         u_char          rcvbuf[H8_MAX_CMD_SIZE]; /* buffer to store response */
  217. } h8_cmd_q_t;
  218. union   intr_buf {
  219.         u_char  byte[2];
  220.         u_int   word;
  221. };
  222. #endif /* __H8_H_ */