FreeBSD kernel IICBUS device code
adt746x.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 adt746x.c:

Go to the source code of this file.

Data Structures

struct  adt746x_fan
 
struct  adt746x_sensor
 
struct  adt746x_softc
 

Macros

#define ADT746X_TACH1LOW   0x28
 
#define ADT746X_TACH1HIGH   0x29
 
#define ADT746X_TACH2LOW   0x2a
 
#define ADT746X_TACH2HIGH   0x2b
 
#define ADT746X_PWM1   0x30
 
#define ADT746X_PWM2   0x31
 
#define ADT746X_DEVICE_ID   0x3d
 
#define ADT746X_COMPANY_ID   0x3e
 
#define ADT746X_REV_ID   0x3f
 
#define ADT746X_CONFIG   0x40
 
#define ADT746X_PWM1_CONF   0x5c
 
#define ADT746X_PWM2_CONF   0x5d
 
#define ADT746X_MANUAL_MASK   0xe0
 
#define ADT7460_DEV_ID   0x27
 
#define ADT7467_DEV_ID   0x68
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int adt746x_probe (device_t)
 
static int adt746x_attach (device_t)
 
static void adt746x_attach_fans (device_t dev)
 
static void adt746x_attach_sensors (device_t dev)
 
static int adt746x_fill_fan_prop (device_t dev)
 
static int adt746x_fill_sensor_prop (device_t dev)
 
static int adt746x_fan_set_pwm (struct adt746x_fan *fan, int pwm)
 
static int adt746x_fan_get_pwm (struct adt746x_fan *fan)
 
static int adt746x_sensor_read (struct adt746x_sensor *sens)
 
static void adt746x_start (void *xdev)
 
static int adt746x_write (device_t dev, uint32_t addr, uint8_t reg, uint8_t *buf)
 
static int adt746x_read (device_t dev, uint32_t addr, uint8_t reg, uint8_t *data)
 
 DRIVER_MODULE (adt746x, iicbus, adt746x_driver, adt746x_devclass, 0, 0)
 
static MALLOC_DEFINE (M_ADT746X, "adt746x", "ADT Sensor Information")
 
static int adt746x_fanrpm_sysctl (SYSCTL_HANDLER_ARGS)
 
static int adt746x_sensor_sysctl (SYSCTL_HANDLER_ARGS)
 

Variables

static device_method_t adt746x_methods []
 
static driver_t adt746x_driver
 
static devclass_t adt746x_devclass
 

Macro Definition Documentation

◆ ADT7460_DEV_ID

#define ADT7460_DEV_ID   0x27

Definition at line 72 of file adt746x.c.

◆ ADT7467_DEV_ID

#define ADT7467_DEV_ID   0x68

Definition at line 73 of file adt746x.c.

◆ ADT746X_COMPANY_ID

#define ADT746X_COMPANY_ID   0x3e

Definition at line 65 of file adt746x.c.

◆ ADT746X_CONFIG

#define ADT746X_CONFIG   0x40

Definition at line 67 of file adt746x.c.

◆ ADT746X_DEVICE_ID

#define ADT746X_DEVICE_ID   0x3d

Definition at line 64 of file adt746x.c.

◆ ADT746X_MANUAL_MASK

#define ADT746X_MANUAL_MASK   0xe0

Definition at line 70 of file adt746x.c.

◆ ADT746X_PWM1

#define ADT746X_PWM1   0x30

Definition at line 62 of file adt746x.c.

◆ ADT746X_PWM1_CONF

#define ADT746X_PWM1_CONF   0x5c

Definition at line 68 of file adt746x.c.

◆ ADT746X_PWM2

#define ADT746X_PWM2   0x31

Definition at line 63 of file adt746x.c.

◆ ADT746X_PWM2_CONF

#define ADT746X_PWM2_CONF   0x5d

Definition at line 69 of file adt746x.c.

◆ ADT746X_REV_ID

#define ADT746X_REV_ID   0x3f

Definition at line 66 of file adt746x.c.

◆ ADT746X_TACH1HIGH

#define ADT746X_TACH1HIGH   0x29

Definition at line 59 of file adt746x.c.

◆ ADT746X_TACH1LOW

#define ADT746X_TACH1LOW   0x28

Definition at line 58 of file adt746x.c.

◆ ADT746X_TACH2HIGH

#define ADT746X_TACH2HIGH   0x2b

Definition at line 61 of file adt746x.c.

◆ ADT746X_TACH2LOW

#define ADT746X_TACH2LOW   0x2a

Definition at line 60 of file adt746x.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ adt746x_attach()

static int adt746x_attach ( device_t  dev)
static

Definition at line 236 of file adt746x.c.

References adt746x_start(), dev, and adt746x_softc::enum_hook.

Here is the call graph for this function:

◆ adt746x_attach_fans()

static void adt746x_attach_fans ( device_t  dev)
static

Definition at line 470 of file adt746x.c.

References adt746x_fan_get_pwm(), adt746x_fanrpm_sysctl(), adt746x_fill_fan_prop(), dev, adt746x_fan::fan, adt746x_fan::id, adt746x_softc::sc_fans, adt746x_softc::sc_nfans, and adt746x_fan::setpoint.

Referenced by adt746x_start().

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

◆ adt746x_attach_sensors()

static void adt746x_attach_sensors ( device_t  dev)
static

Definition at line 598 of file adt746x.c.

References adt746x_fill_sensor_prop(), adt746x_sensor_sysctl(), dev, adt746x_sensor::id, adt746x_sensor::reg, adt746x_softc::sc_nsensors, adt746x_softc::sc_sensors, adt746x_sensor::therm, and adt746x_sensor::type.

Referenced by adt746x_start().

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

◆ adt746x_fan_get_pwm()

static int adt746x_fan_get_pwm ( struct adt746x_fan fan)
static

Definition at line 333 of file adt746x.c.

References adt746x_read(), buf, adt746x_fan::dev, adt746x_fan::pwm_reg, adt746x_softc::sc_addr, and adt746x_softc::sc_dev.

Referenced by adt746x_attach_fans(), and adt746x_fanrpm_sysctl().

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

◆ adt746x_fan_set_pwm()

static int adt746x_fan_set_pwm ( struct adt746x_fan fan,
int  pwm 
)
static

Definition at line 299 of file adt746x.c.

References ADT746X_MANUAL_MASK, adt746x_read(), adt746x_write(), buf, adt746x_fan::conf_reg, adt746x_fan::dev, adt746x_fan::fan, adt746x_fan::pwm_reg, adt746x_softc::sc_addr, adt746x_softc::sc_dev, and adt746x_fan::setpoint.

Referenced by adt746x_fanrpm_sysctl(), and adt746x_fill_fan_prop().

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

◆ adt746x_fanrpm_sysctl()

static int adt746x_fanrpm_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 450 of file adt746x.c.

References adt746x_fan_get_pwm(), adt746x_fan_set_pwm(), adt746x_fan::fan, and adt746x_softc::sc_fans.

Referenced by adt746x_attach_fans().

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

◆ adt746x_fill_fan_prop()

static int adt746x_fill_fan_prop ( device_t  dev)
static

Definition at line 350 of file adt746x.c.

References adt746x_fan_set_pwm(), ADT746X_PWM1, ADT746X_PWM1_CONF, ADT746X_PWM2, ADT746X_PWM2_CONF, adt746x_fan::conf_reg, adt746x_fan::dev, dev, adt746x_fan::fan, adt746x_fan::id, len, adt746x_fan::pwm_reg, adt746x_softc::sc_dev, and adt746x_softc::sc_fans.

Referenced by adt746x_attach_fans().

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

◆ adt746x_fill_sensor_prop()

static int adt746x_fill_sensor_prop ( device_t  dev)
static

Definition at line 402 of file adt746x.c.

References adt746x_sensor_read(), adt746x_sensor::dev, dev, adt746x_sensor::id, adt746x_sensor::reg, adt746x_softc::sc_sensors, adt746x_sensor::therm, and adt746x_sensor::type.

Referenced by adt746x_attach_sensors().

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

◆ adt746x_probe()

static int adt746x_probe ( device_t  dev)
static

Definition at line 210 of file adt746x.c.

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

◆ adt746x_read()

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

Definition at line 182 of file adt746x.c.

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

Referenced by adt746x_fan_get_pwm(), adt746x_fan_set_pwm(), adt746x_sensor_read(), and adt746x_start().

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

◆ adt746x_sensor_read()

static int adt746x_sensor_read ( struct adt746x_sensor sens)
static

Definition at line 542 of file adt746x.c.

References adt746x_read(), data, adt746x_sensor::dev, adt746x_sensor::reg, adt746x_softc::sc_addr, adt746x_softc::sc_dev, adt746x_sensor::type, and val.

Referenced by adt746x_fill_sensor_prop().

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

◆ adt746x_sensor_sysctl()

static int adt746x_sensor_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 577 of file adt746x.c.

References dev, adt746x_softc::sc_sensors, and adt746x_sensor::therm.

Referenced by adt746x_attach_sensors().

Here is the caller graph for this function:

◆ adt746x_start()

static void adt746x_start ( void *  xdev)
static

◆ adt746x_write()

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

Definition at line 155 of file adt746x.c.

References addr, buf, dev, IIC_M_WR, and iicbus_transfer().

Referenced by adt746x_fan_set_pwm(), and adt746x_start().

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

◆ DRIVER_MODULE()

DRIVER_MODULE ( adt746x  ,
iicbus  ,
adt746x_driver  ,
adt746x_devclass  ,
,
 
)

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_ADT746X  ,
"adt746x"  ,
"ADT Sensor Information"   
)
static

Variable Documentation

◆ adt746x_devclass

devclass_t adt746x_devclass
static

Definition at line 146 of file adt746x.c.

◆ adt746x_driver

driver_t adt746x_driver
static
Initial value:
= {
"adt746x",
sizeof(struct adt746x_softc)
}
static device_method_t adt746x_methods[]
Definition: adt746x.c:133

Definition at line 140 of file adt746x.c.

◆ adt746x_methods

device_method_t adt746x_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, adt746x_probe),
DEVMETHOD(device_attach, adt746x_attach),
{ 0, 0 },
}
static int adt746x_attach(device_t)
Definition: adt746x.c:236
static int adt746x_probe(device_t)
Definition: adt746x.c:210

Definition at line 133 of file adt746x.c.