coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spi_bitbang.c File Reference
#include <assert.h>
#include <gpio.h>
#include <soc/spi.h>
#include <spi_bitbang.h>
#include <spi_flash.h>
#include <stddef.h>
Include dependency graph for spi_bitbang.c:

Go to the source code of this file.

Data Structures

struct  rockchip_bitbang_slave
 

Functions

static int get_miso (const struct spi_bitbang_ops *ops)
 
static void set_mosi (const struct spi_bitbang_ops *ops, int value)
 
static void set_clk (const struct spi_bitbang_ops *ops, int value)
 
static void set_cs (const struct spi_bitbang_ops *ops, int value)
 
void rockchip_spi_init (unsigned int bus, unsigned int ignored_speed_hz)
 
void rockchip_spi_set_sample_delay (unsigned int bus, unsigned int delay_ns)
 
static int spi_ctrlr_claim_bus (const struct spi_slave *slave)
 
static void spi_ctrlr_release_bus (const struct spi_slave *slave)
 
static int spi_ctrlr_xfer (const struct spi_slave *slave, const void *dout, size_t bytes_out, void *din, size_t bytes_in)
 

Variables

static const struct rockchip_bitbang_slave slaves []
 
static const struct spi_ctrlr spi_ctrlr
 
const struct spi_ctrlr_buses spi_ctrlr_bus_map []
 
const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map)
 

Function Documentation

◆ get_miso()

static int get_miso ( const struct spi_bitbang_ops ops)
static

Definition at line 21 of file spi_bitbang.c.

References container_of, gpio_get(), ops, and slave.

Here is the call graph for this function:

◆ rockchip_spi_init()

◆ rockchip_spi_set_sample_delay()

void rockchip_spi_set_sample_delay ( unsigned int  bus,
unsigned int  delay_ns 
)

Definition at line 105 of file spi_bitbang.c.

References ARRAY_SIZE, assert, clrsetbits32, DIV_ROUND_CLOSEST, GHz, rockchip_spi_slave::regs, rockchip_spi_slaves, SPI_RXDSD_MASK, SPI_RXDSD_OFFSET, and SPI_SRCCLK_HZ.

Referenced by configure_spi_flash().

Here is the caller graph for this function:

◆ set_clk()

static void set_clk ( const struct spi_bitbang_ops ops,
int  value 
)
static

Definition at line 35 of file spi_bitbang.c.

References container_of, gpio_set(), ops, slave, and value.

Here is the call graph for this function:

◆ set_cs()

static void set_cs ( const struct spi_bitbang_ops ops,
int  value 
)
static

Definition at line 42 of file spi_bitbang.c.

References container_of, spi_slave::cs, gpio_set(), ops, slave, and value.

Here is the call graph for this function:

◆ set_mosi()

static void set_mosi ( const struct spi_bitbang_ops ops,
int  value 
)
static

Definition at line 28 of file spi_bitbang.c.

References container_of, gpio_set(), ops, slave, and value.

Here is the call graph for this function:

◆ spi_ctrlr_claim_bus()

static int spi_ctrlr_claim_bus ( const struct spi_slave slave)
static

Definition at line 110 of file spi_bitbang.c.

References ARRAY_SIZE, assert, spi_slave::bus, rockchip_bitbang_slave::ops, slave, slaves, and spi_bitbang_claim_bus().

Here is the call graph for this function:

◆ spi_ctrlr_release_bus()

static void spi_ctrlr_release_bus ( const struct spi_slave slave)
static

Definition at line 116 of file spi_bitbang.c.

References ARRAY_SIZE, assert, spi_slave::bus, rockchip_bitbang_slave::ops, slave, slaves, and spi_bitbang_release_bus().

Here is the call graph for this function:

◆ spi_ctrlr_xfer()

static int spi_ctrlr_xfer ( const struct spi_slave slave,
const void dout,
size_t  bytes_out,
void din,
size_t  bytes_in 
)
static

Definition at line 122 of file spi_bitbang.c.

Variable Documentation

◆ slaves

const struct rockchip_bitbang_slave slaves[]
static

Definition at line 42 of file spi_bitbang.c.

Referenced by rockchip_spi_init(), spi_ctrlr_claim_bus(), and spi_ctrlr_release_bus().

◆ spi_ctrlr

const struct spi_ctrlr spi_ctrlr
static
Initial value:
= {
.claim_bus = spi_ctrlr_claim_bus,
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
.max_xfer_size = 65535,
}
static void spi_ctrlr_release_bus(const struct spi_slave *slave)
Definition: spi_bitbang.c:116
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout, size_t bytes_out, void *din, size_t bytes_in)
Definition: spi_bitbang.c:122
static int spi_ctrlr_claim_bus(const struct spi_slave *slave)
Definition: spi_bitbang.c:110

Definition at line 122 of file spi_bitbang.c.

◆ spi_ctrlr_bus_map

const struct spi_ctrlr_buses spi_ctrlr_bus_map[]
Initial value:
= {
{
.ctrlr = &spi_ctrlr,
.bus_start = 0,
.bus_end = ARRAY_SIZE(slaves) - 1,
},
}
#define ARRAY_SIZE(a)
Definition: helpers.h:12
static const struct spi_ctrlr spi_ctrlr
Definition: spi_bitbang.c:130
static const struct rockchip_bitbang_slave slaves[]
Definition: spi_bitbang.c:50

Definition at line 122 of file spi_bitbang.c.

◆ spi_ctrlr_bus_map_count

const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map)

Definition at line 145 of file spi_bitbang.c.