summaryrefslogtreecommitdiff
path: root/include/i2c_hid.h
diff options
context:
space:
mode:
authorShecky Lin <sheckylin@chromium.org>2020-03-11 15:15:46 +0800
committerCommit Bot <commit-bot@chromium.org>2020-03-17 12:11:46 +0000
commitc6f631c3e461cdafe5b643fa5d12415d67097ac6 (patch)
tree2df6ee9ff6f3da0353449dcfea21d3d3c38cdcfc /include/i2c_hid.h
parente5e676f641dec32ddf4b32d1b8f4f9636e31ff2a (diff)
downloadchrome-ec-c6f631c3e461cdafe5b643fa5d12415d67097ac6.tar.gz
i2c_hid_touchpad: Add basic structs and descriptors
This is part of a chain to add a common I2C HID interface for touchpads. The CL layouts basic struct, defines and HID descriptors that would be used by an I2C HID touchpad implementation. BUG=chromium:1008568 BRANCH=none TEST=Build and run on MCU to forward touchpad events to host through I2C HID. Change-Id: I89108f0cdce1a9a11bf1e26e43c6662959c7184e Signed-off-by: Shecky Lin <sheckylin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2094927
Diffstat (limited to 'include/i2c_hid.h')
-rw-r--r--include/i2c_hid.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/include/i2c_hid.h b/include/i2c_hid.h
new file mode 100644
index 0000000000..8568b42837
--- /dev/null
+++ b/include/i2c_hid.h
@@ -0,0 +1,67 @@
+/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * General definitions for I2C-HID
+ *
+ * For a complete reference, please see the following docs on
+ * https://docs.microsoft.com/
+ *
+ * 1. hid-over-i2c-protocol-spec-v1-0.docx
+ */
+#ifndef __CROS_EC_I2C_HID_H
+#define __CROS_EC_I2C_HID_H
+
+#include "common.h"
+#include "stdint.h"
+
+/*
+ * I2C-HID registers
+ *
+ * Except for I2C_HID_HID_DESC_REGISTER, fields in this section can be chosen
+ * freely so we just picked something that we are happy with.
+ *
+ * I2C_HID_HID_DESC_REGISTER is defined in the ACPI table so please make sure
+ * you have put in the same value there.
+ */
+#define I2C_HID_HID_DESC_REGISTER 0x0001
+#define I2C_HID_REPORT_DESC_REGISTER 0x1000
+#define I2C_HID_INPUT_REPORT_REGISTER 0x2000
+#define I2C_HID_COMMAND_REGISTER 0x3000
+#define I2C_HID_DATA_REGISTER 0x3000
+
+/* I2C-HID commands */
+#define I2C_HID_CMD_RESET 0x01
+#define I2C_HID_CMD_GET_REPORT 0x02
+#define I2C_HID_CMD_SET_REPORT 0x03
+#define I2C_HID_CMD_GET_IDLE 0x04
+#define I2C_HID_CMD_SET_IDLE 0x05
+#define I2C_HID_CMD_GET_PROTOCOL 0x06
+#define I2C_HID_CMD_SET_PROTOCOL 0x07
+#define I2C_HID_CMD_SET_POWER 0x08
+
+/* Common HID fields */
+#define I2C_HID_DESC_LENGTH sizeof(struct i2c_hid_descriptor)
+#define I2C_HID_BCD_VERSION 0x0100
+
+/* I2C-HID HID descriptor */
+struct __packed i2c_hid_descriptor {
+ uint16_t wHIDDescLength;
+ uint16_t bcdVersion;
+ uint16_t wReportDescLength;
+ uint16_t wReportDescRegister;
+ uint16_t wInputRegister;
+ uint16_t wMaxInputLength;
+ uint16_t wOutputRegister;
+ uint16_t wMaxOutputLength;
+ uint16_t wCommandRegister;
+ uint16_t wDataRegister;
+ uint16_t wVendorID;
+ uint16_t wProductID;
+ uint16_t wVersionID;
+ uint32_t reserved;
+};
+
+#endif /* __CROS_EC_I2C_HID_H */