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

Go to the source code of this file.

Data Structures

struct  ds1672_softc
 

Macros

#define IIC_M_WR   0 /* write operation */
 
#define DS1672_ADDR   0xd0 /* slave address */
 
#define DS1672_COUNTER   0 /* counter (bytes 0-3) */
 
#define DS1672_CTRL   4 /* control (1 byte) */
 
#define DS1672_TRICKLE   5 /* trickle charger (1 byte) */
 
#define DS1672_CTRL_EOSC   (1 << 7) /* Stop/start flag. */
 
#define MAX_IIC_DATA_SIZE   4
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int ds1672_probe (device_t dev)
 
static int ds1672_read (device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
 
static int ds1672_write (device_t dev, uint8_t addr, uint8_t *data, uint8_t size)
 
static int ds1672_init (device_t dev)
 
static int ds1672_detach (device_t dev)
 
static int ds1672_attach (device_t dev)
 
static int ds1672_gettime (device_t dev, struct timespec *ts)
 
static int ds1672_settime (device_t dev, struct timespec *ts)
 
 DRIVER_MODULE (ds1672, iicbus, ds1672_driver, ds1672_devclass, 0, 0)
 
 MODULE_VERSION (ds1672, 1)
 
 MODULE_DEPEND (ds1672, iicbus, 1, 1, 1)
 

Variables

static device_method_t ds1672_methods []
 
static driver_t ds1672_driver
 
static devclass_t ds1672_devclass
 

Macro Definition Documentation

◆ DS1672_ADDR

#define DS1672_ADDR   0xd0 /* slave address */

Definition at line 49 of file ds1672.c.

◆ DS1672_COUNTER

#define DS1672_COUNTER   0 /* counter (bytes 0-3) */

Definition at line 51 of file ds1672.c.

◆ DS1672_CTRL

#define DS1672_CTRL   4 /* control (1 byte) */

Definition at line 52 of file ds1672.c.

◆ DS1672_CTRL_EOSC

#define DS1672_CTRL_EOSC   (1 << 7) /* Stop/start flag. */

Definition at line 55 of file ds1672.c.

◆ DS1672_TRICKLE

#define DS1672_TRICKLE   5 /* trickle charger (1 byte) */

Definition at line 53 of file ds1672.c.

◆ IIC_M_WR

#define IIC_M_WR   0 /* write operation */

Definition at line 47 of file ds1672.c.

◆ MAX_IIC_DATA_SIZE

#define MAX_IIC_DATA_SIZE   4

Definition at line 57 of file ds1672.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( ds1672  ,
iicbus  ,
ds1672_driver  ,
ds1672_devclass  ,
,
 
)

◆ ds1672_attach()

static int ds1672_attach ( device_t  dev)
static

Definition at line 129 of file ds1672.c.

References dev, ds1672_init(), and ds1672_softc::sc_dev.

Here is the call graph for this function:

◆ ds1672_detach()

static int ds1672_detach ( device_t  dev)
static

Definition at line 121 of file ds1672.c.

References dev.

◆ ds1672_gettime()

static int ds1672_gettime ( device_t  dev,
struct timespec *  ts 
)
static

Definition at line 143 of file ds1672.c.

References dev, DS1672_COUNTER, and ds1672_read().

Here is the call graph for this function:

◆ ds1672_init()

static int ds1672_init ( device_t  dev)
static

Definition at line 99 of file ds1672.c.

References dev, DS1672_CTRL, DS1672_CTRL_EOSC, ds1672_read(), and ds1672_write().

Referenced by ds1672_attach().

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

◆ ds1672_probe()

static int ds1672_probe ( device_t  dev)
static

Definition at line 64 of file ds1672.c.

References dev.

◆ ds1672_read()

static int ds1672_read ( device_t  dev,
uint8_t  addr,
uint8_t *  data,
uint8_t  size 
)
static

Definition at line 72 of file ds1672.c.

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

Referenced by ds1672_gettime(), and ds1672_init().

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

◆ ds1672_settime()

static int ds1672_settime ( device_t  dev,
struct timespec *  ts 
)
static

Definition at line 160 of file ds1672.c.

References data, dev, DS1672_COUNTER, and ds1672_write().

Here is the call graph for this function:

◆ ds1672_write()

static int ds1672_write ( device_t  dev,
uint8_t  addr,
uint8_t *  data,
uint8_t  size 
)
static

Definition at line 83 of file ds1672.c.

References addr, data, dev, DS1672_ADDR, IIC_M_WR, iicbus_transfer(), MAX_IIC_DATA_SIZE, and msgs.

Referenced by ds1672_init(), and ds1672_settime().

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

◆ MODULE_DEPEND()

MODULE_DEPEND ( ds1672  ,
iicbus  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( ds1672  ,
 
)

Variable Documentation

◆ ds1672_devclass

devclass_t ds1672_devclass
static

Definition at line 190 of file ds1672.c.

◆ ds1672_driver

driver_t ds1672_driver
static
Initial value:
= {
"ds1672_rtc",
sizeof(struct ds1672_softc),
}
static device_method_t ds1672_methods[]
Definition: ds1672.c:174

Definition at line 185 of file ds1672.c.

◆ ds1672_methods

device_method_t ds1672_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ds1672_probe),
DEVMETHOD(device_attach, ds1672_attach),
DEVMETHOD(device_detach, ds1672_detach),
DEVMETHOD(clock_gettime, ds1672_gettime),
DEVMETHOD(clock_settime, ds1672_settime),
DEVMETHOD_END
}
static int ds1672_probe(device_t dev)
Definition: ds1672.c:64
static int ds1672_settime(device_t dev, struct timespec *ts)
Definition: ds1672.c:160
static int ds1672_attach(device_t dev)
Definition: ds1672.c:129
static int ds1672_gettime(device_t dev, struct timespec *ts)
Definition: ds1672.c:143
static int ds1672_detach(device_t dev)
Definition: ds1672.c:121

Definition at line 174 of file ds1672.c.