summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2016-12-27 16:19:05 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-16 18:03:59 -0800
commit484ef121193865225ddbc3a0b848db7f5384f836 (patch)
tree804173045dad81b2a2839df75c412e874e8d9154 /board
parent69c3fc2378ee9026277c1cbaf6e8aff0b99ecf46 (diff)
downloadchrome-ec-484ef121193865225ddbc3a0b848db7f5384f836.tar.gz
motion: Add opt3001 as a motion sensor
Use the motion sensor to manage ALS as well. The current interface (via memmap) is preserved, but we can also access the sensor via cros ec sensor stack and send the ALS information to ARC++. BUG=chrome-os-partner:59423 BRANCH=reef CQ-DEPEND=CL:424217 TEST=Check the sensor is working via ACPI sensor and cros ec sensor. Check ARC++ sees the sensors. Change-Id: Iaf608370454ad582691b72b471ea87b511863a78 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/424323 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/reef/board.c55
-rw-r--r--board/reef/board.h17
-rw-r--r--board/reef/ec.tasklist1
3 files changed, 55 insertions, 18 deletions
diff --git a/board/reef/board.c b/board/reef/board.c
index 7074ab4952..141a1cd3e0 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -7,7 +7,6 @@
#include "adc.h"
#include "adc_chip.h"
-#include "als.h"
#include "button.h"
#include "charge_manager.h"
#include "charge_ramp.h"
@@ -216,6 +215,8 @@ struct i2c_stress_test i2c_stress_tests[] = {
#endif
#ifdef CONFIG_CMD_I2C_STRESS_TEST_ALS
{
+ .port = I2C_PORT_ALS,
+ .addr = OPT3001_I2C_ADDR1,
.i2c_test = &opt3001_i2c_stress_test_dev,
},
#endif
@@ -441,13 +442,6 @@ const struct temp_sensor_t temp_sensors[] = {
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-/* ALS instances. Must be in same order as enum als_id. */
-struct als_t als[] = {
- /* FIXME(dhendrix): verify attenuation_factor */
- {"TI", opt3001_init, opt3001_read_lux, 5},
-};
-BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
-
const struct button_config buttons[CONFIG_BUTTON_COUNT] = {
{"Volume Down", KEYBOARD_BUTTON_VOLUME_DOWN, GPIO_EC_VOLDN_BTN_ODL,
30 * MSEC, 0},
@@ -779,10 +773,13 @@ const matrix_3x3_t mag_standard_ref = {
{ 0, 0, FLOAT_TO_FP(-1)}
};
+/* sensor private data */
struct kionix_accel_data g_kx022_data;
struct bmi160_drv_data_t g_bmi160_data;
struct bmp280_drv_data_t bmp280_drv_data;
-
+struct opt3001_drv_data_t g_opt3001_data = {
+ .attenuation = 5,
+};
/* FIXME(dhendrix): Copied from Amenia, probably need to tweak for Reef */
struct motion_sensor_t motion_sensors[] = {
@@ -967,9 +964,49 @@ struct motion_sensor_t motion_sensors[] = {
},
},
},
+ [LID_ALS] = {
+ .name = "Light",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_OPT3001,
+ .type = MOTIONSENSE_TYPE_LIGHT,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &opt3001_drv,
+ .drv_data = &g_opt3001_data,
+ .port = I2C_PORT_ALS,
+ .addr = OPT3001_I2C_ADDR1,
+ .rot_standard_ref = NULL,
+ .default_range = OPT3001_RANGE_AUTOMATIC_FULL_SCALE,
+ .config = {
+ /* AP: by default shutdown all sensors */
+ [SENSOR_CONFIG_AP] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 1000,
+ .ec_rate = 0,
+ },
+ /* Sensor off in S3/S5 */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ /* Sensor off in S3/S5 */
+ [SENSOR_CONFIG_EC_S5] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ },
+ },
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */
+const struct motion_sensor_t *motion_als_sensors[] = {
+ &motion_sensors[LID_ALS],
+};
+BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
+
void board_hibernate(void)
{
/*
diff --git a/board/reef/board.h b/board/reef/board.h
index 0dd246b429..0e7ef3b2e0 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -202,7 +202,6 @@
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCEL_KX022
#define CONFIG_ALS_OPT3001
-#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
#define CONFIG_BARO_BMP280
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_UPDATE
@@ -257,12 +256,13 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
-/* Light sensors */
-enum als_id {
- ALS_OPT3001 = 0,
-
- ALS_COUNT
-};
+/*
+ * For backward compatibility, to report ALS via ACPI,
+ * Define the number of ALS sensors: motion_sensor copy the data to the ALS
+ * memmap region.
+ */
+#define CONFIG_ALS
+#define ALS_COUNT 1
/*
* Motion sensors:
@@ -276,6 +276,7 @@ enum sensor_id {
BASE_GYRO,
BASE_MAG,
BASE_BARO,
+ LID_ALS,
};
enum reef_board_version {
@@ -319,7 +320,7 @@ void board_print_tcpc_fw_version(int port);
/* Sensors without hardware FIFO are in forced mode */
#define CONFIG_ACCEL_FORCE_MODE_MASK \
- ((1 << LID_ACCEL) | (1 << BASE_BARO))
+ ((1 << LID_ACCEL) | (1 << BASE_BARO) | (1 << LID_ALS))
#endif /* !__ASSEMBLER__ */
diff --git a/board/reef/ec.tasklist b/board/reef/ec.tasklist
index 47e0048872..e153496b43 100644
--- a/board/reef/ec.tasklist
+++ b/board/reef/ec.tasklist
@@ -22,7 +22,6 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS(ALS, als_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(CHG_RAMP, chg_ramp_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG, usb_charger_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \