Home | History | Annotate | Download | only in dev

Lines Matching refs:sensor

133 	struct smusat_sensor *sensor;
152 sensor = &sc->sc_sensors[sc->sc_num_sensors];
153 sensor->sc = sc;
155 memset(sensor->location, 0, sizeof(sensor->location));
156 OF_getprop(node, "location", sensor->location,
157 sizeof(sensor->location));
159 if (OF_getprop(node, "reg", &sensor->reg,
160 sizeof(sensor->reg)) <= 0)
163 if ((sensor->reg < 0x30) || (sensor->reg > 0x37))
165 sensor->reg -= 0x30;
167 if (OF_getprop(node, "zone", &sensor->zone,
168 sizeof(sensor->zone)) <= 0)
174 if (strcmp(type, "temp-sensor") == 0) {
175 sensor->type = SMUSAT_SENSOR_TEMP;
176 sensor->shift = 10;
177 } else if (strcmp(type, "current-sensor") == 0) {
178 sensor->type = SMUSAT_SENSOR_CURRENT;
179 sensor->shift = 8;
180 } else if (strcmp(type, "voltage-sensor") == 0) {
181 sensor->type = SMUSAT_SENSOR_VOLTAGE;
182 sensor->shift = 4;
183 } else if (strcmp(type, "power-sensor") == 0) {
184 sensor->type = SMUSAT_SENSOR_POWER;
185 sensor->shift = 0;
188 DPRINTF("sensor: location %s reg %x zone %d type %s\n",
189 sensor->location, sensor->reg, sensor->zone, type);
194 /* Create sysctl nodes for each sensor */
205 sensor = &sc->sc_sensors[i];
207 for (j = 0; j < strlen(sensor->location); j++) {
208 sysctl_sensor_name[j] = tolower(sensor->location[j]);
216 CTLTYPE_NODE, sysctl_sensor_name, "sensor information",
225 CTLTYPE_INT, "zone", "sensor zone",
226 NULL, 0, &sensor->zone, 0,
235 CTLTYPE_INT, "value", "sensor current value",
236 smusat_sysctl_sensor_value, 0, (void *) sensor, 0,
252 struct smusat_sensor *sensor;
260 sensor = &sc->sc_sensors[i];
262 switch (sensor->type) {
281 "%s", sensor->location);
304 struct smusat_sensor *sensor;
305 int which = edata->sensor;
311 sensor = &sc->sc_sensors[which];
313 ret = smusat_sensor_read(sensor, NULL);
315 switch (sensor->type) {
317 edata->value_cur = sensor->current_value *
321 edata->value_cur = sensor->current_value * 1000000;
324 edata->value_cur = sensor->current_value * 1000000;
327 edata->value_cur = sensor->current_value * 1000000;
330 edata->value_cur = sensor->current_value;
357 smusat_sensor_read(struct smusat_sensor *sensor, int *value)
359 struct smusat_softc *sc = sensor->sc;
368 reg = sensor->reg << 1;
369 sensor->current_value = (sc->sc_cache[reg] << 8) + sc->sc_cache[reg + 1];
370 sensor->current_value <<= sensor->shift;
372 sensor->current_value >>= 16;
375 *value = sensor->current_value;
384 struct smusat_sensor *sensor = node.sysctl_data;
390 ret = smusat_sensor_read(sensor, &value);