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

Go to the source code of this file.

Data Structures

struct  software_i2c_ops
 

Macros

#define SOFTWARE_I2C_MAX_BUS   10 /* increase as necessary */
 

Functions

int platform_i2c_transfer (unsigned int bus, struct i2c_msg *segments, int count)
 
int software_i2c_transfer (unsigned int bus, struct i2c_msg *segments, int count)
 
void software_i2c_wedge_ack (unsigned int bus, u8 slave)
 
void software_i2c_wedge_read (unsigned int bus, u8 slave, u8 reg, int bit_count)
 
void software_i2c_wedge_write (unsigned int bus, u8 slave, u8 reg, int bit_count)
 
int i2c_read_field (unsigned int bus, uint8_t slave, uint8_t reg, uint8_t *data, uint8_t mask, uint8_t shift)
 
int i2c_write_field (unsigned int bus, uint8_t slave, uint8_t reg, uint8_t data, uint8_t mask, uint8_t shift)
 
static int i2c_transfer (unsigned int bus, struct i2c_msg *segments, int count)
 
static int i2c_read_raw (unsigned int bus, uint8_t slave, uint8_t *data, int len)
 
static int i2c_write_raw (unsigned int bus, uint8_t slave, uint8_t *data, int len)
 
static int i2c_read_bytes (unsigned int bus, uint8_t slave, uint8_t reg, uint8_t *data, int len)
 Read multi-bytes with two segments in one frame. More...
 
static int i2c_readb (unsigned int bus, uint8_t slave, uint8_t reg, uint8_t *data)
 Read a byte with two segments in one frame. More...
 
static int i2c_writeb (unsigned int bus, uint8_t slave, uint8_t reg, uint8_t data)
 Write a byte with one segment in one frame. More...
 
static int i2c_2ba_read_bytes (unsigned int bus, uint8_t slave, uint16_t offset, uint8_t *data, int len)
 Read multi-bytes from an I2C device with two bytes register address/offset with two segments in one frame. More...
 

Variables

struct software_i2c_opssoftware_i2c []
 

Macro Definition Documentation

◆ SOFTWARE_I2C_MAX_BUS

#define SOFTWARE_I2C_MAX_BUS   10 /* increase as necessary */

Definition at line 13 of file i2c_simple.h.

Function Documentation

◆ i2c_2ba_read_bytes()

static int i2c_2ba_read_bytes ( unsigned int  bus,
uint8_t  slave,
uint16_t  offset,
uint8_t data,
int  len 
)
inlinestatic

Read multi-bytes from an I2C device with two bytes register address/offset with two segments in one frame.

[start][slave addr][w][register high addr][register low addr] [start][slave addr][r][data...][stop]

Definition at line 152 of file i2c_simple.h.

References ARRAY_SIZE, i2c_msg::buf, i2c_msg::flags, I2C_M_RD, i2c_transfer(), i2c_msg::len, offset, slave, and i2c_msg::slave.

Referenced by get_ddi1_type().

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

◆ i2c_read_bytes()

static int i2c_read_bytes ( unsigned int  bus,
uint8_t  slave,
uint8_t  reg,
uint8_t data,
int  len 
)
inlinestatic

Read multi-bytes with two segments in one frame.

[start][slave addr][w][register addr][start][slave addr][r][data...][stop]

Definition at line 87 of file i2c_simple.h.

References ARRAY_SIZE, i2c_msg::buf, i2c_msg::flags, I2C_M_RD, i2c_transfer(), i2c_msg::len, slave, and i2c_msg::slave.

Referenced by anx7625_reg_block_read(), ast_software_i2c_read(), mt6360_i2c_read_byte(), and ps8640_get_edid().

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

◆ i2c_read_field()

int i2c_read_field ( unsigned int  bus,
uint8_t  slave,
uint8_t  reg,
uint8_t data,
uint8_t  mask,
uint8_t  shift 
)

Definition at line 6 of file i2c.c.

References buf, chip, i2c_readb(), and mask.

Referenced by da9212_probe(), get_mt6311_chip_id(), get_mt6691_chip_id(), mt6311_hw_init(), and mt6691_get_voltage().

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

◆ i2c_read_raw()

static int i2c_read_raw ( unsigned int  bus,
uint8_t  slave,
uint8_t data,
int  len 
)
inlinestatic

Definition at line 57 of file i2c_simple.h.

References i2c_msg::flags, I2C_M_RD, i2c_transfer(), i2c_msg::len, and slave.

Referenced by cr50_i2c_read(), google_chromeec_command(), iic_tpm_read(), and tis_sendrecv().

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

◆ i2c_readb()

static int i2c_readb ( unsigned int  bus,
uint8_t  slave,
uint8_t  reg,
uint8_t data 
)
inlinestatic

Read a byte with two segments in one frame.

[start][slave addr][w][register addr][start][slave addr][r][data][stop]

Definition at line 109 of file i2c_simple.h.

References ARRAY_SIZE, i2c_msg::buf, i2c_msg::flags, I2C_M_RD, i2c_transfer(), i2c_msg::len, slave, and i2c_msg::slave.

Referenced by anx7625_reg_read(), as3722_read(), i2c_read_field(), i2c_write_field(), max77686_i2c_read(), ps8640_bridge_aux_request(), reg_read(), rk808_read(), setup_power(), sn65dsi86_bridge_link_training(), tps65090_i2c_read(), and tps65913_read().

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

◆ i2c_transfer()

static int i2c_transfer ( unsigned int  bus,
struct i2c_msg segments,
int  count 
)
inlinestatic

Definition at line 42 of file i2c_simple.h.

References CONFIG, count, platform_i2c_transfer(), software_i2c, SOFTWARE_I2C_MAX_BUS, and software_i2c_transfer().

Referenced by bdk_twsix_read_ia(), eeprom_random_read(), i2c_2ba_read_bytes(), i2c_read_bytes(), i2c_read_raw(), i2c_readb(), i2c_write_raw(), i2c_writeb(), iic_tpm_read(), and ledc_transfer().

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

◆ i2c_write_field()

int i2c_write_field ( unsigned int  bus,
uint8_t  slave,
uint8_t  reg,
uint8_t  data,
uint8_t  mask,
uint8_t  shift 
)

◆ i2c_write_raw()

static int i2c_write_raw ( unsigned int  bus,
uint8_t  slave,
uint8_t data,
int  len 
)
inlinestatic

Definition at line 72 of file i2c_simple.h.

References i2c_msg::flags, i2c_transfer(), i2c_msg::len, and slave.

Referenced by cr50_i2c_read(), cr50_i2c_write(), google_chromeec_command(), iic_tpm_read(), iic_tpm_write_generic(), mt6360_i2c_write_byte(), and tis_sendrecv().

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

◆ i2c_writeb()

static int i2c_writeb ( unsigned int  bus,
uint8_t  slave,
uint8_t  reg,
uint8_t  data 
)
inlinestatic

◆ platform_i2c_transfer()

◆ software_i2c_transfer()

int software_i2c_transfer ( unsigned int  bus,
struct i2c_msg segments,
int  count 
)

Definition at line 233 of file software_i2c.c.

References i2c_msg::buf, count, i2c_msg::flags, I2C_M_RD, in_byte(), i2c_msg::len, out_byte(), i2c_msg::slave, start_cond(), and stop_cond().

Referenced by i2c_transfer().

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

◆ software_i2c_wedge_ack()

void software_i2c_wedge_ack ( unsigned int  bus,
u8  slave 
)

Definition at line 261 of file software_i2c.c.

References BIOS_INFO, chip, get_scl(), get_sda(), out_bit(), printk, software_i2c_ops::set_scl, software_i2c_ops::set_sda, software_i2c, start_cond(), wait(), and wait_for_scl().

Here is the call graph for this function:

◆ software_i2c_wedge_read()

void software_i2c_wedge_read ( unsigned int  bus,
u8  slave,
u8  reg,
int  bit_count 
)

Definition at line 284 of file software_i2c.c.

References BIOS_INFO, chip, get_scl(), get_sda(), in_bit(), out_byte(), printk, software_i2c_ops::set_scl, software_i2c_ops::set_sda, software_i2c, start_cond(), wait(), and wait_for_scl().

Here is the call graph for this function:

◆ software_i2c_wedge_write()

void software_i2c_wedge_write ( unsigned int  bus,
u8  slave,
u8  reg,
int  bit_count 
)

Definition at line 313 of file software_i2c.c.

References BIOS_INFO, chip, get_scl(), get_sda(), out_bit(), out_byte(), printk, software_i2c_ops::set_scl, software_i2c_ops::set_sda, software_i2c, start_cond(), wait(), and wait_for_scl().

Here is the call graph for this function:

Variable Documentation

◆ software_i2c