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

Go to the source code of this file.

Data Structures

struct  s390rtc_softc
 

Macros

#define S390_DEVNAME   "s35390a_rtc"
 
#define S390_DEVCODE   0x6 /* 0110 */
 
#define S390_ADDR   (S390_DEVCODE << 4)
 
#define S390_STATUS1   (0 << 1)
 
#define S390_STATUS2   (1 << 1)
 
#define S390_REALTIME1   (2 << 1)
 
#define S390_REALTIME2   (3 << 1)
 
#define S390_INT1_1   (4 << 1)
 
#define S390_INT1_2   (5 << 1)
 
#define S390_CLOCKADJ   (6 << 1)
 
#define S390_FREE   (7 << 1)
 
#define S390_ST1_POC   (1 << 7)
 
#define S390_ST1_BLD   (1 << 6)
 
#define S390_ST1_24H   (1 << 1)
 
#define S390_ST1_RESET   (1 << 0)
 
#define S390_ST2_TEST   (1 << 7)
 
#define S390_RT1_NBYTES   7
 
#define S390_RT1_YEAR   0
 
#define S390_RT1_MONTH   1
 
#define S390_RT1_DAY   2
 
#define S390_RT1_WDAY   3
 
#define S390_RT1_HOUR   4
 
#define S390_RT1_MINUTE   5
 
#define S390_RT1_SECOND   6
 

Functions

 __FBSDID ("$FreeBSD$")
 
static uint8_t bitreverse (uint8_t x)
 
static int s390rtc_read (device_t dev, uint8_t reg, uint8_t *buf, size_t len)
 
static int s390rtc_write (device_t dev, uint8_t reg, uint8_t *buf, size_t len)
 
static int s390rtc_probe (device_t dev)
 
static void s390rtc_start (void *arg)
 
static int s390rtc_attach (device_t dev)
 
static int s390rtc_detach (device_t dev)
 
static int s390rtc_gettime (device_t dev, struct timespec *ts)
 
static int s390rtc_settime (device_t dev, struct timespec *ts)
 
 DRIVER_MODULE (s35390a, iicbus, s390rtc_driver, s390rtc_devclass, NULL, NULL)
 
 MODULE_VERSION (s35390a, 1)
 
 MODULE_DEPEND (s35390a, iicbus, 1, 1, 1)
 

Variables

static const uint8_t nibbletab []
 
static device_method_t s390rtc_methods []
 
static driver_t s390rtc_driver
 
static devclass_t s390rtc_devclass
 

Macro Definition Documentation

◆ S390_ADDR

#define S390_ADDR   (S390_DEVCODE << 4)

Definition at line 92 of file s35390a.c.

◆ S390_CLOCKADJ

#define S390_CLOCKADJ   (6 << 1)

Definition at line 101 of file s35390a.c.

◆ S390_DEVCODE

#define S390_DEVCODE   0x6 /* 0110 */

Definition at line 86 of file s35390a.c.

◆ S390_DEVNAME

#define S390_DEVNAME   "s35390a_rtc"

Definition at line 85 of file s35390a.c.

◆ S390_FREE

#define S390_FREE   (7 << 1)

Definition at line 102 of file s35390a.c.

◆ S390_INT1_1

#define S390_INT1_1   (4 << 1)

Definition at line 99 of file s35390a.c.

◆ S390_INT1_2

#define S390_INT1_2   (5 << 1)

Definition at line 100 of file s35390a.c.

◆ S390_REALTIME1

#define S390_REALTIME1   (2 << 1)

Definition at line 97 of file s35390a.c.

◆ S390_REALTIME2

#define S390_REALTIME2   (3 << 1)

Definition at line 98 of file s35390a.c.

◆ S390_RT1_DAY

#define S390_RT1_DAY   2

Definition at line 117 of file s35390a.c.

◆ S390_RT1_HOUR

#define S390_RT1_HOUR   4

Definition at line 119 of file s35390a.c.

◆ S390_RT1_MINUTE

#define S390_RT1_MINUTE   5

Definition at line 120 of file s35390a.c.

◆ S390_RT1_MONTH

#define S390_RT1_MONTH   1

Definition at line 116 of file s35390a.c.

◆ S390_RT1_NBYTES

#define S390_RT1_NBYTES   7

Definition at line 114 of file s35390a.c.

◆ S390_RT1_SECOND

#define S390_RT1_SECOND   6

Definition at line 121 of file s35390a.c.

◆ S390_RT1_WDAY

#define S390_RT1_WDAY   3

Definition at line 118 of file s35390a.c.

◆ S390_RT1_YEAR

#define S390_RT1_YEAR   0

Definition at line 115 of file s35390a.c.

◆ S390_ST1_24H

#define S390_ST1_24H   (1 << 1)

Definition at line 107 of file s35390a.c.

◆ S390_ST1_BLD

#define S390_ST1_BLD   (1 << 6)

Definition at line 106 of file s35390a.c.

◆ S390_ST1_POC

#define S390_ST1_POC   (1 << 7)

Definition at line 105 of file s35390a.c.

◆ S390_ST1_RESET

#define S390_ST1_RESET   (1 << 0)

Definition at line 108 of file s35390a.c.

◆ S390_ST2_TEST

#define S390_ST2_TEST   (1 << 7)

Definition at line 111 of file s35390a.c.

◆ S390_STATUS1

#define S390_STATUS1   (0 << 1)

Definition at line 95 of file s35390a.c.

◆ S390_STATUS2

#define S390_STATUS2   (1 << 1)

Definition at line 96 of file s35390a.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ bitreverse()

static uint8_t bitreverse ( uint8_t  x)
static

Definition at line 151 of file s35390a.c.

References nibbletab.

Referenced by s390rtc_read(), and s390rtc_write().

Here is the caller graph for this function:

◆ DRIVER_MODULE()

DRIVER_MODULE ( s35390a  ,
iicbus  ,
s390rtc_driver  ,
s390rtc_devclass  ,
NULL  ,
NULL   
)

◆ MODULE_DEPEND()

MODULE_DEPEND ( s35390a  ,
iicbus  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( s35390a  ,
 
)

◆ s390rtc_attach()

static int s390rtc_attach ( device_t  dev)
static

Definition at line 275 of file s35390a.c.

References dev, s390rtc_start(), s390rtc_softc::sc_addr, and s390rtc_softc::sc_dev.

Here is the call graph for this function:

◆ s390rtc_detach()

static int s390rtc_detach ( device_t  dev)
static

Definition at line 289 of file s35390a.c.

References dev.

◆ s390rtc_gettime()

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

Definition at line 297 of file s35390a.c.

References dev, S390_REALTIME1, S390_RT1_DAY, S390_RT1_HOUR, S390_RT1_MINUTE, S390_RT1_MONTH, S390_RT1_NBYTES, S390_RT1_SECOND, S390_RT1_WDAY, S390_RT1_YEAR, and s390rtc_read().

Here is the call graph for this function:

◆ s390rtc_probe()

static int s390rtc_probe ( device_t  dev)
static

Definition at line 205 of file s35390a.c.

References dev, and S390_ADDR.

◆ s390rtc_read()

static int s390rtc_read ( device_t  dev,
uint8_t  reg,
uint8_t *  buf,
size_t  len 
)
static

Definition at line 158 of file s35390a.c.

References bitreverse(), buf, dev, IIC_M_RD, IIC_WAIT, iicbus_transfer_excl(), len, s390rtc_softc::sc_addr, and iic_msg::slave.

Referenced by s390rtc_gettime(), and s390rtc_start().

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

◆ s390rtc_settime()

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

Definition at line 327 of file s35390a.c.

References dev, S390_REALTIME1, S390_RT1_DAY, S390_RT1_HOUR, S390_RT1_MINUTE, S390_RT1_MONTH, S390_RT1_NBYTES, S390_RT1_SECOND, S390_RT1_WDAY, S390_RT1_YEAR, and s390rtc_write().

Here is the call graph for this function:

◆ s390rtc_start()

static void s390rtc_start ( void *  arg)
static

Definition at line 229 of file s35390a.c.

References dev, S390_ST1_24H, S390_ST1_BLD, S390_ST1_POC, S390_ST1_RESET, S390_ST2_TEST, S390_STATUS1, S390_STATUS2, s390rtc_read(), and s390rtc_write().

Referenced by s390rtc_attach().

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

◆ s390rtc_write()

static int s390rtc_write ( device_t  dev,
uint8_t  reg,
uint8_t *  buf,
size_t  len 
)
static

Definition at line 184 of file s35390a.c.

References bitreverse(), buf, dev, IIC_M_WR, IIC_WAIT, iicbus_transfer_excl(), len, s390rtc_softc::sc_addr, and iic_msg::slave.

Referenced by s390rtc_settime(), and s390rtc_start().

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

Variable Documentation

◆ nibbletab

const uint8_t nibbletab[]
static
Initial value:
= {
0x0,
0x8,
0x4,
0xc,
0x2,
0xa,
0x6,
0xe,
0x1,
0x9,
0x5,
0xd,
0x3,
0xb,
0x7,
0xf, }

Definition at line 132 of file s35390a.c.

Referenced by bitreverse().

◆ s390rtc_devclass

devclass_t s390rtc_devclass
static

Definition at line 366 of file s35390a.c.

◆ s390rtc_driver

driver_t s390rtc_driver
static
Initial value:
= {
sizeof(struct s390rtc_softc),
}
static device_method_t s390rtc_methods[]
Definition: s35390a.c:350
#define S390_DEVNAME
Definition: s35390a.c:85

Definition at line 361 of file s35390a.c.

◆ s390rtc_methods

device_method_t s390rtc_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, s390rtc_probe),
DEVMETHOD(device_attach, s390rtc_attach),
DEVMETHOD(device_detach, s390rtc_detach),
DEVMETHOD(clock_gettime, s390rtc_gettime),
DEVMETHOD(clock_settime, s390rtc_settime),
DEVMETHOD_END
}
static int s390rtc_gettime(device_t dev, struct timespec *ts)
Definition: s35390a.c:297
static int s390rtc_detach(device_t dev)
Definition: s35390a.c:289
static int s390rtc_settime(device_t dev, struct timespec *ts)
Definition: s35390a.c:327
static int s390rtc_attach(device_t dev)
Definition: s35390a.c:275
static int s390rtc_probe(device_t dev)
Definition: s35390a.c:205

Definition at line 350 of file s35390a.c.