Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add JEDEC TSE2004av support. OK'ed by pgoyette. If a device ...
details: https://anonhg.NetBSD.org/src/rev/5a6eda1d7a78
branches: trunk
changeset: 346691:5a6eda1d7a78
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Thu Jul 28 09:11:13 2016 +0000
description:
Add JEDEC TSE2004av support. OK'ed by pgoyette. If a device conforms
TES2004av, it can be used without adding new entry into the matching
table.
diffstat:
share/man/man4/sdtemp.4 | 6 ++--
sys/dev/i2c/sdtemp.c | 50 ++++++++++++++++++++++++++++++++++++++---------
sys/dev/i2c/sdtemp_reg.h | 8 ++++++-
3 files changed, 50 insertions(+), 14 deletions(-)
diffs (162 lines):
diff -r 591c4102234c -r 5a6eda1d7a78 share/man/man4/sdtemp.4
--- a/share/man/man4/sdtemp.4 Thu Jul 28 09:03:50 2016 +0000
+++ b/share/man/man4/sdtemp.4 Thu Jul 28 09:11:13 2016 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sdtemp.4,v 1.5 2016/07/26 07:33:30 msaitoh Exp $
+.\" $NetBSD: sdtemp.4,v 1.6 2016/07/28 09:11:14 msaitoh Exp $
.\"
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd July 26, 2016
+.Dd July 28, 2016
.Dt SDTEMP 4
.Os
.Sh NAME
@@ -61,7 +61,7 @@
.Pp
Chips supported by the
.Nm
-driver include:
+driver include TSE2004av compliant devices and:
.Pp
.Bl -bullet -offset indent
.It
diff -r 591c4102234c -r 5a6eda1d7a78 sys/dev/i2c/sdtemp.c
--- a/sys/dev/i2c/sdtemp.c Thu Jul 28 09:03:50 2016 +0000
+++ b/sys/dev/i2c/sdtemp.c Thu Jul 28 09:11:13 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdtemp.c,v 1.30 2016/07/27 09:11:44 msaitoh Exp $ */
+/* $NetBSD: sdtemp.c,v 1.31 2016/07/28 09:11:13 msaitoh Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.30 2016/07/27 09:11:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.31 2016/07/28 09:11:13 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -159,6 +159,12 @@
"Integrated Device Technology TS3000GB2" },
{ IDT_MANUFACTURER_ID, IDT_TS3001GB2_DEVICE_ID, IDT_TS3001GB2_MASK, CIDT,
"Integrated Device Technology TS3001GB2" },
+ /*
+ * Don't change the location of the following two entries. Device specific
+ * entry must be located at above.
+ */
+ { 0, TSE2004AV_ID, TSE2004AV_MASK, NULL,
+ "TSE2004av compliant device (generic driver)" },
{ 0, 0, 0, NULL, "Unknown" }
};
@@ -184,6 +190,10 @@
sdtemp_dev_table[i].sdtemp_devrev)
break;
}
+ /* Check TSE2004av */
+ if ((sdtemp_dev_table[i].sdtemp_mfg_id == 0)
+ && (SDTEMP_IS_TSE2004AV(devrev) == 0))
+ i++; /* Unknown */
return i;
}
@@ -192,7 +202,7 @@
sdtemp_match(device_t parent, cfdata_t cf, void *aux)
{
struct i2c_attach_args *ia = aux;
- uint16_t mfgid, devid;
+ uint16_t mfgid, devid, cap;
struct sdtemp_softc sc;
int i, error;
@@ -202,23 +212,32 @@
if ((ia->ia_addr & SDTEMP_ADDRMASK) != SDTEMP_ADDR)
return 0;
- /* Verify that we can read the manufacturer ID & Device ID */
+ /* Verify that we can read the manufacturer ID, Device ID and the capability */
iic_acquire_bus(sc.sc_tag, 0);
error = sdtemp_read_16(&sc, SDTEMP_REG_MFG_ID, &mfgid) |
- sdtemp_read_16(&sc, SDTEMP_REG_DEV_REV, &devid);
+ sdtemp_read_16(&sc, SDTEMP_REG_DEV_REV, &devid) |
+ sdtemp_read_16(&sc, SDTEMP_REG_CAPABILITY, &cap);
iic_release_bus(sc.sc_tag, 0);
if (error)
return 0;
i = sdtemp_lookup(mfgid, devid);
- if (sdtemp_dev_table[i].sdtemp_mfg_id == 0) {
+ if ((sdtemp_dev_table[i].sdtemp_mfg_id == 0) &&
+ (sdtemp_dev_table[i].sdtemp_devrev == 0)) {
aprint_debug("sdtemp: No match for mfg 0x%04x dev 0x%02x "
"rev 0x%02x at address 0x%02x\n", mfgid, devid >> 8,
devid & 0xff, sc.sc_address);
return 0;
}
+ /*
+ * Check by SDTEMP_IS_TSE2004AV() might not be enough, so check the alarm
+ * capability, too.
+ */
+ if ((cap & SDTEMP_CAP_HAS_ALARM) == 0)
+ return 0;
+
return 1;
}
@@ -249,10 +268,21 @@
aprint_naive(": Temp Sensor\n");
aprint_normal(": %s Temp Sensor\n", sdtemp_dev_table[i].sdtemp_desc);
- if (sdtemp_dev_table[i].sdtemp_mfg_id == 0)
- aprint_debug_dev(self,
- "mfg 0x%04x dev 0x%02x rev 0x%02x at addr 0x%02x\n",
- mfgid, devid >> 8, devid & 0xff, ia->ia_addr);
+ if (sdtemp_dev_table[i].sdtemp_mfg_id == 0) {
+ if (SDTEMP_IS_TSE2004AV(devid))
+ aprint_normal_dev(self, "TSE2004av compliant. "
+ "Manufacturer ID 0x%04hx, Device revision 0x%02x\n",
+ mfgid, devid & TSE2004AV_REV);
+ else {
+ aprint_error_dev(self,
+ "mfg 0x%04x dev 0x%02x rev 0x%02x at addr 0x%02x\n",
+ mfgid, devid >> 8, devid & 0xff, ia->ia_addr);
+ iic_release_bus(sc->sc_tag, 0);
+ aprint_error_dev(self, "It should no happen. "
+ "Why attach() found me?\n");
+ return;
+ }
+ }
error = sdtemp_read_16(sc, SDTEMP_REG_CAPABILITY, &sc->sc_capability);
aprint_debug_dev(self, "capability reg = %04x\n", sc->sc_capability);
diff -r 591c4102234c -r 5a6eda1d7a78 sys/dev/i2c/sdtemp_reg.h
--- a/sys/dev/i2c/sdtemp_reg.h Thu Jul 28 09:03:50 2016 +0000
+++ b/sys/dev/i2c/sdtemp_reg.h Thu Jul 28 09:11:13 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdtemp_reg.h,v 1.9 2016/07/26 07:30:16 msaitoh Exp $ */
+/* $NetBSD: sdtemp_reg.h,v 1.10 2016/07/28 09:11:13 msaitoh Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -95,6 +95,12 @@
* Devices known to conform to JEDEC JC42.4
*/
+/* TSE2004av definitions (JEDEC Standard No. 21-C Page 4.1.6) */
+#define TSE2004AV_ID 0x2200
+#define TSE2004AV_MASK 0xff00 /* ID is upper 8bits */
+#define TSE2004AV_REV 0x00ff /* Revision is lower 8bits */
+#define SDTEMP_IS_TSE2004AV(dev) (((dev) & TSE2004AV_MASK) == TSE2004AV_ID)
+
/* Atmel */
#define AT_MANUFACTURER_ID 0x001f
#define AT_30TS00_DEVICE_ID 0x8201 /* Also matches 002A and 002B */
Home |
Main Index |
Thread Index |
Old Index