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

Go to the source code of this file.

Data Structures

struct  pad_func
 

Macros

#define I2C_FULL_DUTY   100
 
#define I2C_HALF_DUTY   50
 
#define I2C_ADJUSTED_DUTY   45
 
#define I2C_FS_START_CON   0x601
 
#define PAD_FUNC(name, func)   {GPIO(name), PAD_##name##_FUNC_##func}
 

Functions

 _Static_assert (ARRAY_SIZE(mtk_i2c_bus_controller)==I2C_BUS_NUMBER, "Wrong size of mtk_i2c_bus_controller")
 
static void mtk_i2c_set_gpio_pinmux (uint8_t bus)
 
static void mtk_i2c_speed_init_soc (uint8_t bus)
 
void mtk_i2c_bus_init (uint8_t bus)
 
void mtk_i2c_dump_more_info (struct mt_i2c_regs *regs)
 

Variables

struct mtk_i2c mtk_i2c_bus_controller []
 
static const struct pad_func i2c_funcs [I2C_BUS_NUMBER][2]
 

Macro Definition Documentation

◆ I2C_ADJUSTED_DUTY

#define I2C_ADJUSTED_DUTY   45

Definition at line 11 of file i2c.c.

◆ I2C_FS_START_CON

#define I2C_FS_START_CON   0x601

Definition at line 12 of file i2c.c.

◆ I2C_FULL_DUTY

#define I2C_FULL_DUTY   100

Definition at line 9 of file i2c.c.

◆ I2C_HALF_DUTY

#define I2C_HALF_DUTY   50

Definition at line 10 of file i2c.c.

◆ PAD_FUNC

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

Definition at line 74 of file i2c.c.

Function Documentation

◆ _Static_assert()

_Static_assert ( ARRAY_SIZE(mtk_i2c_bus_controller = =I2C_BUS_NUMBER,
"Wrong size of mtk_i2c_bus_controller  
)

◆ mtk_i2c_bus_init()

void mtk_i2c_bus_init ( uint8_t  bus)

Definition at line 179 of file i2c.c.

References mtk_i2c_set_gpio_pinmux(), and mtk_i2c_speed_init_soc().

Here is the call graph for this function:

◆ mtk_i2c_dump_more_info()

void mtk_i2c_dump_more_info ( struct mt_i2c_regs regs)

Definition at line 185 of file i2c.c.

References BIOS_DEBUG, printk, and read32().

Here is the call graph for this function:

◆ mtk_i2c_set_gpio_pinmux()

static void mtk_i2c_set_gpio_pinmux ( uint8_t  bus)
static

Definition at line 119 of file i2c.c.

References assert, pad_func::func, GPIO_PULL_ENABLE, GPIO_PULL_UP, gpio_set_mode(), gpio_set_pull(), I2C_BUS_NUMBER, and i2c_funcs.

Referenced by mtk_i2c_bus_init().

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

◆ mtk_i2c_speed_init_soc()

static void mtk_i2c_speed_init_soc ( uint8_t  bus)
static

Definition at line 130 of file i2c.c.

References assert, DIV_ROUND_UP, I2C_ADJUSTED_DUTY, I2C_BUS_NUMBER, I2C_CLK_HZ, I2C_FS_START_CON, I2C_FULL_DUTY, I2C_HALF_DUTY, KHz, mtk_i2c_bus_controller, and write32().

Referenced by mtk_i2c_bus_init().

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

Variable Documentation

◆ i2c_funcs

const struct pad_func i2c_funcs[I2C_BUS_NUMBER][2]
static

Definition at line 66 of file i2c.c.

Referenced by mtk_i2c_set_gpio_pinmux().

◆ mtk_i2c_bus_controller

struct mtk_i2c mtk_i2c_bus_controller[]

Definition at line 1 of file i2c.c.