summaryrefslogtreecommitdiff
path: root/board/cheza
diff options
context:
space:
mode:
authorAlexandru M Stan <amstan@chromium.org>2019-02-07 17:42:38 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-02-20 21:41:47 -0800
commit27836f5fa97eee3479c56ddca6892a5ed0c887bd (patch)
treeac6cc2b5a3177792f38c03641b59891eeb2007a7 /board/cheza
parentc8df3ef42411181d99fa71cb8af53498995a1123 (diff)
downloadchrome-ec-27836f5fa97eee3479c56ddca6892a5ed0c887bd.tar.gz
cheza: Add ALS sensor
Added definitions for the OPT3001 sensor on our board. TEST=In S0, "> accelread 2" should yield an illuminance number on the "Last calib." line. Shine a light near the camera to modify the value. TEST=On the AP console: localhost /sys/bus/iio/devices/iio:device4 # watch -n 0.1 cat in_illuminance_input BUG=b/112658076 BRANCH=master Change-Id: I0c4890c83c889429b4908821d6157f3809308d7f Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1460092 Reviewed-by: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'board/cheza')
-rw-r--r--board/cheza/board.c27
-rw-r--r--board/cheza/board.h8
2 files changed, 35 insertions, 0 deletions
diff --git a/board/cheza/board.c b/board/cheza/board.c
index 8939296dc2..460708e566 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -6,12 +6,14 @@
/* Cheza board-specific configuration */
#include "adc_chip.h"
+#include "als.h"
#include "button.h"
#include "charge_manager.h"
#include "charge_state.h"
#include "chipset.h"
#include "extpower.h"
#include "driver/accelgyro_bmi160.h"
+#include "driver/als_opt3001.h"
#include "driver/ppc/sn5s330.h"
#include "driver/tcpm/anx74xx.h"
#include "driver/tcpm/ps8xxx.h"
@@ -604,6 +606,11 @@ uint16_t tcpc_get_alert_status(void)
static struct mutex g_lid_mutex;
static struct bmi160_drv_data_t g_bmi160_data;
+static struct opt3001_drv_data_t g_opt3001_data = {
+ .scale = 1,
+ .uscale = 0,
+ .offset = 0,
+};
/* Matrix to rotate accelerometer into standard reference frame */
const mat33_fp_t base_standard_ref = {
@@ -655,5 +662,25 @@ struct motion_sensor_t motion_sensors[] = {
.min_frequency = BMI160_GYRO_MIN_FREQ,
.max_frequency = BMI160_GYRO_MAX_FREQ,
},
+ [LID_ALS] = {
+ .name = "Light",
+ .active_mask = SENSOR_ACTIVE_S0,
+ .chip = MOTIONSENSE_CHIP_OPT3001,
+ .type = MOTIONSENSE_TYPE_LIGHT,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &opt3001_drv,
+ .drv_data = &g_opt3001_data,
+ .port = I2C_PORT_SENSOR,
+ .addr = OPT3001_I2C_ADDR,
+ .rot_standard_ref = NULL,
+ .default_range = 0x10000, /* scale = 1; uscale = 0 */
+ .min_frequency = OPT3001_LIGHT_MIN_FREQ,
+ .max_frequency = OPT3001_LIGHT_MAX_FREQ,
+ .config = {
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 1000,
+ },
+ },
+ },
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
diff --git a/board/cheza/board.h b/board/cheza/board.h
index a243de34f3..d005f624d1 100644
--- a/board/cheza/board.h
+++ b/board/cheza/board.h
@@ -133,6 +133,10 @@
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
+#define CONFIG_ALS
+#define CONFIG_ALS_OPT3001
+#define ALS_COUNT 1
+#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
/* PD */
#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
@@ -190,6 +194,7 @@ enum adc_channel {
enum sensor_id {
LID_ACCEL = 0,
LID_GYRO,
+ LID_ALS,
};
enum pwm_channel {
@@ -206,6 +211,9 @@ void board_reset_pd_mcu(void);
/* Base detection interrupt handler */
void base_detect_interrupt(enum gpio_signal signal);
+/* Sensors without hardware FIFO are in forced mode */
+#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ALS)
+
#endif /* !defined(__ASSEMBLER__) */
#endif /* __CROS_EC_BOARD_H */