blob: 62c08e028dfcefe1689eb5228471de85f7c5e6da (
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
|
/* Copyright (c) 2013 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.
*/
/* System module for Chrome EC : MEC1322 hardware specific implementation */
#include "clock.h"
#include "common.h"
#include "console.h"
#include "cpu.h"
#include "host_command.h"
#include "registers.h"
#include "system.h"
#include "task.h"
#include "timer.h"
#include "util.h"
/* Indices for hibernate data registers (RAM backed by VBAT) */
enum hibdata_index {
HIBDATA_INDEX_SCRATCHPAD = 0, /* General-purpose scratchpad */
HIBDATA_INDEX_SAVED_RESET_FLAGS /* Saved reset flags */
};
void system_pre_init(void)
{
/* Enable direct NVIC */
MEC1322_EC_INT_CTRL |= 1;
/* Deassert nSIO_RESET */
MEC1322_PCR_PWR_RST_CTL &= ~(1 << 0);
}
void system_reset(int flags)
{
/* Trigger watchdog in 1ms */
MEC1322_WDG_LOAD = 1;
MEC1322_WDG_CTL |= 1;
}
const char *system_get_chip_vendor(void)
{
return "smsc";
}
const char *system_get_chip_name(void)
{
switch (MEC1322_CHIP_DEV_ID) {
case 0x15:
return "mec1322";
default:
return "unknown";
}
}
static char to_hex(int x)
{
if (x >= 0 && x <= 9)
return '0' + x;
return 'a' + x - 10;
}
const char *system_get_chip_revision(void)
{
static char buf[3];
uint8_t rev = MEC1322_CHIP_DEV_REV;
buf[0] = to_hex(rev / 16);
buf[1] = to_hex(rev & 0xf);
buf[2] = '\0';
return buf;
}
int system_get_vbnvcontext(uint8_t *block)
{
return EC_ERROR_UNIMPLEMENTED;
}
int system_set_vbnvcontext(const uint8_t *block)
{
return EC_ERROR_UNIMPLEMENTED;
}
int system_set_scratchpad(uint32_t value)
{
MEC1322_VBAT_RAM(HIBDATA_INDEX_SCRATCHPAD) = value;
return EC_SUCCESS;
}
uint32_t system_get_scratchpad(void)
{
return MEC1322_VBAT_RAM(HIBDATA_INDEX_SCRATCHPAD);
}
void system_hibernate(uint32_t seconds, uint32_t microseconds)
{
/* TODO(crosbug.com/p/24107): Implement this */
}
|