aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJayachandran C. <jchandra@FreeBSD.org>2010-12-13 17:53:38 +0000
committerJayachandran C. <jchandra@FreeBSD.org>2010-12-13 17:53:38 +0000
commitd0beb2c412502173fd12a375d77cf60c6152ac97 (patch)
treebba0a1a370bbe35602a3465dbb7f86d71b47587c /sys
parentcab6e6e1fb36d6f38fa080695f331e7bb1ff8e0a (diff)
downloadsrc-d0beb2c412502173fd12a375d77cf60c6152ac97.tar.gz
src-d0beb2c412502173fd12a375d77cf60c6152ac97.zip
Updates for I2C devices on XLR engg boards.
- ds1374u : use multi-byte write. - at24co2n, max6657: remove mutex, iicbus has the necessary locking. Submitted by: Sreekanth M. S. (kanthms at netlogicmicro com)
Notes
Notes: svn path=/head/; revision=216410
Diffstat (limited to 'sys')
-rw-r--r--sys/mips/rmi/dev/iic/at24co2n.c5
-rw-r--r--sys/mips/rmi/dev/iic/ds1374u.c35
-rw-r--r--sys/mips/rmi/dev/iic/max6657.c4
3 files changed, 10 insertions, 34 deletions
diff --git a/sys/mips/rmi/dev/iic/at24co2n.c b/sys/mips/rmi/dev/iic/at24co2n.c
index fe9c1c4ddf9c..19b97388faa6 100644
--- a/sys/mips/rmi/dev/iic/at24co2n.c
+++ b/sys/mips/rmi/dev/iic/at24co2n.c
@@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$");
struct at24co2n_softc {
uint32_t sc_addr;
device_t sc_dev;
- struct mtx sc_mtx;
uint8_t sc_mac_addr[6];
};
@@ -103,8 +102,6 @@ at24co2n_attach(device_t dev)
sc->sc_dev = dev;
sc->sc_addr = iicbus_get_addr(dev);
- mtx_init(&sc->sc_mtx, "eeprom", "eeprom", MTX_DEF);
-
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"eeprom-mac", CTLTYPE_STRING | CTLFLAG_RD, sc, 0,
at24co2n_mac_sysctl, "A", "mac address");
@@ -121,9 +118,7 @@ at24co2n_read_mac(struct at24co2n_softc *sc)
{ sc->sc_addr, IIC_M_RD, 6, sc->sc_mac_addr},
};
- mtx_lock(&sc->sc_mtx);
iicbus_transfer(sc->sc_dev, msgs, 2);
- mtx_unlock(&sc->sc_mtx);
}
static device_method_t at24co2n_methods[] = {
diff --git a/sys/mips/rmi/dev/iic/ds1374u.c b/sys/mips/rmi/dev/iic/ds1374u.c
index f47e9666bf18..0c0b8236b170 100644
--- a/sys/mips/rmi/dev/iic/ds1374u.c
+++ b/sys/mips/rmi/dev/iic/ds1374u.c
@@ -85,36 +85,22 @@ ds1374u_attach(device_t dev)
return (0);
}
-
-static int
-ds1374u_write(device_t dev, int reg, uint8_t val)
+static int
+ds1374u_settime(device_t dev, struct timespec *ts)
{
- uint8_t data[2];
+ /* NB: register pointer precedes actual data */
+ uint8_t data[5] = { DS1374_RTC_COUNTER };
struct ds1374u_softc *sc = device_get_softc(dev);
struct iic_msg msgs[1] = {
- { sc->sc_addr, IIC_M_WR, 2, data },
+ { sc->sc_addr, IIC_M_WR, 5, data },
};
- data[0] = reg;
- data[1] = val;
- if (iicbus_transfer(dev, msgs, 1) == 0)
- return (0);
- else
- return (-1);
-}
+ data[1] = (ts->tv_sec >> 0) & 0xff;
+ data[2] = (ts->tv_sec >> 8) & 0xff;
+ data[3] = (ts->tv_sec >> 16) & 0xff;
+ data[4] = (ts->tv_sec >> 24) & 0xff;
-static int
-ds1374u_settime(device_t dev, struct timespec *ts)
-{
- int i;
- int temp = 0;
-
- for (i = 0; i < 4; i++) {
- temp = (ts->tv_sec >> (8*i)) & 0xff;
- if (ds1374u_write(dev, DS1374_RTC_COUNTER+i, temp)!=0)
- return (-1);
- }
- return 0;
+ return iicbus_transfer(dev, msgs, 1);
}
static int
@@ -137,7 +123,6 @@ ds1374u_gettime(device_t dev, struct timespec *ts)
ts->tv_nsec = 0;
}
return error;
- return 0;
}
static device_method_t ds1374u_methods[] = {
diff --git a/sys/mips/rmi/dev/iic/max6657.c b/sys/mips/rmi/dev/iic/max6657.c
index 81912653ed22..8d7006f66c03 100644
--- a/sys/mips/rmi/dev/iic/max6657.c
+++ b/sys/mips/rmi/dev/iic/max6657.c
@@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
struct max6657_softc {
uint32_t sc_addr;
device_t sc_dev;
- struct mtx sc_mtx;
int sc_curtemp;
int sc_lastupdate; /* in ticks */
};
@@ -101,7 +100,6 @@ max6657_attach(device_t dev)
}
sc->sc_dev = dev;
sc->sc_addr = iicbus_get_addr(dev);
- mtx_init(&sc->sc_mtx, "max6657", "max6657", MTX_DEF);
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"temp", CTLTYPE_INT | CTLFLAG_RD, sc, 0,
@@ -132,7 +130,6 @@ max6657_update(struct max6657_softc *sc)
{
int v;
- mtx_lock(&sc->sc_mtx);
/* NB: no point in updating any faster than the chip */
if (ticks - sc->sc_lastupdate > hz) {
v = max6657_read(sc->sc_dev, sc->sc_addr, MAX6657_EXT_TEMP);
@@ -140,7 +137,6 @@ max6657_update(struct max6657_softc *sc)
sc->sc_curtemp = v;
sc->sc_lastupdate = ticks;
}
- mtx_unlock(&sc->sc_mtx);
}
static device_method_t max6657_methods[] = {