/ src / include / console / spi.h
spi.h
 1  /* SPDX-License-Identifier: GPL-2.0-only */
 2  
 3  #ifndef CONSOLE_SPI_H
 4  #define CONSOLE_SPI_H 1
 5  
 6  #include <stdint.h>
 7  
 8  void spiconsole_init(void);
 9  void spiconsole_tx_byte(unsigned char c);
10  
11  #define __CONSOLE_SPI_ENABLE__	(CONFIG(EM100PRO_SPI_CONSOLE) && \
12  	(ENV_RAMSTAGE || (ENV_SMM && CONFIG(DEBUG_SMI))))
13  
14  #if __CONSOLE_SPI_ENABLE__
15  static inline void __spiconsole_init(void)	{ spiconsole_init(); }
16  static inline void __spiconsole_tx_byte(u8 data)
17  {
18  	spiconsole_tx_byte(data);
19  }
20  #else
21  static inline void __spiconsole_init(void)	{}
22  static inline void __spiconsole_tx_byte(u8 data)	{}
23  #endif /* __CONSOLE_SPI_ENABLE__ */
24  
25  #define MAX_MSG_LENGTH	128
26  
27  #define EM100_DEDICATED_CMD	0x11
28  #define EM100_UFIFO_CMD		0xC0
29  #define EM100_MSG_SIGNATURE	0x47364440
30  
31  enum em100_message_types {
32  	EM100_MSG_CHECKPOINT_1B = 0x01,
33  	EM100_MSG_CHECKPOINT_2B,
34  	EM100_MSG_CHECKPOINT_4B,
35  	EM100_MSG_HEX,
36  	EM100_MSG_ASCII,
37  	EM100_MSG_TIMESTAMP,
38  	EM100_MSG_LOOKUP
39  };
40  
41  struct em100_msg_header {
42  	uint8_t		spi_command;
43  	uint8_t		reserved;
44  	uint8_t		em100_command;
45  	uint32_t	msg_signature;
46  	uint8_t		msg_type;
47  	uint8_t		msg_length;
48  } __packed;
49  
50  struct em100_msg {
51  	struct em100_msg_header header;
52  	char data[MAX_MSG_LENGTH];
53  } __packed;
54  
55  #endif /* CONSOLE_SPI_H */