summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBolat Dinc <bolat.dinc@intel.com>2015-03-26 12:15:18 -0700
committerChromeOS bot <3su6n15k.default@developer.gserviceaccount.com>2015-10-21 18:11:18 +0000
commit61faba40e6885467e29ef2d6af19f79a4cf15bae (patch)
treedde092f9afb614aaf54d1b06238d7a0b92564052
parent67846f9e349a379660dcc909747dfd6365995d42 (diff)
downloadchrome-ec-61faba40e6885467e29ef2d6af19f79a4cf15bae.tar.gz
driver: Add L3GD20H gyrometer basic driver support
BUG=chrome-os-partner:40465 BRANCH=None TEST=Added Gyro config to test L3GD20H Gyro sensor in Strago. Able to read the gyro data from "accelinfo" console command. Rotated the sensor in X,Y,Z axis, respective axis values change. Fits into the existing accel/gyro framework. Change-Id: I19369560ddad5160c2fc9c7ef9823bd37b5389fa Signed-off-by: Bolat Dinc <bolat.dinc@intel.com> Signed-off-by: Divya Jyothi <divya.jyothi@intel.com> Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/307477 Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/strago/board.c26
-rw-r--r--driver/build.mk3
-rw-r--r--driver/gyro_l3gd20h.c439
-rw-r--r--driver/gyro_l3gd20h.h102
-rw-r--r--include/config.h3
-rw-r--r--include/ec_commands.h1
6 files changed, 574 insertions, 0 deletions
diff --git a/board/strago/board.c b/board/strago/board.c
index 76f1d4a3d3..7ca4663aad 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -11,6 +11,7 @@
#include "charge_state.h"
#include "driver/accel_kxcj9.h"
#include "driver/als_isl29035.h"
+#include "driver/gyro_l3gd20h.h"
#include "driver/temp_sensor/tmp432.h"
#include "extpower.h"
#include "gpio.h"
@@ -123,6 +124,13 @@ BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT);
static struct mutex g_kxcj9_mutex[2];
struct kxcj9_data g_kxcj9_data[2];
+#ifdef CONFIG_GYRO_L3GD20H
+/* Gyro sensor */
+/* l3gd20h mutex and local/private data*/
+static struct mutex g_l3gd20h_mutex;
+struct l3gd20_data g_l3gd20h_data;
+#endif
+
/* Matrix to rotate accelrator into standard reference frame */
const matrix_3x3_t base_standard_ref = {
{ 0, FLOAT_TO_FP(1), 0},
@@ -169,6 +177,24 @@ struct motion_sensor_t motion_sensors[] = {
.ec_rate = SUSPEND_SAMPLING_INTERVAL,
}
},
+#ifdef CONFIG_GYRO_L3GD20H
+ {.name = "Lid Gyro",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_L3GD20H,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &l3gd20h_drv,
+ .mutex = &g_l3gd20h_mutex,
+ .drv_data = &g_l3gd20h_data,
+ .i2c_addr = L3GD20_ADDR1,
+ .rot_standard_ref = NULL,
+ .default_config = {
+ .odr = 190000,
+ .range = 2000,
+ .ec_rate = SUSPEND_SAMPLING_INTERVAL,
+ }
+ },
+#endif
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
diff --git a/driver/build.mk b/driver/build.mk
index 4992ced8a7..d9875d6d85 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -11,6 +11,9 @@ driver-$(CONFIG_ACCEL_KXCJ9)+=accel_kxcj9.o
driver-$(CONFIG_ACCELGYRO_LSM6DS0)+=accelgyro_lsm6ds0.o
driver-$(CONFIG_ACCELGYRO_BMI160)+=accelgyro_bmi160.o
+# Gyrometers
+driver-$(CONFIG_GYRO_L3GD20H)+=gyro_l3gd20h.o
+
# ALS drivers
driver-$(CONFIG_ALS_ISL29035)+=als_isl29035.o
driver-$(CONFIG_ALS_OPT3001)+=als_opt3001.o
diff --git a/driver/gyro_l3gd20h.c b/driver/gyro_l3gd20h.c
new file mode 100644
index 0000000000..0f63a93ced
--- /dev/null
+++ b/driver/gyro_l3gd20h.c
@@ -0,0 +1,439 @@
+/* Copyright 2015 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.
+ */
+
+/**
+ * L3GD20H gyro module for Chrome EC 3D digital gyroscope.
+ */
+
+#include "accelgyro.h"
+#include "common.h"
+#include "console.h"
+#include "driver/gyro_l3gd20h.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "task.h"
+#include "util.h"
+
+#define CPUTS(outstr) cputs(CC_ACCEL, outstr)
+#define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ## args)
+
+/*
+ * Struct for pairing an engineering value with the register value for a
+ * parameter.
+ */
+struct gyro_param_pair {
+ int val; /* Value in engineering units. */
+ int reg_val; /* Corresponding register value. */
+};
+
+/*
+ * List of angular rate range values in +/-dps's
+ * and their associated register values.
+ */
+const struct gyro_param_pair dps_ranges[] = {
+ {245, L3GD20_DPS_SEL_245},
+ {500, L3GD20_DPS_SEL_500},
+ {2000, L3GD20_DPS_SEL_2000_0},
+ {2000, L3GD20_DPS_SEL_2000_1}
+};
+
+static inline const struct gyro_param_pair *get_range_table(
+ enum motionsensor_type type, int *psize)
+{
+ if (psize)
+ *psize = ARRAY_SIZE(dps_ranges);
+ return dps_ranges;
+}
+
+/* List of ODR values in mHz and their associated register values. */
+const struct gyro_param_pair gyro_odr[] = {
+ {0, L3GD20_ODR_PD | L3GD20_LOW_ODR_MASK},
+ {12500, L3GD20_ODR_12_5HZ | L3GD20_ODR_PD_MASK | L3GD20_LOW_ODR_MASK},
+ {25000, L3GD20_ODR_25HZ | L3GD20_ODR_PD_MASK | L3GD20_LOW_ODR_MASK},
+ {50000, L3GD20_ODR_50HZ_0 | L3GD20_ODR_PD_MASK | L3GD20_LOW_ODR_MASK},
+ {50000, L3GD20_ODR_50HZ_1 | L3GD20_ODR_PD_MASK | L3GD20_LOW_ODR_MASK},
+ {100000, L3GD20_ODR_100HZ | L3GD20_ODR_PD_MASK},
+ {200000, L3GD20_ODR_200HZ | L3GD20_ODR_PD_MASK},
+ {400000, L3GD20_ODR_400HZ | L3GD20_ODR_PD_MASK},
+ {800000, L3GD20_ODR_800HZ | L3GD20_ODR_PD_MASK},
+};
+
+static inline const struct gyro_param_pair *get_odr_table(
+ enum motionsensor_type type, int *psize)
+{
+ if (psize)
+ *psize = ARRAY_SIZE(gyro_odr);
+ return gyro_odr;
+}
+
+static inline int get_ctrl_reg(enum motionsensor_type type)
+{
+ return L3GD20_CTRL_REG1;
+}
+
+static inline int get_xyz_reg(enum motionsensor_type type)
+{
+ return L3GD20_OUT_X_L | (1 << 7);
+}
+
+/**
+ * @return reg value that matches the given engineering value passed in.
+ * The round_up flag is used to specify whether to round up or down.
+ * Note, this function always returns a valid reg value. If the request is
+ * outside the range of values, it returns the closest valid reg value.
+ */
+static int get_reg_val(const int eng_val, const int round_up,
+ const struct gyro_param_pair *pairs, const int size)
+{
+ int i;
+ for (i = 0; i < size - 1; i++) {
+ if (eng_val <= pairs[i].val)
+ break;
+
+ if (eng_val < pairs[i+1].val) {
+ if (round_up)
+ i += 1;
+ break;
+ }
+ }
+ return pairs[i].reg_val;
+}
+
+/**
+ * @return engineering value that matches the given reg val
+ */
+static int get_engineering_val(const int reg_val,
+ const struct gyro_param_pair *pairs, const int size)
+{
+ int i;
+ for (i = 0; i < size; i++) {
+ if (reg_val == pairs[i].reg_val)
+ break;
+ }
+ return pairs[i].val;
+}
+
+/**
+ * Read register from Gyrometer.
+ */
+static inline int raw_read8(const int addr, const int reg, int *data_ptr)
+{
+ return i2c_read8(I2C_PORT_GYRO, addr, reg, data_ptr);
+}
+
+/**
+ * Write register from Gyrometer.
+ */
+static inline int raw_write8(const int addr, const int reg, int data)
+{
+ return i2c_write8(I2C_PORT_GYRO, addr, reg, data);
+}
+
+static int set_range(const struct motion_sensor_t *s,
+ int range,
+ int rnd)
+{
+ int ret, ctrl_val, range_tbl_size;
+ uint8_t ctrl_reg, reg_val;
+ const struct gyro_param_pair *ranges;
+ struct l3gd20_data *data = (struct l3gd20_data *)s->drv_data;
+
+ ctrl_reg = L3GD20_CTRL_REG4;
+ ranges = get_range_table(s->type, &range_tbl_size);
+
+ reg_val = get_reg_val(range, rnd, ranges, range_tbl_size);
+
+ /*
+ * Lock Gyro resource to prevent another task from attempting
+ * to write Gyro parameters until we are done.
+ */
+ mutex_lock(s->mutex);
+
+ ret = raw_read8(s->i2c_addr, ctrl_reg, &ctrl_val);
+ if (ret != EC_SUCCESS)
+ goto gyro_cleanup;
+
+ ctrl_val = (ctrl_val & ~L3GD20_RANGE_MASK) | reg_val;
+ ret = raw_write8(s->i2c_addr, ctrl_reg, ctrl_val);
+
+ /* Now that we have set the range, update the driver's value. */
+ if (ret == EC_SUCCESS)
+ data->base.range = get_engineering_val(reg_val, ranges,
+ range_tbl_size);
+
+gyro_cleanup:
+ mutex_unlock(s->mutex);
+ return EC_SUCCESS;
+}
+
+static int get_range(const struct motion_sensor_t *s, int *range)
+{
+ struct l3gd20_data *data = (struct l3gd20_data *)s->drv_data;
+
+ return data->base.range;
+}
+
+static int set_resolution(const struct motion_sensor_t *s,
+ int res,
+ int rnd)
+{
+ /* Only one resolution, L3GD20_RESOLUTION, so nothing to do. */
+ return EC_SUCCESS;
+}
+
+static int get_resolution(const struct motion_sensor_t *s,
+ int *res)
+{
+ *res = L3GD20_RESOLUTION;
+ return EC_SUCCESS;
+}
+
+static int set_data_rate(const struct motion_sensor_t *s,
+ int rate,
+ int rnd)
+{
+ int ret, val, odr_tbl_size;
+ uint8_t ctrl_reg, reg_val;
+ const struct gyro_param_pair *data_rates;
+ struct l3gd20_data *data = s->drv_data;
+
+ ctrl_reg = get_ctrl_reg(s->type);
+ data_rates = get_odr_table(s->type, &odr_tbl_size);
+ reg_val = get_reg_val(rate, rnd, data_rates, odr_tbl_size);
+
+ /*
+ * Lock gyro resource to prevent another task from attempting
+ * to write gyro parameters until we are done.
+ */
+ mutex_lock(s->mutex);
+
+ ret = raw_read8(s->i2c_addr, ctrl_reg, &val);
+ if (ret != EC_SUCCESS)
+ goto gyro_cleanup;
+
+ val = (val & ~(L3GD20_ODR_MASK | L3GD20_ODR_PD_MASK)) |
+ (reg_val & ~L3GD20_LOW_ODR_MASK);
+ ret = raw_write8(s->i2c_addr, ctrl_reg, val);
+
+ /* Now that we have set the odr, update the driver's value. */
+ if (ret == EC_SUCCESS)
+ data->base.odr = get_engineering_val(reg_val, data_rates,
+ odr_tbl_size);
+
+ ret = raw_read8(s->i2c_addr, L3GD20_LOW_ODR, &val);
+ if (ret != EC_SUCCESS)
+ goto gyro_cleanup;
+
+ /* We need to clear low_ODR bit for higher data rates */
+ if (reg_val & L3GD20_LOW_ODR_MASK)
+ val |= 1;
+ else
+ val &= ~1;
+
+ ret = raw_write8(s->i2c_addr, L3GD20_LOW_ODR, val);
+ if (ret != EC_SUCCESS)
+ goto gyro_cleanup;
+
+ /* CTRL_REG5 24h
+ * [7] low-power mode = 0;
+ * [6] fifo disabled = 0;
+ * [5] Stop on fth = 0;
+ * [4] High pass filter enable = 1;
+ * [3:2] int1_sel = 0;
+ * [1:0] out_sel = 1;
+ */
+ ret = raw_read8(s->i2c_addr, L3GD20_CTRL_REG5, &val);
+ if (ret != EC_SUCCESS)
+ goto gyro_cleanup;
+
+ val |= (1 << 4); /* high-pass filter enabled */
+ val |= (1 << 0); /* data in data reg are high-pass filtered */
+ ret = raw_write8(s->i2c_addr, L3GD20_CTRL_REG5, val);
+ if (ret != EC_SUCCESS)
+ goto gyro_cleanup;
+
+ ret = raw_read8(s->i2c_addr, L3GD20_CTRL_REG2, &val);
+ if (ret != EC_SUCCESS)
+ goto gyro_cleanup;
+
+ /*
+ * Table 25. High pass filter mode configuration
+ * Table 26. High pass filter cut off frequency configuration
+ */
+ val &= 0xf0;
+ val |= 0x04;
+ ret = raw_write8(s->i2c_addr, L3GD20_CTRL_REG2, val);
+
+gyro_cleanup:
+ mutex_unlock(s->mutex);
+ return ret;
+}
+
+static int get_data_rate(const struct motion_sensor_t *s,
+ int *rate)
+{
+ struct l3gd20_data *data = (struct l3gd20_data *)s->drv_data;
+
+ *rate = data->base.odr;
+ return EC_SUCCESS;
+}
+
+static int set_offset(const struct motion_sensor_t *s,
+ const int16_t *offset,
+ int16_t temp)
+{
+ /* temperature is ignored */
+ struct l3gd20_data *data = s->drv_data;
+ data->offset[X] = offset[X];
+ data->offset[Y] = offset[Y];
+ data->offset[Z] = offset[Z];
+ return EC_SUCCESS;
+}
+
+static int get_offset(const struct motion_sensor_t *s,
+ int16_t *offset,
+ int16_t *temp)
+{
+ struct l3gd20_data *data = s->drv_data;
+ offset[X] = data->offset[X];
+ offset[Y] = data->offset[Y];
+ offset[Z] = data->offset[Z];
+ *temp = EC_MOTION_SENSE_INVALID_CALIB_TEMP;
+ return EC_SUCCESS;
+}
+
+#ifdef CONFIG_ACCEL_INTERRUPTS
+static int set_interrupt(const struct motion_sensor_t *s,
+ unsigned int threshold)
+{
+ /* Currently unsupported. */
+ return EC_ERROR_UNKNOWN;
+}
+#endif
+
+static int is_data_ready(const struct motion_sensor_t *s, int *ready)
+{
+ int ret, tmp;
+
+ ret = raw_read8(s->i2c_addr, L3GD20_STATUS_REG, &tmp);
+
+ if (ret != EC_SUCCESS) {
+ CPRINTF("[%T %s type:0x%X RS Error]", s->name, s->type);
+ return ret;
+ }
+
+ *ready = (tmp & L3GD20_STS_ZYXDA_MASK) ? 1 : 0;
+
+ return EC_SUCCESS;
+}
+
+static int read(const struct motion_sensor_t *s, vector_3_t v)
+{
+ uint8_t raw[6];
+ uint8_t xyz_reg;
+ int ret, range, i, tmp = 0;
+ struct l3gd20_data *data = s->drv_data;
+
+ ret = is_data_ready(s, &tmp);
+ if (ret != EC_SUCCESS)
+ return ret;
+
+ /*
+ * If sensor data is not ready, return the previous read data.
+ * Note: return success so that motion senor task can read again
+ * to get the latest updated sensor data quickly.
+ */
+ if (!tmp) {
+ if (v != s->raw_xyz)
+ memcpy(v, s->raw_xyz, sizeof(s->raw_xyz));
+ return EC_SUCCESS;
+ }
+
+ xyz_reg = get_xyz_reg(s->type);
+
+ /* Read 6 bytes starting at xyz_reg */
+ i2c_lock(I2C_PORT_GYRO, 1);
+ ret = i2c_xfer(I2C_PORT_GYRO, s->i2c_addr,
+ &xyz_reg, 1, raw, 6, I2C_XFER_SINGLE);
+ i2c_lock(I2C_PORT_GYRO, 0);
+
+ if (ret != EC_SUCCESS) {
+ CPRINTF("[%T %s type:0x%X RD XYZ Error]",
+ s->name, s->type);
+ return ret;
+ }
+
+ get_range(s, &range);
+ for (i = X; i <= Z; i++) {
+ v[i] = ((int16_t)((raw[i * 2 + 1] << 8) | raw[i * 2]));
+ v[i] += (data->offset[i] << 5) / range;
+ }
+ if (*s->rot_standard_ref != NULL)
+ rotate(v, *s->rot_standard_ref, v);
+
+ return EC_SUCCESS;
+}
+
+static int init(const struct motion_sensor_t *s)
+{
+ int ret = 0, tmp;
+
+ ret = raw_read8(s->i2c_addr, L3GD20_WHO_AM_I_REG, &tmp);
+ if (ret)
+ return EC_ERROR_UNKNOWN;
+
+ if (tmp != L3GD20_WHO_AM_I)
+ return EC_ERROR_ACCESS_DENIED;
+
+ /* All axes are enabled */
+ ret = raw_write8(s->i2c_addr, L3GD20_CTRL_REG1, 0x0f);
+ if (ret)
+ return EC_ERROR_UNKNOWN;
+
+ mutex_lock(s->mutex);
+ ret = raw_read8(s->i2c_addr, L3GD20_CTRL_REG4, &tmp);
+ if (ret) {
+ mutex_unlock(s->mutex);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ tmp |= L3GD20_BDU_ENABLE;
+ ret = raw_write8(s->i2c_addr, L3GD20_CTRL_REG4, tmp);
+ mutex_unlock(s->mutex);
+ if (ret)
+ return EC_ERROR_UNKNOWN;
+
+ /* Config GYRO Range */
+ ret = set_range(s, s->runtime_config.range, 1);
+ if (ret)
+ return EC_ERROR_UNKNOWN;
+
+ /* Config GYRO ODR */
+ ret = set_data_rate(s, s->runtime_config.odr, 1);
+ if (ret)
+ return EC_ERROR_UNKNOWN;
+
+ CPRINTF("[%T %s: MS Done Init type:0x%X range:%d odr:%d]\n",
+ s->name, s->type, s->runtime_config.range,
+ s->runtime_config.odr);
+ return ret;
+}
+
+const struct accelgyro_drv l3gd20h_drv = {
+ .init = init,
+ .read = read,
+ .set_range = set_range,
+ .get_range = get_range,
+ .set_resolution = set_resolution,
+ .get_resolution = get_resolution,
+ .set_data_rate = set_data_rate,
+ .get_data_rate = get_data_rate,
+ .set_offset = set_offset,
+ .get_offset = get_offset,
+ .perform_calib = NULL,
+#ifdef CONFIG_ACCEL_INTERRUPTS
+ .set_interrupt = set_interrupt,
+#endif
+};
diff --git a/driver/gyro_l3gd20h.h b/driver/gyro_l3gd20h.h
new file mode 100644
index 0000000000..6ff9fba044
--- /dev/null
+++ b/driver/gyro_l3gd20h.h
@@ -0,0 +1,102 @@
+/* Copyright 2015 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.
+ */
+
+/* L3GD20H gyro module for Chrome EC */
+
+#ifndef __CROS_EC_GYRO_L3GD20H_H
+#define __CROS_EC_GYRO_L3GD20H_H
+
+#include "accelgyro.h"
+#include "task.h"
+
+/*
+ * 7-bit address is 110101Xb. Where 'X' is determined
+ * by the voltage on the ADDR pin.
+ */
+#define L3GD20_ADDR0 0xd4
+#define L3GD20_ADDR1 0xd6
+
+/* who am I */
+#define L3GD20_WHO_AM_I 0xd7
+
+/* Chip specific registers. */
+#define L3GD20_WHO_AM_I_REG 0x0f
+#define L3GD20_CTRL_REG1 0x20
+#define L3GD20_CTRL_REG2 0x21
+#define L3GD20_CTRL_REG3 0x22
+#define L3GD20_CTRL_REG4 0x23
+#define L3GD20_CTRL_REG5 0x24
+#define L3GD20_CTRL_REFERENCE 0x25
+#define L3GD20_OUT_TEMP 0x26
+#define L3GD20_STATUS_REG 0x27
+#define L3GD20_OUT_X_L 0x28
+#define L3GD20_OUT_X_H 0x29
+#define L3GD20_OUT_Y_L 0x2a
+#define L3GD20_OUT_Y_H 0x2b
+#define L3GD20_OUT_Z_L 0x2c
+#define L3GD20_OUT_Z_H 0x2d
+#define L3GD20_FIFO_CTRL_REG 0x2e
+#define L3GD20_FIFO_SRC_REG 0x2f
+#define L3GD20_INT1_CFG 0x30
+#define L3GD20_INT1_SRC 0x31
+#define L3GD20_INT1_TSH_XH 0x32
+#define L3GD20_INT1_TSH_XL 0x33
+#define L3GD20_INT1_TSH_YH 0x34
+#define L3GD20_INT1_TSH_YL 0x35
+#define L3GD20_INT1_TSH_ZH 0x36
+#define L3GD20_INT1_TSH_ZL 0x37
+#define L3GD20_INT1_DURATION 0x38
+#define L3GD20_LOW_ODR 0x39
+
+#define L3GD20_DPS_SEL_245 (0 << 4)
+#define L3GD20_DPS_SEL_500 (1 << 4)
+#define L3GD20_DPS_SEL_2000_0 (2 << 4)
+#define L3GD20_DPS_SEL_2000_1 (3 << 4)
+
+#define L3GD20_ODR_PD (0 << 3)
+#define L3GD20_ODR_12_5HZ (0 << 6)
+#define L3GD20_ODR_25HZ (1 << 6)
+#define L3GD20_ODR_50HZ_0 (2 << 6)
+#define L3GD20_ODR_50HZ_1 (3 << 6)
+#define L3GD20_ODR_100HZ (0 << 6)
+#define L3GD20_ODR_200HZ (1 << 6)
+#define L3GD20_ODR_400HZ (2 << 6)
+#define L3GD20_ODR_800HZ (3 << 6)
+
+#define L3GD20_ODR_MASK (3 << 6)
+#define L3GD20_STS_ZYXDA_MASK (1 << 3)
+#define L3GD20_RANGE_MASK (3 << 4)
+#define L3GD20_LOW_ODR_MASK (1 << 0)
+#define L3GD20_ODR_PD_MASK (1 << 3)
+
+/*
+ * Register : STATUS_REG
+ * Address : 0X27
+ */
+enum l3gd20_status {
+ L3GD20_STS_DOWN = 0x00,
+ L3GD20_STS_ZYXDA_UP = 0x08,
+};
+
+/*
+ * Register : CTRL_REG4
+ * Address : 0X23
+ * Bit Group Name: BDU
+ */
+enum l3gd20_bdu {
+ L3GD20_BDU_DISABLE = 0x00,
+ L3GD20_BDU_ENABLE = 0x80,
+};
+
+/* Sensor resolution in number of bits. This sensor has fixed resolution. */
+#define L3GD20_RESOLUTION 16
+
+extern const struct accelgyro_drv l3gd20h_drv;
+struct l3gd20_data {
+ struct motion_data_t base;
+ int16_t offset[3];
+};
+
+#endif /* __CROS_EC_GYRO_L3GD20H_H */
diff --git a/include/config.h b/include/config.h
index b8f7513d07..e767b24d98 100644
--- a/include/config.h
+++ b/include/config.h
@@ -49,6 +49,9 @@
#undef CONFIG_ACCELGYRO_LSM6DS0
#undef CONFIG_ACCELGYRO_BMI160
+/* Specify type of Gyrometers attached. */
+#undef CONFIG_GYRO_L3GD20H
+
/* Compile chip support for analog-to-digital convertor */
#undef CONFIG_ADC
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 68817e59f5..85434a1092 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -1724,6 +1724,7 @@ enum motionsensor_chip {
MOTIONSENSE_CHIP_KXCJ9 = 0,
MOTIONSENSE_CHIP_LSM6DS0 = 1,
MOTIONSENSE_CHIP_BMI160 = 2,
+ MOTIONSENSE_CHIP_L3GD20H = 3,
};
struct ec_response_motion_sensor_data {