blob: bf58a369158120c48924dfa670fda55b529bdea1 [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.
Martin Roth3a543182015-09-28 15:27:24 -060014 */
15
16#ifndef CONSOLE_SPI_H
17#define CONSOLE_SPI_H 1
18
19#include <rules.h>
20#include <stdint.h>
21
22void spiconsole_init(void);
23void spiconsole_tx_byte(unsigned char c);
24
25#define __CONSOLE_SPI_ENABLE__ CONFIG_SPI_CONSOLE && \
26 (ENV_RAMSTAGE || (ENV_SMM && CONFIG_DEBUG_SMI))
27
28#if __CONSOLE_SPI_ENABLE__
29static inline void __spiconsole_init(void) { spiconsole_init(); }
30static inline void __spiconsole_tx_byte(u8 data) { spiconsole_tx_byte(data); }
31#else
32static inline void __spiconsole_init(void) {}
33static inline void __spiconsole_tx_byte(u8 data) {}
34#endif /* __CONSOLE_SPI_ENABLE__ */
35
36#define MAX_MSG_LENGTH 128
37
38#define EM100_DEDICATED_CMD 0x11
39#define EM100_UFIFO_CMD 0xC0
40#define EM100_MSG_SIGNATURE 0x47364440
41
42enum em100_message_types {
43 EM100_MSG_CHECKPOINT_1B = 0x01,
44 EM100_MSG_CHECKPOINT_2B,
45 EM100_MSG_CHECKPOINT_4B,
46 EM100_MSG_HEX,
47 EM100_MSG_ASCII,
48 EM100_MSG_TIMESTAMP,
49 EM100_MSG_LOOKUP
50};
51
52struct em100_msg_header {
53 uint8_t spi_command;
54 uint8_t reserved;
55 uint8_t em100_command;
56 uint32_t msg_signature;
57 uint8_t msg_type;
58 uint8_t msg_length;
59} __attribute__ ((packed));
60
61struct em100_msg {
62 struct em100_msg_header header;
63 char data[MAX_MSG_LENGTH];
64} __attribute__ ((packed));
65
66
67
68#endif /* CONSOLE_SPI_H */