summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Chen <marcochen@google.com>2020-08-26 18:04:14 +0800
committerCommit Bot <commit-bot@chromium.org>2020-08-29 22:43:20 +0000
commit5ce176d76cb0779d7e3e8c0fc9d0f9a743ecf94d (patch)
tree6603918d68e6513398e9d876c049922f028de363
parentcd27f2d3cf95ee15e254f2e6d92a81675b2f925e (diff)
downloadchrome-ec-5ce176d76cb0779d7e3e8c0fc9d0f9a743ecf94d.tar.gz
Octopus: Initiate the first version of parsing SSFC of CBI
Initiate the helper functions to parse the SSFC of CBI. The first and only component in this version is TCPC in the port 1. BRANCH=octopus BUG=b:163922535 TEST=EC log of Meep device can output value of SSFC in CBI Signed-off-by: Marco Chen <marcochen@chromium.org> Change-Id: Iaee608a8b9791796fff0b31599c8be1bdc07cf3e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2377058 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2383923 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Edward Hill <ecgh@chromium.org>
-rw-r--r--baseboard/octopus/build.mk2
-rw-r--r--baseboard/octopus/cbi_ssfc.c34
-rw-r--r--baseboard/octopus/cbi_ssfc.h26
3 files changed, 61 insertions, 1 deletions
diff --git a/baseboard/octopus/build.mk b/baseboard/octopus/build.mk
index efb37acb04..bb8a6f8267 100644
--- a/baseboard/octopus/build.mk
+++ b/baseboard/octopus/build.mk
@@ -6,7 +6,7 @@
# Baseboard specific files build
#
-baseboard-y=baseboard.o
+baseboard-y=baseboard.o cbi_ssfc.o
baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o
baseboard-$(VARIANT_OCTOPUS_EC_NPCX796FB)+=variant_ec_npcx796fb.o
baseboard-$(VARIANT_OCTOPUS_EC_ITE8320)+=variant_ec_ite8320.o
diff --git a/baseboard/octopus/cbi_ssfc.c b/baseboard/octopus/cbi_ssfc.c
new file mode 100644
index 0000000000..e4048e898f
--- /dev/null
+++ b/baseboard/octopus/cbi_ssfc.c
@@ -0,0 +1,34 @@
+/* Copyright 2020 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_ssfc.h"
+#include "common.h"
+#include "console.h"
+#include "cros_board_info.h"
+#include "hooks.h"
+
+/****************************************************************************
+ * Octopus CBI Second Source Factory Cache
+ */
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+
+/* Cache SSFC on init since we don't expect it to change in runtime */
+static uint32_t cached_ssfc;
+
+static void cbi_ssfc_init(void)
+{
+ if (cbi_get_ssfc(&cached_ssfc) != EC_SUCCESS)
+ /* Default to 0 when CBI isn't populated */
+ cached_ssfc = 0;
+
+ CPRINTS("CBI SSFC: 0x%04X", cached_ssfc);
+}
+DECLARE_HOOK(HOOK_INIT, cbi_ssfc_init, HOOK_PRIO_FIRST);
+
+enum ssfc_tcpc_p1 get_cbi_ssfc_tcpc_p1(void)
+{
+ return ((cached_ssfc & SSFC_TCPC_P1_MASK) >> SSFC_TCPC_P1_OFFSET);
+}
diff --git a/baseboard/octopus/cbi_ssfc.h b/baseboard/octopus/cbi_ssfc.h
new file mode 100644
index 0000000000..e8ef54e3fc
--- /dev/null
+++ b/baseboard/octopus/cbi_ssfc.h
@@ -0,0 +1,26 @@
+/* Copyright 2020 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 _OCTOPUS_CBI_SSFC__H_
+#define _OCTOPUS_CBI_SSFC__H_
+
+/****************************************************************************
+ * Octopus CBI Second Source Factory Cache
+ */
+
+/*
+ * TCPC Port 1 (Bits 0-2)
+ */
+enum ssfc_tcpc_p1 {
+ TCPC_P1_DEFAULT,
+ TCPC_P1_PS8751,
+ TCPC_P1_PS8755,
+};
+#define SSFC_TCPC_P1_OFFSET 0
+#define SSFC_TCPC_P1_MASK GENMASK(2, 0)
+
+enum ssfc_tcpc_p1 get_cbi_ssfc_tcpc_p1(void);
+
+#endif /* _OCTOPUS_CBI_SSFC__H_ */