Lines Matching +full:motion +full:- +full:sensors
1 // SPDX-License-Identifier: GPL-2.0
3 * cros_ec_baro - Driver for barometer sensor behind CrosEC.
31 /* Shared by all sensors */
44 int idx = chan->scan_index; in cros_ec_baro_read()
46 mutex_lock(&st->core.cmd_lock); in cros_ec_baro_read()
59 st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_RANGE; in cros_ec_baro_read()
60 st->core.param.sensor_range.data = EC_MOTION_SENSE_NO_VALUE; in cros_ec_baro_read()
62 ret = cros_ec_motion_send_host_cmd(&st->core, 0); in cros_ec_baro_read()
66 *val = st->core.resp->sensor_range.ret; in cros_ec_baro_read()
68 /* scale * in_pressure_raw --> kPa */ in cros_ec_baro_read()
73 ret = cros_ec_sensors_core_read(&st->core, chan, val, val2, in cros_ec_baro_read()
78 mutex_unlock(&st->core.cmd_lock); in cros_ec_baro_read()
90 mutex_lock(&st->core.cmd_lock); in cros_ec_baro_write()
94 st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_RANGE; in cros_ec_baro_write()
95 st->core.param.sensor_range.data = val; in cros_ec_baro_write()
98 st->core.param.sensor_range.roundup = 1; in cros_ec_baro_write()
100 ret = cros_ec_motion_send_host_cmd(&st->core, 0); in cros_ec_baro_write()
102 st->core.range_updated = true; in cros_ec_baro_write()
103 st->core.curr_range = val; in cros_ec_baro_write()
107 ret = cros_ec_sensors_core_write(&st->core, chan, val, val2, in cros_ec_baro_write()
112 mutex_unlock(&st->core.cmd_lock); in cros_ec_baro_write()
125 struct device *dev = &pdev->dev; in cros_ec_baro_probe()
126 struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent); in cros_ec_baro_probe()
132 if (!ec_dev || !ec_dev->ec_dev) { in cros_ec_baro_probe()
134 return -EINVAL; in cros_ec_baro_probe()
139 return -ENOMEM; in cros_ec_baro_probe()
146 indio_dev->info = &cros_ec_baro_info; in cros_ec_baro_probe()
148 channel = state->channels; in cros_ec_baro_probe()
150 channel->info_mask_separate = BIT(IIO_CHAN_INFO_RAW); in cros_ec_baro_probe()
151 channel->info_mask_shared_by_all = in cros_ec_baro_probe()
154 channel->info_mask_shared_by_all_available = in cros_ec_baro_probe()
156 channel->scan_type.realbits = CROS_EC_SENSOR_BITS; in cros_ec_baro_probe()
157 channel->scan_type.storagebits = CROS_EC_SENSOR_BITS; in cros_ec_baro_probe()
158 channel->scan_type.shift = 0; in cros_ec_baro_probe()
159 channel->scan_index = 0; in cros_ec_baro_probe()
160 channel->ext_info = cros_ec_sensors_ext_info; in cros_ec_baro_probe()
161 channel->scan_type.sign = 'u'; in cros_ec_baro_probe()
164 switch (state->core.type) { in cros_ec_baro_probe()
166 channel->type = IIO_PRESSURE; in cros_ec_baro_probe()
169 dev_warn(dev, "Unknown motion sensor\n"); in cros_ec_baro_probe()
170 return -EINVAL; in cros_ec_baro_probe()
175 channel->type = IIO_TIMESTAMP; in cros_ec_baro_probe()
176 channel->channel = -1; in cros_ec_baro_probe()
177 channel->scan_index = 1; in cros_ec_baro_probe()
178 channel->scan_type.sign = 's'; in cros_ec_baro_probe()
179 channel->scan_type.realbits = 64; in cros_ec_baro_probe()
180 channel->scan_type.storagebits = 64; in cros_ec_baro_probe()
182 indio_dev->channels = state->channels; in cros_ec_baro_probe()
183 indio_dev->num_channels = CROS_EC_BARO_MAX_CHANNELS; in cros_ec_baro_probe()
185 state->core.read_ec_sensors_data = cros_ec_sensors_read_cmd; in cros_ec_baro_probe()
193 .name = "cros-ec-baro",
201 .name = "cros-ec-baro",