sdtemp.c revision 1.2 1 /* $NetBSD: sdtemp.c,v 1.2 2009/05/19 23:43:27 pgoyette Exp $ */
2
3 /*
4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Paul Goyette.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.2 2009/05/19 23:43:27 pgoyette Exp $");
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/kmem.h>
38 #include <sys/device.h>
39 #include <sys/kernel.h>
40 #include <sys/endian.h>
41 #include <sys/sysctl.h>
42
43 #include <dev/sysmon/sysmonvar.h>
44
45 #include <dev/i2c/i2cvar.h>
46 #include <dev/i2c/sdtemp_reg.h>
47
48 struct sdtemp_softc {
49 device_t sc_dev;
50 i2c_tag_t sc_tag;
51 int sc_address;
52
53 struct sysmon_envsys *sc_sme;
54 envsys_data_t *sc_sensor;
55 int sc_resolution;
56 uint16_t sc_capability;
57 uint16_t sc_low_lim, sc_high_lim, sc_crit_lim;
58 };
59
60 static int sdtemp_match(device_t, cfdata_t, void *);
61 static void sdtemp_attach(device_t, device_t, void *);
62
63 CFATTACH_DECL_NEW(sdtemp, sizeof(struct sdtemp_softc),
64 sdtemp_match, sdtemp_attach, NULL, NULL);
65
66 static void sdtemp_refresh(struct sysmon_envsys *, envsys_data_t *);
67 #ifdef NOT_YET
68 static int sdtemp_read_8(struct sdtemp_softc *, uint8_t, uint8_t *);
69 static int sdtemp_write_8(struct sdtemp_softc *, uint8_t, uint8_t);
70 #endif /* NOT YET */
71 static int sdtemp_read_16(struct sdtemp_softc *, uint8_t, uint16_t *);
72 static int sdtemp_write_16(struct sdtemp_softc *, uint8_t, uint16_t);
73 static uint32_t sdtemp_decode_temp(struct sdtemp_softc *, uint16_t);
74 static void sdtemp_set_thresh(struct sdtemp_softc *, int, uint16_t);
75 static bool sdtemp_pmf_suspend(device_t PMF_FN_PROTO);
76 static bool sdtemp_pmf_resume(device_t PMF_FN_PROTO);
77
78 SYSCTL_SETUP_PROTO(sysctl_sdtemp_setup);
79 static int sdtemp_sysctl_helper(SYSCTLFN_PROTO);
80
81 struct sdtemp_dev_entry {
82 const uint16_t sdtemp_mfg_id;
83 const uint8_t sdtemp_dev_id;
84 const uint8_t sdtemp_rev_id;
85 const uint8_t sdtemp_resolution;
86 const char *sdtemp_desc;
87 };
88
89 /* sysctl stuff */
90 static int hw_node = CTL_EOL;
91
92 /*
93 * List of devices known to conform to JEDEC JC42.4
94 *
95 * NOTE: A non-negative value for resolution indicates that the sensor
96 * resolution is fixed at that number of fractional bits; a negative
97 * value indicates that the sensor needs to be configured. In either
98 * case, trip-point registers are fixed at two-bit (0.25C) resolution.
99 */
100 static const struct sdtemp_dev_entry
101 sdtemp_dev_table[] = {
102 { MAXIM_MANUFACTURER_ID, MAX_6604_DEVICE_ID, 0xff, 3,
103 "Maxim MAX604" },
104 { MCP_MANUFACTURER_ID, MCP_9805_DEVICE_ID, 0xff, 2,
105 "Microchip Tech MCP9805" },
106 { MCP_MANUFACTURER_ID, MCP_98242_DEVICE_ID, 0xff, -4,
107 "Microchip Tech MCP98242" },
108 { ADT_MANUFACTURER_ID, ADT_7408_DEVICE_ID, 0xff, 4,
109 "Analog Devices ADT7408" },
110 { NXP_MANUFACTURER_ID, NXP_SE97_DEVICE_ID, 0xff, 3,
111 "NXP Semiconductors SE97/SE98" },
112 { STTS_MANUFACTURER_ID, STTS_424E02_DEVICE_ID, 0x00, 2,
113 "STmicroelectronics STTS424E02-DA" },
114 { STTS_MANUFACTURER_ID, STTS_424E02_DEVICE_ID, 0x01, 2,
115 "STmicroelectronics STTS424E02-DN" },
116 { CAT_MANUFACTURER_ID, CAT_34TS02_DEVICE_ID, 0xff, 4,
117 "Catalyst CAT34TS02/CAT6095" },
118 { 0, 0, 0, 2, "Unknown" }
119 };
120
121 static int
122 sdtemp_lookup(uint16_t mfg, uint16_t dev, uint16_t rev)
123 {
124 int i;
125
126 for (i = 0; sdtemp_dev_table[i].sdtemp_mfg_id; i++)
127 if (sdtemp_dev_table[i].sdtemp_mfg_id == mfg &&
128 sdtemp_dev_table[i].sdtemp_dev_id == dev &&
129 (sdtemp_dev_table[i].sdtemp_rev_id == 0xff ||
130 sdtemp_dev_table[i].sdtemp_rev_id == rev))
131 break;
132
133 return i;
134 }
135
136 static int
137 sdtemp_match(device_t parent, cfdata_t cf, void *aux)
138 {
139 struct i2c_attach_args *ia = aux;
140 uint16_t mfgid, devid;
141 struct sdtemp_softc sc;
142 int i, error;
143
144 sc.sc_tag = ia->ia_tag;
145 sc.sc_address = ia->ia_addr;
146
147 if ((ia->ia_addr & SDTEMP_ADDRMASK) != SDTEMP_ADDR)
148 return 0;
149
150 /* Verify that we can read the manufacturer ID & Device ID */
151 iic_acquire_bus(sc.sc_tag, 0);
152 error = sdtemp_read_16(&sc, SDTEMP_REG_MFG_ID, &mfgid) |
153 sdtemp_read_16(&sc, SDTEMP_REG_DEV_REV, &devid);
154 iic_release_bus(sc.sc_tag, 0);
155
156 if (error)
157 return 0;
158
159 i = sdtemp_lookup(mfgid, devid >> 8, devid & 0xff);
160 if (sdtemp_dev_table[i].sdtemp_mfg_id == 0) {
161 aprint_debug("sdtemp: No match for mfg 0x%04x dev 0x%02x "
162 "rev 0x%02x at address 0x%02x\n", mfgid, devid >> 8,
163 devid & 0xff, sc.sc_address);
164 return 0;
165 }
166
167 return 1;
168 }
169
170 static void
171 sdtemp_attach(device_t parent, device_t self, void *aux)
172 {
173 struct sdtemp_softc *sc = device_private(self);
174 struct i2c_attach_args *ia = aux;
175 const struct sysctlnode *node = NULL;
176 uint16_t mfgid, devid;
177 int32_t dev_sysctl_num;
178 int i, error;
179
180 sc->sc_tag = ia->ia_tag;
181 sc->sc_address = ia->ia_addr;
182 sc->sc_dev = self;
183
184 iic_acquire_bus(sc->sc_tag, 0);
185 if ((error = sdtemp_read_16(sc, SDTEMP_REG_MFG_ID, &mfgid)) != 0 ||
186 (error = sdtemp_read_16(sc, SDTEMP_REG_DEV_REV, &devid)) != 0) {
187 iic_release_bus(sc->sc_tag, I2C_F_POLL);
188 aprint_error(": attach error %d\n", error);
189 return;
190 }
191 i = sdtemp_lookup(mfgid, devid >> 8, devid & 0xff);
192 sc->sc_resolution =
193 sdtemp_dev_table[i].sdtemp_resolution;
194
195 aprint_naive(": Temp Sensor\n");
196 aprint_normal(": %s Temp Sensor\n", sdtemp_dev_table[i].sdtemp_desc);
197
198 if (sdtemp_dev_table[i].sdtemp_mfg_id == 0)
199 aprint_debug_dev(self,
200 "mfg 0x%04x dev 0x%02x rev 0x%02x at addr 0x%02x\n",
201 mfgid, devid >> 8, devid & 0xff, ia->ia_addr);
202
203 /*
204 * Alarm capability is required; if not present, this is likely
205 * not a real sdtemp device.
206 */
207 error = sdtemp_read_16(sc, SDTEMP_REG_CAPABILITY, &sc->sc_capability);
208 if (error != 0 || (sc->sc_capability & SDTEMP_CAP_HAS_ALARM) == 0) {
209 iic_release_bus(sc->sc_tag, 0);
210 aprint_error_dev(self,
211 "required alarm capability not present!\n");
212 return;
213 }
214 /* Set the configuration to defaults. */
215 error = sdtemp_write_16(sc, SDTEMP_REG_CONFIG, 0);
216 if (error != 0) {
217 iic_release_bus(sc->sc_tag, 0);
218 aprint_error_dev(self, "error %d writing config register\n",
219 error);
220 return;
221 }
222 /* If variable resolution, set to max */
223 if (sc->sc_resolution < 0) {
224 sc->sc_resolution = ~sc->sc_resolution;
225 error = sdtemp_write_16(sc, SDTEMP_REG_RESOLUTION,
226 sc->sc_resolution & 0x3);
227 if (error != 0) {
228 iic_release_bus(sc->sc_tag, 0);
229 aprint_error_dev(self,
230 "error %d writing resolution register\n", error);
231 return;
232 } else
233 sc->sc_resolution++;
234 }
235 iic_release_bus(sc->sc_tag, 0);
236
237 /* Hook us into the sysmon_envsys subsystem */
238 sc->sc_sme = sysmon_envsys_create();
239 sc->sc_sensor = kmem_zalloc(sizeof(envsys_data_t), KM_NOSLEEP);
240 if (!sc->sc_sensor) {
241 aprint_error_dev(self, "unable to allocate sc_sensor\n");
242 goto bad2;
243 }
244
245 /* Initialize sensor data. */
246 sc->sc_sensor->units = ENVSYS_STEMP;
247 sc->sc_sensor->state = ENVSYS_SINVALID;
248 #ifdef ENVSYS_FMONLIMITS
249 sc->sc_sensor->flags |= ENVSYS_FMONLIMITS;
250 #else
251 sc->sc_sensor->flags |= ENVSYS_FMONWARNOVER | ENVSYS_FMONWARNUNDER |
252 ENVSYS_FMONCRITOVER;
253 #endif
254 (void)strlcpy(sc->sc_sensor->desc, device_xname(self),
255 sizeof(sc->sc_sensor->desc));
256
257 /* Now attach the sensor */
258 if (sysmon_envsys_sensor_attach(sc->sc_sme, sc->sc_sensor)) {
259 aprint_error_dev(self, "unable to attach sensor\n");
260 goto bad;
261 }
262
263 /* Register the device */
264 sc->sc_sme->sme_name = device_xname(self);
265 sc->sc_sme->sme_cookie = sc;
266 sc->sc_sme->sme_refresh = sdtemp_refresh;
267
268 error = sysmon_envsys_register(sc->sc_sme);
269 if (error) {
270 aprint_error_dev(self, "error %d registering with sysmon\n",
271 error);
272 goto bad;
273 }
274
275 if (!pmf_device_register(self, sdtemp_pmf_suspend, sdtemp_pmf_resume))
276 aprint_error_dev(self, "couldn't establish power handler\n");
277
278
279 /* Retrieve and display hardware monitor limits */
280 i = 0;
281 aprint_normal_dev(self, "");
282 iic_acquire_bus(sc->sc_tag, 0);
283 if (sdtemp_read_16(sc, SDTEMP_REG_LOWER_LIM, &sc->sc_low_lim) == 0 &&
284 sc->sc_low_lim != 0) {
285 sc->sc_low_lim >>= 4;
286 aprint_normal("low limit %dC ", sc->sc_low_lim);
287 i++;
288 }
289 if (sdtemp_read_16(sc, SDTEMP_REG_UPPER_LIM, &sc->sc_high_lim) == 0 &&
290 sc->sc_high_lim != 0) {
291 sc->sc_high_lim >>= 4;
292 aprint_normal("high limit %dC ", sc->sc_high_lim);
293 i++;
294 }
295 if (sdtemp_read_16(sc, SDTEMP_REG_CRIT_LIM, &sc->sc_crit_lim) == 0 &&
296 sc->sc_crit_lim != 0) {
297 sc->sc_crit_lim >>= 4;
298 aprint_normal("critical limit %dC ", sc->sc_crit_lim);
299 i++;
300 }
301 iic_release_bus(sc->sc_tag, 0);
302 if (i == 0)
303 aprint_normal("no hardware limits set\n");
304 else
305 aprint_normal("\n");
306
307 /* Create our sysctl tree. We just store the softc pointer for
308 * now; the sysctl_helper function will take care of creating
309 * a real string on the fly. We explicitly specify the new nodes'
310 * sysctl_num in order to identify the specific limit rather than
311 * using CTL_CREATE; this is OK since we're the only place that
312 * touches the sysctl tree for the device.
313 */
314
315 if (hw_node != CTL_EOL)
316 sysctl_createv(NULL, 0, NULL, &node, 0,
317 CTLTYPE_NODE, device_xname(self),
318 NULL, NULL, 0, NULL, 0,
319 CTL_HW, CTL_CREATE, CTL_EOL);
320 if (node != NULL) {
321 dev_sysctl_num = node->sysctl_num;
322 sysctl_createv(NULL, 0, NULL, &node, 0,
323 CTLTYPE_NODE, "limits",
324 SYSCTL_DESCR("temperature limits"),
325 NULL, 0, NULL, 0,
326 CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
327 }
328 if (node != NULL) {
329 sysctl_createv(NULL, 0, NULL, NULL, CTLFLAG_READWRITE,
330 CTLTYPE_INT, "low_limit",
331 SYSCTL_DESCR("alarm window lower limit"),
332 sdtemp_sysctl_helper, 0, sc, sizeof(int),
333 CTL_HW, dev_sysctl_num, node->sysctl_num,
334 SDTEMP_REG_LOWER_LIM, CTL_EOL);
335 sysctl_createv(NULL, 0, NULL, NULL, CTLFLAG_READWRITE,
336 CTLTYPE_INT, "high_limit",
337 SYSCTL_DESCR("alarm window upper limit"),
338 sdtemp_sysctl_helper, 0, sc, sizeof(int),
339 CTL_HW, dev_sysctl_num, node->sysctl_num,
340 SDTEMP_REG_UPPER_LIM, CTL_EOL);
341 sysctl_createv(NULL, 0, NULL, NULL, CTLFLAG_READWRITE,
342 CTLTYPE_INT, "crit_limit",
343 SYSCTL_DESCR("critical alarm limit"),
344 sdtemp_sysctl_helper, 0, sc, sizeof(int),
345 CTL_HW, dev_sysctl_num, node->sysctl_num,
346 SDTEMP_REG_CRIT_LIM, CTL_EOL);
347 }
348 return;
349
350 bad:
351 kmem_free(sc->sc_sensor, sizeof(envsys_data_t));
352 bad2:
353 sysmon_envsys_destroy(sc->sc_sme);
354 }
355
356 /* Set up the threshold registers */
357 static void
358 sdtemp_set_thresh(struct sdtemp_softc *sc, int reg, uint16_t val)
359 {
360 int error;
361 uint16_t *valp;
362
363 switch (reg) {
364 case SDTEMP_REG_LOWER_LIM:
365 valp = &sc->sc_low_lim;
366 break;
367 case SDTEMP_REG_UPPER_LIM:
368 valp = &sc->sc_high_lim;
369 break;
370 case SDTEMP_REG_CRIT_LIM:
371 valp = &sc->sc_crit_lim;
372 break;
373 default:
374 return;
375 }
376
377 iic_acquire_bus(sc->sc_tag, 0);
378 error = sdtemp_write_16(sc, reg, (val << 4) & SDTEMP_TEMP_MASK);
379 iic_release_bus(sc->sc_tag, 0);
380
381 if (error == 0)
382 *valp = val;
383 }
384
385 #ifdef NOT_YET /* All registers on these sensors are 16-bits */
386
387 /* Read a 8-bit value from a register */
388 static int
389 sdtemp_read_8(struct sdtemp_softc *sc, uint8_t reg, uint8_t *valp)
390 {
391 int error;
392
393 error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
394 sc->sc_address, ®, 1, valp, sizeof(*valp), 0);
395
396 return error;
397 }
398
399 static int
400 sdtemp_write_8(struct sdtemp_softc *sc, uint8_t reg, uint8_t val)
401 {
402 return iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
403 sc->sc_address, ®, 1, &val, sizeof(val), 0);
404 }
405 #endif /* NOT_YET */
406
407 /* Read a 16-bit value from a register */
408 static int
409 sdtemp_read_16(struct sdtemp_softc *sc, uint8_t reg, uint16_t *valp)
410 {
411 int error;
412
413 error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
414 sc->sc_address, ®, 1, valp, sizeof(*valp), 0);
415 if (error)
416 return error;
417
418 *valp = be16toh(*valp);
419
420 return 0;
421 }
422
423 static int
424 sdtemp_write_16(struct sdtemp_softc *sc, uint8_t reg, uint16_t val)
425 {
426 uint16_t temp;
427
428 temp = htobe16(val);
429 return iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
430 sc->sc_address, ®, 1, &temp, sizeof(temp), 0);
431 }
432
433 static uint32_t
434 sdtemp_decode_temp(struct sdtemp_softc *sc, uint16_t temp)
435 {
436 uint32_t val;
437 int32_t stemp;
438
439 /* Get only the temperature bits */
440 temp &= SDTEMP_TEMP_MASK;
441
442 /* If necessary, extend the sign bit */
443 if ((sc->sc_capability & SDTEMP_CAP_WIDER_RANGE) &&
444 (temp & SDTEMP_TEMP_NEGATIVE))
445 temp |= SDTEMP_TEMP_SIGN_EXT;
446
447 /* Mask off only bits valid within current resolution */
448 temp &= ~(0xf >> sc->sc_resolution);
449
450 /* Treat as signed and extend to 32-bits */
451 stemp = (int16_t)temp;
452
453 /* Now convert from 0.0625 (1/16) deg C increments to microKelvins */
454 val = (stemp * 62500) + 273150000;
455
456 return val;
457 }
458
459 static void
460 sdtemp_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
461 {
462 struct sdtemp_softc *sc = sme->sme_cookie;
463 uint16_t val;
464 int error;
465
466 iic_acquire_bus(sc->sc_tag, 0);
467 error = sdtemp_read_16(sc, SDTEMP_REG_AMBIENT_TEMP, &val);
468 iic_release_bus(sc->sc_tag, 0);
469
470 if (error) {
471 edata->state = ENVSYS_SINVALID;
472 return;
473 }
474
475 edata->value_cur = sdtemp_decode_temp(sc, val);
476
477 /* Now check for limits */
478 if (val & SDTEMP_ABOVE_CRIT)
479 edata->state = ENVSYS_SCRITOVER;
480 else if (val & SDTEMP_ABOVE_UPPER)
481 edata->state = ENVSYS_SWARNOVER;
482 else if (val & SDTEMP_BELOW_LOWER)
483 edata->state = ENVSYS_SWARNUNDER;
484 else
485 edata->state = ENVSYS_SVALID;
486 }
487
488 SYSCTL_SETUP(sysctl_sdtemp_setup, "sysctl hw.sdtemp subtree setup")
489 {
490 const struct sysctlnode *node;
491
492 if (sysctl_createv(clog, 0, NULL, &node,
493 CTLFLAG_PERMANENT,
494 CTLTYPE_NODE, "hw", NULL,
495 NULL, 0, NULL, 0,
496 CTL_HW, CTL_EOL) != 0)
497 return;
498
499 hw_node = node->sysctl_num;
500 }
501
502 /*
503 * The sysctl node actually contains just a pointer to our softc. We
504 * extract the individual limits on the fly, and if necessary replace
505 * the value with the new value specified by the user.
506 *
507 * Inspired by similar code in sys/net/if_tap.c
508 */
509 static int
510 sdtemp_sysctl_helper(SYSCTLFN_ARGS)
511 {
512 struct sdtemp_softc *sc;
513 struct sysctlnode node;
514 int error, reg;
515 uint16_t reg_value;
516 int lim_value;
517
518 node = *rnode;
519 sc = node.sysctl_data;
520 reg = node.sysctl_num;
521
522 iic_acquire_bus(sc->sc_tag, 0);
523 error = sdtemp_read_16(sc, reg, ®_value);
524 iic_release_bus(sc->sc_tag, 0);
525
526 #ifdef DEBUG
527 aprint_verbose_dev(sc->sc_dev, "(%s) sc %p reg %d val 0x%04x err %d\n",
528 __func__, sc, reg, reg_value, error);
529 #endif
530
531 if (error == 0) {
532 lim_value = reg_value >> 4;
533 node.sysctl_data = &lim_value;
534 error = sysctl_lookup(SYSCTLFN_CALL(&node));
535 }
536 if (error || newp == NULL)
537 return (error);
538
539 /*
540 * We're being asked to update the sysctl value, so retrieve
541 * the new value and check for valid range
542 */
543 lim_value = *(int *)node.sysctl_data;
544 if (lim_value < -256 || lim_value > 255)
545 return (EINVAL);
546
547 sdtemp_set_thresh(sc, reg, (uint16_t)lim_value);
548
549 return (0);
550 }
551
552 /*
553 * power management functions
554 *
555 * We go into "shutdown" mode at suspend time, and return to normal
556 * mode upon resume. This reduces power consumption by disabling
557 * the A/D converter.
558 */
559
560 static bool
561 sdtemp_pmf_suspend(device_t dev PMF_FN_ARGS)
562 {
563 struct sdtemp_softc *sc = device_private(dev);
564 int error;
565 uint16_t config;
566
567 iic_acquire_bus(sc->sc_tag, 0);
568 error = sdtemp_read_16(sc, SDTEMP_REG_CONFIG, &config);
569 if (error == 0) {
570 config |= SDTEMP_CONFIG_SHUTDOWN_MODE;
571 error = sdtemp_write_16(sc, SDTEMP_REG_CONFIG, config);
572 }
573 iic_release_bus(sc->sc_tag, 0);
574 return (error == 0);
575 }
576
577 static bool
578 sdtemp_pmf_resume(device_t dev PMF_FN_ARGS)
579 {
580 struct sdtemp_softc *sc = device_private(dev);
581 int error;
582 uint16_t config;
583
584 iic_acquire_bus(sc->sc_tag, 0);
585 error = sdtemp_read_16(sc, SDTEMP_REG_CONFIG, &config);
586 if (error == 0) {
587 config &= ~SDTEMP_CONFIG_SHUTDOWN_MODE;
588 error = sdtemp_write_16(sc, SDTEMP_REG_CONFIG, config);
589 }
590 iic_release_bus(sc->sc_tag, 0);
591 return (error == 0);
592 }
593