From 56cd91fda92d1dc8147c487737444933a665852a Mon Sep 17 00:00:00 2001 From: Jessy jiang Date: Fri, 15 Feb 2019 14:08:33 +0800 Subject: flapjack: Enable backlight channel for Flapjack flapjack requires to enable LED Bias to control LCD backlight. For C18 boards, three channels are required, and each channel has a current of 24 mA. For C19 boards, four channels are required, each channel having a current of 23.5mA. BUG=b:124465980 BRANCH=none TEST=1:)When the system boots, the backlight will light up. 2:)Use the ectool commands to check the channel and current. channle: ectool i2cread 8 0 104 0xA0 current: ectool i2cread 8 0 104 0xA5 If it's C18 board, get 0xfa in channel command and 0xc8 in current command. If it's C19 board, get 0xfe in channel command and 0xc4 in current command. If the SKU value of the board is empty or incorrect, the default value is the data of the C18 board. Change-Id: I2e51feec830c4cfd46e3eaec0f9db0e1cfdd620c Reviewed-on: https://chromium-review.googlesource.com/1475094 Commit-Ready: Jessy Jiang Tested-by: Jessy Jiang Reviewed-by: Daisuke Nojiri --- board/flapjack/board.c | 20 ++++++++++++++++++++ board/flapjack/board.h | 3 +++ driver/charger/rt946x.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/board/flapjack/board.c b/board/flapjack/board.c index 13372d92f3..2077ff6b31 100644 --- a/board/flapjack/board.c +++ b/board/flapjack/board.c @@ -53,6 +53,25 @@ uint16_t board_version; uint8_t oem; uint32_t sku; +static void board_setup_panel(void) +{ + uint8_t channel; + uint8_t dim; + int rv = 0; + + channel = sku & SKU_ID_PANEL_SIZE_MASK ? 0xfe : 0xfa; + dim = sku & SKU_ID_PANEL_SIZE_MASK ? 0xc4 : 0xc8; + + rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLEN, + channel); + rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLDIM, + dim); + rv |= i2c_write8(I2C_PORT_CHARGER, RT946X_ADDR, MT6370_BACKLIGHT_BLPWM, + 0xac); + if (rv) + CPRINTS("Board setup panel failed\n"); +} + static void cbi_init(void) { uint32_t val; @@ -249,6 +268,7 @@ static void board_init(void) /* Enable gauge interrupt from max17055 */ gpio_enable_interrupt(GPIO_GAUGE_INT_ODL); + board_setup_panel(); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/flapjack/board.h b/board/flapjack/board.h index 65d410fff9..260e29b16b 100644 --- a/board/flapjack/board.h +++ b/board/flapjack/board.h @@ -200,6 +200,9 @@ (EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\ EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)) +/* Define panel size mask according to skuid */ +#define SKU_ID_PANEL_SIZE_MASK (1 << 1) + #ifndef __ASSEMBLER__ enum oem_id { diff --git a/driver/charger/rt946x.h b/driver/charger/rt946x.h index 9f1d682901..d91def7b4c 100644 --- a/driver/charger/rt946x.h +++ b/driver/charger/rt946x.h @@ -136,6 +136,10 @@ #define MT6370_REG_RGBCHRINDCTRL 0x93 #define RT946X_REG_DPDMIRQ 0xC6 +/* backlight */ +#define MT6370_BACKLIGHT_BLEN 0xA0 +#define MT6370_BACKLIGHT_BLPWM 0xA2 +#define MT6370_BACKLIGHT_BLDIM 0xA5 /* status event */ #define MT6370_REG_CHGSTAT1 0xD0 #define RT946X_REG_CHGSTATC MT6370_REG_CHGSTAT1 -- cgit v1.2.1