FreeBSD kernel IICBUS device code
ad7417.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/callout.h>
#include <sys/conf.h>
#include <sys/cpu.h>
#include <sys/ctype.h>
#include <sys/kernel.h>
#include <sys/reboot.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
#include <sys/limits.h>
#include <machine/bus.h>
#include <machine/md_var.h>
#include <dev/iicbus/iicbus.h>
#include <dev/iicbus/iiconf.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <powerpc/powermac/powermac_thermal.h>
Include dependency graph for ad7417.c:

Go to the source code of this file.

Data Structures

struct  ad7417_sensor
 
struct  write_data
 
struct  read_data
 
struct  ad7417_softc
 

Macros

#define AD7417_TEMP   0x00
 
#define AD7417_CONFIG   0x01
 
#define AD7417_ADC   0x04
 
#define AD7417_CONFIG2   0x05
 
#define AD7417_CONFMASK   0xe0
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int ad7417_probe (device_t)
 
static int ad7417_attach (device_t)
 
static int ad7417_sensor_sysctl (SYSCTL_HANDLER_ARGS)
 
static int ad7417_write (device_t dev, uint32_t addr, uint8_t reg, uint8_t *buf, int len)
 
static int ad7417_read_1 (device_t dev, uint32_t addr, uint8_t reg, uint8_t *data)
 
static int ad7417_read_2 (device_t dev, uint32_t addr, uint8_t reg, uint16_t *data)
 
static int ad7417_write_read (device_t dev, uint32_t addr, struct write_data out, struct read_data *in)
 
static int ad7417_diode_read (struct ad7417_sensor *sens)
 
static int ad7417_adc_read (struct ad7417_sensor *sens)
 
static int ad7417_sensor_read (struct ad7417_sensor *sens)
 
 DRIVER_MODULE (ad7417, iicbus, ad7417_driver, ad7417_devclass, 0, 0)
 
static MALLOC_DEFINE (M_AD7417, "ad7417", "Supply-Monitor AD7417")
 
static int ad7417_init_adc (device_t dev, uint32_t addr)
 
static int ad7417_fill_sensor_prop (device_t dev)
 
static int ad7417_get_temp (device_t dev, uint32_t addr, int *temp)
 
static int ad7417_get_adc (device_t dev, uint32_t addr, unsigned int *value, uint8_t chan)
 

Variables

uint8_t adc741x_config
 
static device_method_t ad7417_methods []
 
static driver_t ad7417_driver
 
static devclass_t ad7417_devclass
 

Macro Definition Documentation

◆ AD7417_ADC

#define AD7417_ADC   0x04

Definition at line 59 of file ad7417.c.

◆ AD7417_CONFIG

#define AD7417_CONFIG   0x01

Definition at line 58 of file ad7417.c.

◆ AD7417_CONFIG2

#define AD7417_CONFIG2   0x05

Definition at line 60 of file ad7417.c.

◆ AD7417_CONFMASK

#define AD7417_CONFMASK   0xe0

Definition at line 61 of file ad7417.c.

◆ AD7417_TEMP

#define AD7417_TEMP   0x00

Definition at line 57 of file ad7417.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ ad7417_adc_read()

static int ad7417_adc_read ( struct ad7417_sensor sens)
static

Definition at line 563 of file ad7417.c.

References ad7417_get_adc(), ad7417_sensor::dev, ad7417_sensor::id, ad7417_softc::sc_addr, and ad7417_softc::sc_dev.

Referenced by ad7417_diode_read(), and ad7417_sensor_read().

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

◆ ad7417_attach()

static int ad7417_attach ( device_t  dev)
static

◆ ad7417_diode_read()

static int ad7417_diode_read ( struct ad7417_sensor sens)
static

Definition at line 528 of file ad7417.c.

References ad7417_adc_read(), and ad7417_sensor::therm.

Referenced by ad7417_fill_sensor_prop().

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

◆ ad7417_fill_sensor_prop()

static int ad7417_fill_sensor_prop ( device_t  dev)
static

Definition at line 310 of file ad7417.c.

References ad7417_diode_read(), ad7417_sensor_read(), ad7417_sensor::dev, dev, ad7417_sensor::id, len, ad7417_softc::sc_sensors, ad7417_sensor::therm, and ad7417_sensor::type.

Referenced by ad7417_attach().

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

◆ ad7417_get_adc()

static int ad7417_get_adc ( device_t  dev,
uint32_t  addr,
unsigned int *  value,
uint8_t  chan 
)
static

Definition at line 501 of file ad7417.c.

References AD7417_ADC, AD7417_CONFIG, AD7417_CONFMASK, ad7417_read_1(), ad7417_write_read(), addr, data, dev, write_data::reg, and write_data::val.

Referenced by ad7417_adc_read().

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

◆ ad7417_get_temp()

static int ad7417_get_temp ( device_t  dev,
uint32_t  addr,
int *  temp 
)
static

Definition at line 480 of file ad7417.c.

References ad7417_read_2(), AD7417_TEMP, addr, buf, dev, and read.

Referenced by ad7417_sensor_read().

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

◆ ad7417_init_adc()

static int ad7417_init_adc ( device_t  dev,
uint32_t  addr 
)
static

Definition at line 248 of file ad7417.c.

References AD7417_CONFIG, AD7417_CONFIG2, ad7417_read_1(), ad7417_write(), adc741x_config, addr, buf, dev, and ad7417_softc::init_done.

Referenced by ad7417_sensor_read().

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

◆ ad7417_probe()

static int ad7417_probe ( device_t  dev)
static

Definition at line 281 of file ad7417.c.

References dev, ad7417_softc::sc_addr, and ad7417_softc::sc_dev.

◆ ad7417_read_1()

static int ad7417_read_1 ( device_t  dev,
uint32_t  addr,
uint8_t  reg,
uint8_t *  data 
)
static

Definition at line 157 of file ad7417.c.

References addr, buf, data, dev, IIC_M_NOSTOP, IIC_M_RD, IIC_M_WR, and iicbus_transfer().

Referenced by ad7417_get_adc(), and ad7417_init_adc().

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

◆ ad7417_read_2()

static int ad7417_read_2 ( device_t  dev,
uint32_t  addr,
uint8_t  reg,
uint16_t *  data 
)
static

Definition at line 185 of file ad7417.c.

References addr, buf, data, dev, IIC_M_NOSTOP, IIC_M_RD, IIC_M_WR, and iicbus_transfer().

Referenced by ad7417_get_temp().

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

◆ ad7417_sensor_read()

static int ad7417_sensor_read ( struct ad7417_sensor sens)
static

Definition at line 600 of file ad7417.c.

References ad7417_adc_read(), ad7417_get_temp(), ad7417_init_adc(), ad7417_sensor::dev, ad7417_softc::init_done, ad7417_softc::sc_addr, ad7417_softc::sc_dev, and ad7417_sensor::type.

Referenced by ad7417_fill_sensor_prop().

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

◆ ad7417_sensor_sysctl()

static int ad7417_sensor_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 623 of file ad7417.c.

References dev, ad7417_softc::sc_sensors, and ad7417_sensor::therm.

Referenced by ad7417_attach().

Here is the caller graph for this function:

◆ ad7417_write()

static int ad7417_write ( device_t  dev,
uint32_t  addr,
uint8_t  reg,
uint8_t *  buf,
int  len 
)
static

Definition at line 130 of file ad7417.c.

References addr, buf, dev, IIC_M_WR, iicbus_transfer(), iic_msg::len, and len.

Referenced by ad7417_init_adc().

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

◆ ad7417_write_read()

static int ad7417_write_read ( device_t  dev,
uint32_t  addr,
struct write_data  out,
struct read_data in 
)
static

Definition at line 213 of file ad7417.c.

References addr, buf, dev, IIC_M_NOSTOP, IIC_M_RD, IIC_M_WR, iicbus_transfer(), write_data::reg, read_data::reg, write_data::val, and read_data::val.

Referenced by ad7417_get_adc().

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

◆ DRIVER_MODULE()

DRIVER_MODULE ( ad7417  ,
iicbus  ,
ad7417_driver  ,
ad7417_devclass  ,
,
 
)

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_AD7417  ,
"ad7417"  ,
"Supply-Monitor AD7417"   
)
static

Variable Documentation

◆ ad7417_devclass

devclass_t ad7417_devclass
static

Definition at line 123 of file ad7417.c.

◆ ad7417_driver

driver_t ad7417_driver
static
Initial value:
= {
"ad7417",
sizeof(struct ad7417_softc)
}
static device_method_t ad7417_methods[]
Definition: ad7417.c:110

Definition at line 117 of file ad7417.c.

◆ ad7417_methods

device_method_t ad7417_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ad7417_probe),
DEVMETHOD(device_attach, ad7417_attach),
{ 0, 0 },
}
static int ad7417_probe(device_t)
Definition: ad7417.c:281
static int ad7417_attach(device_t)
Definition: ad7417.c:404

Definition at line 110 of file ad7417.c.

◆ adc741x_config

uint8_t adc741x_config

Definition at line 63 of file ad7417.c.

Referenced by ad7417_init_adc().