Lines Matching +full:temp +full:- +full:sensor

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
52 /* Sensor: Maxim DS1631 */
136 return (-1); in ds1631_write()
164 return (-1); in ds1631_read_1()
192 return (-1); in ds1631_read_2()
210 if (strcmp(name, "temp-monitor") != 0 || in ds1631_probe()
215 sc->sc_dev = dev; in ds1631_probe()
216 sc->sc_addr = iicbus_get_addr(dev); in ds1631_probe()
218 device_set_desc(dev, "Temp-Monitor DS1631"); in ds1631_probe()
230 sc->enum_hook.ich_func = ds1631_start; in ds1631_attach()
231 sc->enum_hook.ich_arg = dev; in ds1631_attach()
237 * the master. The openpic on mac-io is controlling the htpic. in ds1631_attach()
238 * This one gets attached after the mac-io probing and then the in ds1631_attach()
242 if (config_intrhook_establish(&sc->enum_hook) != 0) in ds1631_attach()
259 return (-1); in ds1631_init()
267 * Setup the resolution, 10-bit is enough. Each bit increase in in ds1631_init()
275 return (-1); in ds1631_init()
283 return (-1); in ds1631_init()
286 sc->init_done = 1; in ds1631_init()
310 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensor", in ds1631_start()
311 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "DS1631 Sensor Information"); in ds1631_start()
313 if (OF_getprop(child, "hwsensor-zone", &sc->sc_sensor.zone, in ds1631_start()
315 sc->sc_sensor.zone = 0; in ds1631_start()
317 plen = OF_getprop(child, "hwsensor-location", sc->sc_sensor.name, in ds1631_start()
318 sizeof(sc->sc_sensor.name)); in ds1631_start()
319 if (plen == -1) { in ds1631_start()
321 * Ok, no hwsensor-location property, so let's look for a in ds1631_start()
325 plen = OF_getprop(node, "location", sc->sc_sensor.name, in ds1631_start()
326 sizeof(sc->sc_sensor.name)); in ds1631_start()
329 if (plen == -1) { in ds1631_start()
330 strcpy(sysctl_name, "sensor"); in ds1631_start()
332 for (i = 0; i < strlen(sc->sc_sensor.name); i++) { in ds1631_start()
333 sysctl_name[i] = tolower(sc->sc_sensor.name[i]); in ds1631_start()
341 if (sc->sc_sensor.zone == 0) { in ds1631_start()
342 sc->sc_sensor.target_temp = 400 + ZERO_C_TO_K; in ds1631_start()
343 sc->sc_sensor.max_temp = 500 + ZERO_C_TO_K; in ds1631_start()
345 sc->sc_sensor.target_temp = 300 + ZERO_C_TO_K; in ds1631_start()
346 sc->sc_sensor.max_temp = 500 + ZERO_C_TO_K; in ds1631_start()
349 sc->sc_sensor.read = in ds1631_start()
351 pmac_thermal_sensor_register(&sc->sc_sensor); in ds1631_start()
353 sprintf(sysctl_desc,"%s %s", sc->sc_sensor.name, "(C)"); in ds1631_start()
356 "Sensor Information"); in ds1631_start()
357 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "temp", in ds1631_start()
361 config_intrhook_disestablish(&sc->enum_hook); in ds1631_start()
371 if (!sc->init_done) in ds1631_sensor_read()
372 ds1631_init(sc->sc_dev, sc->sc_addr); in ds1631_sensor_read()
374 err = ds1631_read_2(sc->sc_dev, sc->sc_addr, DS1631_TEMP, buf); in ds1631_sensor_read()
376 device_printf(sc->sc_dev, "ds1631 read TEMP failed: %x\n", err); in ds1631_sensor_read()
377 return (-1); in ds1631_sensor_read()
383 * The default mode of the ADC is 12-bit, the resolution is 0.0625 C in ds1631_sensor_read()
385 * We use 10-bit resolution which seems enough, resolution is 0.25 C. in ds1631_sensor_read()
397 int temp; in ds1631_sensor_sysctl() local
402 temp = ds1631_sensor_read(sc); in ds1631_sensor_sysctl()
403 if (temp < 0) in ds1631_sensor_sysctl()
406 error = sysctl_handle_int(oidp, &temp, 0, req); in ds1631_sensor_sysctl()