coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spi.c File Reference
#include <assert.h>
#include <device/mmio.h>
#include <soc/addressmap.h>
#include <soc/flash_controller_common.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 spi_ctrlr 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)
 

Macro Definition Documentation

◆ PAD_FUNC

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

Definition at line 42 of file spi.c.

◆ PAD_FUNC_GPIO

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

Definition at line 43 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 84 of file spi.c.

References assert, pad_func::func, GPIO, gpio_set_mode(), NULL, 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

◆ 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(SPIM0_CSB),
},
{
.regs = (void *)SPI1_BASE,
.cs_gpio = GPIO(SPIM1_CSB),
},
{
.regs = (void *)SPI2_BASE,
.cs_gpio = GPIO(SPIM2_CSB),
},
{
.regs = (void *)SPI3_BASE,
.cs_gpio = GPIO(PWRAP_SPI_CSN),
},
{
.regs = (void *)SPI4_BASE,
.cs_gpio = GPIO(DGI_D2),
},
{
.regs = (void *)SPI5_BASE,
.cs_gpio = GPIO(DGI_D6),
},
}
@ 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.

Referenced by gspi_ctrlr_params_init(), and gspi_spi_to_gspi_bus().

◆ 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,
},
{
.ctrlr = &spi_flash_ctrlr,
.bus_start = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS,
.bus_end = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS,
},
}
const struct spi_ctrlr spi_ctrlr
Definition: spi.c:261
#define SPI_BUS_NUMBER
Definition: spi.h:8
static const struct spi_ctrlr spi_flash_ctrlr
Definition: spi.c:95

Definition at line 84 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 113 of file spi.c.

◆ spi_flash_ctrlr

const struct spi_ctrlr spi_flash_ctrlr
static
Initial value:
= {
.max_xfer_size = 65535,
.flash_probe = mtk_spi_flash_probe,
}
int mtk_spi_flash_probe(const struct spi_slave *spi, struct spi_flash *flash)

Definition at line 84 of file spi.c.