summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorRobert Zieba <robertzieba@google.com>2023-02-02 17:28:32 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-02-16 18:47:43 +0000
commit2b46c0135d4e7c51bf648da476c442d8e6398b8b (patch)
tree49d8aac9f72e823555022547a38aba9714482913 /driver
parent35159ec25d0dbb7b4dad8bb11d97808c5a016be0 (diff)
downloadchrome-ec-2b46c0135d4e7c51bf648da476c442d8e6398b8b.tar.gz
power/amd_x86: Add support for STB dumping
Skyrim supports dumping the contents of the SoCs smart-trace buffer when triggered externally. The contents of the STB can be useful in debugging S0i3 suspend failures. Add support for triggering an STB dump when the SoC hangs during S0i3 entry/exit. BRANCH=none BUG=b:246770811 TEST=Ran on skyrim DUT Change-Id: Ie18c6072a77f6dd306a46d7f76bd345b4f9e75a7 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4220248 Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/amd_stb.c77
-rw-r--r--driver/amd_stb.h15
2 files changed, 92 insertions, 0 deletions
diff --git a/driver/amd_stb.c b/driver/amd_stb.c
new file mode 100644
index 0000000000..9d847bb524
--- /dev/null
+++ b/driver/amd_stb.c
@@ -0,0 +1,77 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Driver for AMD STB dump functionality */
+#include "chipset.h"
+#include "driver/amd_stb.h"
+#include "hooks.h"
+
+#ifndef CONFIG_ZTEST
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ##args)
+#else
+#define CPRINTS(format, args...) printk(format, ##args)
+#endif
+
+static bool stb_dump_in_progress;
+static struct {
+ /* Interrupt from EC to AP. */
+ const struct gpio_dt_spec *int_out;
+ /* Interrupt from AP to EC. */
+ const struct gpio_dt_spec *int_in;
+} stb_dump_config;
+
+void amd_stb_dump_finish(void)
+{
+ gpio_pin_set_dt(stb_dump_config.int_out, 0);
+ stb_dump_in_progress = false;
+}
+
+void amd_stb_dump_trigger(void)
+{
+ if (stb_dump_in_progress || !stb_dump_config.int_out)
+ return;
+
+ CPRINTS("Triggering STB dump");
+ stb_dump_in_progress = true;
+ gpio_pin_set_dt(stb_dump_config.int_out, 1);
+}
+
+void amd_stb_dump_init(const struct gpio_dt_spec *int_out,
+ const struct gpio_dt_spec *int_in)
+{
+ stb_dump_config.int_out = int_out;
+ stb_dump_config.int_in = int_in;
+}
+
+static void stb_dump_interrupt_deferred(void)
+{
+ /* AP has indicated that it has finished the dump. */
+ if (!stb_dump_in_progress)
+ return;
+
+ amd_stb_dump_finish();
+ CPRINTS("STB dump finished");
+}
+DECLARE_DEFERRED(stb_dump_interrupt_deferred);
+
+bool amd_stb_dump_in_progress(void)
+{
+ return stb_dump_in_progress;
+}
+
+void amd_stb_dump_interrupt(enum gpio_signal signal)
+{
+ hook_call_deferred(&stb_dump_interrupt_deferred_data, 0);
+}
+
+#ifdef CONFIG_PLATFORM_EC_AMD_STB_DUMP_CMD
+static int command_amdstbdump(int argc, const char **argv)
+{
+ amd_stb_dump_trigger();
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(amdstbdump, command_amdstbdump, NULL,
+ "Trigger an STB dump");
+#endif
diff --git a/driver/amd_stb.h b/driver/amd_stb.h
new file mode 100644
index 0000000000..5c339c66e5
--- /dev/null
+++ b/driver/amd_stb.h
@@ -0,0 +1,15 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include <stddef.h>
+
+#include <gpio_signal.h>
+
+struct gpio_dt_spec;
+void amd_stb_dump_finish(void);
+void amd_stb_dump_init(const struct gpio_dt_spec *int_out,
+ const struct gpio_dt_spec *int_in);
+bool amd_stb_dump_in_progress(void);
+void amd_stb_dump_interrupt(enum gpio_signal signal);
+void amd_stb_dump_trigger(void);