1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
|