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_SPI_H__
4 #define __SOC_SPI_H__
5 
6 #include <spi_flash.h>
7 #include <spi-generic.h>
8 
9 #define SPISTS 0x3020 /* Status register */
10 #define SPICTL 0x3022 /* Control register */
11 #define SPIADDR 0x3024 /* Flash chip select and 24-bit address */
12 #define SPIDATA 0x3028 /* 64-byte send/receive data buffer */
13 #define SPIBBAR 0x3070 /* BIOS base address */
14 #define SPIPREOP 0x3074 /* Prefix opcode table */
15 #define SPITYPE 0x3076 /* Opcode type table */
16 #define SPIOPMENU 0x3078 /* Opcode table */
17 #define SPIPBR0 0x3080 /* Protected BIOS range */
18 #define SPIPBR1 0x3084
19 #define SPIPBR2 0x3088
20 
21 struct flash_ctrlr {
22  uint8_t rsvd_0x00[0x3020];/* 0x00 */
23  uint16_t status; /* 0x3020: Status register */
24  uint16_t control; /* 0x3022: Control register */
25  uint32_t address; /* 0x3024: Chip select and 24-bit address */
26  uint8_t data[64]; /* 0x3028: 64-byte send/receive data buffer */
27  uint8_t rsvd_0x68[8]; /* 0x3068 */
28  uint32_t bbar; /* 0x3070: BIOS base address */
29  uint8_t prefix[2]; /* 0x3074: Prefix opcode table */
30  uint16_t type; /* 0x3076: Opcode type table */
31  uint8_t opmenu[8]; /* 0x3078: Opcode table */
32  uint32_t pbr[3]; /* 0x3080: Protected BIOS range */
33 };
34 
35 /* 0x3020: SPISTS */
36 #define SPISTS_CLD 0x8000 /* Lock SPI controller configuration */
37 #define SPISTS_BA 0x0008 /* Access is blocked */
38 #define SPISTS_CD 0x0004 /* Cycle done */
39 #define SPISTS_CIP 0x0001 /* Cycle in progress */
40 
41 /* 0x3022: SPICTL */
42 #define SPICTL_SMIEN 0x8000 /* Assert SMI_B at cycle done */
43 #define SPICTL_DC 0x4000 /* Cycle contains data */
44 #define SPICTL_DBCNT 0x3f00 /* Data byte count - 1, 1 - 64 bytes */
45 #define SPICTL_DBCNT_SHIFT 8
46 #define SPICTL_COPTR 0x0070 /* Opcode menu index, 0 - 7 */
47 #define SPICTL_COPTR_SHIFT 4
48 #define SPICTL_SOPTR 0x0008 /* Prefix index, 0 - 1 */
49 #define SPICTL_SOPTR_SHIFT 3
50 #define SPICTL_ACS 0x0004 /* Atomic cycle sequence */
51 #define SPICTL_CG 0x0002 /* Cycle go */
52 #define SPICTL_AR 0x0001 /* Access request */
53 
54 /* 0x3076: SPITYPE */
55 #define SPITYPE_ADDRESS 0x0002 /* 3-byte address required */
56 #define SPITYPE_PREFIX 0x0001 /* Prefix required, write/erase cycle */
57 
58 /*
59  * 0x3080: PBR0
60  * 0x3084: PBR1
61  * 0x3088: PBR2
62  */
63 #define SPIPBR_WPE 0x80000000 /* Write protect enable */
64 #define SPIPBR_PRL 0x00fff000 /* Protected range limit */
65 #define SPIPBR_PRB_SHIFT 12
66 #define SPIPBR_PRB 0x00000fff /* Protected range base */
67 
68 struct spi_context {
69  volatile struct flash_ctrlr *ctrlr;
72 };
73 
74 extern const struct spi_ctrlr spi_driver;
75 
76 void spi_bios_base(uint32_t bios_base_address);
77 void spi_controller_lock(void);
78 void spi_display(volatile struct flash_ctrlr *ctrlr);
79 const char *spi_opcode_name(int opcode);
81 
82 #endif /* __SOC_SPI_H__ */
uint64_t length
Definition: fw_cfg_if.h:1
uint64_t address
Definition: fw_cfg_if.h:0
int spi_protection(uint32_t address, uint32_t length)
Definition: spi.c:39
void spi_controller_lock(void)
Definition: spi.c:31
void spi_display(volatile struct flash_ctrlr *ctrlr)
Definition: spi_debug.c:48
const struct spi_ctrlr spi_driver
Definition: spi.c:277
const char * spi_opcode_name(int opcode)
Definition: spi_debug.c:6
void spi_bios_base(uint32_t bios_base_address)
Definition: spi.c:21
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8
uint8_t opmenu[8]
Definition: spi.h:31
uint16_t type
Definition: spi.h:30
uint8_t data[64]
Definition: spi.h:26
uint8_t rsvd_0x00[0x3020]
Definition: spi.h:22
uint32_t address
Definition: spi.h:25
uint32_t bbar
Definition: spi.h:28
uint16_t control
Definition: spi.h:24
uint32_t pbr[3]
Definition: spi.h:32
uint16_t status
Definition: spi.h:23
uint8_t prefix[2]
Definition: spi.h:29
uint8_t rsvd_0x68[8]
Definition: spi.h:27
uint16_t prefix
Definition: spi.h:71
volatile struct flash_ctrlr * ctrlr
Definition: spi.h:69
uint16_t control
Definition: spi.h:70