coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spi.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __SOC_SIFIVE_HIFIVE_U_SPI_H__
4 #define __SOC_SIFIVE_HIFIVE_U_SPI_H__
5 #include <spi-generic.h>
6 
7 /* Data Pins: MOSI MISO */
8 #define FU540_SPI_PROTO_S 0
9 /* Data Pins: DQ0 DQ1 */
10 #define FU540_SPI_PROTO_D 1
11 /* Data Pins: DQ0 DQ1 DQ2 DQ3 */
12 #define FU540_SPI_PROTO_Q 2
13 
14 /* send MSB first */
15 #define FU540_SPI_ENDIAN_BIG 0
16 /* send LSB first */
17 #define FU540_SPI_ENDIAN_LITTLE 1
18 
19 /* inactive state of SCK is logical 0 */
20 #define FU540_SPI_PHA_LOW 0
21 /* inactive state of SCK is logical 1 */
22 #define FU540_SPI_PHA_HIGH 1
23 
24 /* data is sampled on leading edge */
25 #define FU540_SPI_POL_LEADING 0
26 /* data is sampled on trailing edge */
27 #define FU540_SPI_POL_TRAILING 1
28 
30  /* speed of spi interface */
31  unsigned int freq;
32  /* serial clock phase */
33  unsigned int pha;
34  /* serial clock polarity */
35  unsigned int pol;
36  unsigned int protocol;
37  unsigned int endianness;
38  /* up to 8bits */
39  unsigned int bits_per_frame;
40 };
41 
42 /* more detailed spi configuration */
43 int fu540_spi_setup(unsigned int bus, unsigned int cs, struct spi_slave *slave,
44  struct fu540_spi_config *config);
45 
46 /* This structure is used to describe the read command of SPI FLASH. */
48  /* enable sending of command */
49  unsigned int cmd_en;
50  /* number of address bytes (0-4) */
51  unsigned int addr_len;
52  /* number of dummy cycles */
53  unsigned int pad_cnt;
54  /* protocol for transmitting command */
55  unsigned int cmd_proto;
56  /* protocol for transmitting address and padding */
57  unsigned int addr_proto;
58  /* protocol for receiving data bytes */
59  unsigned int data_proto;
60  /* value of command byte */
61  unsigned int cmd_code;
62  /* first 8 bits to transmit during dummy cycles */
63  unsigned int pad_code;
64 };
65 
66 int fu540_spi_mmap(
67  const struct spi_slave *slave,
68  const struct fu540_spi_mmap_config *config);
69 
70 #endif /* __SOC_SIFIVE_HIFIVE_U_SPI_H__ */
enum board_config config
Definition: memory.c:448
int fu540_spi_mmap(const struct spi_slave *slave, const struct fu540_spi_mmap_config *config)
Definition: spi.c:213
int fu540_spi_setup(unsigned int bus, unsigned int cs, struct spi_slave *slave, struct fu540_spi_config *config)
Definition: spi.c:165
static struct spi_slave slave
Definition: spiconsole.c:7
Definition: device.h:76
unsigned int pol
Definition: spi.h:35
unsigned int freq
Definition: spi.h:31
unsigned int pha
Definition: spi.h:33
unsigned int protocol
Definition: spi.h:36
unsigned int bits_per_frame
Definition: spi.h:39
unsigned int endianness
Definition: spi.h:37
unsigned int addr_proto
Definition: spi.h:57
unsigned int pad_cnt
Definition: spi.h:53
unsigned int cmd_en
Definition: spi.h:49
unsigned int pad_code
Definition: spi.h:63
unsigned int addr_len
Definition: spi.h:51
unsigned int cmd_proto
Definition: spi.h:55
unsigned int cmd_code
Definition: spi.h:61
unsigned int data_proto
Definition: spi.h:59