cros_ec_lpc_reg.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * cros_ec_lpc_reg - LPC access to the Chrome OS Embedded Controller
  3. *
  4. * Copyright (C) 2016 Google, Inc
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * This driver uses the Chrome OS EC byte-level message-based protocol for
  16. * communicating the keyboard state (which keys are pressed) from a keyboard EC
  17. * to the AP over some bus (such as i2c, lpc, spi). The EC does debouncing,
  18. * but everything else (including deghosting) is done here. The main
  19. * motivation for this is to keep the EC firmware as simple as possible, since
  20. * it cannot be easily upgraded and EC flash/IRAM space is relatively
  21. * expensive.
  22. */
  23. #ifndef __CROS_EC_LPC_REG_H
  24. #define __CROS_EC_LPC_REG_H
  25. /**
  26. * cros_ec_lpc_read_bytes - Read bytes from a given LPC-mapped address.
  27. * Returns 8-bit checksum of all bytes read.
  28. *
  29. * @offset: Base read address
  30. * @length: Number of bytes to read
  31. * @dest: Destination buffer
  32. */
  33. u8 cros_ec_lpc_read_bytes(unsigned int offset, unsigned int length, u8 *dest);
  34. /**
  35. * cros_ec_lpc_write_bytes - Write bytes to a given LPC-mapped address.
  36. * Returns 8-bit checksum of all bytes written.
  37. *
  38. * @offset: Base write address
  39. * @length: Number of bytes to write
  40. * @msg: Write data buffer
  41. */
  42. u8 cros_ec_lpc_write_bytes(unsigned int offset, unsigned int length, u8 *msg);
  43. /**
  44. * cros_ec_lpc_reg_init
  45. *
  46. * Initialize register I/O.
  47. */
  48. void cros_ec_lpc_reg_init(void);
  49. /**
  50. * cros_ec_lpc_reg_destroy
  51. *
  52. * Cleanup reg I/O.
  53. */
  54. void cros_ec_lpc_reg_destroy(void);
  55. #endif /* __CROS_EC_LPC_REG_H */