coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spi_flash.h File Reference
#include <stdint.h>
#include <stddef.h>
#include <spi-generic.h>
#include <boot/coreboot_tables.h>
Include dependency graph for spi_flash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  spi_flash_ops
 
struct  spi_flash_protection_ops
 
struct  spi_flash
 

Macros

#define SPI_OPCODE_WREN   0x06
 
#define SPI_OPCODE_FAST_READ   0x0b
 

Enumerations

enum  spi_flash_status_reg_lockdown {
  SPI_WRITE_PROTECTION_PRESERVE = -1 , SPI_WRITE_PROTECTION_NONE = 0 , SPI_WRITE_PROTECTION_PIN , SPI_WRITE_PROTECTION_REBOOT ,
  SPI_WRITE_PROTECTION_PERMANENT
}
 

Functions

void lb_spi_flash (struct lb_header *header)
 
int spi_flash_probe (unsigned int bus, unsigned int cs, struct spi_flash *flash)
 
int spi_flash_generic_probe (const struct spi_slave *slave, struct spi_flash *flash)
 
int spi_flash_read (const struct spi_flash *flash, u32 offset, size_t len, void *buf)
 
int spi_flash_write (const struct spi_flash *flash, u32 offset, size_t len, const void *buf)
 
int spi_flash_erase (const struct spi_flash *flash, u32 offset, size_t len)
 
int spi_flash_status (const struct spi_flash *flash, u8 *reg)
 
int spi_flash_is_write_protected (const struct spi_flash *flash, const struct region *region)
 
int spi_flash_set_write_protected (const struct spi_flash *flash, const struct region *region, const enum spi_flash_status_reg_lockdown mode)
 
int spi_flash_volatile_group_begin (const struct spi_flash *flash)
 
int spi_flash_volatile_group_end (const struct spi_flash *flash)
 
int chipset_volatile_group_begin (const struct spi_flash *flash)
 
int chipset_volatile_group_end (const struct spi_flash *flash)
 
const struct spi_flashboot_device_spi_flash (void)
 
int spi_flash_ctrlr_protect_region (const struct spi_flash *flash, const struct region *region, const enum ctrlr_prot_type type)
 
int spi_flash_vector_helper (const struct spi_slave *slave, struct spi_op vectors[], size_t count, int(*func)(const struct spi_slave *slave, const void *dout, size_t bytesout, void *din, size_t bytesin))
 
uint32_t spi_flash_get_mmap_windows (struct flash_mmap_window *table)
 

Macro Definition Documentation

◆ SPI_OPCODE_FAST_READ

#define SPI_OPCODE_FAST_READ   0x0b

Definition at line 13 of file spi_flash.h.

◆ SPI_OPCODE_WREN

#define SPI_OPCODE_WREN   0x06

Definition at line 12 of file spi_flash.h.

Enumeration Type Documentation

◆ spi_flash_status_reg_lockdown

Enumerator
SPI_WRITE_PROTECTION_PRESERVE 
SPI_WRITE_PROTECTION_NONE 
SPI_WRITE_PROTECTION_PIN 
SPI_WRITE_PROTECTION_REBOOT 
SPI_WRITE_PROTECTION_PERMANENT 

Definition at line 28 of file spi_flash.h.

Function Documentation

◆ boot_device_spi_flash()

const struct spi_flash* boot_device_spi_flash ( void  )

◆ chipset_volatile_group_begin()

int chipset_volatile_group_begin ( const struct spi_flash flash)

Definition at line 132 of file spi.c.

References CONFIG, ImcSleep(), and NULL.

Referenced by spi_flash_volatile_group_begin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chipset_volatile_group_end()

int chipset_volatile_group_end ( const struct spi_flash flash)

Definition at line 141 of file spi.c.

References CONFIG, ImcWakeup(), and NULL.

Referenced by spi_flash_volatile_group_end().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lb_spi_flash()

◆ spi_flash_ctrlr_protect_region()

int spi_flash_ctrlr_protect_region ( const struct spi_flash flash,
const struct region region,
const enum ctrlr_prot_type  type 
)

Definition at line 719 of file spi_flash.c.

References spi_slave::ctrlr, spi_ctrlr::flash_protect, region_is_subregion(), region::size, spi_flash::size, spi_flash::spi, and type.

Referenced by boot_device_wp_region(), and nvm_protect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spi_flash_erase()

int spi_flash_erase ( const struct spi_flash flash,
u32  offset,
size_t  len 
)

Definition at line 553 of file spi_flash.c.

References spi_flash_ops::erase, offset, spi_flash::ops, spi_flash_volatile_group_begin(), and spi_flash_volatile_group_end().

Referenced by spi_eraseat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spi_flash_generic_probe()

int spi_flash_generic_probe ( const struct spi_slave slave,
struct spi_flash flash 
)

Definition at line 448 of file spi_flash.c.

References BIOS_INFO, BIOS_SPEW, CMD_READ_ID, CONFIG, find_match(), IDCODE_LEN, printk, spi_flash_cmd(), and stmicro_release_deep_sleep_identify().

Referenced by spi_flash_probe(), and spi_flash_programmer_probe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spi_flash_get_mmap_windows()

uint32_t spi_flash_get_mmap_windows ( struct flash_mmap_window table)

◆ spi_flash_is_write_protected()

int spi_flash_is_write_protected ( const struct spi_flash flash,
const struct region region 
)

Definition at line 576 of file spi_flash.c.

References BIOS_WARNING, spi_flash_protection_ops::get_write, printk, spi_flash::prot_ops, region_is_subregion(), region::size, and spi_flash::size.

Referenced by boot_device_wp_region(), mainboard_print_info(), and protect_ro_rgn_spi_flash().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spi_flash_probe()

◆ spi_flash_read()

int spi_flash_read ( const struct spi_flash flash,
u32  offset,
size_t  len,
void buf 
)

Definition at line 531 of file spi_flash.c.

References buf, offset, spi_flash::ops, and spi_flash_ops::read.

Referenced by pre_mem_debug_init(), and spi_readat().

Here is the caller graph for this function:

◆ spi_flash_set_write_protected()

int spi_flash_set_write_protected ( const struct spi_flash flash,
const struct region region,
const enum spi_flash_status_reg_lockdown  mode 
)

◆ spi_flash_status()

int spi_flash_status ( const struct spi_flash flash,
u8 reg 
)

Definition at line 568 of file spi_flash.c.

References spi_flash::ops, and spi_flash_ops::status.

Referenced by mainboard_config_cbi_wp(), nvm_is_write_protected(), and protect_ro_rgn_spi_flash().

Here is the caller graph for this function:

◆ spi_flash_vector_helper()

int spi_flash_vector_helper ( const struct spi_slave slave,
struct spi_op  vectors[],
size_t  count,
int(*)(const struct spi_slave *slave, const void *dout, size_t bytesout, void *din, size_t bytesin)  func 
)

Definition at line 745 of file spi_flash.c.

Referenced by xfer_vectors().

Here is the caller graph for this function:

◆ spi_flash_volatile_group_begin()

int spi_flash_volatile_group_begin ( const struct spi_flash flash)

Definition at line 647 of file spi_flash.c.

References chipset_volatile_group_begin(), CONFIG, count, and volatile_group_count.

Referenced by spi_flash_erase(), and spi_flash_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spi_flash_volatile_group_end()

int spi_flash_volatile_group_end ( const struct spi_flash flash)

Definition at line 664 of file spi_flash.c.

References assert, chipset_volatile_group_end(), CONFIG, count, and volatile_group_count.

Referenced by spi_flash_erase(), and spi_flash_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ spi_flash_write()

int spi_flash_write ( const struct spi_flash flash,
u32  offset,
size_t  len,
const void buf 
)

Definition at line 537 of file spi_flash.c.

References buf, offset, spi_flash::ops, spi_flash_volatile_group_begin(), spi_flash_volatile_group_end(), and spi_flash_ops::write.

Referenced by spi_writeat().

Here is the call graph for this function:
Here is the caller graph for this function: