coreboot-kgpe-d16/src/include/console/spi.h

72 lines
1.7 KiB
C
Raw Normal View History

/*
* This file is part of the coreboot project.
*
* Copyright 2015 Google Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef CONSOLE_SPI_H
#define CONSOLE_SPI_H 1
#include <rules.h>
#include <stdint.h>
void spiconsole_init(void);
void spiconsole_tx_byte(unsigned char c);
src/include: Add parenthesis around macros Fix the following error found by checkpatch.pl: ERROR: Macros with complex values should be enclosed in parentheses False positives are detected for attribute macros. An example is: ERROR: Macros with complex values should be enclosed in parentheses +#define BOOT_STATE_INIT_ATTR __attribute__ ((used, section (".bs_init"))) False positive also generated for macros for linker script files. An example is: ERROR: Macros with complex values should be enclosed in parentheses +#define CBFS_CACHE(addr, size) \ + REGION(cbfs_cache, addr, size, 4) \ + ALIAS_REGION(cbfs_cache, preram_cbfs_cache) \ + ALIAS_REGION(cbfs_cache, postram_cbfs_cache) False positives generated for assembly code macros. An example is: ERROR: Macros with complex values should be enclosed in parentheses +#define DECLARE_OPTIONAL_REGION(name) asm (".weak _" #name ", _e" #name ) False positive detected when macro includes multiple comma separated values. The following code is from src/include/device/azalia_device.h: #define AZALIA_SUBVENDOR(codec, val) \ (((codec) << 28) | (0x01720 << 8) | ((val) & 0xff)), \ (((codec) << 28) | (0x01721 << 8) | (((val) >> 8) & 0xff)), \ (((codec) << 28) | (0x01722 << 8) | (((val) >> 16) & 0xff)), \ (((codec) << 28) | (0x01723 << 8) | (((val) >> 24) & 0xff)) TEST=Build and run on Galileo Gen2 Change-Id: I6e3b6950738e6906851a172ba3a22e3d5af1e35d Signed-off-by: Lee Leahy <Leroy.P.Leahy@intel.com> Reviewed-on: https://review.coreboot.org/18649 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-03-07 22:17:49 +01:00
#define __CONSOLE_SPI_ENABLE__ (CONFIG_SPI_CONSOLE && \
(ENV_RAMSTAGE || (ENV_SMM && CONFIG_DEBUG_SMI)))
#if __CONSOLE_SPI_ENABLE__
static inline void __spiconsole_init(void) { spiconsole_init(); }
static inline void __spiconsole_tx_byte(u8 data)
{
spiconsole_tx_byte(data);
}
#else
static inline void __spiconsole_init(void) {}
static inline void __spiconsole_tx_byte(u8 data) {}
#endif /* __CONSOLE_SPI_ENABLE__ */
#define MAX_MSG_LENGTH 128
#define EM100_DEDICATED_CMD 0x11
#define EM100_UFIFO_CMD 0xC0
#define EM100_MSG_SIGNATURE 0x47364440
enum em100_message_types {
EM100_MSG_CHECKPOINT_1B = 0x01,
EM100_MSG_CHECKPOINT_2B,
EM100_MSG_CHECKPOINT_4B,
EM100_MSG_HEX,
EM100_MSG_ASCII,
EM100_MSG_TIMESTAMP,
EM100_MSG_LOOKUP
};
struct em100_msg_header {
uint8_t spi_command;
uint8_t reserved;
uint8_t em100_command;
uint32_t msg_signature;
uint8_t msg_type;
uint8_t msg_length;
} __attribute__ ((packed));
struct em100_msg {
struct em100_msg_header header;
char data[MAX_MSG_LENGTH];
} __attribute__ ((packed));
#endif /* CONSOLE_SPI_H */