Index: mcp980x.c
===================================================================
RCS file: /cvsroot/src/sys/dev/i2c/mcp980x.c,v
retrieving revision 1.1
diff -u -r1.1 mcp980x.c
--- mcp980x.c   6 May 2013 22:04:12 -0000       1.1
+++ mcp980x.c   27 May 2013 18:32:35 -0000
@@ -69,8 +69,9 @@
static int mcp980x_match(device_t, cfdata_t, void *);
static void mcp980x_attach(device_t, device_t, void *);

-/*static uint8_t mcp980x_reg_read_1(struct mcp980x_softc *sc, uint8_t);*/
+static uint8_t mcp980x_reg_read_1(struct mcp980x_softc *sc, uint8_t);
static uint16_t mcp980x_reg_read_2(struct mcp980x_softc *sc, uint8_t reg);
+static uint8_t mcp980x_reg_write_1(struct mcp980x_softc *sc, uint8_t reg, uint8_t value);

static uint32_t mcp980x_temperature(struct mcp980x_softc *sc);

@@ -105,6 +106,10 @@

       mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);

+       aprint_normal_dev(sc->sc_dev, "MCP980X_CONFIG %x\n", mcp980x_reg_read_1(sc, MCP980X_CONFIG));
+       mcp980x_reg_write_1(sc, MCP980X_CONFIG, 96);
+       aprint_normal_dev(sc->sc_dev, "MCP980X_CONFIG %x\n", mcp980x_reg_read_1(sc, MCP980X_CONFIG));
+
       mcp980x_envsys_register(sc);
}

@@ -132,21 +137,19 @@
       return be16toh(rv);
}

-/* Will need that later for reading config register. */
-/*
static uint8_t
mcp980x_reg_read_1(struct mcp980x_softc *sc, uint8_t reg)
{
-       uint8_t rv, wbuf[2];
+       uint8_t rv, wbuf;

       if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL) != 0) {
               aprint_error_dev(sc->sc_dev, "cannot acquire bus for read\n");
               return 0;
       }

-       wbuf[0] = reg;
+       wbuf = reg;

-       if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, wbuf,
+       if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, &wbuf,
           1, &rv, 1, I2C_F_POLL)) {
               aprint_error_dev(sc->sc_dev, "cannot execute operation\n");
               iic_release_bus(sc->sc_tag, I2C_F_POLL);
@@ -155,7 +158,18 @@
       iic_release_bus(sc->sc_tag, I2C_F_POLL);

       return rv;
-}*/
+}
+
+static uint8_t
+mcp980x_reg_write_1(struct mcp980x_softc *sc, uint8_t reg, uint8_t value)
+{
+       uint8_t cmdbuf[2];
+       cmdbuf[0] = reg;
+       cmdbuf[1] = value;
+
+       return iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
+           sc->sc_addr, cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL);
+}

/* Get temperature in microKelvins. */
static uint32_t