Wed Dec 16 08:05:38 2015 UTC ()
Add direct configuration support via compatible names.


(jdc)
diff -r1.43 -r1.44 src/sys/dev/i2c/dbcool.c

cvs diff -r1.43 -r1.44 src/sys/dev/i2c/dbcool.c (expand / switch to unified diff)

--- src/sys/dev/i2c/dbcool.c 2015/04/23 23:23:00 1.43
+++ src/sys/dev/i2c/dbcool.c 2015/12/16 08:05:38 1.44
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dbcool.c,v 1.43 2015/04/23 23:23:00 pgoyette Exp $ */ 1/* $NetBSD: dbcool.c,v 1.44 2015/12/16 08:05:38 jdc Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Paul Goyette 8 * by Paul Goyette
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -40,27 +40,27 @@ @@ -40,27 +40,27 @@
40 * http://www.onsemi.com/pub/Collateral/ADT7466.PDF 40 * http://www.onsemi.com/pub/Collateral/ADT7466.PDF
41 * http://www.onsemi.com/pub/Collateral/ADT7467-D.PDF 41 * http://www.onsemi.com/pub/Collateral/ADT7467-D.PDF
42 * http://www.onsemi.com/pub/Collateral/ADT7468-D.PDF 42 * http://www.onsemi.com/pub/Collateral/ADT7468-D.PDF
43 * http://www.onsemi.com/pub/Collateral/ADT7473-D.PDF 43 * http://www.onsemi.com/pub/Collateral/ADT7473-D.PDF
44 * http://www.onsemi.com/pub/Collateral/ADT7475-D.PDF 44 * http://www.onsemi.com/pub/Collateral/ADT7475-D.PDF
45 * http://www.onsemi.com/pub/Collateral/ADT7476-D.PDF 45 * http://www.onsemi.com/pub/Collateral/ADT7476-D.PDF
46 * http://www.onsemi.com/pub/Collateral/ADT7490-D.PDF 46 * http://www.onsemi.com/pub/Collateral/ADT7490-D.PDF
47 * http://www.smsc.com/media/Downloads_Public/Data_Sheets/6d103s.pdf 47 * http://www.smsc.com/media/Downloads_Public/Data_Sheets/6d103s.pdf
48 * 48 *
49 * (URLs are correct as of October 5, 2008) 49 * (URLs are correct as of October 5, 2008)
50 */ 50 */
51 51
52#include <sys/cdefs.h> 52#include <sys/cdefs.h>
53__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.43 2015/04/23 23:23:00 pgoyette Exp $"); 53__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.44 2015/12/16 08:05:38 jdc Exp $");
54 54
55#include <sys/param.h> 55#include <sys/param.h>
56#include <sys/systm.h> 56#include <sys/systm.h>
57#include <sys/kernel.h> 57#include <sys/kernel.h>
58#include <sys/device.h> 58#include <sys/device.h>
59#include <sys/malloc.h> 59#include <sys/malloc.h>
60#include <sys/sysctl.h> 60#include <sys/sysctl.h>
61#include <sys/module.h> 61#include <sys/module.h>
62 62
63#include <dev/i2c/dbcool_var.h> 63#include <dev/i2c/dbcool_var.h>
64#include <dev/i2c/dbcool_reg.h> 64#include <dev/i2c/dbcool_reg.h>
65 65
66/* Config interface */ 66/* Config interface */
@@ -721,43 +721,54 @@ struct chip_id chip_table[] = { @@ -721,43 +721,54 @@ struct chip_id chip_table[] = {
721 { 0, 0, 0, NULL, NULL, 0, 0, NULL } 721 { 0, 0, 0, NULL, NULL, 0, 0, NULL }
722}; 722};
723 723
724static const char *behavior[] = { 724static const char *behavior[] = {
725 "remote1", "local", "remote2", "full-speed", 725 "remote1", "local", "remote2", "full-speed",
726 "disabled", "local+remote2","all-temps", "manual" 726 "disabled", "local+remote2","all-temps", "manual"
727}; 727};
728 728
729static char dbcool_cur_behav[16]; 729static char dbcool_cur_behav[16];
730 730
731CFATTACH_DECL_NEW(dbcool, sizeof(struct dbcool_softc), 731CFATTACH_DECL_NEW(dbcool, sizeof(struct dbcool_softc),
732 dbcool_match, dbcool_attach, dbcool_detach, NULL); 732 dbcool_match, dbcool_attach, dbcool_detach, NULL);
733 733
 734static const char * dbcool_compats[] = {
 735 "i2c-adm1031",
 736 NULL
 737};
734int 738int
735dbcool_match(device_t parent, cfdata_t cf, void *aux) 739dbcool_match(device_t parent, cfdata_t cf, void *aux)
736{ 740{
737 struct i2c_attach_args *ia = aux; 741 struct i2c_attach_args *ia = aux;
738 struct dbcool_chipset dc; 742 struct dbcool_chipset dc;
739 dc.dc_tag = ia->ia_tag; 743 dc.dc_tag = ia->ia_tag;
740 dc.dc_addr = ia->ia_addr; 744 dc.dc_addr = ia->ia_addr;
741 dc.dc_chip = NULL; 745 dc.dc_chip = NULL;
742 dc.dc_readreg = dbcool_readreg; 746 dc.dc_readreg = dbcool_readreg;
743 dc.dc_writereg = dbcool_writereg; 747 dc.dc_writereg = dbcool_writereg;
744 748
745 /* no probing if we attach to iic, but verify chip id and address */ 749 /* Direct config - match compats */
746 if ((ia->ia_addr & DBCOOL_ADDRMASK) != DBCOOL_ADDR) 750 if (ia->ia_name) {
747 return 0; 751 if (ia->ia_ncompat > 0) {
748 if (dbcool_chip_ident(&dc) >= 0) 752 if (iic_compat_match(ia, dbcool_compats))
749 return 1; 753 return 1;
750 754 }
 755 /* Indirect config - check address and chip ID */
 756 } else {
 757 if ((ia->ia_addr & DBCOOL_ADDRMASK) != DBCOOL_ADDR)
 758 return 0;
 759 if (dbcool_chip_ident(&dc) >= 0)
 760 return 1;
 761 }
751 return 0; 762 return 0;
752} 763}
753 764
754void 765void
755dbcool_attach(device_t parent, device_t self, void *aux) 766dbcool_attach(device_t parent, device_t self, void *aux)
756{ 767{
757 struct dbcool_softc *sc = device_private(self); 768 struct dbcool_softc *sc = device_private(self);
758 struct i2c_attach_args *args = aux; 769 struct i2c_attach_args *args = aux;
759 uint8_t ver; 770 uint8_t ver;
760 771
761 sc->sc_dc.dc_addr = args->ia_addr; 772 sc->sc_dc.dc_addr = args->ia_addr;
762 sc->sc_dc.dc_tag = args->ia_tag; 773 sc->sc_dc.dc_tag = args->ia_tag;
763 sc->sc_dc.dc_chip = NULL; 774 sc->sc_dc.dc_chip = NULL;