FreeBSD kernel IICBUS device code
iicoc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  iicoc_softc
 

Macros

#define OC_I2C_PRESCALE_LO_REG   0x00
 
#define OC_I2C_PRESCALE_HI_REG   0x01
 
#define OC_I2C_CTRL_REG   0x02
 
#define OC_I2C_TRANSMIT_REG   0x03 /* tx and rx - same reg */
 
#define OC_I2C_RECV_REG   0x03 /* tx and rx - same reg */
 
#define OC_I2C_DATA_REG   0x03 /* tx and rx - same reg */
 
#define OC_I2C_CMD_REG   0x04 /* cmd and status - same reg */
 
#define OC_I2C_STATUS_REG   0x04 /* cmd and status - same reg */
 
#define XLP_I2C_CLKFREQ   133333333 /* XLP 133 MHz IO clock */
 
#define XLP_I2C_FREQ   100000 /* default 100kHz */
 
#define I2C_TIMEOUT   500000
 
#define OC_PRESCALER_LO   0
 
#define OC_PRESCALER_HI   1
 
#define OC_CONTROL   2
 
#define OC_CONTROL_EN   0x80
 
#define OC_CONTROL_IEN   0x40
 
#define OC_DATA   3 /* Data TX & RX Reg */
 
#define OC_COMMAND   4
 
#define OC_COMMAND_START   0x90
 
#define OC_COMMAND_STOP   0x40
 
#define OC_COMMAND_READ   0x20
 
#define OC_COMMAND_WRITE   0x10
 
#define OC_COMMAND_RDACK   0x20
 
#define OC_COMMAND_RDNACK   0x28
 
#define OC_COMMAND_IACK   0x01 /* Not used */
 
#define OC_STATUS   4 /* Same as 'command' */
 
#define OC_STATUS_NACK   0x80 /* Did not get an ACK */
 
#define OC_STATUS_BUSY   0x40
 
#define OC_STATUS_AL   0x20 /* Arbitration Lost */
 
#define OC_STATUS_TIP   0x02 /* Transfer in Progress */
 
#define OC_STATUS_IF   0x01 /* Intr. Pending Flag */
 

Functions

int iicoc_iicbus_start (device_t dev, u_char slave, int timeout)
 
int iicoc_iicbus_stop (device_t dev)
 
int iicoc_iicbus_read (device_t dev, char *buf, int len, int *read, int last, int delay)
 
int iicoc_iicbus_write (device_t dev, const char *buf, int len, int *sent, int timeout)
 
int iicoc_iicbus_repeated_start (device_t dev, u_char slave, int timeout)
 
int iicoc_iicbus_reset (device_t dev, u_char speed, u_char addr, u_char *oldadr)
 
int iicoc_init (device_t dev)
 

Variables

devclass_t iicoc_devclass
 

Macro Definition Documentation

◆ I2C_TIMEOUT

#define I2C_TIMEOUT   500000

Definition at line 48 of file iicoc.h.

◆ OC_COMMAND

#define OC_COMMAND   4

Definition at line 64 of file iicoc.h.

◆ OC_COMMAND_IACK

#define OC_COMMAND_IACK   0x01 /* Not used */

Definition at line 71 of file iicoc.h.

◆ OC_COMMAND_RDACK

#define OC_COMMAND_RDACK   0x20

Definition at line 69 of file iicoc.h.

◆ OC_COMMAND_RDNACK

#define OC_COMMAND_RDNACK   0x28

Definition at line 70 of file iicoc.h.

◆ OC_COMMAND_READ

#define OC_COMMAND_READ   0x20

Definition at line 67 of file iicoc.h.

◆ OC_COMMAND_START

#define OC_COMMAND_START   0x90

Definition at line 65 of file iicoc.h.

◆ OC_COMMAND_STOP

#define OC_COMMAND_STOP   0x40

Definition at line 66 of file iicoc.h.

◆ OC_COMMAND_WRITE

#define OC_COMMAND_WRITE   0x10

Definition at line 68 of file iicoc.h.

◆ OC_CONTROL

#define OC_CONTROL   2

Definition at line 58 of file iicoc.h.

◆ OC_CONTROL_EN

#define OC_CONTROL_EN   0x80

Definition at line 59 of file iicoc.h.

◆ OC_CONTROL_IEN

#define OC_CONTROL_IEN   0x40

Definition at line 60 of file iicoc.h.

◆ OC_DATA

#define OC_DATA   3 /* Data TX & RX Reg */

Definition at line 62 of file iicoc.h.

◆ OC_I2C_CMD_REG

#define OC_I2C_CMD_REG   0x04 /* cmd and status - same reg */

Definition at line 43 of file iicoc.h.

◆ OC_I2C_CTRL_REG

#define OC_I2C_CTRL_REG   0x02

Definition at line 39 of file iicoc.h.

◆ OC_I2C_DATA_REG

#define OC_I2C_DATA_REG   0x03 /* tx and rx - same reg */

Definition at line 42 of file iicoc.h.

◆ OC_I2C_PRESCALE_HI_REG

#define OC_I2C_PRESCALE_HI_REG   0x01

Definition at line 38 of file iicoc.h.

◆ OC_I2C_PRESCALE_LO_REG

#define OC_I2C_PRESCALE_LO_REG   0x00

Definition at line 37 of file iicoc.h.

◆ OC_I2C_RECV_REG

#define OC_I2C_RECV_REG   0x03 /* tx and rx - same reg */

Definition at line 41 of file iicoc.h.

◆ OC_I2C_STATUS_REG

#define OC_I2C_STATUS_REG   0x04 /* cmd and status - same reg */

Definition at line 44 of file iicoc.h.

◆ OC_I2C_TRANSMIT_REG

#define OC_I2C_TRANSMIT_REG   0x03 /* tx and rx - same reg */

Definition at line 40 of file iicoc.h.

◆ OC_PRESCALER_HI

#define OC_PRESCALER_HI   1

Definition at line 56 of file iicoc.h.

◆ OC_PRESCALER_LO

#define OC_PRESCALER_LO   0

Definition at line 55 of file iicoc.h.

◆ OC_STATUS

#define OC_STATUS   4 /* Same as 'command' */

Definition at line 73 of file iicoc.h.

◆ OC_STATUS_AL

#define OC_STATUS_AL   0x20 /* Arbitration Lost */

Definition at line 76 of file iicoc.h.

◆ OC_STATUS_BUSY

#define OC_STATUS_BUSY   0x40

Definition at line 75 of file iicoc.h.

◆ OC_STATUS_IF

#define OC_STATUS_IF   0x01 /* Intr. Pending Flag */

Definition at line 78 of file iicoc.h.

◆ OC_STATUS_NACK

#define OC_STATUS_NACK   0x80 /* Did not get an ACK */

Definition at line 74 of file iicoc.h.

◆ OC_STATUS_TIP

#define OC_STATUS_TIP   0x02 /* Transfer in Progress */

Definition at line 77 of file iicoc.h.

◆ XLP_I2C_CLKFREQ

#define XLP_I2C_CLKFREQ   133333333 /* XLP 133 MHz IO clock */

Definition at line 46 of file iicoc.h.

◆ XLP_I2C_FREQ

#define XLP_I2C_FREQ   100000 /* default 100kHz */

Definition at line 47 of file iicoc.h.

Function Documentation

◆ iicoc_iicbus_read()

int iicoc_iicbus_read ( device_t  dev,
char *  buf,
int  len,
int *  read,
int  last,
int  delay 
)

Definition at line 248 of file iicoc.c.

References buf, data, dev, IIC_EBUSERR, IIC_NOERR, iicoc_rd_cmd(), len, OC_COMMAND_RDNACK, OC_COMMAND_READ, and read.

Here is the call graph for this function:

◆ iicoc_iicbus_repeated_start()

int iicoc_iicbus_repeated_start ( device_t  dev,
u_char  slave,
int  timeout 
)

Definition at line 197 of file iicoc.c.

References dev, iicoc_iicbus_start_common(), slave, and timeout.

Here is the call graph for this function:

◆ iicoc_iicbus_reset()

int iicoc_iicbus_reset ( device_t  dev,
u_char  speed,
u_char  addr,
u_char *  oldadr 
)

Definition at line 274 of file iicoc.c.

References dev, iicoc_init(), and iicoc_softc::sc_mtx.

Here is the call graph for this function:

◆ iicoc_iicbus_start()

int iicoc_iicbus_start ( device_t  dev,
u_char  slave,
int  timeout 
)

Definition at line 190 of file iicoc.c.

References dev, iicoc_iicbus_start_common(), slave, and timeout.

Here is the call graph for this function:

◆ iicoc_iicbus_stop()

int iicoc_iicbus_stop ( device_t  dev)

Definition at line 204 of file iicoc.c.

References dev, iicoc_dev_write(), iicoc_wait_on_status(), OC_COMMAND_STOP, OC_I2C_CMD_REG, OC_STATUS_BUSY, and iicoc_softc::sc_mtx.

Here is the call graph for this function:

◆ iicoc_iicbus_write()

int iicoc_iicbus_write ( device_t  dev,
const char *  buf,
int  len,
int *  sent,
int  timeout 
)

Definition at line 218 of file iicoc.c.

References buf, dev, IIC_EBUSERR, IIC_NOERR, iicoc_wr_ack_cmd(), iicoc_wr_cmd(), len, and OC_COMMAND_WRITE.

Here is the call graph for this function:

◆ iicoc_init()

int iicoc_init ( device_t  dev)

Definition at line 130 of file iicoc.c.

References iicoc_softc::clockfreq, dev, iicoc_softc::i2cfreq, iicoc_dev_read(), iicoc_dev_write(), OC_CONTROL_EN, OC_CONTROL_IEN, OC_I2C_CTRL_REG, OC_I2C_PRESCALE_HI_REG, and OC_I2C_PRESCALE_LO_REG.

Referenced by iicoc_attach(), and iicoc_iicbus_reset().

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

Variable Documentation

◆ iicoc_devclass

devclass_t iicoc_devclass
extern

Definition at line 51 of file iicoc.c.