Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/thorpej-i2c-spi-conf]: src/sys/dev/spi Use spi_compatible_match().



details:   https://anonhg.NetBSD.org/src/rev/e3749bad4835
branches:  thorpej-i2c-spi-conf
changeset: 983381:e3749bad4835
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed May 19 03:34:11 2021 +0000

description:
Use spi_compatible_match().

XXX Should support the other variants of this device.

diffstat:

 sys/dev/spi/tmp121.c |  35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diffs (62 lines):

diff -r eb69e35f8589 -r e3749bad4835 sys/dev/spi/tmp121.c
--- a/sys/dev/spi/tmp121.c      Wed May 19 03:33:33 2021 +0000
+++ b/sys/dev/spi/tmp121.c      Wed May 19 03:34:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tmp121.c,v 1.5 2011/06/20 17:31:37 pgoyette Exp $ */
+/* $NetBSD: tmp121.c,v 1.5.72.1 2021/05/19 03:34:11 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.5 2011/06/20 17:31:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.5.72.1 2021/05/19 03:34:11 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -68,16 +68,39 @@
 CFATTACH_DECL_NEW(tmp121temp, sizeof(struct tmp121temp_softc),
     tmp121temp_match, tmp121temp_attach, NULL, NULL);
 
+static const struct device_compatible_entry compat_data[] = {
+       { .compat = "ti,tmp121" },
+       { .compat = "TMP00121" },
+
+#if 0  /* We should also add support for these: */
+       { .compat = "ti,tmp122" },
+
+       { .compat = "ti,lm70" },
+       { .compat = "LM000070" },
+
+       { .compat = "ti,lm71" },
+       { .compat = "LM000071" },
+
+       { .compat = "ti,lm74" },
+       { .compat = "LM000074" },
+#endif
+       DEVICE_COMPAT_EOL
+};
+
 static int
 tmp121temp_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct spi_attach_args *sa = aux;
+       int rv;
 
-       /* configure for 10MHz */
-       if (spi_configure(sa->sa_handle, SPI_MODE_0, 1000000))
-               return 0;
+       rv = spi_compatible_match(sa, cf, compat_data);
+       if (rv != 0) {
+               /* configure for 10MHz */
+               if (spi_configure(sa->sa_handle, SPI_MODE_0, 1000000))
+                       return 0;
+       }
 
-       return 1;
+       return rv;
 }
 
 static void



Home | Main Index | Thread Index | Old Index