| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: s390.c,v 1.6 2020/01/02 19:00:34 thorpej Exp $ */ | | 1 | /* $NetBSD: s390.c,v 1.7 2021/01/30 17:38:57 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2011 Frank Wille. | | 4 | * Copyright (c) 2011 Frank Wille. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Frank Wille for The NetBSD Project. | | 7 | * Written by Frank Wille for The NetBSD Project. |
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 |
| @@ -19,27 +19,27 @@ | | | @@ -19,27 +19,27 @@ |
19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
20 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 20 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 21 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | * POSSIBILITY OF SUCH DAMAGE. | | 28 | * POSSIBILITY OF SUCH DAMAGE. |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | __KERNEL_RCSID(0, "$NetBSD: s390.c,v 1.6 2020/01/02 19:00:34 thorpej Exp $"); | | 32 | __KERNEL_RCSID(0, "$NetBSD: s390.c,v 1.7 2021/01/30 17:38:57 thorpej Exp $"); |
33 | | | 33 | |
34 | #include <sys/param.h> | | 34 | #include <sys/param.h> |
35 | #include <sys/systm.h> | | 35 | #include <sys/systm.h> |
36 | #include <sys/device.h> | | 36 | #include <sys/device.h> |
37 | #include <sys/conf.h> | | 37 | #include <sys/conf.h> |
38 | | | 38 | |
39 | #include <dev/clock_subr.h> | | 39 | #include <dev/clock_subr.h> |
40 | | | 40 | |
41 | #include <dev/i2c/i2cvar.h> | | 41 | #include <dev/i2c/i2cvar.h> |
42 | #include <dev/i2c/s390reg.h> | | 42 | #include <dev/i2c/s390reg.h> |
43 | | | 43 | |
44 | struct s390rtc_softc { | | 44 | struct s390rtc_softc { |
45 | device_t sc_dev; | | 45 | device_t sc_dev; |
| @@ -52,33 +52,38 @@ static int s390rtc_match(device_t, cfdat | | | @@ -52,33 +52,38 @@ static int s390rtc_match(device_t, cfdat |
52 | static void s390rtc_attach(device_t, device_t, void *); | | 52 | static void s390rtc_attach(device_t, device_t, void *); |
53 | | | 53 | |
54 | CFATTACH_DECL_NEW(s390rtc, sizeof(struct s390rtc_softc), | | 54 | CFATTACH_DECL_NEW(s390rtc, sizeof(struct s390rtc_softc), |
55 | s390rtc_match, s390rtc_attach, NULL, NULL); | | 55 | s390rtc_match, s390rtc_attach, NULL, NULL); |
56 | | | 56 | |
57 | static int s390rtc_gettime_ymdhms(struct todr_chip_handle *, | | 57 | static int s390rtc_gettime_ymdhms(struct todr_chip_handle *, |
58 | struct clock_ymdhms *); | | 58 | struct clock_ymdhms *); |
59 | static int s390rtc_settime_ymdhms(struct todr_chip_handle *, | | 59 | static int s390rtc_settime_ymdhms(struct todr_chip_handle *, |
60 | struct clock_ymdhms *); | | 60 | struct clock_ymdhms *); |
61 | static int s390rtc_read(struct s390rtc_softc *, int, uint8_t *, size_t); | | 61 | static int s390rtc_read(struct s390rtc_softc *, int, uint8_t *, size_t); |
62 | static int s390rtc_write(struct s390rtc_softc *, int, uint8_t *, size_t); | | 62 | static int s390rtc_write(struct s390rtc_softc *, int, uint8_t *, size_t); |
63 | static uint8_t bitreverse(uint8_t); | | 63 | static uint8_t bitreverse(uint8_t); |
64 | | | 64 | |
| | | 65 | static const struct device_compatible_entry compat_data[] = { |
| | | 66 | { .compat = "sii,s35390a" }, |
| | | 67 | DEVICE_COMPAT_EOL |
| | | 68 | }; |
| | | 69 | |
65 | static int | | 70 | static int |
66 | s390rtc_match(device_t parent, cfdata_t cf, void *arg) | | 71 | s390rtc_match(device_t parent, cfdata_t cf, void *arg) |
67 | { | | 72 | { |
68 | struct i2c_attach_args *ia = arg; | | 73 | struct i2c_attach_args *ia = arg; |
69 | int match_result; | | 74 | int match_result; |
70 | | | 75 | |
71 | if (iic_use_direct_match(ia, cf, NULL, &match_result)) | | 76 | if (iic_use_direct_match(ia, cf, compat_data, &match_result)) |
72 | return match_result; | | 77 | return match_result; |
73 | | | 78 | |
74 | /* indirect config - check typical address */ | | 79 | /* indirect config - check typical address */ |
75 | if (ia->ia_addr == S390_ADDR) | | 80 | if (ia->ia_addr == S390_ADDR) |
76 | return I2C_MATCH_ADDRESS_ONLY; | | 81 | return I2C_MATCH_ADDRESS_ONLY; |
77 | | | 82 | |
78 | return 0; | | 83 | return 0; |
79 | } | | 84 | } |
80 | | | 85 | |
81 | static void | | 86 | static void |
82 | s390rtc_attach(device_t parent, device_t self, void *arg) | | 87 | s390rtc_attach(device_t parent, device_t self, void *arg) |
83 | { | | 88 | { |
84 | struct s390rtc_softc *sc = device_private(self); | | 89 | struct s390rtc_softc *sc = device_private(self); |