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

Go to the source code of this file.

Data Structures

struct  ds1631_softc
 
struct  write_data
 
struct  read_data
 

Macros

#define DS1631_STOP   0x22
 
#define DS1631_START   0x51
 
#define DS1631_RESET   0x54
 
#define DS1631_TEMP   0xAA
 
#define DS1631_CONTROL   0xAC
 
#define DS1631_CONTROL_1SHOT   0x01
 
#define DS1631_CONTROL_9BIT   0x00
 
#define DS1631_CONTROL_10BIT   0x04
 
#define DS1631_CONTROL_11BIT   0x08
 
#define DS1631_CONTROL_12BIT   0x0C
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int ds1631_probe (device_t)
 
static int ds1631_attach (device_t)
 
static int ds1631_sensor_read (struct ds1631_softc *sc)
 
static int ds1631_sensor_sysctl (SYSCTL_HANDLER_ARGS)
 
static void ds1631_start (void *xdev)
 
static int ds1631_read_1 (device_t dev, uint32_t addr, uint8_t reg, uint8_t *data)
 
static int ds1631_read_2 (device_t dev, uint32_t addr, uint8_t reg, uint16_t *data)
 
static int ds1631_write (device_t dev, uint32_t addr, uint8_t reg, uint8_t *buff, int len)
 
 DRIVER_MODULE (ds1631, iicbus, ds1631_driver, ds1631_devclass, 0, 0)
 
static int ds1631_init (device_t dev, uint32_t addr)
 

Variables

static device_method_t ds1631_methods []
 
static driver_t ds1631_driver
 
static devclass_t ds1631_devclass
 

Macro Definition Documentation

◆ DS1631_CONTROL

#define DS1631_CONTROL   0xAC

Definition at line 61 of file ds1631.c.

◆ DS1631_CONTROL_10BIT

#define DS1631_CONTROL_10BIT   0x04

Definition at line 64 of file ds1631.c.

◆ DS1631_CONTROL_11BIT

#define DS1631_CONTROL_11BIT   0x08

Definition at line 65 of file ds1631.c.

◆ DS1631_CONTROL_12BIT

#define DS1631_CONTROL_12BIT   0x0C

Definition at line 66 of file ds1631.c.

◆ DS1631_CONTROL_1SHOT

#define DS1631_CONTROL_1SHOT   0x01

Definition at line 62 of file ds1631.c.

◆ DS1631_CONTROL_9BIT

#define DS1631_CONTROL_9BIT   0x00

Definition at line 63 of file ds1631.c.

◆ DS1631_RESET

#define DS1631_RESET   0x54

Definition at line 59 of file ds1631.c.

◆ DS1631_START

#define DS1631_START   0x51

Definition at line 58 of file ds1631.c.

◆ DS1631_STOP

#define DS1631_STOP   0x22

Definition at line 57 of file ds1631.c.

◆ DS1631_TEMP

#define DS1631_TEMP   0xAA

Definition at line 60 of file ds1631.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( ds1631  ,
iicbus  ,
ds1631_driver  ,
ds1631_devclass  ,
,
 
)

◆ ds1631_attach()

static int ds1631_attach ( device_t  dev)
static

Definition at line 229 of file ds1631.c.

References dev, ds1631_start(), and ds1631_softc::enum_hook.

Here is the call graph for this function:

◆ ds1631_init()

static int ds1631_init ( device_t  dev,
uint32_t  addr 
)
static

Definition at line 253 of file ds1631.c.

References addr, dev, DS1631_CONTROL, DS1631_CONTROL_10BIT, DS1631_CONTROL_1SHOT, ds1631_read_1(), DS1631_START, DS1631_STOP, ds1631_write(), and ds1631_softc::init_done.

Referenced by ds1631_sensor_read().

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

◆ ds1631_probe()

static int ds1631_probe ( device_t  dev)
static

Definition at line 204 of file ds1631.c.

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

◆ ds1631_read_1()

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

Definition at line 148 of file ds1631.c.

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

Referenced by ds1631_init().

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

◆ ds1631_read_2()

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

Definition at line 176 of file ds1631.c.

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

Referenced by ds1631_sensor_read().

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

◆ ds1631_sensor_read()

static int ds1631_sensor_read ( struct ds1631_softc sc)
static

Definition at line 370 of file ds1631.c.

References buf, ds1631_init(), ds1631_read_2(), DS1631_TEMP, ds1631_softc::init_done, read, ds1631_softc::sc_addr, and ds1631_softc::sc_dev.

Referenced by ds1631_sensor_sysctl(), and ds1631_start().

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

◆ ds1631_sensor_sysctl()

static int ds1631_sensor_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 397 of file ds1631.c.

References dev, and ds1631_sensor_read().

Referenced by ds1631_start().

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

◆ ds1631_start()

static void ds1631_start ( void *  xdev)
static

Definition at line 297 of file ds1631.c.

References dev, ds1631_sensor_read(), ds1631_sensor_sysctl(), ds1631_softc::enum_hook, and ds1631_softc::sc_sensor.

Referenced by ds1631_attach().

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

◆ ds1631_write()

static int ds1631_write ( device_t  dev,
uint32_t  addr,
uint8_t  reg,
uint8_t *  buff,
int  len 
)
static

Definition at line 121 of file ds1631.c.

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

Referenced by ds1631_init().

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

Variable Documentation

◆ ds1631_devclass

devclass_t ds1631_devclass
static

Definition at line 116 of file ds1631.c.

◆ ds1631_driver

driver_t ds1631_driver
static
Initial value:
= {
"ds1631",
sizeof(struct ds1631_softc)
}
static device_method_t ds1631_methods[]
Definition: ds1631.c:103

Definition at line 110 of file ds1631.c.

◆ ds1631_methods

device_method_t ds1631_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ds1631_probe),
DEVMETHOD(device_attach, ds1631_attach),
{ 0, 0 },
}
static int ds1631_attach(device_t)
Definition: ds1631.c:229
static int ds1631_probe(device_t)
Definition: ds1631.c:204

Definition at line 103 of file ds1631.c.