diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2019-05-14 10:19:05 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-22 20:56:28 -0700 |
commit | 2e45338bc3f0e4833c697878890e67c81ea8fcab (patch) | |
tree | 75c73a0ce9489379b732290390d3afac4f899147 /board/flapjack | |
parent | 1ef611a853c433337bbbbcf50064b6157f7ab18a (diff) | |
download | chrome-ec-2e45338bc3f0e4833c697878890e67c81ea8fcab.tar.gz |
Flapjack: Change pull-up to 3300 mV for BATT_ID and LCM_ID
Currently, BATT_ID and LCM_ID are pulled up to 1800 mV. This causes
inaccurate reading by ADC.
We change the pull-up to 3300 mV. This patch adjusts the thresholds
accordingly.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b/131857403
BRANCH=none
TEST=Verify LCM_ID and BATT_ID are read as expected on board_version=3.
Change-Id: I8693211fc6b1a40fb1b788d9c19db3d594f4bdf2
Reviewed-on: https://chromium-review.googlesource.com/1610427
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: YH Lin <yueherngl@chromium.org>
Diffstat (limited to 'board/flapjack')
-rw-r--r-- | board/flapjack/battery.c | 35 | ||||
-rw-r--r-- | board/flapjack/board.c | 37 | ||||
-rw-r--r-- | board/flapjack/board.h | 4 |
3 files changed, 57 insertions, 19 deletions
diff --git a/board/flapjack/battery.c b/board/flapjack/battery.c index 582b2d2e98..3c3825d5cf 100644 --- a/board/flapjack/battery.c +++ b/board/flapjack/battery.c @@ -278,24 +278,43 @@ static const struct { }, }; -static const struct mv_to_id batteries[] = { - { BATTERY_C18_ATL, 900 }, /* 100K ohm */ - { BATTERY_C19_ATL, 576 }, /* 47K ohm */ - { BATTERY_C18_SUNWODA, 1484 }, /* 470K ohm */ - { BATTERY_C19_SUNWODA, 1200 }, /* 200K ohm */ +/* BOARD_VERSION < 5: Pull-up = 1800 mV. */ +static const struct mv_to_id batteries0[] = { + { BATTERY_C18_ATL, 900 }, /* 100K ohm */ + { BATTERY_C19_ATL, 576 }, /* 47K ohm */ + { BATTERY_C18_SUNWODA, 1484 }, /* 470K ohm */ + { BATTERY_C19_SUNWODA, 1200 }, /* 200K ohm */ }; -BUILD_ASSERT(ARRAY_SIZE(batteries) < BATTERY_COUNT); +BUILD_ASSERT(ARRAY_SIZE(batteries0) < BATTERY_COUNT); + +/* BOARD_VERSION >= 5: Pull-up = 3300 mV. */ +static const struct mv_to_id batteries1[] = { + { BATTERY_C18_ATL, 1650 }, /* 100K ohm */ + { BATTERY_C19_ATL, 1055 }, /* 47K ohm */ + { BATTERY_C18_SUNWODA, 2721 }, /* 470K ohm */ + { BATTERY_C19_SUNWODA, 2200 }, /* 200K ohm */ +}; +BUILD_ASSERT(ARRAY_SIZE(batteries1) < BATTERY_COUNT); static enum battery_type batt_type = BATTERY_UNKNOWN; static void board_get_battery_type(void) { - int id = board_read_id(ADC_BATT_ID, batteries, ARRAY_SIZE(batteries)); + const struct mv_to_id *table = batteries0; + int size = ARRAY_SIZE(batteries0); + int id; + + if (board_version >= 5) { + table = batteries1; + size = ARRAY_SIZE(batteries1); + } + id = board_read_id(ADC_BATT_ID, table, size); if (id != ADC_READ_ERROR) batt_type = id; CPRINTS("Battery Type: %d", batt_type); } -DECLARE_HOOK(HOOK_INIT, board_get_battery_type, HOOK_PRIO_FIRST); +/* It has to run after BOARD_VERSION is read */ +DECLARE_HOOK(HOOK_INIT, board_get_battery_type, HOOK_PRIO_INIT_I2C + 2); const struct battery_info *battery_get_info(void) { diff --git a/board/flapjack/board.c b/board/flapjack/board.c index a6711bf449..a2e309fb77 100644 --- a/board/flapjack/board.c +++ b/board/flapjack/board.c @@ -6,6 +6,7 @@ #include "adc.h" #include "adc_chip.h" #include "backlight.h" +#include "board.h" #include "button.h" #include "charge_manager.h" #include "charge_state.h" @@ -56,13 +57,24 @@ #define SKU_ID_TO_LCM_ID(x) (((x) >> PANEL_ID_BIT_POSITION) & 0xf) #define LCM_ID_TO_SKU_ID(x) (((x) & 0xf) << PANEL_ID_BIT_POSITION) -static const struct mv_to_id panels[] = { - { PANEL_BOE_TV101WUM_NG0, 74 }, - { PANEL_BOE_TV080WUM_NG0, 212 }, - { PANEL_INX_OTA7290D10P, 1191 }, - { PANEL_AUO_NT51021D8P, 1027 }, +/* BOARD_VERSION < 5: Pull-up = 1800 mV. */ +static const struct mv_to_id panels0[] = { + { PANEL_BOE_TV101WUM_NG0, 74 }, /* 2.2 kohm */ + { PANEL_BOE_TV080WUM_NG0, 212 }, /* 6.8 kohm */ + { PANEL_STA_10P, 1191 }, /* 100 kohm */ + { PANEL_STA_08P, 1028 }, /* 68 kohm */ }; -BUILD_ASSERT(ARRAY_SIZE(panels) < PANEL_COUNT); +BUILD_ASSERT(ARRAY_SIZE(panels0) < PANEL_COUNT); + +/* BOARD_VERSION >= 5: Pull-up = 3300 mV. */ +static const struct mv_to_id panels1[] = { + { PANEL_BOE_TV101WUM_NG0, 136 }, /* 2.2 kohm */ + { PANEL_BOE_TV080WUM_NG0, 387 }, /* 6.8 kohm */ + { PANEL_STA_10P, 2184 }, /* 100 kohm */ + { PANEL_STA_08P, 1884 }, /* 68 kohm */ +}; +BUILD_ASSERT(ARRAY_SIZE(panels1) < PANEL_COUNT); + BUILD_ASSERT(PANEL_COUNT <= PANEL_UNINITIALIZED); uint8_t board_version; @@ -108,12 +120,12 @@ static void board_setup_panel(void) if (board_version >= 3) { switch (SKU_ID_TO_LCM_ID(sku)) { case PANEL_BOE_TV080WUM_NG0: - case PANEL_AUO_NT51021D8P: + case PANEL_STA_08P: channel = 0xfa; dim = 0xc8; break; case PANEL_BOE_TV101WUM_NG0: - case PANEL_INX_OTA7290D10P: + case PANEL_STA_10P: channel = 0xfe; dim = 0xc4; break; @@ -139,10 +151,17 @@ static void board_setup_panel(void) static enum panel_id board_get_panel_id(void) { enum panel_id id; + if (board_version < 3) { id = PANEL_DEFAULT; /* No LCM_ID. */ } else { - id = board_read_id(ADC_LCM_ID, panels, ARRAY_SIZE(panels)); + const struct mv_to_id *table = panels0; + int size = ARRAY_SIZE(panels0); + if (board_version >= 5) { + table = panels1; + size = ARRAY_SIZE(panels1); + } + id = board_read_id(ADC_LCM_ID, table, size); if (id < PANEL_DEFAULT || PANEL_COUNT <= id) id = PANEL_DEFAULT; } diff --git a/board/flapjack/board.h b/board/flapjack/board.h index c65bd6c735..ac154ad058 100644 --- a/board/flapjack/board.h +++ b/board/flapjack/board.h @@ -268,8 +268,8 @@ enum panel_id { PANEL_DEFAULT = 0, PANEL_BOE_TV101WUM_NG0, PANEL_BOE_TV080WUM_NG0, - PANEL_INX_OTA7290D10P, - PANEL_AUO_NT51021D8P, + PANEL_STA_10P, + PANEL_STA_08P, PANEL_COUNT, PANEL_UNINITIALIZED = 0xf, }; |