FreeBSD kernel IICBUS device code
iicoc.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/rman.h>
#include <machine/bus.h>
#include <dev/iicbus/iicbus.h>
#include <dev/iicbus/iiconf.h>
#include "iicbus_if.h"
#include "iicoc.h"
Include dependency graph for iicoc.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
 DRIVER_MODULE (iicbus, iicoc, iicbus_driver, iicbus_devclass, 0, 0)
 
static void iicoc_dev_write (device_t dev, int reg, int value)
 
static int iicoc_dev_read (device_t dev, int reg)
 
static int iicoc_wait_on_status (device_t dev, uint8_t bit)
 
static int iicoc_rd_cmd (device_t dev, uint8_t cmd)
 
static int iicoc_wr_cmd (device_t dev, uint8_t data, uint8_t cmd)
 
static int iicoc_wr_ack_cmd (device_t dev, uint8_t data, uint8_t cmd)
 
int iicoc_init (device_t dev)
 
static int iicoc_iicbus_start_common (device_t dev, u_char slave, int timeout, bool repeat)
 
int iicoc_iicbus_start (device_t dev, u_char slave, int timeout)
 
int iicoc_iicbus_repeated_start (device_t dev, u_char slave, int timeout)
 
int iicoc_iicbus_stop (device_t dev)
 
int iicoc_iicbus_write (device_t dev, const char *buf, int len, int *sent, int timeout)
 
int iicoc_iicbus_read (device_t dev, char *buf, int len, int *read, int last, int delay)
 
int iicoc_iicbus_reset (device_t dev, u_char speed, u_char addr, u_char *oldadr)
 

Variables

devclass_t iicoc_devclass
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( iicbus  ,
iicoc  ,
iicbus_driver  ,
iicbus_devclass  ,
,
 
)

◆ iicoc_dev_read()

static int iicoc_dev_read ( device_t  dev,
int  reg 
)
static

Definition at line 65 of file iicoc.c.

References dev, iicoc_softc::mem_res, iicoc_softc::reg_shift, and val.

Referenced by iicoc_iicbus_start_common(), iicoc_init(), iicoc_rd_cmd(), iicoc_wait_on_status(), and iicoc_wr_ack_cmd().

Here is the caller graph for this function:

◆ iicoc_dev_write()

static void iicoc_dev_write ( device_t  dev,
int  reg,
int  value 
)
static

Definition at line 56 of file iicoc.c.

References dev, iicoc_softc::mem_res, and iicoc_softc::reg_shift.

Referenced by iicoc_iicbus_start_common(), iicoc_iicbus_stop(), iicoc_init(), iicoc_rd_cmd(), and iicoc_wr_cmd().

Here is the caller graph for this function:

◆ 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_start_common()

static int iicoc_iicbus_start_common ( device_t  dev,
u_char  slave,
int  timeout,
bool  repeat 
)
static

◆ 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:

◆ iicoc_rd_cmd()

static int iicoc_rd_cmd ( device_t  dev,
uint8_t  cmd 
)
static

Definition at line 89 of file iicoc.c.

References data, dev, iicoc_dev_read(), iicoc_dev_write(), iicoc_wait_on_status(), OC_I2C_CMD_REG, OC_I2C_DATA_REG, and OC_STATUS_TIP.

Referenced by iicoc_iicbus_read().

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

◆ iicoc_wait_on_status()

static int iicoc_wait_on_status ( device_t  dev,
uint8_t  bit 
)
static

Definition at line 76 of file iicoc.c.

References dev, I2C_TIMEOUT, iicoc_dev_read(), and OC_I2C_STATUS_REG.

Referenced by iicoc_iicbus_start_common(), iicoc_iicbus_stop(), iicoc_rd_cmd(), and iicoc_wr_cmd().

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

◆ iicoc_wr_ack_cmd()

static int iicoc_wr_ack_cmd ( device_t  dev,
uint8_t  data,
uint8_t  cmd 
)
static

Definition at line 116 of file iicoc.c.

References data, dev, IIC_ENOACK, iicoc_dev_read(), iicoc_wr_cmd(), OC_I2C_STATUS_REG, and OC_STATUS_NACK.

Referenced by iicoc_iicbus_start_common(), and iicoc_iicbus_write().

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

◆ iicoc_wr_cmd()

static int iicoc_wr_cmd ( device_t  dev,
uint8_t  data,
uint8_t  cmd 
)
static

Definition at line 103 of file iicoc.c.

References data, dev, iicoc_dev_write(), iicoc_wait_on_status(), OC_I2C_CMD_REG, OC_I2C_DATA_REG, and OC_STATUS_TIP.

Referenced by iicoc_iicbus_write(), and iicoc_wr_ack_cmd().

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

Variable Documentation

◆ iicoc_devclass

devclass_t iicoc_devclass

Definition at line 51 of file iicoc.c.