Martin Roth | 3a54318 | 2015-09-28 15:27:24 -0600 | [diff] [blame^] | 1 | /* |
| 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 | |
| 26 | void spiconsole_init(void); |
| 27 | void 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__ |
| 33 | static inline void __spiconsole_init(void) { spiconsole_init(); } |
| 34 | static inline void __spiconsole_tx_byte(u8 data) { spiconsole_tx_byte(data); } |
| 35 | #else |
| 36 | static inline void __spiconsole_init(void) {} |
| 37 | static 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 | |
| 46 | enum 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 | |
| 56 | struct 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 | |
| 65 | struct 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 */ |