ec.h 1.1 KB

12345678910111213141516171819202122232425262728
  1. /* ACPI embedded-controller access (ports 0x62/0x66).
  2. *
  3. * The kernel has no ACPI interpreter, but the standard EC command interface
  4. * is simple enough to drive directly. Both the ThinkPad H8 (tpec.c) and the
  5. * Chrome OS EC (cros_ec.c) sit behind the same protocol:
  6. *
  7. * 0x80 read: command 0x80, register index, read the data byte
  8. * 0x81 write: command 0x81, register index, value
  9. *
  10. * The status port carries IBF (input buffer full) and OBF (output buffer
  11. * full). A pending output byte (an EC event) is drained before each command,
  12. * and every wait is bounded so a dead controller cannot stall the kernel.
  13. */
  14. #ifndef EC_H
  15. #define EC_H
  16. /* Read one EC RAM byte. Returns 0 on success, -1 when the EC did not
  17. * answer (no controller, timeout, or a stale output byte that never
  18. * cleared). */
  19. int ec_read(unsigned char reg, unsigned char *out);
  20. /* Write one EC RAM byte (ACPI "write EC RAM", command 0x81). */
  21. int ec_write(unsigned char reg, unsigned char val);
  22. /* Read a little-endian 16-bit value from two consecutive EC registers. */
  23. int ec_read16(unsigned char reg, unsigned int *out);
  24. #endif