| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #ifndef _EC_LIB_H_
- #define _EC_LIB_H_
- #include <stdint.h>
- #include <stdbool.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <unistd.h>
- #define EC_TIME_OUT 0x1000
- //
- // The EC implements an embedded controller interface at ports 0x60/0x64 and a ACPI compliant
- // system management controller at ports 0x62/0x66. Port 0x66 is the command and status port,
- // port 0x62 is the data port.
- //
- #define EC_D_PORT 0x62
- #define EC_C_PORT 0x66
- //
- // Status Port 0x62
- //
- #define EC_S_OVR_TMP 0x80 // Current CPU temperature exceeds the threshold
- #define EC_S_SMI_EVT 0x40 // SMI event is pending
- #define EC_S_SCI_EVT 0x20 // SCI event is pending
- #define EC_S_BURST 0x10 // EC is in burst mode or normal mode
- #define EC_S_CMD 0x08 // Byte in data register is command/data
- #define EC_S_IGN 0x04 // Ignored
- #define EC_S_IBF 0x02 // Input buffer is full/empty
- #define EC_S_OBF 0x01 // Output buffer is full/empty
- //
- // EC commands that are issued to the EC through the command port (0x66).
- // New commands and command parameters should only be written by the host when IBF=0.
- // Data read from the EC data port is valid only when OBF=1.
- //
- #define EC_C_READ_MEM 0x80
- #define EC_C_WRITE_MEM 0x81
- #define EC_C_GET_QEVENT 0x84
- #define EC_ACPI_MODE_EN_CMD 0x86
- #define EC_ACPI_MODE_DIS_CMD 0x87
- //
- // EC IO base address
- //
- #define EC_IO_BASE 0x390
- //
- // Declare some functions to access EC
- //
- bool port_dev_init(void);
- void port_dev_exit(void);
- uint8_t read_ec_ram(uint8_t index);
- void write_ec_ram(uint8_t index, uint8_t value);
- uint8_t read_ec(uint16_t offset);
- void write_ec(uint16_t offset, uint8_t data);
- #endif
|