![]() |
coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
|
#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 <soc/pinmux.h>
#include <timer.h>
Go to the source code of this file.
Data Structures | |
struct | i2c_regs |
struct | hsi2c_regs |
struct | i2c_bus |
Macros | |
#define | I2C_TIMEOUT_US (1000 * USECS_PER_MSEC) |
#define | HSI2C_SLV_ADDR_MAS(x) ((x & 0x3ff) << 10) |
Enumerations | |
enum | { Hsi2cFuncModeI2c = 1 << 0 , Hsi2cMaster = 1 << 3 , Hsi2cRxchon = 1 << 6 , Hsi2cTxchon = 1 << 7 , Hsi2cSwRst = 1 << 31 } |
enum | { Hsi2cTxFifoLevel = 0x7f << 0 , Hsi2cTxFifoFull = 1 << 7 , Hsi2cTxFifoEmpty = 1 << 8 , Hsi2cRxFifoLevel = 0x7f << 16 , Hsi2cRxFifoFull = 1 << 23 , Hsi2cRxFifoEmpty = 1 << 24 } |
enum | { Hsi2cRxfifoEn = 1 << 0 , Hsi2cTxfifoEn = 1 << 1 , Hsi2cTxfifoTriggerLevel = 0x20 << 16 , Hsi2cRxfifoTriggerLevel = 0x20 << 4 } |
enum | { Hsi2cTrailingCount = 0xff } |
enum | { Hsi2cIntTxAlmostemptyEn = 1 << 0 , Hsi2cIntRxAlmostfullEn = 1 << 1 , Hsi2cIntTrailingEn = 1 << 6 , Hsi2cIntI2cEn = 1 << 9 } |
enum | { Hsi2cAutoMode = 1 << 31 , Hsi2c10bitAddrMode = 1 << 30 , Hsi2cHsMode = 1 << 29 } |
enum | { Hsi2cReadWrite = 1 << 16 , Hsi2cStopAfterTrans = 1 << 17 , Hsi2cMasterRun = 1 << 31 } |
enum | { Hsi2cTimeoutEn = 1 << 31 } |
enum | { Hsi2cMasterBusy = 1 << 17 , Hsi2cSlaveBusy = 1 << 16 , Hsi2cTimeoutAuto = 1 << 4 , Hsi2cNoDev = 1 << 3 , Hsi2cNoDevAck = 1 << 2 , Hsi2cTransAbort = 1 << 1 , Hsi2cTransDone = 1 << 0 } |
enum | { Hsi2cTimeout = 100 } |
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 | |
check_member (hsi2c_regs, i2c_addr, 0x70) | |
static int | hsi2c_get_clk_details (struct i2c_bus *i2c, int *div, int *cycle, unsigned int op_clk) |
static void | hsi2c_ch_init (struct i2c_bus *i2c, unsigned int frequency) |
static void | hsi2c_reset (struct i2c_bus *i2c) |
static void | i2c_ch_init (struct i2c_bus *i2c, int speed) |
void | i2c_init (unsigned int bus, int speed, int slaveadd) |
static int | hsi2c_check_transfer (struct hsi2c_regs *regs) |
static int | hsi2c_wait_for_transfer (struct hsi2c_regs *i2c) |
static int | hsi2c_senddata (struct hsi2c_regs *regs, const uint8_t *data, int len) |
static int | hsi2c_recvdata (struct hsi2c_regs *regs, uint8_t *data, int len) |
static int | hsi2c_segment (struct i2c_msg *seg, struct hsi2c_regs *regs, int stop) |
static int | hsi2c_transfer (struct i2c_bus *i2c, struct i2c_msg *segments, int count) |
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 count) |
Variables | |
static struct i2c_bus | i2c_busses [] |
#define I2C_TIMEOUT_US (1000 * USECS_PER_MSEC) |
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
anonymous enum |
check_member | ( | hsi2c_regs | , |
i2c_addr | , | ||
0x70 | |||
) |
Definition at line 269 of file i2c.c.
References hsi2c_get_clk_details(), Hsi2cAutoMode, Hsi2cRxfifoEn, Hsi2cTimeoutEn, Hsi2cTrailingCount, Hsi2cTxfifoEn, i2c_bus::hsregs, read32(), and write32().
Referenced by hsi2c_reset(), and i2c_init().
|
static |
Definition at line 366 of file i2c.c.
References BIOS_ERR, Hsi2cMasterBusy, Hsi2cNoDev, Hsi2cNoDevAck, Hsi2cTimeoutAuto, Hsi2cTransAbort, printk, and read32().
Referenced by hsi2c_recvdata(), hsi2c_senddata(), and hsi2c_wait_for_transfer().
|
static |
Definition at line 240 of file i2c.c.
References BIOS_ERR, clock_get_periph_rate(), i2c_bus::hsregs, i2c_bus::periph_id, printk, and read32().
Referenced by hsi2c_ch_init().
|
static |
Definition at line 419 of file i2c.c.
References hsi2c_check_transfer(), Hsi2cRxFifoEmpty, and read32().
Referenced by hsi2c_segment().
Definition at line 306 of file i2c.c.
References hsi2c_ch_init(), Hsi2cSwRst, i2c_bus::hsregs, read32(), and write32().
Referenced by hsi2c_transfer(), and i2c_init().
|
static |
Definition at line 430 of file i2c.c.
References i2c_msg::buf, i2c_msg::flags, hsi2c_recvdata(), hsi2c_senddata(), HSI2C_SLV_ADDR_MAS, hsi2c_wait_for_transfer(), Hsi2cFuncModeI2c, Hsi2cMaster, Hsi2cMasterRun, Hsi2cReadWrite, Hsi2cRxchon, Hsi2cStopAfterTrans, Hsi2cTxchon, I2C_M_RD, i2c_msg::len, i2c_msg::slave, and write32().
Referenced by hsi2c_transfer().
|
static |
Definition at line 408 of file i2c.c.
References hsi2c_check_transfer(), Hsi2cTxFifoFull, read32(), and write32().
Referenced by hsi2c_segment().
Definition at line 468 of file i2c.c.
References count, hsi2c_reset(), hsi2c_segment(), hsi2c_wait_for_transfer(), and i2c_bus::hsregs.
Referenced by platform_i2c_transfer().
|
static |
Definition at line 395 of file i2c.c.
References hsi2c_check_transfer(), Hsi2cTimeout, stopwatch_expired(), and stopwatch_init_msecs_expire().
Referenced by hsi2c_segment(), and hsi2c_transfer().
Definition at line 503 of file i2c.c.
References I2cConAckGen, read8(), and write8().
Referenced by i2c_recv_buf().
Definition at line 498 of file i2c.c.
References I2cConAckGen, read8(), and write8().
Referenced by i2c_recv_buf(), and i2c_xmit_buf().
Definition at line 318 of file i2c.c.
References clock_get_periph_rate(), I2cStatEnable, I2cStatMasterXmit, i2c_bus::periph_id, i2c_bus::regs, val, and write32().
Referenced by i2c_init().
Definition at line 493 of file i2c.c.
References I2cConIntPending, read8(), and write8().
Referenced by i2c_recv_buf(), i2c_send_start(), i2c_send_stop(), and i2c_xmit_buf().
|
static |
Definition at line 508 of file i2c.c.
References I2cStatAck, and read8().
Referenced by i2c_send_start(), and i2c_xmit_buf().
Definition at line 347 of file i2c.c.
References i2c_regs::add, clock_get_periph_rate(), i2c_regs::con, hsi2c_ch_init(), hsi2c_reset(), i2c_busses, i2c_ch_init(), I2cStatEnable, I2cStatMasterXmit, i2c_bus::is_highspeed, s3c24x0_i2c_bus::periph_id, s3c24x0_i2c_bus::regs, i2c_regs::stat, val, and write32().
|
static |
Definition at line 488 of file i2c.c.
References I2cConIntPending, and read8().
Referenced by i2c_wait_for_int().
Definition at line 586 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().
|
static |
Definition at line 545 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().
|
static |
Definition at line 537 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().
|
static |
Definition at line 513 of file i2c.c.
References BIOS_ERR, I2cStatBusy, printk, read8(), and udelay().
Referenced by i2c_send_stop(), and platform_i2c_transfer().
|
static |
Definition at line 525 of file i2c.c.
References BIOS_ERR, i2c_int_pending(), printk, and udelay().
Referenced by i2c_recv_buf(), i2c_send_start(), and i2c_xmit_buf().
Definition at line 563 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().
Definition at line 607 of file i2c.c.
References i2c_msg::buf, count, i2c_msg::flags, hsi2c_transfer(), i2c_busses, I2C_M_RD, i2c_recv_buf(), i2c_send_start(), i2c_send_stop(), I2C_TIMEOUT_US, i2c_wait_for_idle(), i2c_xmit_buf(), I2cStatEnable, I2cStatMasterXmit, i2c_bus::is_highspeed, i2c_msg::len, i2c_bus::regs, i2c_msg::slave, and write8().
Referenced by i2c_transfer().
|
static |
Definition at line 62 of file i2c.c.
Referenced by i2c_init(), and platform_i2c_transfer().