Sat Jan 30 17:38:28 2021 UTC ()
Add standard compat strings from the Device Tree bindings.


(thorpej)
diff -r1.16 -r1.17 src/sys/dev/i2c/rs5c372.c

cvs diff -r1.16 -r1.17 src/sys/dev/i2c/rs5c372.c (expand / switch to unified diff)

--- src/sys/dev/i2c/rs5c372.c 2020/01/02 17:17:36 1.16
+++ src/sys/dev/i2c/rs5c372.c 2021/01/30 17:38:27 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rs5c372.c,v 1.16 2020/01/02 17:17:36 thorpej Exp $ */ 1/* $NetBSD: rs5c372.c,v 1.17 2021/01/30 17:38:27 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (C) 2005 NONAKA Kimihiro <nonaka@netbsd.org> 4 * Copyright (C) 2005 NONAKA Kimihiro <nonaka@netbsd.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: rs5c372.c,v 1.16 2020/01/02 17:17:36 thorpej Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: rs5c372.c,v 1.17 2021/01/30 17:38:27 thorpej Exp $");
30 30
31#include <sys/param.h> 31#include <sys/param.h>
32#include <sys/systm.h> 32#include <sys/systm.h>
33#include <sys/device.h> 33#include <sys/device.h>
34#include <sys/kernel.h> 34#include <sys/kernel.h>
35#include <sys/fcntl.h> 35#include <sys/fcntl.h>
36#include <sys/uio.h> 36#include <sys/uio.h>
37#include <sys/conf.h> 37#include <sys/conf.h>
38#include <sys/event.h> 38#include <sys/event.h>
39 39
40#include <dev/clock_subr.h> 40#include <dev/clock_subr.h>
41 41
42#include <dev/i2c/i2cvar.h> 42#include <dev/i2c/i2cvar.h>
@@ -51,33 +51,39 @@ struct rs5c372rtc_softc { @@ -51,33 +51,39 @@ struct rs5c372rtc_softc {
51 51
52static int rs5c372rtc_match(device_t, cfdata_t, void *); 52static int rs5c372rtc_match(device_t, cfdata_t, void *);
53static void rs5c372rtc_attach(device_t, device_t, void *); 53static void rs5c372rtc_attach(device_t, device_t, void *);
54 54
55CFATTACH_DECL_NEW(rs5c372rtc, sizeof(struct rs5c372rtc_softc), 55CFATTACH_DECL_NEW(rs5c372rtc, sizeof(struct rs5c372rtc_softc),
56 rs5c372rtc_match, rs5c372rtc_attach, NULL, NULL); 56 rs5c372rtc_match, rs5c372rtc_attach, NULL, NULL);
57 57
58static int rs5c372rtc_reg_write(struct rs5c372rtc_softc *, int, uint8_t); 58static int rs5c372rtc_reg_write(struct rs5c372rtc_softc *, int, uint8_t);
59static int rs5c372rtc_clock_read(struct rs5c372rtc_softc *, struct clock_ymdhms *); 59static int rs5c372rtc_clock_read(struct rs5c372rtc_softc *, struct clock_ymdhms *);
60static int rs5c372rtc_clock_write(struct rs5c372rtc_softc *, struct clock_ymdhms *); 60static int rs5c372rtc_clock_write(struct rs5c372rtc_softc *, struct clock_ymdhms *);
61static int rs5c372rtc_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *); 61static int rs5c372rtc_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
62static int rs5c372rtc_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *); 62static int rs5c372rtc_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
63 63
 64static const struct device_compatible_entry compat_data[] = {
 65 { .compat = "ricoh,rs5c372a" },
 66 { .compat = "ricoh,rs5c372b" },
 67 DEVICE_COMPAT_EOL
 68};
 69
64static int 70static int
65rs5c372rtc_match(device_t parent, cfdata_t cf, void *arg) 71rs5c372rtc_match(device_t parent, cfdata_t cf, void *arg)
66{ 72{
67 struct i2c_attach_args *ia = arg; 73 struct i2c_attach_args *ia = arg;
68 int match_result; 74 int match_result;
69 75
70 if (iic_use_direct_match(ia, cf, NULL, &match_result)) 76 if (iic_use_direct_match(ia, cf, compat_data, &match_result))
71 return match_result; 77 return match_result;
72 78
73 /* indirect config - check typical address */ 79 /* indirect config - check typical address */
74 if (ia->ia_addr == RS5C372_ADDR) 80 if (ia->ia_addr == RS5C372_ADDR)
75 return I2C_MATCH_ADDRESS_ONLY; 81 return I2C_MATCH_ADDRESS_ONLY;
76 82
77 return 0; 83 return 0;
78} 84}
79 85
80static void 86static void
81rs5c372rtc_attach(device_t parent, device_t self, void *arg) 87rs5c372rtc_attach(device_t parent, device_t self, void *arg)
82{ 88{
83 struct rs5c372rtc_softc *sc = device_private(self); 89 struct rs5c372rtc_softc *sc = device_private(self);