summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-04-17 18:02:05 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-04-20 17:21:59 +0000
commit837e768e90a8d32077450b90ab12c6f6c8ba682e (patch)
treeab9e8a987a1f663d9d92e1f1c05b6478de1225bf
parentea31c63917a728086d70de1221e64b2a1a6225c8 (diff)
downloadchrome-ec-stabilize-flapjack-12105.B.tar.gz
Flapjack: Embed LCM_ID in SKU_IDstabilize-flapjack-12105.B
This patch makes EC embed LCM_ID read from ADC in SKU_ID. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/129569858 BRANCH=none TEST=Read LCM_ID properly Change-Id: Ia0edfec82d40f70f44ecf00dc18564863e8acc2f Reviewed-on: https://chromium-review.googlesource.com/1573202 Commit-Ready: YH Lin <yueherngl@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: YH Lin <yueherngl@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1576627 Commit-Queue: YH Lin <yueherngl@chromium.org> Tested-by: YH Lin <yueherngl@chromium.org>
-rw-r--r--board/flapjack/board.c43
-rw-r--r--board/flapjack/board.h4
2 files changed, 38 insertions, 9 deletions
diff --git a/board/flapjack/board.c b/board/flapjack/board.c
index a1a83e4e22..f05616f853 100644
--- a/board/flapjack/board.c
+++ b/board/flapjack/board.c
@@ -50,6 +50,10 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+/* LCM_ID is embedded in SKU_ID bit[19-16] */
+#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_HIMAX8279D10P, 98 },
{ PANEL_BOE_HIMAX8279D8P, 280 },
@@ -58,7 +62,7 @@ BUILD_ASSERT(ARRAY_SIZE(panels) < PANEL_COUNT);
uint16_t board_version;
uint8_t oem;
-uint32_t sku;
+uint32_t sku = LCM_ID_TO_SKU_ID(PANEL_UNINITIALIZED);
int board_read_id(enum adc_channel ch, const struct mv_to_id *table, int size)
{
@@ -83,7 +87,7 @@ static void board_setup_panel(void)
int rv = 0;
if (board_version >= 3) {
- switch ((sku >> PANEL_ID_BIT_POSITION) & 0xf) {
+ switch (SKU_ID_TO_LCM_ID(sku)) {
case PANEL_BOE_HIMAX8279D8P:
channel = 0xfa;
dim = 0xc8;
@@ -113,13 +117,38 @@ static void board_setup_panel(void)
static enum panel_id board_get_panel_id(void)
{
- int id = board_read_id(ADC_LCM_ID, panels, ARRAY_SIZE(panels));
- if (id == ADC_READ_ERROR)
+ enum panel_id id;
+ if (board_version < 3) {
id = PANEL_UNKNOWN;
+ } else {
+ id = board_read_id(ADC_LCM_ID, panels, ARRAY_SIZE(panels));
+ if (id < PANEL_FIRST || PANEL_COUNT <= id)
+ id = PANEL_UNKNOWN;
+ }
CPRINTS("LCM ID: %d", id);
return id;
}
+#define CBI_SKU_ID_SIZE 4
+
+int cbi_board_override(enum cbi_data_tag tag, uint8_t *buf, uint8_t *size)
+{
+ switch (tag) {
+ case CBI_TAG_SKU_ID:
+ if (*size != CBI_SKU_ID_SIZE)
+ /* For old boards (board_version < 3) */
+ return EC_SUCCESS;
+ if (SKU_ID_TO_LCM_ID(sku) == PANEL_UNINITIALIZED)
+ /* Haven't read LCM_ID */
+ return EC_ERROR_BUSY;
+ buf[PANEL_ID_BIT_POSITION / 8] = SKU_ID_TO_LCM_ID(sku);
+ break;
+ default:
+ break;
+ }
+ return EC_SUCCESS;
+}
+
static void cbi_init(void)
{
uint32_t val;
@@ -132,13 +161,11 @@ static void cbi_init(void)
oem = val;
CPRINTS("OEM: %d", oem);
+ sku = LCM_ID_TO_SKU_ID(board_get_panel_id());
+
if (cbi_get_sku_id(&val) == EC_SUCCESS)
sku = val;
- if (board_version >= 3)
- /* Embed LCM_ID in sku_id bit[19-16] */
- sku |= ((board_get_panel_id() & 0xf) << PANEL_ID_BIT_POSITION);
-
CPRINTS("SKU: 0x%08x", sku);
}
DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1);
diff --git a/board/flapjack/board.h b/board/flapjack/board.h
index c3f697b3ae..6884f309a2 100644
--- a/board/flapjack/board.h
+++ b/board/flapjack/board.h
@@ -250,11 +250,13 @@ enum adc_channel {
/* Refer to coreboot/src/mainboard/google/kukui/display.h */
enum panel_id {
- PANEL_KUKUI_INNOLUX = 0,
+ PANEL_FIRST = 0,
+ PANEL_KUKUI_INNOLUX = PANEL_FIRST,
PANEL_BOE_HIMAX8279D10P,
PANEL_BOE_HIMAX8279D8P,
PANEL_UNKNOWN,
PANEL_COUNT,
+ PANEL_UNINITIALIZED,
};
/* power signal definitions */