summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2015-09-09 09:53:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-10 15:40:46 -0700
commit3f2dc44158630f0ce93633c21df8daaddb2b7324 (patch)
tree0ce8ae9df0e40ac7cd83fd97516232fc377db0b9
parent2a16019d548cd95776a7c60485e9cf775d8e115f (diff)
downloadchrome-ec-3f2dc44158630f0ce93633c21df8daaddb2b7324.tar.gz
glados: Enable TI OPT3001 ambient light sensor
Enable the light sensor driver for glados so it can be exported to the host via ACPI. BUG=chrome-os-partner:43493 BRANCH=none TEST=enable ACPI ALS interface on glados in BIOS and kernel and check that light sensor values can be read by the OS. Change-Id: I813e8cae830832a1ef582b2821f1338e3c1b289b Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/298158 Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/glados/board.c8
-rw-r--r--board/glados/board.h12
-rw-r--r--board/glados/ec.tasklist1
3 files changed, 21 insertions, 0 deletions
diff --git a/board/glados/board.c b/board/glados/board.c
index 8b9b59f20a..b7f3f07690 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -6,6 +6,7 @@
/* Glados board-specific configuration */
#include "adc_chip.h"
+#include "als.h"
#include "bd99992gw.h"
#include "button.h"
#include "charge_manager.h"
@@ -13,6 +14,7 @@
#include "charger.h"
#include "chipset.h"
#include "console.h"
+#include "driver/als_opt3001.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
@@ -199,6 +201,12 @@ struct ec_thermal_config thermal_params[] = {
};
BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
+/* ALS instances. Must be in same order as enum als_id. */
+struct als_t als[] = {
+ {"TI", opt3001_read_lux, 5},
+};
+BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
+
const struct button_config buttons[CONFIG_BUTTON_COUNT] = {
{ 0 },
{ 0 },
diff --git a/board/glados/board.h b/board/glados/board.h
index bf98d2a7f6..836894e759 100644
--- a/board/glados/board.h
+++ b/board/glados/board.h
@@ -10,6 +10,8 @@
/* Optional features */
#define CONFIG_ADC
+#define CONFIG_ALS
+#define CONFIG_ALS_OPT3001
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
#define CONFIG_BATTERY_SMART
@@ -105,6 +107,9 @@
/* Thermal sensors read through PMIC ADC interface */
#define I2C_PORT_THERMAL I2C_PORT_PMIC
+/* Ambient Light Sensor address */
+#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1
+
/* Modules we want to exclude */
#undef CONFIG_CMD_HASH
#undef CONFIG_CMD_I2C_SCAN
@@ -156,6 +161,13 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
+/* Light sensors */
+enum als_id {
+ ALS_OPT3001 = 0,
+
+ ALS_COUNT
+};
+
/* start as a sink in case we have no other power supply/battery */
#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
diff --git a/board/glados/ec.tasklist b/board/glados/ec.tasklist
index ec413f8047..b8e334b52d 100644
--- a/board/glados/ec.tasklist
+++ b/board/glados/ec.tasklist
@@ -18,6 +18,7 @@
*/
#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(USB_CHG_P0, usb_charger_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P1, usb_charger_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \