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

Go to the source code of this file.

Data Structures

struct  i2c_regs
 
struct  s3c24x0_i2c_bus
 

Macros

#define I2C_TIMEOUT_US   (1000 * USECS_PER_MSEC)
 

Enumerations

enum  { I2cConIntPending = 0x1 << 4 , I2cConIntEn = 0x1 << 5 , I2cConAckGen = 0x1 << 7 }
 
enum  {
  I2cStatAck = 0x1 << 0 , I2cStatAddrZero = 0x1 << 1 , I2cStatAddrSlave = 0x1 << 2 , I2cStatArb = 0x1 << 3 ,
  I2cStatEnable = 0x1 << 4 , I2cStatStartStop = 0x1 << 5 , I2cStatBusy = 0x1 << 5 , I2cStatModeMask = 0x3 << 6 ,
  I2cStatSlaveRecv = 0x0 << 6 , I2cStatSlaveXmit = 0x1 << 6 , I2cStatMasterRecv = 0x2 << 6 , I2cStatMasterXmit = 0x3 << 6
}
 

Functions

static int i2c_int_pending (struct i2c_regs *regs)
 
static void i2c_clear_int (struct i2c_regs *regs)
 
static void i2c_ack_enable (struct i2c_regs *regs)
 
static void i2c_ack_disable (struct i2c_regs *regs)
 
static int i2c_got_ack (struct i2c_regs *regs)
 
static int i2c_wait_for_idle (struct i2c_regs *regs, int timeout_us)
 
static int i2c_wait_for_int (struct i2c_regs *regs, int timeout_us)
 
static int i2c_send_stop (struct i2c_regs *regs)
 
static int i2c_send_start (struct i2c_regs *regs, int read, int chip)
 
static int i2c_xmit_buf (struct i2c_regs *regs, uint8_t *data, int len)
 
static int i2c_recv_buf (struct i2c_regs *regs, uint8_t *data, int len)
 
int platform_i2c_transfer (unsigned int bus, struct i2c_msg *segments, int seg_count)
 
void i2c_init (unsigned int bus, int speed, int slaveadd)
 

Variables

static struct s3c24x0_i2c_bus i2c_busses []
 

Macro Definition Documentation

◆ I2C_TIMEOUT_US

#define I2C_TIMEOUT_US   (1000 * USECS_PER_MSEC)

Definition at line 13 of file i2c.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
I2cConIntPending 
I2cConIntEn 
I2cConAckGen 

Definition at line 35 of file i2c.c.

◆ anonymous enum

anonymous enum
Enumerator
I2cStatAck 
I2cStatAddrZero 
I2cStatAddrSlave 
I2cStatArb 
I2cStatEnable 
I2cStatStartStop 
I2cStatBusy 
I2cStatModeMask 
I2cStatSlaveRecv 
I2cStatSlaveXmit 
I2cStatMasterRecv 
I2cStatMasterXmit 

Definition at line 41 of file i2c.c.

Function Documentation

◆ i2c_ack_disable()

static void i2c_ack_disable ( struct i2c_regs regs)
static

Definition at line 115 of file i2c.c.

References I2cConAckGen, read8(), and write8().

Referenced by i2c_recv_buf().

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

◆ i2c_ack_enable()

static void i2c_ack_enable ( struct i2c_regs regs)
static

Definition at line 110 of file i2c.c.

References I2cConAckGen, read8(), and write8().

Referenced by i2c_recv_buf(), and i2c_xmit_buf().

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

◆ i2c_clear_int()

static void i2c_clear_int ( struct i2c_regs regs)
static

Definition at line 105 of file i2c.c.

References I2cConIntPending, read8(), and write8().

Referenced by i2c_recv_buf(), i2c_send_start(), i2c_send_stop(), and i2c_xmit_buf().

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

◆ i2c_got_ack()

static int i2c_got_ack ( struct i2c_regs regs)
static

Definition at line 120 of file i2c.c.

References I2cStatAck, and read8().

Referenced by i2c_send_start(), and i2c_xmit_buf().

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

◆ i2c_init()

void i2c_init ( unsigned int  bus,
int  speed,
int  slaveadd 
)

Definition at line 249 of file i2c.c.

◆ i2c_int_pending()

static int i2c_int_pending ( struct i2c_regs regs)
static

Definition at line 100 of file i2c.c.

References I2cConIntPending, and read8().

Referenced by i2c_wait_for_int().

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

◆ i2c_recv_buf()

static int i2c_recv_buf ( struct i2c_regs regs,
uint8_t data,
int  len 
)
static

Definition at line 198 of file i2c.c.

References ASSERT, i2c_ack_disable(), i2c_ack_enable(), i2c_clear_int(), i2c_wait_for_int(), and read8().

Referenced by platform_i2c_transfer().

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

◆ i2c_send_start()

static int i2c_send_start ( struct i2c_regs regs,
int  read,
int  chip 
)
static

Definition at line 157 of file i2c.c.

References chip, i2c_clear_int(), i2c_got_ack(), I2C_TIMEOUT_US, i2c_wait_for_int(), I2cStatEnable, I2cStatMasterRecv, I2cStatMasterXmit, I2cStatStartStop, and write8().

Referenced by platform_i2c_transfer().

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

◆ i2c_send_stop()

static int i2c_send_stop ( struct i2c_regs regs)
static

Definition at line 149 of file i2c.c.

References i2c_clear_int(), I2C_TIMEOUT_US, i2c_wait_for_idle(), I2cStatEnable, I2cStatModeMask, read8(), and write8().

Referenced by platform_i2c_transfer().

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

◆ i2c_wait_for_idle()

static int i2c_wait_for_idle ( struct i2c_regs regs,
int  timeout_us 
)
static

Definition at line 125 of file i2c.c.

References BIOS_ERR, DIV_ROUND_UP, I2cStatBusy, printk, read8(), and udelay().

Referenced by i2c_send_stop(), and platform_i2c_transfer().

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

◆ i2c_wait_for_int()

static int i2c_wait_for_int ( struct i2c_regs regs,
int  timeout_us 
)
static

Definition at line 137 of file i2c.c.

References BIOS_ERR, DIV_ROUND_UP, i2c_int_pending(), printk, and udelay().

Referenced by i2c_recv_buf(), i2c_send_start(), and i2c_xmit_buf().

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

◆ i2c_xmit_buf()

static int i2c_xmit_buf ( struct i2c_regs regs,
uint8_t data,
int  len 
)
static

Definition at line 175 of file i2c.c.

References ASSERT, BIOS_INFO, i2c_ack_enable(), i2c_clear_int(), i2c_got_ack(), i2c_wait_for_int(), printk, and write8().

Referenced by platform_i2c_transfer().

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

◆ platform_i2c_transfer()

int platform_i2c_transfer ( unsigned int  bus,
struct i2c_msg segments,
int  seg_count 
)

Variable Documentation

◆ i2c_busses

struct s3c24x0_i2c_bus i2c_busses[]
static

Definition at line 1 of file i2c.c.

Referenced by i2c_init(), and platform_i2c_transfer().