| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ds1307.c,v 1.22 2016/04/05 10:53:16 bouyer Exp $ */ | | 1 | /* $NetBSD: ds1307.c,v 1.23 2016/10/04 15:06:59 kiyohara Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2003 Wasabi Systems, Inc. | | 4 | * Copyright (c) 2003 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Steve C. Woodford and Jason R. Thorpe for Wasabi Systems, Inc. | | 7 | * Written by Steve C. Woodford and Jason R. Thorpe for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.22 2016/04/05 10:53:16 bouyer Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.23 2016/10/04 15:06:59 kiyohara Exp $"); |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/systm.h> | | 42 | #include <sys/systm.h> |
43 | #include <sys/device.h> | | 43 | #include <sys/device.h> |
44 | #include <sys/kernel.h> | | 44 | #include <sys/kernel.h> |
45 | #include <sys/fcntl.h> | | 45 | #include <sys/fcntl.h> |
46 | #include <sys/uio.h> | | 46 | #include <sys/uio.h> |
47 | #include <sys/conf.h> | | 47 | #include <sys/conf.h> |
48 | #include <sys/event.h> | | 48 | #include <sys/event.h> |
49 | | | 49 | |
50 | #include <dev/clock_subr.h> | | 50 | #include <dev/clock_subr.h> |
51 | | | 51 | |
52 | #include <dev/i2c/i2cvar.h> | | 52 | #include <dev/i2c/i2cvar.h> |
| @@ -73,26 +73,33 @@ static const struct dsrtc_model dsrtc_mo | | | @@ -73,26 +73,33 @@ static const struct dsrtc_model dsrtc_mo |
73 | .dm_ch_reg = DSXXXX_SECONDS, | | 73 | .dm_ch_reg = DSXXXX_SECONDS, |
74 | .dm_ch_value = DS1307_SECONDS_CH, | | 74 | .dm_ch_value = DS1307_SECONDS_CH, |
75 | .dm_rtc_start = DS1307_RTC_START, | | 75 | .dm_rtc_start = DS1307_RTC_START, |
76 | .dm_rtc_size = DS1307_RTC_SIZE, | | 76 | .dm_rtc_size = DS1307_RTC_SIZE, |
77 | .dm_nvram_start = DS1307_NVRAM_START, | | 77 | .dm_nvram_start = DS1307_NVRAM_START, |
78 | .dm_nvram_size = DS1307_NVRAM_SIZE, | | 78 | .dm_nvram_size = DS1307_NVRAM_SIZE, |
79 | .dm_flags = DSRTC_FLAG_BCD | DSRTC_FLAG_CLOCK_HOLD, | | 79 | .dm_flags = DSRTC_FLAG_BCD | DSRTC_FLAG_CLOCK_HOLD, |
80 | }, { | | 80 | }, { |
81 | .dm_model = 1339, | | 81 | .dm_model = 1339, |
82 | .dm_rtc_start = DS1339_RTC_START, | | 82 | .dm_rtc_start = DS1339_RTC_START, |
83 | .dm_rtc_size = DS1339_RTC_SIZE, | | 83 | .dm_rtc_size = DS1339_RTC_SIZE, |
84 | .dm_flags = DSRTC_FLAG_BCD, | | 84 | .dm_flags = DSRTC_FLAG_BCD, |
85 | }, { | | 85 | }, { |
| | | 86 | .dm_model = 1340, |
| | | 87 | .dm_ch_reg = DSXXXX_SECONDS, |
| | | 88 | .dm_ch_value = DS1340_SECONDS_EOSC, |
| | | 89 | .dm_rtc_start = DS1340_RTC_START, |
| | | 90 | .dm_rtc_size = DS1340_RTC_SIZE, |
| | | 91 | .dm_flags = DSRTC_FLAG_BCD, |
| | | 92 | }, { |
86 | .dm_model = 1672, | | 93 | .dm_model = 1672, |
87 | .dm_rtc_start = DS1672_RTC_START, | | 94 | .dm_rtc_start = DS1672_RTC_START, |
88 | .dm_rtc_size = DS1672_RTC_SIZE, | | 95 | .dm_rtc_size = DS1672_RTC_SIZE, |
89 | .dm_ch_reg = DS1672_CONTROL, | | 96 | .dm_ch_reg = DS1672_CONTROL, |
90 | .dm_ch_value = DS1672_CONTROL_CH, | | 97 | .dm_ch_value = DS1672_CONTROL_CH, |
91 | .dm_flags = 0, | | 98 | .dm_flags = 0, |
92 | }, { | | 99 | }, { |
93 | .dm_model = 3231, | | 100 | .dm_model = 3231, |
94 | .dm_rtc_start = DS3232_RTC_START, | | 101 | .dm_rtc_start = DS3232_RTC_START, |
95 | .dm_rtc_size = DS3232_RTC_SIZE, | | 102 | .dm_rtc_size = DS3232_RTC_SIZE, |
96 | /* | | 103 | /* |
97 | * XXX | | 104 | * XXX |
98 | * the DS3232 likely has the temperature sensor too but I can't | | 105 | * the DS3232 likely has the temperature sensor too but I can't |