coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
i2c_common.h File Reference
#include <device/i2c.h>
Include dependency graph for i2c_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mt_i2c_dma_regs
 
struct  mtk_i2c_ac_timing
 
struct  mtk_i2c
 
struct  i2c_spec_values
 

Macros

#define I2C_TIME_CLR_VALUE   0x0000
 
#define MAX_SAMPLE_CNT_DIV   8
 
#define MAX_STEP_CNT_DIV   64
 
#define MAX_HS_STEP_CNT_DIV   8
 
#define I2C_TIME_DEFAULT_VALUE   0x0083
 
#define I2C_STANDARD_MODE_BUFFER   (1000 / 3)
 
#define I2C_FAST_MODE_BUFFER   (300 / 3)
 
#define I2C_FAST_MODE_PLUS_BUFFER   (20 / 3)
 

Enumerations

enum  { I2C_HS_DEFAULT_VALUE = 0x0102 }
 
enum  i2c_modes { I2C_WRITE_MODE = 0 , I2C_READ_MODE = 1 , I2C_WRITE_READ_MODE = 2 }
 
enum  {
  I2C_DMA_CON_TX = 0x0 , I2C_DMA_CON_RX = 0x1 , I2C_DMA_START_EN = 0x1 , I2C_DMA_INT_FLAG_NONE = 0x0 ,
  I2C_DMA_CLR_FLAG = 0x0 , I2C_DMA_FLUSH_FLAG = 0x1 , I2C_DMA_ASYNC_MODE = 0x0004 , I2C_DMA_SKIP_CONFIG = 0x0010 ,
  I2C_DMA_DIR_CHANGE = 0x0200 , I2C_DMA_WARM_RST = 0x1 , I2C_DMA_HARD_RST = 0x2 , I2C_DMA_HANDSHAKE_RST = 0x4
}
 
enum  { I2C_TRANS_LEN_MASK = (0xff) , I2C_TRANS_AUX_LEN_MASK = (0x1f << 8) , I2C_CONTROL_MASK = (0x3f << 1) }
 
enum  { I2C_APDMA_NOASYNC = 0 , I2C_APDMA_ASYNC = 1 }
 
enum  { I2C_HS_NACKERR = (1 << 2) , I2C_ACKERR = (1 << 1) , I2C_TRANSAC_COMP = (1 << 0) }
 
enum  { I2C_CLR_FLAG = 0x0 , I2C_SOFT_RST = 0x1 , I2C_HANDSHAKE_RST = 0x20 }
 
enum  {
  ASYNC_MODE = (1 << 9) , DMAACK_EN = (1 << 8) , ACK_ERR_DET_EN = (1 << 5) , DIR_CHG = (1 << 4) ,
  CLK_EXT = (1 << 3) , DMA_EN = (1 << 2) , REPEATED_START_FLAG = (1 << 1) , STOP_FLAG = (0 << 1)
}
 
enum  {
  I2C_OK = 0x0000 , I2C_SET_SPEED_FAIL_OVER_SPEED = -0xA001 , I2C_TRANSFER_INVALID_LENGTH = -0xA002 , I2C_TRANSFER_FAIL_HS_NACKERR = -0xA003 ,
  I2C_TRANSFER_FAIL_ACKERR = -0xA004 , I2C_TRANSFER_FAIL_TIMEOUT = -0xA005 , I2C_TRANSFER_INVALID_ARGUMENT = -0xA006
}
 

Functions

 check_member (mt_i2c_dma_regs, dma_tx_len, 0x24)
 
const struct i2c_spec_valuesmtk_i2c_get_spec (uint32_t speed)
 
void mtk_i2c_dump_more_info (struct mt_i2c_regs *regs)
 
int mtk_i2c_check_ac_timing (uint8_t bus, uint32_t clk_src, uint32_t check_speed, uint32_t step_cnt, uint32_t sample_cnt)
 
int mtk_i2c_calculate_speed (uint8_t bus, uint32_t clk_src, uint32_t target_speed, uint32_t *timing_step_cnt, uint32_t *timing_sample_cnt)
 
void mtk_i2c_speed_init (uint8_t bus, uint32_t speed)
 
void mtk_i2c_config_timing (struct mt_i2c_regs *regs, struct mtk_i2c *bus_ctrl)
 

Variables

struct mtk_i2c mtk_i2c_bus_controller []
 

Macro Definition Documentation

◆ I2C_FAST_MODE_BUFFER

#define I2C_FAST_MODE_BUFFER   (300 / 3)

Definition at line 125 of file i2c_common.h.

◆ I2C_FAST_MODE_PLUS_BUFFER

#define I2C_FAST_MODE_PLUS_BUFFER   (20 / 3)

Definition at line 126 of file i2c_common.h.

◆ I2C_STANDARD_MODE_BUFFER

#define I2C_STANDARD_MODE_BUFFER   (1000 / 3)

Definition at line 124 of file i2c_common.h.

◆ I2C_TIME_CLR_VALUE

#define I2C_TIME_CLR_VALUE   0x0000

Definition at line 119 of file i2c_common.h.

◆ I2C_TIME_DEFAULT_VALUE

#define I2C_TIME_DEFAULT_VALUE   0x0083

Definition at line 123 of file i2c_common.h.

◆ MAX_HS_STEP_CNT_DIV

#define MAX_HS_STEP_CNT_DIV   8

Definition at line 122 of file i2c_common.h.

◆ MAX_SAMPLE_CNT_DIV

#define MAX_SAMPLE_CNT_DIV   8

Definition at line 120 of file i2c_common.h.

◆ MAX_STEP_CNT_DIV

#define MAX_STEP_CNT_DIV   64

Definition at line 121 of file i2c_common.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
I2C_HS_DEFAULT_VALUE 

Definition at line 26 of file i2c_common.h.

◆ anonymous enum

anonymous enum
Enumerator
I2C_DMA_CON_TX 
I2C_DMA_CON_RX 
I2C_DMA_START_EN 
I2C_DMA_INT_FLAG_NONE 
I2C_DMA_CLR_FLAG 
I2C_DMA_FLUSH_FLAG 
I2C_DMA_ASYNC_MODE 
I2C_DMA_SKIP_CONFIG 
I2C_DMA_DIR_CHANGE 
I2C_DMA_WARM_RST 
I2C_DMA_HARD_RST 
I2C_DMA_HANDSHAKE_RST 

Definition at line 36 of file i2c_common.h.

◆ anonymous enum

anonymous enum
Enumerator
I2C_TRANS_LEN_MASK 
I2C_TRANS_AUX_LEN_MASK 
I2C_CONTROL_MASK 

Definition at line 51 of file i2c_common.h.

◆ anonymous enum

anonymous enum
Enumerator
I2C_APDMA_NOASYNC 
I2C_APDMA_ASYNC 

Definition at line 57 of file i2c_common.h.

◆ anonymous enum

anonymous enum
Enumerator
I2C_HS_NACKERR 
I2C_ACKERR 
I2C_TRANSAC_COMP 

Definition at line 63 of file i2c_common.h.

◆ anonymous enum

anonymous enum
Enumerator
I2C_CLR_FLAG 
I2C_SOFT_RST 
I2C_HANDSHAKE_RST 

Definition at line 70 of file i2c_common.h.

◆ anonymous enum

anonymous enum
Enumerator
ASYNC_MODE 
DMAACK_EN 
ACK_ERR_DET_EN 
DIR_CHG 
CLK_EXT 
DMA_EN 
REPEATED_START_FLAG 
STOP_FLAG 

Definition at line 77 of file i2c_common.h.

◆ anonymous enum

anonymous enum
Enumerator
I2C_OK 
I2C_SET_SPEED_FAIL_OVER_SPEED 
I2C_TRANSFER_INVALID_LENGTH 
I2C_TRANSFER_FAIL_HS_NACKERR 
I2C_TRANSFER_FAIL_ACKERR 
I2C_TRANSFER_FAIL_TIMEOUT 
I2C_TRANSFER_INVALID_ARGUMENT 

Definition at line 89 of file i2c_common.h.

◆ i2c_modes

enum i2c_modes
Enumerator
I2C_WRITE_MODE 
I2C_READ_MODE 
I2C_WRITE_READ_MODE 

Definition at line 30 of file i2c_common.h.

Function Documentation

◆ check_member()

check_member ( mt_i2c_dma_regs  ,
dma_tx_len  ,
0x24   
)

◆ mtk_i2c_calculate_speed()

int mtk_i2c_calculate_speed ( uint8_t  bus,
uint32_t  clk_src,
uint32_t  target_speed,
uint32_t timing_step_cnt,
uint32_t timing_sample_cnt 
)

Definition at line 408 of file i2c.c.

References mtk_i2c::ac_timing, DIV_ROUND_UP, I2C_SPEED_HIGH, mtk_i2c_ac_timing::inter_clk_div, MAX_SAMPLE_CNT_DIV, mtk_i2c_bus_controller, mtk_i2c_check_ac_timing(), and mtk_i2c_max_step_cnt().

Referenced by mtk_i2c_speed_init().

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

◆ mtk_i2c_check_ac_timing()

◆ mtk_i2c_config_timing()

void mtk_i2c_config_timing ( struct mt_i2c_regs regs,
struct mtk_i2c bus_ctrl 
)

Definition at line 40 of file i2c.c.

References mtk_i2c::ac_timing, mtk_i2c_ac_timing::ext, mtk_i2c_ac_timing::hs, mtk_i2c_ac_timing::htiming, mtk_i2c_ac_timing::inter_clk_div, mtk_i2c_ac_timing::ltiming, and write32().

Referenced by mtk_i2c_speed_init().

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

◆ mtk_i2c_dump_more_info()

void mtk_i2c_dump_more_info ( struct mt_i2c_regs regs)

Definition at line 35 of file i2c.c.

References BIOS_DEBUG, printk, and read32().

Referenced by mtk_i2c_dump_info().

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

◆ mtk_i2c_get_spec()

const struct i2c_spec_values* mtk_i2c_get_spec ( uint32_t  speed)

Definition at line 45 of file i2c.c.

References fast_mode_plus_spec, fast_mode_spec, I2C_SPEED_FAST, I2C_SPEED_STANDARD, and standard_mode_spec.

Referenced by mtk_i2c_check_ac_timing().

Here is the caller graph for this function:

◆ mtk_i2c_speed_init()

void mtk_i2c_speed_init ( uint8_t  bus,
uint32_t  speed 
)

Variable Documentation

◆ mtk_i2c_bus_controller