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 <console/console.h>
#include <device/mmio.h>
#include <spi_flash.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)   {GPIO(name), PAD_##name##_FUNC_##func, GPIO_PULL_DOWN}
 
#define PAD_FUNC_SEL(name, func, sel)   {GPIO(name), PAD_##name##_FUNC_##func, sel}
 
#define PAD_FUNC_GPIO(name)   {GPIO(name), 0, GPIO_PULL_DOWN}
 

Functions

void mtk_snfc_init (int gpio_set)
 
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 pad1_funcs [SPI_BUS_NUMBER][4]
 
static const struct pad_func nor_pinmux [SPI_NOR_GPIO_SET_NUM][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 
)    {GPIO(name), PAD_##name##_FUNC_##func, GPIO_PULL_DOWN}

Definition at line 50 of file spi.c.

◆ PAD_FUNC_GPIO

#define PAD_FUNC_GPIO (   name)    {GPIO(name), 0, GPIO_PULL_DOWN}

Definition at line 52 of file spi.c.

◆ PAD_FUNC_SEL

#define PAD_FUNC_SEL (   name,
  func,
  sel 
)    {GPIO(name), PAD_##name##_FUNC_##func, sel}

Definition at line 51 of file spi.c.

Function Documentation

◆ mtk_snfc_init()

void mtk_snfc_init ( int  gpio_set)

Definition at line 141 of file spi.c.

References ARRAY_SIZE, assert, BIOS_DEBUG, BIOS_WARNING, pad_func::func, GPIO_DRV_8_MA, gpio_get_driving(), GPIO_PULL_ENABLE, gpio_set(), gpio_set_driving(), gpio_set_mode(), gpio_set_pull(), nor_pinmux, NULL, printk, pad_func::select, and SPI_NOR_GPIO_SET_NUM.

Referenced by bootblock_mainboard_init().

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

◆ mtk_spi_set_gpio_pinmux()

void mtk_spi_set_gpio_pinmux ( unsigned int  bus,
enum spi_pad_mask  pad_select 
)

Definition at line 162 of file spi.c.

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

Here is the call graph for this function:

Variable Documentation

◆ nor_pinmux

const struct pad_func nor_pinmux[SPI_NOR_GPIO_SET_NUM][4]
static
Initial value:
= {
PAD_FUNC_SEL(SPI0_CSB, SPINOR_CS, GPIO_PULL_UP),
PAD_FUNC_SEL(SPI0_MO, SPINOR_IO0, GPIO_PULL_DOWN),
PAD_FUNC_SEL(SPI0_MI, SPINOR_IO1, GPIO_PULL_DOWN),
},
PAD_FUNC_SEL(TDM_RX_BCK, SPINOR_CK, GPIO_PULL_DOWN),
PAD_FUNC_SEL(TDM_RX_MCLK, SPINOR_CS, GPIO_PULL_UP),
PAD_FUNC_SEL(TDM_RX_DATA0, SPINOR_IO0, GPIO_PULL_DOWN),
PAD_FUNC_SEL(TDM_RX_DATA1, SPINOR_IO1, GPIO_PULL_DOWN),
},
}
#define SPI0_CLK
@ SPI_NOR_GPIO_SET0
Definition: spi.h:29
@ SPI_NOR_GPIO_SET1
Definition: spi.h:30
#define PAD_FUNC_SEL(name, func, sel)
Definition: spi.c:51
#define GPIO_PULL_UP
Definition: gpio.h:24
#define GPIO_PULL_DOWN
Definition: gpio.h:23

Definition at line 1 of file spi.c.

Referenced by mtk_snfc_init(), and nor_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().

◆ pad1_funcs

const struct pad_func pad1_funcs[SPI_BUS_NUMBER][4]
static
Initial value:
= {
{
PAD_FUNC(EINT3, SPI0_MI_B),
PAD_FUNC_GPIO(EINT1),
PAD_FUNC(EINT2, SPI0_MO_B),
PAD_FUNC(EINT0, SPI0_CLK_B),
},
{
PAD_FUNC(EINT9, SPI1_MI_B),
PAD_FUNC_GPIO(EINT7),
PAD_FUNC(EINT8, SPI1_MO_B),
PAD_FUNC(EINT6, SPI1_CLK_B),
},
{
PAD_FUNC(CAM_PDN1, SPI2_MI_B),
PAD_FUNC_GPIO(CAM_PDN0),
PAD_FUNC(CAM_RST0, SPI2_MO_B),
PAD_FUNC(EINT18, SPI2_CLK_B),
},
{
},
{
PAD_FUNC(I2S2_DI, SPI4_MI_B),
PAD_FUNC_GPIO(I2S2_BCK),
PAD_FUNC(I2S2_LRCK, SPI4_MO_B),
PAD_FUNC(I2S2_MCK, SPI4_CLK_B),
},
{
},
}
#define PAD_FUNC(name, func)
Definition: spi.c:50
#define PAD_FUNC_GPIO(name)
Definition: spi.c:52

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(SPI0_CSB),
},
{
.regs = (void *)SPI1_BASE,
.cs_gpio = GPIO(SPI1_CSB),
},
{
.regs = (void *)SPI2_BASE,
.cs_gpio = GPIO(SPI2_CSB),
},
{
.regs = (void *)SPI3_BASE,
.cs_gpio = GPIO(SPI3_CSB),
},
{
.regs = (void *)SPI4_BASE,
.cs_gpio = GPIO(EINT11),
},
{
.regs = (void *)SPI5_BASE,
.cs_gpio = GPIO(SPI5_CSB),
}
}
@ 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,
},
{
.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:178

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