summaryrefslogtreecommitdiff
path: root/board/kohaku/board.c
diff options
context:
space:
mode:
authorPhilip Chen <philipchen@google.com>2019-06-20 15:33:53 -0700
committerCommit Bot <commit-bot@chromium.org>2019-06-25 08:21:27 +0000
commit08429fb35a85944eb7314926a7cba3254b3de86a (patch)
treebcb5eacb54da415add3b610fa341d03a1b488637 /board/kohaku/board.c
parent71c5056bd1f27b52f99c1ed4cff01bdc8cee032e (diff)
downloadchrome-ec-08429fb35a85944eb7314926a7cba3254b3de86a.tar.gz
kohaku: Add support for TCS3400 as clear ALS and RGB sesnor
BUG=b:134207072, b:135216932 BRANCH=none TEST=build kohaku Change-Id: I7b3d01d5dfb193262055b6aff2d101844159aa94 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1670165 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
Diffstat (limited to 'board/kohaku/board.c')
-rw-r--r--board/kohaku/board.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/board/kohaku/board.c b/board/kohaku/board.c
index 543c656a52..5635cbf3f8 100644
--- a/board/kohaku/board.c
+++ b/board/kohaku/board.c
@@ -13,6 +13,7 @@
#include "driver/accel_bma2x2.h"
#include "driver/accelgyro_bmi160.h"
#include "driver/als_bh1730.h"
+#include "driver/als_tcs3400.h"
#include "driver/ppc/sn5s330.h"
#include "driver/bc12/max14637.h"
#include "driver/sync.h"
@@ -170,6 +171,30 @@ static struct accelgyro_saved_data_t g_bma255_data;
/* BH1730 private data */
struct bh1730_drv_data_t g_bh1730_data;
+/* TCS3400 private data */
+static struct als_drv_data_t g_tcs3400_data = {
+ .als_cal.scale = 1,
+ .als_cal.uscale = 0,
+ .als_cal.offset = 0,
+};
+
+static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = {
+ .device_scale = 1,
+ .device_uscale = 0,
+ .rgb_cal[X] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+ .rgb_cal[Y] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+ .rgb_cal[Z] = {
+ .scale = ALS_CHANNEL_SCALE(1),
+ .offset = 0,
+ },
+};
+
/* Matrix to rotate accelrator into standard reference frame */
static const mat33_fp_t base_standard_ref = {
{ 0, FLOAT_TO_FP(1), 0},
@@ -292,12 +317,51 @@ struct motion_sensor_t motion_sensors[] = {
.min_frequency = 0,
.max_frequency = 1,
},
+
+ [CLEAR_ALS] = {
+ .name = "Clear Light",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_TCS3400,
+ .type = MOTIONSENSE_TYPE_LIGHT,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &tcs3400_drv,
+ .drv_data = &g_tcs3400_data,
+ .port = I2C_PORT_ALS,
+ .addr = TCS3400_I2C_ADDR,
+ .rot_standard_ref = NULL,
+ .default_range = 0x10000, /* scale = 1x, uscale = 0 */
+ .min_frequency = TCS3400_LIGHT_MIN_FREQ,
+ .max_frequency = TCS3400_LIGHT_MAX_FREQ,
+ .config = {
+ /* Run ALS sensor in S0 */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 1000,
+ },
+ },
+ },
+
+ [RGB_ALS] = {
+ /*
+ * RGB channels read by CLEAR_ALS and so the i2c port and
+ * address do not need to be defined for RGB_ALS.
+ */
+ .name = "RGB Light",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_TCS3400,
+ .type = MOTIONSENSE_TYPE_LIGHT_RGB,
+ .location = MOTIONSENSE_LOC_LID,
+ .drv = &tcs3400_rgb_drv,
+ .drv_data = &g_tcs3400_rgb_data,
+ .rot_standard_ref = NULL,
+ .default_range = 0x10000, /* scale = 1x, uscale = 0 */
+ },
};
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],
+ &motion_sensors[CLEAR_ALS],
};
BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
@@ -335,6 +399,8 @@ static void board_init(void)
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
/* Enable gpio interrupt for camera vsync */
gpio_enable_interrupt(GPIO_WFCAM_VSYNC);
+ /* Enable interrupt for the TCS3400 color light sensor */
+ gpio_enable_interrupt(GPIO_TCS3400_INT_ODL);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);