Author: jchandra
Date: Mon Dec 13 17:53:38 2010
New Revision: 216410
URL: http://svn.freebsd.org/changeset/base/216410

Log:
  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)

Modified:
  head/sys/mips/rmi/dev/iic/at24co2n.c
  head/sys/mips/rmi/dev/iic/ds1374u.c
  head/sys/mips/rmi/dev/iic/max6657.c

Modified: head/sys/mips/rmi/dev/iic/at24co2n.c
==============================================================================
--- head/sys/mips/rmi/dev/iic/at24co2n.c        Mon Dec 13 16:23:02 2010        
(r216409)
+++ head/sys/mips/rmi/dev/iic/at24co2n.c        Mon Dec 13 17:53:38 2010        
(r216410)
@@ -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_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[] = {

Modified: head/sys/mips/rmi/dev/iic/ds1374u.c
==============================================================================
--- head/sys/mips/rmi/dev/iic/ds1374u.c Mon Dec 13 16:23:02 2010        
(r216409)
+++ head/sys/mips/rmi/dev/iic/ds1374u.c Mon Dec 13 17:53:38 2010        
(r216410)
@@ -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);
-}
-
-static int 
-ds1374u_settime(device_t dev, struct timespec *ts)
-{
-       int i; 
-       int temp = 0; 
+       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;
 
-       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 tim
                ts->tv_nsec = 0;
        }
        return error;
-       return 0;
 }
 
 static device_method_t ds1374u_methods[] = {

Modified: head/sys/mips/rmi/dev/iic/max6657.c
==============================================================================
--- head/sys/mips/rmi/dev/iic/max6657.c Mon Dec 13 16:23:02 2010        
(r216409)
+++ head/sys/mips/rmi/dev/iic/max6657.c Mon Dec 13 17:53:38 2010        
(r216410)
@@ -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[] = {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to