FreeBSD kernel IICBUS device code
lm75.c File Reference
#include <sys/cdefs.h>
#include "opt_platform.h"
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/endian.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <dev/iicbus/iicbus.h>
#include <dev/iicbus/iiconf.h>
Include dependency graph for lm75.c:

Go to the source code of this file.

Data Structures

struct  lm75_softc
 

Macros

#define LM75_TEMP   0x0
 
#define LM75_TEMP_MASK   0xff80
 
#define LM75A_TEMP_MASK   0xffe0
 
#define LM75_CONF   0x1
 
#define LM75_CONF_FSHIFT   3
 
#define LM75_CONF_FAULT   0x18
 
#define LM75_CONF_POL   0x04
 
#define LM75_CONF_MODE   0x02
 
#define LM75_CONF_SHUTD   0x01
 
#define LM75_CONF_MASK   0x1f
 
#define LM75_THYST   0x2
 
#define LM75_TOS   0x3
 
#define LM75_TEST_PATTERN   0xa
 
#define LM75_MIN_TEMP   -55
 
#define LM75_MAX_TEMP   125
 
#define LM75_0500C   0x80
 
#define LM75_0250C   0x40
 
#define LM75_0125C   0x20
 
#define LM75_MSB   0x8000
 
#define LM75_NEG_BIT   LM75_MSB
 
#define TZ_ZEROC   2731
 
#define HWTYPE_LM75   1
 
#define HWTYPE_LM75A   2
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int lm75_probe (device_t)
 
static int lm75_attach (device_t)
 
static int lm75_conf_read (struct lm75_softc *)
 
static int lm75_conf_write (struct lm75_softc *)
 
static int lm75_temp_read (struct lm75_softc *, uint8_t, int *)
 
static int lm75_temp_write (struct lm75_softc *, uint8_t, int)
 
static void lm75_start (void *)
 
static int lm75_read (device_t, uint32_t, uint8_t, uint8_t *, size_t)
 
static int lm75_write (device_t, uint32_t, uint8_t *, size_t)
 
static int lm75_str_mode (char *)
 
static int lm75_str_pol (char *)
 
static int lm75_temp_sysctl (SYSCTL_HANDLER_ARGS)
 
static int lm75_faults_sysctl (SYSCTL_HANDLER_ARGS)
 
static int lm75_mode_sysctl (SYSCTL_HANDLER_ARGS)
 
static int lm75_pol_sysctl (SYSCTL_HANDLER_ARGS)
 
static int lm75_shutdown_sysctl (SYSCTL_HANDLER_ARGS)
 
 DRIVER_MODULE (lm75, iicbus, lm75_driver, lm75_devclass, 0, 0)
 
static int lm75_type_detect (struct lm75_softc *sc)
 

Variables

static device_method_t lm75_methods []
 
static driver_t lm75_driver
 
static devclass_t lm75_devclass
 

Macro Definition Documentation

◆ HWTYPE_LM75

#define HWTYPE_LM75   1

Definition at line 78 of file lm75.c.

◆ HWTYPE_LM75A

#define HWTYPE_LM75A   2

Definition at line 79 of file lm75.c.

◆ LM75_0125C

#define LM75_0125C   0x20

Definition at line 72 of file lm75.c.

◆ LM75_0250C

#define LM75_0250C   0x40

Definition at line 71 of file lm75.c.

◆ LM75_0500C

#define LM75_0500C   0x80

Definition at line 70 of file lm75.c.

◆ LM75_CONF

#define LM75_CONF   0x1

Definition at line 56 of file lm75.c.

◆ LM75_CONF_FAULT

#define LM75_CONF_FAULT   0x18

Definition at line 58 of file lm75.c.

◆ LM75_CONF_FSHIFT

#define LM75_CONF_FSHIFT   3

Definition at line 57 of file lm75.c.

◆ LM75_CONF_MASK

#define LM75_CONF_MASK   0x1f

Definition at line 62 of file lm75.c.

◆ LM75_CONF_MODE

#define LM75_CONF_MODE   0x02

Definition at line 60 of file lm75.c.

◆ LM75_CONF_POL

#define LM75_CONF_POL   0x04

Definition at line 59 of file lm75.c.

◆ LM75_CONF_SHUTD

#define LM75_CONF_SHUTD   0x01

Definition at line 61 of file lm75.c.

◆ LM75_MAX_TEMP

#define LM75_MAX_TEMP   125

Definition at line 69 of file lm75.c.

◆ LM75_MIN_TEMP

#define LM75_MIN_TEMP   -55

Definition at line 68 of file lm75.c.

◆ LM75_MSB

#define LM75_MSB   0x8000

Definition at line 73 of file lm75.c.

◆ LM75_NEG_BIT

#define LM75_NEG_BIT   LM75_MSB

Definition at line 74 of file lm75.c.

◆ LM75_TEMP

#define LM75_TEMP   0x0

Definition at line 53 of file lm75.c.

◆ LM75_TEMP_MASK

#define LM75_TEMP_MASK   0xff80

Definition at line 54 of file lm75.c.

◆ LM75_TEST_PATTERN

#define LM75_TEST_PATTERN   0xa

Definition at line 67 of file lm75.c.

◆ LM75_THYST

#define LM75_THYST   0x2

Definition at line 63 of file lm75.c.

◆ LM75_TOS

#define LM75_TOS   0x3

Definition at line 64 of file lm75.c.

◆ LM75A_TEMP_MASK

#define LM75A_TEMP_MASK   0xffe0

Definition at line 55 of file lm75.c.

◆ TZ_ZEROC

#define TZ_ZEROC   2731

Definition at line 75 of file lm75.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( lm75  ,
iicbus  ,
lm75_driver  ,
lm75_devclass  ,
,
 
)

◆ lm75_attach()

static int lm75_attach ( device_t  dev)
static

Definition at line 171 of file lm75.c.

References dev, lm75_softc::enum_hook, lm75_start(), lm75_softc::sc_addr, and lm75_softc::sc_dev.

Here is the call graph for this function:

◆ lm75_conf_read()

static int lm75_conf_read ( struct lm75_softc sc)
static

Definition at line 304 of file lm75.c.

References LM75_CONF, lm75_read(), lm75_softc::sc_addr, lm75_softc::sc_conf, and lm75_softc::sc_dev.

Referenced by lm75_type_detect().

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

◆ lm75_conf_write()

static int lm75_conf_write ( struct lm75_softc sc)
static

Definition at line 317 of file lm75.c.

References LM75_CONF, LM75_CONF_MASK, lm75_write(), lm75_softc::sc_addr, lm75_softc::sc_conf, and lm75_softc::sc_dev.

Referenced by lm75_faults_sysctl(), lm75_mode_sysctl(), lm75_pol_sysctl(), lm75_shutdown_sysctl(), and lm75_type_detect().

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

◆ lm75_faults_sysctl()

static int lm75_faults_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 455 of file lm75.c.

References dev, LM75_CONF_FAULT, LM75_CONF_FSHIFT, lm75_conf_write(), and lm75_softc::sc_conf.

Referenced by lm75_start().

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

◆ lm75_mode_sysctl()

static int lm75_mode_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 488 of file lm75.c.

References buf, dev, LM75_CONF_MODE, lm75_conf_write(), lm75_str_mode(), and lm75_softc::sc_conf.

Referenced by lm75_start().

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

◆ lm75_pol_sysctl()

static int lm75_pol_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 522 of file lm75.c.

References buf, dev, LM75_CONF_POL, lm75_conf_write(), lm75_str_pol(), and lm75_softc::sc_conf.

Referenced by lm75_start().

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

◆ lm75_probe()

static int lm75_probe ( device_t  dev)
static

Definition at line 155 of file lm75.c.

References dev, HWTYPE_LM75, and lm75_softc::sc_hwtype.

◆ lm75_read()

static int lm75_read ( device_t  dev,
uint32_t  addr,
uint8_t  reg,
uint8_t *  data,
size_t  len 
)
static

Definition at line 128 of file lm75.c.

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

Referenced by lm75_conf_read(), lm75_temp_read(), and lm75_type_detect().

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

◆ lm75_shutdown_sysctl()

static int lm75_shutdown_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 556 of file lm75.c.

References dev, LM75_CONF_SHUTD, lm75_conf_write(), and lm75_softc::sc_conf.

Referenced by lm75_start().

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

◆ lm75_start()

static void lm75_start ( void *  xdev)
static

Definition at line 249 of file lm75.c.

References dev, lm75_softc::enum_hook, HWTYPE_LM75A, lm75_faults_sysctl(), lm75_mode_sysctl(), lm75_pol_sysctl(), lm75_shutdown_sysctl(), LM75_TEMP, lm75_temp_sysctl(), LM75_THYST, LM75_TOS, lm75_type_detect(), and lm75_softc::sc_hwtype.

Referenced by lm75_attach().

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

◆ lm75_str_mode()

static int lm75_str_mode ( char *  buf)
static

Definition at line 396 of file lm75.c.

References buf, and len.

Referenced by lm75_mode_sysctl().

Here is the caller graph for this function:

◆ lm75_str_pol()

static int lm75_str_pol ( char *  buf)
static

Definition at line 411 of file lm75.c.

References buf, and len.

Referenced by lm75_pol_sysctl().

Here is the caller graph for this function:

◆ lm75_temp_read()

static int lm75_temp_read ( struct lm75_softc sc,
uint8_t  reg,
int *  temp 
)
static

Definition at line 330 of file lm75.c.

References buf, HWTYPE_LM75A, LM75_0125C, LM75_0250C, LM75_0500C, LM75_NEG_BIT, lm75_read(), LM75_TEMP_MASK, LM75A_TEMP_MASK, lm75_softc::sc_addr, lm75_softc::sc_dev, lm75_softc::sc_hwtype, and TZ_ZEROC.

Referenced by lm75_temp_sysctl().

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

◆ lm75_temp_sysctl()

static int lm75_temp_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 430 of file lm75.c.

References dev, lm75_temp_read(), and lm75_temp_write().

Referenced by lm75_start().

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

◆ lm75_temp_write()

static int lm75_temp_write ( struct lm75_softc sc,
uint8_t  reg,
int  temp 
)
static

Definition at line 372 of file lm75.c.

References buf, LM75_MAX_TEMP, LM75_MIN_TEMP, lm75_write(), lm75_softc::sc_addr, lm75_softc::sc_dev, and TZ_ZEROC.

Referenced by lm75_temp_sysctl().

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

◆ lm75_type_detect()

static int lm75_type_detect ( struct lm75_softc sc)
static

Definition at line 193 of file lm75.c.

References HWTYPE_LM75A, lm75_conf_read(), lm75_conf_write(), lm75_read(), LM75_TEST_PATTERN, lm75_softc::sc_addr, lm75_softc::sc_conf, lm75_softc::sc_dev, and lm75_softc::sc_hwtype.

Referenced by lm75_start().

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

◆ lm75_write()

static int lm75_write ( device_t  dev,
uint32_t  addr,
uint8_t *  data,
size_t  len 
)
static

Definition at line 142 of file lm75.c.

References addr, data, dev, IIC_M_WR, iicbus_transfer(), and len.

Referenced by lm75_conf_write(), and lm75_temp_write().

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

Variable Documentation

◆ lm75_devclass

devclass_t lm75_devclass
static

Definition at line 123 of file lm75.c.

◆ lm75_driver

driver_t lm75_driver
static
Initial value:
= {
"lm75",
sizeof(struct lm75_softc)
}
static device_method_t lm75_methods[]
Definition: lm75.c:109

Definition at line 117 of file lm75.c.

◆ lm75_methods

device_method_t lm75_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, lm75_probe),
DEVMETHOD(device_attach, lm75_attach),
DEVMETHOD_END
}
static int lm75_attach(device_t)
Definition: lm75.c:171
static int lm75_probe(device_t)
Definition: lm75.c:155

Definition at line 109 of file lm75.c.