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-31 14:11:30 +0000
commitb5f89ac98cc6714709ba201961abdc4486a62baa (patch)
tree798e0e604cab6b5566ece715924473692975db10
parentf59e6ae612a5274561b7def1ec8e683bb6ed861c (diff)
downloadchrome-ec-b5f89ac98cc6714709ba201961abdc4486a62baa.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> (cherry picked from commit e4d6fd51470e8e5302e20c0916da807bcb879208) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2385018 Reviewed-by: Henry Sun <henrysun@google.com> Commit-Queue: Henry Sun <henrysun@google.com> Tested-by: Henry Sun <henrysun@google.com>
-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_ */