blob: c47fec541a583c1889ea4bc517ee8c3a9b872180 [file] [log] [blame]
Martin Roth3a543182015-09-28 15:27:24 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2015 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc.
18 */
19
20#ifndef CONSOLE_SPI_H
21#define CONSOLE_SPI_H 1
22
23#include <rules.h>
24#include <stdint.h>
25
26void spiconsole_init(void);
27void spiconsole_tx_byte(unsigned char c);
28
29#define __CONSOLE_SPI_ENABLE__ CONFIG_SPI_CONSOLE && \
30 (ENV_RAMSTAGE || (ENV_SMM && CONFIG_DEBUG_SMI))
31
32#if __CONSOLE_SPI_ENABLE__
33static inline void __spiconsole_init(void) { spiconsole_init(); }
34static inline void __spiconsole_tx_byte(u8 data) { spiconsole_tx_byte(data); }
35#else
36static inline void __spiconsole_init(void) {}
37static inline void __spiconsole_tx_byte(u8 data) {}
38#endif /* __CONSOLE_SPI_ENABLE__ */
39
40#define MAX_MSG_LENGTH 128
41
42#define EM100_DEDICATED_CMD 0x11
43#define EM100_UFIFO_CMD 0xC0
44#define EM100_MSG_SIGNATURE 0x47364440
45
46enum em100_message_types {
47 EM100_MSG_CHECKPOINT_1B = 0x01,
48 EM100_MSG_CHECKPOINT_2B,
49 EM100_MSG_CHECKPOINT_4B,
50 EM100_MSG_HEX,
51 EM100_MSG_ASCII,
52 EM100_MSG_TIMESTAMP,
53 EM100_MSG_LOOKUP
54};
55
56struct em100_msg_header {
57 uint8_t spi_command;
58 uint8_t reserved;
59 uint8_t em100_command;
60 uint32_t msg_signature;
61 uint8_t msg_type;
62 uint8_t msg_length;
63} __attribute__ ((packed));
64
65struct em100_msg {
66 struct em100_msg_header header;
67 char data[MAX_MSG_LENGTH];
68} __attribute__ ((packed));
69
70
71
72#endif /* CONSOLE_SPI_H */