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 CPU_SAMSUNG_EXYNOS5250_SPI_H
4 #define CPU_SAMSUNG_EXYNOS5250_SPI_H
5 
6 #include <boot_device.h>
7 
8 /* SPI peripheral register map; padded to 64KB */
9 struct exynos_spi {
10  unsigned int ch_cfg; /* 0x00 */
11  unsigned char reserved0[4];
12  unsigned int mode_cfg; /* 0x08 */
13  unsigned int cs_reg; /* 0x0c */
14  unsigned char reserved1[4];
15  unsigned int spi_sts; /* 0x14 */
16  unsigned int tx_data; /* 0x18 */
17  unsigned int rx_data; /* 0x1c */
18  unsigned int pkt_cnt; /* 0x20 */
19  unsigned char reserved2[4];
20  unsigned int swap_cfg; /* 0x28 */
21  unsigned int fb_clk; /* 0x2c */
22  unsigned char padding[0xffd0];
23 };
24 check_member(exynos_spi, fb_clk, 0x2c);
25 
26 #define EXYNOS_SPI_MAX_FREQ 50000000
27 
28 #define SPI_TIMEOUT_MS 10
29 
30 #define SF_READ_DATA_CMD 0x3
31 
32 /* SPI_CHCFG */
33 #define SPI_CH_HS_EN (1 << 6)
34 #define SPI_CH_RST (1 << 5)
35 #define SPI_SLAVE_MODE (1 << 4)
36 #define SPI_CH_CPOL_L (1 << 3)
37 #define SPI_CH_CPHA_B (1 << 2)
38 #define SPI_RX_CH_ON (1 << 1)
39 #define SPI_TX_CH_ON (1 << 0)
40 
41 /* SPI_MODECFG */
42 #define SPI_MODE_CH_WIDTH_WORD (0x2 << 29)
43 #define SPI_MODE_BUS_WIDTH_WORD (0x2 << 17)
44 
45 /* SPI_CSREG */
46 #define SPI_SLAVE_SIG_INACT (1 << 0)
47 
48 /* SPI_STS */
49 #define SPI_ST_TX_DONE (1 << 25)
50 #define SPI_FIFO_LVL_MASK 0x1ff
51 #define SPI_TX_LVL_OFFSET 6
52 #define SPI_RX_LVL_OFFSET 15
53 
54 /* Feedback Delay */
55 #define SPI_CLK_BYPASS (0 << 0)
56 #define SPI_FB_DELAY_90 (1 << 0)
57 #define SPI_FB_DELAY_180 (2 << 0)
58 #define SPI_FB_DELAY_270 (3 << 0)
59 
60 /* Packet Count */
61 #define SPI_PACKET_CNT_EN (1 << 16)
62 
63 /* Swap config */
64 #define SPI_TX_SWAP_EN (1 << 0)
65 #define SPI_TX_BYTE_SWAP (1 << 2)
66 #define SPI_TX_HWORD_SWAP (1 << 3)
67 #define SPI_TX_BYTE_SWAP (1 << 2)
68 #define SPI_RX_SWAP_EN (1 << 4)
69 #define SPI_RX_BYTE_SWAP (1 << 6)
70 #define SPI_RX_HWORD_SWAP (1 << 7)
71 
72 /* API */
73 int exynos_spi_open(struct exynos_spi *regs);
74 int exynos_spi_read(struct exynos_spi *regs, void *dest, u32 len, u32 off);
75 int exynos_spi_close(struct exynos_spi *regs);
76 
78 const struct region_device *exynos_spi_boot_device(void);
79 #endif
check_member(tegra_spi_regs, spare_ctl, 0x18c)
void exynos_init_spi_boot_device(void)
Definition: spi.c:167
const struct region_device * exynos_spi_boot_device(void)
Definition: spi.c:172
int exynos_spi_close(struct exynos_spi *regs)
Definition: spi.c:114
int exynos_spi_open(struct exynos_spi *regs)
Definition: spi.c:64
int exynos_spi_read(struct exynos_spi *regs, void *dest, u32 len, u32 off)
Definition: spi.c:92
uint32_t u32
Definition: stdint.h:51
Definition: spi.h:9
unsigned int tx_data
Definition: spi.h:16
unsigned int swap_cfg
Definition: spi.h:20
unsigned int cs_reg
Definition: spi.h:13
unsigned int mode_cfg
Definition: spi.h:12
unsigned char reserved2[4]
Definition: spi.h:19
unsigned char reserved0[4]
Definition: spi.h:11
unsigned int pkt_cnt
Definition: spi.h:18
unsigned int fb_clk
Definition: spi.h:21
unsigned int ch_cfg
Definition: spi.h:10
unsigned char reserved1[4]
Definition: spi.h:14
unsigned char padding[0xffd0]
Definition: spi.h:22
unsigned int spi_sts
Definition: spi.h:15
unsigned int rx_data
Definition: spi.h:17