summaryrefslogtreecommitdiff
path: root/include/driver
diff options
context:
space:
mode:
authorHyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com>2021-01-19 09:24:34 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-20 20:12:17 +0000
commit6a87ebfedddef0a3d0438bcbb894e45dc16fe1e1 (patch)
tree85cf0cda8fb472011d80693008f5041c8058988d /include/driver
parent0fb58a57bbbc94391eb56120498dc796edea2ed9 (diff)
downloadchrome-ec-6a87ebfedddef0a3d0438bcbb894e45dc16fe1e1.tar.gz
Zephyr: Create public headers for bmi260, bma2x2, and tcs3400
Separate out the public part of sensor headers so it can be included from Zephyr. BUG=b:175434113 BRANCH=none TEST=make buildall -j8 build volteer on zephyr Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Change-Id: I899e9aea99d6c7d56a1b6735538b280fe0735313 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2637251 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'include/driver')
-rw-r--r--include/driver/accel_bma2x2_public.h48
-rw-r--r--include/driver/accelgyro_bmi260_public.h31
-rw-r--r--include/driver/accelgyro_bmi_common_public.h32
-rw-r--r--include/driver/als_tcs3400_public.h73
4 files changed, 184 insertions, 0 deletions
diff --git a/include/driver/accel_bma2x2_public.h b/include/driver/accel_bma2x2_public.h
new file mode 100644
index 0000000000..6b3d366270
--- /dev/null
+++ b/include/driver/accel_bma2x2_public.h
@@ -0,0 +1,48 @@
+/* Copyright 2021 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.
+ */
+
+/* BMA2x2 gsensor module for Chrome EC */
+
+#ifndef __CROS_EC_DRIVER_ACCEL_BMA2x2_PUBLIC_H
+#define __CROS_EC_DRIVER_ACCEL_BMA2x2_PUBLIC_H
+
+extern const struct accelgyro_drv bma2x2_accel_drv;
+
+/* I2C ADDRESS DEFINITIONS */
+/* The following definition of I2C address is used for the following sensors
+* BMA253
+* BMA255
+* BMA355
+* BMA280
+* BMA282
+* BMA223
+* BMA254
+* BMA284
+* BMA250E
+* BMA222E
+*/
+#define BMA2x2_I2C_ADDR1_FLAGS 0x18
+#define BMA2x2_I2C_ADDR2_FLAGS 0x19
+
+/* The following definition of I2C address is used for the following sensors
+* BMC150
+* BMC056
+* BMC156
+*/
+#define BMA2x2_I2C_ADDR3_FLAGS 0x10
+#define BMA2x2_I2C_ADDR4_FLAGS 0x11
+
+/*
+ * Min and Max sampling frequency in mHz.
+ * Given BMA255 is polled, we limit max frequency to 125Hz.
+ * If set to 250Hz, given we can read up to 3ms before the due time
+ * (see CONFIG_MOTION_MIN_SENSE_WAIT_TIME), we may read too early when
+ * other sensors are active.
+ */
+#define BMA255_ACCEL_MIN_FREQ 7810
+#define BMA255_ACCEL_MAX_FREQ \
+ MOTION_MAX_SENSOR_FREQUENCY(125000, 15625)
+
+#endif /* CROS_EC_DRIVER_ACCEL_BMA2x2_PUBLIC_H */
diff --git a/include/driver/accelgyro_bmi260_public.h b/include/driver/accelgyro_bmi260_public.h
new file mode 100644
index 0000000000..fa616d4a41
--- /dev/null
+++ b/include/driver/accelgyro_bmi260_public.h
@@ -0,0 +1,31 @@
+/* Copyright 2021 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.
+ */
+
+/* BMI260 accelerometer and gyro for Chrome EC */
+
+#ifndef __CROS_EC_DRIVER_ACCELGYRO_BMI260_PUBLIC_H
+#define __CROS_EC_DRIVER_ACCELGYRO_BMI260_PUBLIC_H
+
+/*
+ * The addr field of motion_sensor support both SPI and I2C:
+ * This is defined in include/i2c.h and is no longer an 8bit
+ * address. The 7/10 bit address starts at bit 0 and leaves
+ * room for a 10 bit address, although we don't currently
+ * have any 10 bit slaves. I2C or SPI is indicated by a
+ * more significant bit
+ */
+
+/* I2C addresses */
+#define BMI260_ADDR0_FLAGS 0x68
+
+extern const struct accelgyro_drv bmi260_drv;
+
+void bmi260_interrupt(enum gpio_signal signal);
+
+#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
+extern struct i2c_stress_test_dev bmi260_i2c_stress_test_dev;
+#endif
+
+#endif /* __CROS_EC_DRIVER_ACCELGYRO_BMI260_PUBLIC_H */
diff --git a/include/driver/accelgyro_bmi_common_public.h b/include/driver/accelgyro_bmi_common_public.h
new file mode 100644
index 0000000000..52814c71bf
--- /dev/null
+++ b/include/driver/accelgyro_bmi_common_public.h
@@ -0,0 +1,32 @@
+/* Copyright 2021 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.
+ */
+/* BMI accelerometer and gyro common definitions for Chrome EC */
+
+#ifndef __CROS_EC_DRIVER_ACCELGYRO_BMI_COMMON_PUBLIC_H
+#define __CROS_EC_DRIVER_ACCELGYRO_BMI_COMMON_PUBLIC_H
+
+/* Min and Max sampling frequency in mHz */
+#define BMI_ACCEL_MIN_FREQ 12500
+#define BMI_ACCEL_MAX_FREQ MOTION_MAX_SENSOR_FREQUENCY(1600000, 100000)
+#define BMI_GYRO_MIN_FREQ 25000
+#define BMI_GYRO_MAX_FREQ MOTION_MAX_SENSOR_FREQUENCY(3200000, 100000)
+
+struct bmi_drv_data_t {
+ struct accelgyro_saved_data_t saved_data[3];
+ uint8_t flags;
+ uint8_t enabled_activities;
+ uint8_t disabled_activities;
+#ifdef CONFIG_MAG_BMI_BMM150
+ struct bmm150_private_data compass;
+#endif
+#ifdef CONFIG_BMI_ORIENTATION_SENSOR
+ uint8_t raw_orientation;
+ enum motionsensor_orientation orientation;
+ enum motionsensor_orientation last_orientation;
+#endif
+
+};
+
+#endif /* __CROS_EC_DRIVER_ACCELGYRO_BMI_COMMON_PUBLIC_H */
diff --git a/include/driver/als_tcs3400_public.h b/include/driver/als_tcs3400_public.h
new file mode 100644
index 0000000000..9a9225bfc6
--- /dev/null
+++ b/include/driver/als_tcs3400_public.h
@@ -0,0 +1,73 @@
+/* Copyright 2021 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.
+ *
+ * AMS TCS3400 light sensor driver
+ */
+
+#ifndef __CROS_EC_DRIVER_ALS_TCS3400_PUBLIC_H
+#define __CROS_EC_DRIVER_ALS_TCS3400_PUBLIC_H
+
+#include "accelgyro.h"
+
+/* I2C Interface */
+#define TCS3400_I2C_ADDR_FLAGS 0x39
+
+/* NOTE: The higher the ATIME value in reg, the shorter the accumulation time */
+#define TCS_MIN_ATIME 0x00 /* 712 ms */
+#define TCS_MAX_ATIME 0x70 /* 400 ms */
+#define TCS_ATIME_GRANULARITY 256 /* 256 atime settings */
+#define TCS_SATURATION_LEVEL 0xffff /* for 0 < atime < 0x70 */
+#define TCS_DEFAULT_ATIME TCS_MIN_ATIME /* 712 ms */
+#define TCS_CALIBRATION_ATIME TCS_MIN_ATIME
+#define TCS_GAIN_UPSHIFT_ATIME TCS_MAX_ATIME
+
+/* Number of different ranges supported for atime adjustment support */
+#define TCS_MAX_ATIME_RANGES 13
+#define TCS_GAIN_TABLE_MAX_LUX 12999
+#define TCS_ATIME_GAIN_FACTOR 100 /* table values are 100x actual value */
+
+#define TCS_MIN_AGAIN 0x00 /* 1x gain */
+#define TCS_MAX_AGAIN 0x03 /* 64x gain */
+#define TCS_CALIBRATION_AGAIN 0x02 /* 16x gain */
+#define TCS_DEFAULT_AGAIN TCS_CALIBRATION_AGAIN
+
+#define TCS_ATIME_DEC_STEP 5
+#define TCS_ATIME_INC_STEP TCS_GAIN_UPSHIFT_ATIME
+
+/* Min and Max sampling frequency in mHz */
+#define TCS3400_LIGHT_MIN_FREQ 149
+#define TCS3400_LIGHT_MAX_FREQ 1000
+#if (CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ <= TCS3400_LIGHT_MAX_FREQ)
+#error "EC too slow for light sensor"
+#endif
+
+/* saturation auto-adjustment */
+struct tcs_saturation_t {
+ /*
+ * Gain Scaling; must be value between 0 and 3
+ * 0 - 1x scaling
+ * 1 - 4x scaling
+ * 2 - 16x scaling
+ * 3 - 64x scaling
+ */
+ uint8_t again;
+
+ /* Acquisition Time, controlled by the ATIME register */
+ uint8_t atime; /* ATIME register setting */
+};
+
+/* tcs3400 rgb als driver data */
+struct tcs3400_rgb_drv_data_t {
+ uint8_t calibration_mode;/* 0 = normal run mode, 1 = calibration mode */
+
+ struct rgb_calibration_t calibration;
+ struct tcs_saturation_t saturation; /* saturation adjustment */
+};
+
+extern const struct accelgyro_drv tcs3400_drv;
+extern const struct accelgyro_drv tcs3400_rgb_drv;
+
+void tcs3400_interrupt(enum gpio_signal signal);
+
+#endif /* __CROS_EC_DRIVER_ALS_TCS3400_PUBLIC_H */