coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
kempld_i2c.c File Reference
#include <stdint.h>
#include <console/console.h>
#include <device/device.h>
#include <device/i2c_bus.h>
#include <timer.h>
#include <delay.h>
#include "chip.h"
#include "kempld.h"
#include "kempld_internal.h"
Include dependency graph for kempld_i2c.c:

Go to the source code of this file.

Data Structures

struct  kempld_i2c_data
 

Macros

#define KEMPLD_I2C_PRELOW   0x0b
 
#define KEMPLD_I2C_PREHIGH   0x0c
 
#define KEMPLD_I2C_DATA   0x0e
 
#define KEMPLD_I2C_CTRL   0x0d
 
#define I2C_CTRL_IEN   0x40
 
#define I2C_CTRL_EN   0x80
 
#define KEMPLD_I2C_STAT   0x0f
 
#define I2C_STAT_IF   0x01
 
#define I2C_STAT_TIP   0x02
 
#define I2C_STAT_ARBLOST   0x20
 
#define I2C_STAT_BUSY   0x40
 
#define I2C_STAT_NACK   0x80
 
#define KEMPLD_I2C_CMD   0x0f
 
#define I2C_CMD_START   0x91
 
#define I2C_CMD_STOP   0x41
 
#define I2C_CMD_READ   0x21
 
#define I2C_CMD_WRITE   0x11
 
#define I2C_CMD_READ_ACK   0x21
 
#define I2C_CMD_READ_NACK   0x29
 
#define I2C_CMD_IACK   0x01
 
#define EIO   5
 
#define ENXIO   6
 
#define EAGAIN   11
 
#define EBUSY   16
 
#define ETIMEDOUT   110
 

Enumerations

enum  kempld_i2c_state {
  STATE_DONE = 0 , STATE_INIT , STATE_ADDR , STATE_ADDR10 ,
  STATE_START , STATE_WRITE , STATE_READ , STATE_ERROR
}
 

Functions

static int kempld_i2c_process (struct kempld_i2c_data *const i2c)
 
static int kempld_i2c_xfer (struct device *const dev, const struct i2c_msg *const msgs, const size_t num)
 
void kempld_i2c_device_init (struct device *const dev)
 

Variables

static const struct i2c_bus_operations kempld_i2c_bus_ops
 
static struct device_operations kempld_i2c_dev_ops
 

Macro Definition Documentation

◆ EAGAIN

#define EAGAIN   11

Definition at line 46 of file kempld_i2c.c.

◆ EBUSY

#define EBUSY   16

Definition at line 47 of file kempld_i2c.c.

◆ EIO

#define EIO   5

Definition at line 44 of file kempld_i2c.c.

◆ ENXIO

#define ENXIO   6

Definition at line 45 of file kempld_i2c.c.

◆ ETIMEDOUT

#define ETIMEDOUT   110

Definition at line 48 of file kempld_i2c.c.

◆ I2C_CMD_IACK

#define I2C_CMD_IACK   0x01

Definition at line 42 of file kempld_i2c.c.

◆ I2C_CMD_READ

#define I2C_CMD_READ   0x21

Definition at line 38 of file kempld_i2c.c.

◆ I2C_CMD_READ_ACK

#define I2C_CMD_READ_ACK   0x21

Definition at line 40 of file kempld_i2c.c.

◆ I2C_CMD_READ_NACK

#define I2C_CMD_READ_NACK   0x29

Definition at line 41 of file kempld_i2c.c.

◆ I2C_CMD_START

#define I2C_CMD_START   0x91

Definition at line 36 of file kempld_i2c.c.

◆ I2C_CMD_STOP

#define I2C_CMD_STOP   0x41

Definition at line 37 of file kempld_i2c.c.

◆ I2C_CMD_WRITE

#define I2C_CMD_WRITE   0x11

Definition at line 39 of file kempld_i2c.c.

◆ I2C_CTRL_EN

#define I2C_CTRL_EN   0x80

Definition at line 26 of file kempld_i2c.c.

◆ I2C_CTRL_IEN

#define I2C_CTRL_IEN   0x40

Definition at line 25 of file kempld_i2c.c.

◆ I2C_STAT_ARBLOST

#define I2C_STAT_ARBLOST   0x20

Definition at line 31 of file kempld_i2c.c.

◆ I2C_STAT_BUSY

#define I2C_STAT_BUSY   0x40

Definition at line 32 of file kempld_i2c.c.

◆ I2C_STAT_IF

#define I2C_STAT_IF   0x01

Definition at line 29 of file kempld_i2c.c.

◆ I2C_STAT_NACK

#define I2C_STAT_NACK   0x80

Definition at line 33 of file kempld_i2c.c.

◆ I2C_STAT_TIP

#define I2C_STAT_TIP   0x02

Definition at line 30 of file kempld_i2c.c.

◆ KEMPLD_I2C_CMD

#define KEMPLD_I2C_CMD   0x0f

Definition at line 35 of file kempld_i2c.c.

◆ KEMPLD_I2C_CTRL

#define KEMPLD_I2C_CTRL   0x0d

Definition at line 24 of file kempld_i2c.c.

◆ KEMPLD_I2C_DATA

#define KEMPLD_I2C_DATA   0x0e

Definition at line 22 of file kempld_i2c.c.

◆ KEMPLD_I2C_PREHIGH

#define KEMPLD_I2C_PREHIGH   0x0c

Definition at line 21 of file kempld_i2c.c.

◆ KEMPLD_I2C_PRELOW

#define KEMPLD_I2C_PRELOW   0x0b

Definition at line 20 of file kempld_i2c.c.

◆ KEMPLD_I2C_STAT

#define KEMPLD_I2C_STAT   0x0f

Definition at line 28 of file kempld_i2c.c.

Enumeration Type Documentation

◆ kempld_i2c_state

Enumerator
STATE_DONE 
STATE_INIT 
STATE_ADDR 
STATE_ADDR10 
STATE_START 
STATE_WRITE 
STATE_READ 
STATE_ERROR 

Definition at line 50 of file kempld_i2c.c.

Function Documentation

◆ kempld_i2c_device_init()

◆ kempld_i2c_process()

◆ kempld_i2c_xfer()

static int kempld_i2c_xfer ( struct device *const  dev,
const struct i2c_msg *const  msgs,
const size_t  num 
)
static

Definition at line 173 of file kempld_i2c.c.

Variable Documentation

◆ kempld_i2c_bus_ops

const struct i2c_bus_operations kempld_i2c_bus_ops
static
Initial value:
= {
.transfer = kempld_i2c_xfer,
}
static int kempld_i2c_xfer(struct device *const dev, const struct i2c_msg *const msgs, const size_t num)
Definition: kempld_i2c.c:173

Definition at line 173 of file kempld_i2c.c.

◆ kempld_i2c_dev_ops

struct device_operations kempld_i2c_dev_ops
static
Initial value:
= {
.scan_bus = &scan_smbus,
.ops_i2c_bus = &kempld_i2c_bus_ops,
}
static const struct i2c_bus_operations kempld_i2c_bus_ops
Definition: kempld_i2c.c:219
void scan_smbus(struct device *bus)
Definition: root_device.c:74

Definition at line 173 of file kempld_i2c.c.

Referenced by kempld_i2c_device_init().