FreeBSD kernel IICBUS device code
iic.c File Reference
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/lock.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/sx.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <sys/errno.h>
#include <dev/iicbus/iiconf.h>
#include <dev/iicbus/iicbus.h>
#include <dev/iicbus/iic.h>
#include "iicbus_if.h"
Include dependency graph for iic.c:

Go to the source code of this file.

Data Structures

struct  iic_softc
 
struct  iic_cdevpriv
 

Macros

#define IIC_LOCK(cdp)   sx_xlock(&(cdp)->lock)
 
#define IIC_UNLOCK(cdp)   sx_xunlock(&(cdp)->lock)
 

Functions

static MALLOC_DEFINE (M_IIC, "iic", "I2C device data")
 
static int iic_probe (device_t)
 
static int iic_attach (device_t)
 
static int iic_detach (device_t)
 
static void iic_identify (driver_t *driver, device_t parent)
 
static void iicdtor (void *data)
 
static int iicuio_move (struct iic_cdevpriv *priv, struct uio *uio, int last)
 
static int iicuio (struct cdev *dev, struct uio *uio, int ioflag)
 
static int iicrdwr (struct iic_cdevpriv *priv, struct iic_rdwr_data *d, int flags)
 
static int iicopen (struct cdev *dev, int flags, int fmt, struct thread *td)
 
static int iicioctl (struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td)
 
 DRIVER_MODULE (iic, iicbus, iic_driver, iic_devclass, 0, 0)
 
 MODULE_DEPEND (iic, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER)
 
 MODULE_VERSION (iic, 1)
 

Variables

static devclass_t iic_devclass
 
static device_method_t iic_methods []
 
static driver_t iic_driver
 
static d_open_t iicopen
 
static d_ioctl_t iicioctl
 
static struct cdevsw iic_cdevsw
 

Macro Definition Documentation

◆ IIC_LOCK

#define IIC_LOCK (   cdp)    sx_xlock(&(cdp)->lock)

Definition at line 63 of file iic.c.

◆ IIC_UNLOCK

#define IIC_UNLOCK (   cdp)    sx_xunlock(&(cdp)->lock)

Definition at line 64 of file iic.c.

Function Documentation

◆ DRIVER_MODULE()

DRIVER_MODULE ( iic  ,
iicbus  ,
iic_driver  ,
iic_devclass  ,
,
 
)

◆ iic_attach()

static int iic_attach ( device_t  dev)
static

Definition at line 130 of file iic.c.

References dev, iic_cdevsw, iic_softc::sc_dev, and iic_softc::sc_devnode.

◆ iic_detach()

static int iic_detach ( device_t  dev)
static

Definition at line 149 of file iic.c.

References dev, and iic_softc::sc_devnode.

◆ iic_identify()

static void iic_identify ( driver_t *  driver,
device_t  parent 
)
static

Definition at line 111 of file iic.c.

◆ iic_probe()

static int iic_probe ( device_t  dev)
static

Definition at line 119 of file iic.c.

References dev.

◆ iicdtor()

static void iicdtor ( void *  data)
static

Definition at line 180 of file iic.c.

References data, IIC_UNKNOWN, iicbus_release_bus(), iicbus_reset, iicbus_stop(), iic_cdevpriv::lock, iic_cdevpriv::sc, iic_softc::sc_dev, and iic_cdevpriv::started.

Referenced by iicopen().

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

◆ iicioctl()

static int iicioctl ( struct cdev *  dev,
u_long  cmd,
caddr_t  data,
int  flags,
struct thread *  td 
)
static

◆ iicopen()

static int iicopen ( struct cdev *  dev,
int  flags,
int  fmt,
struct thread *  td 
)
static

Definition at line 162 of file iic.c.

References dev, iicdtor(), iic_cdevpriv::lock, and iic_cdevpriv::sc.

Here is the call graph for this function:

◆ iicrdwr()

static int iicrdwr ( struct iic_cdevpriv priv,
struct iic_rdwr_data d,
int  flags 
)
static

Definition at line 293 of file iic.c.

References iic_msg::buf, buf, iic_msg::flags, IIC_DONTWAIT, IIC_INTR, IIC_M_RD, IIC_RDRW_MAX_MSGS, IIC_WAIT, iicbus_release_bus(), iicbus_request_bus(), iicbus_transfer(), iic_msg::len, iic_rdwr_data::msgs, iic_rdwr_data::nmsgs, iic_cdevpriv::sc, and iic_softc::sc_dev.

Referenced by iicioctl().

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

◆ iicuio()

static int iicuio ( struct cdev *  dev,
struct uio *  uio,
int  ioflag 
)
static

◆ iicuio_move()

static int iicuio_move ( struct iic_cdevpriv priv,
struct uio *  uio,
int  last 
)
static

Definition at line 202 of file iic.c.

References iicbus_read(), iicbus_write(), last, iic_cdevpriv::sc, and iic_softc::sc_dev.

Referenced by iicioctl(), and iicuio().

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

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_IIC  ,
"iic"  ,
"I2C device data  
)
static

◆ MODULE_DEPEND()

MODULE_DEPEND ( iic  ,
iicbus  ,
IICBUS_MINVER  ,
IICBUS_PREFVER  ,
IICBUS_MAXVER   
)

◆ MODULE_VERSION()

MODULE_VERSION ( iic  ,
 
)

Variable Documentation

◆ iic_cdevsw

struct cdevsw iic_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_open = iicopen,
.d_read = iicuio,
.d_write = iicuio,
.d_ioctl = iicioctl,
.d_name = "iic",
}
static int iicuio(struct cdev *dev, struct uio *uio, int ioflag)
Definition: iic.c:243
static d_open_t iicopen
Definition: iic.c:98
static d_ioctl_t iicioctl
Definition: iic.c:99

Definition at line 101 of file iic.c.

Referenced by iic_attach().

◆ iic_devclass

devclass_t iic_devclass
static

Definition at line 77 of file iic.c.

◆ iic_driver

driver_t iic_driver
static
Initial value:
= {
"iic",
sizeof(struct iic_softc),
}
static device_method_t iic_methods[]
Definition: iic.c:79
Definition: iic.c:50

Definition at line 92 of file iic.c.

◆ iic_methods

device_method_t iic_methods[]
static
Initial value:
= {
DEVMETHOD(device_identify, iic_identify),
DEVMETHOD(device_probe, iic_probe),
DEVMETHOD(device_attach, iic_attach),
DEVMETHOD(device_detach, iic_detach),
{ 0, 0 }
}
static int iic_attach(device_t)
Definition: iic.c:130
static int iic_probe(device_t)
Definition: iic.c:119
static void iic_identify(driver_t *driver, device_t parent)
Definition: iic.c:111
static int iic_detach(device_t)
Definition: iic.c:149
int iicbus_generic_intr(device_t dev, int event, char *buf)
Definition: iicbus.c:280
void iicbus_intr(device_t bus, int event, char *buf)
Definition: iiconf.c:97

Definition at line 79 of file iic.c.

◆ iicioctl

d_ioctl_t iicioctl
static

Definition at line 99 of file iic.c.

◆ iicopen

d_open_t iicopen
static

Definition at line 98 of file iic.c.