summaryrefslogtreecommitdiff
path: root/board/dojo
diff options
context:
space:
mode:
authorTommy Chung <tommy.chung@quanta.corp-partner.google.com>2022-04-21 13:52:28 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-04-30 16:50:34 +0000
commit3c6bb0284ee03d234c35d3480b4b23668114f973 (patch)
tree3062f51429179f5d2a06c073a15f8f58f39b94b0 /board/dojo
parentc0d675dc0b43759c4eb4ba8eaeccdf919e312495 (diff)
downloadchrome-ec-3c6bb0284ee03d234c35d3480b4b23668114f973.tar.gz
dojo: Set up board FW_CONFIG parsing
Set up basic file to use for parsing FW_CONFIG. Currently, this just has a function to return the KB BL type and KB layout type. BUG=b:221315327 BRANCH=cherry TEST=make sure FW_CONFIG prints current value correctly. Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com> Change-Id: I1b220faf39868ee1b4716a54bb165fd693fba4de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3598692 Reviewed-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'board/dojo')
-rw-r--r--board/dojo/build.mk2
-rw-r--r--board/dojo/cbi_fw_config.c41
-rw-r--r--board/dojo/cbi_fw_config.h36
3 files changed, 78 insertions, 1 deletions
diff --git a/board/dojo/build.mk b/board/dojo/build.mk
index 0b0569c6d8..25af05d562 100644
--- a/board/dojo/build.mk
+++ b/board/dojo/build.mk
@@ -11,4 +11,4 @@ CHIP_FAMILY:=it8xxx2
CHIP_VARIANT:=it81202bx_1024
BASEBOARD:=cherry
-board-y+=led.o battery.o board.o
+board-y+=led.o battery.o board.o cbi_fw_config.o
diff --git a/board/dojo/cbi_fw_config.c b/board/dojo/cbi_fw_config.c
new file mode 100644
index 0000000000..9972e02249
--- /dev/null
+++ b/board/dojo/cbi_fw_config.c
@@ -0,0 +1,41 @@
+/* Copyright 2022 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 "cbi_fw_config.h"
+#include "common.h"
+#include "console.h"
+#include "cros_board_info.h"
+#include "hooks.h"
+
+/****************************************************************************
+ * Dojo CBI FW Configuration
+ */
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+
+/* Cache FW_CONFIG on init since we don't expect it to change in runtime */
+static uint32_t cached_fw_config;
+
+static void cbi_fw_config_init(void)
+{
+ if (cbi_get_fw_config(&cached_fw_config) != EC_SUCCESS)
+ /* Default to 0 when CBI isn't populated */
+ cached_fw_config = 0;
+
+ CPRINTS("FW_CONFIG: 0x%04X", cached_fw_config);
+}
+DECLARE_HOOK(HOOK_INIT, cbi_fw_config_init, HOOK_PRIO_FIRST);
+
+enum fw_config_kblight_type get_cbi_fw_config_kblight(void)
+{
+ return ((cached_fw_config & FW_CONFIG_KB_BL_MASK)
+ >> FW_CONFIG_KB_BL_OFFSET);
+}
+
+enum fw_config_kblayout_type get_cbi_fw_config_kblayout(void)
+{
+ return ((cached_fw_config & FW_CONFIG_KB_LAYOUT_MASK)
+ >> FW_CONFIG_KB_LAYOUT_OFFSET);
+}
diff --git a/board/dojo/cbi_fw_config.h b/board/dojo/cbi_fw_config.h
new file mode 100644
index 0000000000..7f98585b84
--- /dev/null
+++ b/board/dojo/cbi_fw_config.h
@@ -0,0 +1,36 @@
+/* Copyright 2022 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.
+ */
+
+#ifndef _DOJO_CBI_FW_CONFIG__H_
+#define _DOJO_CBI_FW_CONFIG__H_
+
+/****************************************************************************
+ * Dojo CBI FW Configuration
+ */
+
+/*
+ * Keyboard backlight (bit 0)
+ */
+enum fw_config_kblight_type {
+ KB_BL_ABSENT = 0,
+ KB_BL_PRESENT = 1,
+};
+#define FW_CONFIG_KB_BL_OFFSET 0
+#define FW_CONFIG_KB_BL_MASK GENMASK(0, 0)
+
+/*
+ * Keyboard layout (bit 4-5)
+ */
+enum fw_config_kblayout_type {
+ KB_BL_TOGGLE_KEY_ABSENT = 0, /* Vol-up key on T12 */
+ KB_BL_TOGGLE_KEY_PRESENT = 1, /* Vol-up key on T13 */
+};
+#define FW_CONFIG_KB_LAYOUT_OFFSET 4
+#define FW_CONFIG_KB_LAYOUT_MASK GENMASK(5, 4)
+
+enum fw_config_kblight_type get_cbi_fw_config_kblight(void);
+enum fw_config_kblayout_type get_cbi_fw_config_kblayout(void);
+
+#endif /* _DOJO_CBI_FW_CONFIG__H_ */