blob: ddf99127e35361ef736eff80bb2c05d84bd51d54 (
plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/* Copyright (c) 2012 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.
*/
/* Mock X86 chipset power control module for Chrome EC */
#include "chipset.h"
#include "console.h"
#include "lpc.h"
#include "timer.h"
#include "uart.h"
#include "util.h"
#include "x86_power.h"
static int mock_power_on = 0;
void x86_power_cpu_overheated(int too_hot)
{
/* Print transitions */
static int last_val = 0;
if (too_hot != last_val) {
if (too_hot)
uart_printf("CPU overheated.\n");
else
uart_printf("CPU no longer overheated.\n");
last_val = too_hot;
}
}
void x86_power_force_shutdown(void)
{
uart_puts("Force shutdown\n");
mock_power_on = 0;
}
void x86_power_reset(int cold_reset)
{
uart_printf("X86 Power %s reset\n", cold_reset ? "cold" : "warm");
}
void chipset_throttle_cpu(int throttle)
{
/* Print transitions */
static int last_val = 0;
if (throttle != last_val) {
if (throttle)
uart_printf("Throttle CPU.\n");
else
uart_printf("No longer throttle CPU.\n");
last_val = throttle;
}
}
void chipset_exit_hard_off(void)
{
/* Not implemented */
return;
}
int chipset_in_state(int state_mask)
{
if (mock_power_on)
return state_mask == CHIPSET_STATE_ON;
else
return (state_mask == CHIPSET_STATE_SOFT_OFF) ||
(state_mask == CHIPSET_STATE_ANY_OFF);
}
void x86_power_interrupt(enum gpio_signal signal)
{
/* Not implemented */
return;
}
void x86_power_task(void)
{
/* Do nothing */
while (1)
sleep(5);
}
static int command_mock_power(int argc, char **argv)
{
if (argc != 2)
return EC_ERROR_PARAM_COUNT;
if (!strcasecmp(argv[1], "on")) {
mock_power_on = 1;
}
else if (!strcasecmp(argv[1], "off")) {
mock_power_on = 0;
}
else
return EC_ERROR_PARAM1;
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(powermock, command_mock_power,
"<on | off>",
"Mock power state",
NULL);
|