Lines Matching full:sensor

4  * System Control and Management Interface(SCMI) based IIO sensor driver
44 struct scmi_iio_priv *sensor; in scmi_iio_sensor_update_cb() local
52 sensor = container_of(nb, struct scmi_iio_priv, sensor_update_nb); in scmi_iio_sensor_update_cb()
55 sensor->iio_buf[i] = sensor_update->readings[i].value; in scmi_iio_sensor_update_cb()
57 if (!sensor->sensor_info->timestamped) { in scmi_iio_sensor_update_cb()
71 tstamp_scale = sensor->sensor_info->tstamp_scale + in scmi_iio_sensor_update_cb()
81 scmi_iio_dev = sensor->indio_dev; in scmi_iio_sensor_update_cb()
82 iio_push_to_buffers_with_timestamp(scmi_iio_dev, sensor->iio_buf, in scmi_iio_sensor_update_cb()
89 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_buffer_preenable() local
93 if (sensor->sensor_info->timestamped) in scmi_iio_buffer_preenable()
99 err = sensor->sensor_ops->config_set(sensor->ph, in scmi_iio_buffer_preenable()
100 sensor->sensor_info->id, in scmi_iio_buffer_preenable()
103 dev_err(&iio_dev->dev, "Error in enabling sensor %s err %d", in scmi_iio_buffer_preenable()
104 sensor->sensor_info->name, err); in scmi_iio_buffer_preenable()
111 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_buffer_postdisable() local
117 err = sensor->sensor_ops->config_set(sensor->ph, in scmi_iio_buffer_postdisable()
118 sensor->sensor_info->id, in scmi_iio_buffer_postdisable()
122 "Error in disabling sensor %s with err %d", in scmi_iio_buffer_postdisable()
123 sensor->sensor_info->name, err); in scmi_iio_buffer_postdisable()
136 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_set_odr_val() local
141 int err = sensor->sensor_ops->config_get(sensor->ph, in scmi_iio_set_odr_val()
142 sensor->sensor_info->id, in scmi_iio_set_odr_val()
146 "Error in getting sensor config for sensor %s err %d", in scmi_iio_set_odr_val()
147 sensor->sensor_info->name, err); in scmi_iio_set_odr_val()
154 * The seconds field in the sensor interval in SCMI is 16 bits long in scmi_iio_set_odr_val()
169 "Trying to set invalid sensor update value for sensor %s", in scmi_iio_set_odr_val()
170 sensor->sensor_info->name); in scmi_iio_set_odr_val()
179 if (sensor->sensor_info->timestamped) { in scmi_iio_set_odr_val()
189 err = sensor->sensor_ops->config_set(sensor->ph, in scmi_iio_set_odr_val()
190 sensor->sensor_info->id, in scmi_iio_set_odr_val()
194 "Error in setting sensor update interval for sensor %s value %u err %d", in scmi_iio_set_odr_val()
195 sensor->sensor_info->name, sensor_config, err); in scmi_iio_set_odr_val()
204 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_write_raw() local
209 mutex_lock(&sensor->lock); in scmi_iio_write_raw()
211 mutex_unlock(&sensor->lock); in scmi_iio_write_raw()
223 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_read_avail() local
227 *vals = sensor->freq_avail; in scmi_iio_read_avail()
229 *length = sensor->sensor_info->intervals.count * 2; in scmi_iio_read_avail()
230 if (sensor->sensor_info->intervals.segmented) in scmi_iio_read_avail()
253 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_get_odr_val() local
257 int err = sensor->sensor_ops->config_get(sensor->ph, in scmi_iio_get_odr_val()
258 sensor->sensor_info->id, in scmi_iio_get_odr_val()
262 "Error in getting sensor config for sensor %s err %d", in scmi_iio_get_odr_val()
263 sensor->sensor_info->name, err); in scmi_iio_get_odr_val()
289 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_read_channel_data() local
296 err = sensor->sensor_ops->config_set( in scmi_iio_read_channel_data()
297 sensor->ph, sensor->sensor_info->id, sensor_config); in scmi_iio_read_channel_data()
300 "Error in enabling sensor %s err %d", in scmi_iio_read_channel_data()
301 sensor->sensor_info->name, err); in scmi_iio_read_channel_data()
305 err = sensor->sensor_ops->reading_get_timestamped( in scmi_iio_read_channel_data()
306 sensor->ph, sensor->sensor_info->id, in scmi_iio_read_channel_data()
307 sensor->sensor_info->num_axis, readings); in scmi_iio_read_channel_data()
310 "Error in reading raw attribute for sensor %s err %d", in scmi_iio_read_channel_data()
311 sensor->sensor_info->name, err); in scmi_iio_read_channel_data()
317 err = sensor->sensor_ops->config_set( in scmi_iio_read_channel_data()
318 sensor->ph, sensor->sensor_info->id, sensor_config); in scmi_iio_read_channel_data()
321 "Error in disabling sensor %s err %d", in scmi_iio_read_channel_data()
322 sensor->sensor_info->name, err); in scmi_iio_read_channel_data()
336 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_read_raw() local
342 scale = sensor->sensor_info->axis[ch->scan_index].scale; in scmi_iio_read_raw()
377 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_get_raw_available() local
387 if (sensor->sensor_info->axis[0].extended_attrs) { in scmi_iio_get_raw_available()
388 min_range = sensor->sensor_info->axis[0].attrs.min_range; in scmi_iio_get_raw_available()
389 max_range = sensor->sensor_info->axis[0].attrs.max_range; in scmi_iio_get_raw_available()
390 resolution = sensor->sensor_info->axis[0].resolution; in scmi_iio_get_raw_available()
391 exponent = sensor->sensor_info->axis[0].exponent; in scmi_iio_get_raw_available()
392 scale = sensor->sensor_info->axis[0].scale; in scmi_iio_get_raw_available()
396 * need to divide the resolution exponent by the sensor scale in scmi_iio_get_raw_available()
521 struct scmi_iio_priv *sensor = iio_priv(iio_dev); in scmi_iio_set_sampling_freq_avail() local
524 sensor->freq_avail = in scmi_iio_set_sampling_freq_avail()
526 sizeof(*sensor->freq_avail) * in scmi_iio_set_sampling_freq_avail()
527 (sensor->sensor_info->intervals.count * 2), in scmi_iio_set_sampling_freq_avail()
529 if (!sensor->freq_avail) in scmi_iio_set_sampling_freq_avail()
532 if (sensor->sensor_info->intervals.segmented) { in scmi_iio_set_sampling_freq_avail()
533 low_interval = sensor->sensor_info->intervals in scmi_iio_set_sampling_freq_avail()
537 sensor->freq_avail[0] = hz; in scmi_iio_set_sampling_freq_avail()
538 sensor->freq_avail[1] = uhz; in scmi_iio_set_sampling_freq_avail()
540 step_size = sensor->sensor_info->intervals in scmi_iio_set_sampling_freq_avail()
544 sensor->freq_avail[2] = hz; in scmi_iio_set_sampling_freq_avail()
545 sensor->freq_avail[3] = uhz; in scmi_iio_set_sampling_freq_avail()
547 high_interval = sensor->sensor_info->intervals in scmi_iio_set_sampling_freq_avail()
552 sensor->freq_avail[4] = hz; in scmi_iio_set_sampling_freq_avail()
553 sensor->freq_avail[5] = uhz; in scmi_iio_set_sampling_freq_avail()
555 for (i = 0; i < sensor->sensor_info->intervals.count; i++) { in scmi_iio_set_sampling_freq_avail()
556 cur_interval = sensor->sensor_info->intervals.desc[i]; in scmi_iio_set_sampling_freq_avail()
560 sensor->freq_avail[i * 2] = hz; in scmi_iio_set_sampling_freq_avail()
561 sensor->freq_avail[i * 2 + 1] = uhz; in scmi_iio_set_sampling_freq_avail()
574 struct scmi_iio_priv *sensor; in scmi_alloc_iiodev() local
582 iiodev = devm_iio_device_alloc(dev, sizeof(*sensor)); in scmi_alloc_iiodev()
587 sensor = iio_priv(iiodev); in scmi_alloc_iiodev()
588 sensor->sensor_ops = ops; in scmi_alloc_iiodev()
589 sensor->ph = ph; in scmi_alloc_iiodev()
590 sensor->sensor_info = sensor_info; in scmi_alloc_iiodev()
591 sensor->sensor_update_nb.notifier_call = scmi_iio_sensor_update_cb; in scmi_alloc_iiodev()
592 sensor->indio_dev = iiodev; in scmi_alloc_iiodev()
593 mutex_init(&sensor->lock); in scmi_alloc_iiodev()
627 &sensor->sensor_info->id, in scmi_alloc_iiodev()
628 &sensor->sensor_update_nb); in scmi_alloc_iiodev()
631 "Error in registering sensor update notifier for sensor %s\n", in scmi_alloc_iiodev()
632 sensor->sensor_info->name); in scmi_alloc_iiodev()
656 "SCMI device has no sensor interface\n"); in scmi_iio_dev_probe()
668 "SCMI sensor %d has missing info\n", i); in scmi_iio_dev_probe()
684 "failed to allocate IIO device for sensor %s\n", in scmi_iio_dev_probe()
693 "IIO buffer setup error at sensor %s\n", in scmi_iio_dev_probe()
700 "IIO device registration failed at sensor %s\n", in scmi_iio_dev_probe()
714 .name = "scmi-sensor-iiodev",