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) \