diff options
author | Sue Chen <sue.chen@quanta.corp-partner.google.com> | 2019-01-17 13:32:20 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-01-30 13:06:39 -0800 |
commit | 1cee8540fcb75523238c6ba19cf4fa5bbf1d6c11 (patch) | |
tree | aba0ce97dbae86c596a2229c45aec7a81ef8e6e7 /driver | |
parent | 53a9890eb203d7f5ba88d4e94fd86b58c3d1a204 (diff) | |
download | chrome-ec-1cee8540fcb75523238c6ba19cf4fa5bbf1d6c11.tar.gz |
oz554: Add oz554_set_config API
This patch adds oz554_set_config API and oz554_board_init callback
so that oz554 initialization can be customized by each board.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b/120237453
BRANCH=kalista
TEST=make buildall
Change-Id: I44e83e4cd25eb0794009b621e96d962a97a84fbb
Reviewed-on: https://chromium-review.googlesource.com/1443520
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/led/oz554.c | 26 | ||||
-rw-r--r-- | driver/led/oz554.h | 11 |
2 files changed, 32 insertions, 5 deletions
diff --git a/driver/led/oz554.c b/driver/led/oz554.c index 60581eb64c..4a1c46da0c 100644 --- a/driver/led/oz554.c +++ b/driver/led/oz554.c @@ -9,6 +9,7 @@ #include "gpio.h" #include "hooks.h" #include "i2c.h" +#include "oz554.h" #include "task.h" #include "timer.h" @@ -16,7 +17,6 @@ #define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args) #define I2C_ADDR_OZ554 0x62 -#define OZ554_DATA_SIZE 6 struct oz554_value { uint8_t offset; @@ -34,7 +34,7 @@ struct oz554_value { */ /* This ordering is suggested by vendor. */ -static const struct oz554_value order[] = { +static struct oz554_value oz554_conf[] = { /* * Reigster 0x01: Operation frequency control * Frequency selection: 300(KHz) @@ -73,15 +73,15 @@ static const struct oz554_value order[] = { */ {.offset = 0, .data = 0xF2}, }; -BUILD_ASSERT(ARRAY_SIZE(order) == OZ554_DATA_SIZE); +static const int oz554_conf_size = ARRAY_SIZE(oz554_conf); static void set_oz554_reg(void) { int i; - for (i = 0; i < OZ554_DATA_SIZE; ++i) { + for (i = 0; i < oz554_conf_size; ++i) { int rv = i2c_write8(I2C_PORT_BACKLIGHT, I2C_ADDR_OZ554, - order[i].offset, order[i].data); + oz554_conf[i].offset, oz554_conf[i].data); if (rv) { CPRINTS("Write OZ554 register %d failed rv=%d" , i, rv); return; @@ -102,8 +102,24 @@ void backlight_enable_interrupt(enum gpio_signal signal) hook_call_deferred(&backlight_enable_deferred_data, 30 * MSEC); } +int oz554_set_config(int offset, int data) +{ + int i; + for (i = 0; i < oz554_conf_size; i++) { + if (oz554_conf[i].offset == offset) + break; + } + if (i >= oz554_conf_size) + /* Matching offset not found */ + return EC_ERROR_INVAL; + oz554_conf[i].data = data; + return EC_SUCCESS; +} + static void init_oz554(void) { + oz554_board_init(); + gpio_enable_interrupt(GPIO_PANEL_BACKLIGHT_EN); } DECLARE_HOOK(HOOK_INIT, init_oz554, HOOK_PRIO_DEFAULT); diff --git a/driver/led/oz554.h b/driver/led/oz554.h index d9b5400111..bb45a17f30 100644 --- a/driver/led/oz554.h +++ b/driver/led/oz554.h @@ -10,6 +10,17 @@ #include "gpio.h" +void oz554_board_init(void) __attribute__((weak)); + +/** + * Update oz554 configuration array (oz554_conf). + * + * @param offset: Offset of the register to be set. + * @param data: Value to be set. + * @return EC_SUCCESS or EC_ERROR_* for errors. + */ +int oz554_set_config(int offset, int data); + void backlight_enable_interrupt(enum gpio_signal signal); #endif |