From: kettenis Date: Sat, 15 Oct 2022 18:22:53 +0000 (+0000) Subject: Convert remaining I2C RTC drivers to use todr_attach(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=23c413af725e162520ced0da7ed18e4f885fca2e;p=openbsd Convert remaining I2C RTC drivers to use todr_attach(). These all get a quality of 1000 since these are supposed to be battery backed and almost certainly what the hardware designers want us to use. ok mglocker@, jsg@ --- diff --git a/sys/dev/i2c/abx80x.c b/sys/dev/i2c/abx80x.c index 80c51281efe..310d9bd1766 100644 --- a/sys/dev/i2c/abx80x.c +++ b/sys/dev/i2c/abx80x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: abx80x.c,v 1.7 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: abx80x.c,v 1.8 2022/10/15 18:22:53 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * Copyright (c) 2018 Patrick Wildt @@ -28,8 +28,6 @@ #include #endif -extern todr_chip_handle_t todr_handle; - #define ABX8XX_HTH 0x00 #define ABX8XX_SC 0x01 #define ABX8XX_MN 0x02 @@ -129,7 +127,8 @@ abcrtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = abcrtc_gettime; sc->sc_todr.todr_settime = abcrtc_settime; - todr_handle = &sc->sc_todr; + sc->sc_todr.todr_quality = 1000; + todr_attach(&sc->sc_todr); printf("\n"); } diff --git a/sys/dev/i2c/ds1307.c b/sys/dev/i2c/ds1307.c index 372a59d53bb..0e4cec7a808 100644 --- a/sys/dev/i2c/ds1307.c +++ b/sys/dev/i2c/ds1307.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ds1307.c,v 1.5 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: ds1307.c,v 1.6 2022/10/15 18:22:53 kettenis Exp $ */ /* * Copyright (c) 2016 Marcus Glocker @@ -84,8 +84,6 @@ struct cfdriver maxrtc_cd = { NULL, "maxrtc", DV_DULL }; -extern todr_chip_handle_t todr_handle; - /* * Functions. */ @@ -109,10 +107,6 @@ maxrtc_attach(struct device *parent, struct device *self, void *arg) sc->sc_tag = ia->ia_tag; sc->sc_addr = ia->ia_addr; - sc->sc_todr.cookie = sc; - sc->sc_todr.todr_gettime = maxrtc_gettime; - sc->sc_todr.todr_settime = maxrtc_settime; - sc->sc_todr.todr_setwen = NULL; if (maxrtc_enable_osc(sc) == -1) return; @@ -120,7 +114,11 @@ maxrtc_attach(struct device *parent, struct device *self, void *arg) if (maxrtc_set_24h_mode(sc) == -1) return; - todr_handle = &sc->sc_todr; + sc->sc_todr.cookie = sc; + sc->sc_todr.todr_gettime = maxrtc_gettime; + sc->sc_todr.todr_settime = maxrtc_settime; + sc->sc_todr.todr_quality = 1000; + todr_attach(&sc->sc_todr); } int diff --git a/sys/dev/i2c/ds3231.c b/sys/dev/i2c/ds3231.c index 47f0d140ac5..b80254c35ac 100644 --- a/sys/dev/i2c/ds3231.c +++ b/sys/dev/i2c/ds3231.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ds3231.c,v 1.2 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: ds3231.c,v 1.3 2022/10/15 18:22:53 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis * @@ -23,8 +23,6 @@ #include -extern todr_chip_handle_t todr_handle; - #define DS3231_SC 0x00 #define DS3231_MN 0x01 #define DS3231_HR 0x02 @@ -91,7 +89,8 @@ dsxrtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = dsxrtc_gettime; sc->sc_todr.todr_settime = dsxrtc_settime; - todr_handle = &sc->sc_todr; + sc->sc_todr.todr_quality = 1000; + todr_attach(&sc->sc_todr); printf("\n"); } diff --git a/sys/dev/i2c/isl1208.c b/sys/dev/i2c/isl1208.c index 87eda94afe3..f32b46a6cde 100644 --- a/sys/dev/i2c/isl1208.c +++ b/sys/dev/i2c/isl1208.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isl1208.c,v 1.4 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: isl1208.c,v 1.5 2022/10/15 18:22:53 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -23,8 +23,6 @@ #include -extern todr_chip_handle_t todr_handle; - #define ISL1208_SC 0x00 #define ISL1208_MN 0x01 #define ISL1208_HR 0x02 @@ -90,7 +88,8 @@ islrtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = islrtc_gettime; sc->sc_todr.todr_settime = islrtc_settime; - todr_handle = &sc->sc_todr; + sc->sc_todr.todr_quality = 1000; + todr_attach(&sc->sc_todr); printf("\n"); } diff --git a/sys/dev/i2c/mcp794xx.c b/sys/dev/i2c/mcp794xx.c index a1b9990f16b..a6a012fccbf 100644 --- a/sys/dev/i2c/mcp794xx.c +++ b/sys/dev/i2c/mcp794xx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mcp794xx.c,v 1.2 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: mcp794xx.c,v 1.3 2022/10/15 18:22:53 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * Copyright (c) 2018 Patrick Wildt @@ -24,8 +24,6 @@ #include -extern todr_chip_handle_t todr_handle; - #define MCP794XX_SC 0x00 #define MCP794XX_SC_ST (1 << 7) #define MCP794XX_MN 0x01 @@ -95,9 +93,10 @@ mcprtc_attach(struct device *parent, struct device *self, void *aux) sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = mcprtc_gettime; sc->sc_todr.todr_settime = mcprtc_settime; + sc->sc_todr.todr_quality = 1000; + todr_attach(&sc->sc_todr); printf("\n"); - todr_handle = &sc->sc_todr; } int