diff options
author | Tino Liu <tino.liu@quanta.corp-partner.google.com> | 2018-11-22 17:19:04 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-12-09 20:49:29 -0800 |
commit | ef17e123c89b45cc6ee6ceaaf2a047f29ee60980 (patch) | |
tree | ac13a249d750ee094efd1def01735cd49271d9fa /board | |
parent | 768ce709a6dd85921e60bf871ff0d34824eba990 (diff) | |
download | chrome-ec-ef17e123c89b45cc6ee6ceaaf2a047f29ee60980.tar.gz |
Kalista: Write panel settings to OZ554
GPIO44 is used for panel backlight enable interrupt.
If EC receive rising interrupt, write panel settings to OZ554.
BUG=b:120237453
BRANCH=none
TEST=make buildall pass, panel can show screen properly
Change-Id: I45cd12b5b334db39fa989ab435240d272dc39d7c
Signed-off-by: Tino Liu <tino.liu@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/1351909
Commit-Ready: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Tested-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/karma/board.c | 109 | ||||
-rw-r--r-- | board/karma/board.h | 6 | ||||
-rw-r--r-- | board/karma/build.mk | 1 | ||||
-rw-r--r-- | board/karma/gpio.inc | 2 |
4 files changed, 117 insertions, 1 deletions
diff --git a/board/karma/board.c b/board/karma/board.c new file mode 100644 index 0000000000..49f1b919a3 --- /dev/null +++ b/board/karma/board.c @@ -0,0 +1,109 @@ +/* Copyright 2018 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "console.h" +#include "gpio.h" +#include "hooks.h" +#include "i2c.h" +#include "task.h" +#include "timer.h" + +#define CPRINTS(format, args...) cprints(CC_GPIO, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_GPIO, format, ## args) + +#define I2C_ADDR_OZ554 0x62 +#define OZ554_DATA_SIZE 6 + +struct oz554_value { + uint8_t offset; + uint8_t data; +}; + +/* This ordering is suggested by vendor. */ +static const struct oz554_value oz554_order[] = { + /* + * Reigster 0x01: Operation frequency control + * Frequency selection: 300(KHz) + * Short circuit protection: 8(V) + */ + {.offset = 1, .data = 0x43}, + /* + * Reigster 0x02: LED current amplitude control + * ISET Resistor: 10.2(Kohm) + * Maximum LED current: 1636/10.2 = 160.4(mA) + * Setting LED current: 65(mA) + */ + {.offset = 2, .data = 0x65}, + /* + * Reigster 0x03: LED backlight Status + * Status function: Read only + */ + {.offset = 3, .data = 0x00}, + /* + * Reigster 0x04: LED current control with SMBus + * SMBus PWM function: None Use + */ + {.offset = 4, .data = 0x00}, + /* + * Reigster 0x05: OVP, OCP control + * Over Current Protection: 0.5(V) + * Panel LED Voltage(Max): 47.8(V) + * OVP setting: 54(V) + */ + {.offset = 5, .data = 0x97}, + /* + * Reigster 0x00: Dimming mode and string ON/OFF control + * String Selection: 4(Number) + * Interface Selection: 1 + * Brightness mode: 3 + */ + {.offset = 0, .data = 0xF2}, +}; +BUILD_ASSERT(ARRAY_SIZE(oz554_order) == OZ554_DATA_SIZE); + +static void set_oz554_reg(void) +{ + int i, rv; + + for (i = 0; i < OZ554_DATA_SIZE; ++i) { + rv = i2c_write8( + NPCX_I2C_PORT1, + I2C_ADDR_OZ554, + oz554_order[i].offset, + oz554_order[i].data); + + if (rv) { + CPRINTS("Write OZ554 register index %d failed, rv = %d" + , i, rv); + break; + } + } +} + +static void backlight_enable_deferred(void) +{ + if (gpio_get_level(GPIO_PANEL_BACKLIGHT_EN)) + set_oz554_reg(); +} +DECLARE_DEFERRED(backlight_enable_deferred); + +void backlight_enable_interrupt(enum gpio_signal signal) +{ + hook_call_deferred(&backlight_enable_deferred_data, 30 * MSEC); +} + +static void karma_chipset_resume(void) +{ + /* Enable panel backlight interrupt. */ + gpio_enable_interrupt(GPIO_PANEL_BACKLIGHT_EN); +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME, karma_chipset_resume, HOOK_PRIO_DEFAULT); + +static void karma_chipset_shutdown(void) +{ + /* Disable panel backlight interrupt. */ + gpio_disable_interrupt(GPIO_PANEL_BACKLIGHT_EN); +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, karma_chipset_shutdown, HOOK_PRIO_DEFAULT); diff --git a/board/karma/board.h b/board/karma/board.h index 372b18509b..85c4642fcb 100644 --- a/board/karma/board.h +++ b/board/karma/board.h @@ -10,4 +10,10 @@ #include "baseboard.h" +#ifndef __ASSEMBLER__ + +void backlight_enable_interrupt(enum gpio_signal signal); + +#endif /* !__ASSEMBLER__ */ + #endif /* __CROS_EC_BOARD_H */ diff --git a/board/karma/build.mk b/board/karma/build.mk index 05884cf221..82d7890946 100644 --- a/board/karma/build.mk +++ b/board/karma/build.mk @@ -9,3 +9,4 @@ CHIP:=npcx CHIP_VARIANT:=npcx5m6g BASEBOARD:=kalista +board-y=board.o diff --git a/board/karma/gpio.inc b/board/karma/gpio.inc index d5b47800dc..12a7fef919 100644 --- a/board/karma/gpio.inc +++ b/board/karma/gpio.inc @@ -11,6 +11,7 @@ GPIO_INT(USB_C0_PD_INT_ODL, PIN(3, 7), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) GPIO_INT(AC_PRESENT, PIN(C, 1), GPIO_INT_BOTH, extpower_interrupt) GPIO_INT(POWER_BUTTON_L, PIN(0, 4), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt) /* MECH_PWR_BTN_ODL */ +GPIO_INT(PANEL_BACKLIGHT_EN, PIN(4, 4), GPIO_INT_RISING, backlight_enable_interrupt) GPIO_INT(PCH_SLP_S0_L, PIN(7, 5), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(PCH_SLP_SUS_L, PIN(6, 2), GPIO_INT_BOTH, power_signal_interrupt) @@ -84,7 +85,6 @@ GPIO(SPKR5, PIN(C, 2), GPIO_INPUT) /* No function */ /* Test points */ GPIO(TP48, PIN(B, 1), GPIO_INPUT) GPIO(TP52, PIN(C, 3), GPIO_INPUT) -GPIO(TP120, PIN(4, 4), GPIO_INPUT) GPIO(TP121, PIN(3, 3), GPIO_INPUT) GPIO(TP123, PIN(C, 5), GPIO_INPUT) GPIO(TP127, PIN(6, 6), GPIO_INPUT) |