cros_ec_dev.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * cros_ec_dev - expose the Chrome OS Embedded Controller to userspace
  3. *
  4. * Copyright (C) 2013 The Chromium OS Authors
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _CROS_EC_DEV_H_
  20. #define _CROS_EC_DEV_H_
  21. #include <linux/ioctl.h>
  22. #include <linux/types.h>
  23. /*
  24. * @version: Command version number (often 0)
  25. * @command: Command to send (EC_CMD_...)
  26. * @outdata: Outgoing data to EC
  27. * @outsize: Outgoing length in bytes
  28. * @indata: Where to put the incoming data from EC
  29. * @insize: Incoming length in bytes (filled in by EC)
  30. * @result: EC's response to the command (separate from communication failure)
  31. */
  32. struct cros_ec_command {
  33. uint32_t version;
  34. uint32_t command;
  35. const uint8_t *outdata;
  36. uint32_t outsize;
  37. uint8_t *indata;
  38. uint32_t insize;
  39. uint32_t result;
  40. };
  41. #define CROS_EC_DEV_IOC ':'
  42. #define CROS_EC_DEV_IOCXCMD _IOWR(':', 0, struct cros_ec_command)
  43. /*
  44. * @version: Command version number (often 0)
  45. * @command: Command to send (EC_CMD_...)
  46. * @outsize: Outgoing length in bytes
  47. * @insize: Max number of bytes to accept from EC
  48. * @result: EC's response to the command (separate from communication failure)
  49. * @data: Where to put the incoming data from EC and outgoing data to EC
  50. */
  51. struct cros_ec_command_v2 {
  52. uint32_t version;
  53. uint32_t command;
  54. uint32_t outsize;
  55. uint32_t insize;
  56. uint32_t result;
  57. uint8_t data[0];
  58. };
  59. #define CROS_EC_DEV_IOC_V2 0xEC
  60. #define CROS_EC_DEV_IOCXCMD_V2 _IOWR(CROS_EC_DEV_IOC_V2, 0, \
  61. struct cros_ec_command_v2)
  62. #define CROS_EC_DEV_RETRY 3
  63. #endif /* _CROS_EC_DEV_H_ */