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

Go to the source code of this file.

Data Structures

struct  pad_func
 

Macros

#define PAD_FUNC(name, func)   {PAD_##name##_ID, PAD_##name##_FUNC_##func}
 
#define PAD_FUNC_GPIO(name)   {PAD_##name##_ID, 0}
 

Functions

void mtk_spi_set_gpio_pinmux (unsigned int bus, enum spi_pad_mask pad_select)
 

Variables

struct mtk_spi_bus spi_bus [SPI_BUS_NUMBER]
 
static const struct pad_func pad0_funcs [SPI_BUS_NUMBER][4]
 
static const struct pad_func bus1_pad1_funcs [4]
 
const struct spi_ctrlr_buses spi_ctrlr_bus_map []
 
const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map)
 

Macro Definition Documentation

◆ PAD_FUNC

#define PAD_FUNC (   name,
  func 
)    {PAD_##name##_ID, PAD_##name##_FUNC_##func}

Definition at line 43 of file spi.c.

◆ PAD_FUNC_GPIO

#define PAD_FUNC_GPIO (   name)    {PAD_##name##_ID, 0}

Definition at line 44 of file spi.c.

Function Documentation

◆ mtk_spi_set_gpio_pinmux()

void mtk_spi_set_gpio_pinmux ( unsigned int  bus,
enum spi_pad_mask  pad_select 
)

Definition at line 92 of file spi.c.

References assert, bus1_pad1_funcs, pad_func::func, gpio_set_mode(), pad0_funcs, pad_func::pin_id, SPI_BUS_NUMBER, SPI_PAD0_MASK, and SPI_PAD1_MASK.

Here is the call graph for this function:

Variable Documentation

◆ bus1_pad1_funcs

const struct pad_func bus1_pad1_funcs[4]
static
Initial value:
= {
PAD_FUNC(EINT7, SPI1_B_MI),
PAD_FUNC_GPIO(EINT8),
PAD_FUNC(EINT9, SPI1_B_MO),
PAD_FUNC(EINT10, SPI1_B_CLK),
}
#define PAD_FUNC(name, func)
Definition: spi.c:43
#define PAD_FUNC_GPIO(name)
Definition: spi.c:44

Definition at line 1 of file spi.c.

Referenced by mtk_spi_set_gpio_pinmux().

◆ pad0_funcs

const struct pad_func pad0_funcs[SPI_BUS_NUMBER][4]
static

Definition at line 1 of file spi.c.

Referenced by mtk_spi_set_gpio_pinmux().

◆ spi_bus

struct mtk_spi_bus spi_bus[SPI_BUS_NUMBER]
Initial value:
= {
{
.regs = (void *)SPI0_BASE,
.cs_gpio = GPIO(SPI_CSB),
},
{
.regs = (void *)SPI1_BASE,
.cs_gpio = GPIO(SPI1_CSB),
},
{
.regs = (void *)SPI2_BASE,
.cs_gpio = GPIO(EINT0),
},
{
.regs = (void *)SPI3_BASE,
.cs_gpio = GPIO(DPI_D9),
},
{
.regs = (void *)SPI4_BASE,
.cs_gpio = GPIO(DPI_D5),
},
{
.regs = (void *)SPI5_BASE,
.cs_gpio = GPIO(DPI_D1),
}
}
@ GPIO
Definition: chip.h:84
#define SPI1_BASE
Definition: addressmap.h:14
#define SPI2_BASE
Definition: addressmap.h:15
#define SPI0_BASE
Definition: addressmap.h:13
#define SPI5_BASE
Definition: addressmap.h:43
#define SPI4_BASE
Definition: addressmap.h:42
#define SPI3_BASE
Definition: addressmap.h:41

Definition at line 1 of file spi.c.

◆ spi_ctrlr_bus_map

const struct spi_ctrlr_buses spi_ctrlr_bus_map[]
Initial value:
= {
{
.ctrlr = &spi_ctrlr,
.bus_start = 0,
.bus_end = SPI_BUS_NUMBER - 1,
},
}
const struct spi_ctrlr spi_ctrlr
Definition: spi.c:261
#define SPI_BUS_NUMBER
Definition: spi.h:8

Definition at line 92 of file spi.c.

◆ spi_ctrlr_bus_map_count

const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map)

Definition at line 114 of file spi.c.