Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c Allow i2c addr wildcard matching. Use with care!
details: https://anonhg.NetBSD.org/src/rev/7cd46e9ae65b
branches: trunk
changeset: 789126:7cd46e9ae65b
user: soren <soren%NetBSD.org@localhost>
date: Wed Aug 07 19:38:45 2013 +0000
description:
Allow i2c addr wildcard matching. Use with care!
diffstat:
sys/dev/i2c/at24cxx.c | 6 +++---
sys/dev/i2c/dbcool_reg.h | 6 +++---
sys/dev/i2c/i2c.c | 21 +++++++++++++--------
sys/dev/i2c/lm75reg.h | 6 +++---
sys/dev/i2c/max6900reg.h | 4 ++--
sys/dev/i2c/pcf8583reg.h | 4 ++--
sys/dev/i2c/sdtemp_reg.h | 4 ++--
sys/dev/i2c/spdmem_i2c.c | 6 +++---
sys/dev/i2c/x1226reg.h | 4 ++--
9 files changed, 33 insertions(+), 28 deletions(-)
diffs (227 lines):
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/at24cxx.c
--- a/sys/dev/i2c/at24cxx.c Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/at24cxx.c Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: at24cxx.c,v 1.13 2013/02/08 15:14:11 jdc Exp $ */
+/* $NetBSD: at24cxx.c,v 1.14 2013/08/07 19:38:45 soren Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.13 2013/02/08 15:14:11 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.14 2013/08/07 19:38:45 soren Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -61,7 +61,7 @@
* larger than 512kb). Be sure to check the datasheet of your EEPROM
* because there's much variation between models.
*/
-#define AT24CXX_ADDRMASK 0x78
+#define AT24CXX_ADDRMASK 0x3f8
#define AT24CXX_ADDR 0x50
#define AT24CXX_WRITE_CYCLE_MS 10
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/dbcool_reg.h
--- a/sys/dev/i2c/dbcool_reg.h Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/dbcool_reg.h Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dbcool_reg.h,v 1.6 2011/03/11 18:38:52 pgoyette Exp $ */
+/* $NetBSD: dbcool_reg.h,v 1.7 2013/08/07 19:38:45 soren Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -37,9 +37,9 @@
#define DBCOOLREG_H
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dbcool_reg.h,v 1.6 2011/03/11 18:38:52 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbcool_reg.h,v 1.7 2013/08/07 19:38:45 soren Exp $");
-#define DBCOOL_ADDRMASK 0x7c
+#define DBCOOL_ADDRMASK 0x3fc
#define DBCOOL_ADDR 0x2c /* Some chips have multiple addrs */
/* The dBCool chip family register set */
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/i2c.c
--- a/sys/dev/i2c/i2c.c Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/i2c.c Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i2c.c,v 1.39 2013/02/03 16:28:51 jdc Exp $ */
+/* $NetBSD: i2c.c,v 1.40 2013/08/07 19:38:45 soren Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.39 2013/02/03 16:28:51 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.40 2013/08/07 19:38:45 soren Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -110,7 +110,6 @@
struct i2c_attach_args ia;
ia.ia_tag = sc->sc_tag;
- ia.ia_addr = cf->cf_loc[IICCF_ADDR];
ia.ia_size = cf->cf_loc[IICCF_SIZE];
ia.ia_type = sc->sc_type;
@@ -118,13 +117,19 @@
ia.ia_ncompat = 0;
ia.ia_compat = NULL;
- if (ia.ia_addr != (i2c_addr_t)-1 &&
- ia.ia_addr <= I2C_MAX_ADDR &&
- !sc->sc_devices[ia.ia_addr])
- if (config_match(parent, cf, &ia) > 0) {
+ for (ia.ia_addr = 0; ia.ia_addr <= I2C_MAX_ADDR; ia.ia_addr++) {
+ if (sc->sc_devices[ia.ia_addr] != NULL)
+ continue;
+
+ if (cf->cf_loc[IICCF_ADDR] != -1 &&
+ cf->cf_loc[IICCF_ADDR] != ia.ia_addr)
+ continue;
+
+ if (config_match(parent, cf, &ia) > 0)
sc->sc_devices[ia.ia_addr] =
config_attach(parent, cf, &ia, iic_print);
}
+
return 0;
}
@@ -138,7 +143,7 @@
if (sc->sc_devices[i] == child) {
sc->sc_devices[i] = NULL;
break;
- }
+ }
}
static int
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/lm75reg.h
--- a/sys/dev/i2c/lm75reg.h Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/lm75reg.h Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lm75reg.h,v 1.3 2006/05/17 00:10:54 kiyohara Exp $ */
+/* $NetBSD: lm75reg.h,v 1.4 2013/08/07 19:38:45 soren Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -43,9 +43,9 @@
*
* 100 1xxx
*/
-#define LM75_ADDRMASK 0x78
+#define LM75_ADDRMASK 0x3f8
#define LM75_ADDR 0x48
-#define LM77_ADDRMASK 0x7c
+#define LM77_ADDRMASK 0x3fc
#define LM77_ADDR 0x48
/*
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/max6900reg.h
--- a/sys/dev/i2c/max6900reg.h Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/max6900reg.h Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: max6900reg.h,v 1.2 2005/12/11 12:21:23 christos Exp $ */
+/* $NetBSD: max6900reg.h,v 1.3 2013/08/07 19:38:45 soren Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -43,7 +43,7 @@
*
* 101 0000
*/
-#define MAX6900_ADDRMASK 0x7f
+#define MAX6900_ADDRMASK 0x3ff
#define MAX6900_ADDR 0x50
/*
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/pcf8583reg.h
--- a/sys/dev/i2c/pcf8583reg.h Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/pcf8583reg.h Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcf8583reg.h,v 1.2 2005/12/11 12:21:23 christos Exp $ */
+/* $NetBSD: pcf8583reg.h,v 1.3 2013/08/07 19:38:45 soren Exp $ */
/*
* Ben Harris, 2000
@@ -20,7 +20,7 @@
*
* 101 0000
*/
-#define PCF8583_ADDRMASK 0x7f
+#define PCF8583_ADDRMASK 0x3ff
#define PCF8583_ADDR 0x50
#define PCF8583_REG_CSR 0x00
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/sdtemp_reg.h
--- a/sys/dev/i2c/sdtemp_reg.h Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/sdtemp_reg.h Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdtemp_reg.h,v 1.5 2010/07/12 03:39:05 pgoyette Exp $ */
+/* $NetBSD: sdtemp_reg.h,v 1.6 2013/08/07 19:38:45 soren Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
* Following definitions derived from JEDEC Standard 21-C section 4.7
* available at http://www.jedec.org/download/search/4_07R15.pdf
*/
-#define SDTEMP_ADDRMASK 0x78
+#define SDTEMP_ADDRMASK 0x3f8
#define SDTEMP_ADDR 0x18 /* I2C address 001 1xxx */
#define SDTEMP_REG_CAPABILITY 0x00
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/spdmem_i2c.c
--- a/sys/dev/i2c/spdmem_i2c.c Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/spdmem_i2c.c Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spdmem_i2c.c,v 1.7 2013/07/28 06:12:45 kiyohara Exp $ */
+/* $NetBSD: spdmem_i2c.c,v 1.8 2013/08/07 19:38:45 soren Exp $ */
/*
* Copyright (c) 2007 Nicolas Joly
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.7 2013/07/28 06:12:45 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.8 2013/08/07 19:38:45 soren Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -49,7 +49,7 @@
#include <dev/ic/spdmemvar.h>
/* Constants for matching i2c bus address */
-#define SPDMEM_I2C_ADDRMASK 0x78
+#define SPDMEM_I2C_ADDRMASK 0x3f8
#define SPDMEM_I2C_ADDR 0x50
struct spdmem_i2c_softc {
diff -r 29965c52995d -r 7cd46e9ae65b sys/dev/i2c/x1226reg.h
--- a/sys/dev/i2c/x1226reg.h Wed Aug 07 18:36:19 2013 +0000
+++ b/sys/dev/i2c/x1226reg.h Wed Aug 07 19:38:45 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: x1226reg.h,v 1.3 2005/12/11 12:21:23 christos Exp $ */
+/* $NetBSD: x1226reg.h,v 1.4 2013/08/07 19:38:45 soren Exp $ */
/*
* Copyright (c) 2003 Shigeyuki Fukushima.
@@ -47,7 +47,7 @@
*
* 110 1111
*/
-#define X1226_ADDRMASK 0x7f
+#define X1226_ADDRMASK 0x3ff
#define X1226_ADDR 0x6f
/* XICOR X1226 Device Identifier */
Home |
Main Index |
Thread Index |
Old Index