Lines Matching full:sensor

4  * System Control and Management Interface(SCMI) based IIO sensor driver
41 struct scmi_iio_priv *sensor; in scmi_iio_sensor_update_cb() local
49 sensor = container_of(nb, struct scmi_iio_priv, sensor_update_nb); in scmi_iio_sensor_update_cb()
52 sensor->iio_buf[i] = sensor_update->readings[i].value; in scmi_iio_sensor_update_cb()
54 if (!sensor->sensor_info->timestamped) { in scmi_iio_sensor_update_cb()
68 tstamp_scale = sensor->sensor_info->tstamp_scale + in scmi_iio_sensor_update_cb()
78 scmi_iio_dev = sensor->indio_dev; in scmi_iio_sensor_update_cb()
79 iio_push_to_buffers_with_timestamp(scmi_iio_dev, sensor->iio_buf, in scmi_iio_sensor_update_cb()
86 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_buffer_preenable() local
90 if (sensor->sensor_info->timestamped) in scmi_iio_buffer_preenable()
96 err = sensor->sensor_ops->config_set(sensor->ph, in scmi_iio_buffer_preenable()
97 sensor->sensor_info->id, in scmi_iio_buffer_preenable()
100 dev_err(&iio_dev->dev, "Error in enabling sensor %s err %d", in scmi_iio_buffer_preenable()
101 sensor->sensor_info->name, err); in scmi_iio_buffer_preenable()
108 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_buffer_postdisable() local
114 err = sensor->sensor_ops->config_set(sensor->ph, in scmi_iio_buffer_postdisable()
115 sensor->sensor_info->id, in scmi_iio_buffer_postdisable()
119 "Error in disabling sensor %s with err %d", in scmi_iio_buffer_postdisable()
120 sensor->sensor_info->name, err); in scmi_iio_buffer_postdisable()
133 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_set_odr_val() local
138 int err = sensor->sensor_ops->config_get(sensor->ph, in scmi_iio_set_odr_val()
139 sensor->sensor_info->id, in scmi_iio_set_odr_val()
143 "Error in getting sensor config for sensor %s err %d", in scmi_iio_set_odr_val()
144 sensor->sensor_info->name, err); in scmi_iio_set_odr_val()
151 * The seconds field in the sensor interval in SCMI is 16 bits long in scmi_iio_set_odr_val()
166 "Trying to set invalid sensor update value for sensor %s", in scmi_iio_set_odr_val()
167 sensor->sensor_info->name); in scmi_iio_set_odr_val()
176 if (sensor->sensor_info->timestamped) { in scmi_iio_set_odr_val()
186 err = sensor->sensor_ops->config_set(sensor->ph, in scmi_iio_set_odr_val()
187 sensor->sensor_info->id, in scmi_iio_set_odr_val()
191 "Error in setting sensor update interval for sensor %s value %u err %d", in scmi_iio_set_odr_val()
192 sensor->sensor_info->name, sensor_config, err); in scmi_iio_set_odr_val()
219 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_read_avail() local
223 *vals = sensor->freq_avail; in scmi_iio_read_avail()
225 *length = sensor->sensor_info->intervals.count * 2; in scmi_iio_read_avail()
226 if (sensor->sensor_info->intervals.segmented) in scmi_iio_read_avail()
249 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_get_odr_val() local
253 int err = sensor->sensor_ops->config_get(sensor->ph, in scmi_iio_get_odr_val()
254 sensor->sensor_info->id, in scmi_iio_get_odr_val()
258 "Error in getting sensor config for sensor %s err %d", in scmi_iio_get_odr_val()
259 sensor->sensor_info->name, err); in scmi_iio_get_odr_val()
285 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_read_channel_data() local
292 err = sensor->sensor_ops->config_set( in scmi_iio_read_channel_data()
293 sensor->ph, sensor->sensor_info->id, sensor_config); in scmi_iio_read_channel_data()
296 "Error in enabling sensor %s err %d", in scmi_iio_read_channel_data()
297 sensor->sensor_info->name, err); in scmi_iio_read_channel_data()
301 err = sensor->sensor_ops->reading_get_timestamped( in scmi_iio_read_channel_data()
302 sensor->ph, sensor->sensor_info->id, in scmi_iio_read_channel_data()
303 sensor->sensor_info->num_axis, readings); in scmi_iio_read_channel_data()
306 "Error in reading raw attribute for sensor %s err %d", in scmi_iio_read_channel_data()
307 sensor->sensor_info->name, err); in scmi_iio_read_channel_data()
313 err = sensor->sensor_ops->config_set( in scmi_iio_read_channel_data()
314 sensor->ph, sensor->sensor_info->id, sensor_config); in scmi_iio_read_channel_data()
317 "Error in disabling sensor %s err %d", in scmi_iio_read_channel_data()
318 sensor->sensor_info->name, err); in scmi_iio_read_channel_data()
332 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_read_raw() local
338 scale = sensor->sensor_info->axis[ch->scan_index].scale; in scmi_iio_read_raw()
373 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_get_raw_available() local
383 if (sensor->sensor_info->axis[0].extended_attrs) { in scmi_iio_get_raw_available()
384 min_range = sensor->sensor_info->axis[0].attrs.min_range; in scmi_iio_get_raw_available()
385 max_range = sensor->sensor_info->axis[0].attrs.max_range; in scmi_iio_get_raw_available()
386 resolution = sensor->sensor_info->axis[0].resolution; in scmi_iio_get_raw_available()
387 exponent = sensor->sensor_info->axis[0].exponent; in scmi_iio_get_raw_available()
388 scale = sensor->sensor_info->axis[0].scale; in scmi_iio_get_raw_available()
392 * need to divide the resolution exponent by the sensor scale in scmi_iio_get_raw_available()
517 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_set_sampling_freq_avail() local
520 sensor->freq_avail = in scmi_iio_set_sampling_freq_avail()
522 sizeof(*sensor->freq_avail) * in scmi_iio_set_sampling_freq_avail()
523 (sensor->sensor_info->intervals.count * 2), in scmi_iio_set_sampling_freq_avail()
525 if (!sensor->freq_avail) in scmi_iio_set_sampling_freq_avail()
528 if (sensor->sensor_info->intervals.segmented) { in scmi_iio_set_sampling_freq_avail()
529 low_interval = sensor->sensor_info->intervals in scmi_iio_set_sampling_freq_avail()
533 sensor->freq_avail[0] = hz; in scmi_iio_set_sampling_freq_avail()
534 sensor->freq_avail[1] = uhz; in scmi_iio_set_sampling_freq_avail()
536 step_size = sensor->sensor_info->intervals in scmi_iio_set_sampling_freq_avail()
540 sensor->freq_avail[2] = hz; in scmi_iio_set_sampling_freq_avail()
541 sensor->freq_avail[3] = uhz; in scmi_iio_set_sampling_freq_avail()
543 high_interval = sensor->sensor_info->intervals in scmi_iio_set_sampling_freq_avail()
548 sensor->freq_avail[4] = hz; in scmi_iio_set_sampling_freq_avail()
549 sensor->freq_avail[5] = uhz; in scmi_iio_set_sampling_freq_avail()
551 for (i = 0; i < sensor->sensor_info->intervals.count; i++) { in scmi_iio_set_sampling_freq_avail()
552 cur_interval = sensor->sensor_info->intervals.desc[i]; in scmi_iio_set_sampling_freq_avail()
556 sensor->freq_avail[i * 2] = hz; in scmi_iio_set_sampling_freq_avail()
557 sensor->freq_avail[i * 2 + 1] = uhz; in scmi_iio_set_sampling_freq_avail()
570 struct scmi_iio_priv *sensor; in scmi_alloc_iiodev() local
578 iiodev = devm_iio_device_alloc(dev, sizeof(*sensor)); in scmi_alloc_iiodev()
583 sensor = iio_priv(iiodev); in scmi_alloc_iiodev()
584 sensor->sensor_ops = ops; in scmi_alloc_iiodev()
585 sensor->ph = ph; in scmi_alloc_iiodev()
586 sensor->sensor_info = sensor_info; in scmi_alloc_iiodev()
587 sensor->sensor_update_nb.notifier_call = scmi_iio_sensor_update_cb; in scmi_alloc_iiodev()
588 sensor->indio_dev = iiodev; in scmi_alloc_iiodev()
622 &sensor->sensor_info->id, in scmi_alloc_iiodev()
623 &sensor->sensor_update_nb); in scmi_alloc_iiodev()
626 "Error in registering sensor update notifier for sensor %s err %d", in scmi_alloc_iiodev()
627 sensor->sensor_info->name, ret); in scmi_alloc_iiodev()
652 dev_err(dev, "SCMI device has no sensor interface\n"); in scmi_iio_dev_probe()
665 dev_err(dev, "SCMI sensor %d has missing info\n", i); in scmi_iio_dev_probe()
682 "failed to allocate IIO device for sensor %s: %ld\n", in scmi_iio_dev_probe()
692 "IIO buffer setup error at sensor %s: %d\n", in scmi_iio_dev_probe()
700 "IIO device registration failed at sensor %s: %d\n", in scmi_iio_dev_probe()
716 .name = "scmi-sensor-iiodev",