Lines Matching +full:wp +full:- +full:content

1 // SPDX-License-Identifier: GPL-2.0
3 * ScioSense ENS160 multi-gas sensor driver
8 * https://www.sciosense.com/wp-content/uploads/2023/12/ENS160-Datasheet.pdf
112 iio_device_claim_direct_scoped(return -EBUSY, indio_dev) { in ens160_read_raw()
113 guard(mutex)(&data->mutex); in ens160_read_raw()
114 ret = regmap_bulk_read(data->regmap, chan->address, in ens160_read_raw()
115 &data->buf, sizeof(data->buf)); in ens160_read_raw()
118 *val = le16_to_cpu(data->buf); in ens160_read_raw()
123 switch (chan->channel2) { in ens160_read_raw()
135 return -EINVAL; in ens160_read_raw()
138 return -EINVAL; in ens160_read_raw()
146 ret = regmap_write(data->regmap, ENS160_REG_OPMODE, mode); in ens160_set_mode()
162 struct device *dev = regmap_get_device(data->regmap); in ens160_chip_init()
170 ret = regmap_bulk_read(data->regmap, ENS160_REG_PART_ID, &data->buf, in ens160_chip_init()
171 sizeof(data->buf)); in ens160_chip_init()
175 if (le16_to_cpu(data->buf) != ENS160_PART_ID) in ens160_chip_init()
176 return -ENODEV; in ens160_chip_init()
182 ret = regmap_write(data->regmap, ENS160_REG_COMMAND, in ens160_chip_init()
187 ret = regmap_write(data->regmap, ENS160_REG_COMMAND, in ens160_chip_init()
192 ret = regmap_bulk_read(data->regmap, ENS160_REG_GPR_READ4, in ens160_chip_init()
193 data->fw_version, sizeof(data->fw_version)); in ens160_chip_init()
197 dev_info(dev, "firmware version: %u.%u.%u\n", data->fw_version[2], in ens160_chip_init()
198 data->fw_version[1], data->fw_version[0]); in ens160_chip_init()
208 ret = regmap_read(data->regmap, ENS160_REG_DEVICE_STATUS, &status); in ens160_chip_init()
214 return -EINVAL; in ens160_chip_init()
249 struct iio_dev *indio_dev = pf->indio_dev; in ens160_trigger_handler()
253 guard(mutex)(&data->mutex); in ens160_trigger_handler()
255 ret = regmap_bulk_read(data->regmap, ENS160_REG_DATA_TVOC, in ens160_trigger_handler()
256 data->scan.chans, sizeof(data->scan.chans)); in ens160_trigger_handler()
260 iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, in ens160_trigger_handler()
261 pf->timestamp); in ens160_trigger_handler()
263 iio_trigger_notify_done(indio_dev->trig); in ens160_trigger_handler()
277 return regmap_set_bits(data->regmap, ENS160_REG_CONFIG, in ens160_set_trigger_state()
280 return regmap_clear_bits(data->regmap, ENS160_REG_CONFIG, in ens160_set_trigger_state()
291 struct device *dev = indio_dev->dev.parent; in ens160_setup_trigger()
295 trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, in ens160_setup_trigger()
298 return dev_err_probe(dev, -ENOMEM, in ens160_setup_trigger()
301 trig->ops = &ens160_trigger_ops; in ens160_setup_trigger()
308 indio_dev->trig = iio_trigger_get(trig); in ens160_setup_trigger()
314 indio_dev->name, in ens160_setup_trigger()
315 indio_dev->trig); in ens160_setup_trigger()
331 return -ENOMEM; in devm_ens160_core_probe()
334 data->regmap = regmap; in devm_ens160_core_probe()
336 indio_dev->name = name; in devm_ens160_core_probe()
337 indio_dev->info = &ens160_info; in devm_ens160_core_probe()
338 indio_dev->modes = INDIO_DIRECT_MODE; in devm_ens160_core_probe()
339 indio_dev->channels = ens160_channels; in devm_ens160_core_probe()
340 indio_dev->num_channels = ARRAY_SIZE(ens160_channels); in devm_ens160_core_probe()
353 mutex_init(&data->mutex); in devm_ens160_core_probe()