coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
qspi.c File Reference
#include <spi-generic.h>
#include <spi_flash.h>
#include <arch/cache.h>
#include <device/mmio.h>
#include <soc/addressmap.h>
#include <soc/qspi_common.h>
#include <soc/gpio.h>
#include <soc/clock.h>
#include <symbols.h>
#include <assert.h>
#include <gpio.h>
#include <string.h>
Include dependency graph for qspi.c:

Go to the source code of this file.

Data Structures

struct  cmd_desc
 
struct  xfer_cfg
 

Macros

#define CACHE_LINE_SIZE   64
 

Enumerations

enum  qspi_mode {
  SDR_1BIT = 1 , SDR_2BIT = 2 , SDR_4BIT = 3 , DDR_1BIT = 5 ,
  DDR_2BIT = 6 , DDR_4BIT = 7
}
 
enum  cs_state { CS_DEASSERT , CS_ASSERT }
 
enum  bus_xfer_direction { MASTER_READ = 0 , MASTER_WRITE = 1 }
 

Functions

static void dma_transfer_chain (struct cmd_desc *chain)
 
static void flush_chain (void)
 
static struct cmd_descallocate_descriptor (void)
 
static void cs_change (enum cs_state state)
 
static void configure_gpios (void)
 
static void queue_bounce_data (uint8_t *data, uint32_t data_bytes, enum qspi_mode data_mode, bool write)
 
static void queue_direct_data (uint8_t *data, uint32_t data_bytes, enum qspi_mode data_mode, bool write)
 
static void queue_data (uint8_t *data, uint32_t data_bytes, enum qspi_mode data_mode, bool write)
 
static void reg_init (void)
 
void quadspi_init (uint32_t hz)
 
int qspi_claim_bus (const struct spi_slave *slave)
 
void qspi_release_bus (const struct spi_slave *slave)
 
static int xfer (enum qspi_mode mode, const void *dout, size_t out_bytes, void *din, size_t in_bytes)
 
int qspi_xfer (const struct spi_slave *slave, const void *dout, size_t out_bytes, void *din, size_t in_bytes)
 
int qspi_xfer_dual (const struct spi_slave *slave, const void *dout, size_t out_bytes, void *din, size_t in_bytes)
 

Variables

static int curr_desc_idx = -1
 
struct {
   struct cmd_desc   descriptors [3]
 
   uint8_t   buffers [3][CACHE_LINE_SIZE]
 
} * dma = (void *)_dma_coherent
 

Macro Definition Documentation

◆ CACHE_LINE_SIZE

#define CACHE_LINE_SIZE   64

Definition at line 16 of file qspi.c.

Enumeration Type Documentation

◆ bus_xfer_direction

Enumerator
MASTER_READ 
MASTER_WRITE 

Definition at line 54 of file qspi.c.

◆ cs_state

enum cs_state
Enumerator
CS_DEASSERT 
CS_ASSERT 

Definition at line 45 of file qspi.c.

◆ qspi_mode

enum qspi_mode
Enumerator
SDR_1BIT 
SDR_2BIT 
SDR_4BIT 
DDR_1BIT 
DDR_2BIT 
DDR_4BIT 

Definition at line 36 of file qspi.c.

Function Documentation

◆ allocate_descriptor()

◆ configure_gpios()

static void configure_gpios ( void  )
static

Definition at line 144 of file qspi.c.

References GPIO_8MA, gpio_configure(), GPIO_FUNC_QSPI_CLK, GPIO_FUNC_QSPI_DATA_0, GPIO_FUNC_QSPI_DATA_1, GPIO_NO_PULL, gpio_output(), GPIO_OUTPUT, QSPI_CLK, QSPI_CS, QSPI_DATA_0, and QSPI_DATA_1.

Referenced by quadspi_init().

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

◆ cs_change()

static void cs_change ( enum cs_state  state)
static

Definition at line 139 of file qspi.c.

References CS_DEASSERT, gpio_set(), and QSPI_CS.

Referenced by qspi_claim_bus(), and qspi_release_bus().

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

◆ dma_transfer_chain()

static void dma_transfer_chain ( struct cmd_desc chain)
static

Definition at line 64 of file qspi.c.

References DMA_CHAIN_DONE, qcom_qspi_regs::mstr_int_sts, qcom_qspi_regs::next_dma_desc_addr, qcom_qspi, read32(), and write32().

Referenced by flush_chain().

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

◆ flush_chain()

static void flush_chain ( void  )
static

Definition at line 78 of file qspi.c.

References cmd_desc::bounce_dst, cmd_desc::bounce_length, cmd_desc::bounce_src, curr_desc_idx, cmd_desc::data_address, dcache_invalidate_by_mva, cmd_desc::direction, dma, dma_transfer_chain(), cmd_desc::length, MASTER_READ, memcpy(), and cmd_desc::next_descriptor.

Referenced by xfer().

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

◆ qspi_claim_bus()

int qspi_claim_bus ( const struct spi_slave slave)

Definition at line 259 of file qspi.c.

References CS_ASSERT, and cs_change().

Here is the call graph for this function:

◆ qspi_release_bus()

void qspi_release_bus ( const struct spi_slave slave)

Definition at line 265 of file qspi.c.

References cs_change(), and CS_DEASSERT.

Here is the call graph for this function:

◆ qspi_xfer()

int qspi_xfer ( const struct spi_slave slave,
const void dout,
size_t  out_bytes,
void din,
size_t  in_bytes 
)

Definition at line 286 of file qspi.c.

References SDR_1BIT, and xfer().

Here is the call graph for this function:

◆ qspi_xfer_dual()

int qspi_xfer_dual ( const struct spi_slave slave,
const void dout,
size_t  out_bytes,
void din,
size_t  in_bytes 
)

Definition at line 292 of file qspi.c.

References SDR_2BIT, and xfer().

Here is the call graph for this function:

◆ quadspi_init()

void quadspi_init ( uint32_t  hz)

Definition at line 251 of file qspi.c.

References assert, CACHE_LINE_SIZE, clock_configure_qspi(), configure_gpios(), dcache_line_bytes(), and reg_init().

Referenced by bootblock_soc_init().

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

◆ queue_bounce_data()

static void queue_bounce_data ( uint8_t data,
uint32_t  data_bytes,
enum qspi_mode  data_mode,
bool  write 
)
static

Definition at line 158 of file qspi.c.

References allocate_descriptor(), cmd_desc::bounce_dst, cmd_desc::bounce_length, cmd_desc::bounce_src, cmd_desc::data_address, cmd_desc::direction, cmd_desc::length, memcpy(), and cmd_desc::multi_io_mode.

Referenced by queue_data().

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

◆ queue_data()

static void queue_data ( uint8_t data,
uint32_t  data_bytes,
enum qspi_mode  data_mode,
bool  write 
)
static

Definition at line 197 of file qspi.c.

References ALIGN_DOWN, ALIGN_UP, CACHE_LINE_SIZE, MIN, queue_bounce_data(), and queue_direct_data().

Referenced by xfer().

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

◆ queue_direct_data()

static void queue_direct_data ( uint8_t data,
uint32_t  data_bytes,
enum qspi_mode  data_mode,
bool  write 
)
static

Definition at line 180 of file qspi.c.

References allocate_descriptor(), cmd_desc::data_address, dcache_clean_by_mva(), dcache_invalidate_by_mva, cmd_desc::direction, cmd_desc::length, and cmd_desc::multi_io_mode.

Referenced by queue_data().

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

◆ reg_init()

◆ xfer()

static int xfer ( enum qspi_mode  mode,
const void dout,
size_t  out_bytes,
void din,
size_t  in_bytes 
)
static

Definition at line 270 of file qspi.c.

References flush_chain(), and queue_data().

Referenced by qspi_xfer(), and qspi_xfer_dual().

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

Variable Documentation

◆ buffers

uint8_t buffers[3][CACHE_LINE_SIZE]

Definition at line 61 of file qspi.c.

◆ curr_desc_idx

int curr_desc_idx = -1
static

Definition at line 18 of file qspi.c.

Referenced by allocate_descriptor(), and flush_chain().

◆ descriptors

struct cmd_desc descriptors[3]

Definition at line 33 of file qspi.c.

◆