summaryrefslogtreecommitdiff
path: root/board/poppy/board.c
diff options
context:
space:
mode:
authorMarco Chen <marcochen@chromium.org>2017-11-16 14:12:43 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-11-26 05:21:39 -0800
commita2e2be193a46826fa6af7fbaab0e567e248e40b4 (patch)
tree45081aa3e8896b9cbd1764fbf7ca831b31c499d0 /board/poppy/board.c
parentf326fb05b564b0975a9870b2831f9372539202db (diff)
downloadchrome-ec-a2e2be193a46826fa6af7fbaab0e567e248e40b4.tar.gz
OPT3001: Support MOTIONSENSE_CMD_SENSOR_[OFFSET|RANGE] for calibration.
1. The original driver of OPT3001 a. didn't support to process the command of offset. b. implemented command of range to setter/getter of Range Number Field of chip. But reffering to cros_ec_light_prox.c from linux kernel side, these two commands are actually leveraged for in_illuminance_calib[bias|scale] and these calibration factors should be applied into raw lux value read from the chip. 2. Move ALS in Poppy / Soraka boards from ALS_TASK to MOTIONSENSE_TASK. 3. Mofify parameters of ALS in Reef board in order to adapt changes here. BUG=b:69236269 BRANCH=none TEST=Manually test on the DUT. Change-Id: Ic3b593feb3e4bc6da0bada6b5d614975f0cf2280 Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/774341 Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'board/poppy/board.c')
-rw-r--r--board/poppy/board.c58
1 files changed, 47 insertions, 11 deletions
diff --git a/board/poppy/board.c b/board/poppy/board.c
index 6d87057ee2..09327c9801 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -534,17 +534,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[] = {
- /*
- * attenuation_factor is set to 1 because there would be a calibration
- * in iio framework of kernel which would be configured in factory
- * flow.
- */
- {"TI", opt3001_init, opt3001_read_lux, 1},
-};
-BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
-
const struct button_config *recovery_buttons[] = {
&buttons[BUTTON_VOLUME_DOWN],
&buttons[BUTTON_VOLUME_UP],
@@ -853,6 +842,11 @@ int board_get_version(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 accelrator into standard reference frame */
const matrix_3x3_t mag_standard_ref = {
@@ -999,9 +993,51 @@ struct motion_sensor_t motion_sensors[] = {
},
},
},
+ [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_ALS,
+ .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 = {
+ /* 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);
+
#ifdef BOARD_SORAKA
static void board_sensor_init(void)
{