FreeBSD kernel IICBUS device code
isl12xx.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/lock.h>
#include <sys/module.h>
#include <sys/sx.h>
#include <dev/iicbus/iiconf.h>
#include <dev/iicbus/iicbus.h>
#include "clock_if.h"
#include "iicbus_if.h"
Include dependency graph for isl12xx.c:

Go to the source code of this file.

Data Structures

struct  time_regs
 
struct  isl12xx_softc
 

Macros

#define ISL12XX_SC_REG   0x00 /* RTC Seconds */
 
#define ISL12XX_SR_REG   0x07 /* Status */
 
#define ISL12XX_SR_ARST   (1u << 7) /* Auto-reset on status read */
 
#define ISL12XX_SR_XTOSCB   (1u << 5) /* Osc disable (use ext osc) */
 
#define ISL12XX_SR_WRTC   (1u << 4) /* Write RTC enable */
 
#define ISL12XX_SR_EVT   (1u << 3) /* Event occurred (w0c) */
 
#define ISL12XX_SR_ALM   (1u << 2) /* Alarm occurred (w0c) */
 
#define ISL12XX_SR_BAT   (1u << 1) /* Running on battery (w0c) */
 
#define ISL12XX_SR_RTCF   (1u << 0) /* RTC fail (power loss) */
 
#define ISL12XX_SR_W0C_BITS   (ISL12XX_SR_BAT | ISL12XX_SR_ALM | ISL12XX_SR_EVT)
 
#define ISL12XX_INT_REG   0x08 /* Interrupts */
 
#define ISL12XX_INT_IM   (1u << 7) /* Alarm interrupt mode */
 
#define ISL12XX_INT_ALME   (1u << 6) /* Alarm enable */
 
#define ISL12XX_INT_LPMODE   (1u << 5) /* Low Power mode */
 
#define ISL12XX_INT_FOBATB   (1u << 4) /* Fout/IRQ disabled on bat */
 
#define ISL12XX_INT_FO_SHIFT   0 /* Frequency output select */
 
#define ISL12XX_INT_FO_MASK   0x0f /* shift and mask. */
 
#define ISL12XX_EV_REG   0x09 /* Event */
 
#define ISL12XX_EV_EVIENB   (1u << 7) /* Disable internal pullup */
 
#define ISL12XX_EV_EVBATB   (1u << 6) /* Disable ev detect on bat */
 
#define ISL12XX_EV_RTCHLT   (1u << 5) /* Halt RTC on event */
 
#define ISL12XX_EV_EVEN   (1u << 4) /* Event detect enable */
 
#define ISL12XX_EV_EHYS_SHIFT   2 /* Event input hysteresis */
 
#define ISL12XX_EV_EHYS_MASK   0x03 /* selection; see datasheet */
 
#define ISL12XX_EV_ESMP_SHIFT   0 /* Event input sample rate */
 
#define ISL12XX_EV_ESMP_MASK   0x03 /* selection; see datasheet */
 
#define ISL12XX_ATR_REG   0x0a /* Analog trim (osc adjust) */
 
#define ISL12XX_DTR_REG   0x0b /* Digital trim (osc adjust) */
 
#define ISL12XX_SCA_REG   0x0c /* Alarm seconds */
 
#define ISL12XX_USR1_REG   0x12 /* User byte 1 */
 
#define ISL12XX_USR2_REG   0x13 /* User byte 2 */
 
#define ISL12XX_SCT_REG   0x14 /* Timestamp (event) seconds */
 
#define ISL12XX_24HR_FLAG   (1u << 7) /* Hours register 24-hr mode */
 
#define ISL12XX_PM_FLAG   (1u << 5) /* Hours register PM flag */
 
#define ISL12xx_12HR_MASK   0x1f /* Hours mask in AM/PM mode */
 
#define ISL12xx_24HR_MASK   0x3f /* Hours mask in 24-hr mode */
 
#define WAITFLAGS   (IIC_WAIT | IIC_RECURSIVE)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int isl12xx_read1 (struct isl12xx_softc *sc, uint8_t reg, uint8_t *data)
 
static int isl12xx_write1 (struct isl12xx_softc *sc, uint8_t reg, uint8_t val)
 
static void isl12xx_init (void *arg)
 
static int isl12xx_probe (device_t dev)
 
static int isl12xx_attach (device_t dev)
 
static int isl12xx_detach (device_t dev)
 
static int isl12xx_gettime (device_t dev, struct timespec *ts)
 
static int isl12xx_settime (device_t dev, struct timespec *ts)
 
 DRIVER_MODULE (isl12xx, iicbus, isl12xx_driver, isl12xx_devclass, NULL, NULL)
 
 MODULE_VERSION (isl12xx, 1)
 
 MODULE_DEPEND (isl12xx, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER)
 
 IICBUS_FDT_PNP_INFO (compat_data)
 

Variables

static device_method_t isl12xx_methods []
 
static driver_t isl12xx_driver
 
static devclass_t isl12xx_devclass
 

Macro Definition Documentation

◆ ISL12xx_12HR_MASK

#define ISL12xx_12HR_MASK   0x1f /* Hours mask in AM/PM mode */

Definition at line 113 of file isl12xx.c.

◆ ISL12XX_24HR_FLAG

#define ISL12XX_24HR_FLAG   (1u << 7) /* Hours register 24-hr mode */

Definition at line 111 of file isl12xx.c.

◆ ISL12xx_24HR_MASK

#define ISL12xx_24HR_MASK   0x3f /* Hours mask in 24-hr mode */

Definition at line 114 of file isl12xx.c.

◆ ISL12XX_ATR_REG

#define ISL12XX_ATR_REG   0x0a /* Analog trim (osc adjust) */

Definition at line 99 of file isl12xx.c.

◆ ISL12XX_DTR_REG

#define ISL12XX_DTR_REG   0x0b /* Digital trim (osc adjust) */

Definition at line 101 of file isl12xx.c.

◆ ISL12XX_EV_EHYS_MASK

#define ISL12XX_EV_EHYS_MASK   0x03 /* selection; see datasheet */

Definition at line 95 of file isl12xx.c.

◆ ISL12XX_EV_EHYS_SHIFT

#define ISL12XX_EV_EHYS_SHIFT   2 /* Event input hysteresis */

Definition at line 94 of file isl12xx.c.

◆ ISL12XX_EV_ESMP_MASK

#define ISL12XX_EV_ESMP_MASK   0x03 /* selection; see datasheet */

Definition at line 97 of file isl12xx.c.

◆ ISL12XX_EV_ESMP_SHIFT

#define ISL12XX_EV_ESMP_SHIFT   0 /* Event input sample rate */

Definition at line 96 of file isl12xx.c.

◆ ISL12XX_EV_EVBATB

#define ISL12XX_EV_EVBATB   (1u << 6) /* Disable ev detect on bat */

Definition at line 91 of file isl12xx.c.

◆ ISL12XX_EV_EVEN

#define ISL12XX_EV_EVEN   (1u << 4) /* Event detect enable */

Definition at line 93 of file isl12xx.c.

◆ ISL12XX_EV_EVIENB

#define ISL12XX_EV_EVIENB   (1u << 7) /* Disable internal pullup */

Definition at line 90 of file isl12xx.c.

◆ ISL12XX_EV_REG

#define ISL12XX_EV_REG   0x09 /* Event */

Definition at line 89 of file isl12xx.c.

◆ ISL12XX_EV_RTCHLT

#define ISL12XX_EV_RTCHLT   (1u << 5) /* Halt RTC on event */

Definition at line 92 of file isl12xx.c.

◆ ISL12XX_INT_ALME

#define ISL12XX_INT_ALME   (1u << 6) /* Alarm enable */

Definition at line 83 of file isl12xx.c.

◆ ISL12XX_INT_FO_MASK

#define ISL12XX_INT_FO_MASK   0x0f /* shift and mask. */

Definition at line 87 of file isl12xx.c.

◆ ISL12XX_INT_FO_SHIFT

#define ISL12XX_INT_FO_SHIFT   0 /* Frequency output select */

Definition at line 86 of file isl12xx.c.

◆ ISL12XX_INT_FOBATB

#define ISL12XX_INT_FOBATB   (1u << 4) /* Fout/IRQ disabled on bat */

Definition at line 85 of file isl12xx.c.

◆ ISL12XX_INT_IM

#define ISL12XX_INT_IM   (1u << 7) /* Alarm interrupt mode */

Definition at line 82 of file isl12xx.c.

◆ ISL12XX_INT_LPMODE

#define ISL12XX_INT_LPMODE   (1u << 5) /* Low Power mode */

Definition at line 84 of file isl12xx.c.

◆ ISL12XX_INT_REG

#define ISL12XX_INT_REG   0x08 /* Interrupts */

Definition at line 81 of file isl12xx.c.

◆ ISL12XX_PM_FLAG

#define ISL12XX_PM_FLAG   (1u << 5) /* Hours register PM flag */

Definition at line 112 of file isl12xx.c.

◆ ISL12XX_SC_REG

#define ISL12XX_SC_REG   0x00 /* RTC Seconds */

Definition at line 69 of file isl12xx.c.

◆ ISL12XX_SCA_REG

#define ISL12XX_SCA_REG   0x0c /* Alarm seconds */

Definition at line 103 of file isl12xx.c.

◆ ISL12XX_SCT_REG

#define ISL12XX_SCT_REG   0x14 /* Timestamp (event) seconds */

Definition at line 109 of file isl12xx.c.

◆ ISL12XX_SR_ALM

#define ISL12XX_SR_ALM   (1u << 2) /* Alarm occurred (w0c) */

Definition at line 76 of file isl12xx.c.

◆ ISL12XX_SR_ARST

#define ISL12XX_SR_ARST   (1u << 7) /* Auto-reset on status read */

Definition at line 72 of file isl12xx.c.

◆ ISL12XX_SR_BAT

#define ISL12XX_SR_BAT   (1u << 1) /* Running on battery (w0c) */

Definition at line 77 of file isl12xx.c.

◆ ISL12XX_SR_EVT

#define ISL12XX_SR_EVT   (1u << 3) /* Event occurred (w0c) */

Definition at line 75 of file isl12xx.c.

◆ ISL12XX_SR_REG

#define ISL12XX_SR_REG   0x07 /* Status */

Definition at line 71 of file isl12xx.c.

◆ ISL12XX_SR_RTCF

#define ISL12XX_SR_RTCF   (1u << 0) /* RTC fail (power loss) */

Definition at line 78 of file isl12xx.c.

◆ ISL12XX_SR_W0C_BITS

#define ISL12XX_SR_W0C_BITS   (ISL12XX_SR_BAT | ISL12XX_SR_ALM | ISL12XX_SR_EVT)

Definition at line 79 of file isl12xx.c.

◆ ISL12XX_SR_WRTC

#define ISL12XX_SR_WRTC   (1u << 4) /* Write RTC enable */

Definition at line 74 of file isl12xx.c.

◆ ISL12XX_SR_XTOSCB

#define ISL12XX_SR_XTOSCB   (1u << 5) /* Osc disable (use ext osc) */

Definition at line 73 of file isl12xx.c.

◆ ISL12XX_USR1_REG

#define ISL12XX_USR1_REG   0x12 /* User byte 1 */

Definition at line 105 of file isl12xx.c.

◆ ISL12XX_USR2_REG

#define ISL12XX_USR2_REG   0x13 /* User byte 2 */

Definition at line 107 of file isl12xx.c.

◆ WAITFLAGS

#define WAITFLAGS   (IIC_WAIT | IIC_RECURSIVE)

Definition at line 149 of file isl12xx.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( isl12xx  ,
iicbus  ,
isl12xx_driver  ,
isl12xx_devclass  ,
NULL  ,
NULL   
)

◆ IICBUS_FDT_PNP_INFO()

IICBUS_FDT_PNP_INFO ( compat_data  )

◆ isl12xx_attach()

static int isl12xx_attach ( device_t  dev)
static

Definition at line 207 of file isl12xx.c.

References isl12xx_softc::busdev, isl12xx_softc::dev, dev, isl12xx_softc::init_hook, and isl12xx_init().

Here is the call graph for this function:

◆ isl12xx_detach()

static int isl12xx_detach ( device_t  dev)
static

Definition at line 227 of file isl12xx.c.

References dev.

◆ isl12xx_gettime()

◆ isl12xx_init()

static void isl12xx_init ( void *  arg)
static

Definition at line 166 of file isl12xx.c.

References isl12xx_softc::dev, isl12xx_softc::init_hook, isl12xx_read1(), ISL12XX_SR_REG, and ISL12XX_SR_RTCF.

Referenced by isl12xx_attach().

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

◆ isl12xx_probe()

static int isl12xx_probe ( device_t  dev)
static

Definition at line 191 of file isl12xx.c.

References compat_data, and dev.

◆ isl12xx_read1()

static int isl12xx_read1 ( struct isl12xx_softc sc,
uint8_t  reg,
uint8_t *  data 
)
inlinestatic

Definition at line 152 of file isl12xx.c.

References data, isl12xx_softc::dev, iicdev_readfrom(), and WAITFLAGS.

Referenced by isl12xx_gettime(), isl12xx_init(), and isl12xx_settime().

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

◆ isl12xx_settime()

◆ isl12xx_write1()

static int isl12xx_write1 ( struct isl12xx_softc sc,
uint8_t  reg,
uint8_t  val 
)
inlinestatic

Definition at line 159 of file isl12xx.c.

References isl12xx_softc::dev, iicdev_writeto(), val, and WAITFLAGS.

Referenced by isl12xx_settime().

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

◆ MODULE_DEPEND()

MODULE_DEPEND ( isl12xx  ,
iicbus  ,
IICBUS_MINVER  ,
IICBUS_PREFVER  ,
IICBUS_MAXVER   
)

◆ MODULE_VERSION()

MODULE_VERSION ( isl12xx  ,
 
)

Variable Documentation

◆ isl12xx_devclass

devclass_t isl12xx_devclass
static

Definition at line 356 of file isl12xx.c.

◆ isl12xx_driver

driver_t isl12xx_driver
static
Initial value:
= {
"isl12xx",
sizeof(struct isl12xx_softc),
}
static device_method_t isl12xx_methods[]
Definition: isl12xx.c:338

Definition at line 351 of file isl12xx.c.

◆ isl12xx_methods

device_method_t isl12xx_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, isl12xx_probe),
DEVMETHOD(device_attach, isl12xx_attach),
DEVMETHOD(device_detach, isl12xx_detach),
DEVMETHOD(clock_gettime, isl12xx_gettime),
DEVMETHOD(clock_settime, isl12xx_settime),
DEVMETHOD_END,
}
static int isl12xx_attach(device_t dev)
Definition: isl12xx.c:207
static int isl12xx_gettime(device_t dev, struct timespec *ts)
Definition: isl12xx.c:235
static int isl12xx_detach(device_t dev)
Definition: isl12xx.c:227
static int isl12xx_settime(device_t dev, struct timespec *ts)
Definition: isl12xx.c:282
static int isl12xx_probe(device_t dev)
Definition: isl12xx.c:191

Definition at line 338 of file isl12xx.c.