summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2020-10-23 20:55:16 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2020-10-23 20:55:16 +0000
commitec59766c422cf18ad985e282ae63b61f9f14a358 (patch)
tree474fca3d6d1391da2f0d66e7a8fda36b507c0ebd /sys
parent03fc40bb913f49d5254fd620c7494232dccddaee (diff)
Add support for the Micro Crystal RV4162. This variant holds the
square wave frequency control bits in the Day Of Week register. To make sure we don't fudge with those bits, only reset those that hold the day and keep the rest as is. ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/i2c/m41t8x.c8
-rw-r--r--sys/dev/ic/m41t8xreg.h3
2 files changed, 7 insertions, 4 deletions
diff --git a/sys/dev/i2c/m41t8x.c b/sys/dev/i2c/m41t8x.c
index a0cea7100d3..fa9a14f6d76 100644
--- a/sys/dev/i2c/m41t8x.c
+++ b/sys/dev/i2c/m41t8x.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m41t8x.c,v 1.1 2020/09/30 22:23:41 patrick Exp $ */
+/* $OpenBSD: m41t8x.c,v 1.2 2020/10/23 20:55:15 patrick Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -56,7 +56,8 @@ m41t8xrtc_match(struct device *parent, void *vcf, void *aux)
{
struct i2c_attach_args *ia = (struct i2c_attach_args *)aux;
- if (strcmp(ia->ia_name, "st,m41t83") == 0)
+ if (strcmp(ia->ia_name, "st,m41t83") == 0 ||
+ strcmp(ia->ia_name, "microcrystal,rv4162") == 0)
return (1);
return (0);
@@ -137,7 +138,8 @@ m41t8xrtc_settime(struct todr_chip_handle *handle, struct timeval *tv)
if (dt.dt_year >= 2100)
data[M41T8X_HR] |= M41T8X_CB;
data[M41T8X_HR] |= TOBCD(dt.dt_hour);
- data[M41T8X_DOW] = TOBCD(dt.dt_wday + 1);
+ data[M41T8X_DOW] &= ~M41T8X_DOW_MASK;
+ data[M41T8X_DOW] |= TOBCD(dt.dt_wday + 1);
data[M41T8X_DAY] = TOBCD(dt.dt_day);
data[M41T8X_MON] = TOBCD(dt.dt_mon);
data[M41T8X_YEAR] = TOBCD(dt.dt_year % 100);
diff --git a/sys/dev/ic/m41t8xreg.h b/sys/dev/ic/m41t8xreg.h
index d767a8bb15b..5420260fd7c 100644
--- a/sys/dev/ic/m41t8xreg.h
+++ b/sys/dev/ic/m41t8xreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: m41t8xreg.h,v 1.2 2010/02/19 14:58:13 miod Exp $ */
+/* $OpenBSD: m41t8xreg.h,v 1.3 2020/10/23 20:55:15 patrick Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -40,6 +40,7 @@
#define M41T8X_CEB 0x80 /* century bit toggle enable */
#define M41T8X_CB 0x40 /* century bit */
#define M41T8X_DOW 0x04 /* day of week */
+#define M41T8X_DOW_MASK 0x07 /* day of week bits */
#define M41T8X_DAY 0x05 /* day of month */
#define M41T8X_MON 0x06 /* month */
#define M41T8X_YEAR 0x07 /* year */