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

Go to the source code of this file.

Data Structures

struct  ds3231_softc
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void ds3231_start (void *)
 
static int ds3231_read1 (device_t dev, uint8_t reg, uint8_t *data)
 
static int ds3231_write1 (device_t dev, uint8_t reg, uint8_t data)
 
static int ds3231_ctrl_read (struct ds3231_softc *sc)
 
static int ds3231_ctrl_write (struct ds3231_softc *sc)
 
static int ds3231_status_read (struct ds3231_softc *sc)
 
static int ds3231_status_write (struct ds3231_softc *sc, int clear_a1, int clear_a2)
 
static int ds3231_temp_read (struct ds3231_softc *sc, int *temp)
 
static int ds3231_temp_sysctl (SYSCTL_HANDLER_ARGS)
 
static int ds3231_conv_sysctl (SYSCTL_HANDLER_ARGS)
 
static int ds3231_bbsqw_sysctl (SYSCTL_HANDLER_ARGS)
 
static int ds3231_sqw_freq_sysctl (SYSCTL_HANDLER_ARGS)
 
static int ds3231_str_sqw_mode (char *buf)
 
static int ds3231_sqw_mode_sysctl (SYSCTL_HANDLER_ARGS)
 
static int ds3231_en32khz_sysctl (SYSCTL_HANDLER_ARGS)
 
static int ds3231_probe (device_t dev)
 
static int ds3231_attach (device_t dev)
 
static int ds3231_detach (device_t dev)
 
static int ds3231_gettime (device_t dev, struct timespec *ts)
 
static int ds3231_settime (device_t dev, struct timespec *ts)
 
 DRIVER_MODULE (ds3231, iicbus, ds3231_driver, ds3231_devclass, NULL, NULL)
 
 MODULE_VERSION (ds3231, 1)
 
 MODULE_DEPEND (ds3231, iicbus, 1, 1, 1)
 

Variables

static device_method_t ds3231_methods []
 
static driver_t ds3231_driver
 
static devclass_t ds3231_devclass
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( ds3231  ,
iicbus  ,
ds3231_driver  ,
ds3231_devclass  ,
NULL  ,
NULL   
)

◆ ds3231_attach()

static int ds3231_attach ( device_t  dev)
static

Definition at line 376 of file ds3231.c.

References dev, ds3231_start(), ds3231_softc::enum_hook, ds3231_softc::sc_addr, ds3231_softc::sc_dev, ds3231_softc::sc_last_c, and ds3231_softc::sc_year0.

Here is the call graph for this function:

◆ ds3231_bbsqw_sysctl()

static int ds3231_bbsqw_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 220 of file ds3231.c.

References DS3231_CTRL_BBSQW, ds3231_ctrl_read(), ds3231_ctrl_write(), and ds3231_softc::sc_ctrl.

Referenced by ds3231_start().

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

◆ ds3231_conv_sysctl()

static int ds3231_conv_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 191 of file ds3231.c.

References DS3231_CTRL_CONV, ds3231_ctrl_read(), ds3231_ctrl_write(), DS3231_STATUS_BUSY, ds3231_status_read(), ds3231_softc::sc_ctrl, and ds3231_softc::sc_status.

Referenced by ds3231_start().

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

◆ ds3231_ctrl_read()

static int ds3231_ctrl_read ( struct ds3231_softc sc)
static

Definition at line 85 of file ds3231.c.

References DS3231_CONTROL, ds3231_read1(), ds3231_softc::sc_ctrl, and ds3231_softc::sc_dev.

Referenced by ds3231_bbsqw_sysctl(), ds3231_conv_sysctl(), ds3231_sqw_freq_sysctl(), ds3231_sqw_mode_sysctl(), and ds3231_start().

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

◆ ds3231_ctrl_write()

static int ds3231_ctrl_write ( struct ds3231_softc sc)
static

Definition at line 98 of file ds3231.c.

References data, DS3231_CONTROL, ds3231_write1(), ds3231_softc::sc_ctrl, and ds3231_softc::sc_dev.

Referenced by ds3231_bbsqw_sysctl(), ds3231_conv_sysctl(), ds3231_sqw_freq_sysctl(), ds3231_sqw_mode_sysctl(), and ds3231_start().

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

◆ ds3231_detach()

static int ds3231_detach ( device_t  dev)
static

Definition at line 399 of file ds3231.c.

References dev.

◆ ds3231_en32khz_sysctl()

static int ds3231_en32khz_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 331 of file ds3231.c.

References DS3231_STATUS_EN32KHZ, ds3231_status_read(), ds3231_status_write(), and ds3231_softc::sc_status.

Referenced by ds3231_start().

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

◆ ds3231_gettime()

◆ ds3231_probe()

static int ds3231_probe ( device_t  dev)
static

Definition at line 357 of file ds3231.c.

References dev.

◆ ds3231_read1()

static int ds3231_read1 ( device_t  dev,
uint8_t  reg,
uint8_t *  data 
)
static

Definition at line 71 of file ds3231.c.

References data, dev, IIC_INTRWAIT, and iicdev_readfrom().

Referenced by ds3231_ctrl_read(), and ds3231_status_read().

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

◆ ds3231_settime()

◆ ds3231_sqw_freq_sysctl()

static int ds3231_sqw_freq_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 246 of file ds3231.c.

References ds3231_ctrl_read(), DS3231_CTRL_RS_MASK, DS3231_CTRL_RS_SHIFT, ds3231_ctrl_write(), and ds3231_softc::sc_ctrl.

Referenced by ds3231_start().

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

◆ ds3231_sqw_mode_sysctl()

static int ds3231_sqw_mode_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 297 of file ds3231.c.

References buf, DS3231_CTRL_INTCN, ds3231_ctrl_read(), ds3231_ctrl_write(), ds3231_str_sqw_mode(), and ds3231_softc::sc_ctrl.

Referenced by ds3231_start().

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

◆ ds3231_start()

static void ds3231_start ( void *  xdev)
static

◆ ds3231_status_read()

static int ds3231_status_read ( struct ds3231_softc sc)
static

Definition at line 113 of file ds3231.c.

References ds3231_read1(), DS3231_STATUS, ds3231_softc::sc_dev, and ds3231_softc::sc_status.

Referenced by ds3231_conv_sysctl(), ds3231_en32khz_sysctl(), ds3231_gettime(), ds3231_settime(), and ds3231_start().

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

◆ ds3231_status_write()

static int ds3231_status_write ( struct ds3231_softc sc,
int  clear_a1,
int  clear_a2 
)
static

Definition at line 127 of file ds3231.c.

References data, DS3231_STATUS, DS3231_STATUS_A1F, DS3231_STATUS_A2F, ds3231_write1(), ds3231_softc::sc_dev, and ds3231_softc::sc_status.

Referenced by ds3231_en32khz_sysctl(), ds3231_settime(), and ds3231_start().

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

◆ ds3231_str_sqw_mode()

static int ds3231_str_sqw_mode ( char *  buf)
static

Definition at line 279 of file ds3231.c.

References buf, and len.

Referenced by ds3231_sqw_mode_sysctl().

Here is the caller graph for this function:

◆ ds3231_temp_read()

static int ds3231_temp_read ( struct ds3231_softc sc,
int *  temp 
)
static

Definition at line 145 of file ds3231.c.

References buf, DS3231_0250C, DS3231_0500C, DS3231_NEG_BIT, DS3231_TEMP, DS3231_TEMP_MASK, IIC_INTRWAIT, iicdev_readfrom(), ds3231_softc::sc_dev, and TZ_ZEROC.

Referenced by ds3231_temp_sysctl().

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

◆ ds3231_temp_sysctl()

static int ds3231_temp_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 177 of file ds3231.c.

References ds3231_temp_read().

Referenced by ds3231_start().

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

◆ ds3231_write1()

static int ds3231_write1 ( device_t  dev,
uint8_t  reg,
uint8_t  data 
)
static

Definition at line 78 of file ds3231.c.

References data, dev, IIC_INTRWAIT, and iicdev_writeto().

Referenced by ds3231_ctrl_write(), and ds3231_status_write().

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

◆ MODULE_DEPEND()

MODULE_DEPEND ( ds3231  ,
iicbus  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( ds3231  ,
 
)

Variable Documentation

◆ ds3231_devclass

devclass_t ds3231_devclass
static

Definition at line 620 of file ds3231.c.

◆ ds3231_driver

driver_t ds3231_driver
static
Initial value:
= {
"ds3231",
sizeof(struct ds3231_softc),
}
static device_method_t ds3231_methods[]
Definition: ds3231.c:603

Definition at line 614 of file ds3231.c.

◆ ds3231_methods

device_method_t ds3231_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ds3231_probe),
DEVMETHOD(device_attach, ds3231_attach),
DEVMETHOD(device_detach, ds3231_detach),
DEVMETHOD(clock_gettime, ds3231_gettime),
DEVMETHOD(clock_settime, ds3231_settime),
DEVMETHOD_END
}
static int ds3231_attach(device_t dev)
Definition: ds3231.c:376
static int ds3231_gettime(device_t dev, struct timespec *ts)
Definition: ds3231.c:481
static int ds3231_probe(device_t dev)
Definition: ds3231.c:357
static int ds3231_detach(device_t dev)
Definition: ds3231.c:399
static int ds3231_settime(device_t dev, struct timespec *ts)
Definition: ds3231.c:540

Definition at line 603 of file ds3231.c.