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

Go to the source code of this file.

Data Structures

struct  ad7418_softc
 

Macros

#define IIC_M_WR   0 /* write operation */
 
#define AD7418_ADDR   0x50 /* slave address */
 
#define AD7418_TEMP   0 /* Temperature Value (r/o) */
 
#define AD7418_CONF   1 /* Config Register (r/w) */
 
#define AD7418_CONF_SHUTDOWN   0x01
 
#define AD7418_CONF_CHAN   0xe0 /* channel select mask */
 
#define AD7418_CHAN_TEMP   0x00 /* temperature channel */
 
#define AD7418_CHAN_VOLT   0x80 /* voltage channel */
 
#define AD7418_THYST   2 /* Thyst Setpoint (r/o) */
 
#define AD7418_TOTI   3 /* Toti Setpoint */
 
#define AD7418_VOLT   4 /* ADC aka Voltage (r/o) */
 
#define AD7418_CONF2   5 /* Config2 Register (r/w) */
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void ad7418_update (struct ad7418_softc *)
 
static int ad7418_read_1 (device_t dev, int reg)
 
static int ad7418_write_1 (device_t dev, int reg, int v)
 
static int ad7418_probe (device_t dev)
 
static int ad7418_sysctl_temp (SYSCTL_HANDLER_ARGS)
 
static int ad7418_sysctl_voltage (SYSCTL_HANDLER_ARGS)
 
static int ad7418_attach (device_t dev)
 
static void ad7418_set_channel (struct ad7418_softc *sc, int chan)
 
static int ad7418_read_2 (device_t dev, int reg)
 
 DRIVER_MODULE (ad7418, iicbus, ad7418_driver, ad7418_devclass, 0, 0)
 
 MODULE_VERSION (ad7418, 1)
 
 MODULE_DEPEND (ad7418, iicbus, 1, 1, 1)
 

Variables

static device_method_t ad7418_methods []
 
static driver_t ad7418_driver
 
static devclass_t ad7418_devclass
 

Macro Definition Documentation

◆ AD7418_ADDR

#define AD7418_ADDR   0x50 /* slave address */

Definition at line 47 of file ad7418.c.

◆ AD7418_CHAN_TEMP

#define AD7418_CHAN_TEMP   0x00 /* temperature channel */

Definition at line 53 of file ad7418.c.

◆ AD7418_CHAN_VOLT

#define AD7418_CHAN_VOLT   0x80 /* voltage channel */

Definition at line 54 of file ad7418.c.

◆ AD7418_CONF

#define AD7418_CONF   1 /* Config Register (r/w) */

Definition at line 50 of file ad7418.c.

◆ AD7418_CONF2

#define AD7418_CONF2   5 /* Config2 Register (r/w) */

Definition at line 58 of file ad7418.c.

◆ AD7418_CONF_CHAN

#define AD7418_CONF_CHAN   0xe0 /* channel select mask */

Definition at line 52 of file ad7418.c.

◆ AD7418_CONF_SHUTDOWN

#define AD7418_CONF_SHUTDOWN   0x01

Definition at line 51 of file ad7418.c.

◆ AD7418_TEMP

#define AD7418_TEMP   0 /* Temperature Value (r/o) */

Definition at line 49 of file ad7418.c.

◆ AD7418_THYST

#define AD7418_THYST   2 /* Thyst Setpoint (r/o) */

Definition at line 55 of file ad7418.c.

◆ AD7418_TOTI

#define AD7418_TOTI   3 /* Toti Setpoint */

Definition at line 56 of file ad7418.c.

◆ AD7418_VOLT

#define AD7418_VOLT   4 /* ADC aka Voltage (r/o) */

Definition at line 57 of file ad7418.c.

◆ IIC_M_WR

#define IIC_M_WR   0 /* write operation */

Definition at line 45 of file ad7418.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ ad7418_attach()

static int ad7418_attach ( device_t  dev)
static

◆ ad7418_probe()

static int ad7418_probe ( device_t  dev)
static

Definition at line 74 of file ad7418.c.

References dev.

◆ ad7418_read_1()

static int ad7418_read_1 ( device_t  dev,
int  reg 
)
static

Definition at line 136 of file ad7418.c.

References AD7418_ADDR, addr, data, dev, IIC_M_RD, IIC_M_WR, iicbus_transfer(), and msgs.

Referenced by ad7418_attach(), and ad7418_set_channel().

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

◆ ad7418_read_2()

static int ad7418_read_2 ( device_t  dev,
int  reg 
)
static

Definition at line 180 of file ad7418.c.

References AD7418_ADDR, addr, data, dev, IIC_M_RD, IIC_M_WR, iicbus_transfer(), and msgs.

Referenced by ad7418_update().

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

◆ ad7418_set_channel()

static void ad7418_set_channel ( struct ad7418_softc sc,
int  chan 
)
static

Definition at line 161 of file ad7418.c.

References AD7418_CONF, AD7418_CONF_CHAN, ad7418_read_1(), ad7418_write_1(), ad7418_softc::sc_curchan, and ad7418_softc::sc_dev.

Referenced by ad7418_update().

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

◆ ad7418_sysctl_temp()

static int ad7418_sysctl_temp ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 82 of file ad7418.c.

References ad7418_update(), ad7418_softc::sc_curtemp, and ad7418_softc::sc_lock.

Referenced by ad7418_attach().

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

◆ ad7418_sysctl_voltage()

static int ad7418_sysctl_voltage ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 95 of file ad7418.c.

References ad7418_update(), ad7418_softc::sc_curvolt, and ad7418_softc::sc_lock.

Referenced by ad7418_attach().

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

◆ ad7418_update()

static void ad7418_update ( struct ad7418_softc sc)
static

Definition at line 194 of file ad7418.c.

References AD7418_CHAN_TEMP, AD7418_CHAN_VOLT, ad7418_read_2(), ad7418_set_channel(), AD7418_TEMP, AD7418_VOLT, ad7418_softc::sc_curtemp, ad7418_softc::sc_curvolt, ad7418_softc::sc_dev, ad7418_softc::sc_lastupdate, and ad7418_softc::sc_lock.

Referenced by ad7418_sysctl_temp(), and ad7418_sysctl_voltage().

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

◆ ad7418_write_1()

static int ad7418_write_1 ( device_t  dev,
int  reg,
int  v 
)
static

Definition at line 148 of file ad7418.c.

References AD7418_ADDR, data, dev, IIC_M_WR, iicbus_transfer(), and msgs.

Referenced by ad7418_attach(), and ad7418_set_channel().

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

◆ DRIVER_MODULE()

DRIVER_MODULE ( ad7418  ,
iicbus  ,
ad7418_driver  ,
ad7418_devclass  ,
,
 
)

◆ MODULE_DEPEND()

MODULE_DEPEND ( ad7418  ,
iicbus  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( ad7418  ,
 
)

Variable Documentation

◆ ad7418_devclass

devclass_t ad7418_devclass
static

Definition at line 225 of file ad7418.c.

◆ ad7418_driver

driver_t ad7418_driver
static
Initial value:
= {
"ad7418",
sizeof(struct ad7418_softc),
}
static device_method_t ad7418_methods[]
Definition: ad7418.c:213

Definition at line 220 of file ad7418.c.

◆ ad7418_methods

device_method_t ad7418_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ad7418_probe),
DEVMETHOD(device_attach, ad7418_attach),
DEVMETHOD_END
}
static int ad7418_attach(device_t dev)
Definition: ad7418.c:108
static int ad7418_probe(device_t dev)
Definition: ad7418.c:74

Definition at line 213 of file ad7418.c.