diff options
author | Ben Lok <ben.lok@mediatek.com> | 2015-12-18 14:24:11 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-02-26 05:56:11 -0800 |
commit | 60552e57b61d036edbb628fcd1debbf0ec087e6e (patch) | |
tree | f69f8d62ca42407a53eb3063dd3202d07718b12a | |
parent | e44f7b102915db39d9567e67cd1983f8d5357318 (diff) | |
download | chrome-ec-60552e57b61d036edbb628fcd1debbf0ec087e6e.tar.gz |
oak: Enable TI OPT3001 ambient light sensor for rev5
Refer to commit 3f2dc44158630f0ce93633c21df8daaddb2b7324,
enable light sensor driver for oak rev5
BUG=chrome-os-partner:50312
Change-Id: I896cf99fd781f5d4d8dad206d43f5a3d8faeb9a2
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/319271
Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r-- | board/oak/board.c | 8 | ||||
-rw-r--r-- | board/oak/board.h | 17 | ||||
-rw-r--r-- | board/oak/ec.tasklist | 1 |
3 files changed, 26 insertions, 0 deletions
diff --git a/board/oak/board.c b/board/oak/board.c index f9166b7b15..33a7bec316 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -7,6 +7,7 @@ #include "adc.h" #include "adc_chip.h" +#include "als.h" #include "atomic.h" #include "battery.h" #include "charge_manager.h" @@ -15,6 +16,7 @@ #include "chipset.h" #include "common.h" #include "console.h" +#include "driver/als_opt3001.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" #include "gpio.h" @@ -134,6 +136,12 @@ 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[] = { + {"TI", opt3001_init, opt3001_read_lux, 5}, +}; +BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT); + /* Thermal limits for each temp sensor. All temps are in degrees K. Must be in * same order as enum temp_sensor_id. To always ignore any temp, use 0. */ diff --git a/board/oak/board.h b/board/oak/board.h index 6b366d96c1..6336ba16ad 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -13,6 +13,12 @@ #define CONFIG_ADC #undef CONFIG_ADC_WATCHDOG + +/* Add for Ambient Light Sensor */ +#define CONFIG_ALS +#define CONFIG_ALS_OPT3001 +#define CONFIG_CMD_ALS + /* Add for AC adaptor, charger, battery */ #define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L @@ -134,6 +140,10 @@ #define I2C_PORT_PD_MCU 1 #define I2C_PORT_USB_MUX 1 #define I2C_PORT_TCPC 1 +#define I2C_PORT_ALS I2C_PORT_MASTER + +/* Ambient Light Sensor address */ +#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1 /* Timer selection */ #define TIM_CLOCK32 2 @@ -182,6 +192,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/oak/ec.tasklist b/board/oak/ec.tasklist index 3bf87257bf..45cb276099 100644 --- a/board/oak/ec.tasklist +++ b/board/oak/ec.tasklist @@ -26,6 +26,7 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_VBUS(VBUS, vbus_task, NULL, 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) \ |