diff options
author | 2020-09-30 22:23:40 +0000 | |
---|---|---|
committer | 2020-09-30 22:23:40 +0000 | |
commit | d714ed3db694a238d1e0a5018a7fb156af9527f3 (patch) | |
tree | ec329a4429e2542bc24dd017b8001b22df43564c | |
parent | Sync with libagentx (diff) | |
download | wireguard-openbsd-d714ed3db694a238d1e0a5018a7fb156af9527f3.tar.xz wireguard-openbsd-d714ed3db694a238d1e0a5018a7fb156af9527f3.zip |
Move mfokclock(4) from loongson to sys/dev/i2c so that it be used by more
platforms than just loongson. Rename it to mfokrtc(4) for consistency with
other RTC drivers. Make it match on st,m41t83, since that was the chip for
which the driver was written for. More compatible strings can be added for
each chip of the series verified to behave the same.
Discussed with kettenis@
Compile tested on loongson by kn@
Tested on loongson by and ok visa@
-rw-r--r-- | share/man/man4/Makefile | 6 | ||||
-rw-r--r-- | share/man/man4/man4.loongson/Makefile | 4 | ||||
-rw-r--r-- | share/man/man4/mfokrtc.4 (renamed from share/man/man4/man4.loongson/mfokclock.4) | 10 | ||||
-rw-r--r-- | sys/arch/arm64/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/arm64/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/arch/loongson/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/loongson/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/loongson/conf/files.loongson | 7 | ||||
-rw-r--r-- | sys/arch/loongson/dev/gdiumiic.c | 4 | ||||
-rw-r--r-- | sys/dev/i2c/files.i2c | 7 | ||||
-rw-r--r-- | sys/dev/i2c/m41t8x.c (renamed from sys/arch/loongson/dev/m41t8xclock.c) | 46 |
11 files changed, 51 insertions, 47 deletions
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 4a3df6b33b1..08b69a1f981 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.783 2020/09/15 18:38:51 mglocker Exp $ +# $OpenBSD: Makefile,v 1.784 2020/09/30 22:23:40 patrick Exp $ MAN= aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \ acpi.4 acpiac.4 acpials.4 acpiasus.4 acpibat.4 \ @@ -47,8 +47,8 @@ MAN= aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \ kate.4 kcov.4 km.4 ksmn.4 ksyms.4 kubsan.4 kue.4 lc.4 lge.4 lii.4 \ lisa.4 lm.4 lmenv.4 lmn.4 lmtemp.4 lo.4 lpt.4 lxtphy.4 luphy.4 \ maestro.4 mainbus.4 malo.4 maxds.4 maxrtc.4 maxtmp.4 mbg.4 \ - mcprtc.4 mcx.4 midi.4 mii.4 mfi.4 \ - mfii.4 mlphy.4 moscom.4 mos.4 mpe.4 mpath.4 mpi.4 mpii.4 \ + mcprtc.4 mcx.4 midi.4 mii.4 mfi.4 mfii.4 mfokrtc.4 \ + mlphy.4 moscom.4 mos.4 mpe.4 mpath.4 mpi.4 mpii.4 \ mpip.4 mpu.4 msk.4 mpw.4 msts.4 mtd.4 mtdphy.4 mtio.4 mue.4 \ multicast.4 mvclock.4 mvdog.4 mvgicp.4 mvgpio.4 mvicu.4 mviic.4 \ mvneta.4 mvpinctrl.4 mvpp.4 mvrng.4 mvrtc.4 mvspi.4 mvtemp.4 mvuart.4 \ diff --git a/share/man/man4/man4.loongson/Makefile b/share/man/man4/man4.loongson/Makefile index 6e133c04f62..96b011f4f2d 100644 --- a/share/man/man4/man4.loongson/Makefile +++ b/share/man/man4/man4.loongson/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.10 2016/11/17 15:06:16 visa Exp $ +# $OpenBSD: Makefile,v 1.11 2020/09/30 22:23:40 patrick Exp $ MAN= apm.4 autoconf.4 bonito.4 gdiumiic.4 glxclk.4 glxpcib.4 htb.4 intro.4 \ - leioc.4 mem.4 mfokclock.4 sisfb.4 smfb.4 stsec.4 voyager.4 ykbec.4 + leioc.4 mem.4 sisfb.4 smfb.4 stsec.4 voyager.4 ykbec.4 MANSUBDIR=loongson .include <bsd.prog.mk> diff --git a/share/man/man4/man4.loongson/mfokclock.4 b/share/man/man4/mfokrtc.4 index 69d122dfdf2..777d2902d7d 100644 --- a/share/man/man4/man4.loongson/mfokclock.4 +++ b/share/man/man4/mfokrtc.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mfokclock.4,v 1.2 2018/06/18 06:06:52 jmc Exp $ +.\" $OpenBSD: mfokrtc.4,v 1.1 2020/09/30 22:23:40 patrick Exp $ .\" .\" Copyright (c) 2010 Miodrag Vallat. .\" @@ -14,14 +14,14 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 18 2018 $ -.Dt MFOKCLOCK 4 loongson +.Dd $Mdocdate: September 30 2020 $ +.Dt MFOKRTC 4 .Os .Sh NAME -.Nm mfokclock +.Nm mfokrtc .Nd M41T8x real-time clock .Sh SYNOPSIS -.Cd "mfokclock* at iic? addr 0x68" +.Cd "mfokrtc* at iic? addr 0x68" .Sh DESCRIPTION The .Nm diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC index 00ddc2591b0..8f42d671d7d 100644 --- a/sys/arch/arm64/conf/GENERIC +++ b/sys/arch/arm64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.173 2020/07/31 12:47:43 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.174 2020/09/30 22:23:40 patrick Exp $ # # GENERIC machine description file # @@ -439,6 +439,7 @@ ipmi* at iic? # IPMI (SIIF) islrtc* at iic? # ISL1208 RTC maxrtc* at iic? # DS1307 RTC mcprtc* at iic? # MCP794XX RTC +mfokrtc* at iic? # M41T8X RTC pcamux* at iic? # PCA9548 multiplexer iic* at pcamux? pcfrtc* at iic? # PCF8523 RTC diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK index 56f024f7962..e77b88fc061 100644 --- a/sys/arch/arm64/conf/RAMDISK +++ b/sys/arch/arm64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.131 2020/06/25 12:44:09 patrick Exp $ +# $OpenBSD: RAMDISK,v 1.132 2020/09/30 22:23:41 patrick Exp $ # # GENERIC machine description file # @@ -313,6 +313,7 @@ fusbtc* at iic? # USB Type-C controller islrtc* at iic? # ISL1208 RTC maxrtc* at iic? # DS1307 RTC mcprtc* at iic? # MCP794XX RTC +mfokrtc* at iic? # M41T8X RTC pcfrtc* at iic? # PCF8523 RTC pcxrtc* at iic? # PCF8563 RTC rkpmic* at iic? # RK808 PMIC diff --git a/sys/arch/loongson/conf/GENERIC b/sys/arch/loongson/conf/GENERIC index 32f10728769..d8a84c570b8 100644 --- a/sys/arch/loongson/conf/GENERIC +++ b/sys/arch/loongson/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.61 2019/12/17 13:08:55 reyk Exp $ +# $OpenBSD: GENERIC,v 1.62 2020/09/30 22:23:41 patrick Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -74,7 +74,7 @@ gdiumiic0 at gpio0 offset 46 mask 0x03 # pins 46 and 47 iic0 at gdiumiic0 stsec0 at iic0 # ST7 Embedded Controller lmtemp0 at iic0 # National Semiconductor LM75 -mfokclock0 at iic0 # M41T8x todclock +mfokrtc0 at iic0 # M41T8x RTC #iic* at voyager? ohci* at voyager? smfb* at voyager? diff --git a/sys/arch/loongson/conf/RAMDISK b/sys/arch/loongson/conf/RAMDISK index 31514141754..cd5ee32b4b6 100644 --- a/sys/arch/loongson/conf/RAMDISK +++ b/sys/arch/loongson/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.31 2019/09/04 14:29:42 cheloha Exp $ +# $OpenBSD: RAMDISK,v 1.32 2020/09/30 22:23:41 patrick Exp $ machine loongson mips64 maxusers 4 @@ -61,7 +61,7 @@ gpio0 at voyager? gdiumiic0 at gpio0 offset 6 mask 0x81 # pins 6 and 13 gdiumiic0 at gpio0 offset 46 mask 0x03 # pins 46 and 47 iic0 at gdiumiic0 -mfokclock0 at iic0 # M41T8x todclock +mfokrtc0 at iic0 # M41T8x RTC ohci* at voyager? smfb* at voyager? wsdisplay* at smfb? diff --git a/sys/arch/loongson/conf/files.loongson b/sys/arch/loongson/conf/files.loongson index c28f4b5b5c3..6b3b2854ec1 100644 --- a/sys/arch/loongson/conf/files.loongson +++ b/sys/arch/loongson/conf/files.loongson @@ -1,4 +1,4 @@ -# $OpenBSD: files.loongson,v 1.25 2017/06/08 11:44:00 visa Exp $ +# $OpenBSD: files.loongson,v 1.26 2020/09/30 22:23:41 patrick Exp $ # Standard stanzas config(8) can't run without maxpartitions 16 @@ -102,11 +102,6 @@ device stsec attach stsec at i2c file arch/loongson/dev/stsec.c stsec -# Gdium M41T8x RTC -device mfokclock -attach mfokclock at i2c -file arch/loongson/dev/m41t8xclock.c mfokclock - # SM502 OHCI attach ohci at voyager with ohci_voyager file arch/loongson/dev/ohci_voyager.c ohci_voyager diff --git a/sys/arch/loongson/dev/gdiumiic.c b/sys/arch/loongson/dev/gdiumiic.c index eca4599b8f8..b8832134549 100644 --- a/sys/arch/loongson/dev/gdiumiic.c +++ b/sys/arch/loongson/dev/gdiumiic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gdiumiic.c,v 1.6 2013/04/19 23:44:34 miod Exp $ */ +/* $OpenBSD: gdiumiic.c,v 1.7 2020/09/30 22:23:41 patrick Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -374,6 +374,6 @@ gdiumiic_sensors_scan(struct device *iicdev, struct i2cbus_attach_args *iba, ia.ia_tag = iba->iba_tag; ia.ia_addr = 0x68; ia.ia_size = 1; - ia.ia_name = "mfokclock"; + ia.ia_name = "st,m41t83"; config_found(iicdev, &ia, iic_print); } diff --git a/sys/dev/i2c/files.i2c b/sys/dev/i2c/files.i2c index 2b6f0b0d027..d78a4cdb3f8 100644 --- a/sys/dev/i2c/files.i2c +++ b/sys/dev/i2c/files.i2c @@ -1,4 +1,4 @@ -# $OpenBSD: files.i2c,v 1.66 2020/06/18 18:05:00 kettenis Exp $ +# $OpenBSD: files.i2c,v 1.67 2020/09/30 22:23:41 patrick Exp $ # $NetBSD: files.i2c,v 1.3 2003/10/20 16:24:10 briggs Exp $ define i2c {[addr = -1], [size = -1]} @@ -248,3 +248,8 @@ file dev/i2c/ipmi_i2c.c ipmi_i2c device mcprtc attach mcprtc at i2c file dev/i2c/mcp794xx.c mcprtc + +# STMicroelectronics M41T8x RTC +device mfokrtc +attach mfokrtc at i2c +file dev/i2c/m41t8x.c mfokrtc diff --git a/sys/arch/loongson/dev/m41t8xclock.c b/sys/dev/i2c/m41t8x.c index c0f4fb01690..a0cea7100d3 100644 --- a/sys/arch/loongson/dev/m41t8xclock.c +++ b/sys/dev/i2c/m41t8x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m41t8xclock.c,v 1.4 2020/05/25 13:15:37 visa Exp $ */ +/* $OpenBSD: m41t8x.c,v 1.1 2020/09/30 22:23:41 patrick Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -29,59 +29,61 @@ #include <dev/i2c/i2cvar.h> #include <dev/ic/m41t8xreg.h> -struct m41t8xclock_softc { +struct m41t8xrtc_softc { struct device sc_dev; struct todr_chip_handle sc_todr; i2c_tag_t sc_tag; i2c_addr_t sc_addr; }; -int m41t8xclock_match(struct device *, void *, void *); -void m41t8xclock_attach(struct device *, struct device *, void *); +int m41t8xrtc_match(struct device *, void *, void *); +void m41t8xrtc_attach(struct device *, struct device *, void *); -const struct cfattach mfokclock_ca = { - sizeof(struct m41t8xclock_softc), - m41t8xclock_match, m41t8xclock_attach +const struct cfattach mfokrtc_ca = { + sizeof(struct m41t8xrtc_softc), + m41t8xrtc_match, m41t8xrtc_attach }; -struct cfdriver mfokclock_cd = { - NULL, "mfokclock", DV_DULL +struct cfdriver mfokrtc_cd = { + NULL, "mfokrtc", DV_DULL }; -int m41t8xclock_gettime(struct todr_chip_handle *, struct timeval *); -int m41t8xclock_settime(struct todr_chip_handle *, struct timeval *); +int m41t8xrtc_gettime(struct todr_chip_handle *, struct timeval *); +int m41t8xrtc_settime(struct todr_chip_handle *, struct timeval *); int -m41t8xclock_match(struct device *parent, void *vcf, void *aux) +m41t8xrtc_match(struct device *parent, void *vcf, void *aux) { struct i2c_attach_args *ia = (struct i2c_attach_args *)aux; - struct cfdata *cf = (struct cfdata *)vcf; - return strcmp(ia->ia_name, cf->cf_driver->cd_name) == 0; + if (strcmp(ia->ia_name, "st,m41t83") == 0) + return (1); + return (0); + } void -m41t8xclock_attach(struct device *parent, struct device *self, void *aux) +m41t8xrtc_attach(struct device *parent, struct device *self, void *aux) { - struct m41t8xclock_softc *sc = (struct m41t8xclock_softc *)self; + struct m41t8xrtc_softc *sc = (struct m41t8xrtc_softc *)self; struct i2c_attach_args *ia = (struct i2c_attach_args *)aux; sc->sc_tag = ia->ia_tag; sc->sc_addr = ia->ia_addr; sc->sc_todr.cookie = sc; - sc->sc_todr.todr_gettime = m41t8xclock_gettime; - sc->sc_todr.todr_settime = m41t8xclock_settime; + sc->sc_todr.todr_gettime = m41t8xrtc_gettime; + sc->sc_todr.todr_settime = m41t8xrtc_settime; todr_attach(&sc->sc_todr); printf("\n"); } int -m41t8xclock_gettime(struct todr_chip_handle *handle, struct timeval *tv) +m41t8xrtc_gettime(struct todr_chip_handle *handle, struct timeval *tv) { struct clock_ymdhms dt; - struct m41t8xclock_softc *sc = handle->cookie; + struct m41t8xrtc_softc *sc = handle->cookie; uint8_t regno, data[M41T8X_TOD_LENGTH]; int s; @@ -110,10 +112,10 @@ m41t8xclock_gettime(struct todr_chip_handle *handle, struct timeval *tv) } int -m41t8xclock_settime(struct todr_chip_handle *handle, struct timeval *tv) +m41t8xrtc_settime(struct todr_chip_handle *handle, struct timeval *tv) { struct clock_ymdhms dt; - struct m41t8xclock_softc *sc = handle->cookie; + struct m41t8xrtc_softc *sc = handle->cookie; uint8_t regno, data[M41T8X_TOD_LENGTH]; int s; |