Lines Matching +full:sensor +full:- +full:id

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
65 int id; member
121 static MALLOC_DEFINE(M_AD7417, "ad7417", "Supply-Monitor AD7417");
145 return (-1); in ad7417_write()
173 return (-1); in ad7417_read_1()
201 return (-1); in ad7417_read_2()
217 { addr, IIC_M_WR | IIC_M_NOSTOP, 1, &in->reg }, in ad7417_write_read()
231 in->val = *((uint16_t*)buf); in ad7417_write_read()
236 return (-1); in ad7417_write_read()
268 return (-1); in ad7417_init_adc()
270 sc->init_done = 1; in ad7417_init_adc()
287 if (strcmp(name, "supply-monitor") != 0 || in ad7417_probe()
292 sc->sc_dev = dev; in ad7417_probe()
293 sc->sc_addr = iicbus_get_addr(dev); in ad7417_probe()
295 device_set_desc(dev, "Supply-Monitor AD7417"); in ad7417_probe()
302 * and we have allocated memory for sc->sc_sensors, we fill in the properties.
309 u_int id[10]; in ad7417_fill_sensor_prop() local
318 /* Fill the sensor location property. */ in ad7417_fill_sensor_prop()
319 prop_len = OF_getprop(child, "hwsensor-location", location, in ad7417_fill_sensor_prop()
322 if (sc->sc_sensors != NULL) in ad7417_fill_sensor_prop()
323 strcpy(sc->sc_sensors[i].therm.name, location + len); in ad7417_fill_sensor_prop()
328 if (sc->sc_sensors == NULL) in ad7417_fill_sensor_prop()
331 /* Fill the sensor type property. */ in ad7417_fill_sensor_prop()
335 prop_len = OF_getprop(child, "hwsensor-type", type, sizeof(type)); in ad7417_fill_sensor_prop()
338 sc->sc_sensors[i].type = ADC7417_TEMP_SENSOR; in ad7417_fill_sensor_prop()
340 sc->sc_sensors[i].type = ADC7417_ADC_SENSOR; in ad7417_fill_sensor_prop()
346 /* Fill the sensor id property. Taken from OF. */ in ad7417_fill_sensor_prop()
347 prop_len = OF_getprop(child, "hwsensor-id", id, sizeof(id)); in ad7417_fill_sensor_prop()
349 sc->sc_sensors[j].id = id[j]; in ad7417_fill_sensor_prop()
351 /* Fill the sensor zone property. Taken from OF. */ in ad7417_fill_sensor_prop()
352 prop_len = OF_getprop(child, "hwsensor-zone", id, sizeof(id)); in ad7417_fill_sensor_prop()
354 sc->sc_sensors[j].therm.zone = id[j]; in ad7417_fill_sensor_prop()
357 child nodes of the hwsensor-location node. Check for and in ad7417_fill_sensor_prop()
365 strcpy(sc->sc_sensors[i].therm.name, location); in ad7417_fill_sensor_prop()
369 /* Finish setting up sensor properties */ in ad7417_fill_sensor_prop()
371 sc->sc_sensors[j].dev = dev; in ad7417_fill_sensor_prop()
374 if ((strstr(sc->sc_sensors[j].therm.name, "DIODE TEMP") in ad7417_fill_sensor_prop()
376 || (strstr(sc->sc_sensors[j].therm.name, "AD1") != NULL)) { in ad7417_fill_sensor_prop()
377 sc->sc_sensors[j].type = ADC7417_TEMP_SENSOR; in ad7417_fill_sensor_prop()
378 sc->sc_sensors[j].therm.read = in ad7417_fill_sensor_prop()
381 sc->sc_sensors[j].therm.read = in ad7417_fill_sensor_prop()
385 if (sc->sc_sensors[j].type != ADC7417_TEMP_SENSOR) in ad7417_fill_sensor_prop()
389 sc->sc_sensors[j].therm.target_temp = 500 + ZERO_C_TO_K; in ad7417_fill_sensor_prop()
390 sc->sc_sensors[j].therm.max_temp = 900 + ZERO_C_TO_K; in ad7417_fill_sensor_prop()
392 pmac_thermal_sensor_register(&sc->sc_sensors[j].therm); in ad7417_fill_sensor_prop()
410 sc->sc_nsensors = 0; in ad7417_attach()
413 sc->sc_nsensors = ad7417_fill_sensor_prop(dev); in ad7417_attach()
415 device_printf(dev, "%d sensors detected.\n", sc->sc_nsensors); in ad7417_attach()
417 if (sc->sc_nsensors == 0) in ad7417_attach()
420 sc->sc_sensors = malloc (sc->sc_nsensors * sizeof(struct ad7417_sensor), in ad7417_attach()
425 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensor", in ad7417_attach()
426 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "AD7417 Sensor Information"); in ad7417_attach()
429 sc->sc_nsensors = ad7417_fill_sensor_prop(dev); in ad7417_attach()
432 for (i = 0; i < sc->sc_nsensors; i++) { in ad7417_attach()
433 for (j = 0; j < strlen(sc->sc_sensors[i].therm.name); j++) { in ad7417_attach()
435 tolower(sc->sc_sensors[i].therm.name[j]); in ad7417_attach()
443 "Sensor Information"); in ad7417_attach()
445 if (sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR) { in ad7417_attach()
450 /* I use i to pass the sensor id. */ in ad7417_attach()
454 sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR ? in ad7417_attach()
456 sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR ? in ad7417_attach()
457 "sensor unit (C)" : "sensor unit (mV)"); in ad7417_attach()
459 /* Dump sensor location, ID & type. */ in ad7417_attach()
462 for (i = 0; i < sc->sc_nsensors; i++) { in ad7417_attach()
463 device_printf(dev, "Location: %s ID: %d type: %d\n", in ad7417_attach()
464 sc->sc_sensors[i].therm.name, in ad7417_attach()
465 sc->sc_sensors[i].id, in ad7417_attach()
466 sc->sc_sensors[i].type); in ad7417_attach()
483 return (-1); in ad7417_get_temp()
514 return (-1); in ad7417_get_adc()
540 return (-1); in ad7417_diode_read()
542 if (strstr(sens->therm.name, "CPU B") != NULL) { in ad7417_diode_read()
563 sc = device_get_softc(sens->dev); in ad7417_adc_read()
565 switch (sens->id) { in ad7417_adc_read()
586 if (ad7417_get_adc(sc->sc_dev, sc->sc_addr, &temp, chan) < 0) in ad7417_adc_read()
587 return (-1); in ad7417_adc_read()
599 sc = device_get_softc(sens->dev); in ad7417_sensor_read()
602 if (!sc->init_done) in ad7417_sensor_read()
603 if (ad7417_init_adc(sc->sc_dev, sc->sc_addr) < 0) in ad7417_sensor_read()
604 return (-1); in ad7417_sensor_read()
606 if (sens->type == ADC7417_TEMP_SENSOR) { in ad7417_sensor_read()
607 if (ad7417_get_temp(sc->sc_dev, sc->sc_addr, &temp) < 0) in ad7417_sensor_read()
608 return (-1); in ad7417_sensor_read()
627 sens = &sc->sc_sensors[arg2]; in ad7417_sensor_sysctl()
629 value = sens->therm.read(&sens->therm); in ad7417_sensor_sysctl()