From a1b8555a256d86e34f41f9829dc7a4f2397a7fc8 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sun, 15 Jan 2006 22:03:18 +0000 Subject: Commit missing bits too: If we attach an lm(4) to isa(4) that is already attached to iic(4), disable the one attached to iic(4). idea from deraadt@ --- sys/dev/i2c/lm_i2c.c | 5 ++++- sys/dev/ic/lm78.c | 12 ++++++------ sys/dev/ic/lm78var.h | 7 +++++-- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/i2c/lm_i2c.c b/sys/dev/i2c/lm_i2c.c index bf826a5556d..8cf2b4a1071 100644 --- a/sys/dev/i2c/lm_i2c.c +++ b/sys/dev/i2c/lm_i2c.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm_i2c.c,v 1.7 2006/01/14 15:14:33 kettenis Exp $ */ +/* $OpenBSD: lm_i2c.c,v 1.8 2006/01/15 22:03:17 kettenis Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -80,6 +80,9 @@ lm_i2c_attach(struct device *parent, struct device *self, void *aux) sc->sc_lmsc.lm_readreg = lm_i2c_readreg; lm_attach(&sc->sc_lmsc); + /* Remember we attached to iic(4). */ + sc->sc_lmsc.sbusaddr = ia->ia_addr; + iic_acquire_bus(sc->sc_tag, 0); cmd = 0x4a; diff --git a/sys/dev/ic/lm78.c b/sys/dev/ic/lm78.c index 344aaae4f89..816a58216de 100644 --- a/sys/dev/ic/lm78.c +++ b/sys/dev/ic/lm78.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78.c,v 1.1 2006/01/14 15:14:33 kettenis Exp $ */ +/* $OpenBSD: lm78.c,v 1.2 2006/01/15 22:03:17 kettenis Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -375,7 +375,7 @@ def_match(struct lm_softc *sc) int wb_match(struct lm_softc *sc) { - int banksel, vendid, chipid, devid; + int banksel, vendid, devid; /* Read vendor ID */ banksel = sc->lm_readreg(sc, WB_BANKSEL); @@ -391,10 +391,10 @@ wb_match(struct lm_softc *sc) /* Read device/chip ID */ sc->lm_writereg(sc, WB_BANKSEL, WB_BANKSEL_B0); devid = sc->lm_readreg(sc, LM_CHIPID); - chipid = sc->lm_readreg(sc, WB_BANK0_CHIPID); + sc->chipid = sc->lm_readreg(sc, WB_BANK0_CHIPID); sc->lm_writereg(sc, WB_BANKSEL, banksel); - DPRINTF(("winbond chip id 0x%x\n", chipid)); - switch(chipid) { + DPRINTF(("winbond chip id 0x%x\n", sc->chipid)); + switch(sc->chipid) { case WB_CHIPID_W83627HF: printf(": W83627HF\n"); lm_setup_sensors(sc, w83627hf_sensors); @@ -446,7 +446,7 @@ wb_match(struct lm_softc *sc) } break; default: - printf(": unknown Winbond chip (ID 0x%x)\n", chipid); + printf(": unknown Winbond chip (ID 0x%x)\n", sc->chipid); /* Handle as a standard LM78. */ lm_setup_sensors(sc, lm78_sensors); sc->refresh_sensor_data = lm_refresh_sensor_data; diff --git a/sys/dev/ic/lm78var.h b/sys/dev/ic/lm78var.h index 862e7444e64..3eda4b42fb8 100644 --- a/sys/dev/ic/lm78var.h +++ b/sys/dev/ic/lm78var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lm78var.h,v 1.2 2006/01/14 20:05:06 kettenis Exp $ */ +/* $OpenBSD: lm78var.h,v 1.3 2006/01/15 22:03:17 kettenis Exp $ */ /* * Copyright (c) 2005, 2006 Mark Kettenis @@ -128,7 +128,7 @@ struct lm_sensor { }; struct lm_softc { - struct device sc_dev; + struct device sc_dev; struct sensor sensors[WB_MAX_SENSORS]; struct lm_sensor *lm_sensors; @@ -137,6 +137,9 @@ struct lm_softc { u_int8_t (*lm_readreg)(struct lm_softc *, int); void (*lm_writereg)(struct lm_softc *, int, int); + + u_int8_t sbusaddr; + u_int8_t chipid; }; void lm_attach(struct lm_softc *); -- cgit v1.2.3