![]() |
coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
|
#include <console/console.h>
#include <spi_flash.h>
#include <soc/pci_devs.h>
#include <amdblocks/lpc.h>
#include <amdblocks/spi.h>
#include <device/pci_ops.h>
#include <lib.h>
#include <timer.h>
#include <types.h>
Go to the source code of this file.
Macros | |
#define | GRANULARITY_TEST_4k 0x0000f000 /* bits 15-12 */ |
#define | WORD_TO_DWORD_UPPER(x) ((x << 16) & 0xffff0000) |
#define | SPI_RESTRICTED_CMD1 0x04 |
#define | SPI_RESTRICTED_CMD2 0x08 |
#define | SPI_CNTRL1 0x0c |
#define | SPI_CMD_CODE 0x45 |
#define | SPI_CMD_TRIGGER 0x47 |
#define | SPI_CMD_TRIGGER_EXECUTE BIT(7) |
#define | SPI_TX_BYTE_COUNT 0x48 |
#define | SPI_RX_BYTE_COUNT 0x4b |
#define | SPI_STATUS 0x4c |
#define | SPI_DONE_BYTE_COUNT_SHIFT 0 |
#define | SPI_DONE_BYTE_COUNT_MASK 0xff |
#define | SPI_FIFO_WR_PTR_SHIFT 8 |
#define | SPI_FIFO_WR_PTR_MASK 0x7f |
#define | SPI_FIFO_RD_PTR_SHIFT 16 |
#define | SPI_FIFO_RD_PTR_MASK 0x7f |
Enumerations | |
enum | spi_dump_state_phase { SPI_DUMP_STATE_BEFORE_CMD , SPI_DUMP_STATE_AFTER_CMD } |
Functions | |
static void | dump_state (enum spi_dump_state_phase phase) |
static int | wait_for_ready (void) |
static int | execute_command (void) |
void | spi_init (void) |
static int | spi_ctrlr_xfer (const struct spi_slave *slave, const void *dout, size_t bytesout, void *din, size_t bytesin) |
static int | xfer_vectors (const struct spi_slave *slave, struct spi_op vectors[], size_t count) |
static int | protect_a_range (u32 value) |
static int | fch_spi_flash_protect (const struct spi_flash *flash, const struct region *region, const enum ctrlr_prot_type type) |
Variables | |
static const struct spi_ctrlr | fch_spi_flash_ctrlr |
const struct spi_ctrlr_buses | spi_ctrlr_bus_map [] |
const size_t | spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map) |
#define GRANULARITY_TEST_4k 0x0000f000 /* bits 15-12 */ |
Definition at line 13 of file fch_spi_ctrl.c.
#define SPI_CMD_CODE 0x45 |
Definition at line 20 of file fch_spi_ctrl.c.
#define SPI_CMD_TRIGGER 0x47 |
Definition at line 21 of file fch_spi_ctrl.c.
#define SPI_CMD_TRIGGER_EXECUTE BIT(7) |
Definition at line 22 of file fch_spi_ctrl.c.
#define SPI_CNTRL1 0x0c |
Definition at line 19 of file fch_spi_ctrl.c.
#define SPI_DONE_BYTE_COUNT_MASK 0xff |
Definition at line 27 of file fch_spi_ctrl.c.
#define SPI_DONE_BYTE_COUNT_SHIFT 0 |
Definition at line 26 of file fch_spi_ctrl.c.
#define SPI_FIFO_RD_PTR_MASK 0x7f |
Definition at line 31 of file fch_spi_ctrl.c.
#define SPI_FIFO_RD_PTR_SHIFT 16 |
Definition at line 30 of file fch_spi_ctrl.c.
#define SPI_FIFO_WR_PTR_MASK 0x7f |
Definition at line 29 of file fch_spi_ctrl.c.
#define SPI_FIFO_WR_PTR_SHIFT 8 |
Definition at line 28 of file fch_spi_ctrl.c.
#define SPI_RESTRICTED_CMD1 0x04 |
Definition at line 17 of file fch_spi_ctrl.c.
#define SPI_RESTRICTED_CMD2 0x08 |
Definition at line 18 of file fch_spi_ctrl.c.
#define SPI_RX_BYTE_COUNT 0x4b |
Definition at line 24 of file fch_spi_ctrl.c.
#define SPI_STATUS 0x4c |
Definition at line 25 of file fch_spi_ctrl.c.
#define SPI_TX_BYTE_COUNT 0x48 |
Definition at line 23 of file fch_spi_ctrl.c.
Definition at line 14 of file fch_spi_ctrl.c.
enum spi_dump_state_phase |
Enumerator | |
---|---|
SPI_DUMP_STATE_BEFORE_CMD | |
SPI_DUMP_STATE_AFTER_CMD |
Definition at line 33 of file fch_spi_ctrl.c.
|
static |
Definition at line 38 of file fch_spi_ctrl.c.
References addr, BIOS_DEBUG, CONFIG, hexdump(), printk, SPI_BUSY, SPI_CMD_CODE, SPI_CNTRL0, SPI_DONE_BYTE_COUNT_MASK, SPI_DONE_BYTE_COUNT_SHIFT, SPI_DUMP_STATE_AFTER_CMD, SPI_DUMP_STATE_BEFORE_CMD, SPI_FIFO, SPI_FIFO_RD_PTR_MASK, SPI_FIFO_RD_PTR_SHIFT, SPI_FIFO_WR_PTR_MASK, SPI_FIFO_WR_PTR_SHIFT, spi_get_bar(), spi_read32(), spi_read8(), SPI_RX_BYTE_COUNT, SPI_STATUS, and SPI_TX_BYTE_COUNT.
Referenced by execute_command().
|
static |
Definition at line 104 of file fch_spi_ctrl.c.
References BIOS_ERR, dump_state(), printk, SPI_CMD_TRIGGER, SPI_CMD_TRIGGER_EXECUTE, SPI_DUMP_STATE_AFTER_CMD, SPI_DUMP_STATE_BEFORE_CMD, spi_write8(), and wait_for_ready().
Referenced by spi_ctrlr_xfer().
|
static |
Definition at line 216 of file fch_spi_ctrl.c.
|
static |
Definition at line 185 of file fch_spi_ctrl.c.
References MAX_ROM_PROTECT_RANGES, pci_read_config32(), pci_write_config32(), ROM_PROTECT_RANGE_REG, SOC_LPC_DEV, and value.
|
static |
Definition at line 125 of file fch_spi_ctrl.c.
References BIOS_DEBUG, BIOS_ERR, BIOS_WARNING, CONFIG, count, execute_command(), printk, SPI_CMD_CODE, SPI_FIFO, SPI_FIFO_DEPTH, spi_read8(), SPI_RX_BYTE_COUNT, SPI_TX_BYTE_COUNT, spi_write8(), and wait_for_ready().
Referenced by xfer_vectors().
Definition at line 120 of file fch_spi_ctrl.c.
References BIOS_DEBUG, printk, and spi_get_bar().
|
static |
Definition at line 89 of file fch_spi_ctrl.c.
References SPI_BUSY, spi_read32(), SPI_STATUS, stopwatch_expired(), and stopwatch_init_msecs_expire().
Referenced by execute_command(), and spi_ctrlr_xfer().
|
static |
Definition at line 173 of file fch_spi_ctrl.c.
References count, slave, spi_ctrlr_xfer(), spi_flash_vector_helper(), spi_hw_mutex, thread_mutex_lock(), and thread_mutex_unlock().
|
static |
Definition at line 216 of file fch_spi_ctrl.c.
const struct spi_ctrlr_buses spi_ctrlr_bus_map[] |
Definition at line 216 of file fch_spi_ctrl.c.
const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map) |
Definition at line 308 of file fch_spi_ctrl.c.