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. |
Martin Roth | 3a54318 | 2015-09-28 15:27:24 -0600 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef CONSOLE_SPI_H |
| 17 | #define CONSOLE_SPI_H 1 |
| 18 | |
| 19 | #include <rules.h> |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | void spiconsole_init(void); |
| 23 | void 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__ |
| 29 | static inline void __spiconsole_init(void) { spiconsole_init(); } |
| 30 | static inline void __spiconsole_tx_byte(u8 data) { spiconsole_tx_byte(data); } |
| 31 | #else |
| 32 | static inline void __spiconsole_init(void) {} |
| 33 | static 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 | |
| 42 | enum 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 | |
| 52 | struct 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 | |
| 61 | struct 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 */ |