FreeBSD kernel IICBUS device code
|
#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/libkern.h>
#include <sys/module.h>
#include <sys/sysctl.h>
#include <dev/iicbus/iicbus.h>
#include <dev/iicbus/iiconf.h>
#include "clock_if.h"
#include "iicbus_if.h"
Go to the source code of this file.
Data Structures | |
struct | time_regs |
struct | nxprtc_softc |
struct | nxprtc_compat_data |
Macros | |
#define | PCF8563_ADDR 0xa2 |
#define | PCF8523_ADDR 0xd0 |
#define | PCF85xx_R_CS1 0x00 /* CS1 and CS2 control regs are in */ |
#define | PCF85xx_R_CS2 0x01 /* the same location on all chips. */ |
#define | PCF85xx_B_CS1_STOP 0x20 /* Stop time incrementing bit */ |
#define | PCF85xx_B_SECOND_OS 0x80 /* Oscillator Stopped bit */ |
#define | PCF85xx_M_SECOND 0x7f /* Masks for all BCD time regs... */ |
#define | PCF85xx_M_MINUTE 0x7f |
#define | PCF85xx_M_12HOUR 0x1f |
#define | PCF85xx_M_24HOUR 0x3f |
#define | PCF85xx_M_DAY 0x3f |
#define | PCF85xx_M_MONTH 0x1f |
#define | PCF85xx_M_YEAR 0xff |
#define | PCF2127_R_TMR_CTL 0x10 /* Timer/watchdog control */ |
#define | PCF2127_M_TMR_CTRL 0xe3 /* Mask off undef bits */ |
#define | PCF2127_B_TMR_CD 0x40 /* Run in countdown mode */ |
#define | PCF2127_B_TMR_64HZ 0x01 /* Timer frequency 64Hz */ |
#define | PCF2127_R_TS_CTL 0x12 /* Timestamp control */ |
#define | PCF2127_B_TSOFF 0x40 /* Turn off timestamp function */ |
#define | PCF2127_R_AGING_OFFSET 0x19 /* Frequency aging offset in PPM */ |
#define | PCF2129_B_CS1_12HR 0x04 /* Use 12-hour (AM/PM) mode bit */ |
#define | PCF2129_B_CLKOUT_OTPR 0x20 /* OTP refresh command */ |
#define | PCF2129_B_CLKOUT_HIGHZ 0x07 /* Clock Out Freq = disable */ |
#define | PCF8523_R_CS3 0x02 /* Control and status reg 3 */ |
#define | PCF8523_R_SECOND 0x03 /* Seconds */ |
#define | PCF8523_R_TMR_CLKOUT 0x0F /* Timer and clockout control */ |
#define | PCF8523_R_TMR_A_FREQ 0x10 /* Timer A frequency control */ |
#define | PCF8523_R_TMR_A_COUNT 0x11 /* Timer A count */ |
#define | PCF8523_M_TMR_A_FREQ 0x07 /* Mask off undef bits */ |
#define | PCF8523_B_HOUR_PM 0x20 /* PM bit */ |
#define | PCF8523_B_CS1_SOFTRESET 0x58 /* Initiate Soft Reset bits */ |
#define | PCF8523_B_CS1_12HR 0x08 /* Use 12-hour (AM/PM) mode bit */ |
#define | PCF8523_B_CLKOUT_TACD 0x02 /* TimerA runs in CountDown mode */ |
#define | PCF8523_B_CLKOUT_HIGHZ 0x38 /* Clock Out Freq = disable */ |
#define | PCF8523_B_TMR_A_64HZ 0x01 /* Timer A freq 64Hz */ |
#define | PCF8523_M_CS3_PM 0xE0 /* Power mode mask */ |
#define | PCF8523_B_CS3_PM_NOBAT 0xE0 /* PM bits: no battery usage */ |
#define | PCF8523_B_CS3_PM_STD 0x00 /* PM bits: standard */ |
#define | PCF8523_B_CS3_PM_DSNBM 0xa0 /* PM bits: direct switch, no bat mon */ |
#define | PCF8523_B_CS3_BLF 0x04 /* Battery Low Flag bit */ |
#define | PCF8563_R_SECOND 0x02 /* Seconds */ |
#define | PCF8563_R_CLKOUT 0x0d /* Clock output control */ |
#define | PCF8563_R_TMR_CTRL 0x0e /* Timer control */ |
#define | PCF8563_R_TMR_COUNT 0x0f /* Timer count */ |
#define | PCF8563_M_TMR_CTRL 0x93 /* Mask off undef bits */ |
#define | PCF8563_B_TMR_ENABLE 0x80 /* Enable countdown timer */ |
#define | PCF8563_B_TMR_64HZ 0x01 /* Timer frequency 64Hz */ |
#define | PCF8563_B_MONTH_C 0x80 /* Century bit */ |
#define | TMR_TICKS_SEC 64 |
#define | TMR_TICKS_HALFSEC 32 |
#define | SC_F_CPOL (1 << 0) /* Century bit means 19xx */ |
#define | WAITFLAGS (IIC_WAIT | IIC_RECURSIVE) |
Enumerations | |
enum | { TYPE_NONE , TYPE_PCA2129 , TYPE_PCA8565 , TYPE_PCF2127 , TYPE_PCF2129 , TYPE_PCF8523 , TYPE_PCF8563 , TYPE_COUNT } |
Functions | |
__FBSDID ("$FreeBSD$") | |
CTASSERT (nitems(desc_strings)==TYPE_COUNT) | |
static int | nxprtc_readfrom (device_t slavedev, uint8_t regaddr, void *buffer, uint16_t buflen, int waithow) |
static int | read_reg (struct nxprtc_softc *sc, uint8_t reg, uint8_t *val) |
static int | write_reg (struct nxprtc_softc *sc, uint8_t reg, uint8_t val) |
static int | read_timeregs (struct nxprtc_softc *sc, struct time_regs *tregs, uint8_t *tmr) |
static int | write_timeregs (struct nxprtc_softc *sc, struct time_regs *tregs) |
static int | freqadj_sysctl (SYSCTL_HANDLER_ARGS) |
static int | pcf8523_battery_check (struct nxprtc_softc *sc) |
static int | pcf8523_start (struct nxprtc_softc *sc) |
static int | pcf8523_start_timer (struct nxprtc_softc *sc) |
static int | pcf2127_start_timer (struct nxprtc_softc *sc) |
static int | pcf8563_start (struct nxprtc_softc *sc) |
static int | pcf8563_start_timer (struct nxprtc_softc *sc) |
static void | nxprtc_start (void *dev) |
static int | nxprtc_gettime (device_t dev, struct timespec *ts) |
static int | nxprtc_settime (device_t dev, struct timespec *ts) |
static int | nxprtc_get_chiptype (device_t dev) |
static int | nxprtc_probe (device_t dev) |
static int | nxprtc_attach (device_t dev) |
static int | nxprtc_detach (device_t dev) |
DRIVER_MODULE (nxprtc, iicbus, nxprtc_driver, nxprtc_devclass, NULL, NULL) | |
MODULE_VERSION (nxprtc, 1) | |
MODULE_DEPEND (nxprtc, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER) | |
IICBUS_FDT_PNP_INFO (compat_data) | |
Variables | |
static const char * | desc_strings [] |
static nxprtc_compat_data | compat_data [] |
static device_method_t | nxprtc_methods [] |
static driver_t | nxprtc_driver |
static devclass_t | nxprtc_devclass |
#define PCF2127_B_TSOFF 0x40 /* Turn off timestamp function */ |
#define PCF2127_R_AGING_OFFSET 0x19 /* Frequency aging offset in PPM */ |
#define PCF2127_R_TMR_CTL 0x10 /* Timer/watchdog control */ |
#define PCF2129_B_CLKOUT_HIGHZ 0x07 /* Clock Out Freq = disable */ |
#define PCF2129_B_CLKOUT_OTPR 0x20 /* OTP refresh command */ |
#define PCF2129_B_CS1_12HR 0x04 /* Use 12-hour (AM/PM) mode bit */ |
#define PCF8523_B_CLKOUT_HIGHZ 0x38 /* Clock Out Freq = disable */ |
#define PCF8523_B_CLKOUT_TACD 0x02 /* TimerA runs in CountDown mode */ |
#define PCF8523_B_CS1_12HR 0x08 /* Use 12-hour (AM/PM) mode bit */ |
#define PCF8523_B_CS1_SOFTRESET 0x58 /* Initiate Soft Reset bits */ |
#define PCF8523_B_CS3_PM_DSNBM 0xa0 /* PM bits: direct switch, no bat mon */ |
#define PCF8523_B_CS3_PM_NOBAT 0xE0 /* PM bits: no battery usage */ |
#define PCF8523_M_TMR_A_FREQ 0x07 /* Mask off undef bits */ |
#define PCF8523_R_TMR_A_FREQ 0x10 /* Timer A frequency control */ |
#define PCF8523_R_TMR_CLKOUT 0x0F /* Timer and clockout control */ |
#define PCF8563_B_TMR_ENABLE 0x80 /* Enable countdown timer */ |
#define PCF85xx_B_CS1_STOP 0x20 /* Stop time incrementing bit */ |
#define PCF85xx_B_SECOND_OS 0x80 /* Oscillator Stopped bit */ |
#define PCF85xx_M_SECOND 0x7f /* Masks for all BCD time regs... */ |
#define PCF85xx_R_CS1 0x00 /* CS1 and CS2 control regs are in */ |
#define PCF85xx_R_CS2 0x01 /* the same location on all chips. */ |
#define WAITFLAGS (IIC_WAIT | IIC_RECURSIVE) |
anonymous enum |
__FBSDID | ( | "$FreeBSD$" | ) |
CTASSERT | ( | nitems(desc_strings) | = =TYPE_COUNT | ) |
DRIVER_MODULE | ( | nxprtc | , |
iicbus | , | ||
nxprtc_driver | , | ||
nxprtc_devclass | , | ||
NULL | , | ||
NULL | |||
) |
|
static |
Definition at line 364 of file nxprtc.c.
References nxprtc_softc::freqadj, PCF2127_R_AGING_OFFSET, and write_reg().
Referenced by pcf8523_start().
IICBUS_FDT_PNP_INFO | ( | compat_data | ) |
MODULE_DEPEND | ( | nxprtc | , |
iicbus | , | ||
IICBUS_MINVER | , | ||
IICBUS_PREFVER | , | ||
IICBUS_MAXVER | |||
) |
MODULE_VERSION | ( | nxprtc | , |
1 | |||
) |
|
static |
Definition at line 946 of file nxprtc.c.
References nxprtc_softc::busdev, nxprtc_softc::chiptype, nxprtc_softc::config_hook, nxprtc_softc::dev, dev, nxprtc_get_chiptype(), nxprtc_start(), PCF8523_R_SECOND, PCF8523_R_TMR_A_COUNT, PCF8563_R_SECOND, PCF8563_R_TMR_COUNT, nxprtc_softc::secaddr, nxprtc_softc::tmcaddr, TYPE_PCA2129, TYPE_PCA8565, TYPE_PCF2127, TYPE_PCF2129, TYPE_PCF8523, TYPE_PCF8563, and nxprtc_softc::use_timer.
|
static |
|
static |
Definition at line 890 of file nxprtc.c.
References nxprtc_softc::chiptype, compat_data, dev, nxprtc_compat_data::ocd_data, nxprtc_compat_data::ocd_str, TYPE_NONE, and TYPE_PCF8563.
Referenced by nxprtc_attach(), and nxprtc_probe().
|
static |
Definition at line 742 of file nxprtc.c.
References nxprtc_softc::busdev, nxprtc_softc::chiptype, time_regs::day, nxprtc_softc::dev, dev, nxprtc_softc::flags, time_regs::hour, IIC_WAIT, iicbus_release_bus(), iicbus_request_bus(), time_regs::min, time_regs::month, PCF8523_B_HOUR_PM, PCF8563_B_MONTH_C, PCF85xx_B_CS1_STOP, PCF85xx_B_SECOND_OS, PCF85xx_M_12HOUR, PCF85xx_M_24HOUR, PCF85xx_M_DAY, PCF85xx_M_MINUTE, PCF85xx_M_MONTH, PCF85xx_M_SECOND, PCF85xx_M_YEAR, PCF85xx_R_CS1, read_reg(), read_timeregs(), SC_F_CPOL, time_regs::sec, TMR_TICKS_SEC, TYPE_PCF8563, nxprtc_softc::use_ampm, and time_regs::year.
|
static |
Definition at line 927 of file nxprtc.c.
References nxprtc_softc::chiptype, desc_strings, dev, nxprtc_get_chiptype(), and TYPE_NONE.
|
static |
Definition at line 260 of file nxprtc.c.
References iic_msg::buf, iic_msg::flags, IIC_M_RD, IIC_M_WR, iicbus_transfer_excl(), iic_msg::len, and iic_msg::slave.
Referenced by pcf8523_start(), pcf8563_start(), read_reg(), and read_timeregs().
|
static |
Definition at line 808 of file nxprtc.c.
References nxprtc_softc::busdev, nxprtc_softc::chiptype, time_regs::day, nxprtc_softc::dev, dev, nxprtc_softc::flags, time_regs::hour, IIC_WAIT, iicbus_release_bus(), iicbus_request_bus(), time_regs::min, time_regs::month, PCF8523_B_HOUR_PM, pcf8523_battery_check(), PCF8563_B_MONTH_C, PCF85xx_B_CS1_STOP, PCF85xx_R_CS1, read_reg(), SC_F_CPOL, time_regs::sec, nxprtc_softc::tmcaddr, TMR_TICKS_SEC, TYPE_PCF8563, nxprtc_softc::use_ampm, time_regs::wday, write_reg(), write_timeregs(), and time_regs::year.
|
static |
Definition at line 682 of file nxprtc.c.
References nxprtc_softc::chiptype, nxprtc_softc::config_hook, nxprtc_softc::dev, dev, nxprtc_softc::is212x, pcf2127_start_timer(), pcf8523_start(), pcf8523_start_timer(), pcf8563_start(), pcf8563_start_timer(), TMR_TICKS_SEC, TYPE_PCA2129, TYPE_PCA8565, TYPE_PCF2127, TYPE_PCF2129, TYPE_PCF8523, TYPE_PCF8563, and nxprtc_softc::use_timer.
Referenced by nxprtc_attach().
|
static |
Definition at line 588 of file nxprtc.c.
References PCF2127_B_TMR_CD, PCF2127_M_TMR_CTRL, PCF2127_R_TMR_CTL, PCF8523_B_TMR_A_64HZ, read_reg(), nxprtc_softc::tmcaddr, and write_reg().
Referenced by nxprtc_start().
|
static |
Definition at line 388 of file nxprtc.c.
References nxprtc_softc::bat_time, nxprtc_softc::dev, PCF8523_B_CS3_BLF, PCF8523_B_CS3_PM_DSNBM, PCF8523_B_CS3_PM_STD, PCF8523_R_CS3, read_reg(), and write_reg().
Referenced by nxprtc_settime(), and pcf8523_start().
|
static |
Definition at line 439 of file nxprtc.c.
References nxprtc_softc::dev, nxprtc_softc::freqadj, freqadj_sysctl(), nxprtc_softc::is212x, nxprtc_readfrom(), PCF2127_B_TSOFF, PCF2127_R_AGING_OFFSET, PCF2127_R_TS_CTL, PCF2129_B_CLKOUT_HIGHZ, PCF2129_B_CLKOUT_OTPR, PCF2129_B_CS1_12HR, PCF8523_B_CLKOUT_HIGHZ, PCF8523_B_CS1_12HR, PCF8523_B_CS3_PM_NOBAT, pcf8523_battery_check(), PCF8523_M_CS3_PM, PCF8523_R_TMR_CLKOUT, PCF85xx_B_CS1_STOP, PCF85xx_B_SECOND_OS, PCF85xx_R_CS1, read_reg(), nxprtc_softc::use_ampm, WAITFLAGS, and write_reg().
Referenced by nxprtc_start().
|
static |
Definition at line 556 of file nxprtc.c.
References PCF8523_B_CLKOUT_HIGHZ, PCF8523_B_CLKOUT_TACD, PCF8523_B_TMR_A_64HZ, PCF8523_M_TMR_A_FREQ, PCF8523_R_TMR_A_FREQ, PCF8523_R_TMR_CLKOUT, read_reg(), nxprtc_softc::tmcaddr, and write_reg().
Referenced by nxprtc_start().
|
static |
Definition at line 615 of file nxprtc.c.
References nxprtc_softc::dev, nxprtc_readfrom(), PCF8563_R_CLKOUT, PCF85xx_B_CS1_STOP, PCF85xx_B_SECOND_OS, PCF85xx_R_CS1, WAITFLAGS, and write_reg().
Referenced by nxprtc_start().
|
static |
Definition at line 661 of file nxprtc.c.
References PCF8563_B_TMR_64HZ, PCF8563_B_TMR_ENABLE, PCF8563_M_TMR_CTRL, PCF8563_R_TMR_CTRL, read_reg(), nxprtc_softc::tmcaddr, and write_reg().
Referenced by nxprtc_start().
|
static |
Definition at line 293 of file nxprtc.c.
References nxprtc_softc::dev, nxprtc_readfrom(), val, and WAITFLAGS.
Referenced by nxprtc_gettime(), nxprtc_settime(), pcf2127_start_timer(), pcf8523_battery_check(), pcf8523_start(), pcf8523_start_timer(), pcf8563_start_timer(), and read_timeregs().
|
static |
Definition at line 307 of file nxprtc.c.
References nxprtc_softc::dev, nxprtc_readfrom(), read_reg(), time_regs::sec, nxprtc_softc::secaddr, nxprtc_softc::tmcaddr, TMR_TICKS_HALFSEC, TMR_TICKS_SEC, nxprtc_softc::use_timer, and WAITFLAGS.
Referenced by nxprtc_gettime().
|
static |
Definition at line 300 of file nxprtc.c.
References nxprtc_softc::dev, iicdev_writeto(), val, and WAITFLAGS.
Referenced by freqadj_sysctl(), nxprtc_settime(), pcf2127_start_timer(), pcf8523_battery_check(), pcf8523_start(), pcf8523_start_timer(), pcf8563_start(), and pcf8563_start_timer().
|
static |
Definition at line 356 of file nxprtc.c.
References nxprtc_softc::dev, iicdev_writeto(), nxprtc_softc::secaddr, and WAITFLAGS.
Referenced by nxprtc_settime().
|
static |
Definition at line 243 of file nxprtc.c.
Referenced by nxprtc_get_chiptype().
|
static |
Definition at line 185 of file nxprtc.c.
Referenced by nxprtc_probe().
|
static |
|
static |