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

Go to the source code of this file.

Data Structures

struct  spi_slave
 
struct  spi_op
 
struct  spi_cfg
 
struct  spi_ctrlr
 
struct  spi_ctrlr_buses
 

Macros

#define SPI_FLASH_PROG_TIMEOUT_MS   200
 
#define SPI_FLASH_PAGE_ERASE_TIMEOUT_MS   500
 
#define VENDOR_ID_ADESTO   0x1f
 
#define VENDOR_ID_AMIC   0x37
 
#define VENDOR_ID_ATMEL   0x1f
 
#define VENDOR_ID_EON   0x1c
 
#define VENDOR_ID_GIGADEVICE   0xc8
 
#define VENDOR_ID_MACRONIX   0xc2
 
#define VENDOR_ID_SPANSION   0x01
 
#define VENDOR_ID_SST   0xbf
 
#define VENDOR_ID_STMICRO   0x20
 
#define VENDOR_ID_WINBOND   0xef
 
#define SPI_CTRLR_DEFAULT_MAX_XFER_SIZE   (UINT32_MAX)
 

Enumerations

enum  spi_op_status { SPI_OP_NOT_EXECUTED = 0 , SPI_OP_SUCCESS = 1 , SPI_OP_FAILURE = 2 }
 
enum  spi_clock_phase { SPI_CLOCK_PHASE_FIRST , SPI_CLOCK_PHASE_SECOND }
 
enum  spi_wire_mode { SPI_4_WIRE_MODE , SPI_3_WIRE_MODE }
 
enum  spi_polarity { SPI_POLARITY_LOW , SPI_POLARITY_HIGH }
 
enum  ctrlr_prot_type { READ_PROTECT = 1 , WRITE_PROTECT = 2 , READ_WRITE_PROTECT = 3 }
 
enum  { SPI_CNTRLR_DEDUCT_CMD_LEN = 1 << 0 , SPI_CNTRLR_DEDUCT_OPCODE_LEN = 1 << 1 }
 

Functions

void spi_init (void)
 Init all SPI controllers with default values and enable all SPI controller. More...
 
int spi_get_config (const struct spi_slave *slave, struct spi_cfg *cfg)
 
int spi_setup_slave (unsigned int bus, unsigned int cs, struct spi_slave *slave)
 
int spi_claim_bus (const struct spi_slave *slave)
 
void spi_release_bus (const struct spi_slave *slave)
 
int spi_xfer (const struct spi_slave *slave, const void *dout, size_t bytesout, void *din, size_t bytesin)
 
int spi_xfer_vector (const struct spi_slave *slave, struct spi_op vectors[], size_t count)
 
unsigned int spi_crop_chunk (const struct spi_slave *slave, unsigned int cmd_len, unsigned int buf_len)
 
static int spi_w8r8 (const struct spi_slave *slave, unsigned char byte)
 

Variables

const struct spi_ctrlr_buses spi_ctrlr_bus_map []
 
const size_t spi_ctrlr_bus_map_count
 

Macro Definition Documentation

◆ SPI_CTRLR_DEFAULT_MAX_XFER_SIZE

#define SPI_CTRLR_DEFAULT_MAX_XFER_SIZE   (UINT32_MAX)

Definition at line 102 of file spi-generic.h.

◆ SPI_FLASH_PAGE_ERASE_TIMEOUT_MS

#define SPI_FLASH_PAGE_ERASE_TIMEOUT_MS   500

Definition at line 11 of file spi-generic.h.

◆ SPI_FLASH_PROG_TIMEOUT_MS

#define SPI_FLASH_PROG_TIMEOUT_MS   200

Definition at line 10 of file spi-generic.h.

◆ VENDOR_ID_ADESTO

#define VENDOR_ID_ADESTO   0x1f

Definition at line 18 of file spi-generic.h.

◆ VENDOR_ID_AMIC

#define VENDOR_ID_AMIC   0x37

Definition at line 19 of file spi-generic.h.

◆ VENDOR_ID_ATMEL

#define VENDOR_ID_ATMEL   0x1f

Definition at line 20 of file spi-generic.h.

◆ VENDOR_ID_EON

#define VENDOR_ID_EON   0x1c

Definition at line 21 of file spi-generic.h.

◆ VENDOR_ID_GIGADEVICE

#define VENDOR_ID_GIGADEVICE   0xc8

Definition at line 22 of file spi-generic.h.

◆ VENDOR_ID_MACRONIX

#define VENDOR_ID_MACRONIX   0xc2

Definition at line 23 of file spi-generic.h.

◆ VENDOR_ID_SPANSION

#define VENDOR_ID_SPANSION   0x01

Definition at line 24 of file spi-generic.h.

◆ VENDOR_ID_SST

#define VENDOR_ID_SST   0xbf

Definition at line 25 of file spi-generic.h.

◆ VENDOR_ID_STMICRO

#define VENDOR_ID_STMICRO   0x20

Definition at line 26 of file spi-generic.h.

◆ VENDOR_ID_WINBOND

#define VENDOR_ID_WINBOND   0xef

Definition at line 27 of file spi-generic.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SPI_CNTRLR_DEDUCT_CMD_LEN 
SPI_CNTRLR_DEDUCT_OPCODE_LEN 

Definition at line 112 of file spi-generic.h.

◆ ctrlr_prot_type

Enumerator
READ_PROTECT 
WRITE_PROTECT 
READ_WRITE_PROTECT 

Definition at line 106 of file spi-generic.h.

◆ spi_clock_phase

Enumerator
SPI_CLOCK_PHASE_FIRST 
SPI_CLOCK_PHASE_SECOND 

Definition at line 69 of file spi-generic.h.

◆ spi_op_status

Enumerator
SPI_OP_NOT_EXECUTED 
SPI_OP_SUCCESS 
SPI_OP_FAILURE 

Definition at line 47 of file spi-generic.h.

◆ spi_polarity

Enumerator
SPI_POLARITY_LOW 
SPI_POLARITY_HIGH 

Definition at line 79 of file spi-generic.h.

◆ spi_wire_mode

Enumerator
SPI_4_WIRE_MODE 
SPI_3_WIRE_MODE 

Definition at line 74 of file spi-generic.h.

Function Documentation

◆ spi_claim_bus()

int spi_claim_bus ( const struct spi_slave slave)

Definition at line 9 of file spi-generic.c.

References spi_ctrlr::claim_bus, spi_slave::ctrlr, and slave.

Referenced by crosec_spi_io(), do_dual_io_cmd(), do_dual_output_cmd(), do_spi_flash_cmd(), exynos_spi_read(), ich_hwseq_erase(), and spi_sdcard_enable_cs().

Here is the caller graph for this function:

◆ spi_crop_chunk()

unsigned int spi_crop_chunk ( const struct spi_slave slave,
unsigned int  cmd_len,
unsigned int  buf_len 
)

◆ spi_get_config()

int spi_get_config ( const struct spi_slave slave,
struct spi_cfg cfg 
)

◆ spi_init()

void spi_init ( void  )

Init all SPI controllers with default values and enable all SPI controller.

Definition at line 117 of file spi-generic.c.

References ich_spi_controller::addr, ARRAY_SIZE, B_QNC_LPC_BIOS_CNTL_BIOSWE, B_QNC_LPC_RCBA_EN, B_QNC_LPC_RCBA_MASK, ich7_spi_regs::bbar, ich9_spi_regs::bbar, ich_spi_controller::bbar, BIOS_DEBUG, BIOS_ERR, cavium_spi_slaves, cntlr, CONFIG, ich_spi_controller::control, spi_context::ctrlr, ich_spi_controller::data, ich_spi_controller::databytes, dev_find_device(), ich9_spi_regs::faddr, ich9_spi_regs::fdata, ich9_spi_regs::fdoc, ich9_spi_regs::fdod, ich_spi_controller::flcomp, ich_spi_controller::flmap0, ich_spi_controller::fpr, ich_spi_controller::fpr_max, get_spi_bar(), ich9_spi_regs::hsfs, ich_spi_controller::hsfs, HSFS_FDV, ich_spi_controller::ich7_spi, ich_spi_controller::ich9_spi, ich_set_bbar(), LPC_DEVID, ich_spi_controller::menubytes, NULL, flash_ctrlr::opmenu, ich7_spi_regs::opmenu, ich9_spi_regs::opmenu, ich_spi_controller::opmenu, ich7_spi_regs::optype, ich9_spi_regs::optype, ich_spi_controller::optype, ich7_spi_regs::pbr, PCI_DEV, pci_read_config32(), PCI_VID_INTEL, pci_write_config32(), pcidev_on_root(), ich9_spi_regs::pr, flash_ctrlr::prefix, ich7_spi_regs::preop, ich9_spi_regs::preop, ich_spi_controller::preop, printk, R_QNC_LPC_BIOS_CNTL, R_QNC_LPC_RCBA, readl_, readw_, spi_disable(), spi_driver_context, spi_enable(), spi_get_bar(), spi_set_clock(), spi_set_cs(), spi_set_lsbmsb(), spi_set_smm_only_flashing(), ich7_spi_regs::spia, spibar, ich7_spi_regs::spic, ich7_spi_regs::spid, ich7_spi_regs::spis, SPITYPE_ADDRESS, SPITYPE_PREFIX, ich9_spi_regs::ssfc, ich9_spi_regs::ssfs, ich_spi_controller::status, flash_ctrlr::type, and writel_.

Referenced by boot_device_rw_init(), intel_pch_finalize_smm(), smi_handler(), smm_handler_start(), spi_init_cb(), and spiconsole_init().

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

◆ spi_release_bus()

void spi_release_bus ( const struct spi_slave slave)

Definition at line 17 of file spi-generic.c.

References spi_slave::ctrlr, spi_ctrlr::release_bus, and slave.

Referenced by crosec_spi_io(), do_dual_io_cmd(), do_dual_output_cmd(), do_spi_flash_cmd(), exynos_spi_read(), ich_hwseq_erase(), and spi_sdcard_disable_cs().

Here is the caller graph for this function:

◆ spi_setup_slave()

int spi_setup_slave ( unsigned int  bus,
unsigned int  cs,
struct spi_slave slave 
)

◆ spi_w8r8()

static int spi_w8r8 ( const struct spi_slave slave,
unsigned char  byte 
)
inlinestatic

Definition at line 295 of file spi-generic.h.

References slave, and spi_xfer().

Referenced by sst_byte_write(), and sst_write_ai().

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

◆ spi_xfer()

int spi_xfer ( const struct spi_slave slave,
const void dout,
size_t  bytesout,
void din,
size_t  bytesin 
)

Definition at line 68 of file spi-generic.c.

References spi_slave::ctrlr, slave, and spi_ctrlr::xfer.

Referenced by crosec_spi_io(), read_bytes(), spi_sdcard_recvbyte(), spi_sdcard_sendbyte(), spi_w8r8(), spiconsole_tx_byte(), and write_bytes().

Here is the caller graph for this function:

◆ spi_xfer_vector()

int spi_xfer_vector ( const struct spi_slave slave,
struct spi_op  vectors[],
size_t  count 
)

Definition at line 57 of file spi-generic.c.

References count, spi_slave::ctrlr, slave, spi_xfer_vector_default(), and spi_ctrlr::xfer_vector.

Referenced by do_dual_io_cmd(), do_dual_output_cmd(), and do_spi_flash_cmd().

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

Variable Documentation

◆ spi_ctrlr_bus_map

const struct spi_ctrlr_buses spi_ctrlr_bus_map[]
extern

Definition at line 216 of file fch_spi_ctrl.c.

Referenced by gspi_read_bus_range(), and spi_setup_slave().

◆ spi_ctrlr_bus_map_count

const size_t spi_ctrlr_bus_map_count
extern

Definition at line 308 of file fch_spi_ctrl.c.

Referenced by gspi_read_bus_range(), and spi_setup_slave().