eclib.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef _EC_LIB_H_
  2. #define _EC_LIB_H_
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include <fcntl.h>
  6. #include <stdio.h>
  7. #include <unistd.h>
  8. #define EC_TIME_OUT 0x1000
  9. //
  10. // The EC implements an embedded controller interface at ports 0x60/0x64 and a ACPI compliant
  11. // system management controller at ports 0x62/0x66. Port 0x66 is the command and status port,
  12. // port 0x62 is the data port.
  13. //
  14. #define EC_D_PORT 0x62
  15. #define EC_C_PORT 0x66
  16. //
  17. // Status Port 0x62
  18. //
  19. #define EC_S_OVR_TMP 0x80 // Current CPU temperature exceeds the threshold
  20. #define EC_S_SMI_EVT 0x40 // SMI event is pending
  21. #define EC_S_SCI_EVT 0x20 // SCI event is pending
  22. #define EC_S_BURST 0x10 // EC is in burst mode or normal mode
  23. #define EC_S_CMD 0x08 // Byte in data register is command/data
  24. #define EC_S_IGN 0x04 // Ignored
  25. #define EC_S_IBF 0x02 // Input buffer is full/empty
  26. #define EC_S_OBF 0x01 // Output buffer is full/empty
  27. //
  28. // EC commands that are issued to the EC through the command port (0x66).
  29. // New commands and command parameters should only be written by the host when IBF=0.
  30. // Data read from the EC data port is valid only when OBF=1.
  31. //
  32. #define EC_C_READ_MEM 0x80
  33. #define EC_C_WRITE_MEM 0x81
  34. #define EC_C_GET_QEVENT 0x84
  35. #define EC_ACPI_MODE_EN_CMD 0x86
  36. #define EC_ACPI_MODE_DIS_CMD 0x87
  37. //
  38. // EC IO base address
  39. //
  40. #define EC_IO_BASE 0x390
  41. //
  42. // Declare some functions to access EC
  43. //
  44. bool port_dev_init(void);
  45. void port_dev_exit(void);
  46. uint8_t read_ec_ram(uint8_t index);
  47. void write_ec_ram(uint8_t index, uint8_t value);
  48. uint8_t read_ec(uint16_t offset);
  49. void write_ec(uint16_t offset, uint8_t data);
  50. #endif