Lines Matching +full:motion +full:- +full:sensors
1 // SPDX-License-Identifier: GPL-2.0
3 * cros_ec_light_prox - Driver for light and prox sensors behing CrosEC.
26 * light sensors to return the what the eye would see. For proximity, we
33 /* Shared by all sensors */
47 int idx = chan->scan_index; in cros_ec_light_prox_read()
49 mutex_lock(&st->core.cmd_lock); in cros_ec_light_prox_read()
53 if (chan->type == IIO_PROXIMITY) { in cros_ec_light_prox_read()
61 ret = -EINVAL; in cros_ec_light_prox_read()
65 if (chan->type == IIO_LIGHT) { in cros_ec_light_prox_read()
72 * pre-processed and represents the ambient light in cros_ec_light_prox_read()
78 ret = -EINVAL; in cros_ec_light_prox_read()
82 st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_OFFSET; in cros_ec_light_prox_read()
83 st->core.param.sensor_offset.flags = 0; in cros_ec_light_prox_read()
85 ret = cros_ec_motion_send_host_cmd(&st->core, 0); in cros_ec_light_prox_read()
90 st->core.calib[0].offset = in cros_ec_light_prox_read()
91 st->core.resp->sensor_offset.offset[0]; in cros_ec_light_prox_read()
93 *val = st->core.calib[idx].offset; in cros_ec_light_prox_read()
102 st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_RANGE; in cros_ec_light_prox_read()
103 st->core.param.sensor_range.data = EC_MOTION_SENSE_NO_VALUE; in cros_ec_light_prox_read()
105 ret = cros_ec_motion_send_host_cmd(&st->core, 0); in cros_ec_light_prox_read()
109 val64 = st->core.resp->sensor_range.ret; in cros_ec_light_prox_read()
115 ret = cros_ec_sensors_core_read(&st->core, chan, val, val2, in cros_ec_light_prox_read()
120 mutex_unlock(&st->core.cmd_lock); in cros_ec_light_prox_read()
131 int idx = chan->scan_index; in cros_ec_light_prox_write()
133 mutex_lock(&st->core.cmd_lock); in cros_ec_light_prox_write()
137 st->core.calib[idx].offset = val; in cros_ec_light_prox_write()
139 st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_OFFSET; in cros_ec_light_prox_write()
140 st->core.param.sensor_offset.flags = MOTION_SENSE_SET_OFFSET; in cros_ec_light_prox_write()
141 st->core.param.sensor_offset.offset[0] = in cros_ec_light_prox_write()
142 st->core.calib[0].offset; in cros_ec_light_prox_write()
143 st->core.param.sensor_offset.temp = in cros_ec_light_prox_write()
145 ret = cros_ec_motion_send_host_cmd(&st->core, 0); in cros_ec_light_prox_write()
148 st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_RANGE; in cros_ec_light_prox_write()
149 st->core.curr_range = (val << 16) | (val2 / 100); in cros_ec_light_prox_write()
150 st->core.param.sensor_range.data = st->core.curr_range; in cros_ec_light_prox_write()
151 ret = cros_ec_motion_send_host_cmd(&st->core, 0); in cros_ec_light_prox_write()
153 st->core.range_updated = true; in cros_ec_light_prox_write()
156 ret = cros_ec_sensors_core_write(&st->core, chan, val, val2, in cros_ec_light_prox_write()
161 mutex_unlock(&st->core.cmd_lock); in cros_ec_light_prox_write()
174 struct device *dev = &pdev->dev; in cros_ec_light_prox_probe()
182 return -ENOMEM; in cros_ec_light_prox_probe()
189 indio_dev->info = &cros_ec_light_prox_info; in cros_ec_light_prox_probe()
191 channel = state->channels; in cros_ec_light_prox_probe()
194 channel->info_mask_shared_by_all = in cros_ec_light_prox_probe()
196 channel->info_mask_shared_by_all_available = in cros_ec_light_prox_probe()
198 channel->scan_type.realbits = CROS_EC_SENSOR_BITS; in cros_ec_light_prox_probe()
199 channel->scan_type.storagebits = CROS_EC_SENSOR_BITS; in cros_ec_light_prox_probe()
200 channel->scan_type.shift = 0; in cros_ec_light_prox_probe()
201 channel->scan_index = 0; in cros_ec_light_prox_probe()
202 channel->ext_info = cros_ec_sensors_ext_info; in cros_ec_light_prox_probe()
203 channel->scan_type.sign = 'u'; in cros_ec_light_prox_probe()
206 switch (state->core.type) { in cros_ec_light_prox_probe()
208 channel->type = IIO_LIGHT; in cros_ec_light_prox_probe()
209 channel->info_mask_separate = in cros_ec_light_prox_probe()
215 channel->type = IIO_PROXIMITY; in cros_ec_light_prox_probe()
216 channel->info_mask_separate = in cros_ec_light_prox_probe()
222 dev_warn(dev, "Unknown motion sensor\n"); in cros_ec_light_prox_probe()
223 return -EINVAL; in cros_ec_light_prox_probe()
228 channel->type = IIO_TIMESTAMP; in cros_ec_light_prox_probe()
229 channel->channel = -1; in cros_ec_light_prox_probe()
230 channel->scan_index = 1; in cros_ec_light_prox_probe()
231 channel->scan_type.sign = 's'; in cros_ec_light_prox_probe()
232 channel->scan_type.realbits = 64; in cros_ec_light_prox_probe()
233 channel->scan_type.storagebits = 64; in cros_ec_light_prox_probe()
235 indio_dev->channels = state->channels; in cros_ec_light_prox_probe()
237 indio_dev->num_channels = CROS_EC_LIGHT_PROX_MAX_CHANNELS; in cros_ec_light_prox_probe()
239 state->core.read_ec_sensors_data = cros_ec_sensors_read_cmd; in cros_ec_light_prox_probe()
247 .name = "cros-ec-prox",
250 .name = "cros-ec-light",
258 .name = "cros-ec-light-prox",
266 MODULE_DESCRIPTION("ChromeOS EC light/proximity sensors driver");