coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spi.h File Reference
#include <spi_flash.h>
#include <spi-generic.h>
Include dependency graph for spi.h:

Go to the source code of this file.

Data Structures

struct  flash_ctrlr
 
struct  spi_context
 

Macros

#define SPISTS   0x3020 /* Status register */
 
#define SPICTL   0x3022 /* Control register */
 
#define SPIADDR   0x3024 /* Flash chip select and 24-bit address */
 
#define SPIDATA   0x3028 /* 64-byte send/receive data buffer */
 
#define SPIBBAR   0x3070 /* BIOS base address */
 
#define SPIPREOP   0x3074 /* Prefix opcode table */
 
#define SPITYPE   0x3076 /* Opcode type table */
 
#define SPIOPMENU   0x3078 /* Opcode table */
 
#define SPIPBR0   0x3080 /* Protected BIOS range */
 
#define SPIPBR1   0x3084
 
#define SPIPBR2   0x3088
 
#define SPISTS_CLD   0x8000 /* Lock SPI controller configuration */
 
#define SPISTS_BA   0x0008 /* Access is blocked */
 
#define SPISTS_CD   0x0004 /* Cycle done */
 
#define SPISTS_CIP   0x0001 /* Cycle in progress */
 
#define SPICTL_SMIEN   0x8000 /* Assert SMI_B at cycle done */
 
#define SPICTL_DC   0x4000 /* Cycle contains data */
 
#define SPICTL_DBCNT   0x3f00 /* Data byte count - 1, 1 - 64 bytes */
 
#define SPICTL_DBCNT_SHIFT   8
 
#define SPICTL_COPTR   0x0070 /* Opcode menu index, 0 - 7 */
 
#define SPICTL_COPTR_SHIFT   4
 
#define SPICTL_SOPTR   0x0008 /* Prefix index, 0 - 1 */
 
#define SPICTL_SOPTR_SHIFT   3
 
#define SPICTL_ACS   0x0004 /* Atomic cycle sequence */
 
#define SPICTL_CG   0x0002 /* Cycle go */
 
#define SPICTL_AR   0x0001 /* Access request */
 
#define SPITYPE_ADDRESS   0x0002 /* 3-byte address required */
 
#define SPITYPE_PREFIX   0x0001 /* Prefix required, write/erase cycle */
 
#define SPIPBR_WPE   0x80000000 /* Write protect enable */
 
#define SPIPBR_PRL   0x00fff000 /* Protected range limit */
 
#define SPIPBR_PRB_SHIFT   12
 
#define SPIPBR_PRB   0x00000fff /* Protected range base */
 

Functions

void spi_bios_base (uint32_t bios_base_address)
 
void spi_controller_lock (void)
 
void spi_display (volatile struct flash_ctrlr *ctrlr)
 
const char * spi_opcode_name (int opcode)
 
int spi_protection (uint32_t address, uint32_t length)
 

Variables

const struct spi_ctrlr spi_driver
 

Macro Definition Documentation

◆ SPIADDR

#define SPIADDR   0x3024 /* Flash chip select and 24-bit address */

Definition at line 11 of file spi.h.

◆ SPIBBAR

#define SPIBBAR   0x3070 /* BIOS base address */

Definition at line 13 of file spi.h.

◆ SPICTL

#define SPICTL   0x3022 /* Control register */

Definition at line 10 of file spi.h.

◆ SPICTL_ACS

#define SPICTL_ACS   0x0004 /* Atomic cycle sequence */

Definition at line 50 of file spi.h.

◆ SPICTL_AR

#define SPICTL_AR   0x0001 /* Access request */

Definition at line 52 of file spi.h.

◆ SPICTL_CG

#define SPICTL_CG   0x0002 /* Cycle go */

Definition at line 51 of file spi.h.

◆ SPICTL_COPTR

#define SPICTL_COPTR   0x0070 /* Opcode menu index, 0 - 7 */

Definition at line 46 of file spi.h.

◆ SPICTL_COPTR_SHIFT

#define SPICTL_COPTR_SHIFT   4

Definition at line 47 of file spi.h.

◆ SPICTL_DBCNT

#define SPICTL_DBCNT   0x3f00 /* Data byte count - 1, 1 - 64 bytes */

Definition at line 44 of file spi.h.

◆ SPICTL_DBCNT_SHIFT

#define SPICTL_DBCNT_SHIFT   8

Definition at line 45 of file spi.h.

◆ SPICTL_DC

#define SPICTL_DC   0x4000 /* Cycle contains data */

Definition at line 43 of file spi.h.

◆ SPICTL_SMIEN

#define SPICTL_SMIEN   0x8000 /* Assert SMI_B at cycle done */

Definition at line 42 of file spi.h.

◆ SPICTL_SOPTR

#define SPICTL_SOPTR   0x0008 /* Prefix index, 0 - 1 */

Definition at line 48 of file spi.h.

◆ SPICTL_SOPTR_SHIFT

#define SPICTL_SOPTR_SHIFT   3

Definition at line 49 of file spi.h.

◆ SPIDATA

#define SPIDATA   0x3028 /* 64-byte send/receive data buffer */

Definition at line 12 of file spi.h.

◆ SPIOPMENU

#define SPIOPMENU   0x3078 /* Opcode table */

Definition at line 16 of file spi.h.

◆ SPIPBR0

#define SPIPBR0   0x3080 /* Protected BIOS range */

Definition at line 17 of file spi.h.

◆ SPIPBR1

#define SPIPBR1   0x3084

Definition at line 18 of file spi.h.

◆ SPIPBR2

#define SPIPBR2   0x3088

Definition at line 19 of file spi.h.

◆ SPIPBR_PRB

#define SPIPBR_PRB   0x00000fff /* Protected range base */

Definition at line 66 of file spi.h.

◆ SPIPBR_PRB_SHIFT

#define SPIPBR_PRB_SHIFT   12

Definition at line 65 of file spi.h.

◆ SPIPBR_PRL

#define SPIPBR_PRL   0x00fff000 /* Protected range limit */

Definition at line 64 of file spi.h.

◆ SPIPBR_WPE

#define SPIPBR_WPE   0x80000000 /* Write protect enable */

Definition at line 63 of file spi.h.

◆ SPIPREOP

#define SPIPREOP   0x3074 /* Prefix opcode table */

Definition at line 14 of file spi.h.

◆ SPISTS

#define SPISTS   0x3020 /* Status register */

Definition at line 9 of file spi.h.

◆ SPISTS_BA

#define SPISTS_BA   0x0008 /* Access is blocked */

Definition at line 37 of file spi.h.

◆ SPISTS_CD

#define SPISTS_CD   0x0004 /* Cycle done */

Definition at line 38 of file spi.h.

◆ SPISTS_CIP

#define SPISTS_CIP   0x0001 /* Cycle in progress */

Definition at line 39 of file spi.h.

◆ SPISTS_CLD

#define SPISTS_CLD   0x8000 /* Lock SPI controller configuration */

Definition at line 36 of file spi.h.

◆ SPITYPE

#define SPITYPE   0x3076 /* Opcode type table */

Definition at line 15 of file spi.h.

◆ SPITYPE_ADDRESS

#define SPITYPE_ADDRESS   0x0002 /* 3-byte address required */

Definition at line 55 of file spi.h.

◆ SPITYPE_PREFIX

#define SPITYPE_PREFIX   0x0001 /* Prefix required, write/erase cycle */

Definition at line 56 of file spi.h.

Function Documentation

◆ spi_bios_base()

void spi_bios_base ( uint32_t  bios_base_address)

Definition at line 21 of file spi.c.

References address, flash_ctrlr::bbar, spi_context::ctrlr, and spi_driver_context.

◆ spi_controller_lock()

void spi_controller_lock ( void  )

Definition at line 31 of file spi.c.

References spi_context::ctrlr, spi_driver_context, SPISTS_CLD, and flash_ctrlr::status.

◆ spi_display()

◆ spi_opcode_name()

const char* spi_opcode_name ( int  opcode)

Definition at line 6 of file spi_debug.c.

Referenced by spi_display().

Here is the caller graph for this function:

◆ spi_protection()

int spi_protection ( uint32_t  address,
uint32_t  length 
)

Definition at line 39 of file spi.c.

References address, ARRAY_SIZE, base, BIOS_ERR, spi_context::ctrlr, length, flash_ctrlr::pbr, printk, read32(), spi_driver_context, SPIPBR_PRB, SPIPBR_PRB_SHIFT, SPIPBR_PRL, SPIPBR_WPE, value, and write32().

Here is the call graph for this function:

Variable Documentation

◆ spi_driver

const struct spi_ctrlr spi_driver
extern

Definition at line 275 of file spi.c.